moltspay 0.1.3 → 0.2.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 +126 -0
- package/dist/cli.js +17 -3
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +17 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +249 -2
- package/dist/index.d.ts +249 -2
- package/dist/index.js +824 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +808 -12
- package/dist/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +188 -1
- package/dist/wallet/index.d.ts +188 -1
- package/dist/wallet/index.js +378 -2
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +371 -1
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
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
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';
|
|
3
|
-
export { SecureWallet, Wallet } from './wallet/index.js';
|
|
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';
|
|
6
6
|
export { VerifyPaymentParams, VerifyPaymentResult, getTransactionStatus, verifyPayment, waitForTransaction } from './verify/index.js';
|
|
@@ -118,4 +118,251 @@ declare class AuditLog {
|
|
|
118
118
|
private ensureDir;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Receipt - 交易收据生成
|
|
123
|
+
*
|
|
124
|
+
* 用于生成标准化的交易收据,便于对账/报销/审计
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
interface ReceiptParams {
|
|
128
|
+
/** 发票号(自动生成或指定) */
|
|
129
|
+
invoiceId?: string;
|
|
130
|
+
/** 订单号 */
|
|
131
|
+
orderId: string;
|
|
132
|
+
/** 服务名称 */
|
|
133
|
+
service: string;
|
|
134
|
+
/** 服务描述 */
|
|
135
|
+
description?: string;
|
|
136
|
+
/** 金额 */
|
|
137
|
+
amount: number;
|
|
138
|
+
/** Token */
|
|
139
|
+
token?: 'USDC' | 'USDT' | 'ETH';
|
|
140
|
+
/** 链 */
|
|
141
|
+
chain: ChainName;
|
|
142
|
+
/** 交易 hash */
|
|
143
|
+
txHash: string;
|
|
144
|
+
/** 付款方地址 */
|
|
145
|
+
payerAddress: string;
|
|
146
|
+
/** 收款方地址 */
|
|
147
|
+
recipientAddress: string;
|
|
148
|
+
/** 交付信息 */
|
|
149
|
+
delivery?: {
|
|
150
|
+
/** 交付物 URL */
|
|
151
|
+
url?: string;
|
|
152
|
+
/** 文件 hash */
|
|
153
|
+
fileHash?: string;
|
|
154
|
+
/** 交付时间 */
|
|
155
|
+
deliveredAt?: string;
|
|
156
|
+
};
|
|
157
|
+
/** 额外元数据 */
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
interface Receipt {
|
|
161
|
+
type: 'receipt';
|
|
162
|
+
version: '1.0';
|
|
163
|
+
/** 发票号 */
|
|
164
|
+
invoiceId: string;
|
|
165
|
+
/** 订单号 */
|
|
166
|
+
orderId: string;
|
|
167
|
+
/** 服务 */
|
|
168
|
+
service: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
/** 金额 */
|
|
171
|
+
amount: string;
|
|
172
|
+
token: string;
|
|
173
|
+
/** 链信息 */
|
|
174
|
+
chain: string;
|
|
175
|
+
chainId: number;
|
|
176
|
+
/** 交易信息 */
|
|
177
|
+
txHash: string;
|
|
178
|
+
txUrl: string;
|
|
179
|
+
/** 参与方 */
|
|
180
|
+
payer: string;
|
|
181
|
+
recipient: string;
|
|
182
|
+
/** 时间 */
|
|
183
|
+
paidAt: string;
|
|
184
|
+
issuedAt: string;
|
|
185
|
+
/** 交付信息 */
|
|
186
|
+
delivery?: {
|
|
187
|
+
url?: string;
|
|
188
|
+
fileHash?: string;
|
|
189
|
+
deliveredAt?: string;
|
|
190
|
+
};
|
|
191
|
+
/** 额外元数据 */
|
|
192
|
+
metadata?: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* 生成交易收据
|
|
196
|
+
*/
|
|
197
|
+
declare function generateReceipt(params: ReceiptParams): Receipt;
|
|
198
|
+
/**
|
|
199
|
+
* 从 Invoice + VerifyResult 生成收据
|
|
200
|
+
*/
|
|
201
|
+
declare function generateReceiptFromInvoice(invoice: Invoice, verifyResult: VerifyResult, delivery?: ReceiptParams['delivery']): Receipt;
|
|
202
|
+
/**
|
|
203
|
+
* 格式化收据为人类可读消息
|
|
204
|
+
*/
|
|
205
|
+
declare function formatReceiptMessage(receipt: Receipt): string;
|
|
206
|
+
/**
|
|
207
|
+
* 格式化收据为纯文本(适合飞书/WhatsApp)
|
|
208
|
+
*/
|
|
209
|
+
declare function formatReceiptText(receipt: Receipt): string;
|
|
210
|
+
/**
|
|
211
|
+
* 格式化收据为 JSON(适合 Agent 解析)
|
|
212
|
+
*/
|
|
213
|
+
declare function formatReceiptJson(receipt: Receipt): string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Agent 对话模板
|
|
217
|
+
*
|
|
218
|
+
* 标准化的 Agent-to-Agent 支付对话模板
|
|
219
|
+
* 可直接嵌入 prompt 或用于生成对话
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
declare const SellerTemplates: {
|
|
223
|
+
/**
|
|
224
|
+
* 1. 能力识别 - 询问买方是否有支付能力
|
|
225
|
+
*/
|
|
226
|
+
askPaymentCapability(): string;
|
|
227
|
+
/**
|
|
228
|
+
* 2. 能力协商 - 说明结算方式
|
|
229
|
+
*/
|
|
230
|
+
explainSettlement(chain?: ChainName): string;
|
|
231
|
+
/**
|
|
232
|
+
* 3.1 引导安装 - 第一步安装 SDK
|
|
233
|
+
*/
|
|
234
|
+
guideInstall(): string;
|
|
235
|
+
/**
|
|
236
|
+
* 3.2 确认钱包地址
|
|
237
|
+
*/
|
|
238
|
+
confirmWalletAddress(address: string): string;
|
|
239
|
+
/**
|
|
240
|
+
* 3.3 引导获取资金 - 选择方式
|
|
241
|
+
*/
|
|
242
|
+
guideFunding(): string;
|
|
243
|
+
/**
|
|
244
|
+
* 3.4 引导 Permit 授权
|
|
245
|
+
*/
|
|
246
|
+
guidePermit(agentAddress: string, suggestedAmount?: number): string;
|
|
247
|
+
/**
|
|
248
|
+
* 3.5 确认能力就绪
|
|
249
|
+
*/
|
|
250
|
+
confirmCapabilityReady(): string;
|
|
251
|
+
/**
|
|
252
|
+
* 4. 询问服务需求
|
|
253
|
+
*/
|
|
254
|
+
askServiceRequirements(serviceName?: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* 5. 报价
|
|
257
|
+
*/
|
|
258
|
+
quote(params: {
|
|
259
|
+
service: string;
|
|
260
|
+
price: number;
|
|
261
|
+
recipientAddress: string;
|
|
262
|
+
chain?: ChainName;
|
|
263
|
+
}): string;
|
|
264
|
+
/**
|
|
265
|
+
* 7. 验证中
|
|
266
|
+
*/
|
|
267
|
+
verifying(): string;
|
|
268
|
+
/**
|
|
269
|
+
* 7. 验证通过
|
|
270
|
+
*/
|
|
271
|
+
verificationPassed(amount: string): string;
|
|
272
|
+
/**
|
|
273
|
+
* 7. 验证失败
|
|
274
|
+
*/
|
|
275
|
+
verificationFailed(error: string): string;
|
|
276
|
+
/**
|
|
277
|
+
* 8. 交付
|
|
278
|
+
*/
|
|
279
|
+
deliver(params: {
|
|
280
|
+
downloadUrl: string;
|
|
281
|
+
fileHash?: string;
|
|
282
|
+
}): string;
|
|
283
|
+
/**
|
|
284
|
+
* 9. 收据
|
|
285
|
+
*/
|
|
286
|
+
receipt(receipt: Receipt): string;
|
|
287
|
+
/**
|
|
288
|
+
* 10. 结束
|
|
289
|
+
*/
|
|
290
|
+
end(): string;
|
|
291
|
+
};
|
|
292
|
+
declare const BuyerTemplates: {
|
|
293
|
+
/**
|
|
294
|
+
* 0. 发起请求
|
|
295
|
+
*/
|
|
296
|
+
requestService(service: string): string;
|
|
297
|
+
/**
|
|
298
|
+
* 1. 回复无能力
|
|
299
|
+
*/
|
|
300
|
+
noCapability(): string;
|
|
301
|
+
/**
|
|
302
|
+
* 1. 回复有能力
|
|
303
|
+
*/
|
|
304
|
+
hasCapability(balance?: string): string;
|
|
305
|
+
/**
|
|
306
|
+
* 2. 同意引导
|
|
307
|
+
*/
|
|
308
|
+
agreeToGuide(): string;
|
|
309
|
+
/**
|
|
310
|
+
* 3.1 报告钱包创建完成
|
|
311
|
+
*/
|
|
312
|
+
walletCreated(address: string): string;
|
|
313
|
+
/**
|
|
314
|
+
* 3.3 选择 Permit 方式
|
|
315
|
+
*/
|
|
316
|
+
choosePermit(): string;
|
|
317
|
+
/**
|
|
318
|
+
* 3.3 选择直接转账方式
|
|
319
|
+
*/
|
|
320
|
+
chooseDirectTransfer(): string;
|
|
321
|
+
/**
|
|
322
|
+
* 3.4 报告获得授权
|
|
323
|
+
*/
|
|
324
|
+
permitReceived(amount: number): string;
|
|
325
|
+
/**
|
|
326
|
+
* 4. 提交需求
|
|
327
|
+
*/
|
|
328
|
+
submitRequirements(requirements: string): string;
|
|
329
|
+
/**
|
|
330
|
+
* 5. 确认购买
|
|
331
|
+
*/
|
|
332
|
+
confirmPurchase(): string;
|
|
333
|
+
/**
|
|
334
|
+
* 6. 报告已支付
|
|
335
|
+
*/
|
|
336
|
+
paymentSent(txHash: string, amount: number): string;
|
|
337
|
+
/**
|
|
338
|
+
* 8. 确认收到交付
|
|
339
|
+
*/
|
|
340
|
+
deliveryReceived(): string;
|
|
341
|
+
/**
|
|
342
|
+
* 9. 确认收据
|
|
343
|
+
*/
|
|
344
|
+
receiptReceived(): string;
|
|
345
|
+
/**
|
|
346
|
+
* 向 Boss 请求 Permit
|
|
347
|
+
*/
|
|
348
|
+
requestPermitFromBoss(params: {
|
|
349
|
+
amount: number;
|
|
350
|
+
agentAddress: string;
|
|
351
|
+
deadlineHours?: number;
|
|
352
|
+
reason?: string;
|
|
353
|
+
}): string;
|
|
354
|
+
};
|
|
355
|
+
declare const StatusMarkers: {
|
|
356
|
+
walletReady: string;
|
|
357
|
+
permitReady: (amount: number) => string;
|
|
358
|
+
paymentSent: (txHash: string, amount: number) => string;
|
|
359
|
+
paymentConfirmed: (txHash: string) => string;
|
|
360
|
+
delivered: (url: string, hash?: string) => string;
|
|
361
|
+
receiptIssued: (invoiceId: string, txHash: string) => string;
|
|
362
|
+
};
|
|
363
|
+
declare function parseStatusMarker(message: string): {
|
|
364
|
+
type: string;
|
|
365
|
+
data: Record<string, string>;
|
|
366
|
+
} | null;
|
|
367
|
+
|
|
368
|
+
export { AuditAction, AuditEntry, AuditLog, BuyerTemplates, ChainConfig, ChainName, CreateInvoiceParams, Invoice, PaymentAgent, PaymentAgentConfig, type Receipt, type ReceiptParams, SellerTemplates, StatusMarkers, VerifyOptions, VerifyResult, WalletBalance, formatReceiptJson, formatReceiptMessage, formatReceiptText, generateReceipt, generateReceiptFromInvoice, parseStatusMarker };
|