@t2000/cli 0.22.26 → 0.23.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/README.md +11 -97
- package/dist/{ccip-JEEJV65M.js → ccip-XP27NGI7.js} +3 -3
- package/dist/{chunk-A5X4KG7U.js → chunk-3I6VJOM6.js} +210 -970
- package/dist/chunk-3I6VJOM6.js.map +1 -0
- package/dist/chunk-4N76GQCL.js +35382 -0
- package/dist/chunk-4N76GQCL.js.map +1 -0
- package/dist/{chunk-XOAZJ42V.js → chunk-DWOZSUBE.js} +588 -584
- package/dist/{chunk-XOAZJ42V.js.map → chunk-DWOZSUBE.js.map} +1 -1
- package/dist/chunk-EI3GHTKX.js +968 -0
- package/dist/chunk-EI3GHTKX.js.map +1 -0
- package/dist/{chunk-EEPD7SHV.js → chunk-TYYJRUQI.js} +15755 -15918
- package/dist/chunk-TYYJRUQI.js.map +1 -0
- package/dist/client-5KJQTN5X.js +84 -0
- package/dist/client-5KJQTN5X.js.map +1 -0
- package/dist/{client-R3NRAXMD.js → client-IXUBQ3HM.js} +334 -638
- package/dist/client-IXUBQ3HM.js.map +1 -0
- package/dist/{dist-NBWIWHHS.js → dist-E7HUP73Q.js} +5 -29
- package/dist/{dist-KJM2NT74.js → dist-W4Q4YXD7.js} +4200 -603
- package/dist/dist-W4Q4YXD7.js.map +1 -0
- package/dist/index.js +29 -1016
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/dist/chunk-3WKGZRWT.js +0 -77733
- package/dist/chunk-3WKGZRWT.js.map +0 -1
- package/dist/chunk-77SWBATH.js +0 -204
- package/dist/chunk-77SWBATH.js.map +0 -1
- package/dist/chunk-A5X4KG7U.js.map +0 -1
- package/dist/chunk-EEPD7SHV.js.map +0 -1
- package/dist/client-CK5OR2TP.js +0 -746
- package/dist/client-CK5OR2TP.js.map +0 -1
- package/dist/client-R3NRAXMD.js.map +0 -1
- package/dist/dist-KJM2NT74.js.map +0 -1
- /package/dist/{ccip-JEEJV65M.js.map → ccip-XP27NGI7.js.map} +0 -0
- /package/dist/{dist-NBWIWHHS.js.map → dist-E7HUP73Q.js.map} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
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 {
|
|
3
|
+
Credential_exports,
|
|
4
|
+
Method_exports,
|
|
5
|
+
zod_exports
|
|
6
|
+
} from "./chunk-TYYJRUQI.js";
|
|
7
|
+
import "./chunk-NGS6K3I3.js";
|
|
8
|
+
import "./chunk-EI3GHTKX.js";
|
|
9
|
+
import "./chunk-7LGHVVIJ.js";
|
|
10
|
+
import {
|
|
11
|
+
Transaction,
|
|
12
|
+
coinWithBalance
|
|
13
|
+
} from "./chunk-DWOZSUBE.js";
|
|
14
|
+
import "./chunk-3XUF7GM3.js";
|
|
15
|
+
import "./chunk-YPWSCLE3.js";
|
|
16
|
+
|
|
17
|
+
// ../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_c2ad5be151eba2374dc924cfe6dd724c/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
|
+
})
|
|
26
|
+
},
|
|
27
|
+
request: zod_exports.object({
|
|
28
|
+
amount: zod_exports.string(),
|
|
29
|
+
currency: zod_exports.string(),
|
|
30
|
+
recipient: zod_exports.string()
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
function parseAmountToRaw(amount, decimals) {
|
|
35
|
+
const [whole = "0", frac = ""] = amount.split(".");
|
|
36
|
+
const paddedFrac = frac.padEnd(decimals, "0").slice(0, decimals);
|
|
37
|
+
return BigInt(whole + paddedFrac);
|
|
38
|
+
}
|
|
39
|
+
var SUI_USDC_TYPE = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
|
|
40
|
+
function sui(options) {
|
|
41
|
+
const address = options.signer.toSuiAddress();
|
|
42
|
+
const decimals = options.decimals ?? 6;
|
|
43
|
+
return Method_exports.toClient(suiCharge, {
|
|
44
|
+
async createCredential({ challenge }) {
|
|
45
|
+
const { amount, currency, recipient } = challenge.request;
|
|
46
|
+
const amountRaw = parseAmountToRaw(amount, decimals);
|
|
47
|
+
const tx = new Transaction();
|
|
48
|
+
tx.setSender(address);
|
|
49
|
+
const payment = coinWithBalance({ balance: amountRaw, type: currency });
|
|
50
|
+
tx.transferObjects([payment], recipient);
|
|
51
|
+
let result;
|
|
52
|
+
try {
|
|
53
|
+
if (options.execute) {
|
|
54
|
+
result = await options.execute(tx);
|
|
55
|
+
} else {
|
|
56
|
+
const built = await tx.build({ client: options.client });
|
|
57
|
+
const { signature } = await options.signer.signTransaction(built);
|
|
58
|
+
const execResult = await options.client.core.executeTransaction({
|
|
59
|
+
transaction: built,
|
|
60
|
+
signatures: [signature],
|
|
61
|
+
include: { effects: true }
|
|
62
|
+
});
|
|
63
|
+
if (execResult.FailedTransaction) {
|
|
64
|
+
throw new Error(execResult.FailedTransaction.status.error?.message ?? "Transaction failed");
|
|
65
|
+
}
|
|
66
|
+
result = execResult.Transaction;
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
70
|
+
throw new Error(`Payment transaction failed: ${msg}`);
|
|
71
|
+
}
|
|
72
|
+
return Credential_exports.serialize({
|
|
73
|
+
challenge,
|
|
74
|
+
payload: { digest: result.digest }
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
SUI_USDC_TYPE,
|
|
81
|
+
sui,
|
|
82
|
+
suiCharge
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=client-5KJQTN5X.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_c2ad5be151eba2374dc924cfe6dd724c/node_modules/@suimpp/mpp/src/method.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_c2ad5be151eba2374dc924cfe6dd724c/node_modules/@suimpp/mpp/src/utils.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_c2ad5be151eba2374dc924cfe6dd724c/node_modules/@suimpp/mpp/src/constants.ts","../../../node_modules/.pnpm/@suimpp+mpp@0.3.1_@modelcontextprotocol+sdk@1.28.0_zod@4.3.6__express@5.2.1_hono@4.12.9_c2ad5be151eba2374dc924cfe6dd724c/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 }),\n },\n request: z.object({\n amount: z.string(),\n currency: z.string(),\n recipient: z.string(),\n }),\n },\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 { attempts = 5, baseDelayMs = 1000 }: { 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 const SUI_USDC_TYPE =\n '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC';\n","import { Method, Credential } from 'mppx';\nimport type { ClientWithCoreApi } from '@mysten/sui/client';\nimport type { Signer } from '@mysten/sui/cryptography';\nimport { coinWithBalance, Transaction } from '@mysten/sui/transactions';\nimport { suiCharge } from './method.js';\nimport { parseAmountToRaw } from './utils.js';\n\nexport { suiCharge } from './method.js';\nexport { SUI_USDC_TYPE } from './constants.js';\n\nexport interface SuiChargeOptions {\n client: ClientWithCoreApi;\n signer: Signer;\n /** Number of decimal places for the currency (default: 6, e.g. USDC). */\n decimals?: number;\n /** Override transaction execution (e.g. to route through a gas manager). */\n execute?: (tx: Transaction) => Promise<{ digest: string }>;\n}\n\nexport function sui(options: SuiChargeOptions) {\n const address = options.signer.toSuiAddress();\n const decimals = options.decimals ?? 6;\n\n return Method.toClient(suiCharge, {\n async createCredential({ challenge }) {\n const { amount, currency, recipient } = challenge.request;\n const amountRaw = parseAmountToRaw(amount, decimals);\n\n const tx = new Transaction();\n tx.setSender(address);\n\n const payment = coinWithBalance({ balance: amountRaw, type: currency });\n tx.transferObjects([payment], recipient);\n\n let result;\n try {\n if (options.execute) {\n result = await options.execute(tx);\n } else {\n const built = await tx.build({ client: options.client });\n const { signature } = await options.signer.signTransaction(built);\n const execResult = await options.client.core.executeTransaction({\n transaction: built,\n signatures: [signature],\n include: { effects: true },\n });\n if (execResult.FailedTransaction) {\n throw new Error(execResult.FailedTransaction.status.error?.message ?? '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 return Credential.serialize({\n challenge,\n payload: { digest: result.digest },\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;MAAO,CAClB;IAAA;IAEH,SAAS,YAAE,OAAO;MAChB,QAAQ,YAAE,OAAA;MACV,UAAU,YAAE,OAAA;MACZ,WAAW,YAAE,OAAA;IAAO,CACrB;EAAA;AAEL,CAAC;ACbM,SAAS,iBAAiB,QAAgB,UAA0B;AACzE,QAAM,CAAC,QAAQ,KAAK,OAAO,EAAE,IAAI,OAAO,MAAM,GAAG;AACjD,QAAM,aAAa,KAAK,OAAO,UAAU,GAAG,EAAE,MAAM,GAAG,QAAQ;AAC/D,SAAO,OAAO,QAAQ,UAAU;AAClC;ACRO,IAAM,gBACX;ACkBK,SAAS,IAAI,SAA2B;AAC7C,QAAM,UAAU,QAAQ,OAAO,aAAA;AAC/B,QAAM,WAAW,QAAQ,YAAY;AAErC,SAAOA,eAAO,SAAS,WAAW;IAChC,MAAM,iBAAiB,EAAE,UAAA,GAAa;AACpC,YAAM,EAAE,QAAQ,UAAU,UAAA,IAAc,UAAU;AAClD,YAAM,YAAY,iBAAiB,QAAQ,QAAQ;AAEnD,YAAM,KAAK,IAAI,YAAA;AACf,SAAG,UAAU,OAAO;AAEpB,YAAM,UAAU,gBAAgB,EAAE,SAAS,WAAW,MAAM,SAAA,CAAU;AACtE,SAAG,gBAAgB,CAAC,OAAO,GAAG,SAAS;AAEvC,UAAI;AACJ,UAAI;AACF,YAAI,QAAQ,SAAS;AACnB,mBAAS,MAAM,QAAQ,QAAQ,EAAE;QACnC,OAAO;AACL,gBAAM,QAAQ,MAAM,GAAG,MAAM,EAAE,QAAQ,QAAQ,OAAA,CAAQ;AACvD,gBAAM,EAAE,UAAA,IAAc,MAAM,QAAQ,OAAO,gBAAgB,KAAK;AAChE,gBAAM,aAAa,MAAM,QAAQ,OAAO,KAAK,mBAAmB;YAC9D,aAAa;YACb,YAAY,CAAC,SAAS;YACtB,SAAS,EAAE,SAAS,KAAA;UAAK,CAC1B;AACD,cAAI,WAAW,mBAAmB;AAChC,kBAAM,IAAI,MAAM,WAAW,kBAAkB,OAAO,OAAO,WAAW,oBAAoB;UAC5F;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,aAAO,mBAAW,UAAU;QAC1B;QACA,SAAS,EAAE,QAAQ,OAAO,OAAA;MAAO,CAClC;IACH;EAAA,CACD;AACH;","names":["Method"]}
|