@t2000/cli 4.1.4 → 4.2.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.
package/dist/index.js
CHANGED
|
@@ -35012,7 +35012,23 @@ async function selectAndSplitCoin(tx, client, owner, coinType, amount, options =
|
|
|
35012
35012
|
const coin = coinWithBalance({ type: coinType, balance: effectiveAmount })(tx);
|
|
35013
35013
|
return { coin, effectiveAmount, swapAll };
|
|
35014
35014
|
}
|
|
35015
|
-
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll) {
|
|
35015
|
+
async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowSwapAll, mergeCache) {
|
|
35016
|
+
const cached = mergeCache?.get(coinType);
|
|
35017
|
+
if (cached) {
|
|
35018
|
+
const requested2 = amount === "all" ? cached.remaining : amount;
|
|
35019
|
+
if (cached.remaining === 0n || requested2 > cached.remaining) {
|
|
35020
|
+
throw new T2000Error(
|
|
35021
|
+
"ADDRESS_BALANCE_UNSPONSORABLE",
|
|
35022
|
+
`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.`,
|
|
35023
|
+
{ remaining: cached.remaining.toString(), requested: requested2.toString(), coinType }
|
|
35024
|
+
);
|
|
35025
|
+
}
|
|
35026
|
+
const swapAll2 = amount === "all" || requested2 >= cached.remaining;
|
|
35027
|
+
const effectiveAmount2 = swapAll2 ? cached.remaining : requested2;
|
|
35028
|
+
const coin2 = swapAll2 ? cached.primary : tx.splitCoins(cached.primary, [effectiveAmount2])[0];
|
|
35029
|
+
cached.remaining -= effectiveAmount2;
|
|
35030
|
+
return { coin: coin2, effectiveAmount: effectiveAmount2, swapAll: swapAll2 };
|
|
35031
|
+
}
|
|
35016
35032
|
const objects = [];
|
|
35017
35033
|
let coinObjectTotal = 0n;
|
|
35018
35034
|
let cursor;
|
|
@@ -35052,12 +35068,16 @@ async function selectCoinObjectsOnly(tx, client, owner, coinType, amount, allowS
|
|
|
35052
35068
|
);
|
|
35053
35069
|
}
|
|
35054
35070
|
const coin = swapAll ? primary : tx.splitCoins(primary, [effectiveAmount])[0];
|
|
35071
|
+
mergeCache?.set(coinType, {
|
|
35072
|
+
primary,
|
|
35073
|
+
remaining: coinObjectTotal - effectiveAmount
|
|
35074
|
+
});
|
|
35055
35075
|
return { coin, effectiveAmount, swapAll };
|
|
35056
35076
|
}
|
|
35057
|
-
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext) {
|
|
35077
|
+
async function selectSuiCoin(tx, client, owner, amountMist, sponsoredContext, mergeCache) {
|
|
35058
35078
|
if (sponsoredContext) {
|
|
35059
35079
|
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);
|
|
35080
|
+
return selectCoinObjectsOnly(tx, client, owner, SUI_TYPE2, amountMist, false, mergeCache);
|
|
35061
35081
|
}
|
|
35062
35082
|
const [coin] = tx.splitCoins(tx.gas, [amountMist]);
|
|
35063
35083
|
return { coin, effectiveAmount: amountMist, swapAll: false };
|
|
@@ -35277,7 +35297,8 @@ async function addSwapToTx(tx, client, address, input) {
|
|
|
35277
35297
|
client,
|
|
35278
35298
|
address,
|
|
35279
35299
|
requestedRaw,
|
|
35280
|
-
input.sponsoredContext ?? false
|
|
35300
|
+
input.sponsoredContext ?? false,
|
|
35301
|
+
input.suiMergeCache
|
|
35281
35302
|
);
|
|
35282
35303
|
inputCoin = result.coin;
|
|
35283
35304
|
effectiveRaw = result.effectiveAmount;
|
|
@@ -45305,7 +45326,7 @@ function registerMcpStart(parent) {
|
|
|
45305
45326
|
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
45327
|
let mod2;
|
|
45307
45328
|
try {
|
|
45308
|
-
mod2 = await import("./dist-
|
|
45329
|
+
mod2 = await import("./dist-EQH4IESE.js");
|
|
45309
45330
|
} catch {
|
|
45310
45331
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
45311
45332
|
process.exit(1);
|