@t2000/cli 2.12.0 → 2.13.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.
@@ -0,0 +1,146 @@
1
+ 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);
2
+ import "./chunk-OCLKPYUU.js";
3
+ import {
4
+ Transaction
5
+ } from "./chunk-UY3WLP52.js";
6
+ import "./chunk-3XUF7GM3.js";
7
+ import {
8
+ Credential_exports,
9
+ Method_exports,
10
+ zod_exports
11
+ } from "./chunk-2HBLU5GV.js";
12
+ import "./chunk-NGS6K3I3.js";
13
+ import "./chunk-77SWBATH.js";
14
+ import "./chunk-7LGHVVIJ.js";
15
+ import "./chunk-YPWSCLE3.js";
16
+
17
+ // ../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/dist/client.js
18
+ var suiCharge = Method_exports.from({
19
+ intent: "charge",
20
+ name: "sui",
21
+ schema: {
22
+ credential: {
23
+ payload: zod_exports.object({
24
+ digest: zod_exports.string(),
25
+ signature: zod_exports.string()
26
+ })
27
+ },
28
+ request: zod_exports.object({
29
+ amount: zod_exports.string(),
30
+ currency: zod_exports.string(),
31
+ recipient: zod_exports.string()
32
+ })
33
+ }
34
+ });
35
+ var textEncoder = new TextEncoder();
36
+ function createSuiPaymentProofMessage({
37
+ challenge,
38
+ digest
39
+ }) {
40
+ return JSON.stringify({
41
+ domain: "suimpp.sui.payment-proof",
42
+ version: 1,
43
+ method: challenge.method,
44
+ intent: challenge.intent,
45
+ challengeId: challenge.id,
46
+ amount: challenge.request.amount,
47
+ currency: challenge.request.currency,
48
+ recipient: challenge.request.recipient,
49
+ digest
50
+ });
51
+ }
52
+ function createSuiPaymentProofBytes(message) {
53
+ return textEncoder.encode(createSuiPaymentProofMessage(message));
54
+ }
55
+ function parseAmountToRaw(amount, decimals) {
56
+ const [whole = "0", frac = ""] = amount.split(".");
57
+ const paddedFrac = frac.padEnd(decimals, "0").slice(0, decimals);
58
+ return BigInt(whole + paddedFrac);
59
+ }
60
+ var SUI_USDC_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
61
+ var SUI_USDC_TESTNET_TYPE = "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
62
+ var SUI_DOLLAR_TYPE = "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
63
+ var USDC = {
64
+ type: SUI_USDC_TYPE,
65
+ decimals: 6
66
+ };
67
+ var USDC_TESTNET = {
68
+ type: SUI_USDC_TESTNET_TYPE,
69
+ decimals: 6
70
+ };
71
+ var SUI_DOLLAR = {
72
+ type: SUI_DOLLAR_TYPE,
73
+ decimals: 6
74
+ };
75
+ function sui(options) {
76
+ if (!options.currency) {
77
+ throw new Error("[suimpp] Currency is required");
78
+ }
79
+ return Method_exports.toClient(suiCharge, {
80
+ async createCredential({ challenge }) {
81
+ const { amount, currency, recipient } = challenge.request;
82
+ if (currency !== options.currency.type) {
83
+ throw new Error(`Unsupported currency: ${currency}`);
84
+ }
85
+ const amountRaw = parseAmountToRaw(amount, options.currency.decimals);
86
+ const tx = new Transaction();
87
+ tx.setSender(options.signer.toSuiAddress());
88
+ tx.moveCall({
89
+ target: "0x2::balance::send_funds",
90
+ arguments: [
91
+ tx.balance({ type: options.currency.type, balance: amountRaw }),
92
+ tx.pure.address(recipient)
93
+ ],
94
+ typeArguments: [options.currency.type]
95
+ });
96
+ let result;
97
+ try {
98
+ if (options.execute) {
99
+ result = await options.execute(tx);
100
+ } else {
101
+ const execResult = await options.client.core.signAndExecuteTransaction({
102
+ transaction: await tx.build({ client: options.client }),
103
+ signer: options.signer,
104
+ include: { effects: true }
105
+ });
106
+ if (execResult.FailedTransaction) {
107
+ throw new Error(
108
+ execResult.FailedTransaction.status.error?.message ?? "Transaction failed"
109
+ );
110
+ }
111
+ if (!execResult.Transaction) {
112
+ throw new Error("Transaction failed");
113
+ }
114
+ result = execResult.Transaction;
115
+ }
116
+ } catch (err) {
117
+ const msg = err instanceof Error ? err.message : String(err);
118
+ throw new Error(`Payment transaction failed: ${msg}`);
119
+ }
120
+ const proof = await options.signer.signPersonalMessage(
121
+ createSuiPaymentProofBytes({
122
+ challenge,
123
+ digest: result.digest
124
+ })
125
+ );
126
+ return Credential_exports.serialize({
127
+ challenge,
128
+ payload: {
129
+ digest: result.digest,
130
+ signature: proof.signature
131
+ }
132
+ });
133
+ }
134
+ });
135
+ }
136
+ export {
137
+ SUI_DOLLAR,
138
+ SUI_DOLLAR_TYPE,
139
+ SUI_USDC_TESTNET_TYPE,
140
+ SUI_USDC_TYPE,
141
+ USDC,
142
+ USDC_TESTNET,
143
+ sui,
144
+ suiCharge
145
+ };
146
+ //# sourceMappingURL=client-YLNZOE5Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/src/method.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/src/proof.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/src/utils.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/src/constants.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/src/client.ts"],"sourcesContent":["import { Method, z } from 'mppx';\n\nexport const suiCharge = Method.from({\n intent: 'charge',\n name: 'sui',\n schema: {\n credential: {\n payload: z.object({\n digest: z.string(),\n signature: z.string(),\n }),\n },\n request: z.object({\n amount: z.string(),\n currency: z.string(),\n recipient: z.string(),\n }),\n },\n});\n","import type { Challenge } from 'mppx';\n\nexport interface SuiPaymentProofMessage {\n challenge: Challenge.Challenge<\n {\n amount: string;\n currency: string;\n recipient: string;\n },\n 'charge',\n 'sui'\n >;\n digest: string;\n}\n\nconst textEncoder = new TextEncoder();\n\nexport function createSuiPaymentProofMessage({\n challenge,\n digest,\n}: SuiPaymentProofMessage): string {\n return JSON.stringify({\n domain: 'suimpp.sui.payment-proof',\n version: 1,\n method: challenge.method,\n intent: challenge.intent,\n challengeId: challenge.id,\n amount: challenge.request.amount,\n currency: challenge.request.currency,\n recipient: challenge.request.recipient,\n digest,\n });\n}\n\nexport function createSuiPaymentProofBytes(\n message: SuiPaymentProofMessage,\n): Uint8Array {\n return textEncoder.encode(createSuiPaymentProofMessage(message));\n}\n","/**\n * Parse a string amount to raw bigint units without floating-point math.\n * \"0.01\" with 6 decimals → 10000n\n */\nexport function parseAmountToRaw(amount: string, decimals: number): bigint {\n const [whole = '0', frac = ''] = amount.split('.');\n const paddedFrac = frac.padEnd(decimals, '0').slice(0, decimals);\n return BigInt(whole + paddedFrac);\n}\n\n/**\n * Retry an async function with linear backoff.\n * Throws the last error if all attempts fail.\n */\nexport async function withRetry<T>(\n fn: () => Promise<T>,\n {\n attempts = 5,\n baseDelayMs = 1000,\n }: { attempts?: number; baseDelayMs?: number } = {},\n): Promise<T> {\n let lastError: unknown;\n for (let i = 0; i < attempts; i++) {\n try {\n return await fn();\n } catch (err) {\n lastError = err;\n if (i < attempts - 1) {\n await new Promise((r) => setTimeout(r, baseDelayMs * (i + 1)));\n }\n }\n }\n throw lastError;\n}\n","export interface Currency {\n type: string;\n decimals: number;\n}\n\nexport const SUI_USDC_TYPE =\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';\n\nexport const SUI_USDC_TESTNET_TYPE =\n '0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC';\n\nexport const SUI_DOLLAR_TYPE =\n '0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI';\n\nexport const USDC = {\n type: SUI_USDC_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n\nexport const USDC_TESTNET = {\n type: SUI_USDC_TESTNET_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n\nexport const SUI_DOLLAR = {\n type: SUI_DOLLAR_TYPE,\n decimals: 6,\n} as const satisfies Currency;\n","import type { ClientWithCoreApi } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { Credential, Method } from 'mppx';\nimport type { Currency } from './constants.js';\nimport { suiCharge } from './method.js';\nimport { createSuiPaymentProofBytes } from './proof.js';\nimport { parseAmountToRaw } from './utils.js';\n\nexport { suiCharge } from './method.js';\nexport {\n SUI_DOLLAR,\n SUI_DOLLAR_TYPE,\n SUI_USDC_TESTNET_TYPE,\n SUI_USDC_TYPE,\n USDC,\n USDC_TESTNET,\n} from './constants.js';\nexport type { Currency } from './constants.js';\n\nexport interface SuiChargeOptions {\n client: ClientWithCoreApi;\n signer: Signer;\n currency: Currency;\n /** Override transaction execution (e.g. to route through a gas manager). */\n execute?: (tx: Transaction) => Promise<{ digest: string }>;\n}\n\ntype TransactionResult = { digest: string };\n\nexport function sui(options: SuiChargeOptions) {\n if (!options.currency) {\n throw new Error('[suimpp] Currency is required');\n }\n\n return Method.toClient(suiCharge, {\n async createCredential({ challenge }) {\n const { amount, currency, recipient } = challenge.request;\n if (currency !== options.currency.type) {\n throw new Error(`Unsupported currency: ${currency}`);\n }\n const amountRaw = parseAmountToRaw(amount, options.currency.decimals);\n\n const tx = new Transaction();\n tx.setSender(options.signer.toSuiAddress());\n\n // `send_funds` so that the recipient receives the balance in ABs (not coins)\n tx.moveCall({\n target: '0x2::balance::send_funds',\n arguments: [\n tx.balance({ type: options.currency.type, balance: amountRaw }),\n tx.pure.address(recipient),\n ],\n typeArguments: [options.currency.type],\n });\n\n let result: TransactionResult;\n try {\n if (options.execute) {\n result = await options.execute(tx);\n } else {\n const execResult =\n await options.client.core.signAndExecuteTransaction({\n transaction: await tx.build({ client: options.client }),\n signer: options.signer,\n include: { effects: true },\n });\n if (execResult.FailedTransaction) {\n throw new Error(\n execResult.FailedTransaction.status.error?.message ??\n 'Transaction failed',\n );\n }\n if (!execResult.Transaction) {\n throw new Error('Transaction failed');\n }\n result = execResult.Transaction;\n }\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`Payment transaction failed: ${msg}`);\n }\n\n const proof = await options.signer.signPersonalMessage(\n createSuiPaymentProofBytes({\n challenge,\n digest: result.digest,\n }),\n );\n\n return Credential.serialize({\n challenge,\n payload: {\n digest: result.digest,\n signature: proof.signature,\n },\n });\n },\n });\n}\n"],"mappings":"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","names":["Method"]}
@@ -139,7 +139,7 @@ import {
139
139
  validateLabel,
140
140
  verifyCetusRouteCoinMatch,
141
141
  walletExists
142
- } from "./chunk-XQSJMXDP.js";
142
+ } from "./chunk-7MFY5PQG.js";
143
143
  import "./chunk-NXTB2IJH.js";
