@t2000/sdk 9.11.0 → 9.13.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/README.md +2 -0
- package/dist/browser.cjs +92 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +88 -1
- package/dist/browser.js.map +1 -1
- package/dist/{job-BCRKTThm.d.cts → commerce-gxlqmkX7.d.cts} +36 -1
- package/dist/{job-BCRKTThm.d.ts → commerce-gxlqmkX7.d.ts} +36 -1
- package/dist/index.cjs +92 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 BalanceResponse, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as
|
|
1
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, B as BalanceResponse, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_COMMERCE_API_BASE, f as DEFAULT_NETWORK, g as DepositInfo, E as ETH_TYPE, h as ExtractedTransfer, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, i as Job, j as JobState, k as JobTerms, l as JobVerification, K as KNOWN_TARGETS, m as KeypairSigner, L as LABEL_PATTERNS, n as LOFI_TYPE, M as MANIFEST_TYPE, o as MAX_DELIVER_HORIZON_MS, p as MAX_JOB_USDC, q as MAX_REVIEW_WINDOW_MS, r as MIST_PER_SUI, N as NAVX_TYPE, O as OVERLAY_FEE_RATE, s as OfferingListing, t as OverlayFeeConfig, P as PREFLIGHT_MAX_AMOUNT, u as PREFLIGHT_OK, v as PayOptions, w as PayResult, x as PreflightResult, S as STABLE_ASSETS, y as SUI_DECIMALS, z as SUI_TYPE, F as SUPPORTED_ASSETS, H as SendResult, Q as SimulationResult, R as StableAsset, T as SuiHolding, U as SuiRpcTxBlock, V as SupportedAsset, W as SwapRouteResult, X as T2000Error, Y as T2000ErrorCode, Z as T2000ErrorData, _ as T2000_OVERLAY_FEE_WALLET, $ as TOKEN_MAP, a0 as TransactionLeg, a1 as TransactionRecord, a2 as TransactionSigner, a3 as TxDirection, a4 as USDC_DECIMALS, a5 as USDC_TYPE, a6 as USDE_TYPE, a7 as USDSUI_TYPE, a8 as USDT_TYPE, a9 as WAL_TYPE, aa as WBTC_TYPE, ab as ZkLoginProof, ac as ZkLoginSigner, ad as buildCreateJobTx, ae as buildDeliverJobTx, af as buildRefundJobTx, ag as buildRejectJobTx, ah as buildReleaseJobTx, ai as buildSendTx, aj as buildSwapTx, ak as checkPositiveAmount, al as checkSuiAddress, am as classifyAction, an as classifyLabel, ao as classifyTransaction, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, av as fetchOffering, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, aE as jobActionsFor, aF as listOfferings, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, aJ as parseMppSuiChallenge, aK as parseSuiRpcTx, aL as payWithMpp, aM as preflightCreateJob, aN as preflightFail, aO as preflightPay, aP as preflightSend, aQ as preflightSwap, aR as putJobSpec, aS as rawToStable, aT as rawToUsdc, aU as refineLendingLabel, aV as resolveSymbol, aW as resolveTokenType, aX as stableToRaw, aY as suiToMist, aZ as truncateAddress, a_ as usdcToRaw, a$ as validateAddress, b0 as verifyJobForSeller } from './commerce-gxlqmkX7.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 BalanceResponse, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as
|
|
1
|
+
export { A as A2A_ESCROW_FEE_CONFIG_ID, a as A2A_ESCROW_PACKAGE_ID, B as BalanceResponse, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_COMMERCE_API_BASE, f as DEFAULT_NETWORK, g as DepositInfo, E as ETH_TYPE, h as ExtractedTransfer, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, i as Job, j as JobState, k as JobTerms, l as JobVerification, K as KNOWN_TARGETS, m as KeypairSigner, L as LABEL_PATTERNS, n as LOFI_TYPE, M as MANIFEST_TYPE, o as MAX_DELIVER_HORIZON_MS, p as MAX_JOB_USDC, q as MAX_REVIEW_WINDOW_MS, r as MIST_PER_SUI, N as NAVX_TYPE, O as OVERLAY_FEE_RATE, s as OfferingListing, t as OverlayFeeConfig, P as PREFLIGHT_MAX_AMOUNT, u as PREFLIGHT_OK, v as PayOptions, w as PayResult, x as PreflightResult, S as STABLE_ASSETS, y as SUI_DECIMALS, z as SUI_TYPE, F as SUPPORTED_ASSETS, H as SendResult, Q as SimulationResult, R as StableAsset, T as SuiHolding, U as SuiRpcTxBlock, V as SupportedAsset, W as SwapRouteResult, X as T2000Error, Y as T2000ErrorCode, Z as T2000ErrorData, _ as T2000_OVERLAY_FEE_WALLET, $ as TOKEN_MAP, a0 as TransactionLeg, a1 as TransactionRecord, a2 as TransactionSigner, a3 as TxDirection, a4 as USDC_DECIMALS, a5 as USDC_TYPE, a6 as USDE_TYPE, a7 as USDSUI_TYPE, a8 as USDT_TYPE, a9 as WAL_TYPE, aa as WBTC_TYPE, ab as ZkLoginProof, ac as ZkLoginSigner, ad as buildCreateJobTx, ae as buildDeliverJobTx, af as buildRefundJobTx, ag as buildRejectJobTx, ah as buildReleaseJobTx, ai as buildSendTx, aj as buildSwapTx, ak as checkPositiveAmount, al as checkSuiAddress, am as classifyAction, an as classifyLabel, ao as classifyTransaction, ap as executeTx, aq as extractAllUserLegs, ar as extractTransferDetails, as as extractTxCommands, at as extractTxSender, au as fallbackLabel, av as fetchOffering, aw as findSwapRoute, ax as formatAssetAmount, ay as formatSui, az as formatUsd, aA as getDecimals, aB as getDecimalsForCoinType, aC as getJob, aD as getJobSpec, aE as jobActionsFor, aF as listOfferings, aG as mapMoveAbortCode, aH as mapWalletError, aI as mistToSui, aJ as parseMppSuiChallenge, aK as parseSuiRpcTx, aL as payWithMpp, aM as preflightCreateJob, aN as preflightFail, aO as preflightPay, aP as preflightSend, aQ as preflightSwap, aR as putJobSpec, aS as rawToStable, aT as rawToUsdc, aU as refineLendingLabel, aV as resolveSymbol, aW as resolveTokenType, aX as stableToRaw, aY as suiToMist, aZ as truncateAddress, a_ as usdcToRaw, a$ as validateAddress, b0 as verifyJobForSeller } from './commerce-gxlqmkX7.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
|
@@ -1308,6 +1308,18 @@ async function buildSendTx({
|
|
|
1308
1308
|
required: amount
|
|
1309
1309
|
});
|
|
1310
1310
|
}
|
|
1311
|
+
if (asset === "USDC" || asset === "USDsui") {
|
|
1312
|
+
const rawFloor = displayToRaw(GASLESS_MIN_STABLE_AMOUNT, assetInfo.decimals);
|
|
1313
|
+
const remainder = totalBalance - rawAmount;
|
|
1314
|
+
if (remainder > 0n && remainder < rawFloor) {
|
|
1315
|
+
const total = Number(totalBalance) / 10 ** assetInfo.decimals;
|
|
1316
|
+
throw new T2000Error(
|
|
1317
|
+
"INVALID_AMOUNT",
|
|
1318
|
+
`Gasless ${asset} transfers must send the entire balance or leave at least ${GASLESS_MIN_STABLE_AMOUNT} ${asset}. Sending ${amount} of ${total} leaves ${(total - amount).toFixed(assetInfo.decimals)}. Send ${total} (everything) or at most ${(total - GASLESS_MIN_STABLE_AMOUNT).toFixed(assetInfo.decimals)}.`,
|
|
1319
|
+
{ available: total, required: amount }
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1311
1323
|
if (asset === "SUI") {
|
|
1312
1324
|
const [sendCoin] = tx.splitCoins(tx.gas, [rawAmount]);
|
|
1313
1325
|
tx.transferObjects([sendCoin], recipient);
|
|
@@ -1545,9 +1557,84 @@ async function verifyJobForSeller({
|
|
|
1545
1557
|
return { ok: problems.length === 0, job, problems };
|
|
1546
1558
|
}
|
|
1547
1559
|
|
|
1560
|
+
// src/commerce.ts
|
|
1561
|
+
var DEFAULT_COMMERCE_API_BASE = "https://api.t2000.ai/v1";
|
|
1562
|
+
async function commerceFetchJson(url, init) {
|
|
1563
|
+
const res = await fetch(url, {
|
|
1564
|
+
method: init?.method ?? "GET",
|
|
1565
|
+
headers: init?.body ? { "Content-Type": "application/json" } : void 0,
|
|
1566
|
+
body: init?.body ? JSON.stringify(init.body) : void 0
|
|
1567
|
+
});
|
|
1568
|
+
const json = await res.json().catch(() => ({}));
|
|
1569
|
+
if (!res.ok) {
|
|
1570
|
+
const err = json.error;
|
|
1571
|
+
const msg = typeof err === "string" ? err : err?.message ?? `HTTP ${res.status}`;
|
|
1572
|
+
throw new Error(msg);
|
|
1573
|
+
}
|
|
1574
|
+
return json;
|
|
1575
|
+
}
|
|
1576
|
+
async function listOfferings(base, filter = {}) {
|
|
1577
|
+
const params = new URLSearchParams();
|
|
1578
|
+
if (filter.agent) params.set("agent", filter.agent);
|
|
1579
|
+
if (filter.query) params.set("q", filter.query);
|
|
1580
|
+
const qs = params.size > 0 ? `?${params.toString()}` : "";
|
|
1581
|
+
const json = await commerceFetchJson(`${base}/offerings${qs}`);
|
|
1582
|
+
const offerings = json.offerings ?? [];
|
|
1583
|
+
return { total: json.total ?? offerings.length, offerings };
|
|
1584
|
+
}
|
|
1585
|
+
async function fetchOffering(base, agent, slug) {
|
|
1586
|
+
const { offerings: rows } = await listOfferings(base, { agent });
|
|
1587
|
+
const match = rows.find((o) => o.slug === slug.trim().toLowerCase());
|
|
1588
|
+
if (!match) {
|
|
1589
|
+
const live = rows.filter((o) => !o.retired).map((o) => o.slug);
|
|
1590
|
+
throw new Error(
|
|
1591
|
+
`Agent ${truncateAddress(agent)} has no offering "${slug}".` + (live.length > 0 ? ` Live offerings: ${live.join(", ")}` : "")
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
if (match.retired) {
|
|
1595
|
+
throw new Error(
|
|
1596
|
+
`Offering "${slug}" is retired \u2014 the seller no longer sells it.`
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
return match;
|
|
1600
|
+
}
|
|
1601
|
+
async function sha256Hex(content) {
|
|
1602
|
+
const digest = await crypto.subtle.digest(
|
|
1603
|
+
"SHA-256",
|
|
1604
|
+
new TextEncoder().encode(content)
|
|
1605
|
+
);
|
|
1606
|
+
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1607
|
+
}
|
|
1608
|
+
async function putJobSpec(base, content) {
|
|
1609
|
+
const json = await commerceFetchJson(`${base}/job/spec`, {
|
|
1610
|
+
method: "POST",
|
|
1611
|
+
body: { content }
|
|
1612
|
+
});
|
|
1613
|
+
const hash = json.hash;
|
|
1614
|
+
if (!hash) {
|
|
1615
|
+
throw new Error("Failed to store the job spec.");
|
|
1616
|
+
}
|
|
1617
|
+
return hash;
|
|
1618
|
+
}
|
|
1619
|
+
async function getJobSpec(base, hash) {
|
|
1620
|
+
const clean = hash.trim().toLowerCase().replace(/^0x/, "");
|
|
1621
|
+
const json = await commerceFetchJson(`${base}/job/spec/${clean}`);
|
|
1622
|
+
const content = json.content;
|
|
1623
|
+
if (content === void 0) {
|
|
1624
|
+
throw new Error("No spec stored for this hash.");
|
|
1625
|
+
}
|
|
1626
|
+
const actual = await sha256Hex(content);
|
|
1627
|
+
if (actual !== clean) {
|
|
1628
|
+
throw new Error(
|
|
1629
|
+
"Spec content does NOT match its hash \u2014 the store returned tampered data. Do not trust it."
|
|
1630
|
+
);
|
|
1631
|
+
}
|
|
1632
|
+
return content;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1548
1635
|
// src/browser.ts
|
|
1549
1636
|
init_token_registry();
|
|
1550
1637
|
|
|
1551
|
-
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_PACKAGE_ID, CLOCK_ID, COIN_REGISTRY, 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, MIST_PER_SUI, NAVX_TYPE, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, 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, classifyAction, classifyLabel, classifyTransaction, executeTx, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase642 as fromBase64, getDecimals, getDecimalsForCoinType, getJob, jobActionsFor, mapMoveAbortCode, mapWalletError, mistToSui, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress, verifyJobForSeller };
|
|
1638
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_PACKAGE_ID, CLOCK_ID, COIN_REGISTRY, 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, MIST_PER_SUI, NAVX_TYPE, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, 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, classifyAction, classifyLabel, classifyTransaction, executeTx, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchOffering, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase642 as fromBase64, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, jobActionsFor, listOfferings, mapMoveAbortCode, mapWalletError, mistToSui, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress, verifyJobForSeller };
|
|
1552
1639
|
//# sourceMappingURL=browser.js.map
|
|
1553
1640
|
//# sourceMappingURL=browser.js.map
|