Skip to content

Commit

Permalink
chore: updates per PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-moore committed Feb 14, 2024
1 parent d3f0306 commit e22f807
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions packages/sdk-ui-ts/src/services/ibc/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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[]
}

Expand Down

0 comments on commit e22f807

Please sign in to comment.