@t2000/sdk 3.3.0 → 4.0.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 { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-C1DH4kPA.cjs';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, aA as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, aB as SaveableAsset, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aC as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aD as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aE as isAllowedAsset, aF as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aG as normalizeAsset, aH as normalizeCoinType, am as parseSuiRpcTx, aI as queryHistory, aJ as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aK as simulateTransaction, as as stableToRaw, at as suiToMist, aL as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-C1DH4kPA.cjs';
4
+ import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, v as SupportedAsset, _ as ZkLoginProof, ax as SendableAsset } from './types-CqpN8a8R.cjs';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ay as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, az as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aA as GASLESS_MIN_STABLE_AMOUNT, aB as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, aD as Operation, P as ProtocolFeeInfo, aE as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aF as SENDABLE_ASSETS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, aG as SaveableAsset, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aH as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aI as createSuiClient, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aJ as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, aK as getSuiClient, aL as getSuiGrpcClient, af as getTier, aM as isAllowedAsset, aN as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aO as normalizeAsset, aP as normalizeCoinType, am as parseSuiRpcTx, aQ as queryHistory, aR as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aS as simulateTransaction, as as stableToRaw, at as suiToMist, aT as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-CqpN8a8R.cjs';
6
6
  import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DqIb4AnV.cjs';
7
7
  export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DqIb4AnV.cjs';
8
8
  import { n as T2000Options, P as PayOptions, d as PayResult, o as SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, s as FinancialSummary } from './types-HJGbXJ37.cjs';
@@ -10,6 +10,7 @@ export { A as AssetRates, G as GasReserve, t as HFAlertLevel, O as OVERLAY_FEE_R
10
10
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
11
11
  import { SuinsClient } from '@mysten/suins';
12
12
  export { NaviAdapter, ProtocolRegistry } from './adapters/index.cjs';
13
+ import '@mysten/sui/grpc';
13
14
  import '@cetusprotocol/aggregator-sdk';
14
15
 
15
16
  declare class SafeguardEnforcer {
@@ -95,8 +96,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
95
96
  network?: 'mainnet' | 'testnet';
96
97
  rpcUrl?: string;
97
98
  }): T2000;
