@sentio/sdk 2.15.2 → 2.15.3-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.
@@ -1,8 +1,6 @@
1
1
  import { normalizeLabels } from '../index.js';
2
- import { JsonRpcProvider, Connection, } from '@mysten/sui.js';
2
+ import { getClient } from './network.js';
3
3
  import { defaultMoveCoder } from './move-coder.js';
4
- import { Endpoints } from '@sentio/runtime';
5
- import { ServerError, Status } from 'nice-grpc';
6
4
  import { MoveAccountContext, MoveContext } from '../move/index.js';
7
5
  export class SuiContext extends MoveContext {
8
6
  moduleName;
@@ -44,11 +42,7 @@ export class SuiContext extends MoveContext {
44
42
  };
45
43
  }
46
44
  get client() {
47
- const chainServer = Endpoints.INSTANCE.chainServer.get(this.network);
48
- if (!chainServer) {
49
- throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided');
50
- }
51
- return new JsonRpcProvider(new Connection({ fullnode: chainServer }));
45
+ return getClient(this.network);
52
46
  }
53
47
  }
54
48
  export class SuiObjectsContext extends MoveAccountContext {
@@ -82,11 +76,7 @@ export class SuiObjectsContext extends MoveAccountContext {
82
76
  };
83
77
  }
84
78
  get client() {
85
- const chainServer = Endpoints.INSTANCE.chainServer.get(this.network);
86
- if (!chainServer) {
87
- throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided');
88
- }
89
- return new JsonRpcProvider(new Connection({ fullnode: chainServer }));
79
+ return getClient(this.network);
90
80
  }
