@t2000/sdk 10.15.1 → 10.16.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.
@@ -1451,6 +1451,11 @@ declare function buildCreateJobTx({ client, buyer, terms, }: {
1451
1451
  buyer: string;
1452
1452
  terms: JobTerms;
1453
1453
  }): Promise<Transaction>;
1454
+ /** Seller's pre-delivery abort (SPEC_T2_AGENTS_TRUST §B): FUNDED only →
1455
+ * full fee-free refund to the buyer, terminal state REFUNDED (the
1456
+ * JobDeclined event is what distinguishes a decline from a deadline
1457
+ * refund). Targets the latest package id — `decline` shipped in v3. */
1458
+ declare function buildDeclineJobTx(jobId: string): Transaction;
1454
1459
  /** Seller posts the delivery commitment (hex hash) before the deadline. */
1455
1460
  declare function buildDeliverJobTx(jobId: string, deliveryHash: string): Transaction;
1456
1461
  /** Buyer accepts (or anyone, once the review window lapsed) → funds to seller. */
@@ -1538,4 +1543,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1538
1543
  * the store is untrusted; the chain hash is the authority). */
1539
1544
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1540
1545
 
1541
- 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, selectAndSplitCoin as bA, selectSuiCoin as bB, serializeCetusRoute as bC, simulateTransaction as bD, throwIfSimulationFailed as bE, verifyCetusRouteCoinMatch as bF, 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, deserializeCetusRoute as bo, fetchAllCoins as bp, getCoinMeta as bq, getSuiClient as br, getSuiGrpcClient as bs, isAllowedAsset as bt, isCetusRouteFresh as bu, isInRegistry as bv, normalizeAsset as bw, normalizeCoinType as bx, queryHistory as by, queryTransaction 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 };
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 };
@@ -1451,6 +1451,11 @@ declare function buildCreateJobTx({ client, buyer, terms, }: {
1451
1451
  buyer: string;
1452
1452
  terms: JobTerms;
1453
1453
  }): Promise<Transaction>;
1454
+ /** Seller's pre-delivery abort (SPEC_T2_AGENTS_TRUST §B): FUNDED only →
1455
+ * full fee-free refund to the buyer, terminal state REFUNDED (the
1456
+ * JobDeclined event is what distinguishes a decline from a deadline
1457
+ * refund). Targets the latest package id — `decline` shipped in v3. */
1458
+ declare function buildDeclineJobTx(jobId: string): Transaction;
1454
1459
  /** Seller posts the delivery commitment (hex hash) before the deadline. */
1455
1460
  declare function buildDeliverJobTx(jobId: string, deliveryHash: string): Transaction;
1456
1461
  /** Buyer accepts (or anyone, once the review window lapsed) → funds to seller. */
@@ -1538,4 +1543,4 @@ declare function putJobSpec(base: string, content: string): Promise<string>;
1538
1543
  * the store is untrusted; the chain hash is the authority). */
1539
1544
  declare function getJobSpec(base: string, hash: string): Promise<string>;
1540
1545
 
1541
- 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, selectAndSplitCoin as bA, selectSuiCoin as bB, serializeCetusRoute as bC, simulateTransaction as bD, throwIfSimulationFailed as bE, verifyCetusRouteCoinMatch as bF, 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, deserializeCetusRoute as bo, fetchAllCoins as bp, getCoinMeta as bq, getSuiClient as br, getSuiGrpcClient as bs, isAllowedAsset as bt, isCetusRouteFresh as bu, isInRegistry as bv, normalizeAsset as bw, normalizeCoinType as bx, queryHistory as by, queryTransaction 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 };
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 };
package/dist/index.cjs CHANGED
@@ -3199,14 +3199,155 @@ init_errors();
3199
3199
  init_token_registry();
3200
3200
  init_preflight();
3201
3201
  init_coinSelection();
