@t2000/cli 10.23.0 → 10.25.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/index.js CHANGED
@@ -30160,7 +30160,15 @@ var T2000 = class _T2000 extends import_index2.default {
30160
30160
  amountUsd: approxUsdValue(params.from, params.amount) ?? 0,
30161
30161
  force: params.force
30162
30162
  });
30163
- const { findSwapRoute: findSwapRoute2, buildSwapTx: buildSwapTx2, resolveTokenType: resolveTokenType2, preflightSwap: preflightSwap2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
30163
+ const {
30164
+ findSwapRoute: findSwapRoute2,
30165
+ buildSwapTx: buildSwapTx2,
30166
+ resolveTokenType: resolveTokenType2,
30167
+ preflightSwap: preflightSwap2,
30168
+ deserializeCetusRoute: deserializeCetusRoute2,
30169
+ isCetusRouteFresh: isCetusRouteFresh2,
30170
+ verifyCetusRouteCoinMatch: verifyCetusRouteCoinMatch2
30171
+ } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
30164
30172
  const pf = preflightSwap2({ from: params.from, to: params.to, amount: params.amount });
30165
30173
  if (!pf.valid) throw new T2000Error(pf.code, pf.error);
30166
30174
  const fromType = resolveTokenType2(params.from);
@@ -30171,13 +30179,37 @@ var T2000 = class _T2000 extends import_index2.default {
30171
30179
  const slippage = Math.min(params.slippage ?? 0.01, 0.05);
30172
30180
  const fromDecimals = await resolveCoinDecimals(this.client, fromType);
30173
30181
  const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
30174
- const route = await findSwapRoute2({
30175
- walletAddress: this._address,
30176
- from: fromType,
30177
- to: toType,
30178
- amount: rawAmount,
30179
- byAmountIn
30180
- });
30182
+ let route;
30183
+ if (params.serializedRoute) {
30184
+ const s = params.serializedRoute;
30185
+ if (!verifyCetusRouteCoinMatch2(s, { fromCoinType: fromType, toCoinType: toType })) {
30186
+ throw new T2000Error(
30187
+ "SWAP_ROUTE_MISMATCH",
30188
+ `The quoted route is for ${s.fromCoinType} -> ${s.toCoinType}, not ${params.from} -> ${params.to}. Re-quote and pass the new serializedRoute.`
30189
+ );
30190
+ }
30191
+ if (s.byAmountIn !== byAmountIn || BigInt(s.amountIn) !== rawAmount) {
30192
+ throw new T2000Error(
30193
+ "SWAP_ROUTE_MISMATCH",
30194
+ "The quoted route was for a different amount. Re-quote with the amount you want to execute and pass the new serializedRoute."
30195
+ );
30196
+ }
30197
+ if (!isCetusRouteFresh2(s)) {
30198
+ throw new T2000Error(
30199
+ "SWAP_QUOTE_STALE",
30200
+ "The quote expired (routes are held for ~30s). Re-quote and pass the fresh serializedRoute."
30201
+ );
30202
+ }
30203
+ route = deserializeCetusRoute2(s);
30204
+ } else {
30205
+ route = await findSwapRoute2({
30206
+ walletAddress: this._address,
30207
+ from: fromType,
30208
+ to: toType,
30209
+ amount: rawAmount,
30210
+ byAmountIn
30211
+ });
30212
+ }
30181
30213
  if (!route) throw new T2000Error("SWAP_NO_ROUTE", `No swap route found for ${params.from} -> ${params.to}.`);
30182
30214
  if (route.insufficientLiquidity) throw new T2000Error("SWAP_NO_ROUTE", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
30183
30215
  if (route.priceImpact > 0.05) {
@@ -30778,6 +30810,20 @@ function cancelOpenJob(base, signer, openingId) {
30778
30810
  openingId: openingId.trim()
30779
30811
  });
30780
30812
  }
30813
+ async function resolveCreatedObjectId(client, digest, marker, opts = {}) {
30814
+ try {
30815
+ const result = await client.core.waitForTransaction({
30816
+ digest,
30817
+ include: { objectTypes: true },
30818
+ timeout: opts.timeoutMs ?? 15e3
30819
+ });
30820
+ const txn = result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
30821
+ const types = txn.objectTypes ?? {};
30822
+ return Object.keys(types).find((id) => types[id]?.includes(marker));
30823
+ } catch {
30824
+ return void 0;
30825
+ }
30826
+ }
30781
30827
  init_coinSelection();
30782
30828
  init_cetus_swap();
30783
30829
  init_coinSelection();
@@ -35558,20 +35604,8 @@ function fmtLeft(ms) {
35558
35604
  if (hours >= 1) return `${hours}h`;
35559
35605
  return `${Math.max(1, Math.floor(left / 6e4))}m`;
35560
35606
  }
35561
- async function resolveCreated(digest, marker) {
35562
- try {
35563
- const client = getSuiClient();
35564
- const result = await client.core.waitForTransaction({
35565
- digest,
35566
- include: { objectTypes: true },
35567
- timeout: 15e3
35568
- });
35569
- const txn = result.$kind === "Transaction" ? result.Transaction : result.FailedTransaction;
35570
- const types = txn.objectTypes ?? {};
35571
- return Object.keys(types).find((id) => types[id]?.includes(marker));
35572
- } catch {
35573
- return void 0;
35574
- }
35607
+ function resolveCreated(digest, marker) {
35608
+ return resolveCreatedObjectId(getSuiClient(), digest, marker);
35575
35609
  }
35576
35610
  function registerOpenVerbs(group) {
35577
35611
  group.command("open").description("Open \u2014 post the job to the public board with no ASP picked (buyer); ESCROWS the budget on-chain now, first claim starts work").requiredOption("--title <text>", "The job's public name (up to 80 chars)").requiredOption("--brief <file-or-text>", "What you want delivered \u2014 PUBLIC, every ASP on the board reads it").requiredOption("--max <usdc>", `Budget escrowed AT POST (max ${MAX_JOB_USDC})`).option("--sla <duration>", "Delivery window once claimed (e.g. 30m, 24h, 7d)", "24h").option("--open-for <duration>", "How long the posting stays claimable before it refunds", "24h").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").option("--api <url>", `API base URL (default ${DEFAULT_API_BASE6})`).action(