diff --git a/src/alexSDK.ts b/src/alexSDK.ts index 40a4ee8..ca22bfc 100644 --- a/src/alexSDK.ts +++ b/src/alexSDK.ts @@ -16,6 +16,7 @@ import { broadcastSponsoredTx, isSponsoredSwapEnabled, } from './utils/sponsoredTx'; +import { fetchTokenList, TokenInfo } from './utils/tokenlist'; export { SponsoredTxError, SponsoredTxErrorCode } from './utils/sponsoredTx'; export class AlexSDK { @@ -109,4 +110,8 @@ export class AlexSDK { isSponsoredSwapEnabled(): Promise { return isSponsoredSwapEnabled().catch(() => false); } + + fetchTokenList(): Promise { + return fetchTokenList() + } } diff --git a/src/utils/tokenlist.ts b/src/utils/tokenlist.ts new file mode 100644 index 0000000..dd5f729 --- /dev/null +++ b/src/utils/tokenlist.ts @@ -0,0 +1,17 @@ +export type TokenInfo = { + type: 'fungibleToken', + id: string, + displayPrecision: number, + icon: string, + availableInSwap: boolean, + contractAddress: string, + decimals: number +} + +export function fetchTokenList(): Promise { + return fetch('https://token-list.alexlab.co', { + mode: 'cors' + }) + .then(res => res.json()) + .then(data => data.tokens) +}