@sentio/sdk 2.15.5 → 2.15.6-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -80,6 +80,9 @@ export async function getCoinInfoWithFallback(type, network) {
80
80
  COIN_METADATA_CACHE.set(key, promise);
81
81
  }
82
82
  const meta = await promise;
83
+ if (meta === null) {
84
+ throw Error('Coin not existed ' + key);
85
+ }
83
86
  const parts = type.split(SPLITTER);
84
87
  return {
85
88
  token_type: { type: type, account_address: parts[0] },
@@ -1 +1 @@
1
- {"version":3,"file":"coin.js","sourceRoot":"","sources":["../../../src/sui/ext/coin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,SAAS,EAAc,MAAM,eAAe,CAAA;AAGrD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAA;AAE3D,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,IAAI,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAA;IAChC,IAAI;QACF,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,yFAAyF,CAAC,CAAA;QACnH,IAAI,GAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAS,CAAC,QAAQ,CAAA;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;KACnE;IAED,WAAW,CAAC,IAAI,CAAC,CAAA;AACnB,CAAC;AAUD,SAAS,WAAW,CAAC,IAAmB;IACtC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACvB,IAAI,IAAI,CAAC,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AAE,gFAAgF;YACzF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,2BAA2B;YACjC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,iEAAiE;YAC1E,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,QAAQ;aACtB;SACF;QACD;YACE,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,4BAA4B;YAClC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,wEAAwE;YACjF,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,UAAU;aACxB;SACF;KACF;CACF,CAAA","sourcesContent":["import { SimpleCoinInfo } from '../../move/ext/index.js'\nimport fetch from 'node-fetch'\nimport { SPLITTER } from '../../move/index.js'\nimport { getPriceByType } from '../../utils/index.js'\nimport { SuiChainId } from '../../core/chain.js'\nimport { validateAndNormalizeAddress } from '../utils.js'\nimport { getClient, SuiNetwork } from '../network.js'\nimport { CoinMetadata } from '@mysten/sui.js'\n\nconst WHITELISTED_COINS = new Map<string, SimpleCoinInfo>()\n\nexport async function initCoinList() {\n let list = DEFAULT_LIST.coinlist\n try {\n const resp = await fetch('https://raw.githubusercontent.com/solflare-wallet/sui-coinlist/master/sui-coinlist.json')\n list = ((await resp.json()) as any).coinlist\n } catch (e) {\n console.warn(\"Can't not fetch newest coin list, use default list\")\n }\n\n setCoinList(list)\n}\n\nexport interface SuiCoinInfo {\n network: string\n address: string\n symbol: string\n name: string\n decimals: number\n}\n\nfunction setCoinList(list: SuiCoinInfo[]) {\n for (const info of list) {\n if (info.address.startsWith('0x2::coin::Coin')) {\n continue\n }\n if (info.network !== 'mainnet') {\n continue\n }\n let bridge = 'native'\n if (info.name.includes('Celer')) {\n bridge = 'Celer'\n }\n if (info.name.includes('LayerZero')) {\n bridge = 'LayerZero'\n }\n if (info.name.includes('Wormhole')) {\n bridge = 'Wormhole'\n }\n WHITELISTED_COINS.set(info.address, {\n token_type: {\n type: info.address,\n account_address: info.address.split('::')[0],\n },\n symbol: info.symbol,\n decimals: info.decimals,\n bridge,\n })\n }\n}\n\nexport function whitelistCoins() {\n return WHITELISTED_COINS\n}\n\nexport function whiteListed(coin: string): boolean {\n const [addr, module, type] = coin.split(SPLITTER)\n const normalized = [validateAndNormalizeAddress(addr), module, type].join(SPLITTER)\n return WHITELISTED_COINS.has(normalized)\n}\n\nexport function getCoinInfo(type: string): SimpleCoinInfo {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n const parts = type.split('::')\n // TDDO retrive from network\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: parts[2],\n decimals: 8,\n bridge: 'native',\n }\n }\n return r\n}\n\nconst COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata>>()\n\nexport async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n network = network || SuiChainId.SUI_MAINNET\n const key = network + '_' + type\n let promise = COIN_METADATA_CACHE.get(key)\n if (!promise) {\n const client = getClient(network)\n promise = client.getCoinMetadata({ coinType: type })\n COIN_METADATA_CACHE.set(key, promise)\n }\n const meta = await promise\n\n const parts = type.split(SPLITTER)\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: meta.symbol,\n decimals: meta.decimals,\n bridge: 'native',\n }\n }\n return r\n}\n\nexport async function getPrice(coinType: string, timestamp: number): Promise<number> {\n if (!whiteListed(coinType)) {\n return 0.0\n }\n const date = new Date(timestamp / 1000)\n try {\n return (await getPriceByType(SuiChainId.SUI_MAINNET, coinType, date)) || 0\n } catch (error) {\n console.log(JSON.stringify(error))\n throw error\n }\n}\n\nexport async function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number) {\n const price = await getPrice(coinInfo.token_type.type, timestamp)\n const amount = n.scaleDown(coinInfo.decimals)\n return amount.multipliedBy(price)\n}\n\nconst DEFAULT_LIST = {\n name: 'Sui Coin List',\n timestamp: '2022-12-01T13:34:30.145Z',\n logoURI: 'https://s2.coinmarketcap.com/static/img/coins/128x128/20947.png',\n coinlist: [\n {\n network: 'mainnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'devnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'mainnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'devnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {},\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'testnet',\n address: '0x31b14985adb91360ed90a5786cb0956c83e7f275a8ae6123f38adab9d2b792b1::usdc::USDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {},\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'mainnet',\n address: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN',\n symbol: 'wETH',\n name: 'Wrapped Ethereum (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'mainnet',\n address: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',\n symbol: 'wUSDT',\n name: 'Tether (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'mainnet',\n address: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',\n symbol: 'wUSDC',\n name: 'USD Coin (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'mainnet',\n address: '0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN',\n symbol: 'wCELO',\n name: 'Celo (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'celo',\n },\n },\n {\n network: 'mainnet',\n address: '0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN',\n symbol: 'wMATIC',\n name: 'Wrapped Matic (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'matic-network',\n },\n },\n {\n network: 'mainnet',\n address: '0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN',\n symbol: 'wBNB',\n name: 'Wrapped BNB (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'mainnet',\n address: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',\n symbol: 'wBTC',\n name: 'Wrapped Bitcoin (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/1/large/bitcoin.png',\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'mainnet',\n address: '0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN',\n symbol: 'wAVAX',\n name: 'Wrapped AVAX (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png',\n tags: [],\n extensions: {\n coingeckoId: 'avalanche-2',\n },\n },\n {\n network: 'mainnet',\n address: '0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN',\n symbol: 'wFTM',\n name: 'Wrapped Fantom (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4001/large/Fantom_round.png',\n tags: [],\n extensions: {\n coingeckoId: 'fantom',\n },\n },\n {\n network: 'mainnet',\n address: '0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN',\n symbol: 'wGLMR',\n name: 'Wrapped GLMR (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/22459/large/glmr.png',\n tags: [],\n extensions: {\n coingeckoId: 'moonbeam',\n },\n },\n {\n network: 'mainnet',\n address: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',\n symbol: 'wSOL',\n name: 'Wrapped Solana (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4128/large/solana.png',\n tags: [],\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'mainnet',\n address: '0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN',\n symbol: 'wUSDCsol',\n name: 'USD Coin Solana (Wormhole)',\n decimals: 6,\n logoURI: 'https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n ],\n}\n"]}
1
+ {"version":3,"file":"coin.js","sourceRoot":"","sources":["../../../src/sui/ext/coin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,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YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,yBAAyB;YAC/B,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,2FAA2F;YACpG,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,aAAa;aAC3B;SACF;QACD;YACE,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,2BAA2B;YACjC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,uEAAuE;YAChF,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,QAAQ;aACtB;SACF;QACD;YACE,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,yBAAyB;YAC/B,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,gEAAgE;YACzE,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,UAAU;aACxB;SACF;QACD;YACE,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,2BAA2B;YACjC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,iEAAiE;YAC1E,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,QAAQ;aACtB;SACF;QACD;YACE,OAAO,EAAE,SAAS;YAClB,OAAO,EAAE,gFAAgF;YACzF,MAAM,EAAE,UAAU;YAClB,IAAI,EAAE,4BAA4B;YAClC,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,wEAAwE;YACjF,IAAI,EAAE,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,UAAU;aACxB;SACF;KACF;CACF,CAAA","sourcesContent":["import { SimpleCoinInfo } from '../../move/ext/index.js'\nimport fetch from 'node-fetch'\nimport { SPLITTER } from '../../move/index.js'\nimport { getPriceByType } from '../../utils/index.js'\nimport { SuiChainId } from '../../core/chain.js'\nimport { validateAndNormalizeAddress } from '../utils.js'\nimport { getClient, SuiNetwork } from '../network.js'\nimport { CoinMetadata } from '@mysten/sui.js'\n\nconst WHITELISTED_COINS = new Map<string, SimpleCoinInfo>()\n\nexport async function initCoinList() {\n let list = DEFAULT_LIST.coinlist\n try {\n const resp = await fetch('https://raw.githubusercontent.com/solflare-wallet/sui-coinlist/master/sui-coinlist.json')\n list = ((await resp.json()) as any).coinlist\n } catch (e) {\n console.warn(\"Can't not fetch newest coin list, use default list\")\n }\n\n setCoinList(list)\n}\n\nexport interface SuiCoinInfo {\n network: string\n address: string\n symbol: string\n name: string\n decimals: number\n}\n\nfunction setCoinList(list: SuiCoinInfo[]) {\n for (const info of list) {\n if (info.address.startsWith('0x2::coin::Coin')) {\n continue\n }\n if (info.network !== 'mainnet') {\n continue\n }\n let bridge = 'native'\n if (info.name.includes('Celer')) {\n bridge = 'Celer'\n }\n if (info.name.includes('LayerZero')) {\n bridge = 'LayerZero'\n }\n if (info.name.includes('Wormhole')) {\n bridge = 'Wormhole'\n }\n WHITELISTED_COINS.set(info.address, {\n token_type: {\n type: info.address,\n account_address: info.address.split('::')[0],\n },\n symbol: info.symbol,\n decimals: info.decimals,\n bridge,\n })\n }\n}\n\nexport function whitelistCoins() {\n return WHITELISTED_COINS\n}\n\nexport function whiteListed(coin: string): boolean {\n const [addr, module, type] = coin.split(SPLITTER)\n const normalized = [validateAndNormalizeAddress(addr), module, type].join(SPLITTER)\n return WHITELISTED_COINS.has(normalized)\n}\n\nexport function getCoinInfo(type: string): SimpleCoinInfo {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n const parts = type.split('::')\n // TDDO retrive from network\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: parts[2],\n decimals: 8,\n bridge: 'native',\n }\n }\n return r\n}\n\nconst COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata | null>>()\n\nexport async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {\n const r = WHITELISTED_COINS.get(type)\n if (!r) {\n network = network || SuiChainId.SUI_MAINNET\n const key = network + '_' + type\n let promise = COIN_METADATA_CACHE.get(key)\n if (!promise) {\n const client = getClient(network)\n promise = client.getCoinMetadata({ coinType: type })\n COIN_METADATA_CACHE.set(key, promise)\n }\n const meta = await promise\n if (meta === null) {\n throw Error('Coin not existed ' + key)\n }\n\n const parts = type.split(SPLITTER)\n return {\n token_type: { type: type, account_address: parts[0] },\n symbol: meta.symbol,\n decimals: meta.decimals,\n bridge: 'native',\n }\n }\n return r\n}\n\nexport async function getPrice(coinType: string, timestamp: number): Promise<number> {\n if (!whiteListed(coinType)) {\n return 0.0\n }\n const date = new Date(timestamp / 1000)\n try {\n return (await getPriceByType(SuiChainId.SUI_MAINNET, coinType, date)) || 0\n } catch (error) {\n console.log(JSON.stringify(error))\n throw error\n }\n}\n\nexport async function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number) {\n const price = await getPrice(coinInfo.token_type.type, timestamp)\n const amount = n.scaleDown(coinInfo.decimals)\n return amount.multipliedBy(price)\n}\n\nconst DEFAULT_LIST = {\n name: 'Sui Coin List',\n timestamp: '2022-12-01T13:34:30.145Z',\n logoURI: 'https://s2.coinmarketcap.com/static/img/coins/128x128/20947.png',\n coinlist: [\n {\n network: 'mainnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'devnet',\n address: '0x2::coin::Coin<0x2::sui::SUI>',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'mainnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'devnet',\n address: '0x2::sui::SUI',\n symbol: 'SUI',\n name: 'Sui Coin',\n decimals: 9,\n logoURI: 'https://cryptototem.com/wp-content/uploads/2022/08/SUI-logo.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'sui',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {},\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'testnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'testnet',\n address: '0x31b14985adb91360ed90a5786cb0956c83e7f275a8ae6123f38adab9d2b792b1::usdc::USDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestTEST',\n symbol: 'TEST',\n name: 'Test Token',\n logoURI: 'https://suiswap.app/images/token/suiswap-test.svg',\n tags: [],\n decimals: 8,\n extensions: {},\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDT',\n symbol: 'USDT',\n name: 'Tether',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n decimals: 8,\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestUSDC',\n symbol: 'USDC',\n name: 'USD Coin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestSOL',\n symbol: 'SOL',\n name: 'Solana',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/So11111111111111111111111111111111111111112/logo.png',\n decimals: 8,\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBTC',\n symbol: 'BTC',\n name: 'Bitcoin',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/9n4nbM75f5Ui33ZbPYXn59EwSgE8CGsHtAeTH5YFeJ9E/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestDAI',\n symbol: 'DAI',\n name: 'DAI',\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/FYpdBuyAHSbdaAyD1sKkxyLWbAP8uUW9h6uvdhK74ij1/logo.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'dai',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestBNB',\n symbol: 'BNB',\n name: 'BNB',\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'devnet',\n address: '0xe158e6df182971bb6c85eb9de9fbfb460b68163d19afc45873c8672b5cc521b2::TOKEN::TestETH',\n symbol: 'ETH',\n name: 'Ethereum',\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n decimals: 8,\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'mainnet',\n address: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN',\n symbol: 'wETH',\n name: 'Wrapped Ethereum (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/279/large/ethereum.png',\n tags: [],\n extensions: {\n coingeckoId: 'ethereum',\n },\n },\n {\n network: 'mainnet',\n address: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',\n symbol: 'wUSDT',\n name: 'Tether (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'tether',\n },\n },\n {\n network: 'mainnet',\n address: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN',\n symbol: 'wUSDC',\n name: 'USD Coin (Wormhole)',\n decimals: 6,\n logoURI:\n 'https://raw.githubusercontent.com/solana-labs/token-list/main/assets/mainnet/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/logo.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n {\n network: 'mainnet',\n address: '0xa198f3be41cda8c07b3bf3fee02263526e535d682499806979a111e88a5a8d0f::coin::COIN',\n symbol: 'wCELO',\n name: 'Celo (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/11090/large/InjXBNx9_400x400.jpg',\n tags: [],\n extensions: {\n coingeckoId: 'celo',\n },\n },\n {\n network: 'mainnet',\n address: '0xdbe380b13a6d0f5cdedd58de8f04625263f113b3f9db32b3e1983f49e2841676::coin::COIN',\n symbol: 'wMATIC',\n name: 'Wrapped Matic (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4713/large/matic-token-icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'matic-network',\n },\n },\n {\n network: 'mainnet',\n address: '0xb848cce11ef3a8f62eccea6eb5b35a12c4c2b1ee1af7755d02d7bd6218e8226f::coin::COIN',\n symbol: 'wBNB',\n name: 'Wrapped BNB (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/825/large/bnb-icon2_2x.png',\n tags: [],\n extensions: {\n coingeckoId: 'binancecoin',\n },\n },\n {\n network: 'mainnet',\n address: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',\n symbol: 'wBTC',\n name: 'Wrapped Bitcoin (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/1/large/bitcoin.png',\n tags: [],\n extensions: {\n coingeckoId: 'bitcoin',\n },\n },\n {\n network: 'mainnet',\n address: '0x1e8b532cca6569cab9f9b9ebc73f8c13885012ade714729aa3b450e0339ac766::coin::COIN',\n symbol: 'wAVAX',\n name: 'Wrapped AVAX (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/12559/large/Avalanche_Circle_RedWhite_Trans.png',\n tags: [],\n extensions: {\n coingeckoId: 'avalanche-2',\n },\n },\n {\n network: 'mainnet',\n address: '0x6081300950a4f1e2081580e919c210436a1bed49080502834950d31ee55a2396::coin::COIN',\n symbol: 'wFTM',\n name: 'Wrapped Fantom (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4001/large/Fantom_round.png',\n tags: [],\n extensions: {\n coingeckoId: 'fantom',\n },\n },\n {\n network: 'mainnet',\n address: '0x66f87084e49c38f76502d17f87d17f943f183bb94117561eb573e075fdc5ff75::coin::COIN',\n symbol: 'wGLMR',\n name: 'Wrapped GLMR (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/22459/large/glmr.png',\n tags: [],\n extensions: {\n coingeckoId: 'moonbeam',\n },\n },\n {\n network: 'mainnet',\n address: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',\n symbol: 'wSOL',\n name: 'Wrapped Solana (Wormhole)',\n decimals: 8,\n logoURI: 'https://assets.coingecko.com/coins/images/4128/large/solana.png',\n tags: [],\n extensions: {\n coingeckoId: 'solana',\n },\n },\n {\n network: 'mainnet',\n address: '0xb231fcda8bbddb31f2ef02e6161444aec64a514e2c89279584ac9806ce9cf037::coin::COIN',\n symbol: 'wUSDCsol',\n name: 'USD Coin Solana (Wormhole)',\n decimals: 6,\n logoURI: 'https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png',\n tags: [],\n extensions: {\n coingeckoId: 'usd-coin',\n },\n },\n ],\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.15.5",
3
+ "version": "2.15.6-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@coral-xyz/borsh": "^0.27.0",
48
- "@mysten/sui.js": "npm:@sentio/sui.js@^0.32.0-patch.1",
48
+ "@mysten/sui.js": "npm:@sentio/sui.js@^0.34.0",
49
49
  "@project-serum/anchor": "^0.26.0",
50
50
  "@sentio/bigdecimal": "^9.1.1-patch.3",
51
51
  "@sentio/ethers-v6": "^1.0.28",
52
52
  "@solana/web3.js": "^1.74.0",
53
53
  "@types/prettier": "^2.7.2",
54
- "aptos-sdk": "npm:aptos@^1.8.3",
54
+ "aptos-sdk": "npm:aptos@^1.8.5",
55
55
  "bs58": "^5.0.0",
56
56
  "chalk": "^5.2.0",
57
57
  "csv-parse": "^5.3.0",
@@ -70,8 +70,8 @@
70
70
  "typechain": "^8.0.0",
71
71
  "typedoc": "^0.24.1",
72
72
  "yaml": "^2.2.1",
73
- "@sentio/protos": "^2.15.5",
74
- "@sentio/runtime": "^2.15.5"
73
+ "@sentio/protos": "^2.15.6-rc.1",
74
+ "@sentio/runtime": "^2.15.6-rc.1"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -84,7 +84,7 @@ export function getCoinInfo(type: string): SimpleCoinInfo {
84
84
  return r
85
85
  }
86
86
 
87
- const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata>>()
87
+ const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata | null>>()
88
88
 
89
89
  export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {
90
90
  const r = WHITELISTED_COINS.get(type)
@@ -98,6 +98,9 @@ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork
98
98
  COIN_METADATA_CACHE.set(key, promise)
99
99
  }
100
100
  const meta = await promise
101
+ if (meta === null) {
102
+ throw Error('Coin not existed ' + key)
103
+ }
101
104
 
102
105
  const parts = type.split(SPLITTER)
103
106
  return {