@t2000/sdk 9.5.0 → 9.7.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 +221 -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 +210 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +224 -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 +213 -1
- package/dist/index.js.map +1 -1
- package/dist/{send-DEK6aOGe.d.cts → job-CSq0DRsC.d.cts} +121 -2
- package/dist/{send-DEK6aOGe.d.ts → job-CSq0DRsC.d.ts} +121 -2
- package/package.json +1 -1
package/dist/index.d.cts
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 { T as T2000Error,
|
|
5
|
-
export {
|
|
4
|
+
import { T as T2000Error, aU as T2000Options, Z as TransactionSigner, q as PayOptions, r as PayResult, aV as SwapResult, aW as SwapQuoteResult, H as SupportedAsset, w as SendResult, B as BalanceResponse, Y as TransactionRecord, e as DepositInfo, aX as PaymentRequest, a6 as ZkLoginProof, aY as SuiCoreClient, o as OverlayFeeConfig, aZ as SponsoredCoinMergeCache, Q as SwapRouteResult, a_ as SendableAsset } from './job-CSq0DRsC.cjs';
|
|
5
|
+
export { A as A2A_ESCROW_PACKAGE_ID, a$ as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, b0 as CoinPage, b1 as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, b2 as GASLESS_MIN_STABLE_AMOUNT, b3 as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, g as Job, h as JobState, i as JobTerms, j as JobVerification, K as KNOWN_TARGETS, k as KeypairSigner, L as LABEL_PATTERNS, l as LOFI_TYPE, M as MANIFEST_TYPE, m as MAX_JOB_USDC, n as MIST_PER_SUI, N as NAVX_TYPE, b4 as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, b5 as Operation, P as PREFLIGHT_MAX_AMOUNT, p as PREFLIGHT_OK, s as PreflightResult, b6 as SENDABLE_ASSETS, S as STABLE_ASSETS, t as SUI_DECIMALS, u as SUI_TYPE, v as SUPPORTED_ASSETS, b7 as SelectAndSplitResult, b8 as SerializedCetusRoute, b9 as SerializedCetusRoutePath, ba as SerializedRouterDataV3, x as SimulationResult, y as StableAsset, z as SuiHolding, F as SuiRpcTxBlock, R as T2000ErrorCode, U as T2000ErrorData, V as T2000_OVERLAY_FEE_WALLET, W as TOKEN_MAP, X as TransactionLeg, _ as TxDirection, $ as USDC_DECIMALS, a0 as USDC_TYPE, a1 as USDE_TYPE, a2 as USDSUI_TYPE, a3 as USDT_TYPE, a4 as WAL_TYPE, a5 as WBTC_TYPE, a7 as ZkLoginSigner, bb as addSendToTx, bc as addSwapToTx, bd as assertAllowedAsset, a8 as buildCreateJobTx, a9 as buildDeliverJobTx, aa as buildRefundJobTx, ab as buildRejectJobTx, ac as buildReleaseJobTx, ad as buildSendTx, ae as buildSwapTx, af as checkPositiveAmount, ag as checkSuiAddress, ah as classifyAction, ai as classifyLabel, aj as classifyTransaction, be as deserializeCetusRoute, ak as executeTx, al as extractAllUserLegs, am as extractTransferDetails, an as extractTxCommands, ao as extractTxSender, ap as fallbackLabel, bf as fetchAllCoins, aq as findSwapRoute, ar as formatAssetAmount, as as formatSui, at as formatUsd, bg as getCoinMeta, au as getDecimals, av as getDecimalsForCoinType, aw as getJob, bh as getSuiClient, bi as getSuiGrpcClient, bj as isAllowedAsset, bk as isCetusRouteFresh, bl as isInRegistry, ax as jobActionsFor, ay as mapMoveAbortCode, az as mapWalletError, aA as mistToSui, bm as normalizeAsset, bn as normalizeCoinType, aB as parseMppSuiChallenge, aC as parseSuiRpcTx, aD as payWithMpp, aE as preflightCreateJob, aF as preflightFail, aG as preflightPay, aH as preflightSend, aI as preflightSwap, bo as queryHistory, bp as queryTransaction, aJ as rawToStable, aK as rawToUsdc, aL as refineLendingLabel, aM as resolveSymbol, aN as resolveTokenType, bq as selectAndSplitCoin, br as selectSuiCoin, bs as serializeCetusRoute, bt as simulateTransaction, aO as stableToRaw, aP as suiToMist, bu as throwIfSimulationFailed, aQ as truncateAddress, aR as usdcToRaw, aS as validateAddress, bv as verifyCetusRouteCoinMatch, aT as verifyJobForSeller } from './job-CSq0DRsC.cjs';
|
|
6
6
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
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 { T as T2000Error,
|
|
5
|
-
export {
|
|
4
|
+
import { T as T2000Error, aU as T2000Options, Z as TransactionSigner, q as PayOptions, r as PayResult, aV as SwapResult, aW as SwapQuoteResult, H as SupportedAsset, w as SendResult, B as BalanceResponse, Y as TransactionRecord, e as DepositInfo, aX as PaymentRequest, a6 as ZkLoginProof, aY as SuiCoreClient, o as OverlayFeeConfig, aZ as SponsoredCoinMergeCache, Q as SwapRouteResult, a_ as SendableAsset } from './job-CSq0DRsC.js';
|
|
5
|
+
export { A as A2A_ESCROW_PACKAGE_ID, a$ as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, b0 as CoinPage, b1 as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, E as ETH_TYPE, f as ExtractedTransfer, b2 as GASLESS_MIN_STABLE_AMOUNT, b3 as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, J as JOB_STATES, g as Job, h as JobState, i as JobTerms, j as JobVerification, K as KNOWN_TARGETS, k as KeypairSigner, L as LABEL_PATTERNS, l as LOFI_TYPE, M as MANIFEST_TYPE, m as MAX_JOB_USDC, n as MIST_PER_SUI, N as NAVX_TYPE, b4 as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, b5 as Operation, P as PREFLIGHT_MAX_AMOUNT, p as PREFLIGHT_OK, s as PreflightResult, b6 as SENDABLE_ASSETS, S as STABLE_ASSETS, t as SUI_DECIMALS, u as SUI_TYPE, v as SUPPORTED_ASSETS, b7 as SelectAndSplitResult, b8 as SerializedCetusRoute, b9 as SerializedCetusRoutePath, ba as SerializedRouterDataV3, x as SimulationResult, y as StableAsset, z as SuiHolding, F as SuiRpcTxBlock, R as T2000ErrorCode, U as T2000ErrorData, V as T2000_OVERLAY_FEE_WALLET, W as TOKEN_MAP, X as TransactionLeg, _ as TxDirection, $ as USDC_DECIMALS, a0 as USDC_TYPE, a1 as USDE_TYPE, a2 as USDSUI_TYPE, a3 as USDT_TYPE, a4 as WAL_TYPE, a5 as WBTC_TYPE, a7 as ZkLoginSigner, bb as addSendToTx, bc as addSwapToTx, bd as assertAllowedAsset, a8 as buildCreateJobTx, a9 as buildDeliverJobTx, aa as buildRefundJobTx, ab as buildRejectJobTx, ac as buildReleaseJobTx, ad as buildSendTx, ae as buildSwapTx, af as checkPositiveAmount, ag as checkSuiAddress, ah as classifyAction, ai as classifyLabel, aj as classifyTransaction, be as deserializeCetusRoute, ak as executeTx, al as extractAllUserLegs, am as extractTransferDetails, an as extractTxCommands, ao as extractTxSender, ap as fallbackLabel, bf as fetchAllCoins, aq as findSwapRoute, ar as formatAssetAmount, as as formatSui, at as formatUsd, bg as getCoinMeta, au as getDecimals, av as getDecimalsForCoinType, aw as getJob, bh as getSuiClient, bi as getSuiGrpcClient, bj as isAllowedAsset, bk as isCetusRouteFresh, bl as isInRegistry, ax as jobActionsFor, ay as mapMoveAbortCode, az as mapWalletError, aA as mistToSui, bm as normalizeAsset, bn as normalizeCoinType, aB as parseMppSuiChallenge, aC as parseSuiRpcTx, aD as payWithMpp, aE as preflightCreateJob, aF as preflightFail, aG as preflightPay, aH as preflightSend, aI as preflightSwap, bo as queryHistory, bp as queryTransaction, aJ as rawToStable, aK as rawToUsdc, aL as refineLendingLabel, aM as resolveSymbol, aN as resolveTokenType, bq as selectAndSplitCoin, br as selectSuiCoin, bs as serializeCetusRoute, bt as simulateTransaction, aO as stableToRaw, aP as suiToMist, bu as throwIfSimulationFailed, aQ as truncateAddress, aR as usdcToRaw, aS as validateAddress, bv as verifyCetusRouteCoinMatch, aT as verifyJobForSeller } from './job-CSq0DRsC.js';
|
|
6
6
|
import { TransactionObjectArgument, Transaction } from '@mysten/sui/transactions';
|
|
7
7
|
import { SuinsClient } from '@mysten/suins';
|
|
8
8
|
import '@mysten/sui/client';
|
package/dist/index.js
CHANGED
|
@@ -1045,6 +1045,7 @@ var KeypairSigner = class {
|
|
|
1045
1045
|
constructor(keypair) {
|
|
1046
1046
|
this.keypair = keypair;
|
|
1047
1047
|
}
|
|
1048
|
+
kind = "keypair";
|
|
1048
1049
|
getAddress() {
|
|
1049
1050
|
return this.keypair.getPublicKey().toSuiAddress();
|
|
1050
1051
|
}
|
|
@@ -1151,6 +1152,13 @@ async function payWithMpp(args) {
|
|
|
1151
1152
|
}
|
|
1152
1153
|
const headerChallenge = await parseMppSuiChallenge(probe);
|
|
1153
1154
|
if (headerChallenge) {
|
|
1155
|
+
if (signer.kind === "zklogin") {
|
|
1156
|
+
throw new T2000Error(
|
|
1157
|
+
"DIALECT_UNSUPPORTED",
|
|
1158
|
+
"This seller only offers the MPP header dialect, which zkLogin (Passport) wallets cannot safely pay: the seller cannot verify zkLogin signatures, so the payment would settle on-chain without the service delivering. No payment was made. Use an x402-capable service, or pay from a keypair wallet (t2 CLI / MCP).",
|
|
1159
|
+
{ dialect: "mpp-header", signerKind: "zklogin" }
|
|
1160
|
+
);
|
|
1161
|
+
}
|
|
1154
1162
|
const result = await payViaMppHeader({ signer, client, options });
|
|
1155
1163
|
await reportDirectPayment(result, options.url);
|
|
1156
1164
|
return result;
|
|
@@ -1388,6 +1396,7 @@ var ZkLoginSigner = class {
|
|
|
1388
1396
|
this.userAddress = userAddress;
|
|
1389
1397
|
this.maxEpoch = maxEpoch;
|
|
1390
1398
|
}
|
|
1399
|
+
kind = "zklogin";
|
|
1391
1400
|
getAddress() {
|
|
1392
1401
|
return this.userAddress;
|
|
1393
1402
|
}
|
|
@@ -3116,6 +3125,209 @@ var T2000 = class _T2000 extends EventEmitter {
|
|
|
3116
3125
|
|
|
3117
3126
|
// src/index.ts
|
|
3118
3127
|
init_errors();
|
|
3128
|
+
|
|
3129
|
+
// src/wallet/job.ts
|
|
3130
|
+
init_errors();
|
|
3131
|
+
init_token_registry();
|
|
3132
|
+
init_preflight();
|
|
3133
|
+
init_coinSelection();
|
|
3134
|
+
var A2A_ESCROW_PACKAGE_ID = process.env.A2A_ESCROW_PACKAGE_ID ?? "0x9e67c380fb7079d793d6d15ff916b24d82779d7119bfa4631863102ed485c0a0";
|
|
3135
|
+
var CLOCK_ID2 = "0x6";
|
|
3136
|
+
var MODULE = "escrow";
|
|
3137
|
+
var MAX_JOB_USDC = 50;
|
|
3138
|
+
var JOB_STATES = [
|
|
3139
|
+
"funded",
|
|
3140
|
+
"delivered",
|
|
3141
|
+
"released",
|
|
3142
|
+
"refunded",
|
|
3143
|
+
"rejected"
|
|
3144
|
+
];
|
|
3145
|
+
function hexToBytes2(hex) {
|
|
3146
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
3147
|
+
if (clean.length === 0 || clean.length % 2 !== 0 || /[^0-9a-fA-F]/.test(clean)) {
|
|
3148
|
+
throw new T2000Error(
|
|
3149
|
+
"INVALID_AMOUNT",
|
|
3150
|
+
`Expected a hex hash (0x\u2026), got "${hex.slice(0, 32)}"`
|
|
3151
|
+
);
|
|
3152
|
+
}
|
|
3153
|
+
const out = [];
|
|
3154
|
+
for (let i = 0; i < clean.length; i += 2) {
|
|
3155
|
+
out.push(Number.parseInt(clean.slice(i, i + 2), 16));
|
|
3156
|
+
}
|
|
3157
|
+
return out;
|
|
3158
|
+
}
|
|
3159
|
+
function bytesToHex2(bytes) {
|
|
3160
|
+
let s = "0x";
|
|
3161
|
+
for (const b of bytes) s += b.toString(16).padStart(2, "0");
|
|
3162
|
+
return s;
|
|
3163
|
+
}
|
|
3164
|
+
function preflightCreateJob(terms) {
|
|
3165
|
+
const addressCheck = checkSuiAddress(terms.seller);
|
|
3166
|
+
if (!addressCheck.valid) return addressCheck;
|
|
3167
|
+
if (!Number.isFinite(terms.amountUsdc) || terms.amountUsdc <= 0) {
|
|
3168
|
+
return preflightFail("INVALID_AMOUNT", `Amount must be positive. Got ${terms.amountUsdc}.`);
|
|
3169
|
+
}
|
|
3170
|
+
if (terms.amountUsdc > MAX_JOB_USDC) {
|
|
3171
|
+
return preflightFail(
|
|
3172
|
+
"INVALID_AMOUNT",
|
|
3173
|
+
`v1 caps escrow jobs at ${MAX_JOB_USDC} USDC (no-arbitration split only stays fair at small sizes). Got ${terms.amountUsdc}.`
|
|
3174
|
+
);
|
|
3175
|
+
}
|
|
3176
|
+
if (terms.deliverByMs <= Date.now()) {
|
|
3177
|
+
return preflightFail("INVALID_AMOUNT", "deliverByMs must be in the future.");
|
|
3178
|
+
}
|
|
3179
|
+
if (terms.reviewWindowMs < 0) {
|
|
3180
|
+
return preflightFail("INVALID_AMOUNT", "reviewWindowMs must be \u2265 0.");
|
|
3181
|
+
}
|
|
3182
|
+
if (!Number.isInteger(terms.rejectSplitBps) || terms.rejectSplitBps < 0 || terms.rejectSplitBps > 1e4) {
|
|
3183
|
+
return preflightFail("INVALID_AMOUNT", "rejectSplitBps must be an integer 0\u201310000.");
|
|
3184
|
+
}
|
|
3185
|
+
try {
|
|
3186
|
+
hexToBytes2(terms.specHash);
|
|
3187
|
+
} catch (e) {
|
|
3188
|
+
return preflightFail("INVALID_AMOUNT", e.message);
|
|
3189
|
+
}
|
|
3190
|
+
return PREFLIGHT_OK;
|
|
3191
|
+
}
|
|
3192
|
+
async function buildCreateJobTx({
|
|
3193
|
+
client,
|
|
3194
|
+
buyer,
|
|
3195
|
+
terms
|
|
3196
|
+
}) {
|
|
3197
|
+
const pf = preflightCreateJob(terms);
|
|
3198
|
+
if (!pf.valid) throw new T2000Error(pf.code, pf.error);
|
|
3199
|
+
const seller = validateAddress(terms.seller);
|
|
3200
|
+
if (seller === validateAddress(buyer)) {
|
|
3201
|
+
throw new T2000Error("INVALID_ADDRESS", "Buyer and seller must be different wallets.");
|
|
3202
|
+
}
|
|
3203
|
+
const rawAmount = BigInt(Math.floor(terms.amountUsdc * 10 ** USDC_DECIMALS));
|
|
3204
|
+
const tx = new Transaction();
|
|
3205
|
+
const { coin } = await selectAndSplitCoin(tx, client, buyer, USDC_TYPE, rawAmount, {
|
|
3206
|
+
allowSwapAll: false
|
|
3207
|
+
});
|
|
3208
|
+
tx.moveCall({
|
|
3209
|
+
target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::create`,
|
|
3210
|
+
typeArguments: [USDC_TYPE],
|
|
3211
|
+
arguments: [
|
|
3212
|
+
tx.pure.address(seller),
|
|
3213
|
+
coin,
|
|
3214
|
+
tx.pure.vector("u8", hexToBytes2(terms.specHash)),
|
|
3215
|
+
tx.pure.u64(terms.deliverByMs),
|
|
3216
|
+
tx.pure.u64(terms.reviewWindowMs),
|
|
3217
|
+
tx.pure.u64(terms.rejectSplitBps),
|
|
3218
|
+
tx.object(CLOCK_ID2)
|
|
3219
|
+
]
|
|
3220
|
+
});
|
|
3221
|
+
return tx;
|
|
3222
|
+
}
|
|
3223
|
+
function jobCall(jobId, fn) {
|
|
3224
|
+
const tx = new Transaction();
|
|
3225
|
+
tx.moveCall({
|
|
3226
|
+
target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::${fn}`,
|
|
3227
|
+
typeArguments: [USDC_TYPE],
|
|
3228
|
+
arguments: [tx.object(jobId), tx.object(CLOCK_ID2)]
|
|
3229
|
+
});
|
|
3230
|
+
return tx;
|
|
3231
|
+
}
|
|
3232
|
+
function buildDeliverJobTx(jobId, deliveryHash) {
|
|
3233
|
+
const tx = new Transaction();
|
|
3234
|
+
tx.moveCall({
|
|
3235
|
+
target: `${A2A_ESCROW_PACKAGE_ID}::${MODULE}::deliver`,
|
|
3236
|
+
typeArguments: [USDC_TYPE],
|
|
3237
|
+
arguments: [
|
|
3238
|
+
tx.object(jobId),
|
|
3239
|
+
tx.pure.vector("u8", hexToBytes2(deliveryHash)),
|
|
3240
|
+
tx.object(CLOCK_ID2)
|
|
3241
|
+
]
|
|
3242
|
+
});
|
|
3243
|
+
return tx;
|
|
3244
|
+
}
|
|
3245
|
+
function buildReleaseJobTx(jobId) {
|
|
3246
|
+
return jobCall(jobId, "release");
|
|
3247
|
+
}
|
|
3248
|
+
function buildRejectJobTx(jobId) {
|
|
3249
|
+
return jobCall(jobId, "reject");
|
|
3250
|
+
}
|
|
3251
|
+
function buildRefundJobTx(jobId) {
|
|
3252
|
+
return jobCall(jobId, "refund");
|
|
3253
|
+
}
|
|
3254
|
+
async function getJob(client, jobId) {
|
|
3255
|
+
const resp = await client.core.getObject({ objectId: jobId, include: { json: true } }).catch((e) => {
|
|
3256
|
+
throw new T2000Error(
|
|
3257
|
+
"RPC_ERROR",
|
|
3258
|
+
`Job ${jobId} not found: ${e instanceof Error ? e.message : String(e)}`
|
|
3259
|
+
);
|
|
3260
|
+
});
|
|
3261
|
+
const objType = resp.object?.type ?? "";
|
|
3262
|
+
const json = resp.object?.json;
|
|
3263
|
+
if (!json || !objType.includes(`::${MODULE}::Job<`)) {
|
|
3264
|
+
throw new T2000Error("RPC_ERROR", `Object ${jobId} is not an a2a_escrow Job.`);
|
|
3265
|
+
}
|
|
3266
|
+
const stateNum = Number(json.state ?? -1);
|
|
3267
|
+
const state = JOB_STATES[stateNum];
|
|
3268
|
+
if (!state) {
|
|
3269
|
+
throw new T2000Error("RPC_ERROR", `Job ${jobId} has unknown state ${stateNum}.`);
|
|
3270
|
+
}
|
|
3271
|
+
const deliveredAtMs = Number(json.delivered_at_ms ?? 0);
|
|
3272
|
+
const deliveryBytes = json.delivery_hash ?? [];
|
|
3273
|
+
const hasDelivery = deliveredAtMs > 0;
|
|
3274
|
+
return {
|
|
3275
|
+
id: jobId,
|
|
3276
|
+
buyer: String(json.buyer),
|
|
3277
|
+
seller: String(json.seller),
|
|
3278
|
+
amountUsdc: Number(json.amount) / 10 ** USDC_DECIMALS,
|
|
3279
|
+
escrowUsdc: Number(json.escrow) / 10 ** USDC_DECIMALS,
|
|
3280
|
+
specHash: bytesToHex2(json.spec_hash ?? []),
|
|
3281
|
+
deliverByMs: Number(json.deliver_by_ms),
|
|
3282
|
+
reviewWindowMs: Number(json.review_window_ms),
|
|
3283
|
+
rejectSplitBps: Number(json.reject_split_bps),
|
|
3284
|
+
state,
|
|
3285
|
+
deliveryHash: hasDelivery ? bytesToHex2(deliveryBytes) : null,
|
|
3286
|
+
deliveredAtMs: hasDelivery ? deliveredAtMs : null,
|
|
3287
|
+
createdAtMs: Number(json.created_at_ms)
|
|
3288
|
+
};
|
|
3289
|
+
}
|
|
3290
|
+
function jobActionsFor(job, caller, nowMs = Date.now()) {
|
|
3291
|
+
const me = validateAddress(caller);
|
|
3292
|
+
const isBuyer = me === job.buyer;
|
|
3293
|
+
const isSeller = me === job.seller;
|
|
3294
|
+
const actions = [];
|
|
3295
|
+
if (job.state === "funded") {
|
|
3296
|
+
if (isSeller && nowMs <= job.deliverByMs) actions.push("deliver");
|
|
3297
|
+
if (isBuyer) actions.push("release");
|
|
3298
|
+
if (nowMs > job.deliverByMs) actions.push("refund");
|
|
3299
|
+
} else if (job.state === "delivered") {
|
|
3300
|
+
const windowClosesMs = (job.deliveredAtMs ?? 0) + job.reviewWindowMs;
|
|
3301
|
+
if (isBuyer && nowMs <= windowClosesMs) actions.push("release", "reject");
|
|
3302
|
+
if (nowMs > windowClosesMs) actions.push("release");
|
|
3303
|
+
}
|
|
3304
|
+
return actions;
|
|
3305
|
+
}
|
|
3306
|
+
async function verifyJobForSeller({
|
|
3307
|
+
client,
|
|
3308
|
+
jobId,
|
|
3309
|
+
seller,
|
|
3310
|
+
minAmountUsdc,
|
|
3311
|
+
minRunwayMs = 6e4
|
|
3312
|
+
}) {
|
|
3313
|
+
const job = await getJob(client, jobId);
|
|
3314
|
+
const problems = [];
|
|
3315
|
+
if (job.state !== "funded") {
|
|
3316
|
+
problems.push(`state is "${job.state}", expected "funded"`);
|
|
3317
|
+
}
|
|
3318
|
+
if (job.seller !== validateAddress(seller)) {
|
|
3319
|
+
problems.push(`job pays ${job.seller}, not this seller`);
|
|
3320
|
+
}
|
|
3321
|
+
if (job.escrowUsdc < minAmountUsdc) {
|
|
3322
|
+
problems.push(`escrow holds ${job.escrowUsdc} USDC, price is ${minAmountUsdc}`);
|
|
3323
|
+
}
|
|
3324
|
+
if (job.deliverByMs - Date.now() < minRunwayMs) {
|
|
3325
|
+
problems.push("deadline too close to accept");
|
|
3326
|
+
}
|
|
3327
|
+
return { ok: problems.length === 0, job, problems };
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
// src/index.ts
|
|
3119
3331
|
init_coinSelection();
|
|
3120
3332
|
|
|
3121
3333
|
// src/composeTx.ts
|
|
@@ -3539,6 +3751,6 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
|
3539
3751
|
// src/index.ts
|
|
3540
3752
|
init_preflight();
|
|
3541
3753
|
|
|
3542
|
-
export { AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, 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, assertLimitConfig, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, keypairFromPrivateKey, listModels, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, preflightFail, preflightPay, preflightSend, preflightSwap, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyReceipt, walletExists, writeLimitsFile };
|
|
3754
|
+
export { A2A_ESCROW_PACKAGE_ID, AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, 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, MANIFEST_TYPE, MAX_JOB_USDC, MIST_PER_SUI, NAVX_TYPE, 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, assertLimitConfig, buildAddLeafTx, buildCreateJobTx, buildDeliverJobTx, buildRefundJobTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|
|
3543
3755
|
//# sourceMappingURL=index.js.map
|
|
3544
3756
|
//# sourceMappingURL=index.js.map
|