98
- static init(options: {
99
- pin: string;
99
+ static init(options?: {
100
+ pin?: string;
100
101
  passphrase?: string;
101
102
  keyPath?: string;
102
103
  name?: string;
@@ -134,10 +135,31 @@ declare class T2000 extends EventEmitter<T2000Events> {
134
135
  providers?: string[];
135
136
  }): Promise<SwapQuoteResult>;
136
137
  address(): string;
138
+ /**
139
+ * Send `amount` of `asset` to `to` (hex address, SuiNS name, or
140
+ * `@audric` handle / saved contact).
141
+ *
142
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
143
+ *
144
+ * **Breaking changes from v3.x:**
145
+ * - `asset` is now REQUIRED (no implicit `?? 'USDC'` default). Callers
146
+ * must specify `'USDC' | 'USDsui' | 'SUI'`. Sending `'USDT'` /
147
+ * `'USDe'` / `'WAL'` / `'ETH'` / `'NAVX'` / `'GOLD'` now errors
148
+ * with `INVALID_ASSET` — swap to a stable first.
149
+ * - USDC + USDsui builds go through `SuiGrpcClient` so the gRPC build
150
+ * resolver auto-detects `0x2::balance::send_funds` eligibility and
151
+ * zeros gas at simulate time. Result: **gasless USDC / USDsui sends
152
+ * from a zero-SUI wallet.** SUI sends stay on the standard gas-paid
153
+ * path.
154
+ *
155
+ * Submission stays on the JSON-RPC client (the rest of the SDK
156
+ * expects JSON-RPC for read paths, and Sui's docs explicitly support
157
+ * the "build via gRPC, execute via JSON-RPC" hybrid).
158
+ */
137
159
  send(params: {
138
160
  to: string;
139
161
  amount: number;
140
- asset?: string;
162
+ asset: SupportedAsset;
141
163
  }): Promise<SendResult>;
142
164
  /**
143
165
  * [S.279 / CLI-CONTACTS-CLEANUP — 2026-05-23] Resolve a recipient
@@ -177,11 +199,12 @@ declare class T2000 extends EventEmitter<T2000Events> {
177
199
  transactionDetail(digest: string): Promise<TransactionRecord | null>;
178
200
  deposit(): Promise<DepositInfo>;
179
201
  /**
180
- * [SPEC_AGENTIC_STACK P1 / SDK F2 (CLI rename support) 2026-05-25]
181
- * Preferred alias of `deposit()`. The CLI surface is `t2000 fund` post-Phase 1
182
- * (more intuitive than "deposit" which sounds like a NAVI lending action).
183
- * `deposit()` stays as the canonical method name for back-compat; it is NOT
184
- * deprecated. This wrapper exists so SDK consumers can mirror CLI naming.
202
+ * [SPEC_AGENTIC_STACK P1 / SDK F2 2026-05-25; refreshed S.342 / 2026-05-26]
203
+ * Preferred alias of `deposit()`. Was introduced to mirror the v3 `t2000 fund`
204
+ * CLI command; the v4 CLI surface is `t2 receive` (deleted `fund` in the
205
+ * S.332 bulk cut). `deposit()` stays as the canonical method name for
206
+ * back-compat; `fund()` stays as a programmatic alias for audric + other
207
+ * SDK consumers that prefer the verb.
185
208
  */
186
209
  fund(): Promise<DepositInfo>;
187
210
  receive(params?: {
@@ -377,18 +400,70 @@ declare function normalizeAddressInput(value: string, ctx?: {
377
400
 
378
401
  declare function generateKeypair(): Ed25519Keypair;
379
402
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
380
- declare function saveKey(keypair: Ed25519Keypair, passphrase: string, keyPath?: string): Promise<string>;
381
- declare function loadKey(passphrase: string, keyPath?: string): Promise<Ed25519Keypair>;
403
+ /**
404
+ * Save a keypair as a v2 plain Bech32 JSON file with `0o600` perms.
405
+ *
406
+ * `_passphrase` is accepted but IGNORED — kept in the signature for
407
+ * back-compat with v3.x callers. Will be removed when all callers
408
+ * are off PIN (Phase A Day 5+).
409
+ */
410
+ declare function saveKey(keypair: Ed25519Keypair, _passphrase: string | undefined, keyPath?: string): Promise<string>;
411
+ /**
412
+ * Save a Bech32 secret directly as a v2 plain wallet file. Used by any
413
+ * path where the secret is supplied externally rather than freshly
414
+ * generated. Kept exported because external tooling may still want it
415
+ * even though the CLI no longer ships an `--import` flag.
416
+ */
417
+ declare function saveBech32(secret: string, keyPath?: string): Promise<string>;
418
+ /**
419
+ * Load a keypair from disk.
420
+ *
421
+ * `_passphrase` is accepted but IGNORED — kept for back-compat. The
422
+ * actual file format determines the load path:
423
+ *
424
+ * - **v2 plain JSON** (`{ version: 2, secret: "suiprivkey1..." }`) →
425
+ * decode + return keypair.
426
+ * - **Anything else** → throw `WALLET_CORRUPT`. The user moves or
427
+ * deletes the file and runs `t2 init` to create a fresh wallet.
428
+ */
429
+ declare function loadKey(_passphrase?: string, keyPath?: string): Promise<Ed25519Keypair>;
382
430
  declare function walletExists(keyPath?: string): Promise<boolean>;
383
431
  declare function exportPrivateKey(keypair: Ed25519Keypair): string;
384
432
  declare function getAddress(keypair: Ed25519Keypair): string;
385
433
 
434
+ /**
435
+ * Build a PTB that sends `amount` of `asset` from `address` to `to`.
436
+ *
437
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
438
+ *
439
+ * Asset constraint: `'USDC' | 'USDsui' | 'SUI'` only. Other assets throw
440
+ * `INVALID_ASSET` via `assertAllowedAsset('send', asset)`. The constrained
441
+ * set matches Sui mainnet's gasless allowlist (USDC + USDsui) plus SUI
442
+ * for users who want a gas-native transfer.
443
+ *
444
+ * Build paths:
445
+ * - **USDC / USDsui** — `0x2::balance::send_funds` Move call with a
446
+ * `tx.balance({ type, balance })` input. When built via `SuiGrpcClient`,
447
+ * the gRPC resolver auto-detects gasless eligibility and zeros gas.
448
+ * When built via `SuiJsonRpcClient`, the same PTB still executes but
449
+ * the caller pays normal gas. Minimum 0.01 (protocol allowlist floor).
450
+ * - **SUI** — `tx.splitCoins(tx.gas, [amount]) → tx.transferObjects()`.
451
+ * Standard gas-native transfer. No minimum.
452
+ *
453
+ * Pre-flight balance check stays on JSON-RPC (`client.getBalance`) — it
454
+ * sums coin objects + address balance so the legacy `getCoins` page miss
455
+ * doesn't break for users whose stables landed via gasless deposits.
456
+ *
457
+ * `asset` is REQUIRED (no implicit USDC default — pre-v4 hid LLM intent
458
+ * errors). Callers passing the wrong asset get an explicit error rather
459
+ * than a silent currency substitution.
460
+ */
386
461
  declare function buildSendTx({ client, address, to, amount, asset, }: {
387
462
  client: SuiJsonRpcClient;
388
463
  address: string;
389
464
  to: string;
390
465
  amount: number;
391
- asset?: SupportedAsset;
466
+ asset: SendableAsset;
392
467
  }): Promise<Transaction>;
393
468
  /**
394
469
  * Fragment-appender for the chain-mode send leg of SPEC 7 multi-write
@@ -408,6 +483,13 @@ declare function buildSendTx({ client, address, to, amount, asset, }: {
408
483
  * `buildSendTx` directly — it builds a complete tx including the
409
484
  * wallet-coin selection / merge / split prelude.
410
485
  *
486
+ * [v4.0 Phase A Day 2] Stays on the legacy `transferObjects` path
487
+ * because chain-mode bundles are NEVER gasless — by definition they
488
+ * combine multiple Move calls (`withdraw → send`, `swap → send`) which
489
+ * fail the protocol allowlist check (only `balance::send_funds` and
490
+ * a few related helpers are eligible). The bundled flow still works,
491
+ * the user just pays gas (or has it sponsored by audric via Enoki).
492
+ *
411
493
  * @returns void — the coin is consumed by `tx.transferObjects`. Callers
412
494
  * that need the post-transfer "effective amount" should rely on the
413
495
  * upstream appender's `effectiveAmount` (e.g. `addWithdrawToTx`'s
@@ -605,10 +687,29 @@ interface RepayDebtInput {
605
687
  amount: number;
606
688
  asset?: 'USDC' | 'USDsui';
607
689
  }
690
+ /**
691
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
692
+ * `asset` is now REQUIRED (no more silent USDC default). The parameter
693
+ * type is the wider `SupportedAsset` rather than the narrower
694
+ * `SendableAsset` so callers that thread a wide-typed asset through
695
+ * (primarily the engine LLM tool surface) compile without modification.
696
+ * Runtime narrowing happens via `assertAllowedAsset('send', asset)`,
697
+ * which throws `INVALID_ASSET` for anything outside the
698
+ * `['USDC', 'USDsui', 'SUI']` whitelist. USDC + USDsui route through
699
+ * the gasless `0x2::balance::send_funds` Move call; SUI uses the
700
+ * standard `transferObjects` path.
701
+ *
702
+ * Audric hosts: the audric chat client (`audric-chat-client.tsx`)
703
+ * already defaults asset to `'USDC'` at the marker layer before
704
+ * calling `sponsoredTx({ type: 'send' })`, so this signature change
705
+ * doesn't break the LLM flow. LLM intents like "send 5 WAL" now
706
+ * surface a clear error instead of silently building a non-gasless
707
+ * tx.
708
+ */
608
709
  interface SendTransferInput {
609
710
  to: string;
610
711
  amount: number;
611
- asset?: SupportedAsset;
712
+ asset: SupportedAsset;
612
713
  }
613
714
  interface SwapExecuteInput {
614
715
  from: string;
@@ -790,7 +891,7 @@ type StepPreview = {
790
891
  toolName: 'send_transfer';
791
892
  effectiveAmount: number;
792
893
  recipient: string;
793
- asset: SupportedAsset;
894
+ asset: SendableAsset;
794
895
  } | {
795
896
  toolName: 'swap_execute';
796
897
  effectiveAmountIn: number;
@@ -1387,4 +1488,4 @@ declare function fullHandle(label: string): string;
1387
1488
  */
1388
1489
  declare function displayHandle(label: string): string;
1389
1490
 
1390
- export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, InvalidAddressError, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
1491
+ export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, InvalidAddressError, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, _ as ZkLoginProof, v as SupportedAsset } from './types-DjeENMuV.js';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ax as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, ay as OPERATION_ASSETS, O as OUTBOUND_OPS, az as Operation, P as ProtocolFeeInfo, aA as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, aB as SaveableAsset, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aC as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aD as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, af as getTier, aE as isAllowedAsset, aF as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aG as normalizeAsset, aH as normalizeCoinType, am as parseSuiRpcTx, aI as queryHistory, aJ as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aK as simulateTransaction, as as stableToRaw, at as suiToMist, aL as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-DjeENMuV.js';
4
+ import { Q as TxMetadata, o as SafeguardConfig, T as T2000Error, H as TransactionSigner, v as SupportedAsset, _ as ZkLoginProof, ax as SendableAsset } from './types-_U9XXGFR.js';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, ay as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, az as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, aA as GASLESS_MIN_STABLE_AMOUNT, aB as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, aD as Operation, P as ProtocolFeeInfo, aE as SAVEABLE_ASSETS, S as SAVE_FEE_BPS, aF as SENDABLE_ASSETS, k as STABLE_ASSETS, l as SUI_DECIMALS, m as SUI_TYPE, n as SUPPORTED_ASSETS, p as SafeguardError, q as SafeguardErrorDetails, r as SafeguardRule, aG as SaveableAsset, s as SimulationResult, t as StableAsset, u as SuiRpcTxBlock, w as T2000ErrorCode, x as T2000ErrorData, y as T2000_OVERLAY_FEE_WALLET, z as TOKEN_MAP, J as TxDirection, U as USDC_DECIMALS, R as USDC_TYPE, V as USDE_TYPE, W as USDSUI_TYPE, X as USDT_TYPE, Y as WAL_TYPE, Z as WBTC_TYPE, $ as ZkLoginSigner, a0 as addFeeTransfer, aH as assertAllowedAsset, a1 as calculateFee, a2 as classifyAction, a3 as classifyLabel, a4 as classifyTransaction, aI as createSuiClient, a5 as extractAllUserLegs, a6 as extractTransferDetails, a7 as extractTxCommands, a8 as extractTxSender, a9 as fallbackLabel, aa as formatAssetAmount, ab as formatSui, ac as formatUsd, aJ as getCoinMeta, ad as getDecimals, ae as getDecimalsForCoinType, aK as getSuiClient, aL as getSuiGrpcClient, af as getTier, aM as isAllowedAsset, aN as isInRegistry, ag as isSupported, ah as isTier1, ai as isTier2, aj as mapMoveAbortCode, ak as mapWalletError, al as mistToSui, aO as normalizeAsset, aP as normalizeCoinType, am as parseSuiRpcTx, aQ as queryHistory, aR as queryTransaction, an as rawToStable, ao as rawToUsdc, ap as refineLendingLabel, aq as resolveSymbol, ar as resolveTokenType, aS as simulateTransaction, as as stableToRaw, at as suiToMist, aT as throwIfSimulationFailed, au as truncateAddress, av as usdcToRaw, aw as validateAddress } from './types-_U9XXGFR.js';
6
6
  import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DqIb4AnV.js';
7
7
  export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DqIb4AnV.js';
8
8
  import { n as T2000Options, P as PayOptions, d as PayResult, o as SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, j as SwapRouteResult, s as FinancialSummary } from './types-HJGbXJ37.js';
@@ -10,6 +10,7 @@ export { A as AssetRates, G as GasReserve, t as HFAlertLevel, O as OVERLAY_FEE_R
10
10
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
11
11
  import { SuinsClient } from '@mysten/suins';
12
12
  export { NaviAdapter, ProtocolRegistry } from './adapters/index.js';
13
+ import '@mysten/sui/grpc';
13
14
  import '@cetusprotocol/aggregator-sdk';
14
15
 
15
16
  declare class SafeguardEnforcer {
@@ -95,8 +96,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
95
96
  network?: 'mainnet' | 'testnet';
96
97
  rpcUrl?: string;
97
98
  }): T2000;
98
- static init(options: {
99
- pin: string;
99
+ static init(options?: {
100
+ pin?: string;
100
101
  passphrase?: string;
101
102
  keyPath?: string;
102
103
  name?: string;
@@ -134,10 +135,31 @@ declare class T2000 extends EventEmitter<T2000Events> {
134
135
  providers?: string[];
135
136
  }): Promise<SwapQuoteResult>;
136
137
  address(): string;
138
+ /**
139
+ * Send `amount` of `asset` to `to` (hex address, SuiNS name, or
140
+ * `@audric` handle / saved contact).
141
+ *
142
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
143
+ *
144
+ * **Breaking changes from v3.x:**
145
+ * - `asset` is now REQUIRED (no implicit `?? 'USDC'` default). Callers
146
+ * must specify `'USDC' | 'USDsui' | 'SUI'`. Sending `'USDT'` /
147
+ * `'USDe'` / `'WAL'` / `'ETH'` / `'NAVX'` / `'GOLD'` now errors
148
+ * with `INVALID_ASSET` — swap to a stable first.
149
+ * - USDC + USDsui builds go through `SuiGrpcClient` so the gRPC build
150
+ * resolver auto-detects `0x2::balance::send_funds` eligibility and
151
+ * zeros gas at simulate time. Result: **gasless USDC / USDsui sends
152
+ * from a zero-SUI wallet.** SUI sends stay on the standard gas-paid
153
+ * path.
154
+ *
155
+ * Submission stays on the JSON-RPC client (the rest of the SDK
156
+ * expects JSON-RPC for read paths, and Sui's docs explicitly support
157
+ * the "build via gRPC, execute via JSON-RPC" hybrid).
158
+ */
137
159
  send(params: {
138
160
  to: string;
139
161
  amount: number;
140
- asset?: string;
162
+ asset: SupportedAsset;
141
163
  }): Promise<SendResult>;
142
164
  /**
143
165
  * [S.279 / CLI-CONTACTS-CLEANUP — 2026-05-23] Resolve a recipient
@@ -177,11 +199,12 @@ declare class T2000 extends EventEmitter<T2000Events> {
177
199
  transactionDetail(digest: string): Promise<TransactionRecord | null>;
178
200
  deposit(): Promise<DepositInfo>;
179
201
  /**
180
- * [SPEC_AGENTIC_STACK P1 / SDK F2 (CLI rename support) 2026-05-25]
181
- * Preferred alias of `deposit()`. The CLI surface is `t2000 fund` post-Phase 1
182
- * (more intuitive than "deposit" which sounds like a NAVI lending action).
183
- * `deposit()` stays as the canonical method name for back-compat; it is NOT
184
- * deprecated. This wrapper exists so SDK consumers can mirror CLI naming.
202
+ * [SPEC_AGENTIC_STACK P1 / SDK F2 2026-05-25; refreshed S.342 / 2026-05-26]
203
+ * Preferred alias of `deposit()`. Was introduced to mirror the v3 `t2000 fund`
204
+ * CLI command; the v4 CLI surface is `t2 receive` (deleted `fund` in the
205
+ * S.332 bulk cut). `deposit()` stays as the canonical method name for
206
+ * back-compat; `fund()` stays as a programmatic alias for audric + other
207
+ * SDK consumers that prefer the verb.
185
208
  */
186
209
  fund(): Promise<DepositInfo>;
187
210
  receive(params?: {
@@ -377,18 +400,70 @@ declare function normalizeAddressInput(value: string, ctx?: {
377
400
 
378
401
  declare function generateKeypair(): Ed25519Keypair;
379
402
  declare function keypairFromPrivateKey(privateKey: string): Ed25519Keypair;
380
- declare function saveKey(keypair: Ed25519Keypair, passphrase: string, keyPath?: string): Promise<string>;
381
- declare function loadKey(passphrase: string, keyPath?: string): Promise<Ed25519Keypair>;
403
+ /**
404
+ * Save a keypair as a v2 plain Bech32 JSON file with `0o600` perms.
405
+ *
406
+ * `_passphrase` is accepted but IGNORED — kept in the signature for
407
+ * back-compat with v3.x callers. Will be removed when all callers
408
+ * are off PIN (Phase A Day 5+).
409
+ */
410
+ declare function saveKey(keypair: Ed25519Keypair, _passphrase: string | undefined, keyPath?: string): Promise<string>;
411
+ /**
412
+ * Save a Bech32 secret directly as a v2 plain wallet file. Used by any
413
+ * path where the secret is supplied externally rather than freshly
414
+ * generated. Kept exported because external tooling may still want it
415
+ * even though the CLI no longer ships an `--import` flag.
416
+ */
417
+ declare function saveBech32(secret: string, keyPath?: string): Promise<string>;
418
+ /**
419
+ * Load a keypair from disk.
420
+ *
421
+ * `_passphrase` is accepted but IGNORED — kept for back-compat. The
422
+ * actual file format determines the load path:
423
+ *
424
+ * - **v2 plain JSON** (`{ version: 2, secret: "suiprivkey1..." }`) →
425
+ * decode + return keypair.
426
+ * - **Anything else** → throw `WALLET_CORRUPT`. The user moves or
427
+ * deletes the file and runs `t2 init` to create a fresh wallet.
428
+ */
429
+ declare function loadKey(_passphrase?: string, keyPath?: string): Promise<Ed25519Keypair>;
382
430
  declare function walletExists(keyPath?: string): Promise<boolean>;
383
431
  declare function exportPrivateKey(keypair: Ed25519Keypair): string;
384
432
  declare function getAddress(keypair: Ed25519Keypair): string;
385
433
 
434
+ /**
435
+ * Build a PTB that sends `amount` of `asset` from `address` to `to`.
436
+ *
437
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
438
+ *
439
+ * Asset constraint: `'USDC' | 'USDsui' | 'SUI'` only. Other assets throw
440
+ * `INVALID_ASSET` via `assertAllowedAsset('send', asset)`. The constrained
441
+ * set matches Sui mainnet's gasless allowlist (USDC + USDsui) plus SUI
442
+ * for users who want a gas-native transfer.
443
+ *
444
+ * Build paths:
445
+ * - **USDC / USDsui** — `0x2::balance::send_funds` Move call with a
446
+ * `tx.balance({ type, balance })` input. When built via `SuiGrpcClient`,
447
+ * the gRPC resolver auto-detects gasless eligibility and zeros gas.
448
+ * When built via `SuiJsonRpcClient`, the same PTB still executes but
449
+ * the caller pays normal gas. Minimum 0.01 (protocol allowlist floor).
450
+ * - **SUI** — `tx.splitCoins(tx.gas, [amount]) → tx.transferObjects()`.
451
+ * Standard gas-native transfer. No minimum.
452
+ *
453
+ * Pre-flight balance check stays on JSON-RPC (`client.getBalance`) — it
454
+ * sums coin objects + address balance so the legacy `getCoins` page miss
455
+ * doesn't break for users whose stables landed via gasless deposits.
456
+ *
457
+ * `asset` is REQUIRED (no implicit USDC default — pre-v4 hid LLM intent
458
+ * errors). Callers passing the wrong asset get an explicit error rather
459
+ * than a silent currency substitution.
460
+ */
386
461
  declare function buildSendTx({ client, address, to, amount, asset, }: {
387
462
  client: SuiJsonRpcClient;
388
463
  address: string;
389
464
  to: string;
390
465
  amount: number;
391
- asset?: SupportedAsset;
466
+ asset: SendableAsset;
392
467
  }): Promise<Transaction>;
393
468
  /**
394
469
  * Fragment-appender for the chain-mode send leg of SPEC 7 multi-write
@@ -408,6 +483,13 @@ declare function buildSendTx({ client, address, to, amount, asset, }: {
408
483
  * `buildSendTx` directly — it builds a complete tx including the
409
484
  * wallet-coin selection / merge / split prelude.
410
485
  *
486
+ * [v4.0 Phase A Day 2] Stays on the legacy `transferObjects` path
487
+ * because chain-mode bundles are NEVER gasless — by definition they
488
+ * combine multiple Move calls (`withdraw → send`, `swap → send`) which
489
+ * fail the protocol allowlist check (only `balance::send_funds` and
490
+ * a few related helpers are eligible). The bundled flow still works,
491
+ * the user just pays gas (or has it sponsored by audric via Enoki).
492
+ *
411
493
  * @returns void — the coin is consumed by `tx.transferObjects`. Callers
412
494
  * that need the post-transfer "effective amount" should rely on the
413
495
  * upstream appender's `effectiveAmount` (e.g. `addWithdrawToTx`'s
@@ -605,10 +687,29 @@ interface RepayDebtInput {
605
687
  amount: number;
606
688
  asset?: 'USDC' | 'USDsui';
607
689
  }
690
+ /**
691
+ * [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
692
+ * `asset` is now REQUIRED (no more silent USDC default). The parameter
693
+ * type is the wider `SupportedAsset` rather than the narrower
694
+ * `SendableAsset` so callers that thread a wide-typed asset through
695
+ * (primarily the engine LLM tool surface) compile without modification.
696
+ * Runtime narrowing happens via `assertAllowedAsset('send', asset)`,
697
+ * which throws `INVALID_ASSET` for anything outside the
698
+ * `['USDC', 'USDsui', 'SUI']` whitelist. USDC + USDsui route through
699
+ * the gasless `0x2::balance::send_funds` Move call; SUI uses the
700
+ * standard `transferObjects` path.
701
+ *
702
+ * Audric hosts: the audric chat client (`audric-chat-client.tsx`)
703
+ * already defaults asset to `'USDC'` at the marker layer before
704
+ * calling `sponsoredTx({ type: 'send' })`, so this signature change
705
+ * doesn't break the LLM flow. LLM intents like "send 5 WAL" now
706
+ * surface a clear error instead of silently building a non-gasless
707
+ * tx.
708
+ */
608
709
  interface SendTransferInput {
609
710
  to: string;
610
711
  amount: number;
611
- asset?: SupportedAsset;
712
+ asset: SupportedAsset;
612
713
  }
613
714
  interface SwapExecuteInput {
614
715
  from: string;
@@ -790,7 +891,7 @@ type StepPreview = {
790
891
  toolName: 'send_transfer';
791
892
  effectiveAmount: number;
792
893
  recipient: string;
793
- asset: SupportedAsset;
894
+ asset: SendableAsset;
794
895
  } | {
795
896
  toolName: 'swap_execute';
796
897
  effectiveAmountIn: number;
@@ -1387,4 +1488,4 @@ declare function fullHandle(label: string): string;
1387
1488
  */
1388
1489
  declare function displayHandle(label: string): string;
1389
1490
 
1390
- export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, InvalidAddressError, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
1491
+ export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, InvalidAddressError, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };