@t2000/sdk 10.20.2 → 10.21.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.
@@ -15,8 +15,8 @@ interface TransactionSigner {
15
15
  signature: string;
16
16
  }>;
17
17
  /**
18
- * Sign an arbitrary personal message. Required by `@suimpp/mpp` 0.7+ for
19
- * grief-protection proofs (sender identity verification on settled payments).
18
+ * Sign an arbitrary personal message used for off-chain proofs bound to
19
+ * the wallet (e.g. signed job-review submissions).
20
20
  */
21
21
  signPersonalMessage(messageBytes: Uint8Array): Promise<{
22
22
  signature: string;
@@ -24,13 +24,9 @@ interface TransactionSigner {
24
24
  }>;
25
25
  /**
26
26
  * Signature scheme marker. zkLogin personal-message signatures are ZK
27
- * constructs that only Sui-aware verifiers can check — external x402
28
- * sellers (the MPP header dialect verifies the payer's personal signature
29
- * SELLER-side) reject them AFTER the on-chain payment already settled
30
- * (live finding, JMPR 2026-07-17: charged, no delivery). `payWithMpp`
31
- * fails closed on `'zklogin'` + header-only 402 BEFORE any money moves.
32
- * Optional so external signer impls keep compiling; undefined = keypair
33
- * semantics.
27
+ * constructs only Sui-aware verifiers can check — hosts use this to gate
28
+ * flows that depend on seller-side signature verification. Optional so
29
+ * external signer impls keep compiling; undefined = keypair semantics.
34
30
  */
35
31
  readonly kind?: 'keypair' | 'zklogin';
36
32
  }
@@ -893,19 +889,29 @@ interface PayOptions {
893
889
  maxPrice?: number;
894
890
  /** Bypass the spending-limit gate for this call (caller owns consent). */
895
891
  force?: boolean;
892
+ /**
893
+ * Attributed x402.paid activity reporting (B2) — after a successful pay,
894
+ * the settlement digest is fire-and-forgotten to the t2000.ai report
895
+ * endpoint (chain-verified server-side; never affects the payment).
896
+ * Default ON with source 'pay'; hosts override the source ('connect',
897
+ * 'try-it') or URL, or pass `false` to opt out.
898
+ */
899
+ activityReport?: {
900
+ url?: string;
901
+ source?: 'pay' | 'try-it' | 'connect';
902
+ } | false;
896
903
  }
897
904
  interface PayResult {
898
905
  status: number;
899
906
  body: unknown;
900
907
  paid: boolean;
901
908
  /**
902
- * Which payment dialect settled the call. `'x402'` = the sign-then-settle
903
- * x402 `sui-exact` scheme (client signs, gateway settles); `'legacy'` = the
904
- * pre-x402 MPP digest dialect (client broadcasts, retries with the digest).
905
- * Undefined when nothing was paid (free/cached endpoint). See
906
- * SUIMPP_X402_SCHEME.md.
909
+ * Which payment dialect settled the call — always `'x402'` (sign-then-
910
+ * settle `sui-exact`; client signs, gateway settles) since the MPP header
911
+ * dialect was removed 2026-08-03. Undefined when nothing was paid
912
+ * (free/cached endpoint). See SUIMPP_X402_SCHEME.md.
907
913
  */
908
- dialect?: 'x402' | 'legacy';
914
+ dialect?: 'x402';
909
915
  cost?: number;
910
916
  /**
911
917
  * SUI gas cost actually paid on chain. Zero for gasless payments —
@@ -937,19 +943,26 @@ declare function payWithMpp(args: {
937
943
  client: SuiGrpcClient;
938
944
  options: PayOptions;
939
945
  }): Promise<PayResult>;
940
- /**
941
- * Parse the MPP header dialect from a 402 response: the
942
- * `WWW-Authenticate: Payment …` challenge(s), looking for `method="sui"`.
943
- * Returns the decoded `{ amount, currency, recipient }` request (amount is a
944
- * decimal string, e.g. "0.02") or `undefined` when the response carries no
945
- * sui challenge. Exported for the CLI's `t2 pay --estimate`.
946
- */
947
- declare function parseMppSuiChallenge(response: Response): Promise<{
948
- amount: string;
949
- currency: string;
950
- recipient: string;
951
- description?: string;
952
- } | undefined>;
946
+
947
+ declare const DEFAULT_ACTIVITY_REPORT_URL = "https://t2000.ai/api/activity/x402";
948
+ type ActivityReportSource = 'pay' | 'try-it' | 'connect';
949
+ /** Per-call reporting config on PayOptions: override the URL/source, or
950
+ * `false` to opt out entirely. */
951
+ type ActivityReportConfig = {
952
+ url?: string;
953
+ source?: ActivityReportSource;
954
+ } | false;
955
+ interface X402ActivityPayload {
956
+ digest: string;
957
+ payTo: string;
958
+ payer?: string;
959
+ amountMicroUsdc: number;
960
+ network: string;
961
+ route?: string;
962
+ source: ActivityReportSource;
963
+ }
964
+ /** Fire-and-forget report — short timeout, every failure swallowed. */
965
+ declare function reportX402Activity(payload: X402ActivityPayload, url?: string): void;
953
966
 
954
967
  type SuiTransactionEffects = SuiClientTypes.TransactionEffects;
955
968
  type BuildClient = NonNullable<Parameters<Transaction['build']>[0]>['client'];
@@ -1543,4 +1556,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1543
1556
  * the store is untrusted; the chain hash is the authority). */
