@t2000/cli 2.11.1 → 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":";;;;;;;;;;;;;;;;;AAEO,IAAM,YAAY,eAAO,KAAK;EACnC,QAAQ;EACR,MAAM;EACN,QAAQ;IACN,YAAY;MACV,SAAS,YAAE,OAAO;QAChB,QAAQ,YAAE,OAAA;QACV,WAAW,YAAE,OAAA;MAAO,CACrB;IAAA;IAEH,SAAS,YAAE,OAAO;MAChB,QAAQ,YAAE,OAAA;MACV,UAAU,YAAE,OAAA;MACZ,WAAW,YAAE,OAAA;I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SAAS;QACV,QAAQ;QACR,WAAW;UACT,GAAG,QAAQ,EAAE,MAAM,QAAQ,SAAS,MAAM,SAAS,UAAA,CAAW;UAC9D,GAAG,KAAK,QAAQ,SAAS;QAAA;QAE3B,eAAe,CAAC,QAAQ,SAAS,IAAI;MAAA,CACtC;AAED,UAAI;AACJ,UAAI;AACF,YAAI,QAAQ,SAAS;AACnB,mBAAS,MAAM,QAAQ,QAAQ,EAAE;QACnC,OAAO;AACL,gBAAM,aACJ,MAAM,QAAQ,OAAO,KAAK,0BAA0B;YAClD,aAAa,MAAM,GAAG,MAAM,EAAE,QAAQ,QAAQ,OAAA,CAAQ;YACtD,QAAQ,QAAQ;YAChB,SAAS,EAAE,SAAS,KAAA;UAAK,CAC1B;AACH,cAAI,WAAW,mBAAmB;AAChC,kBAAM,IAAI;cACR,WAAW,kBAAkB,OAAO,OAAO,WACzC;YAAA;UAEN;AACA,cAAI,CAAC,WAAW,aAAa;AAC3B,kBAAM,IAAI,MAAM,oBAAoB;UACtC;AACA,mBAAS,WAAW;QACtB;MACF,SAAS,KAAc;AACrB,cAAM,MAAM,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC3D,cAAM,IAAI,MAAM,+BAA+B,GAAG,EAAE;MACtD;AAEA,YAAM,QAAQ,MAAM,QAAQ,OAAO;QACjC,2BAA2B;UACzB;UACA,QAAQ,OAAO;QAAA,CAChB;MAAA;AAGH,aAAO,mBAAW,UAAU;QAC1B;QACA,SAAS;UACP,QAAQ,OAAO;UACf,WAAW,MAAM;QAAA;MACnB,CACD;IACH;EAAA,CACD;AACH;","names":["Method"]}
@@ -139,7 +139,7 @@ import {
139
139
  validateLabel,
140
140
  verifyCetusRouteCoinMatch,
141
141
  walletExists
142
- } from "./chunk-3DGYEM62.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-546IUBM4.js.map
292
+ //# sourceMappingURL=dist-FQOCT4Z4.js.map