@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.
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 { X as T2000Error, b1 as T2000Options, a2 as TransactionSigner, u as PayOptions, v as PayResult, b2 as SwapResult, b3 as SwapQuoteResult, V as SupportedAsset, F as SendResult, B as BalanceResponse, a1 as TransactionRecord, g as DepositInfo, b4 as PaymentRequest, ab as ZkLoginProof, b5 as SuiCoreClient, s as OverlayFeeConfig, b6 as SponsoredCoinMergeCache, W as SwapRouteResult, b7 as SendableAsset } from './commerce-BkSSPS1w.cjs';
5
- export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b8 as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, b9 as CoinPage, D as DEFAULT_COMMERCE_API_BASE, ba as DEFAULT_GRPC_URL, f as DEFAULT_NETWORK, E as ETH_TYPE, h as ExtractedTransfer, bb as GASLESS_MIN_STABLE_AMOUNT, bc as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, i as Job, j as JobState, k as JobTerms, l as JobVerification, K as KNOWN_TARGETS, m as KeypairSigner, L as LABEL_PATTERNS, n as LOFI_TYPE, M as MANIFEST_TYPE, o as MAX_DELIVER_HORIZON_MS, p as MAX_JOB_USDC, q as MAX_REVIEW_WINDOW_MS, r as MIST_PER_SUI, N as NAVX_TYPE, bd as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, be as Operation, P as PREFLIGHT_MAX_AMOUNT, t as PREFLIGHT_OK, w as PreflightResult, bf as SENDABLE_ASSETS, S as STABLE_ASSETS, x as SUI_DECIMALS, y as SUI_TYPE, z as SUPPORTED_ASSETS, bg as SelectAndSplitResult, bh as SerializedCetusRoute, bi as SerializedCetusRoutePath, bj as SerializedRouterDataV3, H as ServiceListing, Q as SimulationResult, R as StableAsset, T as SuiHolding, U as SuiRpcTxBlock, Y as T2000ErrorCode, Z as T2000ErrorData, _ as T2000_OVERLAY_FEE_WALLET, $ as TOKEN_MAP, a0 as TransactionLeg, a3 as TxDirection, a4 as USDC_DECIMALS, a5 as USDC_TYPE, a6 as USDE_TYPE, a7 as USDSUI_TYPE, a8 as USDT_TYPE, a9 as WAL_TYPE, aa as WBTC_TYPE, ac as ZkLoginSigner, bk as addSendToTx, bl as addSwapToTx, bm as assertAllowedAsset, bn as assertBuyerRequirements, ad as buildCreateJobTx, bo as buildDeclineJobTx, ae as buildDeliverJobTx, af as buildRefundJobTx, ag as buildRejectJobTx, ah as buildReleaseJobTx, ai as buildSendTx, aj as buildSwapTx, ak as checkPositiveAmount, al as checkSuiAddress, am as classifyAction, an as classifyLabel, ao as classifyTransaction, bp as deserializeCetusRoute, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, bq as fetchAllCoins, av as fetchService, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, br as getCoinMeta, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, bs as getSuiClient, bt as getSuiGrpcClient, bu as isAllowedAsset, bv as isCetusRouteFresh, bw as isInRegistry, aE as jobActionsFor, aF as listServices, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, bx as normalizeAsset, by as normalizeCoinType, aJ as parseMppSuiChallenge, aK as parseSuiRpcTx, aL as payWithMpp, aM as preflightCreateJob, aN as preflightFail, aO as preflightPay, aP as preflightSend, aQ as preflightSwap, aR as putJobSpec, bz as queryHistory, bA as queryTransaction, aS as rawToStable, aT as rawToUsdc, aU as refineLendingLabel, aV as resolveSymbol, aW as resolveTokenType, bB as selectAndSplitCoin, bC as selectSuiCoin, bD as serializeCetusRoute, bE as simulateTransaction, aX as stableToRaw, aY as suiToMist, bF as throwIfSimulationFailed, aZ as truncateAddress, a_ as usdcToRaw, a$ as validateAddress, bG as verifyCetusRouteCoinMatch, b0 as verifyJobForSeller } from './commerce-BkSSPS1w.cjs';
4
+ import { Z as T2000Error, b4 as T2000Options, a4 as TransactionSigner, w as PayOptions, x as PayResult, b5 as SwapResult, b6 as SwapQuoteResult, X as SupportedAsset, Q as SendResult, B as BalanceResponse, a3 as TransactionRecord, i as DepositInfo, b7 as PaymentRequest, ae as ZkLoginProof, b8 as SuiCoreClient, u as OverlayFeeConfig, b9 as SponsoredCoinMergeCache, Y as SwapRouteResult, ba as SendableAsset } from './commerce-CS4wgrg5.cjs';
5
+ export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, bb as CETUS_USDC_SUI_POOL, C as CLOCK_ID, c as COIN_REGISTRY, d as ClassifyBalanceChange, e as ClassifyResult, f as CoinMeta, bc as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, g as DEFAULT_COMMERCE_API_BASE, bd as DEFAULT_GRPC_URL, h as DEFAULT_NETWORK, E as ETH_TYPE, j as ExtractedTransfer, be as GASLESS_MIN_STABLE_AMOUNT, bf 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, 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, bg as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bh as Operation, P as PREFLIGHT_MAX_AMOUNT, v as PREFLIGHT_OK, y as PreflightResult, bi as SENDABLE_ASSETS, S as STABLE_ASSETS, z as SUI_DECIMALS, F as SUI_TYPE, H as SUPPORTED_ASSETS, bj as SelectAndSplitResult, bk as SerializedCetusRoute, bl as SerializedCetusRoutePath, bm as SerializedRouterDataV3, R as ServiceListing, T as SimulationResult, U as StableAsset, V as SuiHolding, W as SuiRpcTxBlock, _ as T2000ErrorCode, $ as T2000ErrorData, a0 as T2000_OVERLAY_FEE_WALLET, a1 as TOKEN_MAP, a2 as TransactionLeg, a5 as TxDirection, a6 as USDC_DECIMALS, a7 as USDC_TYPE, a8 as USDE_TYPE, a9 as USDSUI_TYPE, aa as USDT_TYPE, ab as WAL_TYPE, ac as WBTC_TYPE, ad as X402ActivityPayload, af as ZkLoginSigner, bn as addSendToTx, bo as addSwapToTx, bp as assertAllowedAsset, bq as assertBuyerRequirements, ag as buildCreateJobTx, br as buildDeclineJobTx, ah as buildDeliverJobTx, ai as buildRefundJobTx, aj as buildRejectJobTx, ak as buildReleaseJobTx, al as buildSendTx, am as buildSwapTx, an as checkPositiveAmount, ao as checkSuiAddress, ap as classifyAction, aq as classifyLabel, ar as classifyTransaction, bs as deserializeCetusRoute, as as executeTx, at as extractAllUserLegs, au as extractTransferDetails, av as extractTxCommands, aw as extractTxSender, ax as fallbackLabel, bt as fetchAllCoins, ay as fetchService, az as findSwapRoute, aA as formatAssetAmount, aB as formatSui, aC as formatUsd, bu as getCoinMeta, aD as getDecimals, aE as getDecimalsForCoinType, aF as getJob, aG as getJobSpec, bv as getSuiClient, bw as getSuiGrpcClient, bx as isAllowedAsset, by as isCetusRouteFresh, bz as isInRegistry, aH as jobActionsFor, aI as listServices, aJ as mapMoveAbortCode, aK as mapWalletError, aL as mistToSui, bA as normalizeAsset, bB as normalizeCoinType, aM as parseSuiRpcTx, aN as payWithMpp, aO as preflightCreateJob, aP as preflightFail, aQ as preflightPay, aR as preflightSend, aS as preflightSwap, aT as putJobSpec, bC as queryHistory, bD as queryTransaction, aU as rawToStable, aV as rawToUsdc, aW as refineLendingLabel, aX as reportX402Activity, aY as resolveSymbol, aZ as resolveTokenType, bE as selectAndSplitCoin, bF as selectSuiCoin, bG as serializeCetusRoute, bH as simulateTransaction, a_ as stableToRaw, a$ as suiToMist, bI as throwIfSimulationFailed, b0 as truncateAddress, b1 as usdcToRaw, b2 as validateAddress, bJ as verifyCetusRouteCoinMatch, b3 as verifyJobForSeller } from './commerce-CS4wgrg5.cjs';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
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 { X as T2000Error, b1 as T2000Options, a2 as TransactionSigner, u as PayOptions, v as PayResult, b2 as SwapResult, b3 as SwapQuoteResult, V as SupportedAsset, F as SendResult, B as BalanceResponse, a1 as TransactionRecord, g as DepositInfo, b4 as PaymentRequest, ab as ZkLoginProof, b5 as SuiCoreClient, s as OverlayFeeConfig, b6 as SponsoredCoinMergeCache, W as SwapRouteResult, b7 as SendableAsset } from './commerce-BkSSPS1w.js';
5
- export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b8 as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, b9 as CoinPage, D as DEFAULT_COMMERCE_API_BASE, ba as DEFAULT_GRPC_URL, f as DEFAULT_NETWORK, E as ETH_TYPE, h as ExtractedTransfer, bb as GASLESS_MIN_STABLE_AMOUNT, bc as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, i as Job, j as JobState, k as JobTerms, l as JobVerification, K as KNOWN_TARGETS, m as KeypairSigner, L as LABEL_PATTERNS, n as LOFI_TYPE, M as MANIFEST_TYPE, o as MAX_DELIVER_HORIZON_MS, p as MAX_JOB_USDC, q as MAX_REVIEW_WINDOW_MS, r as MIST_PER_SUI, N as NAVX_TYPE, bd as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, be as Operation, P as PREFLIGHT_MAX_AMOUNT, t as PREFLIGHT_OK, w as PreflightResult, bf as SENDABLE_ASSETS, S as STABLE_ASSETS, x as SUI_DECIMALS, y as SUI_TYPE, z as SUPPORTED_ASSETS, bg as SelectAndSplitResult, bh as SerializedCetusRoute, bi as SerializedCetusRoutePath, bj as SerializedRouterDataV3, H as ServiceListing, Q as SimulationResult, R as StableAsset, T as SuiHolding, U as SuiRpcTxBlock, Y as T2000ErrorCode, Z as T2000ErrorData, _ as T2000_OVERLAY_FEE_WALLET, $ as TOKEN_MAP, a0 as TransactionLeg, a3 as TxDirection, a4 as USDC_DECIMALS, a5 as USDC_TYPE, a6 as USDE_TYPE, a7 as USDSUI_TYPE, a8 as USDT_TYPE, a9 as WAL_TYPE, aa as WBTC_TYPE, ac as ZkLoginSigner, bk as addSendToTx, bl as addSwapToTx, bm as assertAllowedAsset, bn as assertBuyerRequirements, ad as buildCreateJobTx, bo as buildDeclineJobTx, ae as buildDeliverJobTx, af as buildRefundJobTx, ag as buildRejectJobTx, ah as buildReleaseJobTx, ai as buildSendTx, aj as buildSwapTx, ak as checkPositiveAmount, al as checkSuiAddress, am as classifyAction, an as classifyLabel, ao as classifyTransaction, bp as deserializeCetusRoute, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, bq as fetchAllCoins, av as fetchService, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, br as getCoinMeta, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, bs as getSuiClient, bt as getSuiGrpcClient, bu as isAllowedAsset, bv as isCetusRouteFresh, bw as isInRegistry, aE as jobActionsFor, aF as listServices, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, bx as normalizeAsset, by as normalizeCoinType, aJ as parseMppSuiChallenge, aK as parseSuiRpcTx, aL as payWithMpp, aM as preflightCreateJob, aN as preflightFail, aO as preflightPay, aP as preflightSend, aQ as preflightSwap, aR as putJobSpec, bz as queryHistory, bA as queryTransaction, aS as rawToStable, aT as rawToUsdc, aU as refineLendingLabel, aV as resolveSymbol, aW as resolveTokenType, bB as selectAndSplitCoin, bC as selectSuiCoin, bD as serializeCetusRoute, bE as simulateTransaction, aX as stableToRaw, aY as suiToMist, bF as throwIfSimulationFailed, aZ as truncateAddress, a_ as usdcToRaw, a$ as validateAddress, bG as verifyCetusRouteCoinMatch, b0 as verifyJobForSeller } from './commerce-BkSSPS1w.js';
4
+ import { Z as T2000Error, b4 as T2000Options, a4 as TransactionSigner, w as PayOptions, x as PayResult, b5 as SwapResult, b6 as SwapQuoteResult, X as SupportedAsset, Q as SendResult, B as BalanceResponse, a3 as TransactionRecord, i as DepositInfo, b7 as PaymentRequest, ae as ZkLoginProof, b8 as SuiCoreClient, u as OverlayFeeConfig, b9 as SponsoredCoinMergeCache, Y as SwapRouteResult, ba as SendableAsset } from './commerce-CS4wgrg5.js';
5
+ export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, bb as CETUS_USDC_SUI_POOL, C as CLOCK_ID, c as COIN_REGISTRY, d as ClassifyBalanceChange, e as ClassifyResult, f as CoinMeta, bc as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, g as DEFAULT_COMMERCE_API_BASE, bd as DEFAULT_GRPC_URL, h as DEFAULT_NETWORK, E as ETH_TYPE, j as ExtractedTransfer, be as GASLESS_MIN_STABLE_AMOUNT, bf 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, 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, bg as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bh as Operation, P as PREFLIGHT_MAX_AMOUNT, v as PREFLIGHT_OK, y as PreflightResult, bi as SENDABLE_ASSETS, S as STABLE_ASSETS, z as SUI_DECIMALS, F as SUI_TYPE, H as SUPPORTED_ASSETS, bj as SelectAndSplitResult, bk as SerializedCetusRoute, bl as SerializedCetusRoutePath, bm as SerializedRouterDataV3, R as ServiceListing, T as SimulationResult, U as StableAsset, V as SuiHolding, W as SuiRpcTxBlock, _ as T2000ErrorCode, $ as T2000ErrorData, a0 as T2000_OVERLAY_FEE_WALLET, a1 as TOKEN_MAP, a2 as TransactionLeg, a5 as TxDirection, a6 as USDC_DECIMALS, a7 as USDC_TYPE, a8 as USDE_TYPE, a9 as USDSUI_TYPE, aa as USDT_TYPE, ab as WAL_TYPE, ac as WBTC_TYPE, ad as X402ActivityPayload, af as ZkLoginSigner, bn as addSendToTx, bo as addSwapToTx, bp as assertAllowedAsset, bq as assertBuyerRequirements, ag as buildCreateJobTx, br as buildDeclineJobTx, ah as buildDeliverJobTx, ai as buildRefundJobTx, aj as buildRejectJobTx, ak as buildReleaseJobTx, al as buildSendTx, am as buildSwapTx, an as checkPositiveAmount, ao as checkSuiAddress, ap as classifyAction, aq as classifyLabel, ar as classifyTransaction, bs as deserializeCetusRoute, as as executeTx, at as extractAllUserLegs, au as extractTransferDetails, av as extractTxCommands, aw as extractTxSender, ax as fallbackLabel, bt as fetchAllCoins, ay as fetchService, az as findSwapRoute, aA as formatAssetAmount, aB as formatSui, aC as formatUsd, bu as getCoinMeta, aD as getDecimals, aE as getDecimalsForCoinType, aF as getJob, aG as getJobSpec, bv as getSuiClient, bw as getSuiGrpcClient, bx as isAllowedAsset, by as isCetusRouteFresh, bz as isInRegistry, aH as jobActionsFor, aI as listServices, aJ as mapMoveAbortCode, aK as mapWalletError, aL as mistToSui, bA as normalizeAsset, bB as normalizeCoinType, aM as parseSuiRpcTx, aN as payWithMpp, aO as preflightCreateJob, aP as preflightFail, aQ as preflightPay, aR as preflightSend, aS as preflightSwap, aT as putJobSpec, bC as queryHistory, bD as queryTransaction, aU as rawToStable, aV as rawToUsdc, aW as refineLendingLabel, aX as reportX402Activity, aY as resolveSymbol, aZ as resolveTokenType, bE as selectAndSplitCoin, bF as selectSuiCoin, bG as serializeCetusRoute, bH as simulateTransaction, a_ as stableToRaw, a$ as suiToMist, bI as throwIfSimulationFailed, b0 as truncateAddress, b1 as usdcToRaw, b2 as validateAddress, bJ as verifyCetusRouteCoinMatch, b3 as verifyJobForSeller } from './commerce-CS4wgrg5.js';
6
6
  import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
