moltspay 0.2.0 → 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.
@@ -34,131 +34,131 @@ function generatePaymentGuide(params) {
34
34
  price,
35
35
  recipientAddress,
36
36
  chain = "base",
37
- serviceName = "\u89C6\u9891\u751F\u6210\u670D\u52A1"
37
+ serviceName = "Video Generation Service"
38
38
  } = params;
39
39
  const chainId = chain === "base" ? 8453 : 84532;
40
- const chainName = chain === "base" ? "Base \u4E3B\u7F51" : "Base Sepolia \u6D4B\u8BD5\u7F51";
40
+ const chainName = chain === "base" ? "Base Mainnet" : "Base Sepolia Testnet";
41
41
  const explorer = chain === "base" ? "https://basescan.org/tx/" : "https://sepolia.basescan.org/tx/";
42
42
  return `\u{1F3AC} **${serviceName}**
43
43
 
44
- \u{1F4CB} **\u8BA2\u5355\u4FE1\u606F:**
45
- - \u8BA2\u5355\u53F7: \`${orderId}\`
46
- - \u5185\u5BB9: ${prompt.length > 50 ? prompt.slice(0, 50) + "..." : prompt}
47
- - \u4EF7\u683C: **${price} USDC**
48
- - \u94FE: ${chainName}
44
+ \u{1F4CB} **Order Details:**
45
+ - Order ID: \`${orderId}\`
46
+ - Content: ${prompt.length > 50 ? prompt.slice(0, 50) + "..." : prompt}
47
+ - Price: **${price} USDC**
48
+ - Chain: ${chainName}
49
49
 
50
50
  ---
51
51
 
52
- ## \u{1F4B3} \u5982\u4F55\u652F\u4ED8
52
+ ## \u{1F4B3} How to Pay
53
53
 
54
- ### \u65B9\u5F0F\u4E00\uFF1A\u5B89\u88C5 moltspay SDK\uFF08\u63A8\u8350\uFF09
54
+ ### Option 1: Install moltspay SDK (Recommended)
55
55
 
56
56
  \`\`\`bash
57
57
  npm install moltspay ethers
58
58
  \`\`\`
59
59
 
60
- **\u521B\u5EFA\u94B1\u5305\u5E76\u652F\u4ED8\uFF1A**
60
+ **Create wallet and pay:**
61
61
 
62
62
  \`\`\`javascript
63
63
  const { SecureWallet, getChain } = require('moltspay');
64
64
  const { Wallet } = require('ethers');
65
65
 
66
- // 1. \u521B\u5EFA\u65B0\u94B1\u5305\uFF08\u9996\u6B21\u4F7F\u7528\uFF09
66
+ // 1. Create new wallet (first time)
67
67
  const newWallet = Wallet.createRandom();
68
- console.log('\u94B1\u5305\u5730\u5740:', newWallet.address);
69
- console.log('\u79C1\u94A5\uFF08\u8BF7\u5B89\u5168\u4FDD\u5B58\uFF09:', newWallet.privateKey);
68
+ console.log('Wallet address:', newWallet.address);
69
+ console.log('Private key (save securely):', newWallet.privateKey);
70
70
 
71
- // 2. \u6216\u4F7F\u7528\u5DF2\u6709\u94B1\u5305
71
+ // 2. Or use existing wallet
72
72
  const wallet = new SecureWallet({
73
73
  chainId: ${chainId},
74
- privateKey: process.env.WALLET_KEY, // \u4F60\u7684\u79C1\u94A5
75
- limits: { requireWhitelist: false } // \u5141\u8BB8\u5411\u4EFB\u610F\u5730\u5740\u8F6C\u8D26
74
+ privateKey: process.env.WALLET_KEY, // Your private key
75
+ limits: { requireWhitelist: false } // Allow transfers to any address
76
76
  });
77
77
 
78
- // 3. \u67E5\u770B\u4F59\u989D
78
+ // 3. Check balance
79
79
  const balance = await wallet.getBalance();
80
- console.log('USDC\u4F59\u989D:', balance.usdc);
80
+ console.log('USDC balance:', balance.usdc);
81
81
 
82
- // 4. \u652F\u4ED8
82
+ // 4. Pay
83
83
  const result = await wallet.transfer('${recipientAddress}', '${price}');
84
84
  if (result.success) {
85
- console.log('\u2705 \u652F\u4ED8\u6210\u529F\uFF01');
86
- console.log('\u4EA4\u6613hash:', result.hash);
87
- // \u628A\u4EA4\u6613hash\u53D1\u7ED9\u6211
85
+ console.log('\u2705 Payment successful!');
86
+ console.log('Tx hash:', result.hash);
87
+ // Send the tx hash to me
88
88
  }
89
89
  \`\`\`
90
90
 
91
- ### \u65B9\u5F0F\u4E8C\uFF1A\u76F4\u63A5\u8F6C\u8D26
91
+ ### Option 2: Direct Transfer
92
92
 
93
- \u4ECE\u4EFB\u610F\u94B1\u5305\u8F6C\u8D26 USDC\uFF1A
94
- - **\u94FE:** ${chainName} (Chain ID: ${chainId})
93
+ Transfer USDC from any wallet:
94
+ - **Chain:** ${chainName} (Chain ID: ${chainId})
95
95
  - **Token:** USDC
96
- - **\u6536\u6B3E\u5730\u5740:** \`${recipientAddress}\`
97
- - **\u91D1\u989D:** ${price} USDC
96
+ - **Recipient:** \`${recipientAddress}\`
97
+ - **Amount:** ${price} USDC
98
98
 
99
99
  ---
100
100
 
101
- ## \u2705 \u652F\u4ED8\u5B8C\u6210\u540E
101
+ ## \u2705 After Payment
102
102
 
103
- \u8BF7\u53D1\u9001**\u4EA4\u6613hash**\u7ED9\u6211\uFF0C\u683C\u5F0F\uFF1A
103
+ Send me the **transaction hash**, format:
104
104
  \`\`\`
105
105
  tx: 0x1234...
106
106
  \`\`\`
107
107
 
108
- \u6216\u76F4\u63A5\u53D1\u9001hash\uFF1A
108
+ Or just send the hash directly:
109
109
  \`\`\`
110
110
  0x1234abcd...
111
111
  \`\`\`
112
112
 
113
- \u6211\u4F1A\u9A8C\u8BC1\u94FE\u4E0A\u4EA4\u6613\u540E\u5F00\u59CB\u5904\u7406\u4F60\u7684\u8BF7\u6C42\u3002
113
+ I'll verify the on-chain transaction and start processing your request.
114
114
 
115
115
  ---
116
116
 
117
117
  \u{1F4E6} **moltspay:** https://www.npmjs.com/package/moltspay
118
- \u{1F517} **\u533A\u5757\u6D4F\u89C8\u5668:** ${explorer}`;
118
+ \u{1F517} **Block Explorer:** ${explorer}`;
119
119
  }
120
120
  function generatePaymentReminder(params) {
121
121
  const { orderId, price, recipientAddress, chain = "base" } = params;
122
122
  const chainName = chain === "base" ? "Base" : "Base Sepolia";
123
- return `\u23F3 **\u5F85\u652F\u4ED8\u8BA2\u5355: ${orderId}**
123
+ return `\u23F3 **Pending Order: ${orderId}**
124
124
 
125
- \u8BF7\u652F\u4ED8 **${price} USDC** \u5230:
126
- - \u94FE: ${chainName}
127
- - \u5730\u5740: \`${recipientAddress}\`
125
+ Please pay **${price} USDC** to:
126
+ - Chain: ${chainName}
127
+ - Address: \`${recipientAddress}\`
128
128
 
129
- \u652F\u4ED8\u540E\u53D1\u9001\u4EA4\u6613hash\u7ED9\u6211\u3002
129
+ Send the tx hash after payment.
130
130
 
131
131
  ---
132
- \u{1F4A1} \u6CA1\u6709\u652F\u4ED8\u80FD\u529B\uFF1F\u8FD0\u884C \`npm install moltspay\` \u83B7\u53D6\u652F\u4ED8SDK`;
132
+ \u{1F4A1} No payment capability? Run \`npm install moltspay\` to get the payment SDK`;
133
133
  }
