@t2000/cli 4.1.1 → 4.1.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
@@ -35656,6 +35656,11 @@ var KeypairSigner = class {
35656
35656
  return this.keypair;
35657
35657
  }
35658
35658
  };
35659
+ function parseChallengeAmount(challenge) {
35660
+ const raw = challenge?.request?.amount;
35661
+ const n = typeof raw === "string" ? Number(raw) : typeof raw === "number" ? raw : Number.NaN;
35662
+ return Number.isFinite(n) ? n : void 0;
35663
+ }
35659
35664
  var ZkLoginSigner = class {
35660
35665
  constructor(ephemeralKeypair, zkProof, userAddress, maxEpoch) {
35661
35666
  this.ephemeralKeypair = ephemeralKeypair;
@@ -40659,11 +40664,17 @@ var T2000 = class _T2000 extends import_index2.default {
40659
40664
  const signerAddress = signer.getAddress();
40660
40665
  let paymentDigest;
40661
40666
  let gasCostSui = 0;
40667
+ let chargedAmount;
40662
40668
  const network = client.network === "testnet" ? "testnet" : "mainnet";
40663
40669
  const grpcBaseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
40664
40670
  const grpcClient = new SuiGrpcClient2({ baseUrl: grpcBaseUrl, network });
40665
40671
  const mppx = Mppx.create({
40666
40672
  polyfill: false,
40673
+ onChallenge: async (challenge) => {
40674
+ const parsed = parseChallengeAmount(challenge);
40675
+ if (parsed !== void 0) chargedAmount = parsed;
40676
+ return void 0;
40677
+ },
40667
40678
  methods: [sui({
40668
40679
  client,
40669
40680
  currency: USDC,
@@ -40695,13 +40706,13 @@ var T2000 = class _T2000 extends import_index2.default {
40695
40706
  }
40696
40707
  const paid = !!paymentDigest;
40697
40708
  if (paid) {
40698
- this.enforcer.recordUsage(options.maxPrice ?? 1);
40709
+ this.enforcer.recordUsage(chargedAmount ?? options.maxPrice ?? 1);
40699
40710
  }
40700
40711
  return {
40701
40712
  status: response.status,
40702
40713
  body,
40703
40714
  paid,
40704
- cost: paid ? options.maxPrice ?? void 0 : void 0,
40715
+ cost: paid ? chargedAmount ?? options.maxPrice ?? void 0 : void 0,
40705
40716
  gasCostSui: paid ? gasCostSui : void 0,
40706
40717
  receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
40707
40718
  };
@@ -45294,7 +45305,7 @@ function registerMcpStart(parent) {
45294
45305
  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) => {
45295
45306
  let mod2;
45296
45307
  try {
45297
- mod2 = await import("./dist-2GOAQHS4.js");
45308
+ mod2 = await import("./dist-C4F63BAI.js");
45298
45309
  } catch {
45299
45310
  console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
45300
45311
  process.exit(1);