1544
1557
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1545
1558
 
1546
- export { TOKEN_MAP as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_COMMERCE_API_BASE as D, ETH_TYPE as E, type SendResult as F, GAS_RESERVE_MIN as G, type ServiceListing 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 SimulationResult as Q, type StableAsset as R, STABLE_ASSETS as S, type SuiHolding as T, type SuiRpcTxBlock as U, type SupportedAsset as V, type SwapRouteResult as W, T2000Error as X, type T2000ErrorCode as Y, type T2000ErrorData as Z, T2000_OVERLAY_FEE_WALLET as _, A2A_ESCROW_PACKAGE_ID as a, validateAddress as a$, type TransactionLeg as a0, type TransactionRecord as a1, type TransactionSigner as a2, type TxDirection as a3, USDC_DECIMALS as a4, USDC_TYPE as a5, USDE_TYPE as a6, USDSUI_TYPE as a7, USDT_TYPE as a8, WAL_TYPE as a9, getDecimals as aA, getDecimalsForCoinType as aB, getJob as aC, getJobSpec as aD, jobActionsFor as aE, listServices as aF, mapMoveAbortCode as aG, mapWalletError as aH, mistToSui as aI, parseMppSuiChallenge as aJ, parseSuiRpcTx as aK, payWithMpp as aL, preflightCreateJob as aM, preflightFail as aN, preflightPay as aO, preflightSend as aP, preflightSwap as aQ, putJobSpec as aR, rawToStable as aS, rawToUsdc as aT, refineLendingLabel as aU, resolveSymbol as aV, resolveTokenType as aW, stableToRaw as aX, suiToMist as aY, truncateAddress as aZ, usdcToRaw as a_, WBTC_TYPE as aa, type ZkLoginProof as ab, ZkLoginSigner as ac, buildCreateJobTx as ad, buildDeliverJobTx as ae, buildRefundJobTx as af, buildRejectJobTx as ag, buildReleaseJobTx as ah, buildSendTx as ai, buildSwapTx as aj, checkPositiveAmount as ak, checkSuiAddress as al, classifyAction as am, classifyLabel as an, classifyTransaction as ao, executeTx as ap, extractAllUserLegs as aq, extractTransferDetails as ar, extractTxCommands as as, extractTxSender as at, fallbackLabel as au, fetchService as av, findSwapRoute as aw, formatAssetAmount as ax, formatSui as ay, formatUsd as az, COIN_REGISTRY as b, verifyJobForSeller as b0, type T2000Options as b1, type SwapResult as b2, type SwapQuoteResult as b3, type PaymentRequest as b4, type SuiCoreClient as b5, type SponsoredCoinMergeCache as b6, type SendableAsset as b7, CETUS_USDC_SUI_POOL as b8, type CoinPage as b9, queryTransaction as bA, selectAndSplitCoin as bB, selectSuiCoin as bC, serializeCetusRoute as bD, simulateTransaction as bE, throwIfSimulationFailed as bF, verifyCetusRouteCoinMatch as bG, DEFAULT_GRPC_URL as ba, GASLESS_MIN_STABLE_AMOUNT as bb, GASLESS_STABLE_TYPES as bc, OPERATION_ASSETS as bd, type Operation as be, SENDABLE_ASSETS as bf, type SelectAndSplitResult as bg, type SerializedCetusRoute as bh, type SerializedCetusRoutePath as bi, type SerializedRouterDataV3 as bj, addSendToTx as bk, addSwapToTx as bl, assertAllowedAsset as bm, assertBuyerRequirements as bn, buildDeclineJobTx as bo, deserializeCetusRoute as bp, fetchAllCoins as bq, getCoinMeta as br, getSuiClient as bs, getSuiGrpcClient as bt, isAllowedAsset as bu, isCetusRouteFresh as bv, isInRegistry as bw, normalizeAsset as bx, normalizeCoinType as by, queryHistory as bz, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_NETWORK as f, type DepositInfo as g, type ExtractedTransfer as h, type Job as i, type JobState as j, type JobTerms as k, type JobVerification as l, KeypairSigner as m, LOFI_TYPE as n, MAX_DELIVER_HORIZON_MS as o, MAX_JOB_USDC as p, MAX_REVIEW_WINDOW_MS as q, MIST_PER_SUI as r, type OverlayFeeConfig as s, PREFLIGHT_OK as t, type PayOptions as u, type PayResult as v, type PreflightResult as w, SUI_DECIMALS as x, SUI_TYPE as y, SUPPORTED_ASSETS as z };
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, payWithMpp 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 SwapResult as b5, type SwapQuoteResult as b6, type PaymentRequest as b7, type SuiCoreClient as b8, type SponsoredCoinMergeCache as b9, normalizeAsset as bA, normalizeCoinType as bB, queryHistory as bC, queryTransaction as bD, selectAndSplitCoin as bE, selectSuiCoin as bF, serializeCetusRoute as bG, simulateTransaction as bH, throwIfSimulationFailed as bI, verifyCetusRouteCoinMatch as bJ, type SendableAsset as ba, CETUS_USDC_SUI_POOL as bb, type CoinPage as bc, DEFAULT_GRPC_URL as bd, GASLESS_MIN_STABLE_AMOUNT as be, GASLESS_STABLE_TYPES as bf, OPERATION_ASSETS as bg, type Operation as bh, SENDABLE_ASSETS as bi, type SelectAndSplitResult as bj, type SerializedCetusRoute as bk, type SerializedCetusRoutePath as bl, type SerializedRouterDataV3 as bm, addSendToTx as bn, addSwapToTx as bo, assertAllowedAsset as bp, assertBuyerRequirements as bq, buildDeclineJobTx as br, deserializeCetusRoute as bs, fetchAllCoins as bt, getCoinMeta as bu, getSuiClient as bv, getSuiGrpcClient as bw, isAllowedAsset as bx, isCetusRouteFresh as by, isInRegistry 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 };
@@ -15,8 +15,8 @@ interface TransactionSigner {
15
15
  signature: string;
16
16
  }>;
