@t2000/cli 5.6.0 → 5.6.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.
@@ -171,11 +171,10 @@ import {
171
171
  processEndpoint,
172
172
  processFlattenRoutes,
173
173
  restituteMsafeFastRouterSwapParams
174
- } from "./chunk-64M2IV26.js";
175
- import "./chunk-D6WAQS6U.js";
176
- import "./chunk-OCLKPYUU.js";
177
- import "./chunk-ITIKLNK5.js";
178
- import "./chunk-MPXYF2CX.js";
174
+ } from "./chunk-SC3LZKLE.js";
175
+ import "./chunk-5AD7I65O.js";
176
+ import "./chunk-TP3M7BAU.js";
177
+ import "./chunk-X6ON6NN5.js";
179
178
  import "./chunk-I2DCISQP.js";
180
179
  import "./chunk-SVEVGZKZ.js";
181
180
  export {
@@ -351,4 +350,4 @@ export {
351
350
  processFlattenRoutes,
352
351
  restituteMsafeFastRouterSwapParams
353
352
  };
354
- //# sourceMappingURL=dist-VXJH2WYL.js.map
353
+ //# sourceMappingURL=dist-PLJ2M72I.js.map
@@ -5,8 +5,8 @@ import {
5
5
  SuiGrpcClient,
6
6
  isSuiGrpcClient,
7
7
  types_exports
8
- } from "./chunk-D6WAQS6U.js";
9
- import "./chunk-MPXYF2CX.js";
8
+ } from "./chunk-5AD7I65O.js";
9
+ import "./chunk-X6ON6NN5.js";
10
10
  import "./chunk-I2DCISQP.js";
11
11
  import "./chunk-SVEVGZKZ.js";
12
12
  export {
@@ -16,4 +16,4 @@ export {
16
16
  SuiGrpcClient,
17
17
  isSuiGrpcClient
18
18
  };
19
- //# sourceMappingURL=grpc-UMZJXRGY.js.map
19
+ //# sourceMappingURL=grpc-OLWNGPHN.js.map
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'module'; import { fileURLToPat
3
3
  import {
4
4
  AggregatorClient,
5
5
  Env
6
- } from "./chunk-64M2IV26.js";
6
+ } from "./chunk-SC3LZKLE.js";
7
7
  import {
8
8
  BalanceChange,
9
9
  BaseClient,
@@ -16,12 +16,11 @@ import {
16
16
  parseTransactionEffectsBcs,
17
17
  transactionDataToGrpcTransaction,
18
18
  transactionToGrpcJson
19
- } from "./chunk-D6WAQS6U.js";
20
- import "./chunk-OCLKPYUU.js";
19
+ } from "./chunk-5AD7I65O.js";
21
20
  import {
22
21
  Transaction,
23
22
  coinWithBalance
24
- } from "./chunk-ITIKLNK5.js";
23
+ } from "./chunk-TP3M7BAU.js";
25
24
  import {
26
25
  ObjectError,
27
26
  SUI_TYPE_ARG,
@@ -32,7 +31,7 @@ import {
32
31
  fromBase64 as fromBase642,
33
32
  suiBcs,
34
33
  toBase64 as toBase642
35
- } from "./chunk-MPXYF2CX.js";
34
+ } from "./chunk-X6ON6NN5.js";
36
35
  import {
37
36
  SIGNATURE_FLAG_TO_SCHEME,
38
37
  SIGNATURE_SCHEME_TO_FLAG,
@@ -26860,6 +26859,7 @@ var init_token_registry = __esm({
26860
26859
  });
26861
26860
  var coinSelection_exports = {};
26862
26861
  __export(coinSelection_exports, {
26862
+ buildCoinToAddressBalanceMigration: () => buildCoinToAddressBalanceMigration,
26863
26863
  fetchAllCoins: () => fetchAllCoins,
26864
26864
  selectAndSplitCoin: () => selectAndSplitCoin,
26865
26865
  selectSuiCoin: () => selectSuiCoin
@@ -26974,6 +26974,32 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
26974
26974
  });
26975
26975
  return { coin, effectiveAmount, swapAll };
26976
26976
  }
