moltspay 0.2.0 → 0.2.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.
Files changed (49) hide show
  1. package/dist/chains/index.d.mts +6 -6
  2. package/dist/chains/index.d.ts +6 -6
  3. package/dist/chains/index.js +2 -2
  4. package/dist/chains/index.js.map +1 -1
  5. package/dist/chains/index.mjs +2 -2
  6. package/dist/chains/index.mjs.map +1 -1
  7. package/dist/cli.js +36 -36
  8. package/dist/cli.js.map +1 -1
  9. package/dist/cli.mjs +36 -36
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/guide/index.d.mts +7 -7
  12. package/dist/guide/index.d.ts +7 -7
  13. package/dist/guide/index.js +50 -50
  14. package/dist/guide/index.js.map +1 -1
  15. package/dist/guide/index.mjs +50 -50
  16. package/dist/guide/index.mjs.map +1 -1
  17. package/dist/{index-CZzgdtin.d.mts → index-CyFg9s2m.d.mts} +1 -1
  18. package/dist/{index-CZzgdtin.d.ts → index-CyFg9s2m.d.ts} +1 -1
  19. package/dist/index.d.mts +89 -89
  20. package/dist/index.d.ts +89 -89
  21. package/dist/index.js +275 -275
  22. package/dist/index.js.map +1 -1
  23. package/dist/index.mjs +275 -275
  24. package/dist/index.mjs.map +1 -1
  25. package/dist/orders/index.d.mts +13 -13
  26. package/dist/orders/index.d.ts +13 -13
  27. package/dist/orders/index.js +10 -10
  28. package/dist/orders/index.js.map +1 -1
  29. package/dist/orders/index.mjs +10 -10
  30. package/dist/orders/index.mjs.map +1 -1
  31. package/dist/permit/index.d.mts +11 -11
  32. package/dist/permit/index.d.ts +11 -11
  33. package/dist/permit/index.js +14 -14
  34. package/dist/permit/index.js.map +1 -1
  35. package/dist/permit/index.mjs +14 -14
  36. package/dist/permit/index.mjs.map +1 -1
  37. package/dist/verify/index.d.mts +4 -4
  38. package/dist/verify/index.d.ts +4 -4
  39. package/dist/verify/index.js +13 -13
  40. package/dist/verify/index.js.map +1 -1
  41. package/dist/verify/index.mjs +13 -13
  42. package/dist/verify/index.mjs.map +1 -1
  43. package/dist/wallet/index.d.mts +72 -72
  44. package/dist/wallet/index.d.ts +72 -72
  45. package/dist/wallet/index.js +48 -48
  46. package/dist/wallet/index.js.map +1 -1
  47. package/dist/wallet/index.mjs +48 -48
  48. package/dist/wallet/index.mjs.map +1 -1
  49. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ChainName, a as ChainConfig, P as PaymentAgentConfig, b as CreateInvoiceParams, I as Invoice, V as VerifyOptions, c as VerifyResult, W as WalletBalance, A as AuditAction, d as AuditEntry } from './index-CZzgdtin.js';
2
- export { E as EIP712TypedData, e as PendingTransfer, f as PermitExecuteResult, g as PermitRequest, h as PermitSignature, S as SecureWalletConfig, i as SecurityLimits, T as TransferParams, j as TransferResult } from './index-CZzgdtin.js';
1
+ import { C as ChainName, a as ChainConfig, P as PaymentAgentConfig, b as CreateInvoiceParams, I as Invoice, V as VerifyOptions, c as VerifyResult, W as WalletBalance, A as AuditAction, d as AuditEntry } from './index-CyFg9s2m.js';
2
+ export { E as EIP712TypedData, e as PendingTransfer, f as PermitExecuteResult, g as PermitRequest, h as PermitSignature, S as SecureWalletConfig, i as SecurityLimits, T as TransferParams, j as TransferResult } from './index-CyFg9s2m.js';
3
3
  export { CreateWalletOptions, CreateWalletResult, PermitData, PermitWallet, PermitWalletConfig, SecureWallet, TransferWithPermitParams, TransferWithPermitResult, Wallet, WalletData, createWallet, formatPermitRequest, getWalletAddress, loadWallet, walletExists } from './wallet/index.js';
4
4
  export { PermitPayment } from './permit/index.js';
5
5
  export { CreateOrderParams, MemoryOrderStore, Order, OrderManager, OrderStatus, OrderStore } from './orders/index.js';