17
17
  /**
18
- * Sign an arbitrary personal message. Required by `@suimpp/mpp` 0.7+ for
19
- * grief-protection proofs (sender identity verification on settled payments).
18
+ * Sign an arbitrary personal message used for off-chain proofs bound to
19
+ * the wallet (e.g. signed job-review submissions).
20
20
  */
21
21
  signPersonalMessage(messageBytes: Uint8Array): Promise<{
22
22
  signature: string;
@@ -24,13 +24,9 @@ interface TransactionSigner {
24
24
  }>;
25
25
  /**
26
26
  * Signature scheme marker. zkLogin personal-message signatures are ZK
27
- * constructs that only Sui-aware verifiers can check — external x402
28
- * sellers (the MPP header dialect verifies the payer's personal signature
29
- * SELLER-side) reject them AFTER the on-chain payment already settled
30
- * (live finding, JMPR 2026-07-17: charged, no delivery). `payWithMpp`
31
- * fails closed on `'zklogin'` + header-only 402 BEFORE any money moves.
32
- * Optional so external signer impls keep compiling; undefined = keypair
33
- * semantics.
27
+ * constructs only Sui-aware verifiers can check — hosts use this to gate
28
+ * flows that depend on seller-side signature verification. Optional so
29
+ * external signer impls keep compiling; undefined = keypair semantics.
34
30
  */
35
31
  readonly kind?: 'keypair' | 'zklogin';
36
32
  }