7
7
  import { SuinsClient } from '@mysten/suins';
8
8
  import '@mysten/sui/client';
package/dist/index.js CHANGED
@@ -1092,11 +1092,23 @@ async function executeTx(client, signer, buildTx, options = {}) {
1092
1092
  // src/wallet/pay.ts
1093
1093
  init_errors();
1094
1094
 
1095
- // src/mpp-cost.ts
1096
- function parseChallengeAmount(challenge) {
1097
- const raw = challenge?.request?.amount;
1098
- const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
1099
- return Number.isFinite(n) ? n : void 0;
1095
+ // src/wallet/activity-report.ts
1096
+ var DEFAULT_ACTIVITY_REPORT_URL = "https://t2000.ai/api/activity/x402";
1097
+ function resolveActivityReportUrl(override) {
1098
+ if (override) return override;
1099
+ const env = typeof process !== "undefined" && process.env ? process.env.T2000_ACTIVITY_REPORT_URL?.trim() : void 0;
1100
+ return env && env.length > 0 ? env : DEFAULT_ACTIVITY_REPORT_URL;
1101
+ }
1102
+ function reportX402Activity(payload, url) {
1103
+ try {
1104
+ void fetch(resolveActivityReportUrl(url), {
1105
+ method: "POST",
1106
+ headers: { "content-type": "application/json" },
1107
+ body: JSON.stringify(payload),
1108
+ signal: AbortSignal.timeout(1500)
1109
+ }).catch(() => void 0);
1110
+ } catch {
1111
+ }
1100
1112
  }
1101
1113
 
1102
1114
  // src/wallet/pay.ts
@@ -1165,18 +1177,12 @@ async function payWithMpp(args) {
1165
1177
  const result = await payViaX402({ signer, client, options, reqInit, requirements });
1166
1178
  return result;
1167
1179
  }
1168
- const headerChallenge = await parseMppSuiChallenge(probe);
1169
- if (headerChallenge) {
1170
- if (signer.kind === "zklogin") {
1171
- throw new T2000Error(
1172
- "DIALECT_UNSUPPORTED",
1173
- "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).",
1174
- { dialect: "mpp-header", signerKind: "zklogin" }
1175
- );
1176
- }
1177
- assertNotSelfPayment(signer.getAddress(), headerChallenge.recipient);
1178
- const result = await payViaMppHeader({ signer, client, options });
1179
- return result;
1180
+ if (hasPaymentAuthenticateHeader(probe)) {
1181
+ throw new T2000Error(
1182
+ "DIALECT_UNSUPPORTED",
1183
+ "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).",
1184
+ { dialect: "mpp-header", reason: "header-only-402-unsupported" }
1185
+ );
1180
1186
  }
1181
1187
  if (pick.kind === "incomplete") {
1182
1188
  throw new T2000Error(
@@ -1190,24 +1196,6 @@ async function payWithMpp(args) {
1190
1196
  `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.`
1191
1197
  );
1192
1198
  }
1193
- async function parseMppSuiChallenge(response) {
1194
- try {
1195
- const { Challenge } = await import('mppx');
1196
- const challenges = Challenge.fromResponseList(response);
1197
- const suiChallenge = challenges.find((c) => c.method === "sui" && c.intent === "charge");
1198
- if (!suiChallenge) return void 0;
1199
- const req = suiChallenge.request;
1200
- if (typeof req?.amount !== "string" || typeof req?.recipient !== "string") return void 0;
1201
- return {
1202
- amount: req.amount,
1203
- currency: typeof req.currency === "string" ? req.currency : "",
1204
- recipient: req.recipient,
1205
- description: suiChallenge.description
1206
- };
1207
- } catch {
1208
- return void 0;
1209
- }
1210
- }
1211
1199
  function hasCompleteSuimppChallenge(entry) {
1212
1200
  const s = entry.extra?.suimpp;
1213
1201
  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";
@@ -1266,6 +1254,21 @@ async function payViaX402(args) {
1266
1254
  }
1267
1255
  const result = await finalize(res, { paid });
1268
1256
  if (!paid) return { ...result, dialect: "x402" };
1257
+ if (digest && options.activityReport !== false) {
1258
+ const report = options.activityReport || {};
1259
+ reportX402Activity(
1260
+ {
1261
+ digest,
1262
+ payTo: requirements.payTo,
1263
+ payer: signer.getAddress(),
1264
+ amountMicroUsdc: Number(amountRaw),
1265
+ network: requirements.network,
1266
+ route: options.url,
1267
+ source: report.source ?? "pay"
1268
+ },
1269
+ report.url
1270
+ );
1271
+ }
1269
1272
  return {
1270
1273
  ...result,
1271
1274
  dialect: "x402",
@@ -1274,61 +1277,6 @@ async function payViaX402(args) {
1274
1277
  receipt: digest ? { reference: digest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : result.receipt
1275
1278
  };
1276
1279
  }
1277
- async function payViaMppHeader(args) {
1278
- const { signer, client, options } = args;
1279
- const { Mppx } = await import('mppx/client');
1280
- const { sui, USDC, USDC_TESTNET } = await import('@suimpp/mpp/client');
1281
- const signerAddress = signer.getAddress();
1282
- const network = client.network === "testnet" ? "testnet" : "mainnet";
1283
- const grpcClient = await makeGrpcBuildClient(client);
1284
- let paymentDigest;
1285
- let gasCostSui = 0;
1286
- let chargedAmount;
1287
- const mppx = Mppx.create({
1288
- polyfill: false,
1289
- onChallenge: async (challenge) => {
1290
- const parsed = parseChallengeAmount(challenge);
1291
- if (parsed !== void 0) {
1292
- chargedAmount = parsed;
1293
- assertWithinMaxPrice(parsed, options.maxPrice);
1294
- }
1295
- return void 0;
1296
- },
1297
- methods: [
1298
- sui({
1299
- client,
1300
- currency: network === "testnet" ? USDC_TESTNET : USDC,
1301
- signer: {
1302
- toSuiAddress: () => signerAddress,
1303
- signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
1304
- },
1305
- execute: async (tx) => {
1306
- const result2 = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1307
- paymentDigest = result2.digest;
1308
- gasCostSui = result2.gasCostSui;
1309
- return { digest: result2.digest };
1310
- }
1311
- })
1312
- ]
1313
- });
1314
- const method = (options.method ?? "GET").toUpperCase();
1315
- const canHaveBody = method !== "GET" && method !== "HEAD";
1316
- const response = await mppx.fetch(options.url, {
1317
- method,
1318
- headers: options.headers,
1319
- body: canHaveBody ? options.body : void 0
1320
- });
1321
- const paid = !!paymentDigest;
1322
- const result = await finalize(response, { paid });
1323
- if (!paid) return { ...result, dialect: "legacy" };
1324
- return {
1325
- ...result,
1326
- dialect: "legacy",
1327
- cost: chargedAmount ?? options.maxPrice ?? void 0,
1328
- gasCostSui,
1329
- receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
1330
- };
1331
- }
1332
1280
  function assertNotSelfPayment(payer, payTo) {
1333
1281
  if (normalizeSuiAddress(payer) === normalizeSuiAddress(payTo)) {
1334
1282
  throw new T2000Error(
@@ -1380,6 +1328,10 @@ async function ensureAddressBalanceCovers(args) {
1380
1328
  const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1381
1329
  return migration.gasCostSui;
1382
1330
  }
1331
+ function hasPaymentAuthenticateHeader(response) {
1332
+ const header = response.headers.get("www-authenticate") ?? "";
1333
+ return /(^|,)\s*Payment[\s,]/i.test(`${header},`);
1334
+ }
1383
1335
  function isJsonText(text) {
1384
1336
  try {
1385
1337
  JSON.parse(text);
@@ -4586,6 +4538,6 @@ async function buildDirectPoolSwapTx(args) {
4586
4538
  return tx;
4587
4539
  }
4588
4540
 
4589
- 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, AGENT_CAPITAL_PACKAGE_ID, AGENT_CAPITAL_PUBLISHED_AT, AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AGENT_POOL_TICK_SPACING, AGENT_TOKEN_DECIMALS, AGENT_TOKEN_LP_ALLOCATION, AGENT_TOKEN_TOTAL_SUPPLY, AGENT_TOKEN_TREASURY_ALLOCATION, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CAPITAL_REGISTRY_ID, CAPITAL_REGISTRY_VERSION, CETUS_CLMM_PACKAGE_ID, CETUS_GLOBAL_CONFIG_ID, CETUS_INTEGRATE_PUBLISHED_AT, CETUS_POOLS_ID, CETUS_POSITION_TYPE, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, 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, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIN_LP_USDC, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICY_ANY_ACTIVE, 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, SYMBOL_BLOCKLIST, 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, buildAgentCoinModule, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildDirectPoolSwapTx, buildPublishAgentCoinTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, buildTokenizeTx, cancelOpenJob, 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, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateAgentCoinParams, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
4541
+ 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, AGENT_CAPITAL_PACKAGE_ID, AGENT_CAPITAL_PUBLISHED_AT, AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AGENT_POOL_TICK_SPACING, AGENT_TOKEN_DECIMALS, AGENT_TOKEN_LP_ALLOCATION, AGENT_TOKEN_TOTAL_SUPPLY, AGENT_TOKEN_TREASURY_ALLOCATION, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CAPITAL_REGISTRY_ID, CAPITAL_REGISTRY_VERSION, CETUS_CLMM_PACKAGE_ID, CETUS_GLOBAL_CONFIG_ID, CETUS_INTEGRATE_PUBLISHED_AT, CETUS_POOLS_ID, CETUS_POSITION_TYPE, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, 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, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIN_LP_USDC, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICY_ANY_ACTIVE, 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, SYMBOL_BLOCKLIST, 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, buildAgentCoinModule, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildDirectPoolSwapTx, buildPublishAgentCoinTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, buildTokenizeTx, cancelOpenJob, 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, payWithMpp, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, reportX402Activity, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateAgentCoinParams, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
4590
4542
  //# sourceMappingURL=index.js.map
4591
4543
  //# sourceMappingURL=index.js.map