26977
+ function buildCoinToAddressBalanceMigration(args) {
26978
+ const { coins, coinType, owner, minAmount } = args;
26979
+ const sorted = [...coins].filter((c) => c.balance > 0n).sort((a, b) => b.balance > a.balance ? 1 : b.balance < a.balance ? -1 : 0);
26980
+ const selected = [];
26981
+ let migratedRaw = 0n;
26982
+ for (const c of sorted) {
26983
+ if (migratedRaw >= minAmount) break;
26984
+ selected.push(c);
26985
+ migratedRaw += c.balance;
26986
+ }
26987
+ if (migratedRaw < minAmount) {
26988
+ throw new T2000Error("INSUFFICIENT_BALANCE", `Insufficient ${coinType} coin objects to migrate`, {
26989
+ available: migratedRaw.toString(),
26990
+ required: minAmount.toString()
26991
+ });
26992
+ }
26993
+ const tx = new Transaction();
26994
+ for (const c of selected) {
26995
+ tx.moveCall({
26996
+ target: "0x2::coin::send_funds",
26997
+ typeArguments: [coinType],
26998
+ arguments: [tx.object(c.objectId), tx.pure.address(owner)]
26999
+ });
27000
+ }
27001
+ return { tx, migratedRaw };
27002
+ }
26977
27003
  async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
26978
27004
  if (sponsoredContext) {
26979
27005
  const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
@@ -27676,7 +27702,7 @@ async function pickSuiExactRequirements(response, network) {
27676
27702
  }
27677
27703
  async function payViaX402(args) {
27678
27704
  const { signer, client, options, reqInit, requirements } = args;
27679
- const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import("./x402-EMQGKUTK.js");
27705
+ const { buildX402SignedPayment, X402_PAYMENT_HEADER, X402_PAYMENT_RESPONSE_HEADER } = await import("./x402-UYN72OS3.js");
27680
27706
  const amountRaw = BigInt(requirements.maxAmountRequired);
27681
27707
  const migrationGasSui = await ensureAddressBalanceCovers({
27682
27708
  signer,
@@ -27724,40 +27750,26 @@ async function ensureAddressBalanceCovers(args) {
27724
27750
  required: amountRaw.toString()
27725
27751
  });
27726
27752
  }
27753
+ const coins = [];
27727
27754
  let coinSum = 0n;
27728
27755
  let cursor;
27729
27756
  let hasNext = true;
27730
27757
  while (hasNext) {
27731
27758
  const page = await client.core.listCoins({ owner, coinType: asset, cursor: cursor ?? void 0 });
27732
- for (const c of page.objects) coinSum += BigInt(c.balance);
27759
+ for (const c of page.objects) {
27760
+ coins.push({ objectId: c.objectId, balance: BigInt(c.balance) });
27761
+ coinSum += BigInt(c.balance);
27762
+ }
27733
27763
  cursor = page.cursor;
27734
27764
  hasNext = page.hasNextPage;
27735
27765
  }
27736
27766
  const addressBalance = total - coinSum;
27737
27767
  if (addressBalance >= amountRaw) return 0;
27738
27768
  const shortfall = amountRaw - addressBalance;
27739
- const { Transaction: Transaction6 } = await import("./transactions-FSCAFG5Z.js");
27740
- const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
27769
+ const { buildCoinToAddressBalanceMigration: buildCoinToAddressBalanceMigration2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
27741
27770
  const grpcClient = await makeGrpcBuildClient(client);
27742
- const migration = await executeTx(
27743
- client,
27744
- signer,
27745
- async () => {
27746
- const tx = new Transaction6();
27747
- const { coin } = await selectAndSplitCoin2(tx, client, owner, asset, shortfall, {
27748
- sponsoredContext: true,
27749
- // coin-objects-only — never the address balance
27750
- allowSwapAll: false
27751
- });
27752
- tx.moveCall({
27753
- target: "0x2::coin::send_funds",
27754
- typeArguments: [asset],
27755
- arguments: [coin, tx.pure.address(owner)]
27756
- });
27757
- return tx;
27758
- },
27759
- { buildClient: grpcClient }
27760
- );
27771
+ const { tx } = buildCoinToAddressBalanceMigration2({ coins, coinType: asset, owner, minAmount: shortfall });
27772
+ const migration = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
27761
27773
  return migration.gasCostSui;
27762
27774
  }
27763
27775
  async function finalize(response, opts) {
@@ -27771,7 +27783,7 @@ async function finalize(response, opts) {
27771
27783
  return { status: response.status, body, paid: opts.paid };
27772
27784
  }
27773
27785
  async function makeGrpcBuildClient(client) {
27774
- const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-UMZJXRGY.js");
27786
+ const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-OLWNGPHN.js");
27775
27787
  const network = client.network === "testnet" ? "testnet" : "mainnet";
27776
27788
  const baseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
27777
27789
  return new SuiGrpcClient2({ baseUrl, network });
@@ -32482,7 +32494,7 @@ function registerMcpStart(parent) {
32482
32494
  parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
32483
32495
  let mod2;
32484
32496
  try {
32485
- mod2 = await import("./dist-ULTRYNV7.js");
32497
+ mod2 = await import("./dist-5TKR5HBZ.js");
32486
32498
  } catch {
32487
32499
  console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
32488
32500
  process.exit(1);