@t2000/sdk 10.20.2 → 10.21.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/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 { X as T2000Error, b0 as T2000Options, a2 as TransactionSigner, u as PayOptions, v as PayResult, b1 as SwapResult, b2 as SwapQuoteResult, V as SupportedAsset, F as SendResult, B as BalanceResponse, a1 as TransactionRecord, g as DepositInfo, b3 as PaymentRequest, ab as ZkLoginProof, b4 as SuiCoreClient, s as OverlayFeeConfig, b5 as SponsoredCoinMergeCache, W as SwapRouteResult, b6 as SendableAsset } from './commerce-sBVg9pVH.cjs';
5
+ export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b7 as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, b8 as CoinPage, D as DEFAULT_COMMERCE_API_BASE, b9 as DEFAULT_GRPC_URL, f as DEFAULT_NETWORK, E as ETH_TYPE, h as ExtractedTransfer, ba as GASLESS_MIN_STABLE_AMOUNT, bb 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, bc as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bd as Operation, P as PREFLIGHT_MAX_AMOUNT, t as PREFLIGHT_OK, w as PreflightResult, be as SENDABLE_ASSETS, S as STABLE_ASSETS, x as SUI_DECIMALS, y as SUI_TYPE, z as SUPPORTED_ASSETS, bf as SelectAndSplitResult, bg as SerializedCetusRoute, bh as SerializedCetusRoutePath, bi 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, bj as addSendToTx, bk as addSwapToTx, bl as assertAllowedAsset, bm as assertBuyerRequirements, ad as buildCreateJobTx, bn 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, bo as deserializeCetusRoute, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, bp as fetchAllCoins, av as fetchService, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, bq as getCoinMeta, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, br as getSuiClient, bs as getSuiGrpcClient, bt as isAllowedAsset, bu as isCetusRouteFresh, bv as isInRegistry, aE as jobActionsFor, aF as listServices, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, bw as normalizeAsset, bx as normalizeCoinType, aJ as parseSuiRpcTx, aK as payWithMpp, aL as preflightCreateJob, aM as preflightFail, aN as preflightPay, aO as preflightSend, aP as preflightSwap, aQ as putJobSpec, by as queryHistory, bz as queryTransaction, aR as rawToStable, aS as rawToUsdc, aT as refineLendingLabel, aU as resolveSymbol, aV as resolveTokenType, bA as selectAndSplitCoin, bB as selectSuiCoin, bC as serializeCetusRoute, bD as simulateTransaction, aW as stableToRaw, aX as suiToMist, bE as throwIfSimulationFailed, aY as truncateAddress, aZ as usdcToRaw, a_ as validateAddress, bF as verifyCetusRouteCoinMatch, a$ as verifyJobForSeller } from './commerce-sBVg9pVH.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 { X as T2000Error, b0 as T2000Options, a2 as TransactionSigner, u as PayOptions, v as PayResult, b1 as SwapResult, b2 as SwapQuoteResult, V as SupportedAsset, F as SendResult, B as BalanceResponse, a1 as TransactionRecord, g as DepositInfo, b3 as PaymentRequest, ab as ZkLoginProof, b4 as SuiCoreClient, s as OverlayFeeConfig, b5 as SponsoredCoinMergeCache, W as SwapRouteResult, b6 as SendableAsset } from './commerce-sBVg9pVH.js';
5
+ export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b7 as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, b8 as CoinPage, D as DEFAULT_COMMERCE_API_BASE, b9 as DEFAULT_GRPC_URL, f as DEFAULT_NETWORK, E as ETH_TYPE, h as ExtractedTransfer, ba as GASLESS_MIN_STABLE_AMOUNT, bb 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, bc as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, bd as Operation, P as PREFLIGHT_MAX_AMOUNT, t as PREFLIGHT_OK, w as PreflightResult, be as SENDABLE_ASSETS, S as STABLE_ASSETS, x as SUI_DECIMALS, y as SUI_TYPE, z as SUPPORTED_ASSETS, bf as SelectAndSplitResult, bg as SerializedCetusRoute, bh as SerializedCetusRoutePath, bi 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, bj as addSendToTx, bk as addSwapToTx, bl as assertAllowedAsset, bm as assertBuyerRequirements, ad as buildCreateJobTx, bn 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, bo as deserializeCetusRoute, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, bp as fetchAllCoins, av as fetchService, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, bq as getCoinMeta, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, br as getSuiClient, bs as getSuiGrpcClient, bt as isAllowedAsset, bu as isCetusRouteFresh, bv as isInRegistry, aE as jobActionsFor, aF as listServices, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, bw as normalizeAsset, bx as normalizeCoinType, aJ as parseSuiRpcTx, aK as payWithMpp, aL as preflightCreateJob, aM as preflightFail, aN as preflightPay, aO as preflightSend, aP as preflightSwap, aQ as putJobSpec, by as queryHistory, bz as queryTransaction, aR as rawToStable, aS as rawToUsdc, aT as refineLendingLabel, aU as resolveSymbol, aV as resolveTokenType, bA as selectAndSplitCoin, bB as selectSuiCoin, bC as serializeCetusRoute, bD as simulateTransaction, aW as stableToRaw, aX as suiToMist, bE as throwIfSimulationFailed, aY as truncateAddress, aZ as usdcToRaw, a_ as validateAddress, bF as verifyCetusRouteCoinMatch, a$ as verifyJobForSeller } from './commerce-sBVg9pVH.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
@@ -1091,15 +1091,6 @@ async function executeTx(client, signer, buildTx, options = {}) {
1091
1091
 
1092
1092
  // src/wallet/pay.ts
1093
1093
  init_errors();
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;
1100
- }
1101
-
1102
- // src/wallet/pay.ts
1103
1094
  init_preflight();
