@t2000/sdk 5.4.0 → 5.5.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.
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-BTIIpnXc.cjs';
5
- export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-BTIIpnXc.cjs';
4
+ import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-KETPmlDo.cjs';
5
+ export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-KETPmlDo.cjs';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
@@ -303,31 +303,35 @@ declare class SuinsRpcError extends Error {
303
303
  */
304
304
  declare function looksLikeSuiNs(value: string): boolean;
305
305
  /**
306
- * Resolve a SuiNS name to its on-chain Sui address via the public
307
- * `suix_resolveNameServiceAddress` JSON-RPC method. Returns `null` if
308
- * the name resolves to no address (= not registered or expired). Throws
309
- * `SuinsRpcError` on RPC/network failure.
306
+ * Resolve a SuiNS name to its on-chain Sui address via the Sui GraphQL
307
+ * `address(name:)` query. Returns `null` if the name resolves to no address
308
+ * (= not registered or expired). Throws `SuinsRpcError` on transport failure.
310
309
  *
311
- * The host SHOULD pass a `rpcUrl` that includes any vendor key (e.g.
312
- * audric's BlockVision-keyed URL) so the call benefits from the host's
313
- * paid retry/cache budget. Falls back to the public mainnet endpoint.
310
+ * `ctx.signal` is honored for cancellation. (`ctx.suiRpcUrl` is retained for
311
+ * call-site back-compat but no longer used resolution runs against the
312
+ * canonical GraphQL endpoint via `getSuiGraphQLClient()`.)
314
313
  */
315
314
  declare function resolveSuinsViaRpc(rawName: string, ctx?: {
316
315
  suiRpcUrl?: string;
317
316
  signal?: AbortSignal;
318
317
  }): Promise<string | null>;
319
318
  /**
320
- * Reverse-resolve a 0x address to its registered SuiNS names via
321
- * `suix_resolveNameServiceNames`. Returns the names sorted by the
322
- * registry (the first entry is conventionally the user's "primary"
323
- * name on dApps that show one), or `[]` when the address has no
324
- * SuiNS records. Throws `SuinsRpcError` on RPC/network failure.
325
- *
326
- * Why this is its own helper (not folded into `normalizeAddressInput`):
327
- * a reverse lookup adds a second RPC round-trip per tool call. We don't
328
- * want every read tool that takes an `address` to silently double its
329
- * latency. The lookup primitive is opt-in via the `resolve_suins` tool;
330
- * normalizers stay forward-only.
319
+ * Reverse-resolve a 0x address to its SuiNS name via the Sui GraphQL
320
+ * `address(address:){ defaultNameRecord { domain } }` query. Returns a
321
+ * single-element array with the address's **default (primary)** name, or
322
+ * `[]` when it has none. Throws `SuinsRpcError` on transport failure.
323
+ *
324
+ * Behavior note: the legacy JSON-RPC path returned *all* names for the
325
+ * address; GraphQL exposes the explicitly-configured default record, which is
326
+ * the one every consumer here actually uses (the LLM `resolve_suins` tool +
327
+ * card titles only ever render the primary). Returning `[primary]` keeps the
328
+ * `string[]` contract intact.
329
+ *
330
+ * Why this is its own helper (not folded into `normalizeAddressInput`): a
331
+ * reverse lookup adds a second round-trip per tool call. We don't want every
332
+ * read tool that takes an `address` to silently double its latency. The lookup
333
+ * primitive is opt-in via the `resolve_suins` tool; normalizers stay
334
+ * forward-only.
331
335
  */
332
336
  declare function resolveAddressToSuinsViaRpc(rawAddress: string, ctx?: {
333
337
  suiRpcUrl?: string;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiGrpcClient } from '@mysten/sui/grpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-BTIIpnXc.js';
5
- export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-BTIIpnXc.js';
4
+ import { T as T2000Error, at as T2000Options, F as TransactionSigner, P as PayOptions, k as PayResult, au as SwapResult, av as SwapQuoteResult, t as SupportedAsset, o as SendResult, B as BalanceResponse, A as TransactionRecord, e as DepositInfo, aw as PaymentRequest, Z as ZkLoginProof, ax as SuiCoreClient, ay as SendableAsset, j as OverlayFeeConfig, az as SponsoredCoinMergeCache, u as SwapRouteResult } from './simulate-KETPmlDo.js';
5
+ export { aA as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aB as CoinPage, aC as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, aD as GASLESS_MIN_STABLE_AMOUNT, aE as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, g as KeypairSigner, L as LABEL_PATTERNS, h as LOFI_TYPE, M as MANIFEST_TYPE, i as MIST_PER_SUI, N as NAVX_TYPE, aF as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aG as Operation, aH as SENDABLE_ASSETS, S as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, aI as SelectAndSplitResult, aJ as SerializedCetusRoute, aK as SerializedCetusRoutePath, aL as SerializedRouterDataV3, p as SimulationResult, q as StableAsset, r as SuiHolding, s as SuiRpcTxBlock, v as T2000ErrorCode, w as T2000ErrorData, x as T2000_OVERLAY_FEE_WALLET, y as TOKEN_MAP, z as TransactionLeg, H as TxDirection, U as USDC_DECIMALS, J as USDC_TYPE, Q as USDE_TYPE, R as USDSUI_TYPE, V as USDT_TYPE, W as WAL_TYPE, X as WBTC_TYPE, Y as ZkLoginSigner, aM as addSwapToTx, aN as assertAllowedAsset, _ as buildSwapTx, $ as classifyAction, a0 as classifyLabel, a1 as classifyTransaction, aO as deserializeCetusRoute, a2 as executeTx, a3 as extractAllUserLegs, a4 as extractTransferDetails, a5 as extractTxCommands, a6 as extractTxSender, a7 as fallbackLabel, aP as fetchAllCoins, a8 as findSwapRoute, a9 as formatAssetAmount, aa as formatSui, ab as formatUsd, aQ as getCoinMeta, ac as getDecimals, ad as getDecimalsForCoinType, aR as getSuiClient, aS as getSuiGrpcClient, aT as isAllowedAsset, aU as isCetusRouteFresh, aV as isInRegistry, ae as mapMoveAbortCode, af as mapWalletError, ag as mistToSui, aW as normalizeAsset, aX as normalizeCoinType, ah as parseSuiRpcTx, ai as payWithMpp, aY as queryHistory, aZ as queryTransaction, aj as rawToStable, ak as rawToUsdc, al as refineLendingLabel, am as resolveSymbol, an as resolveTokenType, a_ as selectAndSplitCoin, a$ as selectSuiCoin, b0 as serializeCetusRoute, b1 as simulateTransaction, ao as stableToRaw, ap as suiToMist, b2 as throwIfSimulationFailed, aq as truncateAddress, ar as usdcToRaw, as as validateAddress, b3 as verifyCetusRouteCoinMatch } from './simulate-KETPmlDo.js';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
@@ -303,31 +303,35 @@ declare class SuinsRpcError extends Error {
303
303
  */
304
304
  declare function looksLikeSuiNs(value: string): boolean;
305
305
  /**
306
- * Resolve a SuiNS name to its on-chain Sui address via the public
307
- * `suix_resolveNameServiceAddress` JSON-RPC method. Returns `null` if
308
- * the name resolves to no address (= not registered or expired). Throws
309
- * `SuinsRpcError` on RPC/network failure.
306
+ * Resolve a SuiNS name to its on-chain Sui address via the Sui GraphQL
307
+ * `address(name:)` query. Returns `null` if the name resolves to no address
308
+ * (= not registered or expired). Throws `SuinsRpcError` on transport failure.
310
309
  *
311
- * The host SHOULD pass a `rpcUrl` that includes any vendor key (e.g.
312
- * audric's BlockVision-keyed URL) so the call benefits from the host's
313
- * paid retry/cache budget. Falls back to the public mainnet endpoint.
310
+ * `ctx.signal` is honored for cancellation. (`ctx.suiRpcUrl` is retained for
311
+ * call-site back-compat but no longer used resolution runs against the
312
+ * canonical GraphQL endpoint via `getSuiGraphQLClient()`.)
314
313
  */
315
314
  declare function resolveSuinsViaRpc(rawName: string, ctx?: {
316
315
  suiRpcUrl?: string;
317
316
  signal?: AbortSignal;
318
317
  }): Promise<string | null>;
319
318
  /**
320
- * Reverse-resolve a 0x address to its registered SuiNS names via
321
- * `suix_resolveNameServiceNames`. Returns the names sorted by the
322
- * registry (the first entry is conventionally the user's "primary"
323
- * name on dApps that show one), or `[]` when the address has no
324
- * SuiNS records. Throws `SuinsRpcError` on RPC/network failure.
325
- *
326
- * Why this is its own helper (not folded into `normalizeAddressInput`):
327
- * a reverse lookup adds a second RPC round-trip per tool call. We don't
328
- * want every read tool that takes an `address` to silently double its
329
- * latency. The lookup primitive is opt-in via the `resolve_suins` tool;
330
- * normalizers stay forward-only.
319
+ * Reverse-resolve a 0x address to its SuiNS name via the Sui GraphQL
320
+ * `address(address:){ defaultNameRecord { domain } }` query. Returns a
321
+ * single-element array with the address's **default (primary)** name, or
322
+ * `[]` when it has none. Throws `SuinsRpcError` on transport failure.
323
+ *
324
+ * Behavior note: the legacy JSON-RPC path returned *all* names for the
325
+ * address; GraphQL exposes the explicitly-configured default record, which is
326
+ * the one every consumer here actually uses (the LLM `resolve_suins` tool +
327
+ * card titles only ever render the primary). Returning `[primary]` keeps the
328
+ * `string[]` contract intact.
329
+ *
330
+ * Why this is its own helper (not folded into `normalizeAddressInput`): a
331
+ * reverse lookup adds a second round-trip per tool call. We don't want every
332
+ * read tool that takes an `address` to silently double its latency. The lookup
333
+ * primitive is opt-in via the `resolve_suins` tool; normalizers stay
334
+ * forward-only.
331
335
  */
332
336
  declare function resolveAddressToSuinsViaRpc(rawAddress: string, ctx?: {
333
337
  suiRpcUrl?: string;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { EventEmitter } from 'eventemitter3';
5
5
  import { createPaymentTransactionUri } from '@mysten/payment-kit';
6
6
  import { SuiGrpcClient } from '@mysten/sui/grpc';
7
7
  import { SuiGraphQLClient } from '@mysten/sui/graphql';
8
- import { normalizeSuiAddress, isValidSuiAddress, fromBase64 } from '@mysten/sui/utils';
8
+ import { normalizeStructTag, normalizeSuiAddress, isValidSuiAddress, fromBase64 } from '@mysten/sui/utils';
9
9
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
10
10
  import { decodeSuiPrivateKey } from '@mysten/sui/cryptography';
11
11
  import { access, mkdir, writeFile, readFile } from 'fs/promises';
@@ -1289,8 +1289,7 @@ function addSendToTx(tx, coin, recipient) {
1289
1289
  const validRecipient = validateAddress(recipient);
1290
1290
  tx.transferObjects([coin], validRecipient);
1291
1291
  }
1292
-
1293
- // src/wallet/balance.ts
1292
+ init_token_registry();
1294
1293
  var SUI_PRICE_FALLBACK = 1;
1295
1294
  var _cachedSuiPrice = 0;
1296
1295
  var _priceLastFetched = 0;
@@ -1323,30 +1322,67 @@ async function fetchSuiPrice(client) {
1323
1322
  }
1324
1323
  return _cachedSuiPrice || SUI_PRICE_FALLBACK;
1325
1324
  }
1325
+ function safeNorm(coinType) {
1326
+ try {
1327
+ return normalizeStructTag(coinType);
1328
+ } catch {
1329
+ return coinType;
1330
+ }
1331
+ }
1332
+ var SUI_TYPE_NORM = safeNorm(SUPPORTED_ASSETS.SUI.type);
1333
+ var STABLE_BY_NORM = (() => {
1334
+ const m = {};
1335
+ for (const asset of STABLE_ASSETS) m[safeNorm(SUPPORTED_ASSETS[asset].type)] = asset;
1336
+ return m;
1337
+ })();
1326
1338
  async function queryBalance(client, address) {
1327
- const stableBalancePromises = STABLE_ASSETS.map(
1328
- (asset) => client.core.getBalance({ owner: address, coinType: SUPPORTED_ASSETS[asset].type }).then((b) => ({ asset, amount: Number(b.balance.balance) / 10 ** SUPPORTED_ASSETS[asset].decimals })).catch(() => ({ asset, amount: 0 }))
1329
- );
1330
- const [suiBalance, suiPriceUsd, ...stableResults] = await Promise.all([
1331
- client.core.getBalance({ owner: address, coinType: SUPPORTED_ASSETS.SUI.type }),
1332
- fetchSuiPrice(client),
1333
- ...stableBalancePromises
1334
- ]);
1339
+ const held = [];
1340
+ let cursor;
1341
+ do {
1342
+ const page = await client.core.listBalances({ owner: address, cursor: cursor ?? void 0 });
1343
+ for (const b of page.balances) {
1344
+ const raw = BigInt(b.balance);
1345
+ if (raw > 0n) held.push({ coinType: b.coinType, raw });
1346
+ }
1347
+ cursor = page.hasNextPage ? page.cursor : null;
1348
+ } while (cursor);
1349
+ const suiPriceUsd = await fetchSuiPrice(client);
1335
1350
  const stables = {};
1351
+ for (const asset of STABLE_ASSETS) stables[asset] = 0;
1336
1352
  let totalStables = 0;
1337
- for (const { asset, amount } of stableResults) {
1338
- stables[asset] = amount;
1339
- totalStables += amount;
1353
+ let suiAmount = 0;
1354
+ const otherCoins = [];
1355
+ for (const { coinType, raw } of held) {
1356
+ const norm = safeNorm(coinType);
1357
+ if (norm === SUI_TYPE_NORM) {
1358
+ suiAmount = Number(raw) / Number(MIST_PER_SUI);
1359
+ } else if (STABLE_BY_NORM[norm]) {
1360
+ const asset = STABLE_BY_NORM[norm];
1361
+ const amount = Number(raw) / 10 ** SUPPORTED_ASSETS[asset].decimals;
1362
+ stables[asset] = amount;
1363
+ totalStables += amount;
1364
+ } else {
1365
+ otherCoins.push({ coinType, raw });
1366
+ }
1340
1367
  }
1341
- const suiAmount = Number(suiBalance.balance.balance) / Number(MIST_PER_SUI);
1368
+ const tokens = await Promise.all(
1369
+ otherCoins.map(async ({ coinType, raw }) => {
1370
+ const decimals = await resolveCoinDecimals(client, coinType);
1371
+ return {
1372
+ coinType,
1373
+ symbol: resolveSymbol(coinType),
1374
+ amount: Number(raw) / 10 ** decimals,
1375
+ usdValue: null
1376
+ };
1377
+ })
1378
+ );
1379
+ tokens.sort((a, b) => a.symbol.localeCompare(b.symbol));
1342
1380
  const suiUsdValue = suiAmount * suiPriceUsd;
1343
1381
  return {
1344
1382
  stables,
1345
1383
  available: totalStables,
1346
- sui: {
1347
- amount: suiAmount,
1348
- usdValue: suiUsdValue
1349
- },
1384
+ sui: { amount: suiAmount, usdValue: suiUsdValue },
1385
+ tokens,
1350
1386
  totalUsd: totalStables + suiUsdValue
1351
1387
  };
1352
1388
  }
@@ -1516,7 +1552,7 @@ var TX_NODE_FRAGMENT = `
1516
1552
  }
1517
1553
  `;
1518
1554
  var HISTORY_QUERY = `query History($address: SuiAddress!, $last: Int!) {
1519
- transactions(last: $last, filter: { sentAddress: $address }) {
1555
+ transactions(last: $last, filter: { affectedAddress: $address }) {
1520
1556
  nodes {${TX_NODE_FRAGMENT}}
1521
1557
  }
1522
1558
  }`;
@@ -1643,7 +1679,12 @@ function extractCommands(txBlock) {
1643
1679
  init_token_registry();
1644
1680
 
1645
1681
  // src/utils/suins.ts
1646
- var SUI_MAINNET_URL = "https://fullnode.mainnet.sui.io:443";
1682
+ var RESOLVE_NAME_QUERY = `query ResolveSuins($name: String!) {
1683
+ address(name: $name) { address }
1684
+ }`;
1685
+ var REVERSE_NAME_QUERY = `query ReverseSuins($address: SuiAddress!) {
1686
+ address(address: $address) { defaultNameRecord { domain } }
1687
+ }`;
1647
1688
  var SUI_ADDRESS_REGEX = /^0x[a-fA-F0-9]{1,64}$/i;
1648
1689
  var SUI_ADDRESS_STRICT_REGEX = /^0x[a-fA-F0-9]{64}$/i;
1649
1690
  var SUINS_NAME_REGEX = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.sui$/;
@@ -1681,76 +1722,45 @@ async function resolveSuinsViaRpc(rawName, ctx = {}) {
1681
1722
  if (!SUINS_NAME_REGEX.test(name)) {
1682
1723
  throw new InvalidAddressError(rawName);
1683
1724
  }
1684
- const url = ctx.suiRpcUrl || SUI_MAINNET_URL;
1725
+ const gql = getSuiGraphQLClient();
1685
1726
  let res;
1686
1727
  try {
1687
- res = await fetch(url, {
1688
- method: "POST",
1689
- headers: { "Content-Type": "application/json" },
1690
- body: JSON.stringify({
1691
- jsonrpc: "2.0",
1692
- id: 1,
1693
- method: "suix_resolveNameServiceAddress",
1694
- params: [name]
1695
- }),
1696
- signal: ctx.signal ?? AbortSignal.timeout(8e3)
1728
+ res = await gql.query({
1729
+ query: RESOLVE_NAME_QUERY,
1730
+ variables: { name },
1731
+ signal: ctx.signal
1697
1732
  });
1698
1733
  } catch (err) {
1699
1734
  const msg = err instanceof Error ? err.message : String(err);
1700
1735
  throw new SuinsRpcError(name, msg);
1701
1736
  }
1702
- if (!res.ok) {
1703
- throw new SuinsRpcError(name, `HTTP ${res.status}`);
1704
- }
1705
- let body;
1706
- try {
1707
- body = await res.json();
1708
- } catch (err) {
1709
- const msg = err instanceof Error ? err.message : String(err);
1710
- throw new SuinsRpcError(name, `JSON parse failed: ${msg}`);
1711
- }
1712
- if (body.error) {
1713
- throw new SuinsRpcError(name, body.error.message);
1737
+ if (res.errors?.length) {
1738
+ throw new SuinsRpcError(name, res.errors.map((e) => e.message ?? "unknown error").join("; "));
1714
1739
  }
1715
- return body.result ?? null;
1740
+ return res.data?.address?.address ?? null;
1716
1741
  }
1717
1742
  async function resolveAddressToSuinsViaRpc(rawAddress, ctx = {}) {
1718
1743
  const address = rawAddress.trim().toLowerCase();
1719
1744
  if (!SUI_ADDRESS_REGEX.test(address)) {
1720
1745
  throw new InvalidAddressError(rawAddress);
1721
1746
  }
1722
- const url = ctx.suiRpcUrl || SUI_MAINNET_URL;
1747
+ const gql = getSuiGraphQLClient();
1723
1748
  let res;
1724
1749
  try {
1725
- res = await fetch(url, {
1726
- method: "POST",
1727
- headers: { "Content-Type": "application/json" },
1728
- body: JSON.stringify({
1729
- jsonrpc: "2.0",
1730
- id: 1,
1731
- method: "suix_resolveNameServiceNames",
1732
- params: [address]
1733
- }),
1734
- signal: ctx.signal ?? AbortSignal.timeout(8e3)
1750
+ res = await gql.query({
1751
+ query: REVERSE_NAME_QUERY,
1752
+ variables: { address },
1753
+ signal: ctx.signal
1735
1754
  });
1736
1755
  } catch (err) {
1737
1756
  const msg = err instanceof Error ? err.message : String(err);
1738
1757
  throw new SuinsRpcError(address, msg);
1739
1758
  }
1740
- if (!res.ok) {
1741
- throw new SuinsRpcError(address, `HTTP ${res.status}`);
1742
- }
1743
- let body;
1744
- try {
1745
- body = await res.json();
1746
- } catch (err) {
1747
- const msg = err instanceof Error ? err.message : String(err);
1748
- throw new SuinsRpcError(address, `JSON parse failed: ${msg}`);
1749
- }
1750
- if (body.error) {
1751
- throw new SuinsRpcError(address, body.error.message);
1759
+ if (res.errors?.length) {
1760
+ throw new SuinsRpcError(address, res.errors.map((e) => e.message ?? "unknown error").join("; "));
1752
1761
  }
1753
- return body.result?.data ?? [];
1762
+ const domain = res.data?.address?.defaultNameRecord?.domain;
1763
+ return domain ? [domain] : [];
1754
1764
  }
1755
1765
  async function normalizeAddressInput(value, ctx = {}) {
1756
1766
  const trimmed = value.trim();