91
81
  getTimestamp() {
92
82
  return this.timestamp.getDate();
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,eAAe,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAEL,eAAe,EACf,UAAU,GAIX,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAa,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,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AAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;IAED,IAAI,MAAM;QACR,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACpE,IAAI,CAAC,WAAW,EAAE;YAChB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;SACpE;QACD,OAAO,IAAI,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;IACvE,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, normalizeLabels } from '../index.js'\nimport { SuiNetwork } from './network.js'\nimport {\n SuiTransactionBlockResponse,\n JsonRpcProvider,\n Connection,\n SuiEvent,\n SuiMoveNormalizedModule,\n SuiMoveObject,\n} from '@mysten/sui.js'\nimport { MoveCoder, defaultMoveCoder } from './move-coder.js'\nimport { Endpoints } from '@sentio/runtime'\nimport { ServerError, Status } from 'nice-grpc'\nimport { MoveAccountContext, MoveContext } from '../move/index.js'\n\nexport class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {\n moduleName: string\n timestamp: Date\n slot: bigint\n transaction: SuiTransactionBlockResponse\n eventIndex: number\n coder: MoveCoder\n\n constructor(\n moduleName: string,\n network: SuiNetwork,\n address: string,\n timestamp: Date,\n slot: bigint,\n transaction: SuiTransactionBlockResponse,\n eventIndex: number,\n baseLabels: Labels | undefined\n ) {\n super(baseLabels)\n this.address = address.toLowerCase()\n this.network = network\n this.moduleName = moduleName\n this.timestamp = timestamp\n this.slot = slot\n this.eventIndex = eventIndex\n this.coder = defaultMoveCoder(network)\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getChainId() {\n return this.network\n }\n\n getTimestamp(): number {\n return this.timestamp.getDate()\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: this.transaction?.digest || '', // TODO\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n get client(): JsonRpcProvider {\n const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)\n if (!chainServer) {\n throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')\n }\n return new JsonRpcProvider(new Connection({ fullnode: chainServer }))\n }\n}\n\nexport class SuiObjectsContext extends MoveAccountContext<\n SuiNetwork,\n SuiMoveNormalizedModule,\n SuiEvent | SuiMoveObject\n> {\n address: string\n network: SuiNetwork\n slot: bigint\n timestamp: Date\n coder: MoveCoder\n\n constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date, baseLabels: Labels | undefined) {\n super(baseLabels)\n this.address = address\n this.network = network\n this.slot = slot\n this.timestamp = timestamp\n this.coder = defaultMoveCoder(network)\n }\n\n getChainId() {\n return this.network\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: 'objects',\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: '',\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n get client(): JsonRpcProvider {\n const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)\n if (!chainServer) {\n throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')\n }\n return new JsonRpcProvider(new Connection({ fullnode: chainServer }))\n }\n\n getTimestamp(): number {\n return this.timestamp.getDate()\n }\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["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CAAC;IAED,IAAI,MAAM;QACR,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, normalizeLabels } from '../index.js'\nimport { getClient, SuiNetwork } from './network.js'\nimport {\n SuiTransactionBlockResponse,\n JsonRpcProvider,\n SuiEvent,\n SuiMoveNormalizedModule,\n SuiMoveObject,\n} from '@mysten/sui.js'\nimport { MoveCoder, defaultMoveCoder } from './move-coder.js'\nimport { MoveAccountContext, MoveContext } from '../move/index.js'\n\nexport class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {\n moduleName: string\n timestamp: Date\n slot: bigint\n transaction: SuiTransactionBlockResponse\n eventIndex: number\n coder: MoveCoder\n\n constructor(\n moduleName: string,\n network: SuiNetwork,\n address: string,\n timestamp: Date,\n slot: bigint,\n transaction: SuiTransactionBlockResponse,\n eventIndex: number,\n baseLabels: Labels | undefined\n ) {\n super(baseLabels)\n this.address = address.toLowerCase()\n this.network = network\n this.moduleName = moduleName\n this.timestamp = timestamp\n this.slot = slot\n this.eventIndex = eventIndex\n this.coder = defaultMoveCoder(network)\n if (transaction) {\n this.transaction = transaction\n }\n }\n\n getChainId() {\n return this.network\n }\n\n getTimestamp(): number {\n return this.timestamp.getDate()\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: this.moduleName,\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: this.transaction?.digest || '', // TODO\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n get client(): JsonRpcProvider {\n return getClient(this.network)\n }\n}\n\nexport class SuiObjectsContext extends MoveAccountContext<\n SuiNetwork,\n SuiMoveNormalizedModule,\n SuiEvent | SuiMoveObject\n> {\n address: string\n network: SuiNetwork\n slot: bigint\n timestamp: Date\n coder: MoveCoder\n\n constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date, baseLabels: Labels | undefined) {\n super(baseLabels)\n this.address = address\n this.network = network\n this.slot = slot\n this.timestamp = timestamp\n this.coder = defaultMoveCoder(network)\n }\n\n getChainId() {\n return this.network\n }\n\n getMetaDataInternal(name: string, labels: Labels): RecordMetaData {\n return {\n address: this.address,\n contractName: 'objects',\n blockNumber: this.slot,\n transactionIndex: 0,\n transactionHash: '',\n logIndex: 0,\n chainId: this.getChainId(),\n name: name,\n labels: normalizeLabels(labels),\n }\n }\n\n get client(): JsonRpcProvider {\n return getClient(this.network)\n }\n\n getTimestamp(): number {\n return this.timestamp.getDate()\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import { SimpleCoinInfo } from '../../move/ext/index.js';
2
+ import { SuiNetwork } from '../network.js';
2
3
  export declare function initCoinList(): Promise<void>;
3
4
  export interface SuiCoinInfo {
4
5
  network: string;
@@ -10,5 +11,6 @@ export interface SuiCoinInfo {
10
11
  export declare function whitelistCoins(): Map<string, SimpleCoinInfo>;
11
12
  export declare function whiteListed(coin: string): boolean;
12
13
  export declare function getCoinInfo(type: string): SimpleCoinInfo;
14
+ export declare function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo>;
13
15
  export declare function getPrice(coinType: string, timestamp: number): Promise<number>;
14
16
  export declare function calculateValueInUsd(n: bigint, coinInfo: SimpleCoinInfo, timestamp: number): Promise<import("@sentio/bigdecimal").BigDecimal>;
@@ -3,6 +3,7 @@ import { SPLITTER } from '../../move/index.js';
3
3
  import { getPriceByType } from '../../utils/index.js';
4
4
  import { SuiChainId } from '../../core/chain.js';
5
5
  import { validateAndNormalizeAddress } from '../utils.js';
6
+ import { getClient } from '../network.js';
6
7
  const WHITELISTED_COINS = new Map();
7
8
  export async function initCoinList() {
8
9
  let list = DEFAULT_LIST.coinlist;
@@ -66,6 +67,29 @@ export function getCoinInfo(type) {
66
67
  }
67
68
  return r;
68
69
  }
70
+ const COIN_METADATA_CACHE = new Map();
71
+ export async function getCoinInfoWithFallback(type, network) {
72
+ const r = WHITELISTED_COINS.get(type);
73
+ if (!r) {
74
+ network = network || SuiChainId.SUI_MAINNET;
75
+ const key = network + '_' + type;
76
+ let promise = COIN_METADATA_CACHE.get(key);
77
+ if (!promise) {
78
+ const client = getClient(network);
79
+ promise = client.getCoinMetadata({ coinType: type });
80
+ COIN_METADATA_CACHE.set(key, promise);
81
+ }
82
+ const meta = await promise;
83
+ const parts = type.split(SPLITTER);
84
+ return {
85
+ token_type: { type: type, account_address: parts[0] },
86
+ symbol: meta.symbol,
87
+ decimals: meta.decimals,
88
+ bridge: 'native',
89
+ };
90
+ }
91
+ return r;
92
+ }
69
93
  export async function getPrice(coinType, timestamp) {
70
94
  if (!whiteListed(coinType)) {
71
95
  return 0.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;AAEzD,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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ACd,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'\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\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,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,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R,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>>()\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"]}
@@ -7,3 +7,4 @@ export { BUILTIN_TYPES } from '../move/types.js';
7
7
  export * from './move-coder.js';
8
8
  export { SuiPlugin } from './sui-plugin.js';
9
9
  export { ModuleClient } from './module-client.js';
10
+ export { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js';
package/lib/sui/index.js CHANGED
@@ -6,4 +6,5 @@ export { BUILTIN_TYPES } from '../move/types.js';
6
6
  export * from './move-coder.js';
7
7
  export { SuiPlugin } from './sui-plugin.js';
8
8
  export { ModuleClient } from './module-client.js';
9
+ export { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAElC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA","sourcesContent":["export * from './sui-processor.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\nexport { BUILTIN_TYPES } from '../move/types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n\nexport { ModuleClient } from './module-client.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sui/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAElC,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAG3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,cAAc,iBAAiB,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export * from './sui-processor.js'\n\nexport * from './network.js'\nexport * from './context.js'\nexport * from './models.js'\n\nexport type { SuiAddress } from './move-types.js'\nexport { BUILTIN_TYPES } from '../move/types.js'\n\nexport * from './move-coder.js'\n\nexport { SuiPlugin } from './sui-plugin.js'\n\nexport { ModuleClient } from './module-client.js'\n\nexport { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js'\n"]}
@@ -1,7 +1,9 @@
1
1
  import { SuiChainId } from '../core/chain.js';
2
+ import { JsonRpcProvider } from '@mysten/sui.js';
2
3
  export type SuiNetwork = SuiChainId;
3
4
  export declare const SuiNetwork: {
4
5
  readonly MAIN_NET: SuiChainId.SUI_MAINNET;
5
6
  readonly TEST_NET: SuiChainId.SUI_TESTNET;
6
7
  readonly DEV_NET: SuiChainId.SUI_DEVNET;
7
8
  };
9
+ export declare function getClient(network: SuiNetwork): JsonRpcProvider;
@@ -1,7 +1,17 @@
1
1
  import { SuiChainId } from '../core/chain.js';
2
+ import { Connection, JsonRpcProvider } from '@mysten/sui.js';
3
+ import { Endpoints } from '@sentio/runtime';
4
+ import { ServerError, Status } from 'nice-grpc';
2
5
  export const SuiNetwork = {
3
6
  MAIN_NET: SuiChainId.SUI_MAINNET,
4
7
  TEST_NET: SuiChainId.SUI_TESTNET,
5
8
  DEV_NET: SuiChainId.SUI_DEVNET,
6
9
  };
10
+ export function getClient(network) {
11
+ const chainServer = Endpoints.INSTANCE.chainServer.get(network);
12
+ if (!chainServer) {
13
+ throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided');
14
+ }
15
+ return new JsonRpcProvider(new Connection({ fullnode: chainServer }));
16
+ }
7
17
  //# sourceMappingURL=network.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/sui/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAG7C,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,QAAQ,EAAE,UAAU,CAAC,WAAW;IAChC,QAAQ,EAAE,UAAU,CAAC,WAAW;IAChC,OAAO,EAAE,UAAU,CAAC,UAAU;CAC/B,CAAA","sourcesContent":["import { SuiChainId } from '../core/chain.js'\n\nexport type SuiNetwork = SuiChainId\nexport const SuiNetwork = <const>{\n MAIN_NET: SuiChainId.SUI_MAINNET,\n TEST_NET: SuiChainId.SUI_TESTNET,\n DEV_NET: SuiChainId.SUI_DEVNET,\n}\n"]}
1
+ {"version":3,"file":"network.js","sourceRoot":"","sources":["../../src/sui/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAG/C,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,QAAQ,EAAE,UAAU,CAAC,WAAW;IAChC,QAAQ,EAAE,UAAU,CAAC,WAAW;IAChC,OAAO,EAAE,UAAU,CAAC,UAAU;CAC/B,CAAA;AAED,MAAM,UAAU,SAAS,CAAC,OAAmB;IAC3C,MAAM,WAAW,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC/D,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAA;KACpE;IACD,OAAO,IAAI,eAAe,CAAC,IAAI,UAAU,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC,CAAA;AACvE,CAAC","sourcesContent":["import { SuiChainId } from '../core/chain.js'\nimport { Connection, JsonRpcProvider } from '@mysten/sui.js'\nimport { Endpoints } from '@sentio/runtime'\nimport { ServerError, Status } from 'nice-grpc'\n\nexport type SuiNetwork = SuiChainId\nexport const SuiNetwork = <const>{\n MAIN_NET: SuiChainId.SUI_MAINNET,\n TEST_NET: SuiChainId.SUI_TESTNET,\n DEV_NET: SuiChainId.SUI_DEVNET,\n}\n\nexport function getClient(network: SuiNetwork): JsonRpcProvider {\n const chainServer = Endpoints.INSTANCE.chainServer.get(network)\n if (!chainServer) {\n throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')\n }\n return new JsonRpcProvider(new Connection({ fullnode: chainServer }))\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.15.2",
3
+ "version": "2.15.3-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -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.2",
74
- "@sentio/runtime": "^2.15.2"
73
+ "@sentio/protos": "^2.15.3-rc.1",
74
+ "@sentio/runtime": "^2.15.3-rc.1"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "tsup": "npm:@sentio/tsup@^6.7.0"
@@ -1,17 +1,14 @@
1
1
  import { RecordMetaData } from '@sentio/protos'
2
2
  import { type Labels, normalizeLabels } from '../index.js'
3
- import { SuiNetwork } from './network.js'
3
+ import { getClient, SuiNetwork } from './network.js'
4
4
  import {
5
5
  SuiTransactionBlockResponse,
6
6
  JsonRpcProvider,
7
- Connection,
8
7
  SuiEvent,
9
8
  SuiMoveNormalizedModule,
10
9
  SuiMoveObject,
11
10
  } from '@mysten/sui.js'
12
11
  import { MoveCoder, defaultMoveCoder } from './move-coder.js'
13
- import { Endpoints } from '@sentio/runtime'
14
- import { ServerError, Status } from 'nice-grpc'
15
12
  import { MoveAccountContext, MoveContext } from '../move/index.js'
16
13
 
17
14
  export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule, SuiEvent | SuiMoveObject> {
@@ -68,11 +65,7 @@ export class SuiContext extends MoveContext<SuiNetwork, SuiMoveNormalizedModule,
68
65
  }
69
66
 
70
67
  get client(): JsonRpcProvider {
71
- const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)
72
- if (!chainServer) {
73
- throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
74
- }
75
- return new JsonRpcProvider(new Connection({ fullnode: chainServer }))
68
+ return getClient(this.network)
76
69
  }
77
70
  }
78
71
 
@@ -115,11 +108,7 @@ export class SuiObjectsContext extends MoveAccountContext<
115
108
  }
116
109
 
117
110
  get client(): JsonRpcProvider {
118
- const chainServer = Endpoints.INSTANCE.chainServer.get(this.network)
119
- if (!chainServer) {
120
- throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
121
- }
122
- return new JsonRpcProvider(new Connection({ fullnode: chainServer }))
111
+ return getClient(this.network)
123
112
  }
124
113
 
125
114
  getTimestamp(): number {
@@ -4,6 +4,8 @@ import { SPLITTER } from '../../move/index.js'
4
4
  import { getPriceByType } from '../../utils/index.js'
5
5
  import { SuiChainId } from '../../core/chain.js'
6
6
  import { validateAndNormalizeAddress } from '../utils.js'
7
+ import { getClient, SuiNetwork } from '../network.js'
8
+ import { CoinMetadata } from '@mysten/sui.js'
7
9
 
8
10
  const WHITELISTED_COINS = new Map<string, SimpleCoinInfo>()
9
11
 
@@ -82,6 +84,32 @@ export function getCoinInfo(type: string): SimpleCoinInfo {
82
84
  return r
83
85
  }
84
86
 
87
+ const COIN_METADATA_CACHE = new Map<string, Promise<CoinMetadata>>()
88
+
89
+ export async function getCoinInfoWithFallback(type: string, network?: SuiNetwork): Promise<SimpleCoinInfo> {
90
+ const r = WHITELISTED_COINS.get(type)
91
+ if (!r) {
92
+ network = network || SuiChainId.SUI_MAINNET
93
+ const key = network + '_' + type
94
+ let promise = COIN_METADATA_CACHE.get(key)
95
+ if (!promise) {
96
+ const client = getClient(network)
97
+ promise = client.getCoinMetadata({ coinType: type })
98
+ COIN_METADATA_CACHE.set(key, promise)
99
+ }
100
+ const meta = await promise
101
+
102
+ const parts = type.split(SPLITTER)
103
+ return {
104
+ token_type: { type: type, account_address: parts[0] },
105
+ symbol: meta.symbol,
106
+ decimals: meta.decimals,
107
+ bridge: 'native',
108
+ }
109
+ }
110
+ return r
111
+ }
112
+
85
113
  export async function getPrice(coinType: string, timestamp: number): Promise<number> {
86
114
  if (!whiteListed(coinType)) {
87
115
  return 0.0
package/src/sui/index.ts CHANGED
@@ -12,3 +12,5 @@ export * from './move-coder.js'
12
12
  export { SuiPlugin } from './sui-plugin.js'
13
13
 
14
14
  export { ModuleClient } from './module-client.js'
15
+
16
+ export { validateAndNormalizeAddress, isValidSuiAddress } from './utils.js'
@@ -1,4 +1,7 @@
1
1
  import { SuiChainId } from '../core/chain.js'
2
+ import { Connection, JsonRpcProvider } from '@mysten/sui.js'
3
+ import { Endpoints } from '@sentio/runtime'
4
+ import { ServerError, Status } from 'nice-grpc'
2
5
 
3
6
  export type SuiNetwork = SuiChainId
4
7
  export const SuiNetwork = <const>{
@@ -6,3 +9,11 @@ export const SuiNetwork = <const>{
6
9
  TEST_NET: SuiChainId.SUI_TESTNET,
7
10
  DEV_NET: SuiChainId.SUI_DEVNET,
8
11
  }
12
+
13
+ export function getClient(network: SuiNetwork): JsonRpcProvider {
14
+ const chainServer = Endpoints.INSTANCE.chainServer.get(network)
15
+ if (!chainServer) {
16
+ throw new ServerError(Status.INTERNAL, 'RPC endpoint not provided')
17
+ }
18
+ return new JsonRpcProvider(new Connection({ fullnode: chainServer }))
19
+ }