@t2000/sdk 10.32.2 → 10.33.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/browser.cjs +94 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +83 -3
- package/dist/{commerce-CiewZ7vq.d.cts → commerce-CptpOlnv.d.cts} +207 -1
- package/dist/{commerce-CiewZ7vq.d.ts → commerce-CptpOlnv.d.ts} +207 -1
- package/dist/index.cjs +170 -5
- package/dist/index.d.cts +23 -112
- package/dist/index.d.ts +23 -112
- package/dist/index.js +154 -7
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 {
|
|
5
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig,
|
|
6
|
-
import {
|
|
4
|
+
import { a8 as T2000Error, bm as T2000Options, af as TransactionSigner, S as PayOptions, bn as X402Probe, T as PayResult, bo as SerializedCetusRoute, bp as SwapResult, bq as SwapQuoteResult, a0 as SendResult, B as BalanceResponse, ae as TransactionRecord, j as DepositInfo, br as PaymentRequest, ap as ZkLoginProof, bs as SuiCoreClient, F as OverlayFeeConfig, bt as SponsoredCoinMergeCache, a6 as SupportedAsset, a7 as SwapRouteResult, bu as SendableAsset } from './commerce-CptpOlnv.cjs';
|
|
5
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, bv as A2A_ESCROW_LATEST_PACKAGE_ID, bw as A2A_ESCROW_OPENING_PACKAGE_ID, a as A2A_ESCROW_PACKAGE_ID, bx as A2A_ESCROW_PACKAGE_V2_ID, by as A2A_ESCROW_PACKAGE_V3_ID, bz as A2A_ESCROW_PACKAGE_V6_ID, bA as A2A_SCORE_BOARD_ID, b as ActivityReportConfig, c as AgentScore, bB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, bC as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, bD as DEFAULT_GRPC_URL, i as DEFAULT_NETWORK, E as ETH_TYPE, k 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, l as Job, m as JobState, n as JobTerms, o as JobVerification, K as KNOWN_TARGETS, p as KeypairSigner, L as LABEL_PATTERNS, q as LOFI_TYPE, bG as MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID, bH as MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, bI as MAINNET_A2A_ESCROW_PACKAGE_ID, bJ as MAINNET_A2A_SCORE_BOARD_ID, M as MANIFEST_TYPE, r as MAX_DELIVER_HORIZON_MS, s as MAX_JOB_USDC, bK as MAX_OPEN_WINDOW_MS, t as MAX_REVIEW_WINDOW_MS, u as MIN_JOB_USDC, v as MIST_PER_SUI, N as NAVX_TYPE, O as OPENING_CLAIM_POLICIES, w as OPENING_CLAIM_POLICY_ANY_ACTIVE, x as OPENING_CLAIM_POLICY_PROVEN, y as OPENING_CLAIM_POLICY_PROVEN_4STAR, bL as OPERATION_ASSETS, z as OVERLAY_FEE_RATE, bM as Opening, bN as OpeningTerms, bO as Operation, P as PREFLIGHT_MAX_AMOUNT, H as PREFLIGHT_OK, Q as PROVEN_MIN_AVG_STARS_X10, R as PROVEN_MIN_REVIEWS, U as PreflightResult, V as REVIEW_MAX_STARS, W as REVIEW_MIN_STARS, bP as SENDABLE_ASSETS, X as STABLE_ASSETS, Y as SUI_DECIMALS, Z as SUI_TYPE, _ as SUPPORTED_ASSETS, bQ as SelectAndSplitResult, $ as SendAssetClass, bR as SerializedCetusRoutePath, bS as SerializedRouterDataV3, a1 as ServiceListing, a2 as SimulationResult, a3 as StableAsset, a4 as SuiHolding, a5 as SuiRpcTxBlock, a9 as T2000ErrorCode, aa as T2000ErrorData, ab as T2000_OVERLAY_FEE_WALLET, ac as TOKEN_MAP, ad as TransactionLeg, ag as TxDirection, ah as USDC_DECIMALS, ai as USDC_TYPE, aj as USDE_TYPE, ak as USDSUI_TYPE, al as USDT_TYPE, am as WAL_TYPE, an as WBTC_TYPE, ao as X402ActivityPayload, aq as ZkLoginSigner, bT as addSendToTx, bU as addSwapToTx, bV as assertAllowedAsset, bW as assertBuyerRequirements, bX as buildCancelOpeningTx, bY as buildClaimOpeningTx, ar as buildCreateJobTx, bZ as buildCreateOpeningTx, b_ as buildDeclineJobTx, as as buildDeliverJobTx, at as buildRefundJobTx, b$ as buildRefundUnclaimedTx, au as buildRejectJobTx, av as buildReleaseJobTx, aw as buildSendTx, c0 as buildSubmitFirstReviewTx, c1 as buildSubmitReviewTx, ax as buildSwapTx, ay as checkPositiveAmount, az as checkSuiAddress, aA as claimPolicyLabel, aB as claimPolicyRequirement, aC as classifyAction, aD as classifyLabel, aE as classifySendAsset, aF as classifyTransaction, aG as deriveAgentScoreId, c2 as deserializeCetusRoute, aH as executeTx, aI as extractAllUserLegs, aJ as extractTransferDetails, aK as extractTxCommands, aL as extractTxSender, aM as fallbackLabel, c3 as fetchAllCoins, aN as fetchService, aO as findSwapRoute, aP as formatAssetAmount, aQ as formatSui, aR as formatUsd, aS as getAgentScore, c4 as getCoinMeta, aT as getDecimals, aU as getDecimalsForCoinType, aV as getJob, aW as getJobSpec, c5 as getOpening, c6 as getSuiClient, c7 as getSuiGrpcClient, aX as invalidSendAssetMessage, c8 as isAllowedAsset, c9 as isCetusRouteFresh, ca as isInRegistry, aY as jobActionsFor, aZ as listServices, a_ as mapMoveAbortCode, a$ as mapWalletError, b0 as meetsClaimPolicy, b1 as mistToSui, cb as normalizeAsset, cc as normalizeCoinType, b2 as parseSuiRpcTx, b3 as payWithX402, b4 as preflightCreateJob, cd as preflightCreateOpening, b5 as preflightFail, b6 as preflightPay, b7 as preflightSend, b8 as preflightSwap, ce as probeX402, b9 as putJobSpec, cf as queryHistory, cg as queryTransaction, ba as rawToStable, bb as rawToUsdc, bc as refineLendingLabel, bd as reportX402Activity, be as resolveSymbol, bf as resolveTokenType, ch as selectAndSplitCoin, ci as selectSuiCoin, cj as serializeCetusRoute, ck as simulateTransaction, bg as stableToRaw, bh as suiToMist, cl as throwIfSimulationFailed, bi as truncateAddress, bj as usdcToRaw, bk as validateAddress, cm as verifyCetusRouteCoinMatch, bl as verifyJobForSeller } from './commerce-CptpOlnv.cjs';
|
|
6
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
|
9
9
|
import '@cetusprotocol/aggregator-sdk';
|
|
@@ -578,114 +578,6 @@ declare function walletExists(keyPath?: string): Promise<boolean>;
|
|
|
578
578
|
declare function exportPrivateKey(keypair: Ed25519Keypair): string;
|
|
579
579
|
declare function getAddress(keypair: Ed25519Keypair): string;
|
|
580
580
|
|
|
581
|
-
/**
|
|
582
|
-
* Open door — client for `a2a_escrow::opening` (SPEC_T2_AGENTS_OPEN_ONCHAIN,
|
|
583
|
-
* Phase 3 escrow-at-post). Posting an open job escrows USDC on-chain
|
|
584
|
-
* immediately in a shared `Opening<USDC>`; the first ACTIVE registered ASP
|
|
585
|
-
* to claim mints a normal `escrow::Job` (deliver/settle with the job verbs).
|
|
586
|
-
* No claim by `open_until` → `refund_unclaimed` (permissionless, fee-free);
|
|
587
|
-
* the buyer can `cancel_open` any time while unclaimed.
|
|
588
|
-
*
|
|
589
|
-
* The `opening` module shipped in the v2 package upgrade, so its calls
|
|
590
|
-
* target the LATEST published id — the original id (types, Job verbs) is
|
|
591
|
-
* unchanged.
|
|
592
|
-
*/
|
|
593
|
-
/** The LATEST published `a2a_escrow` package id on MAINNET (v5 upgrade
|
|
594
|
-
* 2026-08-12, S.1019 — create_open requires reject_split 10000; v4 added
|
|
595
|
-
* amount bounds (S.981); v3 added `escrow::decline`; v2 the `opening`
|
|
596
|
-
* module).
|
|
597
|
-
* A literal, never an env read, so it can serve as a signature-time trust
|
|
598
|
-
* anchor (S.930). Must match the Move upgrade publish notes.
|
|
599
|
-
*
|
|
600
|
-
* S.981: EVERY version-gated verb (escrow create/deliver/release/reject/
|
|
601
|
-
* refund + decline + all opening verbs) targets this id, so a package
|
|
602
|
-
* upgrade + `migrate` cutover is a ONE-VALUE change here. The original id
|
|
603
|
-
* (`MAINNET_A2A_ESCROW_PACKAGE_ID` in job.ts) remains the anchor for type
|
|
604
|
-
* strings, event filters, and object-type queries — those never move. */
|
|
605
|
-
declare const MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0xc84fc8a6d7e8766e36abb16acf5f0c0d15444797137274bbbe027ac7972c56a7";
|
|
606
|
-
/** Back-compat name for the latest id (pre-S.981 consumers import this). */
|
|
607
|
-
declare const MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = "0xc84fc8a6d7e8766e36abb16acf5f0c0d15444797137274bbbe027ac7972c56a7";
|
|
608
|
-
/** Env-overridable latest id for testnet/dev (NOT a trust anchor). A fresh
|
|
609
|
-
* dev publish has original == latest, so `A2A_ESCROW_PACKAGE_ID` alone is
|
|
610
|
-
* honored as the fallback override. */
|
|
611
|
-
declare const A2A_ESCROW_LATEST_PACKAGE_ID: string;
|
|
612
|
-
/** Back-compat name (pre-S.981). */
|
|
613
|
-
declare const A2A_ESCROW_OPENING_PACKAGE_ID: string;
|
|
614
|
-
/**
|
|
615
|
-
* PINNED per-upgrade package ids — event-filter anchors, NEVER bump these.
|
|
616
|
-
*
|
|
617
|
-
* A Sui event's type carries the package id that FIRST DEFINED the struct,
|
|
618
|
-
* not the id of the version that executed. Indexers filtering
|
|
619
|
-
* `<pkg>::module` must therefore pin the DEFINING id per event family:
|
|
620
|
-
* v1 (A2A_ESCROW_PACKAGE_ID) — JobCreated/Delivered/Released/Rejected/Refunded
|
|
621
|
-
* v2 (…_V2_ID) — OpeningCreated/Claimed/Cancelled/Refunded
|
|
622
|
-
* v3 (…_V3_ID) — JobDeclined
|
|
623
|
-
* Filtering the floating LATEST id matches nothing once the next upgrade
|
|
624
|
-
* lands (live finding, 2026-07-28: the openings indexer went dark when
|
|
625
|
-
* A2A_ESCROW_OPENING_PACKAGE_ID moved v2 → v3).
|
|
626
|
-
*/
|
|
627
|
-
declare const A2A_ESCROW_PACKAGE_V2_ID = "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
|
|
628
|
-
declare const A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
|
|
629
|
-
/** v1 claim policy: any ACTIVE registered Agent ID. */
|
|
630
|
-
declare const OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
|
|
631
|
-
/** Max time an opening may stay claimable (contract cap): 30 days. */
|
|
632
|
-
declare const MAX_OPEN_WINDOW_MS = 2592000000;
|
|
633
|
-
interface OpeningTerms {
|
|
634
|
-
/** Budget in USDC — escrows NOW, at post. */
|
|
635
|
-
amountUsdc: number;
|
|
636
|
-
/** sha256 of the public spec envelope (t2-acp-custom@1: title + brief). */
|
|
637
|
-
specHash: string;
|
|
638
|
-
/** Epoch-ms the opening stays claimable until (≤ 30d out). */
|
|
639
|
-
openUntilMs: number;
|
|
640
|
-
/** Delivery window the claiming ASP gets: deliver_by = claim + sla. */
|
|
641
|
-
slaMs: number;
|
|
642
|
-
reviewWindowMs: number;
|
|
643
|
-
/** v5 (S.1019): MUST be 10000 — open-board reject pays the buyer in
|
|
644
|
-
* full (contract-asserted; a partial split made junk delivery +EV over
|
|
645
|
-
* an honest decline). Hire/`escrow::create` keeps the 0–10000 range. */
|
|
646
|
-
rejectSplitBps: number;
|
|
647
|
-
}
|
|
648
|
-
/** Client-side preflight — mirrors the contract's `create_open` bounds plus
|
|
649
|
-
* the $50 client cap (the contract is value-neutral, same as Job). */
|
|
650
|
-
declare function preflightCreateOpening(terms: OpeningTerms): {
|
|
651
|
-
valid: boolean;
|
|
652
|
-
code?: 'INVALID_AMOUNT' | 'INVALID_INPUT';
|
|
653
|
-
error?: string;
|
|
654
|
-
};
|
|
655
|
-
/** Build the escrow-at-post tx: split USDC → `opening::create_open`. */
|
|
656
|
-
declare function buildCreateOpeningTx({ client, buyer, terms, }: {
|
|
657
|
-
client: SuiCoreClient;
|
|
658
|
-
buyer: string;
|
|
659
|
-
terms: OpeningTerms;
|
|
660
|
-
}): Promise<Transaction>;
|
|
661
|
-
/** Claim an opening (ASP side) — consumes it and mints the funded Job.
|
|
662
|
-
* `registryId` = the shared `agent_id::registry::Registry` object
|
|
663
|
-
* (callers pass `AGENT_ID_REGISTRY_ID` from `@t2000/id` — single source). */
|
|
664
|
-
declare function buildClaimOpeningTx({ openingId, registryId, }: {
|
|
665
|
-
openingId: string;
|
|
666
|
-
registryId: string;
|
|
667
|
-
}): Transaction;
|
|
668
|
-
/** Buyer withdraws an unclaimed opening — fee-free, any time. */
|
|
669
|
-
declare function buildCancelOpeningTx(openingId: string): Transaction;
|
|
670
|
-
/** Permissionless refund crank for an opening past `open_until`. */
|
|
671
|
-
declare function buildRefundUnclaimedTx(openingId: string): Transaction;
|
|
672
|
-
/** On-chain view of one Opening. */
|
|
673
|
-
interface Opening {
|
|
674
|
-
id: string;
|
|
675
|
-
buyer: string;
|
|
676
|
-
amountUsdc: number;
|
|
677
|
-
feeBps: number;
|
|
678
|
-
specHash: string;
|
|
679
|
-
openUntilMs: number;
|
|
680
|
-
slaMs: number;
|
|
681
|
-
reviewWindowMs: number;
|
|
682
|
-
rejectSplitBps: number;
|
|
683
|
-
claimPolicy: number;
|
|
684
|
-
createdAtMs: number;
|
|
685
|
-
}
|
|
686
|
-
/** Read one Opening by object id (null = gone: claimed/cancelled/refunded). */
|
|
687
|
-
declare function getOpening(client: SuiCoreClient, openingId: string): Promise<Opening | null>;
|
|
688
|
-
|
|
689
581
|
/** Title rules: an explicit title wins; otherwise the brief's first
|
|
690
582
|
* non-empty line (a leading "Title: …" prefix is stripped for the title
|
|
691
583
|
* field — the FULL text always stays in the brief, lossless), hard-capped
|
|
@@ -735,6 +627,10 @@ interface OpenJobRow {
|
|
|
735
627
|
} | null;
|
|
736
628
|
/** The escrow Job this opening was claimed into (claimed rows). */
|
|
737
629
|
jobId: string | null;
|
|
630
|
+
/** S.1054 — who may race to claim: 0 Anyone, 1 Proven, 2 Proven · 4★+
|
|
631
|
+
* (render with `claimPolicyLabel`, never the raw number). Absent on
|
|
632
|
+
* pre-S.1054 rows = 0. */
|
|
633
|
+
claimPolicy?: number;
|
|
738
634
|
createdAtMs: number;
|
|
739
635
|
updatedAtMs: number;
|
|
740
636
|
}
|
|
@@ -761,6 +657,21 @@ declare function postOpenJob(base: string, signer: TransactionSigner, input: {
|
|
|
761
657
|
slaMinutes?: number;
|
|
762
658
|
/** How long the posting stays claimable (default 24h, max 720). */
|
|
763
659
|
openHours?: number;
|
|
660
|
+
/** S.1054 — 0 Anyone (default), 1 Proven, 2 Proven · 4★+. */
|
|
661
|
+
claimPolicy?: number;
|
|
662
|
+
}): Promise<string>;
|
|
663
|
+
/** Review a RELEASED job you bought — writes the STARS ON-CHAIN (S.1054:
|
|
664
|
+
* the one public score SSOT; `a2a_escrow::reputation`). Same sponsored
|
|
665
|
+
* rail as every job verb; the server resolves whether this is the
|
|
666
|
+
* seller's first review (lazy score create) or an update/edit. Rare race
|
|
667
|
+
* (brand-new seller, two simultaneous first reviews): the loser aborts
|
|
668
|
+
* on-chain — just call this again; the retry re-reads the score and
|
|
669
|
+
* lands as a normal review. Optional `text` is stored off-chain by the
|
|
670
|
+
* API, keyed by jobId — text is not the score. Returns the tx digest. */
|
|
671
|
+
declare function submitJobReview(base: string, signer: TransactionSigner, input: {
|
|
672
|
+
jobId: string;
|
|
673
|
+
/** Integer 1-5. Re-submitting edits your stars in place. */
|
|
674
|
+
stars: number;
|
|
764
675
|
}): Promise<string>;
|
|
765
676
|
/** Claim an open job (ASP side) — first claim wins ON-CHAIN and mints the
|
|
766
677
|
* funded Job immediately; work starts now. Requires an active registered
|
|
@@ -1311,4 +1222,4 @@ declare function fullHandle(label: string, parentName?: string): string;
|
|
|
1311
1222
|
*/
|
|
1312
1223
|
declare function displayHandle(label: string, parentName?: string): string;
|
|
1313
1224
|
|
|
1314
|
-
export {
|
|
1225
|
+
export { AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, type CheckStatus, type ComposeTxOptions, type ComposeTxResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, ESCROW_JOB_TYPE_MARKER, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OPENING_TYPE_MARKER, type OpenJobFilter, type OpenJobRow, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, SerializedCetusRoute, type SponsoredTxGuard, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, type TrustMode, type UpstreamClaim, type VerifyAnchor, type VerifyCheck, type VerifyOptions, type VerifyResult, type VerifyUpstream, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, X402Probe, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, claimOpenJob, clearLimits, composeTx, customHireEnvelope, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getOpenJob, getSponsoredSwapProviders, getSwapQuote, hasLimits, isCustomHireEnvelope, keypairFromPrivateKey, listModels, listOpenJobs, loadKey, looksLikeSuiNs, normalizeAddressInput, postOpenJob, queryBalance, readLimitsFile, recordDailySpend, refundOpenJob, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, setSponsoredTxGuard, submitJobReview, validateLabel, verifyReceipt, walletExists, writeLimitsFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 {
|
|
5
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig,
|
|
6
|
-
import {
|
|
4
|
+
import { a8 as T2000Error, bm as T2000Options, af as TransactionSigner, S as PayOptions, bn as X402Probe, T as PayResult, bo as SerializedCetusRoute, bp as SwapResult, bq as SwapQuoteResult, a0 as SendResult, B as BalanceResponse, ae as TransactionRecord, j as DepositInfo, br as PaymentRequest, ap as ZkLoginProof, bs as SuiCoreClient, F as OverlayFeeConfig, bt as SponsoredCoinMergeCache, a6 as SupportedAsset, a7 as SwapRouteResult, bu as SendableAsset } from './commerce-CptpOlnv.js';
|
|
5
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, bv as A2A_ESCROW_LATEST_PACKAGE_ID, bw as A2A_ESCROW_OPENING_PACKAGE_ID, a as A2A_ESCROW_PACKAGE_ID, bx as A2A_ESCROW_PACKAGE_V2_ID, by as A2A_ESCROW_PACKAGE_V3_ID, bz as A2A_ESCROW_PACKAGE_V6_ID, bA as A2A_SCORE_BOARD_ID, b as ActivityReportConfig, c as AgentScore, bB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, bC as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, bD as DEFAULT_GRPC_URL, i as DEFAULT_NETWORK, E as ETH_TYPE, k 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, l as Job, m as JobState, n as JobTerms, o as JobVerification, K as KNOWN_TARGETS, p as KeypairSigner, L as LABEL_PATTERNS, q as LOFI_TYPE, bG as MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID, bH as MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, bI as MAINNET_A2A_ESCROW_PACKAGE_ID, bJ as MAINNET_A2A_SCORE_BOARD_ID, M as MANIFEST_TYPE, r as MAX_DELIVER_HORIZON_MS, s as MAX_JOB_USDC, bK as MAX_OPEN_WINDOW_MS, t as MAX_REVIEW_WINDOW_MS, u as MIN_JOB_USDC, v as MIST_PER_SUI, N as NAVX_TYPE, O as OPENING_CLAIM_POLICIES, w as OPENING_CLAIM_POLICY_ANY_ACTIVE, x as OPENING_CLAIM_POLICY_PROVEN, y as OPENING_CLAIM_POLICY_PROVEN_4STAR, bL as OPERATION_ASSETS, z as OVERLAY_FEE_RATE, bM as Opening, bN as OpeningTerms, bO as Operation, P as PREFLIGHT_MAX_AMOUNT, H as PREFLIGHT_OK, Q as PROVEN_MIN_AVG_STARS_X10, R as PROVEN_MIN_REVIEWS, U as PreflightResult, V as REVIEW_MAX_STARS, W as REVIEW_MIN_STARS, bP as SENDABLE_ASSETS, X as STABLE_ASSETS, Y as SUI_DECIMALS, Z as SUI_TYPE, _ as SUPPORTED_ASSETS, bQ as SelectAndSplitResult, $ as SendAssetClass, bR as SerializedCetusRoutePath, bS as SerializedRouterDataV3, a1 as ServiceListing, a2 as SimulationResult, a3 as StableAsset, a4 as SuiHolding, a5 as SuiRpcTxBlock, a9 as T2000ErrorCode, aa as T2000ErrorData, ab as T2000_OVERLAY_FEE_WALLET, ac as TOKEN_MAP, ad as TransactionLeg, ag as TxDirection, ah as USDC_DECIMALS, ai as USDC_TYPE, aj as USDE_TYPE, ak as USDSUI_TYPE, al as USDT_TYPE, am as WAL_TYPE, an as WBTC_TYPE, ao as X402ActivityPayload, aq as ZkLoginSigner, bT as addSendToTx, bU as addSwapToTx, bV as assertAllowedAsset, bW as assertBuyerRequirements, bX as buildCancelOpeningTx, bY as buildClaimOpeningTx, ar as buildCreateJobTx, bZ as buildCreateOpeningTx, b_ as buildDeclineJobTx, as as buildDeliverJobTx, at as buildRefundJobTx, b$ as buildRefundUnclaimedTx, au as buildRejectJobTx, av as buildReleaseJobTx, aw as buildSendTx, c0 as buildSubmitFirstReviewTx, c1 as buildSubmitReviewTx, ax as buildSwapTx, ay as checkPositiveAmount, az as checkSuiAddress, aA as claimPolicyLabel, aB as claimPolicyRequirement, aC as classifyAction, aD as classifyLabel, aE as classifySendAsset, aF as classifyTransaction, aG as deriveAgentScoreId, c2 as deserializeCetusRoute, aH as executeTx, aI as extractAllUserLegs, aJ as extractTransferDetails, aK as extractTxCommands, aL as extractTxSender, aM as fallbackLabel, c3 as fetchAllCoins, aN as fetchService, aO as findSwapRoute, aP as formatAssetAmount, aQ as formatSui, aR as formatUsd, aS as getAgentScore, c4 as getCoinMeta, aT as getDecimals, aU as getDecimalsForCoinType, aV as getJob, aW as getJobSpec, c5 as getOpening, c6 as getSuiClient, c7 as getSuiGrpcClient, aX as invalidSendAssetMessage, c8 as isAllowedAsset, c9 as isCetusRouteFresh, ca as isInRegistry, aY as jobActionsFor, aZ as listServices, a_ as mapMoveAbortCode, a$ as mapWalletError, b0 as meetsClaimPolicy, b1 as mistToSui, cb as normalizeAsset, cc as normalizeCoinType, b2 as parseSuiRpcTx, b3 as payWithX402, b4 as preflightCreateJob, cd as preflightCreateOpening, b5 as preflightFail, b6 as preflightPay, b7 as preflightSend, b8 as preflightSwap, ce as probeX402, b9 as putJobSpec, cf as queryHistory, cg as queryTransaction, ba as rawToStable, bb as rawToUsdc, bc as refineLendingLabel, bd as reportX402Activity, be as resolveSymbol, bf as resolveTokenType, ch as selectAndSplitCoin, ci as selectSuiCoin, cj as serializeCetusRoute, ck as simulateTransaction, bg as stableToRaw, bh as suiToMist, cl as throwIfSimulationFailed, bi as truncateAddress, bj as usdcToRaw, bk as validateAddress, cm as verifyCetusRouteCoinMatch, bl as verifyJobForSeller } from './commerce-CptpOlnv.js';
|
|
6
|
+
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
|
9
9
|
import '@cetusprotocol/aggregator-sdk';
|
|
@@ -578,114 +578,6 @@ declare function walletExists(keyPath?: string): Promise<boolean>;
|
|
|
578
578
|
declare function exportPrivateKey(keypair: Ed25519Keypair): string;
|
|
579
579
|
declare function getAddress(keypair: Ed25519Keypair): string;
|
|
580
580
|
|
|
581
|
-
/**
|
|
582
|
-
* Open door — client for `a2a_escrow::opening` (SPEC_T2_AGENTS_OPEN_ONCHAIN,
|
|
583
|
-
* Phase 3 escrow-at-post). Posting an open job escrows USDC on-chain
|
|
584
|
-
* immediately in a shared `Opening<USDC>`; the first ACTIVE registered ASP
|
|
585
|
-
* to claim mints a normal `escrow::Job` (deliver/settle with the job verbs).
|
|
586
|
-
* No claim by `open_until` → `refund_unclaimed` (permissionless, fee-free);
|
|
587
|
-
* the buyer can `cancel_open` any time while unclaimed.
|
|
588
|
-
*
|
|
589
|
-
* The `opening` module shipped in the v2 package upgrade, so its calls
|
|
590
|
-
* target the LATEST published id — the original id (types, Job verbs) is
|
|
591
|
-
* unchanged.
|
|
592
|
-
*/
|
|
593
|
-
/** The LATEST published `a2a_escrow` package id on MAINNET (v5 upgrade
|
|
594
|
-
* 2026-08-12, S.1019 — create_open requires reject_split 10000; v4 added
|
|
595
|
-
* amount bounds (S.981); v3 added `escrow::decline`; v2 the `opening`
|
|
596
|
-
* module).
|
|
597
|
-
* A literal, never an env read, so it can serve as a signature-time trust
|
|
598
|
-
* anchor (S.930). Must match the Move upgrade publish notes.
|
|
599
|
-
*
|
|
600
|
-
* S.981: EVERY version-gated verb (escrow create/deliver/release/reject/
|
|
601
|
-
* refund + decline + all opening verbs) targets this id, so a package
|
|
602
|
-
* upgrade + `migrate` cutover is a ONE-VALUE change here. The original id
|
|
603
|
-
* (`MAINNET_A2A_ESCROW_PACKAGE_ID` in job.ts) remains the anchor for type
|
|
604
|
-
* strings, event filters, and object-type queries — those never move. */
|
|
605
|
-
declare const MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0xc84fc8a6d7e8766e36abb16acf5f0c0d15444797137274bbbe027ac7972c56a7";
|
|
606
|
-
/** Back-compat name for the latest id (pre-S.981 consumers import this). */
|
|
607
|
-
declare const MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = "0xc84fc8a6d7e8766e36abb16acf5f0c0d15444797137274bbbe027ac7972c56a7";
|
|
608
|
-
/** Env-overridable latest id for testnet/dev (NOT a trust anchor). A fresh
|
|
609
|
-
* dev publish has original == latest, so `A2A_ESCROW_PACKAGE_ID` alone is
|
|
610
|
-
* honored as the fallback override. */
|
|
611
|
-
declare const A2A_ESCROW_LATEST_PACKAGE_ID: string;
|
|
612
|
-
/** Back-compat name (pre-S.981). */
|
|
613
|
-
declare const A2A_ESCROW_OPENING_PACKAGE_ID: string;
|
|
614
|
-
/**
|
|
615
|
-
* PINNED per-upgrade package ids — event-filter anchors, NEVER bump these.
|
|
616
|
-
*
|
|
617
|
-
* A Sui event's type carries the package id that FIRST DEFINED the struct,
|
|
618
|
-
* not the id of the version that executed. Indexers filtering
|
|
619
|
-
* `<pkg>::module` must therefore pin the DEFINING id per event family:
|
|
620
|
-
* v1 (A2A_ESCROW_PACKAGE_ID) — JobCreated/Delivered/Released/Rejected/Refunded
|
|
621
|
-
* v2 (…_V2_ID) — OpeningCreated/Claimed/Cancelled/Refunded
|
|
622
|
-
* v3 (…_V3_ID) — JobDeclined
|
|
623
|
-
* Filtering the floating LATEST id matches nothing once the next upgrade
|
|
624
|
-
* lands (live finding, 2026-07-28: the openings indexer went dark when
|
|
625
|
-
* A2A_ESCROW_OPENING_PACKAGE_ID moved v2 → v3).
|
|
626
|
-
*/
|
|
627
|
-
declare const A2A_ESCROW_PACKAGE_V2_ID = "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
|
|
628
|
-
declare const A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
|
|
629
|
-
/** v1 claim policy: any ACTIVE registered Agent ID. */
|
|
630
|
-
declare const OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
|
|
631
|
-
/** Max time an opening may stay claimable (contract cap): 30 days. */
|
|
632
|
-
declare const MAX_OPEN_WINDOW_MS = 2592000000;
|
|
633
|
-
interface OpeningTerms {
|
|
634
|
-
/** Budget in USDC — escrows NOW, at post. */
|
|
635
|
-
amountUsdc: number;
|
|
636
|
-
/** sha256 of the public spec envelope (t2-acp-custom@1: title + brief). */
|
|
637
|
-
specHash: string;
|
|
638
|
-
/** Epoch-ms the opening stays claimable until (≤ 30d out). */
|
|
639
|
-
openUntilMs: number;
|
|
640
|
-
/** Delivery window the claiming ASP gets: deliver_by = claim + sla. */
|
|
641
|
-
slaMs: number;
|
|
642
|
-
reviewWindowMs: number;
|
|
643
|
-
/** v5 (S.1019): MUST be 10000 — open-board reject pays the buyer in
|
|
644
|
-
* full (contract-asserted; a partial split made junk delivery +EV over
|
|
645
|
-
* an honest decline). Hire/`escrow::create` keeps the 0–10000 range. */
|
|
646
|
-
rejectSplitBps: number;
|
|
647
|
-
}
|
|
648
|
-
/** Client-side preflight — mirrors the contract's `create_open` bounds plus
|
|
649
|
-
* the $50 client cap (the contract is value-neutral, same as Job). */
|
|
650
|
-
declare function preflightCreateOpening(terms: OpeningTerms): {
|
|
651
|
-
valid: boolean;
|
|
652
|
-
code?: 'INVALID_AMOUNT' | 'INVALID_INPUT';
|
|
653
|
-
error?: string;
|
|
654
|
-
};
|
|
655
|
-
/** Build the escrow-at-post tx: split USDC → `opening::create_open`. */
|
|
656
|
-
declare function buildCreateOpeningTx({ client, buyer, terms, }: {
|
|
657
|
-
client: SuiCoreClient;
|
|
658
|
-
buyer: string;
|
|
659
|
-
terms: OpeningTerms;
|
|
660
|
-
}): Promise<Transaction>;
|
|
661
|
-
/** Claim an opening (ASP side) — consumes it and mints the funded Job.
|
|
662
|
-
* `registryId` = the shared `agent_id::registry::Registry` object
|
|
663
|
-
* (callers pass `AGENT_ID_REGISTRY_ID` from `@t2000/id` — single source). */
|
|
664
|
-
declare function buildClaimOpeningTx({ openingId, registryId, }: {
|
|
665
|
-
openingId: string;
|
|
666
|
-
registryId: string;
|
|
667
|
-
}): Transaction;
|
|
668
|
-
/** Buyer withdraws an unclaimed opening — fee-free, any time. */
|
|
669
|
-
declare function buildCancelOpeningTx(openingId: string): Transaction;
|
|
670
|
-
/** Permissionless refund crank for an opening past `open_until`. */
|
|
671
|
-
declare function buildRefundUnclaimedTx(openingId: string): Transaction;
|
|
672
|
-
/** On-chain view of one Opening. */
|
|
673
|
-
interface Opening {
|
|
674
|
-
id: string;
|
|
675
|
-
buyer: string;
|
|
676
|
-
amountUsdc: number;
|
|
677
|
-
feeBps: number;
|
|
678
|
-
specHash: string;
|
|
679
|
-
openUntilMs: number;
|
|
680
|
-
slaMs: number;
|
|
681
|
-
reviewWindowMs: number;
|
|
682
|
-
rejectSplitBps: number;
|
|
683
|
-
claimPolicy: number;
|
|
684
|
-
createdAtMs: number;
|
|
685
|
-
}
|
|
686
|
-
/** Read one Opening by object id (null = gone: claimed/cancelled/refunded). */
|
|
687
|
-
declare function getOpening(client: SuiCoreClient, openingId: string): Promise<Opening | null>;
|
|
688
|
-
|
|
689
581
|
/** Title rules: an explicit title wins; otherwise the brief's first
|
|
690
582
|
* non-empty line (a leading "Title: …" prefix is stripped for the title
|
|
691
583
|
* field — the FULL text always stays in the brief, lossless), hard-capped
|
|
@@ -735,6 +627,10 @@ interface OpenJobRow {
|
|
|
735
627
|
} | null;
|
|
736
628
|
/** The escrow Job this opening was claimed into (claimed rows). */
|
|
737
629
|
jobId: string | null;
|
|
630
|
+
/** S.1054 — who may race to claim: 0 Anyone, 1 Proven, 2 Proven · 4★+
|
|
631
|
+
* (render with `claimPolicyLabel`, never the raw number). Absent on
|
|
632
|
+
* pre-S.1054 rows = 0. */
|
|
633
|
+
claimPolicy?: number;
|
|
738
634
|
createdAtMs: number;
|
|
739
635
|
updatedAtMs: number;
|
|
740
636
|
}
|
|
@@ -761,6 +657,21 @@ declare function postOpenJob(base: string, signer: TransactionSigner, input: {
|
|
|
761
657
|
slaMinutes?: number;
|
|
762
658
|
/** How long the posting stays claimable (default 24h, max 720). */
|
|
763
659
|
openHours?: number;
|
|
660
|
+
/** S.1054 — 0 Anyone (default), 1 Proven, 2 Proven · 4★+. */
|
|
661
|
+
claimPolicy?: number;
|
|
662
|
+
}): Promise<string>;
|
|
663
|
+
/** Review a RELEASED job you bought — writes the STARS ON-CHAIN (S.1054:
|
|
664
|
+
* the one public score SSOT; `a2a_escrow::reputation`). Same sponsored
|
|
665
|
+
* rail as every job verb; the server resolves whether this is the
|
|
666
|
+
* seller's first review (lazy score create) or an update/edit. Rare race
|
|
667
|
+
* (brand-new seller, two simultaneous first reviews): the loser aborts
|
|
668
|
+
* on-chain — just call this again; the retry re-reads the score and
|
|
669
|
+
* lands as a normal review. Optional `text` is stored off-chain by the
|
|
670
|
+
* API, keyed by jobId — text is not the score. Returns the tx digest. */
|
|
671
|
+
declare function submitJobReview(base: string, signer: TransactionSigner, input: {
|
|
672
|
+
jobId: string;
|
|
673
|
+
/** Integer 1-5. Re-submitting edits your stars in place. */
|
|
674
|
+
stars: number;
|
|
764
675
|
}): Promise<string>;
|
|
765
676
|
/** Claim an open job (ASP side) — first claim wins ON-CHAIN and mints the
|
|
766
677
|
* funded Job immediately; work starts now. Requires an active registered
|
|
@@ -1311,4 +1222,4 @@ declare function fullHandle(label: string, parentName?: string): string;
|
|
|
1311
1222
|
*/
|
|
1312
1223
|
declare function displayHandle(label: string, parentName?: string): string;
|
|
1313
1224
|
|
|
1314
|
-
export {
|
|
1225
|
+
export { AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type ApiModel, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ChatMessage, type ChatParams, type ChatResult, type ChatUsage, type CheckStatus, type ComposeTxOptions, type ComposeTxResult, DEFAULT_API_BASE, type DailySpend, DepositInfo, ESCROW_JOB_TYPE_MARKER, InvalidAddressError, type LabelValidationResult, type LimitAssertInput, LimitEnforcer, LimitExceededError, type LimitKind, type LimitOperation, type LimitsConfig, type LimitsFile, type NormalizedAddress, OPENING_TYPE_MARKER, type OpenJobFilter, type OpenJobRow, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SendResult, type SendTransferInput, SendableAsset, SerializedCetusRoute, type SponsoredTxGuard, type StepPreview, SuinsNotRegisteredError, type SuinsParent, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, type TrustMode, type UpstreamClaim, type VerifyAnchor, type VerifyCheck, type VerifyOptions, type VerifyResult, type VerifyUpstream, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, X402Probe, ZkLoginProof, approxUsdValue, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, claimOpenJob, clearLimits, composeTx, customHireEnvelope, dailySpentToday, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getLimits, getOpenJob, getSponsoredSwapProviders, getSwapQuote, hasLimits, isCustomHireEnvelope, keypairFromPrivateKey, listModels, listOpenJobs, loadKey, looksLikeSuiNs, normalizeAddressInput, postOpenJob, queryBalance, readLimitsFile, recordDailySpend, refundOpenJob, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, saveBech32, saveKey, setLimits, setSponsoredTxGuard, submitJobReview, validateLabel, verifyReceipt, walletExists, writeLimitsFile };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStructTag, isValidSuiAddress, normalizeSuiAddress, fromBase64 } from '@mysten/sui/utils';
|
|
1
|
+
import { normalizeStructTag, isValidSuiAddress, normalizeSuiAddress, fromBase64, deriveObjectID } from '@mysten/sui/utils';
|
|
2
2
|
import { coinWithBalance, Transaction } from '@mysten/sui/transactions';
|
|
3
3
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
4
4
|
import BN from 'bn.js';
|
|
@@ -16,6 +16,7 @@ import { secp256k1 } from '@noble/curves/secp256k1';
|
|
|
16
16
|
import { sha256 } from '@noble/hashes/sha256';
|
|
17
17
|
import { hexToBytes, bytesToHex } from '@noble/hashes/utils';
|
|
18
18
|
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
19
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
19
20
|
import { SuinsTransaction } from '@mysten/suins';
|
|
20
21
|
|
|
21
22
|
var __defProp = Object.defineProperty;
|
|
@@ -3321,16 +3322,19 @@ init_coinSelection();
|
|
|
3321
3322
|
init_errors();
|
|
3322
3323
|
init_token_registry();
|
|
3323
3324
|
init_coinSelection();
|
|
3324
|
-
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "
|
|
3325
|
+
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0xb065033b6f72c4899055a0b3afac28f09dc7b0b7b491eada793157de20000618";
|
|
3325
3326
|
var MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID;
|
|
3326
3327
|
var A2A_ESCROW_LATEST_PACKAGE_ID = process.env.A2A_ESCROW_OPENING_PACKAGE_ID ?? process.env.A2A_ESCROW_PACKAGE_ID ?? MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID;
|
|
3327
3328
|
var A2A_ESCROW_OPENING_PACKAGE_ID = A2A_ESCROW_LATEST_PACKAGE_ID;
|
|
3328
3329
|
var A2A_ESCROW_PACKAGE_V2_ID = "0x860288d789dc617f6474a0a6801d6011e53bf30d5fb801cdad47b9bc6adb098b";
|
|
3329
3330
|
var A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc2eed75942dcb5bcbe7";
|
|
3331
|
+
var A2A_ESCROW_PACKAGE_V6_ID = "0xb065033b6f72c4899055a0b3afac28f09dc7b0b7b491eada793157de20000618";
|
|
3330
3332
|
var CLOCK_ID2 = "0x6";
|
|
3331
3333
|
var MODULE = "opening";
|
|
3332
3334
|
var SHA256_HEX_RE = /^(0x)?[0-9a-fA-F]{64}$/;
|
|
3333
3335
|
var OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
|
|
3336
|
+
var OPENING_CLAIM_POLICY_PROVEN = 1;
|
|
3337
|
+
var OPENING_CLAIM_POLICY_PROVEN_4STAR = 2;
|
|
3334
3338
|
var MAX_OPEN_WINDOW_MS = 2592e6;
|
|
3335
3339
|
function feeConfigArg(tx) {
|
|
3336
3340
|
return tx.sharedObjectRef({
|
|
@@ -3347,6 +3351,11 @@ function hexToBytes2(hex) {
|
|
|
3347
3351
|
}
|
|
3348
3352
|
return bytes;
|
|
3349
3353
|
}
|
|
3354
|
+
var OPENING_CLAIM_POLICIES = [
|
|
3355
|
+
OPENING_CLAIM_POLICY_ANY_ACTIVE,
|
|
3356
|
+
OPENING_CLAIM_POLICY_PROVEN,
|
|
3357
|
+
OPENING_CLAIM_POLICY_PROVEN_4STAR
|
|
3358
|
+
];
|
|
3350
3359
|
var OPEN_REJECT_SPLIT_BPS = 1e4;
|
|
3351
3360
|
function preflightCreateOpening(terms) {
|
|
3352
3361
|
if (!Number.isFinite(terms.amountUsdc) || terms.amountUsdc <= 0) {
|
|
@@ -3386,6 +3395,14 @@ function preflightCreateOpening(terms) {
|
|
|
3386
3395
|
error: "Open postings lock reject at 100% buyer / 0% seller (rejectSplitBps must be 10000, contract-enforced since v5) \u2014 reject is economically a decline, so junk delivery has no edge."
|
|
3387
3396
|
};
|
|
3388
3397
|
}
|
|
3398
|
+
const policy = terms.claimPolicy ?? OPENING_CLAIM_POLICY_ANY_ACTIVE;
|
|
3399
|
+
if (!OPENING_CLAIM_POLICIES.includes(policy)) {
|
|
3400
|
+
return {
|
|
3401
|
+
valid: false,
|
|
3402
|
+
code: "INVALID_INPUT",
|
|
3403
|
+
error: "claimPolicy must be 0 (Anyone), 1 (Proven) or 2 (Proven \xB7 4\u2605+) \u2014 anything else aborts on-chain."
|
|
3404
|
+
};
|
|
3405
|
+
}
|
|
3389
3406
|
return { valid: true };
|
|
3390
3407
|
}
|
|
3391
3408
|
async function buildCreateOpeningTx({
|
|
@@ -3410,7 +3427,7 @@ async function buildCreateOpeningTx({
|
|
|
3410
3427
|
tx.pure.u64(terms.slaMs),
|
|
3411
3428
|
tx.pure.u64(terms.reviewWindowMs),
|
|
3412
3429
|
tx.pure.u64(terms.rejectSplitBps),
|
|
3413
|
-
tx.pure.u8(OPENING_CLAIM_POLICY_ANY_ACTIVE),
|
|
3430
|
+
tx.pure.u8(terms.claimPolicy ?? OPENING_CLAIM_POLICY_ANY_ACTIVE),
|
|
3414
3431
|
feeConfigArg(tx),
|
|
3415
3432
|
tx.object(CLOCK_ID2)
|
|
3416
3433
|
]
|
|
@@ -3419,13 +3436,20 @@ async function buildCreateOpeningTx({
|
|
|
3419
3436
|
}
|
|
3420
3437
|
function buildClaimOpeningTx({
|
|
3421
3438
|
openingId,
|
|
3422
|
-
registryId
|
|
3439
|
+
registryId,
|
|
3440
|
+
scoreId
|
|
3423
3441
|
}) {
|
|
3424
3442
|
const tx = new Transaction();
|
|
3425
3443
|
tx.moveCall({
|
|
3426
|
-
target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}
|
|
3444
|
+
target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::${scoreId ? "claim_proven" : "claim"}`,
|
|
3427
3445
|
typeArguments: [USDC_TYPE],
|
|
3428
|
-
arguments: [
|
|
3446
|
+
arguments: scoreId ? [
|
|
3447
|
+
tx.object(openingId),
|
|
3448
|
+
tx.object(registryId),
|
|
3449
|
+
tx.object(scoreId),
|
|
3450
|
+
feeConfigArg(tx),
|
|
3451
|
+
tx.object(CLOCK_ID2)
|
|
3452
|
+
] : [
|
|
3429
3453
|
tx.object(openingId),
|
|
3430
3454
|
tx.object(registryId),
|
|
3431
3455
|
feeConfigArg(tx),
|
|
@@ -3707,6 +3731,123 @@ async function verifyJobForSeller({
|
|
|
3707
3731
|
return { ok: problems.length === 0, job, problems };
|
|
3708
3732
|
}
|
|
3709
3733
|
|
|
3734
|
+
// src/wallet/reputation.ts
|
|
3735
|
+
init_errors();
|
|
3736
|
+
init_token_registry();
|
|
3737
|
+
var MAINNET_A2A_SCORE_BOARD_ID = "0x7506f01e01b1c48d73832949a2808929b80dec2f7104889e012f8a4f09719f6e";
|
|
3738
|
+
var A2A_SCORE_BOARD_ID = process.env.A2A_SCORE_BOARD_ID ?? MAINNET_A2A_SCORE_BOARD_ID;
|
|
3739
|
+
var MODULE3 = "reputation";
|
|
3740
|
+
var CLOCK_ID4 = "0x6";
|
|
3741
|
+
var PROVEN_MIN_REVIEWS = 3;
|
|
3742
|
+
var PROVEN_MIN_AVG_STARS_X10 = 40;
|
|
3743
|
+
var REVIEW_MIN_STARS = 1;
|
|
3744
|
+
var REVIEW_MAX_STARS = 5;
|
|
3745
|
+
function boardIdOrThrow(boardId) {
|
|
3746
|
+
const id = boardId ?? A2A_SCORE_BOARD_ID;
|
|
3747
|
+
if (!id) {
|
|
3748
|
+
throw new T2000Error(
|
|
3749
|
+
"INVALID_INPUT",
|
|
3750
|
+
"The reputation ScoreBoard id is not configured (pre-S.1054-cutover build?)."
|
|
3751
|
+
);
|
|
3752
|
+
}
|
|
3753
|
+
return id;
|
|
3754
|
+
}
|
|
3755
|
+
function deriveAgentScoreId(agent, boardId) {
|
|
3756
|
+
return deriveObjectID(
|
|
3757
|
+
boardIdOrThrow(boardId),
|
|
3758
|
+
"address",
|
|
3759
|
+
bcs.Address.serialize(validateAddress(agent)).toBytes()
|
|
3760
|
+
);
|
|
3761
|
+
}
|
|
3762
|
+
async function getAgentScore(client, agent, boardId) {
|
|
3763
|
+
const scoreId = deriveAgentScoreId(agent, boardId);
|
|
3764
|
+
const resp = await client.core.getObject({ objectId: scoreId, include: { json: true } }).catch(() => null);
|
|
3765
|
+
const objType = resp?.object?.type ?? "";
|
|
3766
|
+
const json = resp?.object?.json;
|
|
3767
|
+
if (!json || !objType.includes(`::${MODULE3}::AgentScore`)) {
|
|
3768
|
+
return null;
|
|
3769
|
+
}
|
|
3770
|
+
const reviewCount = Number(json.review_count ?? 0);
|
|
3771
|
+
const starsSum = Number(json.stars_sum ?? 0);
|
|
3772
|
+
return {
|
|
3773
|
+
id: scoreId,
|
|
3774
|
+
agent: String(json.agent),
|
|
3775
|
+
reviewCount,
|
|
3776
|
+
starsSum,
|
|
3777
|
+
averageStars: reviewCount > 0 ? Math.round(starsSum / reviewCount * 100) / 100 : 0
|
|
3778
|
+
};
|
|
3779
|
+
}
|
|
3780
|
+
function meetsClaimPolicy(score, claimPolicy) {
|
|
3781
|
+
if (claimPolicy === 0) return true;
|
|
3782
|
+
if (!score) return false;
|
|
3783
|
+
const proven = score.reviewCount >= PROVEN_MIN_REVIEWS;
|
|
3784
|
+
if (claimPolicy === 1) return proven;
|
|
3785
|
+
if (claimPolicy === 2) {
|
|
3786
|
+
return proven && score.starsSum * 10 >= score.reviewCount * PROVEN_MIN_AVG_STARS_X10;
|
|
3787
|
+
}
|
|
3788
|
+
return false;
|
|
3789
|
+
}
|
|
3790
|
+
function claimPolicyLabel(claimPolicy) {
|
|
3791
|
+
if (claimPolicy === 0) return "Anyone";
|
|
3792
|
+
if (claimPolicy === 1) return "Proven";
|
|
3793
|
+
if (claimPolicy === 2) return "Proven \xB7 4\u2605+";
|
|
3794
|
+
return `Unknown policy ${claimPolicy}`;
|
|
3795
|
+
}
|
|
3796
|
+
function claimPolicyRequirement(claimPolicy) {
|
|
3797
|
+
if (claimPolicy === 1) {
|
|
3798
|
+
return `Claiming needs at least ${PROVEN_MIN_REVIEWS} on-chain reviews.`;
|
|
3799
|
+
}
|
|
3800
|
+
if (claimPolicy === 2) {
|
|
3801
|
+
return `Claiming needs at least ${PROVEN_MIN_REVIEWS} on-chain reviews and a 4.0\u2605 average.`;
|
|
3802
|
+
}
|
|
3803
|
+
return "Anyone can claim (active Agent ID required).";
|
|
3804
|
+
}
|
|
3805
|
+
function assertStars(stars) {
|
|
3806
|
+
if (!Number.isInteger(stars) || stars < REVIEW_MIN_STARS || stars > REVIEW_MAX_STARS) {
|
|
3807
|
+
throw new T2000Error("INVALID_INPUT", "Stars must be an integer 1-5.");
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3810
|
+
function buildSubmitReviewTx({
|
|
3811
|
+
scoreId,
|
|
3812
|
+
jobId,
|
|
3813
|
+
stars
|
|
3814
|
+
}) {
|
|
3815
|
+
assertStars(stars);
|
|
3816
|
+
const tx = new Transaction();
|
|
3817
|
+
tx.moveCall({
|
|
3818
|
+
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::${MODULE3}::submit_review`,
|
|
3819
|
+
typeArguments: [USDC_TYPE],
|
|
3820
|
+
arguments: [
|
|
3821
|
+
tx.object(scoreId),
|
|
3822
|
+
tx.object(validateAddress(jobId)),
|
|
3823
|
+
tx.pure.u8(stars),
|
|
3824
|
+
feeConfigArg(tx),
|
|
3825
|
+
tx.object(CLOCK_ID4)
|
|
3826
|
+
]
|
|
3827
|
+
});
|
|
3828
|
+
return tx;
|
|
3829
|
+
}
|
|
3830
|
+
function buildSubmitFirstReviewTx({
|
|
3831
|
+
jobId,
|
|
3832
|
+
stars,
|
|
3833
|
+
boardId
|
|
3834
|
+
}) {
|
|
3835
|
+
assertStars(stars);
|
|
3836
|
+
const tx = new Transaction();
|
|
3837
|
+
tx.moveCall({
|
|
3838
|
+
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::${MODULE3}::submit_first_review`,
|
|
3839
|
+
typeArguments: [USDC_TYPE],
|
|
3840
|
+
arguments: [
|
|
3841
|
+
tx.object(boardIdOrThrow(boardId)),
|
|
3842
|
+
tx.object(validateAddress(jobId)),
|
|
3843
|
+
tx.pure.u8(stars),
|
|
3844
|
+
feeConfigArg(tx),
|
|
3845
|
+
tx.object(CLOCK_ID4)
|
|
3846
|
+
]
|
|
3847
|
+
});
|
|
3848
|
+
return tx;
|
|
3849
|
+
}
|
|
3850
|
+
|
|
3710
3851
|
// src/commerce.ts
|
|
3711
3852
|
var DEFAULT_COMMERCE_API_BASE = "https://api.t2000.ai/v1";
|
|
3712
3853
|
async function commerceFetchJson(url, init) {
|
|
@@ -3932,6 +4073,12 @@ async function sponsoredOpeningVerb(base, signer, action, params) {
|
|
|
3932
4073
|
function postOpenJob(base, signer, input) {
|
|
3933
4074
|
return sponsoredOpeningVerb(base, signer, "open-create", input);
|
|
3934
4075
|
}
|
|
4076
|
+
function submitJobReview(base, signer, input) {
|
|
4077
|
+
return sponsoredOpeningVerb(base, signer, "job-review", {
|
|
4078
|
+
jobId: input.jobId.trim(),
|
|
4079
|
+
stars: input.stars
|
|
4080
|
+
});
|
|
4081
|
+
}
|
|
3935
4082
|
function claimOpenJob(base, signer, openingId) {
|
|
3936
4083
|
return sponsoredOpeningVerb(base, signer, "open-claim", {
|
|
3937
4084
|
openingId: openingId.trim()
|
|
@@ -4389,4 +4536,4 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
|
4389
4536
|
// src/index.ts
|
|
4390
4537
|
init_preflight();
|
|
4391
4538
|
|
|
4392
|
-
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_LATEST_PACKAGE_ID, A2A_ESCROW_OPENING_PACKAGE_ID, A2A_ESCROW_PACKAGE_ID, A2A_ESCROW_PACKAGE_V2_ID, A2A_ESCROW_PACKAGE_V3_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ESCROW_JOB_TYPE_MARKER, 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, MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID, MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, MAINNET_A2A_ESCROW_PACKAGE_ID, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIN_JOB_USDC, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICY_ANY_ACTIVE, OPENING_TYPE_MARKER, 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, 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, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, claimOpenJob, classifyAction, classifyLabel, classifySendAsset, classifyTransaction, clearLimits, composeTx, customHireEnvelope, 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, invalidSendAssetMessage, isAllowedAsset, isCetusRouteFresh, isCustomHireEnvelope, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithX402, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, reportX402Activity, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, setSponsoredTxGuard, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|
|
4539
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_LATEST_PACKAGE_ID, A2A_ESCROW_OPENING_PACKAGE_ID, A2A_ESCROW_PACKAGE_ID, A2A_ESCROW_PACKAGE_V2_ID, A2A_ESCROW_PACKAGE_V3_ID, A2A_ESCROW_PACKAGE_V6_ID, A2A_SCORE_BOARD_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ESCROW_JOB_TYPE_MARKER, 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, MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID, MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, MAINNET_A2A_ESCROW_PACKAGE_ID, MAINNET_A2A_SCORE_BOARD_ID, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_OPEN_WINDOW_MS, MAX_REVIEW_WINDOW_MS, MIN_JOB_USDC, MIST_PER_SUI, NAVX_TYPE, OPENING_CLAIM_POLICIES, OPENING_CLAIM_POLICY_ANY_ACTIVE, OPENING_CLAIM_POLICY_PROVEN, OPENING_CLAIM_POLICY_PROVEN_4STAR, OPENING_TYPE_MARKER, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, PROVEN_MIN_AVG_STARS_X10, PROVEN_MIN_REVIEWS, REVIEW_MAX_STARS, REVIEW_MIN_STARS, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, 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, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateJobTx, buildCreateOpeningTx, buildDeclineJobTx, buildDeliverJobTx, buildRefundJobTx, buildRefundUnclaimedTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSubmitFirstReviewTx, buildSubmitReviewTx, buildSwapTx, cancelOpenJob, canonicalizeRecipientInput, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, claimOpenJob, claimPolicyLabel, claimPolicyRequirement, classifyAction, classifyLabel, classifySendAsset, classifyTransaction, clearLimits, composeTx, customHireEnvelope, dailySpentToday, deriveAgentScoreId, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getAgentScore, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getOpenJob, getOpening, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, invalidSendAssetMessage, isAllowedAsset, isCetusRouteFresh, isCustomHireEnvelope, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, meetsClaimPolicy, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, payWithX402, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, reportX402Activity, resolveAddressToSuinsViaRpc, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, setSponsoredTxGuard, simulateTransaction, stableToRaw, submitJobReview, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|