3202
+
3203
+ // src/wallet/opening.ts
3204
+ init_errors();
3205
+ init_token_registry();
3206
+ init_coinSelection();
3207
+ var A2A_ESCROW_OPENING_PACKAGE_ID = process.env.A2A_ESCROW_OPENING_PACKAGE_ID ?? "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
3208
+ var A2A_ESCROW_PACKAGE_V2_ID = "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
3209
+ var A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
3210
+ var CLOCK_ID2 = "0x6";
3211
+ var MODULE = "opening";
3212
+ var SHA256_HEX_RE = /^(0x)?[0-9a-fA-F]{64}$/;
3213
+ var OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
3214
+ var MAX_OPEN_WINDOW_MS = 2592e6;
3215
+ function feeConfigArg(tx) {
3216
+ return tx.sharedObjectRef({
3217
+ objectId: A2A_ESCROW_FEE_CONFIG_ID,
3218
+ initialSharedVersion: A2A_ESCROW_FEE_CONFIG_VERSION,
3219
+ mutable: false
3220
+ });
3221
+ }
3222
+ function hexToBytes2(hex) {
3223
+ const clean = hex.replace(/^0x/, "");
3224
+ const bytes = [];
3225
+ for (let i = 0; i < clean.length; i += 2) {
3226
+ bytes.push(Number.parseInt(clean.slice(i, i + 2), 16));
3227
+ }
3228
+ return bytes;
3229
+ }
3230
+ function preflightCreateOpening(terms) {
3231
+ if (!Number.isFinite(terms.amountUsdc) || terms.amountUsdc <= 0) {
3232
+ return { valid: false, code: "INVALID_AMOUNT", error: "Budget must be positive." };
3233
+ }
3234
+ if (terms.amountUsdc > MAX_JOB_USDC) {
3235
+ return {
3236
+ valid: false,
3237
+ code: "INVALID_AMOUNT",
3238
+ error: `Open jobs cap at ${MAX_JOB_USDC} USDC (v1).`
3239
+ };
3240
+ }
3241
+ if (!SHA256_HEX_RE.test(terms.specHash)) {
3242
+ return { valid: false, code: "INVALID_INPUT", error: "specHash must be a sha256 hex string." };
3243
+ }
3244
+ const now = Date.now();
3245
+ if (terms.openUntilMs <= now) {
3246
+ return { valid: false, code: "INVALID_INPUT", error: "openUntil must be in the future." };
3247
+ }
3248
+ if (terms.openUntilMs > now + MAX_OPEN_WINDOW_MS) {
3249
+ return { valid: false, code: "INVALID_INPUT", error: "Openings can stay claimable at most 30 days." };
3250
+ }
3251
+ if (terms.slaMs <= 0) {
3252
+ return { valid: false, code: "INVALID_INPUT", error: "Delivery window must be positive." };
3253
+ }
3254
+ return { valid: true };
3255
+ }
3256
+ async function buildCreateOpeningTx({
3257
+ client,
3258
+ buyer,
3259
+ terms
3260
+ }) {
3261
+ const pf = preflightCreateOpening(terms);
3262
+ if (!pf.valid) throw new exports.T2000Error(pf.code ?? "INVALID_INPUT", pf.error ?? "Invalid opening.");
3263
+ const rawAmount = BigInt(Math.floor(terms.amountUsdc * 10 ** USDC_DECIMALS));
3264
+ const tx = new transactions.Transaction();
3265
+ const { coin } = await selectAndSplitCoin(tx, client, validateAddress(buyer), exports.USDC_TYPE, rawAmount, {
3266
+ allowSwapAll: false
3267
+ });
3268
+ tx.moveCall({
3269
+ target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::create_open`,
3270
+ typeArguments: [exports.USDC_TYPE],
3271
+ arguments: [
3272
+ coin,
3273
+ tx.pure.vector("u8", hexToBytes2(terms.specHash)),
3274
+ tx.pure.u64(terms.openUntilMs),
3275
+ tx.pure.u64(terms.slaMs),
3276
+ tx.pure.u64(terms.reviewWindowMs),
3277
+ tx.pure.u64(terms.rejectSplitBps),
3278
+ tx.pure.u8(OPENING_CLAIM_POLICY_ANY_ACTIVE),
3279
+ feeConfigArg(tx),
3280
+ tx.object(CLOCK_ID2)
3281
+ ]
3282
+ });
3283
+ return tx;
3284
+ }
3285
+ function buildClaimOpeningTx({
3286
+ openingId,
3287
+ registryId
3288
+ }) {
3289
+ const tx = new transactions.Transaction();
3290
+ tx.moveCall({
3291
+ target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::claim`,
3292
+ typeArguments: [exports.USDC_TYPE],
3293
+ arguments: [
3294
+ tx.object(openingId),
3295
+ tx.object(registryId),
3296
+ feeConfigArg(tx),
3297
+ tx.object(CLOCK_ID2)
3298
+ ]
3299
+ });
3300
+ return tx;
3301
+ }
3302
+ function openingCall(openingId, fn) {
3303
+ const tx = new transactions.Transaction();
3304
+ tx.moveCall({
3305
+ target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::${fn}`,
3306
+ typeArguments: [exports.USDC_TYPE],
3307
+ arguments: [tx.object(openingId), feeConfigArg(tx), tx.object(CLOCK_ID2)]
3308
+ });
3309
+ return tx;
3310
+ }
3311
+ function buildCancelOpeningTx(openingId) {
3312
+ return openingCall(openingId, "cancel_open");
3313
+ }
3314
+ function buildRefundUnclaimedTx(openingId) {
3315
+ return openingCall(openingId, "refund_unclaimed");
3316
+ }
3317
+ function bytesToHex2(bytes) {
3318
+ return `0x${Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
3319
+ }
3320
+ async function getOpening(client, openingId) {
3321
+ const resp = await client.core.getObject({ objectId: openingId, include: { json: true } }).catch(() => null);
3322
+ const objType = resp?.object?.type ?? "";
3323
+ const json = resp?.object?.json;
3324
+ if (!json || !objType.includes(`::${MODULE}::Opening<`)) {
3325
+ return null;
3326
+ }
3327
+ return {
3328
+ id: openingId,
3329
+ buyer: String(json.buyer),
3330
+ amountUsdc: Number(json.amount) / 10 ** USDC_DECIMALS,
3331
+ feeBps: Number(json.fee_bps ?? 0),
3332
+ specHash: bytesToHex2(json.spec_hash ?? []),
3333
+ openUntilMs: Number(json.open_until_ms),
3334
+ slaMs: Number(json.sla_ms),
3335
+ reviewWindowMs: Number(json.review_window_ms),
3336
+ rejectSplitBps: Number(json.reject_split_bps),
3337
+ claimPolicy: Number(json.claim_policy ?? 0),
3338
+ createdAtMs: Number(json.created_at_ms ?? 0)
3339
+ };
3340
+ }
3341
+
3342
+ // src/wallet/job.ts
3202
3343
  var A2A_ESCROW_PACKAGE_ID = process.env.A2A_ESCROW_PACKAGE_ID ?? "0x358a819c1c016e2cc84ef5fbea81cba90c31f7f8a62bf45cb5e5276acf198bdd";
3203
3344
  var A2A_ESCROW_FEE_CONFIG_ID = process.env.A2A_ESCROW_FEE_CONFIG_ID ?? "0xddaa25570950b7484dbf20797ebcf75707be9c87cd67bef2a06ed2e81d2c494b";
3204
3345
  var A2A_ESCROW_FEE_CONFIG_VERSION = Number(
3205
3346
  process.env.A2A_ESCROW_FEE_CONFIG_VERSION ?? 931861903
3206
3347
  );
3207
- var CLOCK_ID2 = "0x6";
3208
- var MODULE = "escrow";
3209
- function feeConfigArg(tx) {
3348
+ var CLOCK_ID3 = "0x6";
3349
+ var MODULE2 = "escrow";
3350
+ function feeConfigArg2(tx) {
3210
3351
  return tx.sharedObjectRef({
3211
3352
  objectId: A2A_ESCROW_FEE_CONFIG_ID,
3212
3353
  initialSharedVersion: A2A_ESCROW_FEE_CONFIG_VERSION,
@@ -3223,7 +3364,7 @@ var JOB_STATES = [
3223
3364
  "refunded",
3224
3365
  "rejected"
3225
3366
  ];
3226
- function hexToBytes2(hex) {
3367
+ function hexToBytes3(hex) {
3227
3368
  const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
3228
3369
  if (clean.length === 0 || clean.length % 2 !== 0 || /[^0-9a-fA-F]/.test(clean)) {
3229
3370
  throw new exports.T2000Error(
@@ -3237,7 +3378,7 @@ function hexToBytes2(hex) {
3237
3378
  }
3238
3379
  return out;
3239
3380
  }
3240
- function bytesToHex2(bytes) {
3381
+ function bytesToHex3(bytes) {
3241
3382
  const arr = typeof bytes === "string" ? Array.from(atob(bytes), (c) => c.charCodeAt(0)) : bytes;
3242
3383
  let s = "0x";
3243
3384
  for (const b of arr) s += b.toString(16).padStart(2, "0");
@@ -3268,7 +3409,7 @@ function preflightCreateJob(terms) {
3268
3409
  return preflightFail("INVALID_AMOUNT", "rejectSplitBps must be an integer 0\u201310000.");
3269
3410
  }
3270
3411
  try {
3271
- hexToBytes2(terms.specHash);
3412
+ hexToBytes3(terms.specHash);
3272
3413
  } catch (e) {
3273
3414
  return preflightFail("INVALID_AMOUNT", e.message);
3274
3415
  }
@@ -3291,40 +3432,49 @@ async function buildCreateJobTx({
3291
3432
  allowSwapAll: false
3292
3433
  });
3293
3434
  tx.moveCall({
3294
- target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::create`,
3435
+ target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE2}::create`,
3295
3436
  typeArguments: [exports.USDC_TYPE],
3296
3437
  arguments: [
3297
3438
  tx.pure.address(seller),
3298
3439
  coin,
3299
- tx.pure.vector("u8", hexToBytes2(terms.specHash)),
3440
+ tx.pure.vector("u8", hexToBytes3(terms.specHash)),
3300
3441
  tx.pure.u64(terms.deliverByMs),
3301
3442
  tx.pure.u64(terms.reviewWindowMs),
3302
3443
  tx.pure.u64(terms.rejectSplitBps),
3303
- feeConfigArg(tx),
3304
- tx.object(CLOCK_ID2)
3444
+ feeConfigArg2(tx),
3445
+ tx.object(CLOCK_ID3)
3305
3446
  ]
3306
3447
  });
3307
3448
  return tx;
3308
3449
  }
3450
+ function buildDeclineJobTx(jobId) {
3451
+ const tx = new transactions.Transaction();
3452
+ tx.moveCall({
3453
+ target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE2}::decline`,
3454
+ typeArguments: [exports.USDC_TYPE],
3455
+ arguments: [tx.object(jobId), feeConfigArg2(tx), tx.object(CLOCK_ID3)]
3456
+ });
3457
+ return tx;
3458
+ }
3309
3459
  function jobCall(jobId, fn) {
3310
3460
  const tx = new transactions.Transaction();
3311
3461
  tx.moveCall({
3312
- target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::${fn}`,
3462
+ target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE2}::${fn}`,
3313
3463
  typeArguments: [exports.USDC_TYPE],
3314
- arguments: [tx.object(jobId), feeConfigArg(tx), tx.object(CLOCK_ID2)]
3464
+ arguments: [tx.object(jobId), feeConfigArg2(tx), tx.object(CLOCK_ID3)]
3315
3465
  });
3316
3466
  return tx;
3317
3467
  }
3318
3468
  function buildDeliverJobTx(jobId, deliveryHash) {
3319
3469
  const tx = new transactions.Transaction();
3320
3470
  tx.moveCall({
3321
- target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::deliver`,
3471
+ target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE2}::deliver`,
3322
3472
  typeArguments: [exports.USDC_TYPE],
3323
3473
  arguments: [
3324
3474
  tx.object(jobId),
3325
- tx.pure.vector("u8", hexToBytes2(deliveryHash)),
3326
- feeConfigArg(tx),
3327
- tx.object(CLOCK_ID2)
3475
+ tx.pure.vector("u8", hexToBytes3(deliveryHash)),
3476
+ feeConfigArg2(tx),
3477
+ tx.object(CLOCK_ID3)
3328
3478
  ]
3329
3479
  });
3330
3480
  return tx;
@@ -3347,7 +3497,7 @@ async function getJob(client, jobId) {
3347
3497
  });
3348
3498
  const objType = resp.object?.type ?? "";
3349
3499
  const json = resp.object?.json;
3350
- if (!json || !objType.includes(`::${MODULE}::Job<`)) {
3500
+ if (!json || !objType.includes(`::${MODULE2}::Job<`)) {
3351
3501
  throw new exports.T2000Error("RPC_ERROR", `Object ${jobId} is not an a2a_escrow Job.`);
3352
3502
  }
3353
3503
  const stateNum = Number(json.state ?? -1);
@@ -3365,12 +3515,12 @@ async function getJob(client, jobId) {
3365
3515
  amountUsdc: Number(json.amount) / 10 ** USDC_DECIMALS,
3366
3516
  escrowUsdc: Number(json.escrow) / 10 ** USDC_DECIMALS,
3367
3517
  feeBps: Number(json.fee_bps ?? 0),
3368
- specHash: bytesToHex2(json.spec_hash ?? []),
3518
+ specHash: bytesToHex3(json.spec_hash ?? []),
3369
3519
  deliverByMs: Number(json.deliver_by_ms),
3370
3520
  reviewWindowMs: Number(json.review_window_ms),
3371
3521
  rejectSplitBps: Number(json.reject_split_bps),
3372
3522
  state,
3373
- deliveryHash: hasDelivery ? bytesToHex2(deliveryBytes) : null,
3523
+ deliveryHash: hasDelivery ? bytesToHex3(deliveryBytes) : null,
3374
3524
  deliveredAtMs: hasDelivery ? deliveredAtMs : null,
3375
3525
  createdAtMs: Number(json.created_at_ms)
3376
3526
  };
@@ -3415,143 +3565,6 @@ async function verifyJobForSeller({
3415
3565
  return { ok: problems.length === 0, job, problems };
3416
3566
  }
3417
3567
 
3418
- // src/wallet/opening.ts
3419
- init_errors();
3420
- init_token_registry();
3421
- init_coinSelection();
3422
- var A2A_ESCROW_OPENING_PACKAGE_ID = process.env.A2A_ESCROW_OPENING_PACKAGE_ID ?? "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
3423
- var CLOCK_ID3 = "0x6";
3424
- var MODULE2 = "opening";
3425
- var SHA256_HEX_RE = /^(0x)?[0-9a-fA-F]{64}$/;
3426
- var OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
3427
- var MAX_OPEN_WINDOW_MS = 2592e6;
3428
- function feeConfigArg2(tx) {
3429
- return tx.sharedObjectRef({
3430
- objectId: A2A_ESCROW_FEE_CONFIG_ID,
3431
- initialSharedVersion: A2A_ESCROW_FEE_CONFIG_VERSION,
3432
- mutable: false
3433
- });
3434
- }
3435
- function hexToBytes3(hex) {
3436
- const clean = hex.replace(/^0x/, "");
3437
- const bytes = [];
3438
- for (let i = 0; i < clean.length; i += 2) {
3439
- bytes.push(Number.parseInt(clean.slice(i, i + 2), 16));
3440
- }
3441
- return bytes;
3442
- }
3443
- function preflightCreateOpening(terms) {
3444
- if (!Number.isFinite(terms.amountUsdc) || terms.amountUsdc <= 0) {
3445
- return { valid: false, code: "INVALID_AMOUNT", error: "Budget must be positive." };
3446
- }
3447
- if (terms.amountUsdc > MAX_JOB_USDC) {
3448
- return {
3449
- valid: false,
3450
- code: "INVALID_AMOUNT",
3451
- error: `Open jobs cap at ${MAX_JOB_USDC} USDC (v1).`
3452
- };
3453
- }
3454
- if (!SHA256_HEX_RE.test(terms.specHash)) {
3455
- return { valid: false, code: "INVALID_INPUT", error: "specHash must be a sha256 hex string." };
3456
- }
3457
- const now = Date.now();
3458
- if (terms.openUntilMs <= now) {
3459
- return { valid: false, code: "INVALID_INPUT", error: "openUntil must be in the future." };
3460
- }
3461
- if (terms.openUntilMs > now + MAX_OPEN_WINDOW_MS) {
3462
- return { valid: false, code: "INVALID_INPUT", error: "Openings can stay claimable at most 30 days." };
3463
- }
3464
- if (terms.slaMs <= 0) {
3465
- return { valid: false, code: "INVALID_INPUT", error: "Delivery window must be positive." };
3466
- }
3467
- return { valid: true };
3468
- }
3469
- async function buildCreateOpeningTx({
3470
- client,
3471
- buyer,
3472
- terms
3473
- }) {
3474
- const pf = preflightCreateOpening(terms);
3475
- if (!pf.valid) throw new exports.T2000Error(pf.code ?? "INVALID_INPUT", pf.error ?? "Invalid opening.");
3476
- const rawAmount = BigInt(Math.floor(terms.amountUsdc * 10 ** USDC_DECIMALS));
3477
- const tx = new transactions.Transaction();
3478
- const { coin } = await selectAndSplitCoin(tx, client, validateAddress(buyer), exports.USDC_TYPE, rawAmount, {
3479
- allowSwapAll: false
3480
- });
3481
- tx.moveCall({
3482
- target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE2}::create_open`,
3483
- typeArguments: [exports.USDC_TYPE],
3484
- arguments: [
3485
- coin,
3486
- tx.pure.vector("u8", hexToBytes3(terms.specHash)),
3487
- tx.pure.u64(terms.openUntilMs),
3488
- tx.pure.u64(terms.slaMs),
3489
- tx.pure.u64(terms.reviewWindowMs),
3490
- tx.pure.u64(terms.rejectSplitBps),
3491
- tx.pure.u8(OPENING_CLAIM_POLICY_ANY_ACTIVE),
3492
- feeConfigArg2(tx),
3493
- tx.object(CLOCK_ID3)
3494
- ]
3495
- });
3496
- return tx;
3497
- }
3498
- function buildClaimOpeningTx({
3499
- openingId,
3500
- registryId
3501
- }) {
3502
- const tx = new transactions.Transaction();
3503
- tx.moveCall({
3504
- target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE2}::claim`,
3505
- typeArguments: [exports.USDC_TYPE],
3506
- arguments: [
3507
- tx.object(openingId),
3508
- tx.object(registryId),
3509
- feeConfigArg2(tx),
3510
- tx.object(CLOCK_ID3)
3511
- ]
3512
- });
3513
- return tx;
3514
- }
3515
- function openingCall(openingId, fn) {
3516
- const tx = new transactions.Transaction();
3517
- tx.moveCall({
3518
- target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE2}::${fn}`,
3519
- typeArguments: [exports.USDC_TYPE],
3520
- arguments: [tx.object(openingId), feeConfigArg2(tx), tx.object(CLOCK_ID3)]
3521
- });
3522
- return tx;
3523
- }
3524
- function buildCancelOpeningTx(openingId) {
3525
- return openingCall(openingId, "cancel_open");
3526
- }
3527
- function buildRefundUnclaimedTx(openingId) {
3528
- return openingCall(openingId, "refund_unclaimed");
3529
- }
3530
- function bytesToHex3(bytes) {
3531
- return `0x${Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
3532
- }
3533
- async function getOpening(client, openingId) {
3534
- const resp = await client.core.getObject({ objectId: openingId, include: { json: true } }).catch(() => null);
3535
- const objType = resp?.object?.type ?? "";
3536
- const json = resp?.object?.json;
3537
- if (!json || !objType.includes(`::${MODULE2}::Opening<`)) {
3538
- return null;
3539
- }
3540
- return {
3541
- id: openingId,
3542
- buyer: String(json.buyer),
3543
- amountUsdc: Number(json.amount) / 10 ** USDC_DECIMALS,
3544
- feeBps: Number(json.fee_bps ?? 0),
3545
- specHash: bytesToHex3(json.spec_hash ?? []),
3546
- openUntilMs: Number(json.open_until_ms),
3547
- slaMs: Number(json.sla_ms),
3548
- reviewWindowMs: Number(json.review_window_ms),
3549
- rejectSplitBps: Number(json.reject_split_bps),
3550
- claimPolicy: Number(json.claim_policy ?? 0),
3551
- createdAtMs: Number(json.created_at_ms ?? 0)
3552
- };
3553
- }
3554
-
3555
3568
  // src/commerce.ts
3556
3569
  var DEFAULT_COMMERCE_API_BASE = "https://api.t2000.ai/v1";
3557
3570
  async function commerceFetchJson(url, init) {
@@ -4561,6 +4574,8 @@ async function buildDirectPoolSwapTx(args) {
4561
4574
  exports.A2A_ESCROW_FEE_CONFIG_ID = A2A_ESCROW_FEE_CONFIG_ID;
4562
4575
  exports.A2A_ESCROW_OPENING_PACKAGE_ID = A2A_ESCROW_OPENING_PACKAGE_ID;
4563
4576
  exports.A2A_ESCROW_PACKAGE_ID = A2A_ESCROW_PACKAGE_ID;
4577
+ exports.A2A_ESCROW_PACKAGE_V2_ID = A2A_ESCROW_PACKAGE_V2_ID;
4578
+ exports.A2A_ESCROW_PACKAGE_V3_ID = A2A_ESCROW_PACKAGE_V3_ID;
4564
4579
  exports.AGENT_CAPITAL_PACKAGE_ID = AGENT_CAPITAL_PACKAGE_ID;
4565
4580
  exports.AGENT_CAPITAL_PUBLISHED_AT = AGENT_CAPITAL_PUBLISHED_AT;
4566
4581
  exports.AGENT_ID_PARENT = AGENT_ID_PARENT;
@@ -4633,6 +4648,7 @@ exports.buildCancelOpeningTx = buildCancelOpeningTx;
4633
4648
  exports.buildClaimOpeningTx = buildClaimOpeningTx;
4634
4649
  exports.buildCreateJobTx = buildCreateJobTx;
4635
4650
  exports.buildCreateOpeningTx = buildCreateOpeningTx;
4651
+ exports.buildDeclineJobTx = buildDeclineJobTx;
4636
4652
  exports.buildDeliverJobTx = buildDeliverJobTx;
4637
4653
  exports.buildDirectPoolSwapTx = buildDirectPoolSwapTx;
4638
4654
  exports.buildPublishAgentCoinTx = buildPublishAgentCoinTx;