@@ -893,19 +889,29 @@ interface PayOptions {
893
889
  maxPrice?: number;
894
890
  /** Bypass the spending-limit gate for this call (caller owns consent). */
895
891
  force?: boolean;
892
+ /**
893
+ * Attributed x402.paid activity reporting (B2) — after a successful pay,
894
+ * the settlement digest is fire-and-forgotten to the t2000.ai report
895
+ * endpoint (chain-verified server-side; never affects the payment).
896
+ * Default ON with source 'pay'; hosts override the source ('connect',
897
+ * 'try-it') or URL, or pass `false` to opt out.
898
+ */
899
+ activityReport?: {
900
+ url?: string;
901
+ source?: 'pay' | 'try-it' | 'connect';
902
+ } | false;
896
903
  }
897
904
  interface PayResult {
898
905
  status: number;
899
906
  body: unknown;
900
907
  paid: boolean;
901
908
  /**
902
- * Which payment dialect settled the call. `'x402'` = the sign-then-settle
903
- * x402 `sui-exact` scheme (client signs, gateway settles); `'legacy'` = the
904
- * pre-x402 MPP digest dialect (client broadcasts, retries with the digest).
905
- * Undefined when nothing was paid (free/cached endpoint). See
906
- * SUIMPP_X402_SCHEME.md.
909
+ * Which payment dialect settled the call — always `'x402'` (sign-then-
910
+ * settle `sui-exact`; client signs, gateway settles) since the MPP header
911
+ * dialect was removed 2026-08-03. Undefined when nothing was paid
912
+ * (free/cached endpoint). See SUIMPP_X402_SCHEME.md.
907
913
  */
908
- dialect?: 'x402' | 'legacy';
914
+ dialect?: 'x402';
909
915
  cost?: number;
910
916
  /**
911
917
  * SUI gas cost actually paid on chain. Zero for gasless payments —
@@ -937,19 +943,26 @@ declare function payWithMpp(args: {
937
943
  client: SuiGrpcClient;
938
944
  options: PayOptions;
939
945
  }): Promise<PayResult>;
940
- /**
941
- * Parse the MPP header dialect from a 402 response: the
942
- * `WWW-Authenticate: Payment …` challenge(s), looking for `method="sui"`.
943
- * Returns the decoded `{ amount, currency, recipient }` request (amount is a
944
- * decimal string, e.g. "0.02") or `undefined` when the response carries no
945
- * sui challenge. Exported for the CLI's `t2 pay --estimate`.
946
- */
947
- declare function parseMppSuiChallenge(response: Response): Promise<{
948
- amount: string;
949
- currency: string;
950
- recipient: string;
951
- description?: string;
952
- } | undefined>;
946
+
947
+ declare const DEFAULT_ACTIVITY_REPORT_URL = "https://t2000.ai/api/activity/x402";
948
+ type ActivityReportSource = 'pay' | 'try-it' | 'connect';
949
+ /** Per-call reporting config on PayOptions: override the URL/source, or
950
+ * `false` to opt out entirely. */
951
+ type ActivityReportConfig = {
952
+ url?: string;
953
+ source?: ActivityReportSource;
954
+ } | false;
955
+ interface X402ActivityPayload {
956
+ digest: string;
957
+ payTo: string;
958
+ payer?: string;
959
+ amountMicroUsdc: number;
960
+ network: string;
961
+ route?: string;
962
+ source: ActivityReportSource;
963
+ }
964
+ /** Fire-and-forget report — short timeout, every failure swallowed. */
965
+ declare function reportX402Activity(payload: X402ActivityPayload, url?: string): void;
953
966
 
954
967
  type SuiTransactionEffects = SuiClientTypes.TransactionEffects;
955
968
  type BuildClient = NonNullable<Parameters<Transaction['build']>[0]>['client'];
@@ -1543,4 +1556,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1543
1556
  * the store is untrusted; the chain hash is the authority). */
1544
1557
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1545
1558
 
