@t2000/sdk 4.2.1 → 4.3.0

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,8 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- import { SuiGrpcClient } from '@mysten/sui/grpc';
4
- import { T as TransactionLeg, k as TransactionRecord } from './types-DUmk5ivZ.js';
3
+ import { P as PayOptions, d as PayResult, T as TransactionLeg, k as TransactionRecord } from './types-Ch0zVUpC.cjs';
5
4
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
6
6
 
7
7
  /**
8
8
  * Abstract signing interface that decouples the SDK from any specific
@@ -61,13 +61,111 @@ declare class ZkLoginSigner implements TransactionSigner {
61
61
  signTransaction(txBytes: Uint8Array): Promise<{
62
62
  signature: string;
63
63
  }>;
64
- signPersonalMessage(_messageBytes: Uint8Array): Promise<{
64
+ signPersonalMessage(messageBytes: Uint8Array): Promise<{
65
65
  signature: string;
66
66
  bytes: string;
67
67
  }>;
68
68
  isExpired(currentEpoch: number): boolean;
69
69
  }
70
70
 
71
+ /**
72
+ * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
73
+ *
74
+ * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
75
+ *
76
+ * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
77
+ * Tier 2: 15 curated swap assets — hold, trade, and send only.
78
+ * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
79
+ *
80
+ * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
81
+ * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
82
+ */
83
+ interface CoinMeta {
84
+ type: string;
85
+ decimals: number;
86
+ symbol: string;
87
+ tier?: 1 | 2;
88
+ }
89
+ /**
90
+ * Canonical coin registry.
91
+ * Key = user-friendly name (used in swap_execute, CLI, prompts).
92
+ */
93
+ declare const COIN_REGISTRY: Record<string, CoinMeta>;
94
+ /**
95
+ * Returns the registry metadata for a coin type, or `undefined` if the coin
96
+ * is not in the registry. Use this when you need to distinguish "known coin"
97
+ * from "supported coin" — `isSupported` only flags tiered (active) coins,
98
+ * but legacy coins like USDsui / USDe / USDT are in the registry without a
99
+ * tier and still need canonical-symbol resolution.
100
+ */
101
+ declare function getCoinMeta(coinType: string): CoinMeta | undefined;
102
+ /**
103
+ * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
104
+ * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
105
+ * entries. The blockvision-prices canonical-symbol gate uses this looser
106
+ * check so that USDsui (legacy/no-tier today, but with a registry-canonical
107
+ * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
108
+ */
109
+ declare function isInRegistry(coinType: string): boolean;
110
+ /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
111
+ declare function isTier1(coinType: string): boolean;
112
+ /** Returns true if the coin type is Tier 2 (curated swap asset). */
113
+ declare function isTier2(coinType: string): boolean;
114
+ /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
115
+ declare function isSupported(coinType: string): boolean;
116
+ /** Returns the tier for a coin type, or undefined if legacy/unknown. */
117
+ declare function getTier(coinType: string): 1 | 2 | undefined;
118
+ /**
119
+ * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
120
+ * Works for both tiered and legacy tokens.
121
+ */
122
+ declare function getDecimalsForCoinType(coinType: string): number;
123
+ /**
124
+ * Resolve a full coin type to a user-friendly symbol.
125
+ * Returns the last `::` segment if not in the registry.
126
+ */
127
+ declare function resolveSymbol(coinType: string): string;
128
+ /**
129
+ * Name → type map for swap resolution. Derived from COIN_REGISTRY.
130
+ * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
131
+ */
132
+ declare const TOKEN_MAP: Record<string, string>;
133
+ /**
134
+ * Resolve a user-friendly token name to its full coin type.
135
+ * Returns the input unchanged if already a full coin type (contains "::").
136
+ * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
137
+ */
138
+ declare function resolveTokenType(nameOrType: string): string | null;
139
+ /** Common type constants for direct import. */
140
+ declare const SUI_TYPE: string;
141
+ declare const USDC_TYPE: string;
142
+ declare const USDT_TYPE: string;
143
+ declare const USDSUI_TYPE: string;
144
+ declare const USDE_TYPE: string;
145
+ declare const ETH_TYPE: string;
146
+ declare const WBTC_TYPE: string;
147
+ declare const WAL_TYPE: string;
148
+ declare const NAVX_TYPE: string;
149
+ declare const IKA_TYPE: string;
150
+ declare const LOFI_TYPE: string;
151
+ declare const MANIFEST_TYPE: string;
152
+
153
+ declare function payWithMpp(args: {
154
+ signer: TransactionSigner;
155
+ client: SuiJsonRpcClient;
156
+ options: PayOptions;
157
+ }): Promise<PayResult>;
158
+
159
+ type SuiTransactionEffects = NonNullable<Awaited<ReturnType<SuiJsonRpcClient['executeTransactionBlock']>>['effects']>;
160
+ type BuildClient = NonNullable<Parameters<Transaction['build']>[0]>['client'];
161
+ declare function executeTx(client: SuiJsonRpcClient, signer: TransactionSigner, buildTx: () => Promise<Transaction> | Transaction, options?: {
162
+ buildClient?: BuildClient;
163
+ }): Promise<{
164
+ digest: string;
165
+ gasCostSui: number;
166
+ effects: SuiTransactionEffects | undefined;
167
+ }>;
168
+
71
169
  type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'ADDRESS_BALANCE_UNSPONSORABLE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'WALLET_CORRUPT' | 'INVALID_KEY' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
