@t2000/sdk 10.37.2 → 10.38.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 +105 -22
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +96 -23
- 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 +149 -31
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +139 -32
- package/package.json +2 -2
package/dist/browser.cjs
CHANGED
|
@@ -237,6 +237,14 @@ __export(coinSelection_exports, {
|
|
|
237
237
|
selectAndSplitCoin: () => selectAndSplitCoin,
|
|
238
238
|
selectSuiCoin: () => selectSuiCoin
|
|
239
239
|
});
|
|
240
|
+
function formatRawAmount(raw, coinType) {
|
|
241
|
+
const decimals = getDecimalsForCoinType(coinType);
|
|
242
|
+
const dp = Math.min(decimals, 8);
|
|
243
|
+
const s = raw.toString().padStart(decimals + 1, "0");
|
|
244
|
+
const whole = s.slice(0, s.length - decimals);
|
|
245
|
+
const frac = s.slice(s.length - decimals).slice(0, dp).replace(/0+$/, "");
|
|
246
|
+
return frac ? `${whole}.${frac}` : whole;
|
|
247
|
+
}
|
|
240
248
|
async function fetchAllCoins(client, owner, coinType) {
|
|
241
249
|
const [balance, ids] = await Promise.all([
|
|
242
250
|
client.core.getBalance({ owner, coinType }),
|
|
@@ -269,15 +277,25 @@ async function selectAndSplitCoin(tx, client, owner, coinType, amount, options =
|
|
|
269
277
|
}
|
|
270
278
|
const balanceResp = await client.core.getBalance({ owner, coinType });
|
|
271
279
|
const totalBalance = BigInt(balanceResp.balance.balance);
|
|
280
|
+
const symbol = resolveSymbol(coinType);
|
|
272
281
|
if (totalBalance === 0n) {
|
|
273
|
-
throw new exports.T2000Error(
|
|
282
|
+
throw new exports.T2000Error(
|
|
283
|
+
"INSUFFICIENT_BALANCE",
|
|
284
|
+
amount === "all" ? `No ${symbol} in this wallet.` : `Insufficient ${symbol}: need ${formatRawAmount(amount, coinType)}, the wallet holds 0.`,
|
|
285
|
+
{ available: "0", required: amount === "all" ? "0" : amount.toString(), coinType }
|
|
286
|
+
);
|
|
274
287
|
}
|
|
275
288
|
const allowSwapAll = options.allowSwapAll ?? true;
|
|
276
289
|
if (amount !== "all" && amount > totalBalance && !allowSwapAll) {
|
|
277
|
-
throw new exports.T2000Error(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
290
|
+
throw new exports.T2000Error(
|
|
291
|
+
"INSUFFICIENT_BALANCE",
|
|
292
|
+
`Insufficient ${symbol}: need ${formatRawAmount(amount, coinType)}, the wallet holds ${formatRawAmount(totalBalance, coinType)}.`,
|
|
293
|
+
{
|
|
294
|
+
available: totalBalance.toString(),
|
|
295
|
+
required: amount.toString(),
|
|
296
|
+
coinType
|
|
297
|
+
}
|
|
298
|
+
);
|
|
281
299
|
}
|
|
282
300
|
const requested = amount === "all" ? totalBalance : amount;
|
|
283
301
|
const swapAll = amount === "all" || requested >= totalBalance;
|
|
@@ -292,7 +310,7 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
292
310
|
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
293
311
|
throw new exports.T2000Error(
|
|
294
312
|
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
295
|
-
`Not enough ${coinType} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
313
|
+
`Not enough ${resolveSymbol(coinType)} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
296
314
|
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
297
315
|
);
|
|
298
316
|
}
|
|
@@ -357,7 +375,7 @@ function buildCoinToAddressBalanceMigration(args) {
|
|
|
357
375
|
migratedRaw += c.balance;
|
|
358
376
|
}
|
|
359
377
|
if (migratedRaw < minAmount) {
|
|
360
|
-
throw new exports.T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
|
|
378
|
+
throw new exports.T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${resolveSymbol(coinType)} coin objects to migrate`, {
|
|
361
379
|
available: migratedRaw.toString(),
|
|
362
380
|
required: minAmount.toString()
|
|
363
381
|
});
|
|
@@ -383,6 +401,7 @@ async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, me
|
|
|
383
401
|
var init_coinSelection = __esm({
|
|
384
402
|
"src/wallet/coinSelection.ts"() {
|
|
385
403
|
init_errors();
|
|
404
|
+
init_token_registry();
|
|
386
405
|
}
|
|
387
406
|
});
|
|
388
407
|
|
|
@@ -1332,10 +1351,11 @@ init_coinSelection();
|
|
|
1332
1351
|
init_errors();
|
|
1333
1352
|
init_token_registry();
|
|
1334
1353
|
init_coinSelection();
|
|
1335
|
-
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "
|
|
1354
|
+
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
1336
1355
|
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;
|
|
1337
1356
|
var A2A_ESCROW_PACKAGE_V7_ID = "0x4249f0b242c47c7baf0c37304365bc4bbe769bcedf11f3525e84682d59a3b23e";
|
|
1338
1357
|
var A2A_ESCROW_PACKAGE_V8_ID = "0x1595b80bc05a03607f3908702c866ca63cf961025b4263b5ecbe419e07f8ff31";
|
|
1358
|
+
var A2A_ESCROW_PACKAGE_V10_ID = process.env.A2A_ESCROW_PACKAGE_V10_ID ?? "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
1339
1359
|
var OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
|
|
1340
1360
|
var OPENING_CLAIM_POLICY_PROVEN = 1;
|
|
1341
1361
|
var OPENING_CLAIM_POLICY_PROVEN_4STAR = 2;
|
|
@@ -1461,15 +1481,6 @@ async function buildCreateJobTx({
|
|
|
1461
1481
|
});
|
|
1462
1482
|
return tx;
|
|
1463
1483
|
}
|
|
1464
|
-
function jobCall(jobId, fn) {
|
|
1465
|
-
const tx = new transactions.Transaction();
|
|
1466
|
-
tx.moveCall({
|
|
1467
|
-
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::${MODULE}::${fn}`,
|
|
1468
|
-
typeArguments: [exports.USDC_TYPE],
|
|
1469
|
-
arguments: [tx.object(jobId), feeConfigArg(tx), tx.object(CLOCK_ID2)]
|
|
1470
|
-
});
|
|
1471
|
-
return tx;
|
|
1472
|
-
}
|
|
1473
1484
|
function buildRejectJobTx(jobId, v2) {
|
|
1474
1485
|
const tx = new transactions.Transaction();
|
|
1475
1486
|
tx.moveCall({
|
|
@@ -1520,8 +1531,19 @@ function buildDeliverJobTx(jobId, deliveryHash) {
|
|
|
1520
1531
|
});
|
|
1521
1532
|
return tx;
|
|
1522
1533
|
}
|
|
1523
|
-
function buildReleaseJobTx(jobId) {
|
|
1524
|
-
|
|
1534
|
+
function buildReleaseJobTx(jobId, v2) {
|
|
1535
|
+
const tx = new transactions.Transaction();
|
|
1536
|
+
tx.moveCall({
|
|
1537
|
+
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::reputation::release_v2`,
|
|
1538
|
+
typeArguments: [exports.USDC_TYPE],
|
|
1539
|
+
arguments: [
|
|
1540
|
+
tx.object(jobId),
|
|
1541
|
+
tx.object(v2.sellerScoreId),
|
|
1542
|
+
feeConfigArg(tx),
|
|
1543
|
+
tx.object(CLOCK_ID2)
|
|
1544
|
+
]
|
|
1545
|
+
});
|
|
1546
|
+
return tx;
|
|
1525
1547
|
}
|
|
1526
1548
|
async function getJob(client, jobId) {
|
|
1527
1549
|
const resp = await client.core.getObject({ objectId: jobId, include: { json: true } }).catch((e) => {
|
|
@@ -1609,6 +1631,10 @@ var PROVEN_MIN_REVIEWS = 3;
|
|
|
1609
1631
|
var PROVEN_MIN_AVG_STARS_X10 = 40;
|
|
1610
1632
|
var REVIEW_MIN_STARS = 1;
|
|
1611
1633
|
var REVIEW_MAX_STARS = 5;
|
|
1634
|
+
var SELLER_LEVEL_ACTIVE_CAPS = [4, 10, 20, 30];
|
|
1635
|
+
var NO_DELIVERY_REGRESSION_FLOOR = 3;
|
|
1636
|
+
var LEVEL4_MIN_REVIEWS = 20;
|
|
1637
|
+
var LEVEL4_MAX_NO_DELIVERY = 2;
|
|
1612
1638
|
function boardIdOrThrow(boardId) {
|
|
1613
1639
|
const id = boardId ?? A2A_SCORE_BOARD_ID;
|
|
1614
1640
|
if (!id) {
|
|
@@ -1654,11 +1680,12 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
1654
1680
|
}
|
|
1655
1681
|
const reviewCount = Number(json.review_count ?? 0);
|
|
1656
1682
|
const starsSum = Number(json.stars_sum ?? 0);
|
|
1657
|
-
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected] = await Promise.all([
|
|
1683
|
+
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected, activeSellerJobs] = await Promise.all([
|
|
1658
1684
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V7_ID, "DistinctCountKey"),
|
|
1659
1685
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "RejectedAfterDeliveryKey"),
|
|
1660
1686
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "NoDeliveryKey"),
|
|
1661
|
-
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey")
|
|
1687
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey"),
|
|
1688
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V10_ID, "ActiveSellerJobsKey")
|
|
1662
1689
|
]);
|
|
1663
1690
|
return {
|
|
1664
1691
|
id: scoreId,
|
|
@@ -1669,7 +1696,8 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
1669
1696
|
distinctBuyers,
|
|
1670
1697
|
rejectedAfterDelivery,
|
|
1671
1698
|
noDelivery,
|
|
1672
|
-
asBuyerRejected
|
|
1699
|
+
asBuyerRejected,
|
|
1700
|
+
activeSellerJobs
|
|
1673
1701
|
};
|
|
1674
1702
|
}
|
|
1675
1703
|
function meetsClaimPolicy(score, claimPolicy) {
|
|
@@ -1697,6 +1725,51 @@ function claimPolicyRequirement(claimPolicy) {
|
|
|
1697
1725
|
}
|
|
1698
1726
|
return "Anyone can claim (active Agent ID required).";
|
|
1699
1727
|
}
|
|
1728
|
+
function sellerLevel(score) {
|
|
1729
|
+
if (!score) return 1;
|
|
1730
|
+
const provenAvg = score.distinctBuyers >= PROVEN_MIN_REVIEWS && score.starsSum * 10 >= score.reviewCount * PROVEN_MIN_AVG_STARS_X10;
|
|
1731
|
+
if (provenAvg) {
|
|
1732
|
+
return score.reviewCount >= LEVEL4_MIN_REVIEWS && score.noDelivery <= LEVEL4_MAX_NO_DELIVERY ? 4 : 3;
|
|
1733
|
+
}
|
|
1734
|
+
return score.distinctBuyers >= PROVEN_MIN_REVIEWS ? 2 : 1;
|
|
1735
|
+
}
|
|
1736
|
+
function effectiveSellerLevel(score) {
|
|
1737
|
+
if (!score) return 1;
|
|
1738
|
+
if (score.noDelivery >= NO_DELIVERY_REGRESSION_FLOOR) return 1;
|
|
1739
|
+
return sellerLevel(score);
|
|
1740
|
+
}
|
|
1741
|
+
function activeCapForLevel(level) {
|
|
1742
|
+
return SELLER_LEVEL_ACTIVE_CAPS[level - 1];
|
|
1743
|
+
}
|
|
1744
|
+
function meetsMinSellerLevel(score, minLevel) {
|
|
1745
|
+
if (minLevel <= 0) return true;
|
|
1746
|
+
return effectiveSellerLevel(score) >= minLevel;
|
|
1747
|
+
}
|
|
1748
|
+
function sellerLevelLabel(level) {
|
|
1749
|
+
return level >= 1 && level <= 4 ? `Level ${level}` : `Level ? (${level})`;
|
|
1750
|
+
}
|
|
1751
|
+
function preflightClaimOpening(score, opening) {
|
|
1752
|
+
if (!meetsClaimPolicy(score, opening.claimPolicy)) {
|
|
1753
|
+
return { valid: false, error: claimPolicyRequirement(opening.claimPolicy) };
|
|
1754
|
+
}
|
|
1755
|
+
const level = effectiveSellerLevel(score);
|
|
1756
|
+
const cap = activeCapForLevel(level);
|
|
1757
|
+
const active = score?.activeSellerJobs ?? 0;
|
|
1758
|
+
if (active >= cap) {
|
|
1759
|
+
return {
|
|
1760
|
+
valid: false,
|
|
1761
|
+
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.`
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
const minLevel = opening.minSellerLevel ?? 0;
|
|
1765
|
+
if (!meetsMinSellerLevel(score, minLevel)) {
|
|
1766
|
+
return {
|
|
1767
|
+
valid: false,
|
|
1768
|
+
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.`
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
return { valid: true };
|
|
1772
|
+
}
|
|
1700
1773
|
|
|
1701
1774
|
// src/commerce.ts
|
|
1702
1775
|
var DEFAULT_COMMERCE_API_BASE = "https://api.t2000.ai/v1";
|
|
@@ -1799,11 +1872,14 @@ exports.JOB_STATES = JOB_STATES;
|
|
|
1799
1872
|
exports.KNOWN_TARGETS = KNOWN_TARGETS;
|
|
1800
1873
|
exports.KeypairSigner = KeypairSigner;
|
|
1801
1874
|
exports.LABEL_PATTERNS = LABEL_PATTERNS;
|
|
1875
|
+
exports.LEVEL4_MAX_NO_DELIVERY = LEVEL4_MAX_NO_DELIVERY;
|
|
1876
|
+
exports.LEVEL4_MIN_REVIEWS = LEVEL4_MIN_REVIEWS;
|
|
1802
1877
|
exports.MAX_DELIVER_HORIZON_MS = MAX_DELIVER_HORIZON_MS;
|
|
1803
1878
|
exports.MAX_JOB_USDC = MAX_JOB_USDC;
|
|
1804
1879
|
exports.MAX_REVIEW_WINDOW_MS = MAX_REVIEW_WINDOW_MS;
|
|
1805
1880
|
exports.MIN_JOB_USDC = MIN_JOB_USDC;
|
|
1806
1881
|
exports.MIST_PER_SUI = MIST_PER_SUI;
|
|
1882
|
+
exports.NO_DELIVERY_REGRESSION_FLOOR = NO_DELIVERY_REGRESSION_FLOOR;
|
|
1807
1883
|
exports.OPENING_CLAIM_POLICIES = OPENING_CLAIM_POLICIES;
|
|
1808
1884
|
exports.OPENING_CLAIM_POLICY_ANY_ACTIVE = OPENING_CLAIM_POLICY_ANY_ACTIVE;
|
|
1809
1885
|
exports.OPENING_CLAIM_POLICY_PROVEN = OPENING_CLAIM_POLICY_PROVEN;
|
|
@@ -1815,12 +1891,14 @@ exports.PROVEN_MIN_AVG_STARS_X10 = PROVEN_MIN_AVG_STARS_X10;
|
|
|
1815
1891
|
exports.PROVEN_MIN_REVIEWS = PROVEN_MIN_REVIEWS;
|
|
1816
1892
|
exports.REVIEW_MAX_STARS = REVIEW_MAX_STARS;
|
|
1817
1893
|
exports.REVIEW_MIN_STARS = REVIEW_MIN_STARS;
|
|
1894
|
+
exports.SELLER_LEVEL_ACTIVE_CAPS = SELLER_LEVEL_ACTIVE_CAPS;
|
|
1818
1895
|
exports.STABLE_ASSETS = STABLE_ASSETS;
|
|
1819
1896
|
exports.SUI_DECIMALS = SUI_DECIMALS;
|
|
1820
1897
|
exports.SUPPORTED_ASSETS = SUPPORTED_ASSETS;
|
|
1821
1898
|
exports.T2000_OVERLAY_FEE_WALLET = T2000_OVERLAY_FEE_WALLET;
|
|
1822
1899
|
exports.USDC_DECIMALS = USDC_DECIMALS;
|
|
1823
1900
|
exports.ZkLoginSigner = ZkLoginSigner;
|
|
1901
|
+
exports.activeCapForLevel = activeCapForLevel;
|
|
1824
1902
|
exports.buildCreateJobTx = buildCreateJobTx;
|
|
1825
1903
|
exports.buildDeliverJobTx = buildDeliverJobTx;
|
|
1826
1904
|
exports.buildRefundJobTx = buildRefundJobTx;
|
|
@@ -1837,6 +1915,7 @@ exports.classifyLabel = classifyLabel;
|
|
|
1837
1915
|
exports.classifySendAsset = classifySendAsset;
|
|
1838
1916
|
exports.classifyTransaction = classifyTransaction;
|
|
1839
1917
|
exports.deriveAgentScoreId = deriveAgentScoreId;
|
|
1918
|
+
exports.effectiveSellerLevel = effectiveSellerLevel;
|
|
1840
1919
|
exports.executeTx = executeTx;
|
|
1841
1920
|
exports.extractAllUserLegs = extractAllUserLegs;
|
|
1842
1921
|
exports.extractTransferDetails = extractTransferDetails;
|
|
@@ -1860,9 +1939,11 @@ exports.listServices = listServices;
|
|
|
1860
1939
|
exports.mapMoveAbortCode = mapMoveAbortCode;
|
|
1861
1940
|
exports.mapWalletError = mapWalletError;
|
|
1862
1941
|
exports.meetsClaimPolicy = meetsClaimPolicy;
|
|
1942
|
+
exports.meetsMinSellerLevel = meetsMinSellerLevel;
|
|
1863
1943
|
exports.mistToSui = mistToSui;
|
|
1864
1944
|
exports.parseSuiRpcTx = parseSuiRpcTx;
|
|
1865
1945
|
exports.payWithX402 = payWithX402;
|
|
1946
|
+
exports.preflightClaimOpening = preflightClaimOpening;
|
|
1866
1947
|
exports.preflightCreateJob = preflightCreateJob;
|
|
1867
1948
|
exports.preflightFail = preflightFail;
|
|
1868
1949
|
exports.preflightPay = preflightPay;
|
|
@@ -1875,6 +1956,8 @@ exports.refineLendingLabel = refineLendingLabel;
|
|
|
1875
1956
|
exports.reportX402Activity = reportX402Activity;
|
|
1876
1957
|
exports.resolveSymbol = resolveSymbol;
|
|
1877
1958
|
exports.resolveTokenType = resolveTokenType;
|
|
1959
|
+
exports.sellerLevel = sellerLevel;
|
|
1960
|
+
exports.sellerLevelLabel = sellerLevelLabel;
|
|
1878
1961
|
exports.stableToRaw = stableToRaw;
|
|
1879
1962
|
exports.suiToMist = suiToMist;
|
|
1880
1963
|
exports.toBase64 = toBase64;
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, c as AgentScore, B as BalanceResponse, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, i as DEFAULT_NETWORK, j as DepositInfo, E as ETH_TYPE, k as ExtractedTransfer, 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, M as MANIFEST_TYPE,
|
|
1
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, c as AgentScore, B as BalanceResponse, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, i as DEFAULT_NETWORK, j as DepositInfo, E as ETH_TYPE, k as ExtractedTransfer, 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, M as MANIFEST_TYPE, t as MAX_DELIVER_HORIZON_MS, u as MAX_JOB_USDC, 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, P as OVERLAY_FEE_RATE, Q as OverlayFeeConfig, R as PREFLIGHT_MAX_AMOUNT, S as PREFLIGHT_OK, T as PROVEN_MIN_AVG_STARS_X10, U as PROVEN_MIN_REVIEWS, V as PayOptions, W as PayResult, X as PreflightResult, Y as REVIEW_MAX_STARS, Z as REVIEW_MIN_STARS, _ as SELLER_LEVEL_ACTIVE_CAPS, $ as STABLE_ASSETS, a0 as SUI_DECIMALS, a1 as SUI_TYPE, a2 as SUPPORTED_ASSETS, a3 as SellerLevel, a4 as SendAssetClass, a5 as SendResult, a6 as ServiceListing, a7 as SimulationResult, a8 as StableAsset, a9 as SuiHolding, aa as SuiRpcTxBlock, ab as SupportedAsset, ac as SwapRouteResult, ad as T2000Error, ae as T2000ErrorCode, af as T2000ErrorData, ag as T2000_OVERLAY_FEE_WALLET, ah as TOKEN_MAP, ai as TransactionLeg, aj as TransactionRecord, ak as TransactionSigner, 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, au as ZkLoginProof, av as ZkLoginSigner, aw as activeCapForLevel, ax as buildCreateJobTx, ay as buildDeliverJobTx, az as buildRefundJobTx, aA as buildRejectJobTx, aB as buildReleaseJobTx, aC as buildSendTx, 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, aN as effectiveSellerLevel, aO as executeTx, aP as extractAllUserLegs, aQ as extractTransferDetails, aR as extractTxCommands, aS as extractTxSender, aT as fallbackLabel, aU as fetchService, aV as findSwapRoute, aW as formatAssetAmount, aX as formatSui, aY as formatUsd, aZ as getAgentScore, a_ as getDecimals, a$ as getDecimalsForCoinType, b0 as getJob, b1 as getJobSpec, b2 as invalidSendAssetMessage, b3 as jobActionsFor, b4 as listServices, b5 as mapMoveAbortCode, b6 as mapWalletError, b7 as meetsClaimPolicy, b8 as meetsMinSellerLevel, b9 as mistToSui, ba as parseSuiRpcTx, bb as payWithX402, bc as preflightClaimOpening, bd as preflightCreateJob, be as preflightFail, bf as preflightPay, bg as preflightSend, bh as preflightSwap, bi as putJobSpec, bj as rawToStable, bk as rawToUsdc, bl as refineLendingLabel, bm as reportX402Activity, bn as resolveSymbol, bo as resolveTokenType, bp as sellerLevel, bq as sellerLevelLabel, br as stableToRaw, bs as suiToMist, bt as truncateAddress, bu as usdcToRaw, bv as validateAddress, bw as verifyJobForSeller } from './commerce-D14qzqAV.cjs';
|
|
2
2
|
import '@mysten/sui/keypairs/ed25519';
|
|
3
3
|
import '@mysten/sui/grpc';
|
|
4
4
|
import '@mysten/sui/client';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, c as AgentScore, B as BalanceResponse, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, i as DEFAULT_NETWORK, j as DepositInfo, E as ETH_TYPE, k as ExtractedTransfer, 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, M as MANIFEST_TYPE,
|
|
1
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, b as ActivityReportConfig, c as AgentScore, B as BalanceResponse, C as CLOCK_ID, d as COIN_REGISTRY, e as ClassifyBalanceChange, f as ClassifyResult, g as CoinMeta, D as DEFAULT_ACTIVITY_REPORT_URL, h as DEFAULT_COMMERCE_API_BASE, i as DEFAULT_NETWORK, j as DepositInfo, E as ETH_TYPE, k as ExtractedTransfer, 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, M as MANIFEST_TYPE, t as MAX_DELIVER_HORIZON_MS, u as MAX_JOB_USDC, 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, P as OVERLAY_FEE_RATE, Q as OverlayFeeConfig, R as PREFLIGHT_MAX_AMOUNT, S as PREFLIGHT_OK, T as PROVEN_MIN_AVG_STARS_X10, U as PROVEN_MIN_REVIEWS, V as PayOptions, W as PayResult, X as PreflightResult, Y as REVIEW_MAX_STARS, Z as REVIEW_MIN_STARS, _ as SELLER_LEVEL_ACTIVE_CAPS, $ as STABLE_ASSETS, a0 as SUI_DECIMALS, a1 as SUI_TYPE, a2 as SUPPORTED_ASSETS, a3 as SellerLevel, a4 as SendAssetClass, a5 as SendResult, a6 as ServiceListing, a7 as SimulationResult, a8 as StableAsset, a9 as SuiHolding, aa as SuiRpcTxBlock, ab as SupportedAsset, ac as SwapRouteResult, ad as T2000Error, ae as T2000ErrorCode, af as T2000ErrorData, ag as T2000_OVERLAY_FEE_WALLET, ah as TOKEN_MAP, ai as TransactionLeg, aj as TransactionRecord, ak as TransactionSigner, 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, au as ZkLoginProof, av as ZkLoginSigner, aw as activeCapForLevel, ax as buildCreateJobTx, ay as buildDeliverJobTx, az as buildRefundJobTx, aA as buildRejectJobTx, aB as buildReleaseJobTx, aC as buildSendTx, 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, aN as effectiveSellerLevel, aO as executeTx, aP as extractAllUserLegs, aQ as extractTransferDetails, aR as extractTxCommands, aS as extractTxSender, aT as fallbackLabel, aU as fetchService, aV as findSwapRoute, aW as formatAssetAmount, aX as formatSui, aY as formatUsd, aZ as getAgentScore, a_ as getDecimals, a$ as getDecimalsForCoinType, b0 as getJob, b1 as getJobSpec, b2 as invalidSendAssetMessage, b3 as jobActionsFor, b4 as listServices, b5 as mapMoveAbortCode, b6 as mapWalletError, b7 as meetsClaimPolicy, b8 as meetsMinSellerLevel, b9 as mistToSui, ba as parseSuiRpcTx, bb as payWithX402, bc as preflightClaimOpening, bd as preflightCreateJob, be as preflightFail, bf as preflightPay, bg as preflightSend, bh as preflightSwap, bi as putJobSpec, bj as rawToStable, bk as rawToUsdc, bl as refineLendingLabel, bm as reportX402Activity, bn as resolveSymbol, bo as resolveTokenType, bp as sellerLevel, bq as sellerLevelLabel, br as stableToRaw, bs as suiToMist, bt as truncateAddress, bu as usdcToRaw, bv as validateAddress, bw as verifyJobForSeller } from './commerce-D14qzqAV.js';
|
|
2
2
|
import '@mysten/sui/keypairs/ed25519';
|
|
3
3
|
import '@mysten/sui/grpc';
|
|
4
4
|
import '@mysten/sui/client';
|
package/dist/browser.js
CHANGED
|
@@ -235,6 +235,14 @@ __export(coinSelection_exports, {
|
|
|
235
235
|
selectAndSplitCoin: () => selectAndSplitCoin,
|
|
236
236
|
selectSuiCoin: () => selectSuiCoin
|
|
237
237
|
});
|
|
238
|
+
function formatRawAmount(raw, coinType) {
|
|
239
|
+
const decimals = getDecimalsForCoinType(coinType);
|
|
240
|
+
const dp = Math.min(decimals, 8);
|
|
241
|
+
const s = raw.toString().padStart(decimals + 1, "0");
|
|
242
|
+
const whole = s.slice(0, s.length - decimals);
|
|
243
|
+
const frac = s.slice(s.length - decimals).slice(0, dp).replace(/0+$/, "");
|
|
244
|
+
return frac ? `${whole}.${frac}` : whole;
|
|
245
|
+
}
|
|
238
246
|
async function fetchAllCoins(client, owner, coinType) {
|
|
239
247
|
const [balance, ids] = await Promise.all([
|
|
240
248
|
client.core.getBalance({ owner, coinType }),
|
|
@@ -267,15 +275,25 @@ async function selectAndSplitCoin(tx, client, owner, coinType, amount, options =
|
|
|
267
275
|
}
|
|
268
276
|
const balanceResp = await client.core.getBalance({ owner, coinType });
|
|
269
277
|
const totalBalance = BigInt(balanceResp.balance.balance);
|
|
278
|
+
const symbol = resolveSymbol(coinType);
|
|
270
279
|
if (totalBalance === 0n) {
|
|
271
|
-
throw new T2000Error(
|
|
280
|
+
throw new T2000Error(
|
|
281
|
+
"INSUFFICIENT_BALANCE",
|
|
282
|
+
amount === "all" ? `No ${symbol} in this wallet.` : `Insufficient ${symbol}: need ${formatRawAmount(amount, coinType)}, the wallet holds 0.`,
|
|
283
|
+
{ available: "0", required: amount === "all" ? "0" : amount.toString(), coinType }
|
|
284
|
+
);
|
|
272
285
|
}
|
|
273
286
|
const allowSwapAll = options.allowSwapAll ?? true;
|
|
274
287
|
if (amount !== "all" && amount > totalBalance && !allowSwapAll) {
|
|
275
|
-
throw new T2000Error(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
288
|
+
throw new T2000Error(
|
|
289
|
+
"INSUFFICIENT_BALANCE",
|
|
290
|
+
`Insufficient ${symbol}: need ${formatRawAmount(amount, coinType)}, the wallet holds ${formatRawAmount(totalBalance, coinType)}.`,
|
|
291
|
+
{
|
|
292
|
+
available: totalBalance.toString(),
|
|
293
|
+
required: amount.toString(),
|
|
294
|
+
coinType
|
|
295
|
+
}
|
|
296
|
+
);
|
|
279
297
|
}
|
|
280
298
|
const requested = amount === "all" ? totalBalance : amount;
|
|
281
299
|
const swapAll = amount === "all" || requested >= totalBalance;
|
|
@@ -290,7 +308,7 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
290
308
|
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
291
309
|
throw new T2000Error(
|
|
292
310
|
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
293
|
-
`Not enough ${coinType} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
311
|
+
`Not enough ${resolveSymbol(coinType)} in coin objects to cover all legs of this sponsored bundle. The remaining funds are in your address balance, which sponsored transactions can't access yet.`,
|
|
294
312
|
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
295
313
|
);
|
|
296
314
|
}
|
|
@@ -355,7 +373,7 @@ function buildCoinToAddressBalanceMigration(args) {
|
|
|
355
373
|
migratedRaw += c.balance;
|
|
356
374
|
}
|
|
357
375
|
if (migratedRaw < minAmount) {
|
|
358
|
-
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
|
|
376
|
+
throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${resolveSymbol(coinType)} coin objects to migrate`, {
|
|
359
377
|
available: migratedRaw.toString(),
|
|
360
378
|
required: minAmount.toString()
|
|
361
379
|
});
|
|
@@ -381,6 +399,7 @@ async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, me
|
|
|
381
399
|
var init_coinSelection = __esm({
|
|
382
400
|
"src/wallet/coinSelection.ts"() {
|
|
383
401
|
init_errors();
|
|
402
|
+
init_token_registry();
|
|
384
403
|
}
|
|
385
404
|
});
|
|
386
405
|
|
|
@@ -1330,10 +1349,11 @@ init_coinSelection();
|
|
|
1330
1349
|
init_errors();
|
|
1331
1350
|
init_token_registry();
|
|
1332
1351
|
init_coinSelection();
|
|
1333
|
-
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "
|
|
1352
|
+
var MAINNET_A2A_ESCROW_LATEST_PACKAGE_ID = "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
1334
1353
|
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;
|
|
1335
1354
|
var A2A_ESCROW_PACKAGE_V7_ID = "0x4249f0b242c47c7baf0c37304365bc4bbe769bcedf11f3525e84682d59a3b23e";
|
|
1336
1355
|
var A2A_ESCROW_PACKAGE_V8_ID = "0x1595b80bc05a03607f3908702c866ca63cf961025b4263b5ecbe419e07f8ff31";
|
|
1356
|
+
var A2A_ESCROW_PACKAGE_V10_ID = process.env.A2A_ESCROW_PACKAGE_V10_ID ?? "0x5c90ec07da01bf885a4e65247ce98b75ab8a042cd965d30d7213856d579c4afa";
|
|
1337
1357
|
var OPENING_CLAIM_POLICY_ANY_ACTIVE = 0;
|
|
1338
1358
|
var OPENING_CLAIM_POLICY_PROVEN = 1;
|
|
1339
1359
|
var OPENING_CLAIM_POLICY_PROVEN_4STAR = 2;
|
|
@@ -1459,15 +1479,6 @@ async function buildCreateJobTx({
|
|
|
1459
1479
|
});
|
|
1460
1480
|
return tx;
|
|
1461
1481
|
}
|
|
1462
|
-
function jobCall(jobId, fn) {
|
|
1463
|
-
const tx = new Transaction();
|
|
1464
|
-
tx.moveCall({
|
|
1465
|
-
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::${MODULE}::${fn}`,
|
|
1466
|
-
typeArguments: [USDC_TYPE],
|
|
1467
|
-
arguments: [tx.object(jobId), feeConfigArg(tx), tx.object(CLOCK_ID2)]
|
|
1468
|
-
});
|
|
1469
|
-
return tx;
|
|
1470
|
-
}
|
|
1471
1482
|
function buildRejectJobTx(jobId, v2) {
|
|
1472
1483
|
const tx = new Transaction();
|
|
1473
1484
|
tx.moveCall({
|
|
@@ -1518,8 +1529,19 @@ function buildDeliverJobTx(jobId, deliveryHash) {
|
|
|
1518
1529
|
});
|
|
1519
1530
|
return tx;
|
|
1520
1531
|
}
|
|
1521
|
-
function buildReleaseJobTx(jobId) {
|
|
1522
|
-
|
|
1532
|
+
function buildReleaseJobTx(jobId, v2) {
|
|
1533
|
+
const tx = new Transaction();
|
|
1534
|
+
tx.moveCall({
|
|
1535
|
+
target: `${A2A_ESCROW_LATEST_PACKAGE_ID}::reputation::release_v2`,
|
|
1536
|
+
typeArguments: [USDC_TYPE],
|
|
1537
|
+
arguments: [
|
|
1538
|
+
tx.object(jobId),
|
|
1539
|
+
tx.object(v2.sellerScoreId),
|
|
1540
|
+
feeConfigArg(tx),
|
|
1541
|
+
tx.object(CLOCK_ID2)
|
|
1542
|
+
]
|
|
1543
|
+
});
|
|
1544
|
+
return tx;
|
|
1523
1545
|
}
|
|
1524
1546
|
async function getJob(client, jobId) {
|
|
1525
1547
|
const resp = await client.core.getObject({ objectId: jobId, include: { json: true } }).catch((e) => {
|
|
@@ -1607,6 +1629,10 @@ var PROVEN_MIN_REVIEWS = 3;
|
|
|
1607
1629
|
var PROVEN_MIN_AVG_STARS_X10 = 40;
|
|
1608
1630
|
var REVIEW_MIN_STARS = 1;
|
|
1609
1631
|
var REVIEW_MAX_STARS = 5;
|
|
1632
|
+
var SELLER_LEVEL_ACTIVE_CAPS = [4, 10, 20, 30];
|
|
1633
|
+
var NO_DELIVERY_REGRESSION_FLOOR = 3;
|
|
1634
|
+
var LEVEL4_MIN_REVIEWS = 20;
|
|
1635
|
+
var LEVEL4_MAX_NO_DELIVERY = 2;
|
|
1610
1636
|
function boardIdOrThrow(boardId) {
|
|
1611
1637
|
const id = boardId ?? A2A_SCORE_BOARD_ID;
|
|
1612
1638
|
if (!id) {
|
|
@@ -1652,11 +1678,12 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
1652
1678
|
}
|
|
1653
1679
|
const reviewCount = Number(json.review_count ?? 0);
|
|
1654
1680
|
const starsSum = Number(json.stars_sum ?? 0);
|
|
1655
|
-
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected] = await Promise.all([
|
|
1681
|
+
const [distinctBuyers, rejectedAfterDelivery, noDelivery, asBuyerRejected, activeSellerJobs] = await Promise.all([
|
|
1656
1682
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V7_ID, "DistinctCountKey"),
|
|
1657
1683
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "RejectedAfterDeliveryKey"),
|
|
1658
1684
|
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "NoDeliveryKey"),
|
|
1659
|
-
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey")
|
|
1685
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V8_ID, "AsBuyerRejectedKey"),
|
|
1686
|
+
readCounterDf(client, scoreId, A2A_ESCROW_PACKAGE_V10_ID, "ActiveSellerJobsKey")
|
|
1660
1687
|
]);
|
|
1661
1688
|
return {
|
|
1662
1689
|
id: scoreId,
|
|
@@ -1667,7 +1694,8 @@ async function getAgentScore(client, agent, boardId) {
|
|
|
1667
1694
|
distinctBuyers,
|
|
1668
1695
|
rejectedAfterDelivery,
|
|
1669
1696
|
noDelivery,
|
|
1670
|
-
asBuyerRejected
|
|
1697
|
+
asBuyerRejected,
|
|
1698
|
+
activeSellerJobs
|
|
1671
1699
|
};
|
|
1672
1700
|
}
|
|
1673
1701
|
function meetsClaimPolicy(score, claimPolicy) {
|
|
@@ -1695,6 +1723,51 @@ function claimPolicyRequirement(claimPolicy) {
|
|
|
1695
1723
|
}
|
|
1696
1724
|
return "Anyone can claim (active Agent ID required).";
|
|
1697
1725
|
}
|
|
1726
|
+
function sellerLevel(score) {
|
|
1727
|
+
if (!score) return 1;
|
|
1728
|
+
const provenAvg = score.distinctBuyers >= PROVEN_MIN_REVIEWS && score.starsSum * 10 >= score.reviewCount * PROVEN_MIN_AVG_STARS_X10;
|
|
1729
|
+
if (provenAvg) {
|
|
1730
|
+
return score.reviewCount >= LEVEL4_MIN_REVIEWS && score.noDelivery <= LEVEL4_MAX_NO_DELIVERY ? 4 : 3;
|
|
1731
|
+
}
|
|
1732
|
+
return score.distinctBuyers >= PROVEN_MIN_REVIEWS ? 2 : 1;
|
|
1733
|
+
}
|
|
1734
|
+
function effectiveSellerLevel(score) {
|
|
1735
|
+
if (!score) return 1;
|
|
1736
|
+
if (score.noDelivery >= NO_DELIVERY_REGRESSION_FLOOR) return 1;
|
|
1737
|
+
return sellerLevel(score);
|
|
1738
|
+
}
|
|
1739
|
+
function activeCapForLevel(level) {
|
|
1740
|
+
return SELLER_LEVEL_ACTIVE_CAPS[level - 1];
|
|
1741
|
+
}
|
|
1742
|
+
function meetsMinSellerLevel(score, minLevel) {
|
|
1743
|
+
if (minLevel <= 0) return true;
|
|
1744
|
+
return effectiveSellerLevel(score) >= minLevel;
|
|
1745
|
+
}
|
|
1746
|
+
function sellerLevelLabel(level) {
|
|
1747
|
+
return level >= 1 && level <= 4 ? `Level ${level}` : `Level ? (${level})`;
|
|
1748
|
+
}
|
|
1749
|
+
function preflightClaimOpening(score, opening) {
|
|
1750
|
+
if (!meetsClaimPolicy(score, opening.claimPolicy)) {
|
|
1751
|
+
return { valid: false, error: claimPolicyRequirement(opening.claimPolicy) };
|
|
1752
|
+
}
|
|
1753
|
+
const level = effectiveSellerLevel(score);
|
|
1754
|
+
const cap = activeCapForLevel(level);
|
|
1755
|
+
const active = score?.activeSellerJobs ?? 0;
|
|
1756
|
+
if (active >= cap) {
|
|
1757
|
+
return {
|
|
1758
|
+
valid: false,
|
|
1759
|
+
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.`
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1762
|
+
const minLevel = opening.minSellerLevel ?? 0;
|
|
1763
|
+
if (!meetsMinSellerLevel(score, minLevel)) {
|
|
1764
|
+
return {
|
|
1765
|
+
valid: false,
|
|
1766
|
+
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.`
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
return { valid: true };
|
|
1770
|
+
}
|
|
1698
1771
|
|
|
1699
1772
|
// src/commerce.ts
|
|
1700
1773
|
var DEFAULT_COMMERCE_API_BASE = "https://api.t2000.ai/v1";
|
|
@@ -1786,4 +1859,4 @@ async function getJobSpec(base, hash) {
|
|
|
1786
1859
|
// src/browser.ts
|
|
1787
1860
|
init_token_registry();
|
|
1788
1861
|
|
|
1789
|
-
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_PACKAGE_ID, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_COMMERCE_API_BASE, DEFAULT_NETWORK, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, JOB_STATES, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, 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, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, PROVEN_MIN_AVG_STARS_X10, PROVEN_MIN_REVIEWS, REVIEW_MAX_STARS, REVIEW_MIN_STARS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, buildCreateJobTx, buildDeliverJobTx, buildRefundJobTx, buildRejectJobTx, buildReleaseJobTx, buildSendTx, buildSwapTx, checkPositiveAmount, checkSuiAddress, claimPolicyLabel, claimPolicyRequirement, classifyAction, classifyLabel, classifySendAsset, classifyTransaction, deriveAgentScoreId, executeTx, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase642 as fromBase64, getAgentScore, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, invalidSendAssetMessage, jobActionsFor, listServices, mapMoveAbortCode, mapWalletError, meetsClaimPolicy, mistToSui, parseSuiRpcTx, payWithX402, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, rawToStable, rawToUsdc, refineLendingLabel, reportX402Activity, resolveSymbol, resolveTokenType, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress, verifyJobForSeller };
|
|
1862
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_PACKAGE_ID, CLOCK_ID, COIN_REGISTRY, DEFAULT_ACTIVITY_REPORT_URL, DEFAULT_COMMERCE_API_BASE, DEFAULT_NETWORK, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, JOB_STATES, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LEVEL4_MAX_NO_DELIVERY, LEVEL4_MIN_REVIEWS, LOFI_TYPE, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_REVIEW_WINDOW_MS, 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, 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, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, activeCapForLevel, buildCreateJobTx, buildDeliverJobTx, buildRefundJobTx, buildRejectJobTx, buildReleaseJobTx, buildSendTx, buildSwapTx, checkPositiveAmount, checkSuiAddress, claimPolicyLabel, claimPolicyRequirement, classifyAction, classifyLabel, classifySendAsset, classifyTransaction, deriveAgentScoreId, effectiveSellerLevel, executeTx, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase642 as fromBase64, getAgentScore, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, invalidSendAssetMessage, jobActionsFor, listServices, mapMoveAbortCode, mapWalletError, meetsClaimPolicy, meetsMinSellerLevel, mistToSui, parseSuiRpcTx, payWithX402, preflightClaimOpening, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, rawToStable, rawToUsdc, refineLendingLabel, reportX402Activity, resolveSymbol, resolveTokenType, sellerLevel, sellerLevelLabel, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress, verifyJobForSeller };
|