134
134
  function generateWalletGuide() {
135
- return `## \u{1F510} \u521B\u5EFA\u652F\u4ED8\u94B1\u5305
135
+ return `## \u{1F510} Create Payment Wallet
136
136
 
137
- **1. \u5B89\u88C5 moltspay:**
137
+ **1. Install moltspay:**
138
138
  \`\`\`bash
139
139
  npm install moltspay ethers
140
140
  \`\`\`
141
141
 
142
- **2. \u521B\u5EFA\u65B0\u94B1\u5305:**
142
+ **2. Create new wallet:**
143
143
  \`\`\`javascript
144
144
  const { Wallet } = require('ethers');
145
145
 
146
146
  const wallet = Wallet.createRandom();
147
- console.log('\u5730\u5740:', wallet.address);
148
- console.log('\u79C1\u94A5:', wallet.privateKey);
149
- // \u26A0\uFE0F \u8BF7\u5B89\u5168\u4FDD\u5B58\u79C1\u94A5\uFF01
147
+ console.log('Address:', wallet.address);
148
+ console.log('Private key:', wallet.privateKey);
149
+ // \u26A0\uFE0F Save the private key securely!
150
150
  \`\`\`
151
151
 
152
- **3. \u83B7\u53D6 USDC:**
153
- - \u4E3B\u7F51: \u4ECE\u4EA4\u6613\u6240\u63D0\u5E01\u5230\u4F60\u7684\u94B1\u5305\u5730\u5740
154
- - \u6D4B\u8BD5\u7F51: \u4F7F\u7528 Base Sepolia faucet
152
+ **3. Get USDC:**
153
+ - Mainnet: Withdraw from exchange to your wallet
154
+ - Testnet: Use Base Sepolia faucet
155
155
 
156
- **4. \u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF:**
156
+ **4. Set environment variable:**
157
157
  \`\`\`bash
158
- export WALLET_KEY="\u4F60\u7684\u79C1\u94A5"
158
+ export WALLET_KEY="your_private_key"
159
159
  \`\`\`
160
160
 
161
- \u5B8C\u6210\u540E\u5373\u53EF\u4F7F\u7528 moltspay \u8FDB\u884C\u94FE\u4E0A\u652F\u4ED8\uFF01`;
161
+ You're now ready to make on-chain payments with moltspay!`;
162
162
  }
