@t2000/sdk 10.25.1 → 10.27.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 +22 -11
- 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 +22 -11
- package/dist/browser.js.map +1 -1
- package/dist/{commerce-B_eH6fvR.d.cts → commerce-DR_F-Eg6.d.cts} +56 -2
- package/dist/{commerce-B_eH6fvR.d.ts → commerce-DR_F-Eg6.d.ts} +56 -2
- package/dist/index.cjs +97 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.js +94 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -938,6 +938,50 @@ declare function preflightPay(input: {
|
|
|
938
938
|
url: string;
|
|
939
939
|
maxPrice?: number;
|
|
940
940
|
}): PreflightResult;
|
|
941
|
+
/**
|
|
942
|
+
* What a paid call WOULD cost, without paying (S.919). Every branch mirrors
|
|
943
|
+
* a `payWithX402` outcome so the probe can never promise something the pay
|
|
944
|
+
* path then refuses — one dialect story, not two.
|
|
945
|
+
*/
|
|
946
|
+
type X402Probe = {
|
|
947
|
+
kind: 'free';
|
|
948
|
+
status: number;
|
|
949
|
+
note: string;
|
|
950
|
+
} | {
|
|
951
|
+
kind: 'payable';
|
|
952
|
+
priceUsdc: number;
|
|
953
|
+
asset: string;
|
|
954
|
+
payTo: string;
|
|
955
|
+
network: string;
|
|
956
|
+
} | {
|
|
957
|
+
kind: 'escrow';
|
|
958
|
+
priceUsdc: number;
|
|
959
|
+
payTo: string;
|
|
960
|
+
note: string;
|
|
961
|
+
} | {
|
|
962
|
+
kind: 'unsupported';
|
|
963
|
+
reason: string;
|
|
964
|
+
note: string;
|
|
965
|
+
} | {
|
|
966
|
+
kind: 'incomplete';
|
|
967
|
+
reason: string;
|
|
968
|
+
note: string;
|
|
969
|
+
} | {
|
|
970
|
+
kind: 'not-x402';
|
|
971
|
+
status: number;
|
|
972
|
+
note: string;
|
|
973
|
+
};
|
|
974
|
+
/**
|
|
975
|
+
* READ-ONLY x402 probe: issue the same request `pay()` would, read the 402,
|
|
976
|
+
* and report the terms. Never signs, never spends, never throws on a
|
|
977
|
+
* non-payable answer — an unpayable endpoint is information, not a failure.
|
|
978
|
+
* (Invalid input still throws, exactly as `pay()` would, so a caller can't
|
|
979
|
+
* probe a URL that could never be paid.)
|
|
980
|
+
*/
|
|
981
|
+
declare function probeX402(args: {
|
|
982
|
+
network: string;
|
|
983
|
+
options: PayOptions;
|
|
984
|
+
}): Promise<X402Probe>;
|
|
941
985
|
declare function payWithX402(args: {
|
|
942
986
|
signer: TransactionSigner;
|
|
943
987
|
client: SuiGrpcClient;
|
|
@@ -1400,7 +1444,17 @@ declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, r
|
|
|
1400
1444
|
* onto the Job at create, FeeConfig versioning, bounded windows). Override
|
|
1401
1445
|
* via env for testnet/dev.
|
|
1402
1446
|
*/
|
|
1403
|
-
/** The published `a2a_escrow` package id
|
|
1447
|
+
/** The published `a2a_escrow` package id on MAINNET — a literal, never an
|
|
1448
|
+
* env read.
|
|
1449
|
+
*
|
|
1450
|
+
* Security (S.930): the env-overridable constant below is a dev/testnet
|
|
1451
|
+
* convenience, which makes it useless as a trust anchor — anything verifying
|
|
1452
|
+
* "is this the real escrow package?" against it would be checking the
|
|
1453
|
+
* attacker's own answer. Signature-time verification compares against THIS.
|
|
1454
|
+
* Must match the Move upgrade publish notes. */
|
|
1455
|
+
declare const MAINNET_A2A_ESCROW_PACKAGE_ID = "0x358a819c1c016e2cc84ef5fbea81cba90c31f7f8a62bf45cb5e5276acf198bdd";
|
|
1456
|
+
/** The published `a2a_escrow` package id (mainnet default; env-overridable
|
|
1457
|
+
* for testnet/dev — NOT a trust anchor, see above). */
|
|
1404
1458
|
declare const A2A_ESCROW_PACKAGE_ID: string;
|
|
1405
1459
|
/** The shared `FeeConfig` object every escrow entry reads (mainnet). */
|
|
1406
1460
|
declare const A2A_ESCROW_FEE_CONFIG_ID: string;
|
|
@@ -1556,4 +1610,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
|
|
|
1556
1610
|
* the store is untrusted; the chain hash is the authority). */
|
|
1557
1611
|
declare function getJobSpec(base: string, hash: string): Promise<string>;
|
|
1558
1612
|
|
|
1559
|
-
export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type
|
|
1613
|
+
export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type X402Probe as b5, type SerializedCetusRoute as b6, type SwapResult as b7, type SwapQuoteResult as b8, type PaymentRequest as b9, isCetusRouteFresh as bA, isInRegistry as bB, normalizeAsset as bC, normalizeCoinType as bD, probeX402 as bE, queryHistory as bF, queryTransaction as bG, selectAndSplitCoin as bH, selectSuiCoin as bI, serializeCetusRoute as bJ, simulateTransaction as bK, throwIfSimulationFailed as bL, verifyCetusRouteCoinMatch as bM, type SuiCoreClient as ba, type SponsoredCoinMergeCache as bb, type SendableAsset as bc, CETUS_USDC_SUI_POOL as bd, type CoinPage as be, DEFAULT_GRPC_URL as bf, GASLESS_MIN_STABLE_AMOUNT as bg, GASLESS_STABLE_TYPES as bh, MAINNET_A2A_ESCROW_PACKAGE_ID as bi, OPERATION_ASSETS as bj, type Operation as bk, SENDABLE_ASSETS as bl, type SelectAndSplitResult as bm, type SerializedCetusRoutePath as bn, type SerializedRouterDataV3 as bo, addSendToTx as bp, addSwapToTx as bq, assertAllowedAsset as br, assertBuyerRequirements as bs, buildDeclineJobTx as bt, deserializeCetusRoute as bu, fetchAllCoins as bv, getCoinMeta as bw, getSuiClient as bx, getSuiGrpcClient as by, isAllowedAsset as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
|
|
@@ -938,6 +938,50 @@ declare function preflightPay(input: {
|
|
|
938
938
|
url: string;
|
|
939
939
|
maxPrice?: number;
|
|
940
940
|
}): PreflightResult;
|
|
941
|
+
/**
|
|
942
|
+
* What a paid call WOULD cost, without paying (S.919). Every branch mirrors
|
|
943
|
+
* a `payWithX402` outcome so the probe can never promise something the pay
|
|
944
|
+
* path then refuses — one dialect story, not two.
|
|
945
|
+
*/
|
|
946
|
+
type X402Probe = {
|
|
947
|
+
kind: 'free';
|
|
948
|
+
status: number;
|
|
949
|
+
note: string;
|
|
950
|
+
} | {
|
|
951
|
+
kind: 'payable';
|
|
952
|
+
priceUsdc: number;
|
|
953
|
+
asset: string;
|
|
954
|
+
payTo: string;
|
|
955
|
+
network: string;
|
|
956
|
+
} | {
|
|
957
|
+
kind: 'escrow';
|
|
958
|
+
priceUsdc: number;
|
|
959
|
+
payTo: string;
|
|
960
|
+
note: string;
|
|
961
|
+
} | {
|
|
962
|
+
kind: 'unsupported';
|
|
963
|
+
reason: string;
|
|
964
|
+
note: string;
|
|
965
|
+
} | {
|
|
966
|
+
kind: 'incomplete';
|
|
967
|
+
reason: string;
|
|
968
|
+
note: string;
|
|
969
|
+
} | {
|
|
970
|
+
kind: 'not-x402';
|
|
971
|
+
status: number;
|
|
972
|
+
note: string;
|
|
973
|
+
};
|
|
974
|
+
/**
|
|
975
|
+
* READ-ONLY x402 probe: issue the same request `pay()` would, read the 402,
|
|
976
|
+
* and report the terms. Never signs, never spends, never throws on a
|
|
977
|
+
* non-payable answer — an unpayable endpoint is information, not a failure.
|
|
978
|
+
* (Invalid input still throws, exactly as `pay()` would, so a caller can't
|
|
979
|
+
* probe a URL that could never be paid.)
|
|
980
|
+
*/
|
|
981
|
+
declare function probeX402(args: {
|
|
982
|
+
network: string;
|
|
983
|
+
options: PayOptions;
|
|
984
|
+
}): Promise<X402Probe>;
|
|
941
985
|
declare function payWithX402(args: {
|
|
942
986
|
signer: TransactionSigner;
|
|
943
987
|
client: SuiGrpcClient;
|
|
@@ -1400,7 +1444,17 @@ declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, r
|
|
|
1400
1444
|
* onto the Job at create, FeeConfig versioning, bounded windows). Override
|
|
1401
1445
|
* via env for testnet/dev.
|
|
1402
1446
|
*/
|
|
1403
|
-
/** The published `a2a_escrow` package id
|
|
1447
|
+
/** The published `a2a_escrow` package id on MAINNET — a literal, never an
|
|
1448
|
+
* env read.
|
|
1449
|
+
*
|
|
1450
|
+
* Security (S.930): the env-overridable constant below is a dev/testnet
|
|
1451
|
+
* convenience, which makes it useless as a trust anchor — anything verifying
|
|
1452
|
+
* "is this the real escrow package?" against it would be checking the
|
|
1453
|
+
* attacker's own answer. Signature-time verification compares against THIS.
|
|
1454
|
+
* Must match the Move upgrade publish notes. */
|
|
1455
|
+
declare const MAINNET_A2A_ESCROW_PACKAGE_ID = "0x358a819c1c016e2cc84ef5fbea81cba90c31f7f8a62bf45cb5e5276acf198bdd";
|
|
1456
|
+
/** The published `a2a_escrow` package id (mainnet default; env-overridable
|
|
1457
|
+
* for testnet/dev — NOT a trust anchor, see above). */
|
|
1404
1458
|
declare const A2A_ESCROW_PACKAGE_ID: string;
|
|
1405
1459
|
/** The shared `FeeConfig` object every escrow entry reads (mainnet). */
|
|
1406
1460
|
declare const A2A_ESCROW_FEE_CONFIG_ID: string;
|
|
@@ -1556,4 +1610,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
|
|
|
1556
1610
|
* the store is untrusted; the chain hash is the authority). */
|
|
1557
1611
|
declare function getJobSpec(base: string, hash: string): Promise<string>;
|
|
1558
1612
|
|
|
1559
|
-
export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type
|
|
1613
|
+
export { type T2000ErrorData as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_ACTIVITY_REPORT_URL as D, ETH_TYPE as E, SUI_TYPE as F, GAS_RESERVE_MIN as G, SUPPORTED_ASSETS as H, IKA_TYPE as I, JOB_STATES as J, KNOWN_TARGETS as K, LABEL_PATTERNS as L, MANIFEST_TYPE as M, NAVX_TYPE as N, OVERLAY_FEE_RATE as O, PREFLIGHT_MAX_AMOUNT as P, type SendResult as Q, type ServiceListing as R, STABLE_ASSETS as S, type SimulationResult as T, type StableAsset as U, type SuiHolding as V, type SuiRpcTxBlock as W, type SupportedAsset as X, type SwapRouteResult as Y, T2000Error as Z, type T2000ErrorCode as _, A2A_ESCROW_PACKAGE_ID as a, suiToMist as a$, T2000_OVERLAY_FEE_WALLET as a0, TOKEN_MAP as a1, type TransactionLeg as a2, type TransactionRecord as a3, type TransactionSigner as a4, type TxDirection as a5, USDC_DECIMALS as a6, USDC_TYPE as a7, USDE_TYPE as a8, USDSUI_TYPE as a9, formatAssetAmount as aA, formatSui as aB, formatUsd as aC, getDecimals as aD, getDecimalsForCoinType as aE, getJob as aF, getJobSpec as aG, jobActionsFor as aH, listServices as aI, mapMoveAbortCode as aJ, mapWalletError as aK, mistToSui as aL, parseSuiRpcTx as aM, payWithX402 as aN, preflightCreateJob as aO, preflightFail as aP, preflightPay as aQ, preflightSend as aR, preflightSwap as aS, putJobSpec as aT, rawToStable as aU, rawToUsdc as aV, refineLendingLabel as aW, reportX402Activity as aX, resolveSymbol as aY, resolveTokenType as aZ, stableToRaw as a_, USDT_TYPE as aa, WAL_TYPE as ab, WBTC_TYPE as ac, type X402ActivityPayload as ad, type ZkLoginProof as ae, ZkLoginSigner as af, buildCreateJobTx as ag, buildDeliverJobTx as ah, buildRefundJobTx as ai, buildRejectJobTx as aj, buildReleaseJobTx as ak, buildSendTx as al, buildSwapTx as am, checkPositiveAmount as an, checkSuiAddress as ao, classifyAction as ap, classifyLabel as aq, classifyTransaction as ar, executeTx as as, extractAllUserLegs as at, extractTransferDetails as au, extractTxCommands as av, extractTxSender as aw, fallbackLabel as ax, fetchService as ay, findSwapRoute as az, type ActivityReportConfig as b, truncateAddress as b0, usdcToRaw as b1, validateAddress as b2, verifyJobForSeller as b3, type T2000Options as b4, type X402Probe as b5, type SerializedCetusRoute as b6, type SwapResult as b7, type SwapQuoteResult as b8, type PaymentRequest as b9, isCetusRouteFresh as bA, isInRegistry as bB, normalizeAsset as bC, normalizeCoinType as bD, probeX402 as bE, queryHistory as bF, queryTransaction as bG, selectAndSplitCoin as bH, selectSuiCoin as bI, serializeCetusRoute as bJ, simulateTransaction as bK, throwIfSimulationFailed as bL, verifyCetusRouteCoinMatch as bM, type SuiCoreClient as ba, type SponsoredCoinMergeCache as bb, type SendableAsset as bc, CETUS_USDC_SUI_POOL as bd, type CoinPage as be, DEFAULT_GRPC_URL as bf, GASLESS_MIN_STABLE_AMOUNT as bg, GASLESS_STABLE_TYPES as bh, MAINNET_A2A_ESCROW_PACKAGE_ID as bi, OPERATION_ASSETS as bj, type Operation as bk, SENDABLE_ASSETS as bl, type SelectAndSplitResult as bm, type SerializedCetusRoutePath as bn, type SerializedRouterDataV3 as bo, addSendToTx as bp, addSwapToTx as bq, assertAllowedAsset as br, assertBuyerRequirements as bs, buildDeclineJobTx as bt, deserializeCetusRoute as bu, fetchAllCoins as bv, getCoinMeta as bw, getSuiClient as bx, getSuiGrpcClient as by, isAllowedAsset as bz, COIN_REGISTRY as c, type ClassifyBalanceChange as d, type ClassifyResult as e, type CoinMeta as f, DEFAULT_COMMERCE_API_BASE as g, DEFAULT_NETWORK as h, type DepositInfo as i, type ExtractedTransfer as j, type Job as k, type JobState as l, type JobTerms as m, type JobVerification as n, KeypairSigner as o, LOFI_TYPE as p, MAX_DELIVER_HORIZON_MS as q, MAX_JOB_USDC as r, MAX_REVIEW_WINDOW_MS as s, MIST_PER_SUI as t, type OverlayFeeConfig as u, PREFLIGHT_OK as v, type PayOptions as w, type PayResult as x, type PreflightResult as y, SUI_DECIMALS as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1140,11 +1140,65 @@ function preflightPay(input) {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
return exports.PREFLIGHT_OK;
|
|
1142
1142
|
}
|
|
1143
|
-
async function
|
|
1144
|
-
const {
|
|
1145
|
-
|
|
1146
|
-
const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
|
|
1143
|
+
async function probeX402(args) {
|
|
1144
|
+
const { network } = args;
|
|
1145
|
+
const pf = preflightPay({ url: args.options.url, maxPrice: args.options.maxPrice });
|
|
1147
1146
|
if (!pf.valid) throw new exports.T2000Error(pf.code, pf.error);
|
|
1147
|
+
const { reqInit } = normalizePayRequest(args.options);
|
|
1148
|
+
const probe = await fetch(args.options.url, reqInit);
|
|
1149
|
+
if (probe.status !== 402) {
|
|
1150
|
+
return {
|
|
1151
|
+
kind: "free",
|
|
1152
|
+
status: probe.status,
|
|
1153
|
+
note: "No payment required \u2014 this endpoint served without a 402."
|
|
1154
|
+
};
|
|
1155
|
+
}
|
|
1156
|
+
const pick = await pickSuiExactRequirements(probe, network);
|
|
1157
|
+
if (pick.kind === "payable") {
|
|
1158
|
+
const requirements = pick.requirements;
|
|
1159
|
+
const priceUsdc = atomicToHuman(
|
|
1160
|
+
BigInt(requirements.maxAmountRequired),
|
|
1161
|
+
await assetDecimals(requirements.asset)
|
|
1162
|
+
);
|
|
1163
|
+
const { isX402EscrowRequirements } = await import('@t2000/sui-x402');
|
|
1164
|
+
if (isX402EscrowRequirements(requirements)) {
|
|
1165
|
+
return {
|
|
1166
|
+
kind: "escrow",
|
|
1167
|
+
priceUsdc,
|
|
1168
|
+
payTo: requirements.payTo,
|
|
1169
|
+
note: "This endpoint sells deliverable work through on-chain escrow, not an instant call. Hire it as a job instead \u2014 funds lock in a Job object and release on delivery."
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
return {
|
|
1173
|
+
kind: "payable",
|
|
1174
|
+
priceUsdc,
|
|
1175
|
+
asset: requirements.asset,
|
|
1176
|
+
payTo: requirements.payTo,
|
|
1177
|
+
network
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
if (hasPaymentAuthenticateHeader(probe)) {
|
|
1181
|
+
return {
|
|
1182
|
+
kind: "unsupported",
|
|
1183
|
+
reason: "header-only-402-unsupported",
|
|
1184
|
+
note: "This seller answered a header-only 402 (WWW-Authenticate: Payment) with no payable x402 accepts[] envelope. That dialect is no longer supported \u2014 the seller must offer x402 (e.g. @t2000/serve emits it)."
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1187
|
+
if (pick.kind === "incomplete") {
|
|
1188
|
+
return {
|
|
1189
|
+
kind: "incomplete",
|
|
1190
|
+
reason: "incomplete-x402-accepts",
|
|
1191
|
+
note: "Seller's x402 challenge is incomplete (missing extra.suimpp) \u2014 the 402 advertises an exact/sui entry but carries no settlement challenge to bind a payment to."
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
return {
|
|
1195
|
+
kind: "not-x402",
|
|
1196
|
+
status: probe.status,
|
|
1197
|
+
note: `Endpoint returned 402 without an x402 'exact' / sui:${network} requirement in the body. Nothing this SDK can pay.`
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
function normalizePayRequest(input) {
|
|
1201
|
+
let options = input;
|
|
1148
1202
|
const method = (options.method ?? "GET").toUpperCase();
|
|
1149
1203
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
1150
1204
|
if (canHaveBody && typeof options.body === "string" && isJsonText(options.body) && !hasContentType(options.headers)) {
|
|
@@ -1153,11 +1207,23 @@ async function payWithX402(args) {
|
|
|
1153
1207
|
headers: { ...options.headers ?? {}, "content-type": "application/json" }
|
|
1154
1208
|
};
|
|
1155
1209
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1210
|
+
return {
|
|
1211
|
+
options,
|
|
1212
|
+
reqInit: {
|
|
1213
|
+
method,
|
|
1214
|
+
headers: options.headers,
|
|
1215
|
+
body: canHaveBody ? options.body : void 0
|
|
1216
|
+
}
|
|
1160
1217
|
};
|
|
1218
|
+
}
|
|
1219
|
+
async function payWithX402(args) {
|
|
1220
|
+
const { signer, client } = args;
|
|
1221
|
+
let options = args.options;
|
|
1222
|
+
const pf = preflightPay({ url: options.url, maxPrice: options.maxPrice });
|
|
1223
|
+
if (!pf.valid) throw new exports.T2000Error(pf.code, pf.error);
|
|
1224
|
+
const normalized = normalizePayRequest(options);
|
|
1225
|
+
options = normalized.options;
|
|
1226
|
+
const reqInit = normalized.reqInit;
|
|
1161
1227
|
const probe = await fetch(options.url, reqInit);
|
|
1162
1228
|
if (probe.status !== 402) {
|
|
1163
1229
|
return finalize(probe, { paid: false });
|
|
@@ -2799,6 +2865,15 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
|
|
|
2799
2865
|
return this._signer;
|
|
2800
2866
|
}
|
|
2801
2867
|
// -- MPP Payments --
|
|
2868
|
+
/**
|
|
2869
|
+
* READ-ONLY price probe for an x402 endpoint (S.919). Reports what `pay()`
|
|
2870
|
+
* would cost without signing or spending, so a caller (Connect's
|
|
2871
|
+
* `t2000_pay_probe`, the CLI, a UI) can show terms before committing.
|
|
2872
|
+
* No limit gate: nothing moves.
|
|
2873
|
+
*/
|
|
2874
|
+
async payProbe(options) {
|
|
2875
|
+
return await probeX402({ network: this.client.network, options });
|
|
2876
|
+
}
|
|
2802
2877
|
async pay(options) {
|
|
2803
2878
|
this.limits.assert({ operation: "pay", amountUsd: options.maxPrice ?? 0, force: options.force });
|
|
2804
2879
|
const result = await payWithX402({ signer: this._signer, client: this.client, options });
|
|
@@ -3217,7 +3292,8 @@ init_coinSelection();
|
|
|
3217
3292
|
init_errors();
|
|
3218
3293
|
init_token_registry();
|
|
3219
3294
|
init_coinSelection();
|
|
3220
|
-
var
|
|
3295
|
+
var MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
|
|
3296
|
+
var A2A_ESCROW_OPENING_PACKAGE_ID = process.env.A2A_ESCROW_OPENING_PACKAGE_ID ?? MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID;
|
|
3221
3297
|
var A2A_ESCROW_PACKAGE_V2_ID = "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
|
|
3222
3298
|
var A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
|
|
3223
3299
|
var CLOCK_ID2 = "0x6";
|
|
@@ -3353,7 +3429,8 @@ async function getOpening(client, openingId) {
|
|
|
3353
3429
|
}
|
|
3354
3430
|
|
|
3355
3431
|
// src/wallet/job.ts
|
|
3356
|
-
var
|
|
3432
|
+
var MAINNET_A2A_ESCROW_PACKAGE_ID = "0x358a819c1c016e2cc84ef5fbea81cba90c31f7f8a62bf45cb5e5276acf198bdd";
|
|
3433
|
+
var A2A_ESCROW_PACKAGE_ID = process.env.A2A_ESCROW_PACKAGE_ID ?? MAINNET_A2A_ESCROW_PACKAGE_ID;
|
|
3357
3434
|
var A2A_ESCROW_FEE_CONFIG_ID = process.env.A2A_ESCROW_FEE_CONFIG_ID ?? "0xddaa25570950b7484dbf20797ebcf75707be9c87cd67bef2a06ed2e81d2c494b";
|
|
3358
3435
|
var A2A_ESCROW_FEE_CONFIG_VERSION = Number(
|
|
3359
3436
|
process.env.A2A_ESCROW_FEE_CONFIG_VERSION ?? 931861903
|
|
@@ -3723,6 +3800,10 @@ async function fetchJson(url, init) {
|
|
|
3723
3800
|
}
|
|
3724
3801
|
return json;
|
|
3725
3802
|
}
|
|
3803
|
+
var sponsoredTxGuard = null;
|
|
3804
|
+
function setSponsoredTxGuard(guard) {
|
|
3805
|
+
sponsoredTxGuard = guard;
|
|
3806
|
+
}
|
|
3726
3807
|
async function listOpenJobs(base, filter = {}) {
|
|
3727
3808
|
const params = new URLSearchParams();
|
|
3728
3809
|
if (filter.status) params.set("status", filter.status);
|
|
@@ -3741,6 +3822,7 @@ async function getOpenJob(base, id) {
|
|
|
3741
3822
|
}
|
|
3742
3823
|
async function sponsoredOpeningVerb(base, signer, action, params) {
|
|
3743
3824
|
const address = signer.getAddress();
|
|
3825
|
+
sponsoredTxGuard?.({ base, action });
|
|
3744
3826
|
const prep = await fetchJson(`${base}/job/prepare`, {
|
|
3745
3827
|
method: "POST",
|
|
3746
3828
|
body: { address, action, params }
|
|
@@ -3750,6 +3832,7 @@ async function sponsoredOpeningVerb(base, signer, action, params) {
|
|
|
3750
3832
|
if (!(nonce && txBytes)) {
|
|
3751
3833
|
throw new Error("Failed to prepare the transaction.");
|
|
3752
3834
|
}
|
|
3835
|
+
sponsoredTxGuard?.({ base, action, txBytes });
|
|
3753
3836
|
const { signature } = await signer.signTransaction(utils.fromBase64(txBytes));
|
|
3754
3837
|
const json = await fetchJson(`${base}/job/submit`, {
|
|
3755
3838
|
method: "POST",
|
|
@@ -4242,6 +4325,8 @@ exports.KeypairSigner = KeypairSigner;
|
|
|
4242
4325
|
exports.LABEL_PATTERNS = LABEL_PATTERNS;
|
|
4243
4326
|
exports.LimitEnforcer = LimitEnforcer;
|
|
4244
4327
|
exports.LimitExceededError = LimitExceededError;
|
|
4328
|
+
exports.MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID;
|
|
4329
|
+
exports.MAINNET_A2A_ESCROW_PACKAGE_ID = MAINNET_A2A_ESCROW_PACKAGE_ID;
|
|
4245
4330
|
exports.MAX_DELIVER_HORIZON_MS = MAX_DELIVER_HORIZON_MS;
|
|
4246
4331
|
exports.MAX_JOB_USDC = MAX_JOB_USDC;
|
|
4247
4332
|
exports.MAX_OPEN_WINDOW_MS = MAX_OPEN_WINDOW_MS;
|
|
@@ -4355,6 +4440,7 @@ exports.preflightFail = preflightFail;
|
|
|
4355
4440
|
exports.preflightPay = preflightPay;
|
|
4356
4441
|
exports.preflightSend = preflightSend;
|
|
4357
4442
|
exports.preflightSwap = preflightSwap;
|
|
4443
|
+
exports.probeX402 = probeX402;
|
|
4358
4444
|
exports.putJobSpec = putJobSpec;
|
|
4359
4445
|
exports.queryBalance = queryBalance;
|
|
4360
4446
|
exports.queryHistory = queryHistory;
|
|
@@ -4377,6 +4463,7 @@ exports.selectAndSplitCoin = selectAndSplitCoin;
|
|
|
4377
4463
|
exports.selectSuiCoin = selectSuiCoin;
|
|
4378
4464
|
exports.serializeCetusRoute = serializeCetusRoute;
|
|
4379
4465
|
exports.setLimits = setLimits;
|
|
4466
|
+
exports.setSponsoredTxGuard = setSponsoredTxGuard;
|
|
4380
4467
|
exports.simulateTransaction = simulateTransaction;
|
|
4381
4468
|
exports.stableToRaw = stableToRaw;
|
|
4382
4469
|
exports.suiToMist = suiToMist;
|