72
170
  interface T2000ErrorData {
73
171
  reason?: string;
@@ -246,88 +344,6 @@ declare function truncateAddress(address: string): string;
246
344
  */
247
345
  declare function normalizeCoinType(coinType: string): string;
248
346
 
249
- /**
250
- * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
251
- *
252
- * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
253
- *
254
- * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
255
- * Tier 2: 15 curated swap assets — hold, trade, and send only.
256
- * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
257
- *
258
- * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
259
- * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
260
- */
261
- interface CoinMeta {
262
- type: string;
263
- decimals: number;
264
- symbol: string;
265
- tier?: 1 | 2;
266
- }
267
- /**
268
- * Canonical coin registry.
269
- * Key = user-friendly name (used in swap_execute, CLI, prompts).
270
- */
271
- declare const COIN_REGISTRY: Record<string, CoinMeta>;
272
- /**
273
- * Returns the registry metadata for a coin type, or `undefined` if the coin
274
- * is not in the registry. Use this when you need to distinguish "known coin"
275
- * from "supported coin" — `isSupported` only flags tiered (active) coins,
276
- * but legacy coins like USDsui / USDe / USDT are in the registry without a
277
- * tier and still need canonical-symbol resolution.
278
- */
279
- declare function getCoinMeta(coinType: string): CoinMeta | undefined;
280
- /**
281
- * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
282
- * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
283
- * entries. The blockvision-prices canonical-symbol gate uses this looser
284
- * check so that USDsui (legacy/no-tier today, but with a registry-canonical
285
- * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
286
- */
287
- declare function isInRegistry(coinType: string): boolean;
288
- /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
289
- declare function isTier1(coinType: string): boolean;
290
- /** Returns true if the coin type is Tier 2 (curated swap asset). */
291
- declare function isTier2(coinType: string): boolean;
292
- /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
293
- declare function isSupported(coinType: string): boolean;
294
- /** Returns the tier for a coin type, or undefined if legacy/unknown. */
295
- declare function getTier(coinType: string): 1 | 2 | undefined;
296
- /**
297
- * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
298
- * Works for both tiered and legacy tokens.
299
- */
300
- declare function getDecimalsForCoinType(coinType: string): number;
301
- /**
302
- * Resolve a full coin type to a user-friendly symbol.
303
- * Returns the last `::` segment if not in the registry.
304
- */
305
- declare function resolveSymbol(coinType: string): string;
306
- /**
307
- * Name → type map for swap resolution. Derived from COIN_REGISTRY.
308
- * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
309
- */
310
- declare const TOKEN_MAP: Record<string, string>;
311
- /**
312
- * Resolve a user-friendly token name to its full coin type.
313
- * Returns the input unchanged if already a full coin type (contains "::").
314
- * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
315
- */
316
- declare function resolveTokenType(nameOrType: string): string | null;
317
- /** Common type constants for direct import. */
318
- declare const SUI_TYPE: string;
319
- declare const USDC_TYPE: string;
320
- declare const USDT_TYPE: string;
321
- declare const USDSUI_TYPE: string;
322
- declare const USDE_TYPE: string;
323
- declare const ETH_TYPE: string;
324
- declare const WBTC_TYPE: string;
325
- declare const WAL_TYPE: string;
326
- declare const NAVX_TYPE: string;
327
- declare const IKA_TYPE: string;
328
- declare const LOFI_TYPE: string;
329
- declare const MANIFEST_TYPE: string;
330
-
331
347
  /**
332
348
  * Shared transaction classifier.
333
349
  *
@@ -648,4 +664,4 @@ interface TxMetadata {
648
664
  declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
649
665
  declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
650
666
 
651
- export { ZkLoginSigner as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxDirection as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, type TxMetadata as Q, USDC_TYPE as R, SAVE_FEE_BPS as S, T2000Error as T, USDC_DECIMALS as U, USDE_TYPE as V, USDSUI_TYPE as W, USDT_TYPE as X, WAL_TYPE as Y, WBTC_TYPE as Z, type ZkLoginProof as _, BPS_DENOMINATOR as a, addFeeTransfer as a0, calculateFee as a1, classifyAction as a2, classifyLabel as a3, classifyTransaction as a4, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, GASLESS_MIN_STABLE_AMOUNT as aA, GASLESS_STABLE_TYPES as aB, OPERATION_ASSETS as aC, type Operation as aD, SAVEABLE_ASSETS as aE, SENDABLE_ASSETS as aF, type SaveableAsset as aG, assertAllowedAsset as aH, createSuiClient as aI, getCoinMeta as aJ, getSuiClient as aK, getSuiGrpcClient as aL, isAllowedAsset as aM, isInRegistry as aN, normalizeAsset as aO, normalizeCoinType as aP, queryHistory as aQ, queryTransaction as aR, simulateTransaction as aS, throwIfSimulationFailed as aT, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, type SendableAsset as ax, CETUS_USDC_SUI_POOL as ay, DEFAULT_GRPC_URL as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, STABLE_ASSETS as k, SUI_DECIMALS as l, SUI_TYPE as m, SUPPORTED_ASSETS as n, type SafeguardConfig as o, SafeguardError as p, type SafeguardErrorDetails as q, type SafeguardRule as r, type SimulationResult as s, type StableAsset as t, type SuiRpcTxBlock as u, type SupportedAsset as v, type T2000ErrorCode as w, type T2000ErrorData as x, T2000_OVERLAY_FEE_WALLET as y, TOKEN_MAP as z };
667
+ export { ZkLoginSigner as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxDirection as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, type TxMetadata as Q, USDC_TYPE as R, SAVE_FEE_BPS as S, T2000Error as T, USDC_DECIMALS as U, USDE_TYPE as V, USDSUI_TYPE as W, USDT_TYPE as X, WAL_TYPE as Y, WBTC_TYPE as Z, type ZkLoginProof as _, BPS_DENOMINATOR as a, addFeeTransfer as a0, calculateFee as a1, classifyAction as a2, classifyLabel as a3, classifyTransaction as a4, executeTx as a5, extractAllUserLegs as a6, extractTransferDetails as a7, extractTxCommands as a8, extractTxSender as a9, CETUS_USDC_SUI_POOL as aA, DEFAULT_GRPC_URL as aB, GASLESS_MIN_STABLE_AMOUNT as aC, GASLESS_STABLE_TYPES as aD, OPERATION_ASSETS as aE, type Operation as aF, SAVEABLE_ASSETS as aG, SENDABLE_ASSETS as aH, type SaveableAsset as aI, assertAllowedAsset as aJ, createSuiClient as aK, getCoinMeta as aL, getSuiClient as aM, getSuiGrpcClient as aN, isAllowedAsset as aO, isInRegistry as aP, normalizeAsset as aQ, normalizeCoinType as aR, queryHistory as aS, queryTransaction as aT, simulateTransaction as aU, throwIfSimulationFailed as aV, fallbackLabel as aa, formatAssetAmount as ab, formatSui as ac, formatUsd as ad, getDecimals as ae, getDecimalsForCoinType as af, getTier as ag, isSupported as ah, isTier1 as ai, isTier2 as aj, mapMoveAbortCode as ak, mapWalletError as al, mistToSui as am, parseSuiRpcTx as an, payWithMpp as ao, rawToStable as ap, rawToUsdc as aq, refineLendingLabel as ar, resolveSymbol as as, resolveTokenType as at, stableToRaw as au, suiToMist as av, truncateAddress as aw, usdcToRaw as ax, validateAddress as ay, type SendableAsset as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, STABLE_ASSETS as k, SUI_DECIMALS as l, SUI_TYPE as m, SUPPORTED_ASSETS as n, type SafeguardConfig as o, SafeguardError as p, type SafeguardErrorDetails as q, type SafeguardRule as r, type SimulationResult as s, type StableAsset as t, type SuiRpcTxBlock as u, type SupportedAsset as v, type T2000ErrorCode as w, type T2000ErrorData as x, T2000_OVERLAY_FEE_WALLET as y, TOKEN_MAP as z };
@@ -92,6 +92,7 @@ interface SelectAndSplitResult {
92
92
  declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, coinType: string, amount: bigint | 'all', options?: {
93
93
  allowSwapAll?: boolean;
94
94
  sponsoredContext?: boolean;
95
+ mergeCache?: SponsoredCoinMergeCache;
95
96
  }): Promise<SelectAndSplitResult>;
96
97
  /**
97
98
  * Coin-object-only selection for sponsored (Enoki) transactions. Fetches the
@@ -114,14 +115,20 @@ declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, o
114
115
  * `primary` instead of re-fetching + re-merging.
115
116
  *
116
117
  * Why this exists (S.xxx, 2026-06-02): a sponsored bundle with 2+ legs
117
- * sourcing the same coin (e.g. `SUI→WAL` + `SUI→DEEP`) called
118
- * `selectCoinObjectsOnly` once per leg. Each call emitted its own
119
- * `mergeCoins` over the SAME coin objects, so the second leg's merge
120
- * referenced coins the first leg already consumed → Enoki dry-run failed
121
- * with `CommandArgumentError { ArgumentWithoutValue }`. Non-SUI legs dodge
122
- * this because they go through `coinWithBalance`, whose resolver batches
123
- * all intents for one coin type into a single build-time merge. The SUI
124
- * sponsored path has no such batching, so the cache supplies it.
118
+ * sourcing the same coin (e.g. `SUI→WAL` + `SUI→DEEP`, or `swap USDC` +
119
+ * `save USDC`) called `selectCoinObjectsOnly` once per leg. Each call
120
+ * emitted its own `mergeCoins` over the SAME coin objects, so the second
121
+ * leg's merge referenced coins the first leg already consumed → Enoki
122
+ * dry-run failed with `CommandArgumentError { ArgumentWithoutValue }`.
123
+ *
124
+ * This is NOT SUI-specific. Under sponsorship, `selectAndSplitCoin` routes
125
+ * EVERY asset through `selectCoinObjectsOnly` (the `coinWithBalance`
126
+ * batching that would otherwise dedup these merges only runs for
127
+ * non-sponsored CLI/direct flows — its address-balance `FundsWithdrawal`
128
+ * reservation is what Enoki can't deserialize, issue #93). So the cache is
129
+ * the dedup layer for ALL coin types in a sponsored multi-leg PTB, keyed
130
+ * by coin type. SUI was simply the first asset observed failing in the
131
+ * wild because it's the most common swap source.
125
132
  */
126
133
  type SponsoredCoinMergeCache = Map<string, {
127
134
  primary: TransactionObjectArgument;
@@ -395,14 +402,16 @@ declare function addSwapToTx(tx: Transaction, client: SuiJsonRpcClient, address:
395
402
  */
396
403
  sponsoredContext?: boolean;
397
404
  /**
398
- * Per-PTB merge cache for sponsored SUI sourcing. Provided by
399
- * `composeTx`'s orchestration loop so multiple SUI-source legs in one
400
- * bundle share a single merged primary coin instead of each emitting
401
- * its own `mergeCoins` (the second of which references already-consumed
402
- * coins Enoki dry-run `ArgumentWithoutValue`). Single swaps / non-SUI
403
- * sources don't need it; omit. See `SponsoredCoinMergeCache` JSDoc.
405
+ * Per-PTB merge cache for sponsored coin-object sourcing (any coin
406
+ * type SUI in the dedicated branch, USDC/USDsui/etc. in the wallet
407
+ * branch). Provided by `composeTx`'s orchestration loop so multiple
408
+ * legs sourcing the same coin in one bundle share a single merged
409
+ * primary coin instead of each emitting its own `mergeCoins` (the
410
+ * second of which references already-consumed coins Enoki dry-run
411
+ * `ArgumentWithoutValue`). Single swaps don't need it; omit. See
412
+ * `SponsoredCoinMergeCache` JSDoc.
404
413
  */
405
- suiMergeCache?: SponsoredCoinMergeCache;
414
+ coinMergeCache?: SponsoredCoinMergeCache;
406
415
  }): Promise<{
407
416
  coin: TransactionObjectArgument;
408
417
  effectiveAmountIn: number;
@@ -92,6 +92,7 @@ interface SelectAndSplitResult {
92
92
  declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, owner: string, coinType: string, amount: bigint | 'all', options?: {
93
93
  allowSwapAll?: boolean;
94
94
  sponsoredContext?: boolean;
95
+ mergeCache?: SponsoredCoinMergeCache;
95
96
  }): Promise<SelectAndSplitResult>;
96
97
  /**
97
98
  * Coin-object-only selection for sponsored (Enoki) transactions. Fetches the
@@ -114,14 +115,20 @@ declare function selectAndSplitCoin(tx: Transaction, client: SuiJsonRpcClient, o
114
115
  * `primary` instead of re-fetching + re-merging.
115
116
  *
116
117
  * Why this exists (S.xxx, 2026-06-02): a sponsored bundle with 2+ legs
117
- * sourcing the same coin (e.g. `SUI→WAL` + `SUI→DEEP`) called
118
- * `selectCoinObjectsOnly` once per leg. Each call emitted its own
119
- * `mergeCoins` over the SAME coin objects, so the second leg's merge
120
- * referenced coins the first leg already consumed → Enoki dry-run failed
121
- * with `CommandArgumentError { ArgumentWithoutValue }`. Non-SUI legs dodge
122
- * this because they go through `coinWithBalance`, whose resolver batches
123
- * all intents for one coin type into a single build-time merge. The SUI
124
- * sponsored path has no such batching, so the cache supplies it.
118
+ * sourcing the same coin (e.g. `SUI→WAL` + `SUI→DEEP`, or `swap USDC` +
119
+ * `save USDC`) called `selectCoinObjectsOnly` once per leg. Each call
120
+ * emitted its own `mergeCoins` over the SAME coin objects, so the second
121
+ * leg's merge referenced coins the first leg already consumed → Enoki
122
+ * dry-run failed with `CommandArgumentError { ArgumentWithoutValue }`.
123
+ *
124
+ * This is NOT SUI-specific. Under sponsorship, `selectAndSplitCoin` routes
125
+ * EVERY asset through `selectCoinObjectsOnly` (the `coinWithBalance`
126
+ * batching that would otherwise dedup these merges only runs for
127
+ * non-sponsored CLI/direct flows — its address-balance `FundsWithdrawal`
128
+ * reservation is what Enoki can't deserialize, issue #93). So the cache is
129
+ * the dedup layer for ALL coin types in a sponsored multi-leg PTB, keyed
130
+ * by coin type. SUI was simply the first asset observed failing in the
131
+ * wild because it's the most common swap source.
125
132
  */
126
133
  type SponsoredCoinMergeCache = Map<string, {
127
134
  primary: TransactionObjectArgument;
@@ -395,14 +402,16 @@ declare function addSwapToTx(tx: Transaction, client: SuiJsonRpcClient, address:
395
402
  */
396
403
  sponsoredContext?: boolean;
397
404
  /**
398
- * Per-PTB merge cache for sponsored SUI sourcing. Provided by
399
- * `composeTx`'s orchestration loop so multiple SUI-source legs in one
400
- * bundle share a single merged primary coin instead of each emitting
401
- * its own `mergeCoins` (the second of which references already-consumed
402
- * coins Enoki dry-run `ArgumentWithoutValue`). Single swaps / non-SUI
403
- * sources don't need it; omit. See `SponsoredCoinMergeCache` JSDoc.
405
+ * Per-PTB merge cache for sponsored coin-object sourcing (any coin
406
+ * type SUI in the dedicated branch, USDC/USDsui/etc. in the wallet
407
+ * branch). Provided by `composeTx`'s orchestration loop so multiple
408
+ * legs sourcing the same coin in one bundle share a single merged
409
+ * primary coin instead of each emitting its own `mergeCoins` (the
410
+ * second of which references already-consumed coins Enoki dry-run
411
+ * `ArgumentWithoutValue`). Single swaps don't need it; omit. See
412
+ * `SponsoredCoinMergeCache` JSDoc.
404
413
  */
405
- suiMergeCache?: SponsoredCoinMergeCache;
414
+ coinMergeCache?: SponsoredCoinMergeCache;
406
415
  }): Promise<{
407
416
  coin: TransactionObjectArgument;
408
417
  effectiveAmountIn: number;
@@ -1,8 +1,8 @@
1
1
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
- import { SuiGrpcClient } from '@mysten/sui/grpc';
4
- import { T as TransactionLeg, k as TransactionRecord } from './types-DUmk5ivZ.cjs';
3
+ import { P as PayOptions, d as PayResult, T as TransactionLeg, k as TransactionRecord } from './types-Ch0zVUpC.js';
5
4
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
5
+ import { SuiGrpcClient } from '@mysten/sui/grpc';
6
6
 
7
7
  /**
8
8
  * Abstract signing interface that decouples the SDK from any specific
@@ -61,13 +61,111 @@ declare class ZkLoginSigner implements TransactionSigner {
61
61
  signTransaction(txBytes: Uint8Array): Promise<{
62
62
  signature: string;
63
63
  }>;
64
- signPersonalMessage(_messageBytes: Uint8Array): Promise<{
64
+ signPersonalMessage(messageBytes: Uint8Array): Promise<{
65
65
  signature: string;
66
66
  bytes: string;
67
67
  }>;
68
68
  isExpired(currentEpoch: number): boolean;
69
69
  }
70
70
 
71
+ /**
72
+ * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
73
+ *
74
+ * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
75
+ *
76
+ * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
77
+ * Tier 2: 15 curated swap assets — hold, trade, and send only.
78
+ * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
79
+ *
80
+ * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
81
+ * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
82
+ */
83
+ interface CoinMeta {
84
+ type: string;
85
+ decimals: number;
86
+ symbol: string;
87
+ tier?: 1 | 2;
88
+ }
89
+ /**
90
+ * Canonical coin registry.
91
+ * Key = user-friendly name (used in swap_execute, CLI, prompts).
92
+ */
93
+ declare const COIN_REGISTRY: Record<string, CoinMeta>;
94
+ /**
95
+ * Returns the registry metadata for a coin type, or `undefined` if the coin
96
+ * is not in the registry. Use this when you need to distinguish "known coin"
97
+ * from "supported coin" — `isSupported` only flags tiered (active) coins,
98
+ * but legacy coins like USDsui / USDe / USDT are in the registry without a
99
+ * tier and still need canonical-symbol resolution.
100
+ */
101
+ declare function getCoinMeta(coinType: string): CoinMeta | undefined;
102
+ /**
103
+ * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
104
+ * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
105
+ * entries. The blockvision-prices canonical-symbol gate uses this looser
106
+ * check so that USDsui (legacy/no-tier today, but with a registry-canonical
107
+ * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
108
+ */
109
+ declare function isInRegistry(coinType: string): boolean;
110
+ /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
111
+ declare function isTier1(coinType: string): boolean;
112
+ /** Returns true if the coin type is Tier 2 (curated swap asset). */
113
+ declare function isTier2(coinType: string): boolean;
114
+ /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
115
+ declare function isSupported(coinType: string): boolean;
116
+ /** Returns the tier for a coin type, or undefined if legacy/unknown. */
117
+ declare function getTier(coinType: string): 1 | 2 | undefined;
118
+ /**
119
+ * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
120
+ * Works for both tiered and legacy tokens.
121
+ */
122
+ declare function getDecimalsForCoinType(coinType: string): number;
123
+ /**
124
+ * Resolve a full coin type to a user-friendly symbol.
125
+ * Returns the last `::` segment if not in the registry.
126
+ */
127
+ declare function resolveSymbol(coinType: string): string;
128
+ /**
129
+ * Name → type map for swap resolution. Derived from COIN_REGISTRY.
130
+ * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
131
+ */
132
+ declare const TOKEN_MAP: Record<string, string>;
133
+ /**
134
+ * Resolve a user-friendly token name to its full coin type.
135
+ * Returns the input unchanged if already a full coin type (contains "::").
136
+ * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
137
+ */
138
+ declare function resolveTokenType(nameOrType: string): string | null;
139
+ /** Common type constants for direct import. */
140
+ declare const SUI_TYPE: string;
141
+ declare const USDC_TYPE: string;
142
+ declare const USDT_TYPE: string;
143
+ declare const USDSUI_TYPE: string;
144
+ declare const USDE_TYPE: string;
145
+ declare const ETH_TYPE: string;
146
+ declare const WBTC_TYPE: string;
147
+ declare const WAL_TYPE: string;
148
+ declare const NAVX_TYPE: string;
149
+ declare const IKA_TYPE: string;
150
+ declare const LOFI_TYPE: string;
151
+ declare const MANIFEST_TYPE: string;
152
+
153
+ declare function payWithMpp(args: {
154
+ signer: TransactionSigner;
155
+ client: SuiJsonRpcClient;
156
+ options: PayOptions;
157
+ }): Promise<PayResult>;
158
+
159
+ type SuiTransactionEffects = NonNullable<Awaited<ReturnType<SuiJsonRpcClient['executeTransactionBlock']>>['effects']>;
160
+ type BuildClient = NonNullable<Parameters<Transaction['build']>[0]>['client'];
161
+ declare function executeTx(client: SuiJsonRpcClient, signer: TransactionSigner, buildTx: () => Promise<Transaction> | Transaction, options?: {
162
+ buildClient?: BuildClient;
163
+ }): Promise<{
164
+ digest: string;
165
+ gasCostSui: number;
166
+ effects: SuiTransactionEffects | undefined;
167
+ }>;
168
+
71
169
  type T2000ErrorCode = 'INSUFFICIENT_BALANCE' | 'ADDRESS_BALANCE_UNSPONSORABLE' | 'INSUFFICIENT_GAS' | 'INVALID_ADDRESS' | 'INVALID_AMOUNT' | 'WALLET_NOT_FOUND' | 'WALLET_LOCKED' | 'WALLET_EXISTS' | 'WALLET_CORRUPT' | 'INVALID_KEY' | 'SIMULATION_FAILED' | 'TRANSACTION_FAILED' | 'ASSET_NOT_SUPPORTED' | 'INVALID_ASSET' | 'HEALTH_FACTOR_TOO_LOW' | 'WITHDRAW_WOULD_LIQUIDATE' | 'WITHDRAW_FAILED' | 'NO_COLLATERAL' | 'PROTOCOL_PAUSED' | 'PROTOCOL_UNAVAILABLE' | 'RPC_ERROR' | 'RPC_UNREACHABLE' | 'PRICE_EXCEEDS_LIMIT' | 'UNSUPPORTED_NETWORK' | 'PAYMENT_EXPIRED' | 'DUPLICATE_PAYMENT' | 'FACILITATOR_REJECTION' | 'CONTACT_NOT_FOUND' | 'INVALID_CONTACT_NAME' | 'SUINS_NOT_REGISTERED' | 'FACILITATOR_TIMEOUT' | 'SAFEGUARD_BLOCKED' | 'SWAP_NO_ROUTE' | 'SWAP_FAILED' | 'CHAIN_MODE_INVALID' | 'UNKNOWN';
72
170
  interface T2000ErrorData {
73
171
  reason?: string;
@@ -246,88 +344,6 @@ declare function truncateAddress(address: string): string;
246
344
  */
247
345
  declare function normalizeCoinType(coinType: string): string;
248
346
 
249
- /**
250
- * Unified token registry — single source of truth for coin types, decimals, symbols, and tiers.
251
- *
252
- * ZERO heavy dependencies. Safe to import from any context (server, browser, Edge).
253
- *
254
- * Tier 1: USDC — the financial layer (save, borrow, receive, yield, allowances, marketplace, MPP).
255
- * Tier 2: 15 curated swap assets — hold, trade, and send only.
256
- * No tier: Legacy tokens kept for display accuracy (existing NAVI positions). No new operations.
257
- *
258
- * To add a new token: add ONE entry to COIN_REGISTRY below. Everything else derives from it.
259
- * Gate for Tier 2 addition: confirmed deep Cetus liquidity + clear user need.
260
- */
261
- interface CoinMeta {
262
- type: string;
263
- decimals: number;
264
- symbol: string;
265
- tier?: 1 | 2;
266
- }
267
- /**
268
- * Canonical coin registry.
269
- * Key = user-friendly name (used in swap_execute, CLI, prompts).
270
- */
271
- declare const COIN_REGISTRY: Record<string, CoinMeta>;
272
- /**
273
- * Returns the registry metadata for a coin type, or `undefined` if the coin
274
- * is not in the registry. Use this when you need to distinguish "known coin"
275
- * from "supported coin" — `isSupported` only flags tiered (active) coins,
276
- * but legacy coins like USDsui / USDe / USDT are in the registry without a
277
- * tier and still need canonical-symbol resolution.
278
- */
279
- declare function getCoinMeta(coinType: string): CoinMeta | undefined;
280
- /**
281
- * Returns true if the coin type appears anywhere in COIN_REGISTRY (tier 1, 2,
282
- * OR legacy/no-tier). Different from `isSupported`, which excludes legacy
283
- * entries. The blockvision-prices canonical-symbol gate uses this looser
284
- * check so that USDsui (legacy/no-tier today, but with a registry-canonical
285
- * mixed-case symbol) still wins over BlockVision's uppercase 'USDSUI'.
286
- */
287
- declare function isInRegistry(coinType: string): boolean;
288
- /** Returns true if the coin type is Tier 1 (USDC — the financial layer). */
289
- declare function isTier1(coinType: string): boolean;
290
- /** Returns true if the coin type is Tier 2 (curated swap asset). */
291
- declare function isTier2(coinType: string): boolean;
292
- /** Returns true if the coin type is actively supported (Tier 1 or Tier 2). */
293
- declare function isSupported(coinType: string): boolean;
294
- /** Returns the tier for a coin type, or undefined if legacy/unknown. */
295
- declare function getTier(coinType: string): 1 | 2 | undefined;
296
- /**
297
- * Get decimals for any coin type. Checks full type match, then suffix match, then defaults to 9.
298
- * Works for both tiered and legacy tokens.
299
- */
300
- declare function getDecimalsForCoinType(coinType: string): number;
301
- /**
302
- * Resolve a full coin type to a user-friendly symbol.
303
- * Returns the last `::` segment if not in the registry.
304
- */
305
- declare function resolveSymbol(coinType: string): string;
306
- /**
307
- * Name → type map for swap resolution. Derived from COIN_REGISTRY.
308
- * Contains BOTH original-case and UPPERCASE keys for case-insensitive lookup.
309
- */
310
- declare const TOKEN_MAP: Record<string, string>;
311
- /**
312
- * Resolve a user-friendly token name to its full coin type.
313
- * Returns the input unchanged if already a full coin type (contains "::").
314
- * Case-insensitive: 'usde', 'USDe', 'USDE' all resolve correctly.
315
- */
316
- declare function resolveTokenType(nameOrType: string): string | null;
317
- /** Common type constants for direct import. */
318
- declare const SUI_TYPE: string;
319
- declare const USDC_TYPE: string;
320
- declare const USDT_TYPE: string;
321
- declare const USDSUI_TYPE: string;
322
- declare const USDE_TYPE: string;
323
- declare const ETH_TYPE: string;
324
- declare const WBTC_TYPE: string;
325
- declare const WAL_TYPE: string;
326
- declare const NAVX_TYPE: string;
327
- declare const IKA_TYPE: string;
328
- declare const LOFI_TYPE: string;
329
- declare const MANIFEST_TYPE: string;
330
-
331
347
  /**
332
348
  * Shared transaction classifier.
333
349
  *
@@ -648,4 +664,4 @@ interface TxMetadata {
648
664
  declare const OUTBOUND_OPS: Set<"save" | "borrow" | "withdraw" | "repay" | "send" | "pay">;
649
665
  declare const DEFAULT_SAFEGUARD_CONFIG: SafeguardConfig;
650
666
 
651
- export { ZkLoginSigner as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxDirection as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, type TxMetadata as Q, USDC_TYPE as R, SAVE_FEE_BPS as S, T2000Error as T, USDC_DECIMALS as U, USDE_TYPE as V, USDSUI_TYPE as W, USDT_TYPE as X, WAL_TYPE as Y, WBTC_TYPE as Z, type ZkLoginProof as _, BPS_DENOMINATOR as a, addFeeTransfer as a0, calculateFee as a1, classifyAction as a2, classifyLabel as a3, classifyTransaction as a4, extractAllUserLegs as a5, extractTransferDetails as a6, extractTxCommands as a7, extractTxSender as a8, fallbackLabel as a9, GASLESS_MIN_STABLE_AMOUNT as aA, GASLESS_STABLE_TYPES as aB, OPERATION_ASSETS as aC, type Operation as aD, SAVEABLE_ASSETS as aE, SENDABLE_ASSETS as aF, type SaveableAsset as aG, assertAllowedAsset as aH, createSuiClient as aI, getCoinMeta as aJ, getSuiClient as aK, getSuiGrpcClient as aL, isAllowedAsset as aM, isInRegistry as aN, normalizeAsset as aO, normalizeCoinType as aP, queryHistory as aQ, queryTransaction as aR, simulateTransaction as aS, throwIfSimulationFailed as aT, formatAssetAmount as aa, formatSui as ab, formatUsd as ac, getDecimals as ad, getDecimalsForCoinType as ae, getTier as af, isSupported as ag, isTier1 as ah, isTier2 as ai, mapMoveAbortCode as aj, mapWalletError as ak, mistToSui as al, parseSuiRpcTx as am, rawToStable as an, rawToUsdc as ao, refineLendingLabel as ap, resolveSymbol as aq, resolveTokenType as ar, stableToRaw as as, suiToMist as at, truncateAddress as au, usdcToRaw as av, validateAddress as aw, type SendableAsset as ax, CETUS_USDC_SUI_POOL as ay, DEFAULT_GRPC_URL as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, STABLE_ASSETS as k, SUI_DECIMALS as l, SUI_TYPE as m, SUPPORTED_ASSETS as n, type SafeguardConfig as o, SafeguardError as p, type SafeguardErrorDetails as q, type SafeguardRule as r, type SimulationResult as s, type StableAsset as t, type SuiRpcTxBlock as u, type SupportedAsset as v, type T2000ErrorCode as w, type T2000ErrorData as x, T2000_OVERLAY_FEE_WALLET as y, TOKEN_MAP as z };
667
+ export { ZkLoginSigner as $, ALL_NAVI_ASSETS as A, BORROW_FEE_BPS as B, CLOCK_ID as C, DEFAULT_NETWORK as D, ETH_TYPE as E, type FeeOperation as F, GAS_RESERVE_MIN as G, type TransactionSigner as H, IKA_TYPE as I, type TxDirection as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OUTBOUND_OPS as O, type ProtocolFeeInfo as P, type TxMetadata as Q, USDC_TYPE as R, SAVE_FEE_BPS as S, T2000Error as T, USDC_DECIMALS as U, USDE_TYPE as V, USDSUI_TYPE as W, USDT_TYPE as X, WAL_TYPE as Y, WBTC_TYPE as Z, type ZkLoginProof as _, BPS_DENOMINATOR as a, addFeeTransfer as a0, calculateFee as a1, classifyAction as a2, classifyLabel as a3, classifyTransaction as a4, executeTx as a5, extractAllUserLegs as a6, extractTransferDetails as a7, extractTxCommands as a8, extractTxSender as a9, CETUS_USDC_SUI_POOL as aA, DEFAULT_GRPC_URL as aB, GASLESS_MIN_STABLE_AMOUNT as aC, GASLESS_STABLE_TYPES as aD, OPERATION_ASSETS as aE, type Operation as aF, SAVEABLE_ASSETS as aG, SENDABLE_ASSETS as aH, type SaveableAsset as aI, assertAllowedAsset as aJ, createSuiClient as aK, getCoinMeta as aL, getSuiClient as aM, getSuiGrpcClient as aN, isAllowedAsset as aO, isInRegistry as aP, normalizeAsset as aQ, normalizeCoinType as aR, queryHistory as aS, queryTransaction as aT, simulateTransaction as aU, throwIfSimulationFailed as aV, fallbackLabel as aa, formatAssetAmount as ab, formatSui as ac, formatUsd as ad, getDecimals as ae, getDecimalsForCoinType as af, getTier as ag, isSupported as ah, isTier1 as ai, isTier2 as aj, mapMoveAbortCode as ak, mapWalletError as al, mistToSui as am, parseSuiRpcTx as an, payWithMpp as ao, rawToStable as ap, rawToUsdc as aq, refineLendingLabel as ar, resolveSymbol as as, resolveTokenType as at, stableToRaw as au, suiToMist as av, truncateAddress as aw, usdcToRaw as ax, validateAddress as ay, type SendableAsset as az, COIN_REGISTRY as b, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_SAFEGUARD_CONFIG as f, type ExtractedTransfer as g, KeypairSigner as h, LOFI_TYPE as i, MIST_PER_SUI as j, STABLE_ASSETS as k, SUI_DECIMALS as l, SUI_TYPE as m, SUPPORTED_ASSETS as n, type SafeguardConfig as o, SafeguardError as p, type SafeguardErrorDetails as q, type SafeguardRule as r, type SimulationResult as s, type StableAsset as t, type SuiRpcTxBlock as u, type SupportedAsset as v, type T2000ErrorCode as w, type T2000ErrorData as x, T2000_OVERLAY_FEE_WALLET as y, TOKEN_MAP as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t2000/sdk",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "TypeScript SDK for Agent Wallets on Sui — gasless USDC + USDsui transfers, Cetus swap routing, NAVI lending (programmatic), MPP paid API access, zkLogin compatible.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",