@t2000/cli 4.2.0 → 4.2.2
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
|
@@ -34992,7 +34992,15 @@ async function fetchAllCoins(client, owner, coinType) {
|
|
|
34992
34992
|
}
|
|
34993
34993
|
async function selectAndSplitCoin(tx, client, owner, coinType, amount, options = {}) {
|
|
34994
34994
|
if (options.sponsoredContext) {
|
|
34995
|
-
return selectCoinObjectsOnly(
|
|
34995
|
+
return selectCoinObjectsOnly(
|
|
34996
|
+
tx,
|
|
34997
|
+
client,
|
|
34998
|
+
owner,
|
|
34999
|
+
coinType,
|
|
35000
|
+
amount,
|
|
35001
|
+
options.allowSwapAll ?? true,
|
|
35002
|
+
options.mergeCache
|
|
35003
|
+
);
|
|
34996
35004
|
}
|
|
34997
35005
|
const balanceResp = await client.getBalance({ owner, coinType });
|
|
34998
35006
|
const totalBalance = BigInt(balanceResp.totalBalance);
|
|
@@ -35012,7 +35020,23 @@ async function selectAndSplitCoin(tx, client, owner, coinType, amount, options =
|
|
|
35012
35020
|
const coin = coinWithBalance({ type: coinType, balance: effectiveAmount })(tx);
|
|
35013
35021
|
return { coin, effectiveAmount, swapAll };
|
|
35014
35022
|
}
|
|
35015
|
-
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll) {
|
|
35023
|
+
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll, mergeCache) {
|
|
35024
|
+
const cached = mergeCache?.get(coinType);
|
|
35025
|
+
if (cached) {
|
|
35026
|
+
const requested2 = amount === "all" ? cached.remaining : amount;
|
|
35027
|
+
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
35028
|
+
throw new T2000Error(
|
|
35029
|
+
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
35030
|
+
`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.`,
|
|
35031
|
+
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
35032
|
+
);
|
|
35033
|
+
}
|
|
35034
|
+
const swapAll2 = amount === "all" || requested2 >= cached.remaining;
|
|
35035
|
+
const effectiveAmount2 = swapAll2 ? cached.remaining : requested2;
|
|
35036
|
+
const coin2 = swapAll2 ? cached.primary : tx.splitCoins(cached.primary, [effectiveAmount2])[0];
|
|
35037
|
+
cached.remaining -= effectiveAmount2;
|
|
35038
|
+
return { coin: coin2, effectiveAmount: effectiveAmount2, swapAll: swapAll2 };
|
|
35039
|
+
}
|
|
35016
35040
|
const objects = [];
|
|
35017
35041
|
let coinObjectTotal = 0n;
|
|
35018
35042
|
let cursor;
|
|
@@ -35052,12 +35076,16 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
35052
35076
|
);
|
|
35053
35077
|
}
|
|
35054
35078
|
const coin = swapAll ? primary : tx.splitCoins(primary, [effectiveAmount])[0];
|
|
35079
|
+
mergeCache?.set(coinType, {
|
|
35080
|
+
primary,
|
|
35081
|
+
remaining: coinObjectTotal - effectiveAmount
|
|
35082
|
+
});
|
|
35055
35083
|
return { coin, effectiveAmount, swapAll };
|
|
35056
35084
|
}
|
|
35057
|
-
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext) {
|
|
35085
|
+
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
|
|
35058
35086
|
if (sponsoredContext) {
|
|
35059
35087
|
const { SUI_TYPE: SUI_TYPE2 } = await Promise.resolve().then(() => (init_token_registry(), token_registry_exports));
|
|
35060
|
-
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false);
|
|
35088
|
+
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false, mergeCache);
|
|
35061
35089
|
}
|
|
35062
35090
|
const [coin] = tx.splitCoins(tx.gas, [amountMist]);
|
|
35063
35091
|
return { coin, effectiveAmount: amountMist, swapAll: false };
|
|
@@ -35277,14 +35305,16 @@ async function addSwapToTx(tx, client, address, input) {
|
|
|
35277
35305
|
client,
|
|
35278
35306
|
address,
|
|
35279
35307
|
requestedRaw,
|
|
35280
|
-
input.sponsoredContext ?? false
|
|
35308
|
+
input.sponsoredContext ?? false,
|
|
35309
|
+
input.coinMergeCache
|
|
35281
35310
|
);
|
|
35282
35311
|
inputCoin = result.coin;
|
|
35283
35312
|
effectiveRaw = result.effectiveAmount;
|
|
35284
35313
|
} else {
|
|
35285
35314
|
const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
|
|
35286
35315
|
const result = await selectAndSplitCoin2(tx, client, address, fromType, requestedRaw, {
|
|
35287
|
-
sponsoredContext: input.sponsoredContext ?? false
|
|
35316
|
+
sponsoredContext: input.sponsoredContext ?? false,
|
|
35317
|
+
mergeCache: input.coinMergeCache
|
|
35288
35318
|
});
|
|
35289
35319
|
inputCoin = result.coin;
|
|
35290
35320
|
effectiveRaw = result.effectiveAmount;
|
|
@@ -45305,7 +45335,7 @@ function registerMcpStart(parent) {
|
|
|
45305
45335
|
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) => {
|
|
45306
45336
|
let mod2;
|
|
45307
45337
|
try {
|
|
45308
|
-
mod2 = await import("./dist-
|
|
45338
|
+
mod2 = await import("./dist-FS73FEVZ.js");
|
|
45309
45339
|
} catch {
|
|
45310
45340
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
45311
45341
|
process.exit(1);
|