@t2000/sdk 10.37.2 → 10.38.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/browser.cjs +79 -15
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +70 -16
- package/dist/{commerce-gDWVYXP8.d.cts → commerce-D14qzqAV.d.cts} +91 -14
- package/dist/{commerce-gDWVYXP8.d.ts → commerce-D14qzqAV.d.ts} +91 -14
- package/dist/index.cjs +123 -24
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +113 -25
- package/package.json +2 -2
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 {
|
|
5
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID,
|
|
4
|
+
import { ad as T2000Error, bx as T2000Options, ak as TransactionSigner, V as PayOptions, by as X402Probe, W as PayResult, bz as SerializedCetusRoute, bA as SwapResult, bB as SwapQuoteResult, a5 as SendResult, B as BalanceResponse, aj as TransactionRecord, j as DepositInfo, bC as PaymentRequest, au as ZkLoginProof, bD as SuiCoreClient, Q as OverlayFeeConfig, bE as SponsoredCoinMergeCache, ab as SupportedAsset, ac as SwapRouteResult, bF as SendableAsset } from './commerce-D14qzqAV.js';
|
|
5
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, bG as A2A_ESCROW_LATEST_PACKAGE_ID, bH as A2A_ESCROW_OPENING_PACKAGE_ID, a as A2A_ESCROW_PACKAGE_ID, bI as A2A_ESCROW_PACKAGE_V10_ID, bJ as A2A_ESCROW_PACKAGE_V2_ID, bK as A2A_ESCROW_PACKAGE_V3_ID, bL as A2A_ESCROW_PACKAGE_V6_ID, bM as A2A_ESCROW_PACKAGE_V7_ID, bN as A2A_ESCROW_PACKAGE_V8_ID, bO as A2A_SCORE_BOARD_ID, b as ActivityReportConfig, c as AgentScore, bP as ApiRouteListing, bQ as CETUS_USDC_SUI_POOL, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, bR as CoinPage, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, bS as DEFAULT_GRPC_URL, i as DEFAULT_NETWORK, E as ETH_TYPE, k as ExtractedTransfer, bT as GASLESS_MIN_STABLE_AMOUNT, bU 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 LEVEL4_MAX_NO_DELIVERY, r as LEVEL4_MIN_REVIEWS, s as LOFI_TYPE, bV as MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID, bW as MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID, bX as MAINNET_A2A_ESCROW_PACKAGE_ID, bY as MAINNET_A2A_SCORE_BOARD_ID, M as MANIFEST_TYPE, t as MAX_DELIVER_HORIZON_MS, u as MAX_JOB_USDC, bZ as MAX_OPEN_WINDOW_MS, v as MAX_REVIEW_WINDOW_MS, w as MIN_JOB_USDC, x as MIST_PER_SUI, N as NAVX_TYPE, y as NO_DELIVERY_REGRESSION_FLOOR, O as OPENING_CLAIM_POLICIES, z as OPENING_CLAIM_POLICY_ANY_ACTIVE, F as OPENING_CLAIM_POLICY_PROVEN, H as OPENING_CLAIM_POLICY_PROVEN_4STAR, b_ as OPERATION_ASSETS, P as OVERLAY_FEE_RATE, b$ as Opening, c0 as OpeningTerms, c1 as Operation, R as PREFLIGHT_MAX_AMOUNT, S as PREFLIGHT_OK, T as PROVEN_MIN_AVG_STARS_X10, U as PROVEN_MIN_REVIEWS, X as PreflightResult, Y as REVIEW_MAX_STARS, Z as REVIEW_MIN_STARS, _ as SELLER_LEVEL_ACTIVE_CAPS, c2 as SENDABLE_ASSETS, $ as STABLE_ASSETS, a0 as SUI_DECIMALS, a1 as SUI_TYPE, a2 as SUPPORTED_ASSETS, c3 as SelectAndSplitResult, a3 as SellerLevel, a4 as SendAssetClass, c4 as SerializedCetusRoutePath, c5 as SerializedRouterDataV3, a6 as ServiceListing, c6 as ServicesRail, c7 as ServicesRow, a7 as SimulationResult, a8 as StableAsset, a9 as SuiHolding, aa as SuiRpcTxBlock, ae as T2000ErrorCode, af as T2000ErrorData, ag as T2000_OVERLAY_FEE_WALLET, ah as TOKEN_MAP, ai as TransactionLeg, al as TxDirection, am as USDC_DECIMALS, an as USDC_TYPE, ao as USDE_TYPE, ap as USDSUI_TYPE, aq as USDT_TYPE, ar as WAL_TYPE, as as WBTC_TYPE, at as X402ActivityPayload, av as ZkLoginSigner, aw as activeCapForLevel, c8 as addSendToTx, c9 as addSwapToTx, ca as assertAllowedAsset, cb as assertBuyerRequirements, cc as buildCancelOpeningTx, cd as buildClaimOpeningTx, ce as buildCreateEmptyScoreTx, ax as buildCreateJobTx, cf as buildCreateOpeningTx, cg as buildDeclineJobTx, ay as buildDeliverJobTx, az as buildRefundJobTx, ch as buildRefundUnclaimedTx, aA as buildRejectJobTx, aB as buildReleaseJobTx, aC as buildSendTx, ci as buildSubmitFirstReviewTx, cj as buildSubmitReviewTx, aD as buildSwapTx, aE as checkPositiveAmount, aF as checkSuiAddress, aG as claimPolicyLabel, aH as claimPolicyRequirement, aI as classifyAction, aJ as classifyLabel, aK as classifySendAsset, aL as classifyTransaction, aM as deriveAgentScoreId, ck as deserializeCetusRoute, aN as effectiveSellerLevel, aO as executeTx, aP as extractAllUserLegs, aQ as extractTransferDetails, aR as extractTxCommands, aS as extractTxSender, aT as fallbackLabel, cl as fetchAllCoins, aU as fetchService, aV as findSwapRoute, aW as formatAssetAmount, aX as formatSui, aY as formatUsd, aZ as getAgentScore, cm as getCoinMeta, a_ as getDecimals, a$ as getDecimalsForCoinType, b0 as getJob, b1 as getJobSpec, cn as getOpening, co as getSuiClient, cp as getSuiGrpcClient, b2 as invalidSendAssetMessage, cq as isAllowedAsset, cr as isCetusRouteFresh, cs as isInRegistry, b3 as jobActionsFor, b4 as listServices, b5 as mapMoveAbortCode, b6 as mapWalletError, b7 as meetsClaimPolicy, b8 as meetsMinSellerLevel, b9 as mistToSui, ct as normalizeAsset, cu as normalizeCoinType, ba as parseSuiRpcTx, bb as payWithX402, bc as preflightClaimOpening, bd as preflightCreateJob, cv as preflightCreateOpening, be as preflightFail, bf as preflightPay, bg as preflightSend, bh as preflightSwap, cw as probeX402, bi as putJobSpec, cx as queryHistory, cy as queryTransaction, bj as rawToStable, bk as rawToUsdc, bl as refineLendingLabel, bm as reportX402Activity, bn as resolveSymbol, bo as resolveTokenType, cz as selectAndSplitCoin, cA as selectSuiCoin, bp as sellerLevel, bq as sellerLevelLabel, cB as serializeCetusRoute, cC as simulateTransaction, br as stableToRaw, bs as suiToMist, cD as throwIfSimulationFailed, bt as truncateAddress, bu as usdcToRaw, bv as validateAddress, cE as verifyCetusRouteCoinMatch, bw as verifyJobForSeller } from './commerce-D14qzqAV.js';
|
|
6
6
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
|
@@ -552,6 +552,9 @@ interface OpenJobRow {
|
|
|
552
552
|
* (render with `claimPolicyLabel`, never the raw number). Absent on
|
|
553
553
|
* pre-S.1054 rows = 0. */
|
|
554
554
|
claimPolicy?: number;
|
|
555
|
+
/** S.1192 — minimum EFFECTIVE seller level to claim (render with
|
|
556
|
+
* `sellerLevelLabel`). Absent on pre-S.1192 rows = 0 (no floor). */
|
|
557
|
+
minSellerLevel?: number;
|
|
555
558
|
createdAtMs: number;
|
|
556
559
|
updatedAtMs: number;
|
|
557
560
|
}
|
|
@@ -595,6 +598,9 @@ declare function postOpenJob(base: string, signer: TransactionSigner, input: {
|
|
|
595
598
|
openHours?: number;
|
|
596
599
|
/** S.1054 — 0 Anyone (default), 1 Proven, 2 Proven · 4★+. */
|
|
597
600
|
claimPolicy?: number;
|
|
601
|
+
/** S.1192 — minimum EFFECTIVE seller level to claim: 0 none
|
|
602
|
+
* (default), 1..4. Independent of claimPolicy. */
|
|
603
|
+
minSellerLevel?: number;
|
|
598
604
|
}): Promise<string>;
|
|
599
605
|
/** Review a settled job you bought — RELEASED or REJECTED (S.1064),
|
|
600
606
|
* always with a real delivery — writes the STARS ON-CHAIN (S.1054:
|
package/dist/index.js
CHANGED
|
@@ -2980,7 +2980,7 @@ init_coinSelection();
|
|
|
2980
2980
|
init_errors();
|
|
2981
2981
|
init_token_registry();
|
|
2982
2982
|
init_coinSelection();
|
|
2983
|
-
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "
|
|
2983
|
+
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
2984
2984
|
var MAINNET_A2A_ESCROW_OPENING_PACKAGE_ID = MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID;
|
|
2985
2985
|
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;
|
|
2986
2986
|
var A2A_ESCROW_OPENING_PACKAGE_ID = A2A_ESCROW_LATEST_PACKAGE_ID;
|
|
@@ -2989,6 +2989,7 @@ var A2A_ESCROW_PACKAGE_V3_ID = "0x69ad93c555519de520a5c7f7f2963ad6f8b91cefc098fc
|
|
|
2989
2989
|
var A2A_ESCROW_PACKAGE_V6_ID = "0xb065033b6f72c4899055a0b3afac28f09dc7b0b7b491eada793157de20000618";
|
|
2990
2990
|
var A2A_ESCROW_PACKAGE_V7_ID = "0x4249f0b242c47c7baf0c37304365bc4bbe769bcedf11f3525e84682d59a3b23e";
|
|
2991
2991
|
var A2A_ESCROW_PACKAGE_V8_ID = "0x1595b80bc05a03607f3908702c866ca63cf961025b4263b5ecbe419e07f8ff31";
|
|
2992
|
+
var A2A_ESCROW_PACKAGE_V10_ID = process.env.A2A_ESCROW_PACKAGE_V10_ID ?? "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
2992
2993
|
var CLOCK_ID2 = "0x6";
|
|
2993
2994
|
var MODULE = "opening";
|
|
2994
2995
|
var SHA256_HEX_RE = /^(0x)?[0-9a-fA-F]{64}$/;
|
|
@@ -3063,6 +3064,14 @@ function preflightCreateOpening(terms) {
|
|
|
3063
3064
|
error: "claimPolicy must be 0 (Anyone), 1 (Proven) or 2 (Proven \xB7 4\u2605+) \u2014 anything else aborts on-chain."
|
|
3064
3065
|
};
|
|
3065
3066
|
}
|
|
3067
|
+
const minLevel = terms.minSellerLevel ?? 0;
|
|
3068
|
+
if (!Number.isInteger(minLevel) || minLevel < 0 || minLevel > 4) {
|
|
3069
|
+
return {
|
|
3070
|
+
valid: false,
|
|
3071
|
+
code: "INVALID_INPUT",
|
|
3072
|
+
error: "minSellerLevel must be 0 (no floor) or 1\u20134 (Level 1\u20134) \u2014 anything else aborts on-chain (S.1192)."
|
|
3073
|
+
};
|
|
3074
|
+
}
|
|
3066
3075
|
return { valid: true };
|
|
3067
3076
|
}
|
|
3068
3077
|
async function buildCreateOpeningTx({
|
|
@@ -3078,7 +3087,9 @@ async function buildCreateOpeningTx({
|
|
|
3078
3087
|
allowSwapAll: false
|
|
3079
3088
|
});
|
|
3080
3089
|
tx.moveCall({
|
|
3081
|
-
|
|
3090
|
+
// S.1192: create_open is a dead abort stub after the v10 migrate —
|
|
3091
|
+
// every post rides v2 (adds the min_seller_level DF write).
|
|
3092
|
+
target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::create_open_v2`,
|
|
3082
3093
|
typeArguments: [USDC_TYPE],
|
|
3083
3094
|
arguments: [
|
|
3084
3095
|
coin,
|
|
@@ -3088,6 +3099,7 @@ async function buildCreateOpeningTx({
|
|
|
3088
3099
|
tx.pure.u64(terms.reviewWindowMs),
|
|
3089
3100
|
tx.pure.u64(terms.rejectSplitBps),
|
|
3090
3101
|
tx.pure.u8(terms.claimPolicy ?? OPENING_CLAIM_POLICY_ANY_ACTIVE),
|
|
3102
|
+
tx.pure.u8(terms.minSellerLevel ?? 0),
|
|
3091
3103
|
feeConfigArg(tx),
|
|
3092
3104
|
tx.object(CLOCK_ID2)
|
|
3093
3105
|
]
|
|
@@ -3097,23 +3109,26 @@ async function buildCreateOpeningTx({
|
|
|
3097
3109
|
function buildClaimOpeningTx({
|
|
3098
3110
|
openingId,
|
|
3099
3111
|
registryId,
|
|
3100
|
-
scoreId
|
|
3112
|
+
scoreId,
|
|
3113
|
+
claimPolicy = OPENING_CLAIM_POLICY_ANY_ACTIVE
|
|
3101
3114
|
}) {
|
|
3115
|
+
if (!scoreId) {
|
|
3116
|
+
throw new T2000Error(
|
|
3117
|
+
"INVALID_INPUT",
|
|
3118
|
+
"Claiming needs the claimer's own AgentScore id (S.1192 \u2014 every claim moves the active-job counter). Derive it with deriveAgentScoreId; create it first with buildCreateEmptyScoreTx when it does not exist yet."
|
|
3119
|
+
);
|
|
3120
|
+
}
|
|
3121
|
+
const proven = claimPolicy !== OPENING_CLAIM_POLICY_ANY_ACTIVE;
|
|
3102
3122
|
const tx = new Transaction();
|
|
3103
3123
|
tx.moveCall({
|
|
3104
|
-
target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::${
|
|
3124
|
+
target: `${A2A_ESCROW_OPENING_PACKAGE_ID}::${MODULE}::${proven ? "claim_proven_v2" : "claim_v2"}`,
|
|
3105
3125
|
typeArguments: [USDC_TYPE],
|
|
3106
|
-
arguments:
|
|
3126
|
+
arguments: [
|
|
3107
3127
|
tx.object(openingId),
|
|
3108
3128
|
tx.object(registryId),
|
|
3109
3129
|
tx.object(scoreId),
|
|
3110
3130
|
feeConfigArg(tx),
|
|
3111
3131
|
tx.object(CLOCK_ID2)
|
|
3112
|
-
] : [
|
|
3113
|
-
tx.object(openingId),
|
|
3114
|
-
tx.object(registryId),
|
|
3115
|
-
feeConfigArg(tx),
|
|
3116
|
-
tx.object(CLOCK_ID2)
|
|
3117
3132
|
]
|
|
3118
3133
|
});
|
|
3119
3134
|
return tx;
|
|
@@ -3133,6 +3148,24 @@ function buildCancelOpeningTx(openingId) {
|
|
|
3133
3148
|
function buildRefundUnclaimedTx(openingId) {
|
|
3134
3149
|
return openingCall(openingId, "refund_unclaimed");
|
|
3135
3150
|
}
|
|
3151
|
+
async function readMinSellerLevelDf(client, openingId) {
|
|
3152
|
+
if (!A2A_ESCROW_PACKAGE_V10_ID) return 0;
|
|
3153
|
+
try {
|
|
3154
|
+
const fieldId = deriveDynamicFieldID(
|
|
3155
|
+
openingId,
|
|
3156
|
+
`${A2A_ESCROW_PACKAGE_V10_ID}::${MODULE}::MinSellerLevelKey`,
|
|
3157
|
+
new Uint8Array([0])
|
|
3158
|
+
);
|
|
3159
|
+
const resp = await client.core.getObject({
|
|
3160
|
+
objectId: fieldId,
|
|
3161
|
+
include: { json: true }
|
|
3162
|
+
});
|
|
3163
|
+
const json = resp?.object?.json;
|
|
3164
|
+
return Number(json?.value ?? 0);
|
|
3165
|
+
} catch {
|
|
3166
|
+
return 0;
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3136
3169
|
function bytesToHex(bytes) {
|
|
3137
3170
|
return `0x${Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
3138
3171
|
}
|
|
@@ -3143,6 +3176,7 @@ async function getOpening(client, openingId) {
|
|
|
3143
3176
|
if (!json || !objType.includes(`::${MODULE}::Opening<`)) {
|
|
3144
3177
|
return null;
|
|
3145
3178
|
}
|
|
3179
|
+
const minSellerLevel = await readMinSellerLevelDf(client, openingId);
|
|
3146
3180
|
return {
|
|
3147
3181
|
id: openingId,
|
|
3148
3182
|
buyer: String(json.buyer),
|
|
@@ -3154,6 +3188,7 @@ async function getOpening(client, openingId) {
|
|
|
3154
3188
|
reviewWindowMs: Number(json.review_window_ms),
|
|
3155
3189
|
rejectSplitBps: Number(json.reject_split_bps),
|
|
3156
3190
|
claimPolicy: Number(json.claim_policy ?? 0),
|
|
3191
|
+
minSellerLevel,
|
|
3157
3192
|
createdAtMs: Number(json.created_at_ms ?? 0)
|
|
3158
3193
|
};
|
|
3159
3194
|
}
|
|
@@ -3283,15 +3318,6 @@ function buildDeclineJobTx(jobId) {
|
|
|
3283
3318
|
});
|
|
3284
3319
|
return tx;
|
|
3285
3320
|
}
|
|
3286
|
-
function jobCall(jobId, fn) {
|
|
3287
|
-
const tx = new Transaction();
|
|
3288
|
-
tx.moveCall({
|
|
3289
|
-
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::${MODULE2}::${fn}`,
|
|
3290
|
-
typeArguments: [USDC_TYPE],
|
|
3291
|
-
arguments: [tx.object(jobId), feeConfigArg2(tx), tx.object(CLOCK_ID3)]
|
|
3292
|
-
});
|
|
3293
|
-
return tx;
|
|
3294
|
-
}
|
|
3295
3321
|
function buildRejectJobTx(jobId, v2) {
|
|
3296
3322
|
const tx = new Transaction();
|
|
3297
3323
|
tx.moveCall({
|
|
@@ -3342,8 +3368,19 @@ function buildDeliverJobTx(jobId, deliveryHash) {
|
|
|
3342
3368
|
});
|
|
3343
3369
|
return tx;
|
|
3344
3370
|
}
|
|
3345
|
-
function buildReleaseJobTx(jobId) {
|
|
3346
|
-
|
|
3371
|
+
function buildReleaseJobTx(jobId, v2) {
|
|
3372
|
+
const tx = new Transaction();
|
|
3373
|
+
tx.moveCall({
|
|
3374
|
+
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::reputation::release_v2`,
|
|
3375
|
+
typeArguments: [USDC_TYPE],
|
|
3376
|
+
arguments: [
|
|
3377
|
+
tx.object(jobId),
|
|
3378
|
+
tx.object(v2.sellerScoreId),
|
|
3379
|
+
feeConfigArg2(tx),
|
|
3380
|
+
tx.object(CLOCK_ID3)
|
|
3381
|
+
]
|
|
3382
|
+
});
|
|
3383
|
+
return tx;
|
|
3347
3384
|
}
|
|
3348
3385
|
async function getJob(client, jobId) {
|
|
3349
3386
|
const resp = await client.core.getObject({ objectId: jobId, include: { json: true } }).catch((e) => {
|
|
@@ -3432,6 +3469,10 @@ var PROVEN_MIN_REVIEWS = 3;
|
|
|
3432
3469
|
var PROVEN_MIN_AVG_STARS_X10 = 40;
|
|
3433
3470
|
var REVIEW_MIN_STARS = 1;
|
|
3434
3471
|
var REVIEW_MAX_STARS = 5;
|
|
3472
|
+
var SELLER_LEVEL_ACTIVE_CAPS = [4, 10, 20, 30];
|
|
3473
|
+
var NO_DELIVERY_REGRESSION_FLOOR = 3;
|
|
3474
|
+
var LEVEL4_MIN_REVIEWS = 20;
|
|
3475
|
+
var LEVEL4_MAX_NO_DELIVERY = 2;
|
|
3435
3476
|
function boardIdOrThrow(boardId) {
|
|
3436
3477
|
const id = boardId ?? A2A_SCORE_BOARD_ID;
|
|
3437
3478
|
if (!id) {
|
|
@@ -3477,11 +3518,12 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
3477
3518
|
}
|
|
3478
3519
|
const reviewCount = Number(json.review_count ?? 0);
|
|
3479
3520
|
const starsSum = Number(json.stars_sum ?? 0);
|
|
3480
|
-
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected] = await Promise.all([
|
|
3521
|
+
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected, activeSellerJobs] = await Promise.all([
|
|
3481
3522
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V7_ID, "DistinctCountKey"),
|
|
3482
3523
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "RejectedAfterDeliveryKey"),
|
|
3483
3524
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "NoDeliveryKey"),
|
|
3484
|
-
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey")
|
|
3525
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey"),
|
|
3526
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V10_ID, "ActiveSellerJobsKey")
|
|
3485
3527
|
]);
|
|
3486
3528
|
return {
|
|
3487
3529
|
id: scoreId,
|
|
@@ -3492,7 +3534,8 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
3492
3534
|
distinctBuyers,
|
|
3493
3535
|
rejectedAfterDelivery,
|
|
3494
3536
|
noDelivery,
|
|
3495
|
-
asBuyerRejected
|
|
3537
|
+
asBuyerRejected,
|
|
3538
|
+
activeSellerJobs
|
|
3496
3539
|
};
|
|
3497
3540
|
}
|
|
3498
3541
|
function buildCreateEmptyScoreTx({
|
|
@@ -3537,6 +3580,51 @@ function claimPolicyRequirement(claimPolicy) {
|
|
|
3537
3580
|
}
|
|
3538
3581
|
return "Anyone can claim (active Agent ID required).";
|
|
3539
3582
|
}
|
|
3583
|
+
function sellerLevel(score) {
|
|
3584
|
+
if (!score) return 1;
|
|
3585
|
+
const provenAvg = score.distinctBuyers >= PROVEN_MIN_REVIEWS && score.starsSum * 10 >= score.reviewCount * PROVEN_MIN_AVG_STARS_X10;
|
|
3586
|
+
if (provenAvg) {
|
|
3587
|
+
return score.reviewCount >= LEVEL4_MIN_REVIEWS && score.noDelivery <= LEVEL4_MAX_NO_DELIVERY ? 4 : 3;
|
|
3588
|
+
}
|
|
3589
|
+
return score.distinctBuyers >= PROVEN_MIN_REVIEWS ? 2 : 1;
|
|
3590
|
+
}
|
|
3591
|
+
function effectiveSellerLevel(score) {
|
|
3592
|
+
if (!score) return 1;
|
|
3593
|
+
if (score.noDelivery >= NO_DELIVERY_REGRESSION_FLOOR) return 1;
|
|
3594
|
+
return sellerLevel(score);
|
|
3595
|
+
}
|
|
3596
|
+
function activeCapForLevel(level) {
|
|
3597
|
+
return SELLER_LEVEL_ACTIVE_CAPS[level - 1];
|
|
3598
|
+
}
|
|
3599
|
+
function meetsMinSellerLevel(score, minLevel) {
|
|
3600
|
+
if (minLevel <= 0) return true;
|
|
3601
|
+
return effectiveSellerLevel(score) >= minLevel;
|
|
3602
|
+
}
|
|
3603
|
+
function sellerLevelLabel(level) {
|
|
3604
|
+
return level >= 1 && level <= 4 ? `Level ${level}` : `Level ? (${level})`;
|
|
3605
|
+
}
|
|
3606
|
+
function preflightClaimOpening(score, opening) {
|
|
3607
|
+
if (!meetsClaimPolicy(score, opening.claimPolicy)) {
|
|
3608
|
+
return { valid: false, error: claimPolicyRequirement(opening.claimPolicy) };
|
|
3609
|
+
}
|
|
3610
|
+
const level = effectiveSellerLevel(score);
|
|
3611
|
+
const cap = activeCapForLevel(level);
|
|
3612
|
+
const active = score?.activeSellerJobs ?? 0;
|
|
3613
|
+
if (active >= cap) {
|
|
3614
|
+
return {
|
|
3615
|
+
valid: false,
|
|
3616
|
+
error: `Active: ${active}/${cap} \u2014 ${sellerLevelLabel(level)} caps in-flight claimed jobs at ${cap}. Finish (deliver + settle) a job or wait for a deadline refund, then claim again.`
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3619
|
+
const minLevel = opening.minSellerLevel ?? 0;
|
|
3620
|
+
if (!meetsMinSellerLevel(score, minLevel)) {
|
|
3621
|
+
return {
|
|
3622
|
+
valid: false,
|
|
3623
|
+
error: `This opening needs ${sellerLevelLabel(minLevel)}+ \u2014 this wallet is ${sellerLevelLabel(level)}. Level 2 = reviews from ${PROVEN_MIN_REVIEWS}+ distinct buyers; Level 3 adds a 4.0\u2605 average; reliability (no-shows) can regress a level. Earn it on openings without a floor first.`
|
|
3624
|
+
};
|
|
3625
|
+
}
|
|
3626
|
+
return { valid: true };
|
|
3627
|
+
}
|
|
3540
3628
|
function assertStars(stars) {
|
|
3541
3629
|
if (!Number.isInteger(stars) || stars < REVIEW_MIN_STARS || stars > REVIEW_MAX_STARS) {
|
|
3542
3630
|
throw new T2000Error("INVALID_INPUT", "Stars must be an integer 1-5.");
|
|
@@ -4799,4 +4887,4 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
|
4799
4887
|
// src/index.ts
|
|
4800
4888
|
init_preflight();
|
|
4801
4889
|
|
|
4802
|
-
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_ESCROW_PACKAGE_V7_ID, A2A_ESCROW_PACKAGE_V8_ID, A2A_SCORE_BOARD_ID, AGENT_CATEGORIES, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, CommerceClient, 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, MAX_SLUG_LENGTH, MAX_TIER_BASE_LENGTH, 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, SERVICE_SLUG_RE, SERVICE_TIERS, 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, agentResolveUrl, approxUsdValue, assertAllowedAsset, assertBuyerRequirements, assertLimitConfig, buildAddLeafTx, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateEmptyScoreTx, 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, createPackage, customHireEnvelope, dailySpentToday, deriveAgentScoreId, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, endpointIssueLines, ensureCategory, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchChallengeNonce, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getAgentProfile, getAgentScore, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getOpenJob, getOpening, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, invalidSendAssetMessage, isAllowedAsset, isCetusRouteFresh, isCustomHireEnvelope, isInRegistry, jobActionsFor, keypairFromPrivateKey, listEndpoint, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, meetsClaimPolicy, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, packageBaseFromName, packageBaseSlug, packageTierSlugs, parseAgentCategory, parseServiceTierSlug, parseSuiRpcTx, payWithX402, planPackage, postOpenJob, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, profileChallengeMessage, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, registerAgent, removeEndpoint, reportX402Activity, resolveAddressToSuinsViaRpc, resolveAgentRef, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, retireService, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, serviceChallengeMessage, servicePayloadSha256, serviceUpsertPayload, setLimits, setSponsoredTxGuard, signChallenge, simulateTransaction, slugify, slugifyLoner, slugifyUnbounded, stableToRaw, submitJobReview, suiToMist, throwIfSimulationFailed, trimDashes, truncateAddress, updateProfile, upsertService, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, walletExists, writeLimitsFile };
|
|
4890
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_LATEST_PACKAGE_ID, A2A_ESCROW_OPENING_PACKAGE_ID, A2A_ESCROW_PACKAGE_ID, A2A_ESCROW_PACKAGE_V10_ID, A2A_ESCROW_PACKAGE_V2_ID, A2A_ESCROW_PACKAGE_V3_ID, A2A_ESCROW_PACKAGE_V6_ID, A2A_ESCROW_PACKAGE_V7_ID, A2A_ESCROW_PACKAGE_V8_ID, A2A_SCORE_BOARD_ID, AGENT_CATEGORIES, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, CommerceClient, 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, LEVEL4_MAX_NO_DELIVERY, LEVEL4_MIN_REVIEWS, 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, MAX_SLUG_LENGTH, MAX_TIER_BASE_LENGTH, MIN_JOB_USDC, MIST_PER_SUI, NAVX_TYPE, NO_DELIVERY_REGRESSION_FLOOR, 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, SELLER_LEVEL_ACTIVE_CAPS, SENDABLE_ASSETS, SERVICE_SLUG_RE, SERVICE_TIERS, 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, activeCapForLevel, addSendToTx, addSwapToTx, agentResolveUrl, approxUsdValue, assertAllowedAsset, assertBuyerRequirements, assertLimitConfig, buildAddLeafTx, buildCancelOpeningTx, buildClaimOpeningTx, buildCreateEmptyScoreTx, 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, createPackage, customHireEnvelope, dailySpentToday, deriveAgentScoreId, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, effectiveSellerLevel, endpointIssueLines, ensureCategory, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchChallengeNonce, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getAgentProfile, getAgentScore, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getOpenJob, getOpening, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, invalidSendAssetMessage, isAllowedAsset, isCetusRouteFresh, isCustomHireEnvelope, isInRegistry, jobActionsFor, keypairFromPrivateKey, listEndpoint, listModels, listOpenJobs, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, meetsClaimPolicy, meetsMinSellerLevel, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, packageBaseFromName, packageBaseSlug, packageTierSlugs, parseAgentCategory, parseServiceTierSlug, parseSuiRpcTx, payWithX402, planPackage, postOpenJob, preflightClaimOpening, preflightCreateJob, preflightCreateOpening, preflightFail, preflightPay, preflightSend, preflightSwap, probeX402, profileChallengeMessage, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, refundOpenJob, registerAgent, removeEndpoint, reportX402Activity, resolveAddressToSuinsViaRpc, resolveAgentRef, resolveCreatedObjectId, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, retireService, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, sellerLevel, sellerLevelLabel, serializeCetusRoute, serviceChallengeMessage, servicePayloadSha256, serviceUpsertPayload, setLimits, setSponsoredTxGuard, signChallenge, simulateTransaction, slugify, slugifyLoner, slugifyUnbounded, stableToRaw, submitJobReview, suiToMist, throwIfSimulationFailed, trimDashes, truncateAddress, updateProfile, upsertService, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, walletExists, writeLimitsFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t2000/sdk",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.38.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20"
|
|
6
6
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@phala/dcap-qvl": "^0.5.2",
|
|
56
56
|
"bn.js": "^5.2.1",
|
|
57
57
|
"eventemitter3": "^5",
|
|
58
|
-
"@t2000/sui-x402": "10.
|
|
58
|
+
"@t2000/sui-x402": "10.38.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/bn.js": "^5.1.5",
|