1104
1095
  function preflightPay(input) {
1105
1096
  if (typeof input.url !== "string" || input.url.trim() === "") {
@@ -1165,18 +1156,12 @@ async function payWithMpp(args) {
1165
1156
  const result = await payViaX402({ signer, client, options, reqInit, requirements });
1166
1157
  return result;
1167
1158
  }
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;
1159
+ if (hasPaymentAuthenticateHeader(probe)) {
1160
+ throw new T2000Error(
1161
+ "DIALECT_UNSUPPORTED",
1162
+ "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).",
1163
+ { dialect: "mpp-header", reason: "header-only-402-unsupported" }
1164
+ );
1180
1165
  }
1181
1166
  if (pick.kind === "incomplete") {
1182
1167
  throw new T2000Error(
@@ -1190,24 +1175,6 @@ async function payWithMpp(args) {
1190
1175
  `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
1176
  );
1192
1177
  }
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
1178
  function hasCompleteSuimppChallenge(entry) {
1212
1179
  const s = entry.extra?.suimpp;
1213
1180
  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";
@@ -1274,61 +1241,6 @@ async function payViaX402(args) {
1274
1241
  receipt: digest ? { reference: digest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : result.receipt
1275
1242
  };
1276
1243
  }
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
1244
  function assertNotSelfPayment(payer, payTo) {
1333
1245
  if (normalizeSuiAddress(payer) === normalizeSuiAddress(payTo)) {
1334
1246
  throw new T2000Error(
@@ -1380,6 +1292,10 @@ async function ensureAddressBalanceCovers(args) {
1380
1292
  const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
1381
1293
  return migration.gasCostSui;
1382
1294
  }
1295
+ function hasPaymentAuthenticateHeader(response) {
1296
+ const header = response.headers.get("www-authenticate") ?? "";
1297
+ return /(^|,)\s*Payment[\s,]/i.test(`${header},`);
1298
+ }
1383
1299
  function isJsonText(text) {
1384
1300
  try {
1385
1301
  JSON.parse(text);
@@ -4586,6 +4502,6 @@ async function buildDirectPoolSwapTx(args) {
4586
4502
  return tx;
4587
4503
  }
4588
4504
 
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 };
4505
+ 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, 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 };
4590
4506
  //# sourceMappingURL=index.js.map
4591
4507
  //# sourceMappingURL=index.js.map