moltspay 0.1.3 → 0.2.1
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/guide/index.d.mts +7 -7
- package/dist/guide/index.d.ts +7 -7
- package/dist/guide/index.js +50 -50
- package/dist/guide/index.js.map +1 -1
- package/dist/guide/index.mjs +50 -50
- package/dist/guide/index.mjs.map +1 -1
- package/dist/index.d.mts +249 -2
- package/dist/index.d.ts +249 -2
- package/dist/index.js +874 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +858 -62
- 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/guide/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n * Payment Guide Generator\n * Generate guides for Agents without payment capability to install and use moltspay\n */\n\nexport interface PaymentGuideParams {\n orderId: string;\n prompt: string;\n price: number;\n recipientAddress: string;\n chain?: 'base' | 'base_sepolia';\n serviceName?: string;\n}\n\n/**\n * Generate complete payment guide message\n */\nexport function generatePaymentGuide(params: PaymentGuideParams): string {\n const {\n orderId,\n prompt,\n price,\n recipientAddress,\n chain = 'base',\n serviceName = 'Video Generation Service'\n } = params;\n\n const chainId = chain === 'base' ? 8453 : 84532;\n const chainName = chain === 'base' ? 'Base Mainnet' : 'Base Sepolia Testnet';\n const explorer = chain === 'base' \n ? 'https://basescan.org/tx/' \n : 'https://sepolia.basescan.org/tx/';\n\n return `🎬 **${serviceName}**\n\n📋 **Order Details:**\n- Order ID: \\`${orderId}\\`\n- Content: ${prompt.length > 50 ? prompt.slice(0, 50) + '...' : prompt}\n- Price: **${price} USDC**\n- Chain: ${chainName}\n\n---\n\n## 💳 How to Pay\n\n### Option 1: Install moltspay SDK (Recommended)\n\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**Create wallet and pay:**\n\n\\`\\`\\`javascript\nconst { SecureWallet, getChain } = require('moltspay');\nconst { Wallet } = require('ethers');\n\n// 1. Create new wallet (first time)\nconst newWallet = Wallet.createRandom();\nconsole.log('Wallet address:', newWallet.address);\nconsole.log('Private key (save securely):', newWallet.privateKey);\n\n// 2. Or use existing wallet\nconst wallet = new SecureWallet({\n chainId: ${chainId},\n privateKey: process.env.WALLET_KEY, // Your private key\n limits: { requireWhitelist: false } // Allow transfers to any address\n});\n\n// 3. Check balance\nconst balance = await wallet.getBalance();\nconsole.log('USDC balance:', balance.usdc);\n\n// 4. Pay\nconst result = await wallet.transfer('${recipientAddress}', '${price}');\nif (result.success) {\n console.log('✅ Payment successful!');\n console.log('Tx hash:', result.hash);\n // Send the tx hash to me\n}\n\\`\\`\\`\n\n### Option 2: Direct Transfer\n\nTransfer USDC from any wallet:\n- **Chain:** ${chainName} (Chain ID: ${chainId})\n- **Token:** USDC\n- **Recipient:** \\`${recipientAddress}\\`\n- **Amount:** ${price} USDC\n\n---\n\n## ✅ After Payment\n\nSend me the **transaction hash**, format:\n\\`\\`\\`\ntx: 0x1234...\n\\`\\`\\`\n\nOr just send the hash directly:\n\\`\\`\\`\n0x1234abcd...\n\\`\\`\\`\n\nI'll verify the on-chain transaction and start processing your request.\n\n---\n\n📦 **moltspay:** https://www.npmjs.com/package/moltspay\n🔗 **Block Explorer:** ${explorer}`;\n}\n\n/**\n * Generate short payment reminder\n */\nexport function generatePaymentReminder(params: {\n orderId: string;\n price: number;\n recipientAddress: string;\n chain?: 'base' | 'base_sepolia';\n}): string {\n const { orderId, price, recipientAddress, chain = 'base' } = params;\n const chainName = chain === 'base' ? 'Base' : 'Base Sepolia';\n\n return `⏳ **Pending Order: ${orderId}**\n\nPlease pay **${price} USDC** to:\n- Chain: ${chainName}\n- Address: \\`${recipientAddress}\\`\n\nSend the tx hash after payment.\n\n---\n💡 No payment capability? Run \\`npm install moltspay\\` to get the payment SDK`;\n}\n\n/**\n * Generate wallet creation guide\n */\nexport function generateWalletGuide(): string {\n return `## 🔐 Create Payment Wallet\n\n**1. Install moltspay:**\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**2. Create new wallet:**\n\\`\\`\\`javascript\nconst { Wallet } = require('ethers');\n\nconst wallet = Wallet.createRandom();\nconsole.log('Address:', wallet.address);\nconsole.log('Private key:', wallet.privateKey);\n// ⚠️ Save the private key securely!\n\\`\\`\\`\n\n**3. Get USDC:**\n- Mainnet: Withdraw from exchange to your wallet\n- Testnet: Use Base Sepolia faucet\n\n**4. Set environment variable:**\n\\`\\`\\`bash\nexport WALLET_KEY=\"your_private_key\"\n\\`\\`\\`\n\nYou're now ready to make on-chain payments with moltspay!`;\n}\n\n/**\n * Extract transaction hash from user message\n */\nexport function extractTransactionHash(message: string): string | null {\n // Match 0x followed by 64 hex chars\n const match = message.match(/0x[a-fA-F0-9]{64}/);\n if (match) return match[0];\n\n // Match tx: followed by content\n const txMatch = message.match(/tx:\\s*([a-fA-F0-9]{64})/i);\n if (txMatch) return '0x' + txMatch[1];\n\n return null;\n}\n\n/**\n * Check if message contains transaction hash\n */\nexport function hasTransactionHash(message: string): boolean {\n return extractTransactionHash(message) !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,qBAAqB,QAAoC;AACvE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,EAChB,IAAI;AAEJ,QAAM,UAAU,UAAU,SAAS,OAAO;AAC1C,QAAM,YAAY,UAAU,SAAS,iBAAiB;AACtD,QAAM,WAAW,UAAU,SACvB,6BACA;AAEJ,SAAO,eAAQ,WAAW;AAAA;AAAA;AAAA,gBAGZ,OAAO;AAAA,aACV,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;AAAA,aACzD,KAAK;AAAA,WACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAyBP,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAUoB,gBAAgB,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAWrD,SAAS,eAAe,OAAO;AAAA;AAAA,qBAEzB,gBAAgB;AAAA,gBACrB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAqBI,QAAQ;AACjC;AAKO,SAAS,wBAAwB,QAK7B;AACT,QAAM,EAAE,SAAS,OAAO,kBAAkB,QAAQ,OAAO,IAAI;AAC7D,QAAM,YAAY,UAAU,SAAS,SAAS;AAE9C,SAAO,2BAAsB,OAAO;AAAA;AAAA,eAEvB,KAAK;AAAA,WACT,SAAS;AAAA,eACL,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAM/B;AAKO,SAAS,sBAA8B;AAC5C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BT;AAKO,SAAS,uBAAuB,SAAgC;AAErE,QAAM,QAAQ,QAAQ,MAAM,mBAAmB;AAC/C,MAAI,MAAO,QAAO,MAAM,CAAC;AAGzB,QAAM,UAAU,QAAQ,MAAM,0BAA0B;AACxD,MAAI,QAAS,QAAO,OAAO,QAAQ,CAAC;AAEpC,SAAO;AACT;AAKO,SAAS,mBAAmB,SAA0B;AAC3D,SAAO,uBAAuB,OAAO,MAAM;AAC7C;","names":[]}
|
package/dist/guide/index.mjs
CHANGED
|
@@ -6,131 +6,131 @@ function generatePaymentGuide(params) {
|
|
|
6
6
|
price,
|
|
7
7
|
recipientAddress,
|
|
8
8
|
chain = "base",
|
|
9
|
-
serviceName = "
|
|
9
|
+
serviceName = "Video Generation Service"
|
|
10
10
|
} = params;
|
|
11
11
|
const chainId = chain === "base" ? 8453 : 84532;
|
|
12
|
-
const chainName = chain === "base" ? "Base
|
|
12
|
+
const chainName = chain === "base" ? "Base Mainnet" : "Base Sepolia Testnet";
|
|
13
13
|
const explorer = chain === "base" ? "https://basescan.org/tx/" : "https://sepolia.basescan.org/tx/";
|
|
14
14
|
return `\u{1F3AC} **${serviceName}**
|
|
15
15
|
|
|
16
|
-
\u{1F4CB}
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
16
|
+
\u{1F4CB} **Order Details:**
|
|
17
|
+
- Order ID: \`${orderId}\`
|
|
18
|
+
- Content: ${prompt.length > 50 ? prompt.slice(0, 50) + "..." : prompt}
|
|
19
|
+
- Price: **${price} USDC**
|
|
20
|
+
- Chain: ${chainName}
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
## \u{1F4B3}
|
|
24
|
+
## \u{1F4B3} How to Pay
|
|
25
25
|
|
|
26
|
-
###
|
|
26
|
+
### Option 1: Install moltspay SDK (Recommended)
|
|
27
27
|
|
|
28
28
|
\`\`\`bash
|
|
29
29
|
npm install moltspay ethers
|
|
30
30
|
\`\`\`
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
**Create wallet and pay:**
|
|
33
33
|
|
|
34
34
|
\`\`\`javascript
|
|
35
35
|
const { SecureWallet, getChain } = require('moltspay');
|
|
36
36
|
const { Wallet } = require('ethers');
|
|
37
37
|
|
|
38
|
-
// 1.
|
|
38
|
+
// 1. Create new wallet (first time)
|
|
39
39
|
const newWallet = Wallet.createRandom();
|
|
40
|
-
console.log('
|
|
41
|
-
console.log('
|
|
40
|
+
console.log('Wallet address:', newWallet.address);
|
|
41
|
+
console.log('Private key (save securely):', newWallet.privateKey);
|
|
42
42
|
|
|
43
|
-
// 2.
|
|
43
|
+
// 2. Or use existing wallet
|
|
44
44
|
const wallet = new SecureWallet({
|
|
45
45
|
chainId: ${chainId},
|
|
46
|
-
privateKey: process.env.WALLET_KEY, //
|
|
47
|
-
limits: { requireWhitelist: false } //
|
|
46
|
+
privateKey: process.env.WALLET_KEY, // Your private key
|
|
47
|
+
limits: { requireWhitelist: false } // Allow transfers to any address
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
// 3.
|
|
50
|
+
// 3. Check balance
|
|
51
51
|
const balance = await wallet.getBalance();
|
|
52
|
-
console.log('USDC
|
|
52
|
+
console.log('USDC balance:', balance.usdc);
|
|
53
53
|
|
|
54
|
-
// 4.
|
|
54
|
+
// 4. Pay
|
|
55
55
|
const result = await wallet.transfer('${recipientAddress}', '${price}');
|
|
56
56
|
if (result.success) {
|
|
57
|
-
console.log('\u2705
|
|
58
|
-
console.log('
|
|
59
|
-
//
|
|
57
|
+
console.log('\u2705 Payment successful!');
|
|
58
|
+
console.log('Tx hash:', result.hash);
|
|
59
|
+
// Send the tx hash to me
|
|
60
60
|
}
|
|
61
61
|
\`\`\`
|
|
62
62
|
|
|
63
|
-
###
|
|
63
|
+
### Option 2: Direct Transfer
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
-
|
|
65
|
+
Transfer USDC from any wallet:
|
|
66
|
+
- **Chain:** ${chainName} (Chain ID: ${chainId})
|
|
67
67
|
- **Token:** USDC
|
|
68
|
-
-
|
|
69
|
-
-
|
|
68
|
+
- **Recipient:** \`${recipientAddress}\`
|
|
69
|
+
- **Amount:** ${price} USDC
|
|
70
70
|
|
|
71
71
|
---
|
|
72
72
|
|
|
73
|
-
## \u2705
|
|
73
|
+
## \u2705 After Payment
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Send me the **transaction hash**, format:
|
|
76
76
|
\`\`\`
|
|
77
77
|
tx: 0x1234...
|
|
78
78
|
\`\`\`
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
Or just send the hash directly:
|
|
81
81
|
\`\`\`
|
|
82
82
|
0x1234abcd...
|
|
83
83
|
\`\`\`
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
I'll verify the on-chain transaction and start processing your request.
|
|
86
86
|
|
|
87
87
|
---
|
|
88
88
|
|
|
89
89
|
\u{1F4E6} **moltspay:** https://www.npmjs.com/package/moltspay
|
|
90
|
-
\u{1F517}
|
|
90
|
+
\u{1F517} **Block Explorer:** ${explorer}`;
|
|
91
91
|
}
|
|
92
92
|
function generatePaymentReminder(params) {
|
|
93
93
|
const { orderId, price, recipientAddress, chain = "base" } = params;
|
|
94
94
|
const chainName = chain === "base" ? "Base" : "Base Sepolia";
|
|
95
|
-
return `\u23F3
|
|
95
|
+
return `\u23F3 **Pending Order: ${orderId}**
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
97
|
+
Please pay **${price} USDC** to:
|
|
98
|
+
- Chain: ${chainName}
|
|
99
|
+
- Address: \`${recipientAddress}\`
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Send the tx hash after payment.
|
|
102
102
|
|
|
103
103
|
---
|
|
104
|
-
\u{1F4A1}
|
|
104
|
+
\u{1F4A1} No payment capability? Run \`npm install moltspay\` to get the payment SDK`;
|
|
105
105
|
}
|
|
106
106
|
function generateWalletGuide() {
|
|
107
|
-
return `## \u{1F510}
|
|
107
|
+
return `## \u{1F510} Create Payment Wallet
|
|
108
108
|
|
|
109
|
-
**1.
|
|
109
|
+
**1. Install moltspay:**
|
|
110
110
|
\`\`\`bash
|
|
111
111
|
npm install moltspay ethers
|
|
112
112
|
\`\`\`
|
|
113
113
|
|
|
114
|
-
**2.
|
|
114
|
+
**2. Create new wallet:**
|
|
115
115
|
\`\`\`javascript
|
|
116
116
|
const { Wallet } = require('ethers');
|
|
117
117
|
|
|
118
118
|
const wallet = Wallet.createRandom();
|
|
119
|
-
console.log('
|
|
120
|
-
console.log('
|
|
121
|
-
// \u26A0\uFE0F
|
|
119
|
+
console.log('Address:', wallet.address);
|
|
120
|
+
console.log('Private key:', wallet.privateKey);
|
|
121
|
+
// \u26A0\uFE0F Save the private key securely!
|
|
122
122
|
\`\`\`
|
|
123
123
|
|
|
124
|
-
**3.
|
|
125
|
-
-
|
|
126
|
-
-
|
|
124
|
+
**3. Get USDC:**
|
|
125
|
+
- Mainnet: Withdraw from exchange to your wallet
|
|
126
|
+
- Testnet: Use Base Sepolia faucet
|
|
127
127
|
|
|
128
|
-
**4.
|
|
128
|
+
**4. Set environment variable:**
|
|
129
129
|
\`\`\`bash
|
|
130
|
-
export WALLET_KEY="
|
|
130
|
+
export WALLET_KEY="your_private_key"
|
|
131
131
|
\`\`\`
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
You're now ready to make on-chain payments with moltspay!`;
|
|
134
134
|
}
|
|
135
135
|
function extractTransactionHash(message) {
|
|
136
136
|
const match = message.match(/0x[a-fA-F0-9]{64}/);
|
package/dist/guide/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n * Payment Guide Generator\n * Generate guides for Agents without payment capability to install and use moltspay\n */\n\nexport interface PaymentGuideParams {\n orderId: string;\n prompt: string;\n price: number;\n recipientAddress: string;\n chain?: 'base' | 'base_sepolia';\n serviceName?: string;\n}\n\n/**\n * Generate complete payment guide message\n */\nexport function generatePaymentGuide(params: PaymentGuideParams): string {\n const {\n orderId,\n prompt,\n price,\n recipientAddress,\n chain = 'base',\n serviceName = 'Video Generation Service'\n } = params;\n\n const chainId = chain === 'base' ? 8453 : 84532;\n const chainName = chain === 'base' ? 'Base Mainnet' : 'Base Sepolia Testnet';\n const explorer = chain === 'base' \n ? 'https://basescan.org/tx/' \n : 'https://sepolia.basescan.org/tx/';\n\n return `🎬 **${serviceName}**\n\n📋 **Order Details:**\n- Order ID: \\`${orderId}\\`\n- Content: ${prompt.length > 50 ? prompt.slice(0, 50) + '...' : prompt}\n- Price: **${price} USDC**\n- Chain: ${chainName}\n\n---\n\n## 💳 How to Pay\n\n### Option 1: Install moltspay SDK (Recommended)\n\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**Create wallet and pay:**\n\n\\`\\`\\`javascript\nconst { SecureWallet, getChain } = require('moltspay');\nconst { Wallet } = require('ethers');\n\n// 1. Create new wallet (first time)\nconst newWallet = Wallet.createRandom();\nconsole.log('Wallet address:', newWallet.address);\nconsole.log('Private key (save securely):', newWallet.privateKey);\n\n// 2. Or use existing wallet\nconst wallet = new SecureWallet({\n chainId: ${chainId},\n privateKey: process.env.WALLET_KEY, // Your private key\n limits: { requireWhitelist: false } // Allow transfers to any address\n});\n\n// 3. Check balance\nconst balance = await wallet.getBalance();\nconsole.log('USDC balance:', balance.usdc);\n\n// 4. Pay\nconst result = await wallet.transfer('${recipientAddress}', '${price}');\nif (result.success) {\n console.log('✅ Payment successful!');\n console.log('Tx hash:', result.hash);\n // Send the tx hash to me\n}\n\\`\\`\\`\n\n### Option 2: Direct Transfer\n\nTransfer USDC from any wallet:\n- **Chain:** ${chainName} (Chain ID: ${chainId})\n- **Token:** USDC\n- **Recipient:** \\`${recipientAddress}\\`\n- **Amount:** ${price} USDC\n\n---\n\n## ✅ After Payment\n\nSend me the **transaction hash**, format:\n\\`\\`\\`\ntx: 0x1234...\n\\`\\`\\`\n\nOr just send the hash directly:\n\\`\\`\\`\n0x1234abcd...\n\\`\\`\\`\n\nI'll verify the on-chain transaction and start processing your request.\n\n---\n\n📦 **moltspay:** https://www.npmjs.com/package/moltspay\n🔗 **Block Explorer:** ${explorer}`;\n}\n\n/**\n * Generate short payment reminder\n */\nexport function generatePaymentReminder(params: {\n orderId: string;\n price: number;\n recipientAddress: string;\n chain?: 'base' | 'base_sepolia';\n}): string {\n const { orderId, price, recipientAddress, chain = 'base' } = params;\n const chainName = chain === 'base' ? 'Base' : 'Base Sepolia';\n\n return `⏳ **Pending Order: ${orderId}**\n\nPlease pay **${price} USDC** to:\n- Chain: ${chainName}\n- Address: \\`${recipientAddress}\\`\n\nSend the tx hash after payment.\n\n---\n💡 No payment capability? Run \\`npm install moltspay\\` to get the payment SDK`;\n}\n\n/**\n * Generate wallet creation guide\n */\nexport function generateWalletGuide(): string {\n return `## 🔐 Create Payment Wallet\n\n**1. Install moltspay:**\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**2. Create new wallet:**\n\\`\\`\\`javascript\nconst { Wallet } = require('ethers');\n\nconst wallet = Wallet.createRandom();\nconsole.log('Address:', wallet.address);\nconsole.log('Private key:', wallet.privateKey);\n// ⚠️ Save the private key securely!\n\\`\\`\\`\n\n**3. Get USDC:**\n- Mainnet: Withdraw from exchange to your wallet\n- Testnet: Use Base Sepolia faucet\n\n**4. Set environment variable:**\n\\`\\`\\`bash\nexport WALLET_KEY=\"your_private_key\"\n\\`\\`\\`\n\nYou're now ready to make on-chain payments with moltspay!`;\n}\n\n/**\n * Extract transaction hash from user message\n */\nexport function extractTransactionHash(message: string): string | null {\n // Match 0x followed by 64 hex chars\n const match = message.match(/0x[a-fA-F0-9]{64}/);\n if (match) return match[0];\n\n // Match tx: followed by content\n const txMatch = message.match(/tx:\\s*([a-fA-F0-9]{64})/i);\n if (txMatch) return '0x' + txMatch[1];\n\n return null;\n}\n\n/**\n * Check if message contains transaction hash\n */\nexport function hasTransactionHash(message: string): boolean {\n return extractTransactionHash(message) !== null;\n}\n"],"mappings":";AAiBO,SAAS,qBAAqB,QAAoC;AACvE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,cAAc;AAAA,EAChB,IAAI;AAEJ,QAAM,UAAU,UAAU,SAAS,OAAO;AAC1C,QAAM,YAAY,UAAU,SAAS,iBAAiB;AACtD,QAAM,WAAW,UAAU,SACvB,6BACA;AAEJ,SAAO,eAAQ,WAAW;AAAA;AAAA;AAAA,gBAGZ,OAAO;AAAA,aACV,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;AAAA,aACzD,KAAK;AAAA,WACP,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAyBP,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAUoB,gBAAgB,OAAO,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,eAWrD,SAAS,eAAe,OAAO;AAAA;AAAA,qBAEzB,gBAAgB;AAAA,gBACrB,KAAK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAqBI,QAAQ;AACjC;AAKO,SAAS,wBAAwB,QAK7B;AACT,QAAM,EAAE,SAAS,OAAO,kBAAkB,QAAQ,OAAO,IAAI;AAC7D,QAAM,YAAY,UAAU,SAAS,SAAS;AAE9C,SAAO,2BAAsB,OAAO;AAAA;AAAA,eAEvB,KAAK;AAAA,WACT,SAAS;AAAA,eACL,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAM/B;AAKO,SAAS,sBAA8B;AAC5C,SAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BT;AAKO,SAAS,uBAAuB,SAAgC;AAErE,QAAM,QAAQ,QAAQ,MAAM,mBAAmB;AAC/C,MAAI,MAAO,QAAO,MAAM,CAAC;AAGzB,QAAM,UAAU,QAAQ,MAAM,0BAA0B;AACxD,MAAI,QAAS,QAAO,OAAO,QAAQ,CAAC;AAEpC,SAAO;AACT;AAKO,SAAS,mBAAmB,SAA0B;AAC3D,SAAO,uBAAuB,OAAO,MAAM;AAC7C;","names":[]}
|
package/dist/index.d.mts
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.mjs';
|
|
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.mjs';
|
|
3
|
-
export { SecureWallet, Wallet } from './wallet/index.mjs';
|
|
3
|
+
export { CreateWalletOptions, CreateWalletResult, PermitData, PermitWallet, PermitWalletConfig, SecureWallet, TransferWithPermitParams, TransferWithPermitResult, Wallet, WalletData, createWallet, formatPermitRequest, getWalletAddress, loadWallet, walletExists } from './wallet/index.mjs';
|
|
4
4
|
export { PermitPayment } from './permit/index.mjs';
|
|
5
5
|
export { CreateOrderParams, MemoryOrderStore, Order, OrderManager, OrderStatus, OrderStore } from './orders/index.mjs';
|
|
6
6
|
export { VerifyPaymentParams, VerifyPaymentResult, getTransactionStatus, verifyPayment, waitForTransaction } from './verify/index.mjs';
|
|
@@ -118,4 +118,251 @@ declare class AuditLog {
|
|
|
118
118
|
private ensureDir;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Receipt - Transaction receipt generation
|
|
123
|
+
*
|
|
124
|
+
* Generate standardized transaction receipts for reconciliation/reimbursement/audit
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
interface ReceiptParams {
|
|
128
|
+
/** Invoice ID (auto-generated or specified) */
|
|
129
|
+
invoiceId?: string;
|
|
130
|
+
/** Order ID */
|
|
131
|
+
orderId: string;
|
|
132
|
+
/** Service name */
|
|
133
|
+
service: string;
|
|
134
|
+
/** Service description */
|
|
135
|
+
description?: string;
|
|
136
|
+
/** Amount */
|
|
137
|
+
amount: number;
|
|
138
|
+
/** Token */
|
|
139
|
+
token?: 'USDC' | 'USDT' | 'ETH';
|
|
140
|
+
/** Chain */
|
|
141
|
+
chain: ChainName;
|
|
142
|
+
/** Transaction hash */
|
|
143
|
+
txHash: string;
|
|
144
|
+
/** Payer address */
|
|
145
|
+
payerAddress: string;
|
|
146
|
+
/** Recipient address */
|
|
147
|
+
recipientAddress: string;
|
|
148
|
+
/** Delivery info */
|
|
149
|
+
delivery?: {
|
|
150
|
+
/** Delivery URL */
|
|
151
|
+
url?: string;
|
|
152
|
+
/** File hash */
|
|
153
|
+
fileHash?: string;
|
|
154
|
+
/** Delivery timestamp */
|
|
155
|
+
deliveredAt?: string;
|
|
156
|
+
};
|
|
157
|
+
/** Additional metadata */
|
|
158
|
+
metadata?: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
interface Receipt {
|
|
161
|
+
type: 'receipt';
|
|
162
|
+
version: '1.0';
|
|
163
|
+
/** Invoice ID */
|
|
164
|
+
invoiceId: string;
|
|
165
|
+
/** Order ID */
|
|
166
|
+
orderId: string;
|
|
167
|
+
/** Service */
|
|
168
|
+
service: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
/** Amount */
|
|
171
|
+
amount: string;
|
|
172
|
+
token: string;
|
|
173
|
+
/** Chain info */
|
|
174
|
+
chain: string;
|
|
175
|
+
chainId: number;
|
|
176
|
+
/** Transaction info */
|
|
177
|
+
txHash: string;
|
|
178
|
+
txUrl: string;
|
|
179
|
+
/** Parties */
|
|
180
|
+
payer: string;
|
|
181
|
+
recipient: string;
|
|
182
|
+
/** Timestamps */
|
|
183
|
+
paidAt: string;
|
|
184
|
+
issuedAt: string;
|
|
185
|
+
/** Delivery info */
|
|
186
|
+
delivery?: {
|
|
187
|
+
url?: string;
|
|
188
|
+
fileHash?: string;
|
|
189
|
+
deliveredAt?: string;
|
|
190
|
+
};
|
|
191
|
+
/** Additional metadata */
|
|
192
|
+
metadata?: Record<string, unknown>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Generate transaction receipt
|
|
196
|
+
*/
|
|
197
|
+
declare function generateReceipt(params: ReceiptParams): Receipt;
|
|
198
|
+
/**
|
|
199
|
+
* Generate receipt from Invoice + VerifyResult
|
|
200
|
+
*/
|
|
201
|
+
declare function generateReceiptFromInvoice(invoice: Invoice, verifyResult: VerifyResult, delivery?: ReceiptParams['delivery']): Receipt;
|
|
202
|
+
/**
|
|
203
|
+
* Format receipt as human-readable message (Markdown)
|
|
204
|
+
*/
|
|
205
|
+
declare function formatReceiptMessage(receipt: Receipt): string;
|
|
206
|
+
/**
|
|
207
|
+
* Format receipt as plain text (for Feishu/WhatsApp)
|
|
208
|
+
*/
|
|
209
|
+
declare function formatReceiptText(receipt: Receipt): string;
|
|
210
|
+
/**
|
|
211
|
+
* Format receipt as JSON (for Agent parsing)
|
|
212
|
+
*/
|
|
213
|
+
declare function formatReceiptJson(receipt: Receipt): string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Agent Conversation Templates
|
|
217
|
+
*
|
|
218
|
+
* Standardized Agent-to-Agent payment conversation templates
|
|
219
|
+
* Can be embedded in prompts or used for dialogue generation
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
declare const SellerTemplates: {
|
|
223
|
+
/**
|
|
224
|
+
* 1. Capability Check - Ask if buyer has payment capability
|
|
225
|
+
*/
|
|
226
|
+
askPaymentCapability(): string;
|
|
227
|
+
/**
|
|
228
|
+
* 2. Settlement Method - Explain how we settle
|
|
229
|
+
*/
|
|
230
|
+
explainSettlement(chain?: ChainName): string;
|
|
231
|
+
/**
|
|
232
|
+
* 3.1 Installation Guide - First step: install SDK
|
|
233
|
+
*/
|
|
234
|
+
guideInstall(): string;
|
|
235
|
+
/**
|
|
236
|
+
* 3.2 Confirm Wallet Address
|
|
237
|
+
*/
|
|
238
|
+
confirmWalletAddress(address: string): string;
|
|
239
|
+
/**
|
|
240
|
+
* 3.3 Funding Options - Choose method
|
|
241
|
+
*/
|
|
242
|
+
guideFunding(): string;
|
|
243
|
+
/**
|
|
244
|
+
* 3.4 Guide Permit Authorization
|
|
245
|
+
*/
|
|
246
|
+
guidePermit(agentAddress: string, suggestedAmount?: number): string;
|
|
247
|
+
/**
|
|
248
|
+
* 3.5 Confirm Capability Ready
|
|
249
|
+
*/
|
|
250
|
+
confirmCapabilityReady(): string;
|
|
251
|
+
/**
|
|
252
|
+
* 4. Ask Service Requirements
|
|
253
|
+
*/
|
|
254
|
+
askServiceRequirements(serviceName?: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* 5. Quote
|
|
257
|
+
*/
|
|
258
|
+
quote(params: {
|
|
259
|
+
service: string;
|
|
260
|
+
price: number;
|
|
261
|
+
recipientAddress: string;
|
|
262
|
+
chain?: ChainName;
|
|
263
|
+
}): string;
|
|
264
|
+
/**
|
|
265
|
+
* 7. Verifying
|
|
266
|
+
*/
|
|
267
|
+
verifying(): string;
|
|
268
|
+
/**
|
|
269
|
+
* 7. Verification Passed
|
|
270
|
+
*/
|
|
271
|
+
verificationPassed(amount: string): string;
|
|
272
|
+
/**
|
|
273
|
+
* 7. Verification Failed
|
|
274
|
+
*/
|
|
275
|
+
verificationFailed(error: string): string;
|
|
276
|
+
/**
|
|
277
|
+
* 8. Delivery
|
|
278
|
+
*/
|
|
279
|
+
deliver(params: {
|
|
280
|
+
downloadUrl: string;
|
|
281
|
+
fileHash?: string;
|
|
282
|
+
}): string;
|
|
283
|
+
/**
|
|
284
|
+
* 9. Receipt
|
|
285
|
+
*/
|
|
286
|
+
receipt(receipt: Receipt): string;
|
|
287
|
+
/**
|
|
288
|
+
* 10. End
|
|
289
|
+
*/
|
|
290
|
+
end(): string;
|
|
291
|
+
};
|
|
292
|
+
declare const BuyerTemplates: {
|
|
293
|
+
/**
|
|
294
|
+
* 0. Request Service
|
|
295
|
+
*/
|
|
296
|
+
requestService(service: string): string;
|
|
297
|
+
/**
|
|
298
|
+
* 1. No Capability
|
|
299
|
+
*/
|
|
300
|
+
noCapability(): string;
|
|
301
|
+
/**
|
|
302
|
+
* 1. Has Capability
|
|
303
|
+
*/
|
|
304
|
+
hasCapability(balance?: string): string;
|
|
305
|
+
/**
|
|
306
|
+
* 2. Agree to Guide
|
|
307
|
+
*/
|
|
308
|
+
agreeToGuide(): string;
|
|
309
|
+
/**
|
|
310
|
+
* 3.1 Report Wallet Created
|
|
311
|
+
*/
|
|
312
|
+
walletCreated(address: string): string;
|
|
313
|
+
/**
|
|
314
|
+
* 3.3 Choose Permit Method
|
|
315
|
+
*/
|
|
316
|
+
choosePermit(): string;
|
|
317
|
+
/**
|
|
318
|
+
* 3.3 Choose Direct Transfer
|
|
319
|
+
*/
|
|
320
|
+
chooseDirectTransfer(): string;
|
|
321
|
+
/**
|
|
322
|
+
* 3.4 Report Permit Received
|
|
323
|
+
*/
|
|
324
|
+
permitReceived(amount: number): string;
|
|
325
|
+
/**
|
|
326
|
+
* 4. Submit Requirements
|
|
327
|
+
*/
|
|
328
|
+
submitRequirements(requirements: string): string;
|
|
329
|
+
/**
|
|
330
|
+
* 5. Confirm Purchase
|
|
331
|
+
*/
|
|
332
|
+
confirmPurchase(): string;
|
|
333
|
+
/**
|
|
334
|
+
* 6. Report Payment Sent
|
|
335
|
+
*/
|
|
336
|
+
paymentSent(txHash: string, amount: number): string;
|
|
337
|
+
/**
|
|
338
|
+
* 8. Confirm Delivery Received
|
|
339
|
+
*/
|
|
340
|
+
deliveryReceived(): string;
|
|
341
|
+
/**
|
|
342
|
+
* 9. Confirm Receipt
|
|
343
|
+
*/
|
|
344
|
+
receiptReceived(): string;
|
|
345
|
+
/**
|
|
346
|
+
* Request Permit from Boss
|
|
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 };
|