163
163
  function extractTransactionHash(message) {
164
164
  const match = message.match(/0x[a-fA-F0-9]{64}/);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n * 支付引导消息生成\n * 用于引导没有支付能力的Agent安装和使用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 * 生成完整的支付引导消息\n */\nexport function generatePaymentGuide(params: PaymentGuideParams): string {\n const {\n orderId,\n prompt,\n price,\n recipientAddress,\n chain = 'base',\n serviceName = '视频生成服务'\n } = params;\n\n const chainId = chain === 'base' ? 8453 : 84532;\n const chainName = chain === 'base' ? 'Base 主网' : 'Base Sepolia 测试网';\n const explorer = chain === 'base' \n ? 'https://basescan.org/tx/' \n : 'https://sepolia.basescan.org/tx/';\n\n return `🎬 **${serviceName}**\n\n📋 **订单信息:**\n- 订单号: \\`${orderId}\\`\n- 内容: ${prompt.length > 50 ? prompt.slice(0, 50) + '...' : prompt}\n- 价格: **${price} USDC**\n- 链: ${chainName}\n\n---\n\n## 💳 如何支付\n\n### 方式一:安装 moltspay SDK(推荐)\n\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**创建钱包并支付:**\n\n\\`\\`\\`javascript\nconst { SecureWallet, getChain } = require('moltspay');\nconst { Wallet } = require('ethers');\n\n// 1. 创建新钱包(首次使用)\nconst newWallet = Wallet.createRandom();\nconsole.log('钱包地址:', newWallet.address);\nconsole.log('私钥(请安全保存):', newWallet.privateKey);\n\n// 2. 或使用已有钱包\nconst wallet = new SecureWallet({\n chainId: ${chainId},\n privateKey: process.env.WALLET_KEY, // 你的私钥\n limits: { requireWhitelist: false } // 允许向任意地址转账\n});\n\n// 3. 查看余额\nconst balance = await wallet.getBalance();\nconsole.log('USDC余额:', balance.usdc);\n\n// 4. 支付\nconst result = await wallet.transfer('${recipientAddress}', '${price}');\nif (result.success) {\n console.log('✅ 支付成功!');\n console.log('交易hash:', result.hash);\n // 把交易hash发给我\n}\n\\`\\`\\`\n\n### 方式二:直接转账\n\n从任意钱包转账 USDC:\n- **链:** ${chainName} (Chain ID: ${chainId})\n- **Token:** USDC\n- **收款地址:** \\`${recipientAddress}\\`\n- **金额:** ${price} USDC\n\n---\n\n## ✅ 支付完成后\n\n请发送**交易hash**给我,格式:\n\\`\\`\\`\ntx: 0x1234...\n\\`\\`\\`\n\n或直接发送hash:\n\\`\\`\\`\n0x1234abcd...\n\\`\\`\\`\n\n我会验证链上交易后开始处理你的请求。\n\n---\n\n📦 **moltspay:** https://www.npmjs.com/package/moltspay\n🔗 **区块浏览器:** ${explorer}`;\n}\n\n/**\n * 生成简短的支付提醒\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 `⏳ **待支付订单: ${orderId}**\n\n请支付 **${price} USDC** 到:\n- 链: ${chainName}\n- 地址: \\`${recipientAddress}\\`\n\n支付后发送交易hash给我。\n\n---\n💡 没有支付能力?运行 \\`npm install moltspay\\` 获取支付SDK`;\n}\n\n/**\n * 生成钱包创建指南\n */\nexport function generateWalletGuide(): string {\n return `## 🔐 创建支付钱包\n\n**1. 安装 moltspay:**\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**2. 创建新钱包:**\n\\`\\`\\`javascript\nconst { Wallet } = require('ethers');\n\nconst wallet = Wallet.createRandom();\nconsole.log('地址:', wallet.address);\nconsole.log('私钥:', wallet.privateKey);\n// ⚠️ 请安全保存私钥!\n\\`\\`\\`\n\n**3. 获取 USDC:**\n- 主网: 从交易所提币到你的钱包地址\n- 测试网: 使用 Base Sepolia faucet\n\n**4. 设置环境变量:**\n\\`\\`\\`bash\nexport WALLET_KEY=\"你的私钥\"\n\\`\\`\\`\n\n完成后即可使用 moltspay 进行链上支付!`;\n}\n\n/**\n * 解析用户消息中的交易hash\n */\nexport function extractTransactionHash(message: string): string | null {\n // 匹配 0x 开头的64hex\n const match = message.match(/0x[a-fA-F0-9]{64}/);\n if (match) return match[0];\n\n // 匹配 tx: 后面的内容\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 * 判断消息是否包含交易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,sBAAY;AACjD,QAAM,WAAW,UAAU,SACvB,6BACA;AAEJ,SAAO,eAAQ,WAAW;AAAA;AAAA;AAAA,0BAGjB,OAAO;AAAA,kBACV,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,EAAE,IAAI,QAAQ,MAAM;AAAA,oBACvD,KAAK;AAAA,YACR,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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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":[]}
@@ -6,131 +6,131 @@ function generatePaymentGuide(params) {
6
6
  price,
7
7
  recipientAddress,
8
8
  chain = "base",
9
- serviceName = "\u89C6\u9891\u751F\u6210\u670D\u52A1"
9
+ serviceName = "Video Generation Service"
10
10
  } = params;
11
11
  const chainId = chain === "base" ? 8453 : 84532;
12
- const chainName = chain === "base" ? "Base \u4E3B\u7F51" : "Base Sepolia \u6D4B\u8BD5\u7F51";
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} **\u8BA2\u5355\u4FE1\u606F:**
17
- - \u8BA2\u5355\u53F7: \`${orderId}\`
18
- - \u5185\u5BB9: ${prompt.length > 50 ? prompt.slice(0, 50) + "..." : prompt}
19
- - \u4EF7\u683C: **${price} USDC**
20
- - \u94FE: ${chainName}
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} \u5982\u4F55\u652F\u4ED8
24
+ ## \u{1F4B3} How to Pay
25
25
 
26
- ### \u65B9\u5F0F\u4E00\uFF1A\u5B89\u88C5 moltspay SDK\uFF08\u63A8\u8350\uFF09
26
+ ### Option 1: Install moltspay SDK (Recommended)
27
27
 
28
28
  \`\`\`bash
29
29
  npm install moltspay ethers
30
30
  \`\`\`
31
31
 
32
- **\u521B\u5EFA\u94B1\u5305\u5E76\u652F\u4ED8\uFF1A**
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. \u521B\u5EFA\u65B0\u94B1\u5305\uFF08\u9996\u6B21\u4F7F\u7528\uFF09
38
+ // 1. Create new wallet (first time)
39
39
  const newWallet = Wallet.createRandom();
40
- console.log('\u94B1\u5305\u5730\u5740:', newWallet.address);
41
- console.log('\u79C1\u94A5\uFF08\u8BF7\u5B89\u5168\u4FDD\u5B58\uFF09:', newWallet.privateKey);
40
+ console.log('Wallet address:', newWallet.address);
41
+ console.log('Private key (save securely):', newWallet.privateKey);
42
42
 
43
- // 2. \u6216\u4F7F\u7528\u5DF2\u6709\u94B1\u5305
43
+ // 2. Or use existing wallet
44
44
  const wallet = new SecureWallet({
45
45
  chainId: ${chainId},
46
- privateKey: process.env.WALLET_KEY, // \u4F60\u7684\u79C1\u94A5
47
- limits: { requireWhitelist: false } // \u5141\u8BB8\u5411\u4EFB\u610F\u5730\u5740\u8F6C\u8D26
46
+ privateKey: process.env.WALLET_KEY, // Your private key
47
+ limits: { requireWhitelist: false } // Allow transfers to any address
48
48
  });
49
49
 
50
- // 3. \u67E5\u770B\u4F59\u989D
50
+ // 3. Check balance
51
51
  const balance = await wallet.getBalance();
52
- console.log('USDC\u4F59\u989D:', balance.usdc);
52
+ console.log('USDC balance:', balance.usdc);
53
53
 
54
- // 4. \u652F\u4ED8
54
+ // 4. Pay
55
55
  const result = await wallet.transfer('${recipientAddress}', '${price}');
56
56
  if (result.success) {
57
- console.log('\u2705 \u652F\u4ED8\u6210\u529F\uFF01');
58
- console.log('\u4EA4\u6613hash:', result.hash);
59
- // \u628A\u4EA4\u6613hash\u53D1\u7ED9\u6211
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
- ### \u65B9\u5F0F\u4E8C\uFF1A\u76F4\u63A5\u8F6C\u8D26
63
+ ### Option 2: Direct Transfer
64
64
 
65
- \u4ECE\u4EFB\u610F\u94B1\u5305\u8F6C\u8D26 USDC\uFF1A
66
- - **\u94FE:** ${chainName} (Chain ID: ${chainId})
65
+ Transfer USDC from any wallet:
66
+ - **Chain:** ${chainName} (Chain ID: ${chainId})
67
67
  - **Token:** USDC
68
- - **\u6536\u6B3E\u5730\u5740:** \`${recipientAddress}\`
69
- - **\u91D1\u989D:** ${price} USDC
68
+ - **Recipient:** \`${recipientAddress}\`
69
+ - **Amount:** ${price} USDC
70
70
 
71
71
  ---
72
72
 
73
- ## \u2705 \u652F\u4ED8\u5B8C\u6210\u540E
73
+ ## \u2705 After Payment
74
74
 
75
- \u8BF7\u53D1\u9001**\u4EA4\u6613hash**\u7ED9\u6211\uFF0C\u683C\u5F0F\uFF1A
75
+ Send me the **transaction hash**, format:
76
76
  \`\`\`
77
77
  tx: 0x1234...
78
78
  \`\`\`
79
79
 
80
- \u6216\u76F4\u63A5\u53D1\u9001hash\uFF1A
80
+ Or just send the hash directly:
81
81
  \`\`\`
82
82
  0x1234abcd...
83
83
  \`\`\`
84
84
 
85
- \u6211\u4F1A\u9A8C\u8BC1\u94FE\u4E0A\u4EA4\u6613\u540E\u5F00\u59CB\u5904\u7406\u4F60\u7684\u8BF7\u6C42\u3002
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} **\u533A\u5757\u6D4F\u89C8\u5668:** ${explorer}`;
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 **\u5F85\u652F\u4ED8\u8BA2\u5355: ${orderId}**
95
+ return `\u23F3 **Pending Order: ${orderId}**
96
96
 
97
- \u8BF7\u652F\u4ED8 **${price} USDC** \u5230:
98
- - \u94FE: ${chainName}
99
- - \u5730\u5740: \`${recipientAddress}\`
97
+ Please pay **${price} USDC** to:
98
+ - Chain: ${chainName}
99
+ - Address: \`${recipientAddress}\`
100
100
 
101
- \u652F\u4ED8\u540E\u53D1\u9001\u4EA4\u6613hash\u7ED9\u6211\u3002
101
+ Send the tx hash after payment.
102
102
 
103
103
  ---
104
- \u{1F4A1} \u6CA1\u6709\u652F\u4ED8\u80FD\u529B\uFF1F\u8FD0\u884C \`npm install moltspay\` \u83B7\u53D6\u652F\u4ED8SDK`;
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} \u521B\u5EFA\u652F\u4ED8\u94B1\u5305
107
+ return `## \u{1F510} Create Payment Wallet
108
108
 
109
- **1. \u5B89\u88C5 moltspay:**
109
+ **1. Install moltspay:**
110
110
  \`\`\`bash
111
111
  npm install moltspay ethers
112
112
  \`\`\`
113
113
 
114
- **2. \u521B\u5EFA\u65B0\u94B1\u5305:**
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('\u5730\u5740:', wallet.address);
120
- console.log('\u79C1\u94A5:', wallet.privateKey);
121
- // \u26A0\uFE0F \u8BF7\u5B89\u5168\u4FDD\u5B58\u79C1\u94A5\uFF01
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. \u83B7\u53D6 USDC:**
125
- - \u4E3B\u7F51: \u4ECE\u4EA4\u6613\u6240\u63D0\u5E01\u5230\u4F60\u7684\u94B1\u5305\u5730\u5740
126
- - \u6D4B\u8BD5\u7F51: \u4F7F\u7528 Base Sepolia faucet
124
+ **3. Get USDC:**
125
+ - Mainnet: Withdraw from exchange to your wallet
126
+ - Testnet: Use Base Sepolia faucet
127
127
 
128
- **4. \u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF:**
128
+ **4. Set environment variable:**
129
129
  \`\`\`bash
130
- export WALLET_KEY="\u4F60\u7684\u79C1\u94A5"
130
+ export WALLET_KEY="your_private_key"
131
131
  \`\`\`
132
132
 
133
- \u5B8C\u6210\u540E\u5373\u53EF\u4F7F\u7528 moltspay \u8FDB\u884C\u94FE\u4E0A\u652F\u4ED8\uFF01`;
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}/);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/guide/index.ts"],"sourcesContent":["/**\n * 支付引导消息生成\n * 用于引导没有支付能力的Agent安装和使用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 * 生成完整的支付引导消息\n */\nexport function generatePaymentGuide(params: PaymentGuideParams): string {\n const {\n orderId,\n prompt,\n price,\n recipientAddress,\n chain = 'base',\n serviceName = '视频生成服务'\n } = params;\n\n const chainId = chain === 'base' ? 8453 : 84532;\n const chainName = chain === 'base' ? 'Base 主网' : 'Base Sepolia 测试网';\n const explorer = chain === 'base' \n ? 'https://basescan.org/tx/' \n : 'https://sepolia.basescan.org/tx/';\n\n return `🎬 **${serviceName}**\n\n📋 **订单信息:**\n- 订单号: \\`${orderId}\\`\n- 内容: ${prompt.length > 50 ? prompt.slice(0, 50) + '...' : prompt}\n- 价格: **${price} USDC**\n- 链: ${chainName}\n\n---\n\n## 💳 如何支付\n\n### 方式一:安装 moltspay SDK(推荐)\n\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**创建钱包并支付:**\n\n\\`\\`\\`javascript\nconst { SecureWallet, getChain } = require('moltspay');\nconst { Wallet } = require('ethers');\n\n// 1. 创建新钱包(首次使用)\nconst newWallet = Wallet.createRandom();\nconsole.log('钱包地址:', newWallet.address);\nconsole.log('私钥(请安全保存):', newWallet.privateKey);\n\n// 2. 或使用已有钱包\nconst wallet = new SecureWallet({\n chainId: ${chainId},\n privateKey: process.env.WALLET_KEY, // 你的私钥\n limits: { requireWhitelist: false } // 允许向任意地址转账\n});\n\n// 3. 查看余额\nconst balance = await wallet.getBalance();\nconsole.log('USDC余额:', balance.usdc);\n\n// 4. 支付\nconst result = await wallet.transfer('${recipientAddress}', '${price}');\nif (result.success) {\n console.log('✅ 支付成功!');\n console.log('交易hash:', result.hash);\n // 把交易hash发给我\n}\n\\`\\`\\`\n\n### 方式二:直接转账\n\n从任意钱包转账 USDC:\n- **链:** ${chainName} (Chain ID: ${chainId})\n- **Token:** USDC\n- **收款地址:** \\`${recipientAddress}\\`\n- **金额:** ${price} USDC\n\n---\n\n## ✅ 支付完成后\n\n请发送**交易hash**给我,格式:\n\\`\\`\\`\ntx: 0x1234...\n\\`\\`\\`\n\n或直接发送hash:\n\\`\\`\\`\n0x1234abcd...\n\\`\\`\\`\n\n我会验证链上交易后开始处理你的请求。\n\n---\n\n📦 **moltspay:** https://www.npmjs.com/package/moltspay\n🔗 **区块浏览器:** ${explorer}`;\n}\n\n/**\n * 生成简短的支付提醒\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 `⏳ **待支付订单: ${orderId}**\n\n请支付 **${price} USDC** 到:\n- 链: ${chainName}\n- 地址: \\`${recipientAddress}\\`\n\n支付后发送交易hash给我。\n\n---\n💡 没有支付能力?运行 \\`npm install moltspay\\` 获取支付SDK`;\n}\n\n/**\n * 生成钱包创建指南\n */\nexport function generateWalletGuide(): string {\n return `## 🔐 创建支付钱包\n\n**1. 安装 moltspay:**\n\\`\\`\\`bash\nnpm install moltspay ethers\n\\`\\`\\`\n\n**2. 创建新钱包:**\n\\`\\`\\`javascript\nconst { Wallet } = require('ethers');\n\nconst wallet = Wallet.createRandom();\nconsole.log('地址:', wallet.address);\nconsole.log('私钥:', wallet.privateKey);\n// ⚠️ 请安全保存私钥!\n\\`\\`\\`\n\n**3. 获取 USDC:**\n- 主网: 从交易所提币到你的钱包地址\n- 测试网: 使用 Base Sepolia faucet\n\n**4. 设置环境变量:**\n\\`\\`\\`bash\nexport WALLET_KEY=\"你的私钥\"\n\\`\\`\\`\n\n完成后即可使用 moltspay 进行链上支付!`;\n}\n\n/**\n * 解析用户消息中的交易hash\n */\nexport function extractTransactionHash(message: string): string | null {\n // 匹配 0x 开头的64hex\n const match = message.match(/0x[a-fA-F0-9]{64}/);\n if (match) return match[0];\n\n // 匹配 tx: 后面的内容\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 * 判断消息是否包含交易hash\n */\nexport function has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;AAAA;AAAA;AAAA;AAAA;AAM1B;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":[]}
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;AA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