diff --git a/packages/sdk-ui-ts/src/services/ibc/tokens.ts b/packages/sdk-ui-ts/src/services/ibc/tokens.ts index d5cc303cf..1adb4d2cf 100644 --- a/packages/sdk-ui-ts/src/services/ibc/tokens.ts +++ b/packages/sdk-ui-ts/src/services/ibc/tokens.ts @@ -17,7 +17,9 @@ type IbcTokenMetadata = { isTrading: boolean } -const ibcTokenMetadataApi = new HttpRestClient('https://api.tfm.com/api/v1/') +const ibcTokenMetadataApi = new HttpRestClient('https://api.tfm.com/api/v1/', { + timeout: 2000, +}) const TOKEN_METADATA_PATH = 'ibc/chain/injective-1/tokens' @@ -49,24 +51,9 @@ function ibcTokenMetadataToToken( }) } -function timeout(ms: number) { - return new Promise((_, reject) => - setTimeout(() => reject(new Error('Request timed out')), ms), - ) -} - ;(async () => { try { - const ibcTokenMetadataResponse = ibcTokenMetadataApi.get( - TOKEN_METADATA_PATH, - ) as Promise<{ - data: IbcTokenMetadata[] - }> - - const response = (await Promise.race([ - ibcTokenMetadataResponse, - timeout(2000), - ])) as { + const response = (await ibcTokenMetadataApi.get(TOKEN_METADATA_PATH)) as { data: IbcTokenMetadata[] }