-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NO CHANGELOG] [Add Funds Widget] Add funds/improve get from amount (#…
- Loading branch information
1 parent
2d6eade
commit b2bd368
Showing
9 changed files
with
186 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/checkout/widgets-lib/src/widgets/add-funds/functions/fetchTokens.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Token } from '../types'; | ||
import { SQUID_SDK_BASE_URL } from '../utils/config'; | ||
|
||
type SquidTokenResponse = { | ||
chainId: number; | ||
address: string; | ||
decimals: number; | ||
symbol?: string; | ||
name?: string; | ||
usdPrice: number; | ||
logoURI: string; | ||
}; | ||
|
||
type SquidTokensResponse = { | ||
tokens: SquidTokenResponse[]; | ||
}; | ||
|
||
export const fetchTokens = async (integratorId:string): Promise<Token[]> => { | ||
const url = `${SQUID_SDK_BASE_URL}/v2/sdk-info`; | ||
|
||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
'Content-Type': 'application/json', | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
'x-integrator-id': integratorId, | ||
}, | ||
}); | ||
|
||
const data: SquidTokensResponse = await response.json(); | ||
|
||
return data.tokens.map((tokenResponse: SquidTokenResponse) => ({ | ||
chainId: tokenResponse.chainId.toString(), | ||
address: tokenResponse.address, | ||
decimals: tokenResponse.decimals, | ||
symbol: tokenResponse.symbol, | ||
name: tokenResponse.name, | ||
usdPrice: tokenResponse.usdPrice, | ||
iconUrl: tokenResponse.logoURI, | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.