@@ -8,12 +8,12 @@ export { PaymentGuideParams, extractTransactionHash, generatePaymentGuide, gener
8
8
  export { CHAINS, ERC20_ABI, getChain, getChainById, listChains } from './chains/index.js';
9
9
 
10
10
  /**
11
- * PaymentAgent - 核心支付代理
11
+ * PaymentAgent - Core Payment Agent
12
12
  *
13
- * 功能:
14
- * - 生成 Invoice(支付请求)
15
- * - 验证链上支付
16
- * - 生成钱包深度链接
13
+ * Features:
14
+ * - Generate Invoice (payment request)
15
+ * - Verify on-chain payment
16
+ * - Generate wallet deep link
17
17
  */
18
18
 
19
19
  declare class PaymentAgent {
@@ -25,38 +25,38 @@ declare class PaymentAgent {
25
25
  static readonly PROTOCOL_VERSION = "1.0";
26
26
  constructor(config?: PaymentAgentConfig);
27
27
  /**
28
- * 生成支付请求(Invoice)
28
+ * Generate payment request(Invoice)
29
29
  */
30
30
  createInvoice(params: CreateInvoiceParams): Invoice;
31
31
  /**
32
- * 生成钱包深度链接(支持 MetaMask 等)
32
+ * Generate wallet deep link(supports MetaMask etc)
33
33
  */
34
34
  generateDeepLink(amount: number, memo: string): string;
35
35
  /**
36
- * 验证链上支付
36
+ * Verify on-chain payment
37
37
  */
38
38
  verifyPayment(txHash: string, options?: VerifyOptions): Promise<VerifyResult>;
39
39
  /**
40
- * 扫描最近转账(按金额匹配)
40
+ * Scan recent transfers (match by amount)
41
41
  */
42
42
  scanRecentTransfers(expectedAmount: number, timeoutMinutes?: number): Promise<VerifyResult>;
43
43
  /**
44
- * 获取钱包余额
44
+ * Get wallet balance
45
45
  */
46
46
  getBalance(address?: string): Promise<WalletBalance>;
47
47
  /**
48
- * 格式化 Invoice 为人类可读消息
48
+ * Format Invoice as human-readable message
49
49
  */
50
50
  formatInvoiceMessage(invoice: Invoice, includeJson?: boolean): string;
51
51
  }
52
52
 
53
53
  /**
54
- * AuditLog - 不可篡改审计日志
54
+ * AuditLog - Immutable Audit Log
55
55
  *
56
- * 特点:
57
- * - 链式哈希,任何修改都会破坏链条
58
- * - 按日期分文件存储
59
- * - JSONL 格式便于追加和解析
56
+ * Features:
57
+ * - Hash-chained, any modification breaks the chain
58
+ * - Stored by date in separate files
59
+ * - JSONL format for easy append and parse
60
60
  */
61
61
 
62
62
  interface LogParams {
@@ -75,22 +75,22 @@ declare class AuditLog {
75
75
  private lastHash;
76
76
  constructor(basePath?: string);
77
77
  /**
78
- * 记录审计日志
78
+ * Record audit log
79
79
  */
80
80
  log(params: LogParams): Promise<AuditEntry>;
81
81
  /**
82
- * 读取指定日期的日志
82
+ * Read logs for specified date
83
83
  */
84
84
  read(date?: Date): AuditEntry[];
85
85
  /**
86
- * 验证日志完整性
86
+ * Verify log integrity
87
87
  */
88
88
  verify(date?: Date): {
89
89
  valid: boolean;
90
90
  errors: string[];
91
91
  };
92
92
  /**
93
- * 搜索日志
93
+ * Search logs
94
94
  */
95
95
  search(filter: Partial<{
96
96
  action: AuditAction;
@@ -101,159 +101,159 @@ declare class AuditLog {
101
101
  endDate: Date;
102
102
  }>): AuditEntry[];
103
103
  /**
104
- * 获取日志文件路径
104
+ * Get log file path
105
105
  */
106
106
  private getFilePath;
107
107
  /**
108
- * 计算条目哈希
108
+ * Calculate entry hash
109
109
  */
110
110
  private calculateHash;
111
111
  /**
112
- * 加载最后一条日志的哈希
112
+ * Load last log entry hash
113
113
  */
114
114
  private loadLastHash;
115
115
  /**
116
- * 确保目录存在
116
+ * Ensure directory exists
117
117
  */
118
118
  private ensureDir;
119
119
  }
120
120
 
121
121
  /**
122
- * Receipt - 交易收据生成
122
+ * Receipt - Transaction receipt generation
123
123
  *
124
- * 用于生成标准化的交易收据,便于对账/报销/审计
124
+ * Generate standardized transaction receipts for reconciliation/reimbursement/audit
125
125
  */
126
126
 
127
127
  interface ReceiptParams {
128
- /** 发票号(自动生成或指定) */
128
+ /** Invoice ID (auto-generated or specified) */
129
129
  invoiceId?: string;
130
- /** 订单号 */
130
+ /** Order ID */
131
131
  orderId: string;
132
- /** 服务名称 */
132
+ /** Service name */
133
133
  service: string;
134
- /** 服务描述 */
134
+ /** Service description */
135
135
  description?: string;
136
- /** 金额 */
136
+ /** Amount */
137
137
  amount: number;
138
138
  /** Token */
139
139
  token?: 'USDC' | 'USDT' | 'ETH';
140
- /** */
140
+ /** Chain */
141
141
  chain: ChainName;
142
- /** 交易 hash */
142
+ /** Transaction hash */
143
143
  txHash: string;
144
- /** 付款方地址 */
144
+ /** Payer address */
145
145
  payerAddress: string;
146
- /** 收款方地址 */
146
+ /** Recipient address */
147
147
  recipientAddress: string;
148
- /** 交付信息 */
148
+ /** Delivery info */
149
149
  delivery?: {
150
- /** 交付物 URL */
150
+ /** Delivery URL */
151
151
  url?: string;
152
- /** 文件 hash */
152
+ /** File hash */
153
153
  fileHash?: string;
154
- /** 交付时间 */
154
+ /** Delivery timestamp */
155
155
  deliveredAt?: string;
156
156
  };
157
- /** 额外元数据 */
157
+ /** Additional metadata */
158
158
  metadata?: Record<string, unknown>;
159
159
  }
160
160
  interface Receipt {
161
161
  type: 'receipt';
162
162
  version: '1.0';
163
- /** 发票号 */
163
+ /** Invoice ID */
164
164
  invoiceId: string;
165
- /** 订单号 */
165
+ /** Order ID */
166
166
  orderId: string;
167
- /** 服务 */
167
+ /** Service */
168
168
  service: string;
169
169
  description?: string;
170
- /** 金额 */
170
+ /** Amount */
171
171
  amount: string;
172
172
  token: string;
173
- /** 链信息 */
173
+ /** Chain info */
174
174
  chain: string;
175
175
  chainId: number;
176
- /** 交易信息 */
176
+ /** Transaction info */
177
177
  txHash: string;
178
178
  txUrl: string;
179
- /** 参与方 */
179
+ /** Parties */
180
180
  payer: string;
181
181
  recipient: string;
182
- /** 时间 */
182
+ /** Timestamps */
183
183
  paidAt: string;
184
184
  issuedAt: string;
185
- /** 交付信息 */
185
+ /** Delivery info */
186
186
  delivery?: {
187
187
  url?: string;
188
188
  fileHash?: string;
189
189
  deliveredAt?: string;
190
190
  };
191
- /** 额外元数据 */
191
+ /** Additional metadata */
192
192
  metadata?: Record<string, unknown>;
193
193
  }
194
194
  /**
195
- * 生成交易收据
195
+ * Generate transaction receipt
196
196
  */
197
197
  declare function generateReceipt(params: ReceiptParams): Receipt;
198
198
  /**
199
- * Invoice + VerifyResult 生成收据
199
+ * Generate receipt from Invoice + VerifyResult
200
200
  */
201
201
  declare function generateReceiptFromInvoice(invoice: Invoice, verifyResult: VerifyResult, delivery?: ReceiptParams['delivery']): Receipt;
202
202
  /**
203
- * 格式化收据为人类可读消息
203
+ * Format receipt as human-readable message (Markdown)
204
204
  */
205
205
  declare function formatReceiptMessage(receipt: Receipt): string;
206
206
  /**
207
- * 格式化收据为纯文本(适合飞书/WhatsApp
207
+ * Format receipt as plain text (for Feishu/WhatsApp)
208
208
  */
209
209
  declare function formatReceiptText(receipt: Receipt): string;
210
210
  /**
211
- * 格式化收据为 JSON(适合 Agent 解析)
211
+ * Format receipt as JSON (for Agent parsing)
212
212
  */
213
213
  declare function formatReceiptJson(receipt: Receipt): string;
214
214
 
215
215
  /**
216
- * Agent 对话模板
216
+ * Agent Conversation Templates
217
217
  *
218
- * 标准化的 Agent-to-Agent 支付对话模板
219
- * 可直接嵌入 prompt 或用于生成对话
218
+ * Standardized Agent-to-Agent payment conversation templates
219
+ * Can be embedded in prompts or used for dialogue generation
220
220
  */
221
221
 
222
222
  declare const SellerTemplates: {
223
223
  /**
224
- * 1. 能力识别 - 询问买方是否有支付能力
224
+ * 1. Capability Check - Ask if buyer has payment capability
225
225
  */
226
226
  askPaymentCapability(): string;
227
227
  /**
228
- * 2. 能力协商 - 说明结算方式
228
+ * 2. Settlement Method - Explain how we settle
229
229
  */
230
230
  explainSettlement(chain?: ChainName): string;
231
231
  /**
232
- * 3.1 引导安装 - 第一步安装 SDK
232
+ * 3.1 Installation Guide - First step: install SDK
233
233
  */
234
234
  guideInstall(): string;
235
235
  /**
236
- * 3.2 确认钱包地址
236
+ * 3.2 Confirm Wallet Address
237
237
  */
238
238
  confirmWalletAddress(address: string): string;
239
239
  /**
240
- * 3.3 引导获取资金 - 选择方式
240
+ * 3.3 Funding Options - Choose method
241
241
  */
242
242
  guideFunding(): string;
243
243
  /**
244
- * 3.4 引导 Permit 授权
244
+ * 3.4 Guide Permit Authorization
245
245
  */
246
246
  guidePermit(agentAddress: string, suggestedAmount?: number): string;
247
247
  /**
248
- * 3.5 确认能力就绪
248
+ * 3.5 Confirm Capability Ready
249
249
  */
250
250
  confirmCapabilityReady(): string;
251
251
  /**
252
- * 4. 询问服务需求
252
+ * 4. Ask Service Requirements
253
253
  */
254
254
  askServiceRequirements(serviceName?: string): string;
255
255
  /**
256
- * 5. 报价
256
+ * 5. Quote
257
257
  */
258
258
  quote(params: {
259
259
  service: string;
@@ -262,88 +262,88 @@ declare const SellerTemplates: {
262
262
  chain?: ChainName;
263
263
  }): string;
264
264
  /**
265
- * 7. 验证中
265
+ * 7. Verifying
266
266
  */
267
267
  verifying(): string;
268
268
  /**
269
- * 7. 验证通过
269
+ * 7. Verification Passed
270
270
  */
271
271
  verificationPassed(amount: string): string;
272
272
  /**
273
- * 7. 验证失败
273
+ * 7. Verification Failed
274
274
  */
275
275
  verificationFailed(error: string): string;
276
276
  /**
277
- * 8. 交付
277
+ * 8. Delivery
278
278
  */
279
279
  deliver(params: {
280
280
  downloadUrl: string;
281
281
  fileHash?: string;
282
282
  }): string;
283
283
  /**
284
- * 9. 收据
284
+ * 9. Receipt
285
285
  */
286
286
  receipt(receipt: Receipt): string;
287
287
  /**
288
- * 10. 结束
288
+ * 10. End
289
289
  */
290
290
  end(): string;
291
291
  };
292
292
  declare const BuyerTemplates: {
293
293
  /**
294
- * 0. 发起请求
294
+ * 0. Request Service
295
295
  */
296
296
  requestService(service: string): string;
297
297
  /**
298
- * 1. 回复无能力
298
+ * 1. No Capability
299
299
  */
300
300
  noCapability(): string;
301
301
  /**
302
- * 1. 回复有能力
302
+ * 1. Has Capability
303
303
  */
304
304
  hasCapability(balance?: string): string;
305
305
  /**
306
- * 2. 同意引导
306
+ * 2. Agree to Guide
307
307
  */
308
308
  agreeToGuide(): string;
309
309
  /**
310
- * 3.1 报告钱包创建完成
310
+ * 3.1 Report Wallet Created
311
311
  */
312
312
  walletCreated(address: string): string;
313
313
  /**
314
- * 3.3 选择 Permit 方式
314
+ * 3.3 Choose Permit Method
315
315
  */
316
316
  choosePermit(): string;
317
317
  /**
318
- * 3.3 选择直接转账方式
318
+ * 3.3 Choose Direct Transfer
319
319
  */
320
320
  chooseDirectTransfer(): string;
321
321
  /**
322
- * 3.4 报告获得授权
322
+ * 3.4 Report Permit Received
323
323
  */
324
324
  permitReceived(amount: number): string;
325
325
  /**
326
- * 4. 提交需求
326
+ * 4. Submit Requirements
327
327
  */
328
328
  submitRequirements(requirements: string): string;
329
329
  /**
330
- * 5. 确认购买
330
+ * 5. Confirm Purchase
331
331
  */
332
332
  confirmPurchase(): string;
333
333
  /**
334
- * 6. 报告已支付
334
+ * 6. Report Payment Sent
335
335
  */
336
336
  paymentSent(txHash: string, amount: number): string;
337
337
  /**
338
- * 8. 确认收到交付
338
+ * 8. Confirm Delivery Received
339
339
  */
340
340
  deliveryReceived(): string;
341
341
  /**
342
- * 9. 确认收据
342
+ * 9. Confirm Receipt
343
343
  */
344
344
  receiptReceived(): string;
345
345
  /**
346
- * Boss 请求 Permit
346
+ * Request Permit from Boss
347
347
  */
348
348
  requestPermitFromBoss(params: {
349
349
  amount: number;