1546
- export { TOKEN_MAP as $, A2A_ESCROW_FEE_CONFIG_ID as A, type BalanceResponse as B, CLOCK_ID as C, DEFAULT_COMMERCE_API_BASE as D, ETH_TYPE as E, type SendResult as F, GAS_RESERVE_MIN as G, type ServiceListing 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 SimulationResult as Q, type StableAsset as R, STABLE_ASSETS as S, type SuiHolding as T, type SuiRpcTxBlock as U, type SupportedAsset as V, type SwapRouteResult as W, T2000Error as X, type T2000ErrorCode as Y, type T2000ErrorData as Z, T2000_OVERLAY_FEE_WALLET as _, A2A_ESCROW_PACKAGE_ID as a, validateAddress as a$, type TransactionLeg as a0, type TransactionRecord as a1, type TransactionSigner as a2, type TxDirection as a3, USDC_DECIMALS as a4, USDC_TYPE as a5, USDE_TYPE as a6, USDSUI_TYPE as a7, USDT_TYPE as a8, WAL_TYPE as a9, getDecimals as aA, getDecimalsForCoinType as aB, getJob as aC, getJobSpec as aD, jobActionsFor as aE, listServices as aF, mapMoveAbortCode as aG, mapWalletError as aH, mistToSui as aI, parseMppSuiChallenge as aJ, parseSuiRpcTx as aK, payWithMpp as aL, preflightCreateJob as aM, preflightFail as aN, preflightPay as aO, preflightSend as aP, preflightSwap as aQ, putJobSpec as aR, rawToStable as aS, rawToUsdc as aT, refineLendingLabel as aU, resolveSymbol as aV, resolveTokenType as aW, stableToRaw as aX, suiToMist as aY, truncateAddress as aZ, usdcToRaw as a_, WBTC_TYPE as aa, type ZkLoginProof as ab, ZkLoginSigner as ac, buildCreateJobTx as ad, buildDeliverJobTx as ae, buildRefundJobTx as af, buildRejectJobTx as ag, buildReleaseJobTx as ah, buildSendTx as ai, buildSwapTx as aj, checkPositiveAmount as ak, checkSuiAddress as al, classifyAction as am, classifyLabel as an, classifyTransaction as ao, executeTx as ap, extractAllUserLegs as aq, extractTransferDetails as ar, extractTxCommands as as, extractTxSender as at, fallbackLabel as au, fetchService as av, findSwapRoute as aw, formatAssetAmount as ax, formatSui as ay, formatUsd as az, COIN_REGISTRY as b, verifyJobForSeller as b0, type T2000Options as b1, type SwapResult as b2, type SwapQuoteResult as b3, type PaymentRequest as b4, type SuiCoreClient as b5, type SponsoredCoinMergeCache as b6, type SendableAsset as b7, CETUS_USDC_SUI_POOL as b8, type CoinPage as b9, queryTransaction as bA, selectAndSplitCoin as bB, selectSuiCoin as bC, serializeCetusRoute as bD, simulateTransaction as bE, throwIfSimulationFailed as bF, verifyCetusRouteCoinMatch as bG, DEFAULT_GRPC_URL as ba, GASLESS_MIN_STABLE_AMOUNT as bb, GASLESS_STABLE_TYPES as bc, OPERATION_ASSETS as bd, type Operation as be, SENDABLE_ASSETS as bf, type SelectAndSplitResult as bg, type SerializedCetusRoute as bh, type SerializedCetusRoutePath as bi, type SerializedRouterDataV3 as bj, addSendToTx as bk, addSwapToTx as bl, assertAllowedAsset as bm, assertBuyerRequirements as bn, buildDeclineJobTx as bo, deserializeCetusRoute as bp, fetchAllCoins as bq, getCoinMeta as br, getSuiClient as bs, getSuiGrpcClient as bt, isAllowedAsset as bu, isCetusRouteFresh as bv, isInRegistry as bw, normalizeAsset as bx, normalizeCoinType as by, queryHistory as bz, type ClassifyBalanceChange as c, type ClassifyResult as d, type CoinMeta as e, DEFAULT_NETWORK as f, type DepositInfo as g, type ExtractedTransfer as h, type Job as i, type JobState as j, type JobTerms as k, type JobVerification as l, KeypairSigner as m, LOFI_TYPE as n, MAX_DELIVER_HORIZON_MS as o, MAX_JOB_USDC as p, MAX_REVIEW_WINDOW_MS as q, MIST_PER_SUI as r, type OverlayFeeConfig as s, PREFLIGHT_OK as t, type PayOptions as u, type PayResult as v, type PreflightResult as w, SUI_DECIMALS as x, SUI_TYPE as y, SUPPORTED_ASSETS as z };
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, payWithMpp 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 SwapResult as b5, type SwapQuoteResult as b6, type PaymentRequest as b7, type SuiCoreClient as b8, type SponsoredCoinMergeCache as b9, normalizeAsset as bA, normalizeCoinType as bB, queryHistory as bC, queryTransaction as bD, selectAndSplitCoin as bE, selectSuiCoin as bF, serializeCetusRoute as bG, simulateTransaction as bH, throwIfSimulationFailed as bI, verifyCetusRouteCoinMatch as bJ, type SendableAsset as ba, CETUS_USDC_SUI_POOL as bb, type CoinPage as bc, DEFAULT_GRPC_URL as bd, GASLESS_MIN_STABLE_AMOUNT as be, GASLESS_STABLE_TYPES as bf, OPERATION_ASSETS as bg, type Operation as bh, SENDABLE_ASSETS as bi, type SelectAndSplitResult as bj, type SerializedCetusRoute as bk, type SerializedCetusRoutePath as bl, type SerializedRouterDataV3 as bm, addSendToTx as bn, addSwapToTx as bo, assertAllowedAsset as bp, assertBuyerRequirements as bq, buildDeclineJobTx as br, deserializeCetusRoute as bs, fetchAllCoins as bt, getCoinMeta as bu, getSuiClient as bv, getSuiGrpcClient as bw, isAllowedAsset as bx, isCetusRouteFresh as by, isInRegistry 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
@@ -1098,11 +1098,23 @@ async function executeTx(client, signer, buildTx, options = {}) {
1098
1098
  // src/wallet/pay.ts
1099
1099
  init_errors();
1100
1100
 
1101
- // src/mpp-cost.ts
1102
- function parseChallengeAmount(challenge) {
1103
- const raw = challenge?.request?.amount;
1104
- const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
1105
- return Number.isFinite(n) ? n : void 0;
1101
+ // src/wallet/activity-report.ts
1102
+ var DEFAULT_ACTIVITY_REPORT_URL = "https://t2000.ai/api/activity/x402";
1103
+ function resolveActivityReportUrl(override) {
1104
+ if (override) return override;
1105
+ const env = typeof process !== "undefined" && process.env ? process.env.T2000_ACTIVITY_REPORT_URL?.trim() : void 0;
1106
+ return env && env.length > 0 ? env : DEFAULT_ACTIVITY_REPORT_URL;
1107
+ }
1108
+ function reportX402Activity(payload, url) {
1109
+ try {
1110
+ void fetch(resolveActivityReportUrl(url), {
1111
+ method: "POST",
1112
+ headers: { "content-type": "application/json" },
1113
+ body: JSON.stringify(payload),
1114
+ signal: AbortSignal.timeout(1500)
1115
+ }).catch(() => void 0);
1116
+ } catch {
1117
+ }
1106
1118
  }
1107
1119
 
1108
1120
  // src/wallet/pay.ts
@@ -1171,18 +1183,12 @@ async function payWithMpp(args) {
1171
1183
  const result = await payViaX402({ signer, client, options, reqInit, requirements });
1172
1184
  return result;
1173
1185
  }
1174
- const headerChallenge = await parseMppSuiChallenge(probe);
1175
- if (headerChallenge) {
1176
- if (signer.kind === "zklogin") {
1177
- throw new exports.T2000Error(
1178
- "DIALECT_UNSUPPORTED",
1179
- "This seller only offers the MPP header dialect, which zkLogin (Passport) wallets cannot safely pay: the seller cannot verify zkLogin signatures, so the payment would settle on-chain without the service delivering. No payment was made. Use an x402-capable service, or pay from a keypair wallet (t2 CLI / MCP).",
1180
- { dialect: "mpp-header", signerKind: "zklogin" }
1181
- );
1182
- }
1183
- assertNotSelfPayment(signer.getAddress(), headerChallenge.recipient);
1184
- const result = await payViaMppHeader({ signer, client, options });
1185
- return result;
1186
+ if (hasPaymentAuthenticateHeader(probe)) {
1187
+ throw new exports.T2000Error(
1188
+ "DIALECT_UNSUPPORTED",
1189
+ "This seller answered a header-only 402 (WWW-Authenticate: Payment) with no payable x402 accepts[] envelope. The MPP header dialect is no longer supported \u2014 it charged before the seller proved it could deliver. No payment was made. The seller must offer x402 (e.g. @t2000/serve emits it).",
1190
+ { dialect: "mpp-header", reason: "header-only-402-unsupported" }
1191
+ );
1186
1192
  }
1187
1193
  if (pick.kind === "incomplete") {
1188
1194
  throw new exports.T2000Error(
@@ -1196,24 +1202,6 @@ async function payWithMpp(args) {
1196
1202
  `Endpoint returned 402 without an x402 'exact' / sui:${client.network} requirement in the body or an MPP 'sui' challenge in WWW-Authenticate. Nothing this SDK can pay.`
1197
1203
  );
1198
1204
  }
1199
- async function parseMppSuiChallenge(response) {
1200
- try {
1201
- const { Challenge } = await import('mppx');
1202
- const challenges = Challenge.fromResponseList(response);
1203
- const suiChallenge = challenges.find((c) => c.method === "sui" && c.intent === "charge");
1204
- if (!suiChallenge) return void 0;
1205
- const req = suiChallenge.request;
1206
- if (typeof req?.amount !== "string" || typeof req?.recipient !== "string") return void 0;
1207
- return {
1208
- amount: req.amount,
1209
- currency: typeof req.currency === "string" ? req.currency : "",
1210
- recipient: req.recipient,
1211
- description: suiChallenge.description
1212
- };
1213
- } catch {
1214
- return void 0;
1215
- }
1216
- }
1217
1205
  function hasCompleteSuimppChallenge(entry) {
1218
1206
  const s = entry.extra?.suimpp;
1219
1207
  return !!s && typeof s.challengeId === "string" && s.challengeId.length > 0 && typeof s.nonce === "number" && typeof s.chain === "string" && s.chain.length > 0 && typeof s.minEpoch === "string" && typeof s.maxEpoch === "string";
@@ -1272,6 +1260,21 @@ async function payViaX402(args) {
1272
1260
  }
1273
1261
  const result = await finalize(res, { paid });
1274
1262
  if (!paid) return { ...result, dialect: "x402" };
1263
+ if (digest && options.activityReport !== false) {
1264
+ const report = options.activityReport || {};
1265
+ reportX402Activity(
1266
+ {
1267
+ digest,
1268
+ payTo: requirements.payTo,
1269
+ payer: signer.getAddress(),
1270
+ amountMicroUsdc: Number(amountRaw),
1271
+ network: requirements.network,
1272
+ route: options.url,
1273
+ source: report.source ?? "pay"
1274
+ },
1275
+ report.url
1276
+ );
1277
+ }
1275
1278
  return {
1276
1279
  ...result,
1277
1280
  dialect: "x402",
@@ -1280,61 +1283,6 @@ async function payViaX402(args) {
1280
1283
  receipt: digest ? { reference: digest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : result.receipt
1281
1284
  };
1282
1285
  }
1283
- async function payViaMppHeader(args) {
1284
- const { signer, client, options } = args;
1285
- const { Mppx } = await import('mppx/client');
1286
- const { sui, USDC, USDC_TESTNET } = await import('@suimpp/mpp/client');
1287
- const signerAddress = signer.getAddress();
1288
- const network = client.network === "testnet" ? "testnet" : "mainnet";
1289
- const grpcClient = await makeGrpcBuildClient(client);
1290
- let paymentDigest;
1291
- let gasCostSui = 0;
1292
- let chargedAmount;
1293
- const mppx = Mppx.create({
1294
- polyfill: false,
1295
- onChallenge: async (challenge) => {
1296
- const parsed = parseChallengeAmount(challenge);
1297
- if (parsed !== void 0) {
1298
- chargedAmount = parsed;
1299
- assertWithinMaxPrice(parsed, options.maxPrice);
1300
- }
1301
- return void 0;
1302
- },
1303
- methods: [
1304
- sui({
1305
- client,
1306
- currency: network === "testnet" ? USDC_TESTNET : USDC,
1307
- signer: {
1308
- toSuiAddress: () => signerAddress,
1309
- signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
1310
- },
1311
- execute: async (tx) => {
1312
- const result2 = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1313
- paymentDigest = result2.digest;
1314
- gasCostSui = result2.gasCostSui;
1315
- return { digest: result2.digest };
1316
- }
1317
- })
1318
- ]
1319
- });
1320
- const method = (options.method ?? "GET").toUpperCase();
1321
- const canHaveBody = method !== "GET" && method !== "HEAD";
1322
- const response = await mppx.fetch(options.url, {
1323
- method,
1324
- headers: options.headers,
1325
- body: canHaveBody ? options.body : void 0
1326
- });
1327
- const paid = !!paymentDigest;
1328
- const result = await finalize(response, { paid });
1329
- if (!paid) return { ...result, dialect: "legacy" };
1330
- return {
1331
- ...result,
1332
- dialect: "legacy",
1333
- cost: chargedAmount ?? options.maxPrice ?? void 0,
1334
- gasCostSui,
1335
- receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
1336
- };
1337
- }
1338
1286
  function assertNotSelfPayment(payer, payTo) {
1339
1287
  if (utils.normalizeSuiAddress(payer) === utils.normalizeSuiAddress(payTo)) {
1340
1288
  throw new exports.T2000Error(
@@ -1386,6 +1334,10 @@ async function ensureAddressBalanceCovers(args) {
1386
1334
  const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1387
1335
  return migration.gasCostSui;
1388
1336
  }
1337
+ function hasPaymentAuthenticateHeader(response) {
1338
+ const header = response.headers.get("www-authenticate") ?? "";
1339
+ return /(^|,)\s*Payment[\s,]/i.test(`${header},`);
1340
+ }
1389
1341
  function isJsonText(text) {
1390
1342
  try {
1391
1343
  JSON.parse(text);
@@ -4619,6 +4571,7 @@ exports.CETUS_POOLS_ID = CETUS_POOLS_ID;
4619
4571
  exports.CETUS_POSITION_TYPE = CETUS_POSITION_TYPE;
4620
4572
  exports.CETUS_USDC_SUI_POOL = CETUS_USDC_SUI_POOL;
4621
4573
  exports.CLOCK_ID = CLOCK_ID;
4574
+ exports.DEFAULT_ACTIVITY_REPORT_URL = DEFAULT_ACTIVITY_REPORT_URL;
4622
4575
  exports.DEFAULT_API_BASE = DEFAULT_API_BASE;
4623
4576
  exports.DEFAULT_COMMERCE_API_BASE = DEFAULT_COMMERCE_API_BASE;
4624
4577
  exports.DEFAULT_GRPC_URL = DEFAULT_GRPC_URL;
@@ -4741,7 +4694,6 @@ exports.mistToSui = mistToSui;
4741
4694
  exports.normalizeAddressInput = normalizeAddressInput;
4742
4695
  exports.normalizeAsset = normalizeAsset;
4743
4696
  exports.normalizeCoinType = normalizeCoinType;
4744
- exports.parseMppSuiChallenge = parseMppSuiChallenge;
4745
4697
  exports.parseSuiRpcTx = parseSuiRpcTx;
4746
4698
  exports.payWithMpp = payWithMpp;
4747
4699
  exports.postOpenJob = postOpenJob;
@@ -4761,6 +4713,7 @@ exports.readLimitsFile = readLimitsFile;
4761
4713
  exports.recordDailySpend = recordDailySpend;
4762
4714
  exports.refineLendingLabel = refineLendingLabel;
4763
4715
  exports.refundOpenJob = refundOpenJob;
4716
+ exports.reportX402Activity = reportX402Activity;
4764
4717
  exports.resolveAddressToSuinsViaRpc = resolveAddressToSuinsViaRpc;
4765
4718
  exports.resolveSuinsViaRpc = resolveSuinsViaRpc;
4766
4719
  exports.resolveSymbol = resolveSymbol;