144
144
  import "./chunk-OCLKPYUU.js";
145
145
  import "./chunk-6JATGRLJ.js";
@@ -289,4 +289,4 @@ export {
289
289
  verifyCetusRouteCoinMatch,
290
290
  walletExists
291
291
  };
292
- //# sourceMappingURL=dist-IFJDNLBP.js.map
292
+ //# sourceMappingURL=dist-FQOCT4Z4.js.map
@@ -20594,9 +20594,9 @@ var init_binary_writer = __esm({
20594
20594
  writerFactory: () => new BinaryWriter()
20595
20595
  };
20596
20596
  BinaryWriter = class {
20597
- constructor(textEncoder2) {
20597
+ constructor(textEncoder3) {
20598
20598
  this.stack = [];
20599
- this.textEncoder = textEncoder2 !== null && textEncoder2 !== void 0 ? textEncoder2 : new TextEncoder();
20599
+ this.textEncoder = textEncoder3 !== null && textEncoder3 !== void 0 ? textEncoder3 : new TextEncoder();
20600
20600
  this.chunks = [];
20601
20601
  this.buf = [];
20602
20602
  }
@@ -66253,9 +66253,9 @@ var require_axios = __commonJS({
66253
66253
  };
66254
66254
  var readBlob$1 = readBlob2;
66255
66255
  var BOUNDARY_ALPHABET2 = platform.ALPHABET.ALPHA_DIGIT + "-_";
66256
- var textEncoder2 = typeof TextEncoder === "function" ? new TextEncoder() : new util__default["default"].TextEncoder();
66256
+ var textEncoder3 = typeof TextEncoder === "function" ? new TextEncoder() : new util__default["default"].TextEncoder();
66257
66257
  var CRLF2 = "\r\n";
66258
- var CRLF_BYTES2 = textEncoder2.encode(CRLF2);
66258
+ var CRLF_BYTES2 = textEncoder3.encode(CRLF2);
66259
66259
  var CRLF_BYTES_COUNT2 = 2;
66260
66260
  var FormDataPart2 = class {
66261
66261
  constructor(name, value) {
@@ -66263,11 +66263,11 @@ var require_axios = __commonJS({
66263
66263
  const isStringValue = utils$1.isString(value);
66264
66264
  let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ""}${CRLF2}`;
66265
66265
  if (isStringValue) {
66266
- value = textEncoder2.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF2));
66266
+ value = textEncoder3.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF2));
66267
66267
  } else {
66268
66268
  headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF2}`;
66269
66269
  }
66270
- this.headers = textEncoder2.encode(headers + CRLF2);
66270
+ this.headers = textEncoder3.encode(headers + CRLF2);
66271
66271
  this.contentLength = isStringValue ? value.byteLength : value.size;
66272
66272
  this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT2;
66273
66273
  this.name = name;
@@ -66306,8 +66306,8 @@ var require_axios = __commonJS({
66306
66306
  if (boundary.length < 1 || boundary.length > 70) {
66307
66307
  throw Error("boundary must be 10-70 characters long");
66308
66308
  }
66309
- const boundaryBytes = textEncoder2.encode("--" + boundary + CRLF2);
66310
- const footerBytes = textEncoder2.encode("--" + boundary + "--" + CRLF2);
66309
+ const boundaryBytes = textEncoder3.encode("--" + boundary + CRLF2);
66310
+ const footerBytes = textEncoder3.encode("--" + boundary + "--" + CRLF2);
66311
66311
  let contentLength = footerBytes.byteLength;
66312
66312
  const parts = Array.from(form.entries()).map(([name, value]) => {
66313
66313
  const part = new FormDataPart2(name, value);
@@ -120501,40 +120501,77 @@ var init_dist8 = __esm({
120501
120501
  });
120502
120502
  var client_exports2 = {};
120503
120503
  __export(client_exports2, {
120504
+ SUI_DOLLAR: () => SUI_DOLLAR,
120505
+ SUI_DOLLAR_TYPE: () => SUI_DOLLAR_TYPE,
120506
+ SUI_USDC_TESTNET_TYPE: () => SUI_USDC_TESTNET_TYPE,
120504
120507
  SUI_USDC_TYPE: () => SUI_USDC_TYPE,
120508
+ USDC: () => USDC,
120509
+ USDC_TESTNET: () => USDC_TESTNET,
120505
120510
  sui: () => sui,
120506
120511
  suiCharge: () => suiCharge
120507
120512
  });
120513
+ function createSuiPaymentProofMessage({
120514
+ challenge: challenge2,
120515
+ digest
120516
+ }) {
120517
+ return JSON.stringify({
120518
+ domain: "suimpp.sui.payment-proof",
120519
+ version: 1,
120520
+ method: challenge2.method,
120521
+ intent: challenge2.intent,
120522
+ challengeId: challenge2.id,
120523
+ amount: challenge2.request.amount,
120524
+ currency: challenge2.request.currency,
120525
+ recipient: challenge2.request.recipient,
120526
+ digest
120527
+ });
120528
+ }
120529
+ function createSuiPaymentProofBytes(message) {
120530
+ return textEncoder2.encode(createSuiPaymentProofMessage(message));
120531
+ }
120508
120532
  function parseAmountToRaw(amount2, decimals2) {
120509
120533
  const [whole = "0", frac = ""] = amount2.split(".");
120510
120534
  const paddedFrac = frac.padEnd(decimals2, "0").slice(0, decimals2);
120511
120535
  return BigInt(whole + paddedFrac);
120512
120536
  }
120513
120537
  function sui(options) {
120514
- const address2 = options.signer.toSuiAddress();
120515
- const decimals2 = options.decimals ?? 6;
120538
+ if (!options.currency) {
120539
+ throw new Error("[suimpp] Currency is required");
120540
+ }
120516
120541
  return Method_exports.toClient(suiCharge, {
120517
120542
  async createCredential({ challenge: challenge2 }) {
120518
120543
  const { amount: amount2, currency: currency2, recipient } = challenge2.request;
120519
- const amountRaw = parseAmountToRaw(amount2, decimals2);
120544
+ if (currency2 !== options.currency.type) {
120545
+ throw new Error(`Unsupported currency: ${currency2}`);
120546
+ }
120547
+ const amountRaw = parseAmountToRaw(amount2, options.currency.decimals);
120520
120548
  const tx = new Transaction();
120521
- tx.setSender(address2);
120522
- const payment = coinWithBalance({ balance: amountRaw, type: currency2 });
120523
- tx.transferObjects([payment], recipient);
120549
+ tx.setSender(options.signer.toSuiAddress());
120550
+ tx.moveCall({
120551
+ target: "0x2::balance::send_funds",
120552
+ arguments: [
120553
+ tx.balance({ type: options.currency.type, balance: amountRaw }),
120554
+ tx.pure.address(recipient)
120555
+ ],
120556
+ typeArguments: [options.currency.type]
120557
+ });
120524
120558
  let result;
120525
120559
  try {
120526
120560
  if (options.execute) {
120527
120561
  result = await options.execute(tx);
120528
120562
  } else {
120529
- const built = await tx.build({ client: options.client });
120530
- const { signature: signature2 } = await options.signer.signTransaction(built);
120531
- const execResult = await options.client.core.executeTransaction({
120532
- transaction: built,
120533
- signatures: [signature2],
120563
+ const execResult = await options.client.core.signAndExecuteTransaction({
120564
+ transaction: await tx.build({ client: options.client }),
120565
+ signer: options.signer,
120534
120566
  include: { effects: true }
120535
120567
  });
120536
120568
  if (execResult.FailedTransaction) {
120537
- throw new Error(execResult.FailedTransaction.status.error?.message ?? "Transaction failed");
120569
+ throw new Error(
120570
+ execResult.FailedTransaction.status.error?.message ?? "Transaction failed"
120571
+ );
120572
+ }
120573
+ if (!execResult.Transaction) {
120574
+ throw new Error("Transaction failed");
120538
120575
  }
120539
120576
  result = execResult.Transaction;
120540
120577
  }
@@ -120542,26 +120579,42 @@ function sui(options) {
120542
120579
  const msg = err instanceof Error ? err.message : String(err);
120543
120580
  throw new Error(`Payment transaction failed: ${msg}`);
120544
120581
  }
120582
+ const proof = await options.signer.signPersonalMessage(
120583
+ createSuiPaymentProofBytes({
120584
+ challenge: challenge2,
120585
+ digest: result.digest
120586
+ })
120587
+ );
120545
120588
  return Credential_exports.serialize({
120546
120589
  challenge: challenge2,
120547
- payload: { digest: result.digest }
120590
+ payload: {
120591
+ digest: result.digest,
120592
+ signature: proof.signature
120593
+ }
120548
120594
  });
120549
120595
  }
120550
120596
  });
120551
120597
  }
120552
120598
  var suiCharge;
120599
+ var textEncoder2;
120553
120600
  var SUI_USDC_TYPE;
120601
+ var SUI_USDC_TESTNET_TYPE;
120602
+ var SUI_DOLLAR_TYPE;
120603
+ var USDC;
120604
+ var USDC_TESTNET;
120605
+ var SUI_DOLLAR;
120554
120606
  var init_client7 = __esm({
120555
- "../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_0b94899a6b1cb79b7850473c6a4b48f9/node_modules/@suimpp/mpp/dist/client.js"() {
120556
- init_dist8();
120607
+ "../../node_modules/.pnpm/@suimpp+mpp@0.7.0_@modelcontextprotocol+sdk@1.28.0_zod@3.25.76__express@5.2.1_hono@4.12_f01adfc448f369aa1dacd5a54f4d2679/node_modules/@suimpp/mpp/dist/client.js"() {
120557
120608
  init_transactions();
120609
+ init_dist8();
120558
120610
  suiCharge = Method_exports.from({
120559
120611
  intent: "charge",
120560
120612
  name: "sui",
120561
120613
  schema: {
120562
120614
  credential: {
120563
120615
  payload: zod_exports.object({
120564
- digest: zod_exports.string()
120616
+ digest: zod_exports.string(),
120617
+ signature: zod_exports.string()
120565
120618
  })
120566
120619
  },
120567
120620
  request: zod_exports.object({
@@ -120571,7 +120624,22 @@ var init_client7 = __esm({
120571
120624
  })
120572
120625
  }
120573
120626
  });
120627
+ textEncoder2 = new TextEncoder();
120574
120628
  SUI_USDC_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
120629
+ SUI_USDC_TESTNET_TYPE = "0xa1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC";
120630
+ SUI_DOLLAR_TYPE = "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI";
120631
+ USDC = {
120632
+ type: SUI_USDC_TYPE,
120633
+ decimals: 6
120634
+ };
120635
+ USDC_TESTNET = {
120636
+ type: SUI_USDC_TESTNET_TYPE,
120637
+ decimals: 6
120638
+ };
120639
+ SUI_DOLLAR = {
120640
+ type: SUI_DOLLAR_TYPE,
120641
+ decimals: 6
120642
+ };
120575
120643
  }
120576
120644
  });
120577
120645
  // @__NO_SIDE_EFFECTS__
@@ -133762,6 +133830,9 @@ var KeypairSigner = class {
133762
133830
  async signTransaction(txBytes) {
133763
133831
  return this.keypair.signTransaction(txBytes);
133764
133832
  }
133833
+ async signPersonalMessage(messageBytes) {
133834
+ return this.keypair.signPersonalMessage(messageBytes);
133835
+ }
133765
133836
  /** Access the underlying keypair for APIs that still require it directly. */
133766
133837
  getKeypair() {
133767
133838
  return this.keypair;
@@ -133788,6 +133859,9 @@ var ZkLoginSigner = class {
133788
133859
  })
133789
133860
  };
133790
133861
  }
133862
+ async signPersonalMessage(_messageBytes) {
133863
+ throw new Error("ZkLoginSigner.signPersonalMessage is not yet implemented. Use KeypairSigner for sdk.pay() until grief-protection signing is wired for zkLogin.");
133864
+ }
133791
133865
  isExpired(currentEpoch) {
133792
133866
  return currentEpoch >= this.maxEpoch;
133793
133867
  }
@@ -138689,7 +138763,7 @@ var T2000 = class _T2000 extends import_index2.default {
138689
138763
  this.enforcer.assertNotLocked();
138690
138764
  this.enforcer.check({ operation: "pay", amount: options.maxPrice ?? 1 });
138691
138765
  const { Mppx } = await Promise.resolve().then(() => (init_client6(), client_exports));
138692
- const { sui: sui2 } = await Promise.resolve().then(() => (init_client7(), client_exports2));
138766
+ const { sui: sui2, USDC: USDC2 } = await Promise.resolve().then(() => (init_client7(), client_exports2));
138693
138767
  const client = this.client;
138694
138768
  const signer = this._signer;
138695
138769
  const signerAddress = signer.getAddress();
@@ -138697,10 +138771,14 @@ var T2000 = class _T2000 extends import_index2.default {
138697
138771
  polyfill: false,
138698
138772
  methods: [sui2({
138699
138773
  client,
138700
- signer: { toSuiAddress: () => signerAddress },
138774
+ currency: USDC2,
138775
+ signer: {
138776
+ toSuiAddress: () => signerAddress,
138777
+ signPersonalMessage: (bytes) => signer.signPersonalMessage(bytes)
138778
+ },
138701
138779
  execute: async (tx) => {
138702
138780
  const result = await executeTx(client, signer, () => tx);
138703
- return { digest: result.digest, effects: result.effects };
138781
+ return { digest: result.digest };
138704
138782
  }
138705
138783
  })]
138706
138784
  });
@@ -141220,7 +141298,7 @@ ${context}
141220
141298
  })
141221
141299
  );
141222
141300
  }
141223
- var PKG_VERSION = "2.12.0";
141301
+ var PKG_VERSION = "2.13.0";
141224
141302
  console.log = (...args) => console.error("[log]", ...args);
141225
141303
  console.warn = (...args) => console.error("[warn]", ...args);
141226
141304
  async function startMcpServer(opts) {
@@ -141311,4 +141389,4 @@ axios/dist/node/axios.cjs:
141311
141389
  @scure/bip39/index.js:
141312
141390
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
141313
141391
  */
141314
- //# sourceMappingURL=dist-5O3HO6YP.js.map
141392
+ //# sourceMappingURL=dist-L7I3XOJK.js.map