Skip to content

Commit

Permalink
fix: unexpected ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Envoy-VC committed Jun 26, 2024
1 parent 3520e85 commit 2a74db4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/www/src/components/navbar/connect-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const ConnectButton = () => {
className='h-9 w-9 rounded-full'
src={
ensAvatar ??
`https://api.dicebear.com/8.x/shapes/svg?seed=${address}`
`https://api.dicebear.com/8.x/shapes/svg?seed=${address ?? ''}`
}
/>
)}
Expand Down
2 changes: 0 additions & 2 deletions apps/www/src/lib/hooks/use-invoice-form.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { create } from 'zustand';

export enum InvoiceFormStep {
Expand Down
26 changes: 17 additions & 9 deletions apps/www/src/lib/invoice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {
CurrencyManager,
NativeCurrencyInput,
getSupportedERC777Tokens,
type ERC20Currency,
type ERC777Currency,
type NativeCurrencyInput,
} from '@requestnetwork/currency';
import { RequestLogicTypes } from '@requestnetwork/types';
import { z } from 'zod';
Expand Down Expand Up @@ -200,6 +201,13 @@ export const ChainNames = [
...DeclarativeChains,
] as const;

export type CurrencyWithMeta<T, Type> = T & {
type: Type;
id: string;
hash: string;
meta: unknown;
};

export const getCurrencies = (
type: RequestLogicTypes.CURRENCY,
network?: (typeof ChainNames)[number]['id']
Expand All @@ -212,23 +220,23 @@ export const getCurrencies = (
) {
const c = allCurrencies.filter(
(currency) => currency.type === type
) as (NativeCurrencyInput & {
id: string;
hash: string;
meta: unknown;
})[];
) as CurrencyWithMeta<NativeCurrencyInput, typeof type>[];
if (network) {
return c.filter((currency) => currency.network === network);
}
return c;
} else if (type === RequestLogicTypes.CURRENCY.ERC20) {
const c = allCurrencies.filter((currency) => currency.type === type);
const c = allCurrencies.filter(
(currency) => currency.type === type
) as CurrencyWithMeta<ERC20Currency, typeof type>[];
if (network) {
return c.filter((currency) => currency.network === network);
}
return c;
} else if (type === RequestLogicTypes.CURRENCY.ERC777) {
const c = allCurrencies.filter((currency) => currency.type === type);
const c = allCurrencies.filter(
(currency) => currency.type === type
) as CurrencyWithMeta<ERC777Currency, typeof type>[];
if (network) {
return c.filter((currency) => currency.network === network);
}
Expand Down

0 comments on commit 2a74db4

Please sign in to comment.