Skip to content

Commit

Permalink
[NO CHANGELOG] [Add Funds Widget] Add native currency in chain type (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyounglee authored Sep 30, 2024
1 parent bdf1787 commit 53b2812
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ type SquidChain = {
chainName: string;
chainIconURI: string;
chainType: string;
nativeCurrency: SquidNativeCurrency;
};

type SquidChains = {
chains: SquidChain[];
};
type SquidChains = {
chains: SquidChain[];
};

export type SquidNativeCurrency = {
name: string;
symbol: string;
decimals: number;
icon: string;
};

export const fetchChains = async (): Promise<Chain[]> => {
const url = `${SQUID_API_BASE_URL}/chains`;
Expand All @@ -25,11 +33,16 @@ export const fetchChains = async (): Promise<Chain[]> => {

const data: SquidChains = await response.json();

const chains = data.chains.map((chain: SquidChain) => ({
return data.chains.map((chain: SquidChain) => ({
id: chain.chainId.toString(),
name: chain.chainName,
iconUrl: chain.chainIconURI,
type: chain.chainType,
nativeCurrency: {
name: chain.nativeCurrency.name,
symbol: chain.nativeCurrency.symbol,
decimals: chain.nativeCurrency.decimals,
iconUrl: chain.nativeCurrency.icon,
},
}));
return chains;
};
8 changes: 8 additions & 0 deletions packages/checkout/widgets-lib/src/widgets/add-funds/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ export type Chain = {
type: string;
name: string;
iconUrl: string;
nativeCurrency: NativeCurrency;
};

export type NativeCurrency = {
name: string;
symbol: string;
decimals: number;
iconUrl:string;
};

export type AmountData = {
Expand Down

0 comments on commit 53b2812

Please sign in to comment.