Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve the coingeckoId issue #25

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/ibc-asset-list/hooks/queries/usePrices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ type CoinGeckoUSD = { usd: number };
type CoinGeckoUSDResponse = Record<CoinGeckoId, CoinGeckoUSD>;

const getAssetsWithGeckoIds = (assets: Asset[]) => {
return assets // .filter((asset) => !!asset?.coingeckoId);
return assets.filter((asset) => !!asset?.coingeckoId);
};

const getGeckoIds = (assets: Asset[]) => {
return assets.map((asset) => asset.coingeckoId ?? asset.name.toLowerCase()) as string[];
return assets.map((asset) => asset.coingeckoId) as string[];
};

const formatPrices = (
prices: CoinGeckoUSDResponse,
assets: Asset[]
): Record<string, number> => {
return Object.entries(prices).reduce((priceHash, cur) => {
const denom = assets.find((asset) => asset.coingeckoId === cur[0] || asset.name.toLowerCase() === cur[0])!.base;
const denom = assets.find((asset) => asset.coingeckoId === cur[0])!.base;
return { ...priceHash, [denom]: cur[1].usd };
}, {});
};
Expand Down
1 change: 1 addition & 0 deletions examples/ibc-asset-list/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"@chain-registry/assets": "^1.70.32",
"@chain-registry/types": "^0.50.13",
"@chain-registry/v2": "^1.71.132",
"@cosmjs/stargate": "^0.32.3",
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
Expand Down
17 changes: 17 additions & 0 deletions examples/ibc-asset-list/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ __metadata:
languageName: node
linkType: hard

"@chain-registry/v2-types@npm:^0.53.77":
version: 0.53.77
resolution: "@chain-registry/v2-types@npm:0.53.77"
checksum: 10c0/b7b0b7d3ca9436706c8143a8f6cd322f5e663675bae5d08e5da065a1d4f0bf0e9163b931dbf887e8a44567fe797e571f94f6b0d2dc0e6379819827d6a9345e8d
languageName: node
linkType: hard

"@chain-registry/v2@npm:1.71.71":
version: 1.71.71
resolution: "@chain-registry/v2@npm:1.71.71"
Expand All @@ -160,6 +167,15 @@ __metadata:
languageName: node
linkType: hard

"@chain-registry/v2@npm:^1.71.132":
version: 1.71.132
resolution: "@chain-registry/v2@npm:1.71.132"
dependencies:
"@chain-registry/v2-types": "npm:^0.53.77"
checksum: 10c0/1d5cd51546e36f211b1248e52c52345a073dd91233e58bbcce5e0ac7decf666f32782bfa9a335a89501be7832a523c964dcd36b84c0cedd36bbcf6fbe59b0dd9
languageName: node
linkType: hard

"@confio/ics23@npm:^0.6.8":
version: 0.6.8
resolution: "@confio/ics23@npm:0.6.8"
Expand Down Expand Up @@ -1073,6 +1089,7 @@ __metadata:
dependencies:
"@chain-registry/assets": "npm:^1.70.32"
"@chain-registry/types": "npm:^0.50.13"
"@chain-registry/v2": "npm:^1.71.132"
"@cosmjs/stargate": "npm:^0.32.3"
"@emotion/react": "npm:11.10.6"
"@emotion/styled": "npm:11.10.6"
Expand Down
Loading