@t2000/cli 4.2.1 → 4.3.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/{client-3JAUHH6P.js → client-UCPLLOGQ.js} +6 -6
- package/dist/{dist-EQH4IESE.js → dist-ELFUROC5.js} +256 -235
- package/dist/{dist-EQH4IESE.js.map → dist-ELFUROC5.js.map} +1 -1
- package/dist/index.js +110 -89
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- /package/dist/{client-3JAUHH6P.js.map → client-UCPLLOGQ.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from 'module'; import { fileURLToPath as __fileURLToPath } from 'url'; import { dirname as __pathDirname } from 'path'; const require = __createRequire(import.meta.url); const __filename = __fileURLToPath(import.meta.url); const __dirname = __pathDirname(__filename);
|
|
3
|
+
import {
|
|
4
|
+
SIGNATURE_FLAG_TO_SCHEME,
|
|
5
|
+
SIGNATURE_SCHEME_TO_FLAG,
|
|
6
|
+
SIGNATURE_SCHEME_TO_SIZE
|
|
7
|
+
} from "./chunk-634W6JCI.js";
|
|
3
8
|
import {
|
|
4
9
|
AggregatorClient,
|
|
5
10
|
Env,
|
|
@@ -27,11 +32,6 @@ import {
|
|
|
27
32
|
init_bcs,
|
|
28
33
|
suiBcs
|
|
29
34
|
} from "./chunk-24QPX3VK.js";
|
|
30
|
-
import {
|
|
31
|
-
SIGNATURE_FLAG_TO_SCHEME,
|
|
32
|
-
SIGNATURE_SCHEME_TO_FLAG,
|
|
33
|
-
SIGNATURE_SCHEME_TO_SIZE
|
|
34
|
-
} from "./chunk-634W6JCI.js";
|
|
35
35
|
import {
|
|
36
36
|
HashMD,
|
|
37
37
|
SHA512_IV,
|
|
@@ -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);
|
|
@@ -35298,14 +35306,15 @@ async function addSwapToTx(tx, client, address, input) {
|
|
|
35298
35306
|
address,
|
|
35299
35307
|
requestedRaw,
|
|
35300
35308
|
input.sponsoredContext ?? false,
|
|
35301
|
-
input.
|
|
35309
|
+
input.coinMergeCache
|
|
35302
35310
|
);
|
|
35303
35311
|
inputCoin = result.coin;
|
|
35304
35312
|
effectiveRaw = result.effectiveAmount;
|
|
35305
35313
|
} else {
|
|
35306
35314
|
const { selectAndSplitCoin: selectAndSplitCoin2 } = await Promise.resolve().then(() => (init_coinSelection(), coinSelection_exports));
|
|
35307
35315
|
const result = await selectAndSplitCoin2(tx, client, address, fromType, requestedRaw, {
|
|
35308
|
-
sponsoredContext: input.sponsoredContext ?? false
|
|
35316
|
+
sponsoredContext: input.sponsoredContext ?? false,
|
|
35317
|
+
mergeCache: input.coinMergeCache
|
|
35309
35318
|
});
|
|
35310
35319
|
inputCoin = result.coin;
|
|
35311
35320
|
effectiveRaw = result.effectiveAmount;
|
|
@@ -35677,11 +35686,88 @@ var KeypairSigner = class {
|
|
|
35677
35686
|
return this.keypair;
|
|
35678
35687
|
}
|
|
35679
35688
|
};
|
|
35689
|
+
async function executeTx(client, signer, buildTx, options = {}) {
|
|
35690
|
+
const tx = await buildTx();
|
|
35691
|
+
tx.setSender(signer.getAddress());
|
|
35692
|
+
const txBytes = await tx.build({ client: options.buildClient ?? client });
|
|
35693
|
+
const { signature } = await signer.signTransaction(txBytes);
|
|
35694
|
+
const result = await client.executeTransactionBlock({
|
|
35695
|
+
transactionBlock: txBytes,
|
|
35696
|
+
signature,
|
|
35697
|
+
options: { showEffects: true }
|
|
35698
|
+
});
|
|
35699
|
+
await client.waitForTransaction({ digest: result.digest });
|
|
35700
|
+
const gasUsed = result.effects?.gasUsed;
|
|
35701
|
+
let gasCostSui = 0;
|
|
35702
|
+
if (gasUsed) {
|
|
35703
|
+
const total = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
35704
|
+
gasCostSui = Number(total) / 1e9;
|
|
35705
|
+
}
|
|
35706
|
+
return { digest: result.digest, gasCostSui, effects: result.effects ?? void 0 };
|
|
35707
|
+
}
|
|
35680
35708
|
function parseChallengeAmount(challenge) {
|
|
35681
35709
|
const raw = challenge?.request?.amount;
|
|
35682
35710
|
const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
|
|
35683
35711
|
return Number.isFinite(n) ? n : void 0;
|
|
35684
35712
|
}
|
|
35713
|
+
async function payWithMpp(args) {
|
|
35714
|
+
const { signer, client, options } = args;
|
|
35715
|
+
const { Mppx } = await import("./client-BG6M6WUI.js");
|
|
35716
|
+
const { sui, USDC } = await import("./client-UCPLLOGQ.js");
|
|
35717
|
+
const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-RHG6ARHV.js");
|
|
35718
|
+
const signerAddress = signer.getAddress();
|
|
35719
|
+
let paymentDigest;
|
|
35720
|
+
let gasCostSui = 0;
|
|
35721
|
+
let chargedAmount;
|
|
35722
|
+
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
35723
|
+
const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
35724
|
+
const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
|
|
35725
|
+
const mppx = Mppx.create({
|
|
35726
|
+
polyfill: false,
|
|
35727
|
+
onChallenge: async (challenge) => {
|
|
35728
|
+
const parsed = parseChallengeAmount(challenge);
|
|
35729
|
+
if (parsed !== void 0) chargedAmount = parsed;
|
|
35730
|
+
return void 0;
|
|
35731
|
+
},
|
|
35732
|
+
methods: [sui({
|
|
35733
|
+
client,
|
|
35734
|
+
currency: USDC,
|
|
35735
|
+
signer: {
|
|
35736
|
+
toSuiAddress: () => signerAddress,
|
|
35737
|
+
signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
|
|
35738
|
+
},
|
|
35739
|
+
execute: async (tx) => {
|
|
35740
|
+
const result = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
|
|
35741
|
+
paymentDigest = result.digest;
|
|
35742
|
+
gasCostSui = result.gasCostSui;
|
|
35743
|
+
return { digest: result.digest };
|
|
35744
|
+
}
|
|
35745
|
+
})]
|
|
35746
|
+
});
|
|
35747
|
+
const method = (options.method ?? "GET").toUpperCase();
|
|
35748
|
+
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
35749
|
+
const response = await mppx.fetch(options.url, {
|
|
35750
|
+
method,
|
|
35751
|
+
headers: options.headers,
|
|
35752
|
+
body: canHaveBody ? options.body : void 0
|
|
35753
|
+
});
|
|
35754
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
35755
|
+
let body;
|
|
35756
|
+
try {
|
|
35757
|
+
body = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
35758
|
+
} catch {
|
|
35759
|
+
body = null;
|
|
35760
|
+
}
|
|
35761
|
+
const paid = !!paymentDigest;
|
|
35762
|
+
return {
|
|
35763
|
+
status: response.status,
|
|
35764
|
+
body,
|
|
35765
|
+
paid,
|
|
35766
|
+
cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
|
|
35767
|
+
gasCostSui: paid ? gasCostSui : void 0,
|
|
35768
|
+
receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
35769
|
+
};
|
|
35770
|
+
}
|
|
35685
35771
|
var ZkLoginSigner = class {
|
|
35686
35772
|
constructor(ephemeralKeypair, zkProof, userAddress, maxEpoch) {
|
|
35687
35773
|
this.ephemeralKeypair = ephemeralKeypair;
|
|
@@ -35703,8 +35789,17 @@ var ZkLoginSigner = class {
|
|
|
35703
35789
|
})
|
|
35704
35790
|
};
|
|
35705
35791
|
}
|
|
35706
|
-
async signPersonalMessage(
|
|
35707
|
-
|
|
35792
|
+
async signPersonalMessage(messageBytes) {
|
|
35793
|
+
const { getZkLoginSignature } = await import("./esm-SWUQQCXL.js");
|
|
35794
|
+
const { signature: ephSig, bytes } = await this.ephemeralKeypair.signPersonalMessage(messageBytes);
|
|
35795
|
+
return {
|
|
35796
|
+
signature: getZkLoginSignature({
|
|
35797
|
+
inputs: this.zkProof,
|
|
35798
|
+
maxEpoch: this.maxEpoch,
|
|
35799
|
+
userSignature: ephSig
|
|
35800
|
+
}),
|
|
35801
|
+
bytes
|
|
35802
|
+
};
|
|
35708
35803
|
}
|
|
35709
35804
|
isExpired(currentEpoch) {
|
|
35710
35805
|
return currentEpoch >= this.maxEpoch;
|
|
@@ -40579,25 +40674,6 @@ var ContactManager = class {
|
|
|
40579
40674
|
}
|
|
40580
40675
|
};
|
|
40581
40676
|
var DEFAULT_CONFIG_DIR = join$1(homedir(), ".t2000");
|
|
40582
|
-
async function executeTx(client, signer, buildTx, options = {}) {
|
|
40583
|
-
const tx = await buildTx();
|
|
40584
|
-
tx.setSender(signer.getAddress());
|
|
40585
|
-
const txBytes = await tx.build({ client: options.buildClient ?? client });
|
|
40586
|
-
const { signature } = await signer.signTransaction(txBytes);
|
|
40587
|
-
const result = await client.executeTransactionBlock({
|
|
40588
|
-
transactionBlock: txBytes,
|
|
40589
|
-
signature,
|
|
40590
|
-
options: { showEffects: true }
|
|
40591
|
-
});
|
|
40592
|
-
await client.waitForTransaction({ digest: result.digest });
|
|
40593
|
-
const gasUsed = result.effects?.gasUsed;
|
|
40594
|
-
let gasCostSui = 0;
|
|
40595
|
-
if (gasUsed) {
|
|
40596
|
-
const total = BigInt(gasUsed.computationCost) + BigInt(gasUsed.storageCost) - BigInt(gasUsed.storageRebate);
|
|
40597
|
-
gasCostSui = Number(total) / 1e9;
|
|
40598
|
-
}
|
|
40599
|
-
return { digest: result.digest, gasCostSui, effects: result.effects ?? void 0 };
|
|
40600
|
-
}
|
|
40601
40677
|
var T2000 = class _T2000 extends import_index2.default {
|
|
40602
40678
|
_signer;
|
|
40603
40679
|
_keypair;
|
|
@@ -40677,66 +40753,11 @@ var T2000 = class _T2000 extends import_index2.default {
|
|
|
40677
40753
|
async pay(options) {
|
|
40678
40754
|
this.enforcer.assertNotLocked();
|
|
40679
40755
|
this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
|
|
40680
|
-
const
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
const client = this.client;
|
|
40684
|
-
const signer = this._signer;
|
|
40685
|
-
const signerAddress = signer.getAddress();
|
|
40686
|
-
let paymentDigest;
|
|
40687
|
-
let gasCostSui = 0;
|
|
40688
|
-
let chargedAmount;
|
|
40689
|
-
const network = client.network === "testnet" ? "testnet" : "mainnet";
|
|
40690
|
-
const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
|
|
40691
|
-
const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
|
|
40692
|
-
const mppx = Mppx.create({
|
|
40693
|
-
polyfill: false,
|
|
40694
|
-
onChallenge: async (challenge) => {
|
|
40695
|
-
const parsed = parseChallengeAmount(challenge);
|
|
40696
|
-
if (parsed !== void 0) chargedAmount = parsed;
|
|
40697
|
-
return void 0;
|
|
40698
|
-
},
|
|
40699
|
-
methods: [sui({
|
|
40700
|
-
client,
|
|
40701
|
-
currency: USDC,
|
|
40702
|
-
signer: {
|
|
40703
|
-
toSuiAddress: () => signerAddress,
|
|
40704
|
-
signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
|
|
40705
|
-
},
|
|
40706
|
-
execute: async (tx) => {
|
|
40707
|
-
const result = await executeTx(client, signer, () => tx, { buildClient: grpcClient });
|
|
40708
|
-
paymentDigest = result.digest;
|
|
40709
|
-
gasCostSui = result.gasCostSui;
|
|
40710
|
-
return { digest: result.digest };
|
|
40711
|
-
}
|
|
40712
|
-
})]
|
|
40713
|
-
});
|
|
40714
|
-
const method = (options.method ?? "GET").toUpperCase();
|
|
40715
|
-
const canHaveBody = method !== "GET" && method !== "HEAD";
|
|
40716
|
-
const response = await mppx.fetch(options.url, {
|
|
40717
|
-
method,
|
|
40718
|
-
headers: options.headers,
|
|
40719
|
-
body: canHaveBody ? options.body : void 0
|
|
40720
|
-
});
|
|
40721
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
40722
|
-
let body;
|
|
40723
|
-
try {
|
|
40724
|
-
body = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
40725
|
-
} catch {
|
|
40726
|
-
body = null;
|
|
40727
|
-
}
|
|
40728
|
-
const paid = !!paymentDigest;
|
|
40729
|
-
if (paid) {
|
|
40730
|
-
this.enforcer.recordUsage(chargedAmount ?? options.maxPrice ?? 1);
|
|
40756
|
+
const result = await payWithMpp({ signer: this._signer, client: this.client, options });
|
|
40757
|
+
if (result.paid) {
|
|
40758
|
+
this.enforcer.recordUsage(result.cost ?? options.maxPrice ?? 1);
|
|
40731
40759
|
}
|
|
40732
|
-
return
|
|
40733
|
-
status: response.status,
|
|
40734
|
-
body,
|
|
40735
|
-
paid,
|
|
40736
|
-
cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
|
|
40737
|
-
gasCostSui: paid ? gasCostSui : void 0,
|
|
40738
|
-
receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
|
|
40739
|
-
};
|
|
40760
|
+
return result;
|
|
40740
40761
|
}
|
|
40741
40762
|
// [S.323 / 2026-05-25] VOLO vSUI staking surfaces removed (full cut).
|
|
40742
40763
|
// Engine cut Volo in S.277; SDK + CLI + MCP followed in S.323 because the
|
|
@@ -45326,7 +45347,7 @@ function registerMcpStart(parent) {
|
|
|
45326
45347
|
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) => {
|
|
45327
45348
|
let mod2;
|
|
45328
45349
|
try {
|
|
45329
|
-
mod2 = await import("./dist-
|
|
45350
|
+
mod2 = await import("./dist-ELFUROC5.js");
|
|
45330
45351
|
} catch {
|
|
45331
45352
|
console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
|
|
45332
45353
|
process.exit(1);
|