@t2000/sdk 10.27.1 → 10.28.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.
- package/dist/browser.cjs +55 -50
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +55 -52
- package/dist/browser.js.map +1 -1
- package/dist/{commerce-DR_F-Eg6.d.cts → commerce-B6_F6JYi.d.cts} +56 -23
- package/dist/{commerce-DR_F-Eg6.d.ts → commerce-B6_F6JYi.d.ts} +56 -23
- package/dist/index.cjs +92 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -14
- package/dist/index.d.ts +13 -14
- package/dist/index.js +91 -51
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 {
|
|
5
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig,
|
|
4
|
+
import { _ as T2000Error, b7 as T2000Options, a5 as TransactionSigner, w as PayOptions, b8 as X402Probe, x as PayResult, b9 as SerializedCetusRoute, ba as SwapResult, bb as SwapQuoteResult, R as SendResult, B as BalanceResponse, a4 as TransactionRecord, i as DepositInfo, bc as PaymentRequest, af as ZkLoginProof, bd as SuiCoreClient, u as OverlayFeeConfig, be as SponsoredCoinMergeCache, Y as SupportedAsset, Z as SwapRouteResult, bf as SendableAsset } from './commerce-B6_F6JYi.cjs';
|
|
5
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, bg as CETUS_USDC_SUI_POOL, C as CLOCK_ID, c as COIN_REGISTRY, d as ClassifyBalanceChange, e as ClassifyResult, f as CoinMeta, bh as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, g as DEFAULT_COMMERCE_API_BASE, bi as DEFAULT_GRPC_URL, h as DEFAULT_NETWORK, E as ETH_TYPE, j as ExtractedTransfer, bj as GASLESS_MIN_STABLE_AMOUNT, bk as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, k as Job, l as JobState, m as JobTerms, n as JobVerification, K as KNOWN_TARGETS, o as KeypairSigner, L as LABEL_PATTERNS, p as LOFI_TYPE, bl as MAINNET_A2A_ESCROW_PACKAGE_ID, M as MANIFEST_TYPE, q as MAX_DELIVER_HORIZON_MS, r as MAX_JOB_USDC, s as MAX_REVIEW_WINDOW_MS, t as MIST_PER_SUI, N as NAVX_TYPE, bm as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bn as Operation, P as PREFLIGHT_MAX_AMOUNT, v as PREFLIGHT_OK, y as PreflightResult, bo as SENDABLE_ASSETS, S as STABLE_ASSETS, z as SUI_DECIMALS, F as SUI_TYPE, H as SUPPORTED_ASSETS, bp as SelectAndSplitResult, Q as SendAssetClass, bq as SerializedCetusRoutePath, br as SerializedRouterDataV3, T as ServiceListing, U as SimulationResult, V as StableAsset, W as SuiHolding, X as SuiRpcTxBlock, $ as T2000ErrorCode, a0 as T2000ErrorData, a1 as T2000_OVERLAY_FEE_WALLET, a2 as TOKEN_MAP, a3 as TransactionLeg, a6 as TxDirection, a7 as USDC_DECIMALS, a8 as USDC_TYPE, a9 as USDE_TYPE, aa as USDSUI_TYPE, ab as USDT_TYPE, ac as WAL_TYPE, ad as WBTC_TYPE, ae as X402ActivityPayload, ag as ZkLoginSigner, bs as addSendToTx, bt as addSwapToTx, bu as assertAllowedAsset, bv as assertBuyerRequirements, ah as buildCreateJobTx, bw as buildDeclineJobTx, ai as buildDeliverJobTx, aj as buildRefundJobTx, ak as buildRejectJobTx, al as buildReleaseJobTx, am as buildSendTx, an as buildSwapTx, ao as checkPositiveAmount, ap as checkSuiAddress, aq as classifyAction, ar as classifyLabel, as as classifySendAsset, at as classifyTransaction, bx as deserializeCetusRoute, au as executeTx, av as extractAllUserLegs, aw as extractTransferDetails, ax as extractTxCommands, ay as extractTxSender, az as fallbackLabel, by as fetchAllCoins, aA as fetchService, aB as findSwapRoute, aC as formatAssetAmount, aD as formatSui, aE as formatUsd, bz as getCoinMeta, aF as getDecimals, aG as getDecimalsForCoinType, aH as getJob, aI as getJobSpec, bA as getSuiClient, bB as getSuiGrpcClient, aJ as invalidSendAssetMessage, bC as isAllowedAsset, bD as isCetusRouteFresh, bE as isInRegistry, aK as jobActionsFor, aL as listServices, aM as mapMoveAbortCode, aN as mapWalletError, aO as mistToSui, bF as normalizeAsset, bG as normalizeCoinType, aP as parseSuiRpcTx, aQ as payWithX402, aR as preflightCreateJob, aS as preflightFail, aT as preflightPay, aU as preflightSend, aV as preflightSwap, bH as probeX402, aW as putJobSpec, bI as queryHistory, bJ as queryTransaction, aX as rawToStable, aY as rawToUsdc, aZ as refineLendingLabel, a_ as reportX402Activity, a$ as resolveSymbol, b0 as resolveTokenType, bK as selectAndSplitCoin, bL as selectSuiCoin, bM as serializeCetusRoute, bN as simulateTransaction, b1 as stableToRaw, b2 as suiToMist, bO as throwIfSimulationFailed, b3 as truncateAddress, b4 as usdcToRaw, b5 as validateAddress, bP as verifyCetusRouteCoinMatch, b6 as verifyJobForSeller } from './commerce-B6_F6JYi.cjs';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
|
@@ -335,18 +335,17 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
335
335
|
/**
|
|
336
336
|
* Send `amount` of `asset` to `to` (hex address or SuiNS name).
|
|
337
337
|
*
|
|
338
|
-
* [
|
|
338
|
+
* [S.957 — 2026-08-08] `asset` accepts **any held coin type** — a
|
|
339
|
+
* registry symbol (`USDC`, `MANIFEST`) or a full `0x…::module::TYPE`.
|
|
340
|
+
* Unresolvable strings throw `INVALID_ASSET`; empty balances throw
|
|
341
|
+
* `INSUFFICIENT_BALANCE`.
|
|
339
342
|
*
|
|
340
|
-
* **Breaking changes from v3.x:**
|
|
341
|
-
* - `asset` is now REQUIRED (no implicit `?? 'USDC'` default). Callers
|
|
342
|
-
* must specify `'USDC' | 'USDsui' | 'SUI'`. Sending `'USDT'` /
|
|
343
|
-
* `'USDe'` / `'WAL'` / `'ETH'` / `'NAVX'` / `'GOLD'` now errors
|
|
344
|
-
* with `INVALID_ASSET` — swap to a stable first.
|
|
345
343
|
* - USDC + USDsui builds go through `SuiGrpcClient` so the gRPC build
|
|
346
344
|
* resolver auto-detects `0x2::balance::send_funds` eligibility and
|
|
347
|
-
* zeros gas at simulate time
|
|
348
|
-
*
|
|
349
|
-
*
|
|
345
|
+
* zeros gas at simulate time — **gasless sends from a zero-SUI
|
|
346
|
+
* wallet.** They remain the ONLY gasless assets.
|
|
347
|
+
* - SUI and every other coin type are gas-paid (the sender needs SUI).
|
|
348
|
+
* - `asset` stays REQUIRED (no implicit `?? 'USDC'` default — v4 rule).
|
|
350
349
|
*
|
|
351
350
|
* Submission stays on the JSON-RPC client (the rest of the SDK
|
|
352
351
|
* expects JSON-RPC for read paths, and Sui's docs explicitly support
|
|
@@ -355,7 +354,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
355
354
|
send(params: {
|
|
356
355
|
to: string;
|
|
357
356
|
amount: number;
|
|
358
|
-
asset:
|
|
357
|
+
asset: string;
|
|
359
358
|
force?: boolean;
|
|
360
359
|
}): Promise<SendResult>;
|
|
361
360
|
/**
|
|
@@ -846,8 +845,8 @@ type WriteToolName = 'send_transfer' | 'swap_execute';
|
|
|
846
845
|
* type is the wider `SupportedAsset` rather than the narrower
|
|
847
846
|
* `SendableAsset` so callers that thread a wide-typed asset through
|
|
848
847
|
* (primarily the engine LLM tool surface) compile without modification.
|
|
849
|
-
* Runtime narrowing happens via
|
|
850
|
-
* which throws `INVALID_ASSET` for anything outside the
|
|
848
|
+
* Runtime narrowing happens via the appender's local `SENDABLE_ASSETS`
|
|
849
|
+
* check, which throws `INVALID_ASSET` for anything outside the
|
|
851
850
|
* `['USDC', 'USDsui', 'SUI']` whitelist. USDC + USDsui route through
|
|
852
851
|
* the gasless `0x2::balance::send_funds` Move call; SUI uses the
|
|
853
852
|
* standard `transferObjects` path.
|
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 {
|
|
5
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig,
|
|
4
|
+
import { _ as T2000Error, b7 as T2000Options, a5 as TransactionSigner, w as PayOptions, b8 as X402Probe, x as PayResult, b9 as SerializedCetusRoute, ba as SwapResult, bb as SwapQuoteResult, R as SendResult, B as BalanceResponse, a4 as TransactionRecord, i as DepositInfo, bc as PaymentRequest, af as ZkLoginProof, bd as SuiCoreClient, u as OverlayFeeConfig, be as SponsoredCoinMergeCache, Y as SupportedAsset, Z as SwapRouteResult, bf as SendableAsset } from './commerce-B6_F6JYi.js';
|
|
5
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, bg as CETUS_USDC_SUI_POOL, C as CLOCK_ID, c as COIN_REGISTRY, d as ClassifyBalanceChange, e as ClassifyResult, f as CoinMeta, bh as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, g as DEFAULT_COMMERCE_API_BASE, bi as DEFAULT_GRPC_URL, h as DEFAULT_NETWORK, E as ETH_TYPE, j as ExtractedTransfer, bj as GASLESS_MIN_STABLE_AMOUNT, bk as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, k as Job, l as JobState, m as JobTerms, n as JobVerification, K as KNOWN_TARGETS, o as KeypairSigner, L as LABEL_PATTERNS, p as LOFI_TYPE, bl as MAINNET_A2A_ESCROW_PACKAGE_ID, M as MANIFEST_TYPE, q as MAX_DELIVER_HORIZON_MS, r as MAX_JOB_USDC, s as MAX_REVIEW_WINDOW_MS, t as MIST_PER_SUI, N as NAVX_TYPE, bm as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bn as Operation, P as PREFLIGHT_MAX_AMOUNT, v as PREFLIGHT_OK, y as PreflightResult, bo as SENDABLE_ASSETS, S as STABLE_ASSETS, z as SUI_DECIMALS, F as SUI_TYPE, H as SUPPORTED_ASSETS, bp as SelectAndSplitResult, Q as SendAssetClass, bq as SerializedCetusRoutePath, br as SerializedRouterDataV3, T as ServiceListing, U as SimulationResult, V as StableAsset, W as SuiHolding, X as SuiRpcTxBlock, $ as T2000ErrorCode, a0 as T2000ErrorData, a1 as T2000_OVERLAY_FEE_WALLET, a2 as TOKEN_MAP, a3 as TransactionLeg, a6 as TxDirection, a7 as USDC_DECIMALS, a8 as USDC_TYPE, a9 as USDE_TYPE, aa as USDSUI_TYPE, ab as USDT_TYPE, ac as WAL_TYPE, ad as WBTC_TYPE, ae as X402ActivityPayload, ag as ZkLoginSigner, bs as addSendToTx, bt as addSwapToTx, bu as assertAllowedAsset, bv as assertBuyerRequirements, ah as buildCreateJobTx, bw as buildDeclineJobTx, ai as buildDeliverJobTx, aj as buildRefundJobTx, ak as buildRejectJobTx, al as buildReleaseJobTx, am as buildSendTx, an as buildSwapTx, ao as checkPositiveAmount, ap as checkSuiAddress, aq as classifyAction, ar as classifyLabel, as as classifySendAsset, at as classifyTransaction, bx as deserializeCetusRoute, au as executeTx, av as extractAllUserLegs, aw as extractTransferDetails, ax as extractTxCommands, ay as extractTxSender, az as fallbackLabel, by as fetchAllCoins, aA as fetchService, aB as findSwapRoute, aC as formatAssetAmount, aD as formatSui, aE as formatUsd, bz as getCoinMeta, aF as getDecimals, aG as getDecimalsForCoinType, aH as getJob, aI as getJobSpec, bA as getSuiClient, bB as getSuiGrpcClient, aJ as invalidSendAssetMessage, bC as isAllowedAsset, bD as isCetusRouteFresh, bE as isInRegistry, aK as jobActionsFor, aL as listServices, aM as mapMoveAbortCode, aN as mapWalletError, aO as mistToSui, bF as normalizeAsset, bG as normalizeCoinType, aP as parseSuiRpcTx, aQ as payWithX402, aR as preflightCreateJob, aS as preflightFail, aT as preflightPay, aU as preflightSend, aV as preflightSwap, bH as probeX402, aW as putJobSpec, bI as queryHistory, bJ as queryTransaction, aX as rawToStable, aY as rawToUsdc, aZ as refineLendingLabel, a_ as reportX402Activity, a$ as resolveSymbol, b0 as resolveTokenType, bK as selectAndSplitCoin, bL as selectSuiCoin, bM as serializeCetusRoute, bN as simulateTransaction, b1 as stableToRaw, b2 as suiToMist, bO as throwIfSimulationFailed, b3 as truncateAddress, b4 as usdcToRaw, b5 as validateAddress, bP as verifyCetusRouteCoinMatch, b6 as verifyJobForSeller } from './commerce-B6_F6JYi.js';
|
|
6
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
|
@@ -335,18 +335,17 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
335
335
|
/**
|
|
336
336
|
* Send `amount` of `asset` to `to` (hex address or SuiNS name).
|
|
337
337
|
*
|
|
338
|
-
* [
|
|
338
|
+
* [S.957 — 2026-08-08] `asset` accepts **any held coin type** — a
|
|
339
|
+
* registry symbol (`USDC`, `MANIFEST`) or a full `0x…::module::TYPE`.
|
|
340
|
+
* Unresolvable strings throw `INVALID_ASSET`; empty balances throw
|
|
341
|
+
* `INSUFFICIENT_BALANCE`.
|
|
339
342
|
*
|
|
340
|
-
* **Breaking changes from v3.x:**
|
|
341
|
-
* - `asset` is now REQUIRED (no implicit `?? 'USDC'` default). Callers
|
|
342
|
-
* must specify `'USDC' | 'USDsui' | 'SUI'`. Sending `'USDT'` /
|
|
343
|
-
* `'USDe'` / `'WAL'` / `'ETH'` / `'NAVX'` / `'GOLD'` now errors
|
|
344
|
-
* with `INVALID_ASSET` — swap to a stable first.
|
|
345
343
|
* - USDC + USDsui builds go through `SuiGrpcClient` so the gRPC build
|
|
346
344
|
* resolver auto-detects `0x2::balance::send_funds` eligibility and
|
|
347
|
-
* zeros gas at simulate time
|
|
348
|
-
*
|
|
349
|
-
*
|
|
345
|
+
* zeros gas at simulate time — **gasless sends from a zero-SUI
|
|
346
|
+
* wallet.** They remain the ONLY gasless assets.
|
|
347
|
+
* - SUI and every other coin type are gas-paid (the sender needs SUI).
|
|
348
|
+
* - `asset` stays REQUIRED (no implicit `?? 'USDC'` default — v4 rule).
|
|
350
349
|
*
|
|
351
350
|
* Submission stays on the JSON-RPC client (the rest of the SDK
|
|
352
351
|
* expects JSON-RPC for read paths, and Sui's docs explicitly support
|
|
@@ -355,7 +354,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
355
354
|
send(params: {
|
|
356
355
|
to: string;
|
|
357
356
|
amount: number;
|
|
358
|
-
asset:
|
|
357
|
+
asset: string;
|
|
359
358
|
force?: boolean;
|
|
360
359
|
}): Promise<SendResult>;
|
|
361
360
|
/**
|
|
@@ -846,8 +845,8 @@ type WriteToolName = 'send_transfer' | 'swap_execute';
|
|
|
846
845
|
* type is the wider `SupportedAsset` rather than the narrower
|
|
847
846
|
* `SendableAsset` so callers that thread a wide-typed asset through
|
|
848
847
|
* (primarily the engine LLM tool surface) compile without modification.
|
|
849
|
-
* Runtime narrowing happens via
|
|
850
|
-
* which throws `INVALID_ASSET` for anything outside the
|
|
848
|
+
* Runtime narrowing happens via the appender's local `SENDABLE_ASSETS`
|
|
849
|
+
* check, which throws `INVALID_ASSET` for anything outside the
|
|
851
850
|
* `['USDC', 'USDsui', 'SUI']` whitelist. USDC + USDsui route through
|
|
852
851
|
* the gasless `0x2::balance::send_funds` Move call; SUI uses the
|
|
853
852
|
* standard `transferObjects` path.
|
package/dist/index.js
CHANGED
|
@@ -841,7 +841,7 @@ var SUPPORTED_ASSETS = {
|
|
|
841
841
|
};
|
|
842
842
|
var STABLE_ASSETS = ["USDC", "USDsui"];
|
|
843
843
|
var OPERATION_ASSETS = {
|
|
844
|
-
send:
|
|
844
|
+
send: "*",
|
|
845
845
|
swap: "*"
|
|
846
846
|
};
|
|
847
847
|
function isAllowedAsset(op, asset) {
|
|
@@ -1529,19 +1529,42 @@ function normalizeAsset(input) {
|
|
|
1529
1529
|
}
|
|
1530
1530
|
|
|
1531
1531
|
// src/wallet/send.ts
|
|
1532
|
+
init_token_registry();
|
|
1532
1533
|
init_preflight();
|
|
1533
|
-
function
|
|
1534
|
+
function classifySendAsset(asset) {
|
|
1535
|
+
const coinType = resolveTokenType(asset.trim());
|
|
1536
|
+
if (!coinType) return null;
|
|
1537
|
+
let normalized;
|
|
1534
1538
|
try {
|
|
1535
|
-
|
|
1536
|
-
} catch
|
|
1537
|
-
return
|
|
1539
|
+
normalized = normalizeStructTag(coinType);
|
|
1540
|
+
} catch {
|
|
1541
|
+
return null;
|
|
1542
|
+
}
|
|
1543
|
+
if (normalized === normalizeStructTag(GASLESS_STABLE_TYPES.USDC)) {
|
|
1544
|
+
return { kind: "gasless-stable", symbol: "USDC", coinType: GASLESS_STABLE_TYPES.USDC };
|
|
1545
|
+
}
|
|
1546
|
+
if (normalized === normalizeStructTag(GASLESS_STABLE_TYPES.USDsui)) {
|
|
1547
|
+
return { kind: "gasless-stable", symbol: "USDsui", coinType: GASLESS_STABLE_TYPES.USDsui };
|
|
1548
|
+
}
|
|
1549
|
+
if (normalized === normalizeStructTag(SUI_TYPE)) {
|
|
1550
|
+
return { kind: "sui", symbol: "SUI", coinType: SUI_TYPE };
|
|
1551
|
+
}
|
|
1552
|
+
return { kind: "coin", symbol: resolveSymbol(coinType), coinType };
|
|
1553
|
+
}
|
|
1554
|
+
function invalidSendAssetMessage(asset) {
|
|
1555
|
+
return `Unknown asset "${asset}". Use a registry symbol (USDC, USDsui, SUI, MANIFEST, \u2026) or a full coin type (0x\u2026::module::TYPE).`;
|
|
1556
|
+
}
|
|
1557
|
+
function preflightSend(input) {
|
|
1558
|
+
const cls = classifySendAsset(input.asset);
|
|
1559
|
+
if (!cls) {
|
|
1560
|
+
return preflightFail("INVALID_ASSET", invalidSendAssetMessage(input.asset));
|
|
1538
1561
|
}
|
|
1539
1562
|
const amountCheck = checkPositiveAmount(input.amount);
|
|
1540
1563
|
if (!amountCheck.valid) return amountCheck;
|
|
1541
|
-
if (
|
|
1564
|
+
if (cls.kind === "gasless-stable" && input.amount < GASLESS_MIN_STABLE_AMOUNT) {
|
|
1542
1565
|
return preflightFail(
|
|
1543
1566
|
"INVALID_AMOUNT",
|
|
1544
|
-
`Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${
|
|
1567
|
+
`Minimum gasless transfer is ${GASLESS_MIN_STABLE_AMOUNT} ${cls.symbol}. Got ${input.amount}.`
|
|
1545
1568
|
);
|
|
1546
1569
|
}
|
|
1547
1570
|
const addressCheck = checkSuiAddress(input.to);
|
|
@@ -1558,42 +1581,44 @@ async function buildSendTx({
|
|
|
1558
1581
|
const pf = preflightSend({ to, amount, asset });
|
|
1559
1582
|
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
1560
1583
|
const recipient = validateAddress(to);
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1563
|
-
const rawAmount = displayToRaw(amount,
|
|
1584
|
+
const cls = classifySendAsset(asset);
|
|
1585
|
+
const decimals = cls.kind === "gasless-stable" || cls.kind === "sui" ? SUPPORTED_ASSETS[cls.symbol].decimals : await resolveCoinDecimals(client, cls.coinType);
|
|
1586
|
+
const rawAmount = displayToRaw(amount, decimals);
|
|
1564
1587
|
const tx = new Transaction();
|
|
1565
1588
|
tx.setSender(address);
|
|
1566
|
-
const balanceResp = await client.core.getBalance({ owner: address, coinType:
|
|
1589
|
+
const balanceResp = await client.core.getBalance({ owner: address, coinType: cls.coinType });
|
|
1567
1590
|
const totalBalance = BigInt(balanceResp.balance.balance);
|
|
1568
1591
|
if (totalBalance < rawAmount) {
|
|
1569
|
-
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${
|
|
1570
|
-
available: Number(totalBalance) / 10 **
|
|
1592
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${cls.symbol} balance`, {
|
|
1593
|
+
available: Number(totalBalance) / 10 ** decimals,
|
|
1571
1594
|
required: amount
|
|
1572
1595
|
});
|
|
1573
1596
|
}
|
|
1574
|
-
if (
|
|
1575
|
-
const rawFloor = displayToRaw(GASLESS_MIN_STABLE_AMOUNT, assetInfo.decimals);
|
|
1576
|
-
const remainder = totalBalance - rawAmount;
|
|
1577
|
-
if (remainder > 0n && remainder < rawFloor) {
|
|
1578
|
-
const total = Number(totalBalance) / 10 ** assetInfo.decimals;
|
|
1579
|
-
throw new T2000Error(
|
|
1580
|
-
"INVALID_AMOUNT",
|
|
1581
|
-
`Gasless ${asset} transfers must send the entire balance or leave at least ${GASLESS_MIN_STABLE_AMOUNT} ${asset}. Sending ${amount} of ${total} leaves ${(total - amount).toFixed(assetInfo.decimals)}. Send ${total} (everything) or at most ${(total - GASLESS_MIN_STABLE_AMOUNT).toFixed(assetInfo.decimals)}.`,
|
|
1582
|
-
{ available: total, required: amount }
|
|
1583
|
-
);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
if (asset === "SUI") {
|
|
1597
|
+
if (cls.kind === "sui") {
|
|
1587
1598
|
const [sendCoin] = tx.splitCoins(tx.gas, [rawAmount]);
|
|
1588
1599
|
tx.transferObjects([sendCoin], recipient);
|
|
1589
1600
|
return tx;
|
|
1590
1601
|
}
|
|
1591
|
-
|
|
1602
|
+
if (cls.kind === "coin") {
|
|
1603
|
+
const sendCoin = coinWithBalance({ type: cls.coinType, balance: rawAmount })(tx);
|
|
1604
|
+
tx.transferObjects([sendCoin], recipient);
|
|
1605
|
+
return tx;
|
|
1606
|
+
}
|
|
1607
|
+
const rawFloor = displayToRaw(GASLESS_MIN_STABLE_AMOUNT, decimals);
|
|
1608
|
+
const remainder = totalBalance - rawAmount;
|
|
1609
|
+
if (remainder > 0n && remainder < rawFloor) {
|
|
1610
|
+
const total = Number(totalBalance) / 10 ** decimals;
|
|
1611
|
+
throw new T2000Error(
|
|
1612
|
+
"INVALID_AMOUNT",
|
|
1613
|
+
`Gasless ${cls.symbol} transfers must send the entire balance or leave at least ${GASLESS_MIN_STABLE_AMOUNT} ${cls.symbol}. Sending ${amount} of ${total} leaves ${(total - amount).toFixed(decimals)}. Send ${total} (everything) or at most ${(total - GASLESS_MIN_STABLE_AMOUNT).toFixed(decimals)}.`,
|
|
1614
|
+
{ available: total, required: amount }
|
|
1615
|
+
);
|
|
1616
|
+
}
|
|
1592
1617
|
tx.moveCall({
|
|
1593
1618
|
target: "0x2::balance::send_funds",
|
|
1594
|
-
typeArguments: [coinType],
|
|
1619
|
+
typeArguments: [cls.coinType],
|
|
1595
1620
|
arguments: [
|
|
1596
|
-
tx.balance({ type: coinType, balance: rawAmount }),
|
|
1621
|
+
tx.balance({ type: cls.coinType, balance: rawAmount }),
|
|
1597
1622
|
tx.pure.address(recipient)
|
|
1598
1623
|
]
|
|
1599
1624
|
});
|
|
@@ -2936,11 +2961,21 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
2936
2961
|
const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
|
|
2937
2962
|
let route;
|
|
2938
2963
|
if (params.serializedRoute) {
|
|
2939
|
-
|
|
2964
|
+
let s = params.serializedRoute;
|
|
2965
|
+
const nested = s.serializedRoute;
|
|
2966
|
+
if (nested && typeof nested === "object" && typeof nested.fromCoinType === "string" && nested.routerData) {
|
|
2967
|
+
s = nested;
|
|
2968
|
+
}
|
|
2969
|
+
if (typeof s.fromCoinType !== "string" || typeof s.toCoinType !== "string") {
|
|
2970
|
+
throw new T2000Error(
|
|
2971
|
+
"SWAP_ROUTE_MISMATCH",
|
|
2972
|
+
"serializedRoute is not the object t2000 quoted \u2014 it is missing fromCoinType/toCoinType. Pass quote.serializedRoute exactly as the quote returned it (not the whole quote response), or omit serializedRoute to discover a fresh route."
|
|
2973
|
+
);
|
|
2974
|
+
}
|
|
2940
2975
|
if (!verifyCetusRouteCoinMatch2(s, { fromCoinType: fromType, toCoinType: toType })) {
|
|
2941
2976
|
throw new T2000Error(
|
|
2942
2977
|
"SWAP_ROUTE_MISMATCH",
|
|
2943
|
-
`The quoted route is for ${s.fromCoinType} -> ${s.toCoinType}, not ${
|
|
2978
|
+
`The quoted route is for ${s.fromCoinType} -> ${s.toCoinType}, not ${fromType} -> ${toType}. Re-quote and pass the new serializedRoute.`
|
|
2944
2979
|
);
|
|
2945
2980
|
}
|
|
2946
2981
|
if (s.byAmountIn !== byAmountIn || BigInt(s.amountIn) !== rawAmount) {
|
|
@@ -3084,18 +3119,17 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
3084
3119
|
/**
|
|
3085
3120
|
* Send `amount` of `asset` to `to` (hex address or SuiNS name).
|
|
3086
3121
|
*
|
|
3087
|
-
* [
|
|
3122
|
+
* [S.957 — 2026-08-08] `asset` accepts **any held coin type** — a
|
|
3123
|
+
* registry symbol (`USDC`, `MANIFEST`) or a full `0x…::module::TYPE`.
|
|
3124
|
+
* Unresolvable strings throw `INVALID_ASSET`; empty balances throw
|
|
3125
|
+
* `INSUFFICIENT_BALANCE`.
|
|
3088
3126
|
*
|
|
3089
|
-
* **Breaking changes from v3.x:**
|
|
3090
|
-
* - `asset` is now REQUIRED (no implicit `?? 'USDC'` default). Callers
|
|
3091
|
-
* must specify `'USDC' | 'USDsui' | 'SUI'`. Sending `'USDT'` /
|
|
3092
|
-
* `'USDe'` / `'WAL'` / `'ETH'` / `'NAVX'` / `'GOLD'` now errors
|
|
3093
|
-
* with `INVALID_ASSET` — swap to a stable first.
|
|
3094
3127
|
* - USDC + USDsui builds go through `SuiGrpcClient` so the gRPC build
|
|
3095
3128
|
* resolver auto-detects `0x2::balance::send_funds` eligibility and
|
|
3096
|
-
* zeros gas at simulate time
|
|
3097
|
-
*
|
|
3098
|
-
*
|
|
3129
|
+
* zeros gas at simulate time — **gasless sends from a zero-SUI
|
|
3130
|
+
* wallet.** They remain the ONLY gasless assets.
|
|
3131
|
+
* - SUI and every other coin type are gas-paid (the sender needs SUI).
|
|
3132
|
+
* - `asset` stays REQUIRED (no implicit `?? 'USDC'` default — v4 rule).
|
|
3099
3133
|
*
|
|
3100
3134
|
* Submission stays on the JSON-RPC client (the rest of the SDK
|
|
3101
3135
|
* expects JSON-RPC for read paths, and Sui's docs explicitly support
|
|
@@ -3106,30 +3140,31 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
3106
3140
|
if (!asset) {
|
|
3107
3141
|
throw new T2000Error(
|
|
3108
3142
|
"INVALID_ASSET",
|
|
3109
|
-
"send() requires an explicit asset. Use
|
|
3143
|
+
"send() requires an explicit asset. Use a registry symbol (USDC, USDsui, SUI, MANIFEST, \u2026) or a full coin type (0x\u2026::module::TYPE)."
|
|
3110
3144
|
);
|
|
3111
3145
|
}
|
|
3112
|
-
|
|
3113
|
-
|
|
3146
|
+
const cls = classifySendAsset(asset);
|
|
3147
|
+
if (!cls) {
|
|
3148
|
+
throw new T2000Error("INVALID_ASSET", invalidSendAssetMessage(asset));
|
|
3149
|
+
}
|
|
3114
3150
|
this.limits.assert({
|
|
3115
3151
|
operation: "send",
|
|
3116
|
-
amountUsd: approxUsdValue(
|
|
3152
|
+
amountUsd: approxUsdValue(cls.symbol, params.amount) ?? 0,
|
|
3117
3153
|
force: params.force
|
|
3118
3154
|
});
|
|
3119
3155
|
const resolved = await this.resolveRecipient(params.to);
|
|
3120
3156
|
const sendAmount = params.amount;
|
|
3121
3157
|
const sendTo = resolved.address;
|
|
3122
|
-
const
|
|
3123
|
-
const buildClient = useGrpc ? getSuiGrpcClient() : void 0;
|
|
3158
|
+
const buildClient = cls.kind === "gasless-stable" ? getSuiGrpcClient() : void 0;
|
|
3124
3159
|
const gasResult = await executeTx(
|
|
3125
3160
|
this.client,
|
|
3126
3161
|
this._signer,
|
|
3127
|
-
() => buildSendTx({ client: this.client, address: this._address, to: sendTo, amount: sendAmount, asset
|
|
3162
|
+
() => buildSendTx({ client: this.client, address: this._address, to: sendTo, amount: sendAmount, asset }),
|
|
3128
3163
|
{ buildClient }
|
|
3129
3164
|
);
|
|
3130
|
-
this.limits.record(approxUsdValue(
|
|
3165
|
+
this.limits.record(approxUsdValue(cls.symbol, sendAmount) ?? 0);
|
|
3131
3166
|
const balance = await this.balance();
|
|
3132
|
-
this.emitBalanceChange(
|
|
3167
|
+
this.emitBalanceChange(cls.symbol, sendAmount, "send", gasResult.digest);
|
|
3133
3168
|
return {
|
|
3134
3169
|
success: true,
|
|
3135
3170
|
tx: gasResult.digest,
|
|
@@ -3905,7 +3940,12 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
3905
3940
|
"send_transfer requires an explicit asset. Use one of: USDC, USDsui, SUI."
|
|
3906
3941
|
);
|
|
3907
3942
|
}
|
|
3908
|
-
|
|
3943
|
+
if (!SENDABLE_ASSETS.some((a) => a.toLowerCase() === input.asset.toLowerCase())) {
|
|
3944
|
+
throw new T2000Error(
|
|
3945
|
+
"INVALID_ASSET",
|
|
3946
|
+
`send_transfer only supports ${SENDABLE_ASSETS.join(", ")}. Cannot use ${input.asset}. Swap to USDC or USDsui first, or send SUI.`
|
|
3947
|
+
);
|
|
3948
|
+
}
|
|
3909
3949
|
const asset = input.asset;
|
|
3910
3950
|
const assetInfo = SUPPORTED_ASSETS[asset];
|
|
3911
3951
|
if (input.amount <= 0) {
|
|
@@ -4293,6 +4333,6 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
|
4293
4333
|
// src/index.ts
|
|
4294
4334
|
init_preflight();
|
|
4295
4335
|
|
|
4296
|
-
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_OPENING_PACKAGE_ID, A2A_ESCROW_PACKAGE_ID, A2A_ESCROW_PACKAGE_V2_ID, A2A_ESCROW_PACKAGE_V3_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ESCROW_JOB_TYPE_MARKER, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, JOB_STATES, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, MAINNET_A2A_ESCROW_PACKAGE_ID, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICY_ANY_ACTIVE, OPENING_TYPE_MARKER, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertBuyerRequirements, assertLimitConfig, buildAddLeafTx, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, claimOpenJob, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getOpenJob, getOpening, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithX402, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, reportX402Activity, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, setSponsoredTxGuard, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|
|
4336
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_OPENING_PACKAGE_ID, A2A_ESCROW_PACKAGE_ID, A2A_ESCROW_PACKAGE_V2_ID, A2A_ESCROW_PACKAGE_V3_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ESCROW_JOB_TYPE_MARKER, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, JOB_STATES, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, MAINNET_A2A_ESCROW_PACKAGE_ID, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICY_ANY_ACTIVE, OPENING_TYPE_MARKER, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertBuyerRequirements, assertLimitConfig, buildAddLeafTx, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, claimOpenJob, classifyAction, classifyLabel, classifySendAsset, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getOpenJob, getOpening, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, invalidSendAssetMessage, isAllowedAsset, isCetusRouteFresh, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithX402, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, reportX402Activity, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, setSponsoredTxGuard, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|
|
4297
4337
|
//# sourceMappingURL=index.js.map
|
|
4298
4338
|
//# sourceMappingURL=index.js.map
|