@atxp/polygon 0.8.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 +497 -0
- package/dist/cache.d.ts +19 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +11 -0
- package/dist/cache.js.map +1 -0
- package/dist/directWalletPaymentMaker.d.ts +35 -0
- package/dist/directWalletPaymentMaker.d.ts.map +1 -0
- package/dist/directWalletPaymentMaker.js +143 -0
- package/dist/directWalletPaymentMaker.js.map +1 -0
- package/dist/index.cjs +458 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +446 -0
- package/dist/index.js.map +1 -0
- package/dist/polygonBrowserAccount.d.ts +40 -0
- package/dist/polygonBrowserAccount.d.ts.map +1 -0
- package/dist/polygonBrowserAccount.js +70 -0
- package/dist/polygonBrowserAccount.js.map +1 -0
- package/dist/polygonServerAccount.d.ts +35 -0
- package/dist/polygonServerAccount.d.ts.map +1 -0
- package/dist/polygonServerAccount.js +78 -0
- package/dist/polygonServerAccount.js.map +1 -0
- package/dist/serverPaymentMaker.d.ts +29 -0
- package/dist/serverPaymentMaker.d.ts.map +1 -0
- package/dist/serverPaymentMaker.js +173 -0
- package/dist/serverPaymentMaker.js.map +1 -0
- package/dist/smartWalletHelpers.d.ts +18 -0
- package/dist/smartWalletHelpers.d.ts.map +1 -0
- package/dist/smartWalletHelpers.js +93 -0
- package/dist/smartWalletHelpers.js.map +1 -0
- package/dist/smartWalletPaymentMaker.d.ts +29 -0
- package/dist/smartWalletPaymentMaker.d.ts.map +1 -0
- package/dist/smartWalletPaymentMaker.js +172 -0
- package/dist/smartWalletPaymentMaker.js.map +1 -0
- package/dist/spendPermissionShim.d.ts +19 -0
- package/dist/spendPermissionShim.d.ts.map +1 -0
- package/dist/spendPermissionShim.js +129 -0
- package/dist/spendPermissionShim.js.map +1 -0
- package/dist/testHelpers.d.ts +17 -0
- package/dist/testHelpers.d.ts.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { encodeFunctionData } from 'viem';
|
|
2
|
+
import { getPolygonUSDCAddress } from '@atxp/client';
|
|
3
|
+
import { polygon } from 'viem/chains';
|
|
4
|
+
import { ConsoleLogger, buildES256KJWTMessage, completeES256KJWT } from '@atxp/common';
|
|
5
|
+
|
|
6
|
+
const USDC_DECIMALS = 6;
|
|
7
|
+
/**
|
|
8
|
+
* Browser-based payment maker using direct wallet signing.
|
|
9
|
+
* Each transaction requires user approval in their wallet.
|
|
10
|
+
* User pays gas fees in POL.
|
|
11
|
+
*/
|
|
12
|
+
class DirectWalletPaymentMaker {
|
|
13
|
+
constructor(walletAddress, provider, logger, chainId = polygon.id) {
|
|
14
|
+
this.walletAddress = walletAddress;
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
this.logger = logger || new ConsoleLogger();
|
|
17
|
+
this.chainId = chainId;
|
|
18
|
+
this.usdcAddress = getPolygonUSDCAddress(chainId);
|
|
19
|
+
}
|
|
20
|
+
getSourceAddress(_params) {
|
|
21
|
+
return this.walletAddress;
|
|
22
|
+
}
|
|
23
|
+
async generateJWT(payload) {
|
|
24
|
+
this.logger.info(`codeChallenge: ${payload.codeChallenge}`);
|
|
25
|
+
this.logger.info(`paymentRequestId: ${payload.paymentRequestId}`);
|
|
26
|
+
this.logger.info(`walletAddress: ${this.walletAddress}`);
|
|
27
|
+
// Step 1: Build the JWT message (header.payload) that needs to be signed
|
|
28
|
+
const { message } = buildES256KJWTMessage({
|
|
29
|
+
walletAddress: this.walletAddress,
|
|
30
|
+
codeChallenge: payload.codeChallenge,
|
|
31
|
+
paymentRequestId: payload.paymentRequestId,
|
|
32
|
+
accountId: payload.accountId,
|
|
33
|
+
});
|
|
34
|
+
this.logger.info(`Requesting signature for JWT message: ${message}`);
|
|
35
|
+
// Step 2: Request signature from the wallet using personal_sign
|
|
36
|
+
// The user will sign the JWT message (header.payload)
|
|
37
|
+
// This returns a 65-byte ECDSA signature (130 hex chars + 0x prefix)
|
|
38
|
+
const signature = await this.provider.request({
|
|
39
|
+
method: 'personal_sign',
|
|
40
|
+
params: [message, this.walletAddress]
|
|
41
|
+
});
|
|
42
|
+
this.logger.info(`Received signature: ${signature}`);
|
|
43
|
+
// Step 3: Complete the JWT by adding the signature
|
|
44
|
+
const jwtToken = completeES256KJWT({
|
|
45
|
+
message,
|
|
46
|
+
signature
|
|
47
|
+
});
|
|
48
|
+
this.logger.info(`Generated ES256K JWT: ${jwtToken}`);
|
|
49
|
+
return jwtToken;
|
|
50
|
+
}
|
|
51
|
+
async makePayment(destinations, _memo, _paymentRequestId) {
|
|
52
|
+
// Filter to polygon chain destinations
|
|
53
|
+
const polygonDestinations = destinations.filter(d => d.chain === 'polygon');
|
|
54
|
+
if (polygonDestinations.length === 0) {
|
|
55
|
+
this.logger.debug('MainWalletPaymentMaker: No polygon destinations found, cannot handle payment');
|
|
56
|
+
return null; // Cannot handle these destinations
|
|
57
|
+
}
|
|
58
|
+
// Pick first polygon destination
|
|
59
|
+
const dest = polygonDestinations[0];
|
|
60
|
+
const amount = dest.amount;
|
|
61
|
+
const currency = dest.currency;
|
|
62
|
+
const receiver = dest.address;
|
|
63
|
+
if (currency !== 'USDC') {
|
|
64
|
+
throw new Error('Only usdc currency is supported');
|
|
65
|
+
}
|
|
66
|
+
this.logger.info(`Making direct payment of ${amount} ${currency} to ${receiver} on Polygon`);
|
|
67
|
+
// Convert amount to USDC units (6 decimals)
|
|
68
|
+
const amountInUSDCUnits = BigInt(amount.multipliedBy(10 ** USDC_DECIMALS).toFixed(0));
|
|
69
|
+
// Encode the transfer function data
|
|
70
|
+
const transferData = encodeFunctionData({
|
|
71
|
+
abi: [{
|
|
72
|
+
name: 'transfer',
|
|
73
|
+
type: 'function',
|
|
74
|
+
inputs: [
|
|
75
|
+
{ name: 'to', type: 'address' },
|
|
76
|
+
{ name: 'amount', type: 'uint256' }
|
|
77
|
+
],
|
|
78
|
+
outputs: [{ name: '', type: 'bool' }]
|
|
79
|
+
}],
|
|
80
|
+
functionName: 'transfer',
|
|
81
|
+
args: [receiver, amountInUSDCUnits]
|
|
82
|
+
});
|
|
83
|
+
// Send the transaction through the user's wallet
|
|
84
|
+
const txHash = await this.provider.request({
|
|
85
|
+
method: 'eth_sendTransaction',
|
|
86
|
+
params: [{
|
|
87
|
+
from: this.walletAddress,
|
|
88
|
+
to: this.usdcAddress,
|
|
89
|
+
data: transferData,
|
|
90
|
+
value: '0x0'
|
|
91
|
+
}]
|
|
92
|
+
});
|
|
93
|
+
this.logger.info(`Transaction submitted. TxHash: ${txHash}`);
|
|
94
|
+
// Wait for confirmations
|
|
95
|
+
const CONFIRMATIONS = 2;
|
|
96
|
+
await this.waitForTransactionConfirmations(txHash, CONFIRMATIONS);
|
|
97
|
+
// Return payment result with chain and currency
|
|
98
|
+
return {
|
|
99
|
+
transactionId: txHash,
|
|
100
|
+
chain: 'polygon',
|
|
101
|
+
currency: 'USDC'
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
async waitForTransactionConfirmations(txHash, confirmations) {
|
|
105
|
+
this.logger.info(`Waiting for ${confirmations} confirmations...`);
|
|
106
|
+
// Poll for transaction receipt
|
|
107
|
+
let receipt = null;
|
|
108
|
+
while (!receipt) {
|
|
109
|
+
try {
|
|
110
|
+
receipt = await this.provider.request({
|
|
111
|
+
method: 'eth_getTransactionReceipt',
|
|
112
|
+
params: [txHash]
|
|
113
|
+
});
|
|
114
|
+
if (!receipt) {
|
|
115
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
this.logger.warn(`Error getting receipt: ${error}`);
|
|
120
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Check if transaction was successful
|
|
124
|
+
if (receipt.status === '0x0') {
|
|
125
|
+
throw new Error(`Transaction failed. TxHash: ${txHash}`);
|
|
126
|
+
}
|
|
127
|
+
// Wait for confirmations
|
|
128
|
+
const startBlock = parseInt(receipt.blockNumber, 16);
|
|
129
|
+
let currentBlock = startBlock;
|
|
130
|
+
while (currentBlock - startBlock < confirmations - 1) {
|
|
131
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
132
|
+
const blockNumber = await this.provider.request({
|
|
133
|
+
method: 'eth_blockNumber',
|
|
134
|
+
params: []
|
|
135
|
+
});
|
|
136
|
+
currentBlock = parseInt(blockNumber, 16);
|
|
137
|
+
}
|
|
138
|
+
this.logger.info(`Transaction confirmed with ${confirmations} confirmations`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { DirectWalletPaymentMaker };
|
|
143
|
+
//# sourceMappingURL=directWalletPaymentMaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directWalletPaymentMaker.js","sources":["../src/directWalletPaymentMaker.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAUA,MAAM,aAAa,GAAG,CAAC;AASvB;;;;AAIG;MACU,wBAAwB,CAAA;IAKnC,WAAA,CACU,aAAqB,EACrB,QAA4B,EACpC,MAAe,EACf,OAAA,GAAkB,OAAO,CAAC,EAAE,EAAA;QAHpB,IAAA,CAAA,aAAa,GAAb,aAAa;QACb,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAIhB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,aAAa,EAAE;AAC3C,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AACtB,QAAA,IAAI,CAAC,WAAW,GAAG,qBAAqB,CAAC,OAAO,CAAC;IACnD;AAEA,IAAA,gBAAgB,CAAC,OAAgF,EAAA;QAC/F,OAAO,IAAI,CAAC,aAAa;IAC3B;IAEA,MAAM,WAAW,CAAC,OAIjB,EAAA;QACC,IAAI,CAA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AAO,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD;QACF;;AAGA,QAAA,IAAI,OAAO,CAAC,MAAM,KAAK,KAAK,EAAE;AAC5B,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAA,CAAE,CAAC;QAC1D;;QAGA,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;QACpD,IAAI,YAAY,GAAG,UAAU;QAE7B,OAAO,YAAY,GAAG,UAAU,GAAG,aAAa,GAAG,CAAC,EAAE;AACpD,YAAA,MAAM,IAAI,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YAEvD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;AAC9C,gBAAA,MAAM,EAAE,iBAAiB;AACzB,gBAAA,MAAM,EAAE;AACT,aAAA,CAAC;AAEF,YAAA,YAAY,GAAG,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1C;QAEA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA,2BAAA,EAA8B,aAAa,CAAA,cAAA,CAAgB,CAAC;IAC/E;AAED;;;;"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('@atxp/common');
|
|
4
|
+
var viem = require('viem');
|
|
5
|
+
var client = require('@atxp/client');
|
|
6
|
+
var chains = require('viem/chains');
|
|
7
|
+
var accounts = require('viem/accounts');
|
|
8
|
+
|
|
9
|
+
const USDC_DECIMALS$1 = 6;
|
|
10
|
+
/**
|
|
11
|
+
* Browser-based payment maker using direct wallet signing.
|
|
12
|
+
* Each transaction requires user approval in their wallet.
|
|
13
|
+
* User pays gas fees in POL.
|
|
14
|
+
*/
|
|
15
|
+
class DirectWalletPaymentMaker {
|
|
16
|
+
constructor(walletAddress, provider, logger, chainId = chains.polygon.id) {
|
|
17
|
+
this.walletAddress = walletAddress;
|
|
18
|
+
this.provider = provider;
|
|
19
|
+
this.logger = logger || new common.ConsoleLogger();
|
|
20
|
+
this.chainId = chainId;
|
|
21
|
+
this.usdcAddress = client.getPolygonUSDCAddress(chainId);
|
|
22
|
+
}
|
|
23
|
+
getSourceAddress(_params) {
|
|
24
|
+
return this.walletAddress;
|
|
25
|
+
}
|
|
26
|
+
async generateJWT(payload) {
|
|
27
|
+
this.logger.info(`codeChallenge: ${payload.codeChallenge}`);
|
|
28
|
+
this.logger.info(`paymentRequestId: ${payload.paymentRequestId}`);
|
|
29
|
+
this.logger.info(`walletAddress: ${this.walletAddress}`);
|
|
30
|
+
// Step 1: Build the JWT message (header.payload) that needs to be signed
|
|
31
|
+
const { message } = common.buildES256KJWTMessage({
|
|
32
|
+
walletAddress: this.walletAddress,
|
|
33
|
+
codeChallenge: payload.codeChallenge,
|
|
34
|
+
paymentRequestId: payload.paymentRequestId,
|
|
35
|
+
accountId: payload.accountId,
|
|
36
|
+
});
|
|
37
|
+
this.logger.info(`Requesting signature for JWT message: ${message}`);
|
|
38
|
+
// Step 2: Request signature from the wallet using personal_sign
|
|
39
|
+
// The user will sign the JWT message (header.payload)
|
|
40
|
+
// This returns a 65-byte ECDSA signature (130 hex chars + 0x prefix)
|
|
41
|
+
const signature = await this.provider.request({
|
|
42
|
+
method: 'personal_sign',
|
|
43
|
+
params: [message, this.walletAddress]
|
|
44
|
+
});
|
|
45
|
+
this.logger.info(`Received signature: ${signature}`);
|
|
46
|
+
// Step 3: Complete the JWT by adding the signature
|
|
47
|
+
const jwtToken = common.completeES256KJWT({
|
|
48
|
+
message,
|
|
49
|
+
signature
|
|
50
|
+
});
|
|
51
|
+
this.logger.info(`Generated ES256K JWT: ${jwtToken}`);
|
|
52
|
+
return jwtToken;
|
|
53
|
+
}
|
|
54
|
+
async makePayment(destinations, _memo, _paymentRequestId) {
|
|
55
|
+
// Filter to polygon chain destinations
|
|
56
|
+
const polygonDestinations = destinations.filter(d => d.chain === 'polygon');
|
|
57
|
+
if (polygonDestinations.length === 0) {
|
|
58
|
+
this.logger.debug('MainWalletPaymentMaker: No polygon destinations found, cannot handle payment');
|
|
59
|
+
return null; // Cannot handle these destinations
|
|
60
|
+
}
|
|
61
|
+
// Pick first polygon destination
|
|
62
|
+
const dest = polygonDestinations[0];
|
|
63
|
+
const amount = dest.amount;
|
|
64
|
+
const currency = dest.currency;
|
|
65
|
+
const receiver = dest.address;
|
|
66
|
+
if (currency !== 'USDC') {
|
|
67
|
+
throw new Error('Only usdc currency is supported');
|
|
68
|
+
}
|
|
69
|
+
this.logger.info(`Making direct payment of ${amount} ${currency} to ${receiver} on Polygon`);
|
|
70
|
+
// Convert amount to USDC units (6 decimals)
|
|
71
|
+
const amountInUSDCUnits = BigInt(amount.multipliedBy(10 ** USDC_DECIMALS$1).toFixed(0));
|
|
72
|
+
// Encode the transfer function data
|
|
73
|
+
const transferData = viem.encodeFunctionData({
|
|
74
|
+
abi: [{
|
|
75
|
+
name: 'transfer',
|
|
76
|
+
type: 'function',
|
|
77
|
+
inputs: [
|
|
78
|
+
{ name: 'to', type: 'address' },
|
|
79
|
+
{ name: 'amount', type: 'uint256' }
|
|
80
|
+
],
|
|
81
|
+
outputs: [{ name: '', type: 'bool' }]
|
|
82
|
+
}],
|
|
83
|
+
functionName: 'transfer',
|
|
84
|
+
args: [receiver, amountInUSDCUnits]
|
|
85
|
+
});
|
|
86
|
+
// Send the transaction through the user's wallet
|
|
87
|
+
const txHash = await this.provider.request({
|
|
88
|
+
method: 'eth_sendTransaction',
|
|
89
|
+
params: [{
|
|
90
|
+
from: this.walletAddress,
|
|
91
|
+
to: this.usdcAddress,
|
|
92
|
+
data: transferData,
|
|
93
|
+
value: '0x0'
|
|
94
|
+
}]
|
|
95
|
+
});
|
|
96
|
+
this.logger.info(`Transaction submitted. TxHash: ${txHash}`);
|
|
97
|
+
// Wait for confirmations
|
|
98
|
+
const CONFIRMATIONS = 2;
|
|
99
|
+
await this.waitForTransactionConfirmations(txHash, CONFIRMATIONS);
|
|
100
|
+
// Return payment result with chain and currency
|
|
101
|
+
return {
|
|
102
|
+
transactionId: txHash,
|
|
103
|
+
chain: 'polygon',
|
|
104
|
+
currency: 'USDC'
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async waitForTransactionConfirmations(txHash, confirmations) {
|
|
108
|
+
this.logger.info(`Waiting for ${confirmations} confirmations...`);
|
|
109
|
+
// Poll for transaction receipt
|
|
110
|
+
let receipt = null;
|
|
111
|
+
while (!receipt) {
|
|
112
|
+
try {
|
|
113
|
+
receipt = await this.provider.request({
|
|
114
|
+
method: 'eth_getTransactionReceipt',
|
|
115
|
+
params: [txHash]
|
|
116
|
+
});
|
|
117
|
+
if (!receipt) {
|
|
118
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
this.logger.warn(`Error getting receipt: ${error}`);
|
|
123
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Check if transaction was successful
|
|
127
|
+
if (receipt.status === '0x0') {
|
|
128
|
+
throw new Error(`Transaction failed. TxHash: ${txHash}`);
|
|
129
|
+
}
|
|
130
|
+
// Wait for confirmations
|
|
131
|
+
const startBlock = parseInt(receipt.blockNumber, 16);
|
|
132
|
+
let currentBlock = startBlock;
|
|
133
|
+
while (currentBlock - startBlock < confirmations - 1) {
|
|
134
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
135
|
+
const blockNumber = await this.provider.request({
|
|
136
|
+
method: 'eth_blockNumber',
|
|
137
|
+
params: []
|
|
138
|
+
});
|
|
139
|
+
currentBlock = parseInt(blockNumber, 16);
|
|
140
|
+
}
|
|
141
|
+
this.logger.info(`Transaction confirmed with ${confirmations} confirmations`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Polygon browser account implementation using Direct Wallet mode.
|
|
147
|
+
*
|
|
148
|
+
* Direct Wallet mode:
|
|
149
|
+
* - User signs each transaction with their wallet
|
|
150
|
+
* - User pays gas fees in POL
|
|
151
|
+
* - No smart wallet or gasless transactions
|
|
152
|
+
*
|
|
153
|
+
* Note: Smart Wallet mode is not supported on Polygon because Coinbase CDP
|
|
154
|
+
* does not provide Paymaster services for Polygon mainnet.
|
|
155
|
+
*/
|
|
156
|
+
class PolygonBrowserAccount {
|
|
157
|
+
static async initialize(config) {
|
|
158
|
+
const logger = config.logger || new common.ConsoleLogger();
|
|
159
|
+
const chainId = config.chainId || chains.polygon.id; // Default to Polygon mainnet
|
|
160
|
+
// Warn if deprecated smart wallet parameters are provided
|
|
161
|
+
if (config.useEphemeralWallet === true) {
|
|
162
|
+
logger.warn('Smart Wallet mode (useEphemeralWallet=true) is not supported on Polygon. Using Direct Wallet mode instead.');
|
|
163
|
+
}
|
|
164
|
+
if (config.allowance !== undefined || config.periodInDays !== undefined) {
|
|
165
|
+
logger.warn('allowance and periodInDays parameters are ignored in Direct Wallet mode.');
|
|
166
|
+
}
|
|
167
|
+
if (config.coinbaseCdpApiKey !== undefined) {
|
|
168
|
+
logger.warn('coinbaseCdpApiKey parameter is ignored in Direct Wallet mode.');
|
|
169
|
+
}
|
|
170
|
+
// Some wallets don't support wallet_connect, so
|
|
171
|
+
// will just continue if it fails
|
|
172
|
+
try {
|
|
173
|
+
await config.provider.request({ method: 'wallet_connect' });
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
// Continue if wallet_connect is not supported
|
|
177
|
+
logger.warn(`wallet_connect not supported, continuing with initialization. ${error}`);
|
|
178
|
+
}
|
|
179
|
+
logger.info(`Initializing Polygon account in Direct Wallet mode for address: ${config.walletAddress}`);
|
|
180
|
+
return new PolygonBrowserAccount(config.walletAddress, config.provider, logger, chainId);
|
|
181
|
+
}
|
|
182
|
+
constructor(walletAddress, provider, logger, chainId = chains.polygon.id) {
|
|
183
|
+
this.walletAddress = walletAddress;
|
|
184
|
+
this.chainId = chainId;
|
|
185
|
+
// Format accountId as network:address
|
|
186
|
+
this.accountId = `polygon:${walletAddress}`;
|
|
187
|
+
this.paymentMakers = [
|
|
188
|
+
new DirectWalletPaymentMaker(walletAddress, provider, logger, chainId)
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
async getSources() {
|
|
192
|
+
// For Polygon, we support both mainnet (137) and Amoy testnet (80002)
|
|
193
|
+
const chain = common.ChainEnum.Polygon;
|
|
194
|
+
return [{
|
|
195
|
+
address: this.walletAddress,
|
|
196
|
+
chain,
|
|
197
|
+
walletType: common.WalletTypeEnum.EOA
|
|
198
|
+
}];
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Clear cached data (no-op in Direct Wallet mode, kept for backward compatibility)
|
|
202
|
+
* @deprecated This method is a no-op in Direct Wallet mode
|
|
203
|
+
*/
|
|
204
|
+
static clearAllCachedData(_userWalletAddress, _cache) {
|
|
205
|
+
// No-op: Direct Wallet mode doesn't cache any data
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Helper function to convert to base64url that works in both Node.js and browsers
|
|
210
|
+
function toBase64Url(data) {
|
|
211
|
+
// Convert string to base64
|
|
212
|
+
const base64 = typeof Buffer !== 'undefined'
|
|
213
|
+
? Buffer.from(data).toString('base64')
|
|
214
|
+
: btoa(data);
|
|
215
|
+
// Convert base64 to base64url
|
|
216
|
+
return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
217
|
+
}
|
|
218
|
+
const USDC_DECIMALS = 6;
|
|
219
|
+
const ERC20_ABI = [
|
|
220
|
+
{
|
|
221
|
+
constant: false,
|
|
222
|
+
inputs: [
|
|
223
|
+
{ name: "_to", type: "address" },
|
|
224
|
+
{ name: "_value", type: "uint256" },
|
|
225
|
+
],
|
|
226
|
+
name: "transfer",
|
|
227
|
+
outputs: [{ name: "", type: "bool" }],
|
|
228
|
+
type: "function",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"constant": true,
|
|
232
|
+
"inputs": [
|
|
233
|
+
{
|
|
234
|
+
"name": "_owner",
|
|
235
|
+
"type": "address"
|
|
236
|
+
}
|
|
237
|
+
],
|
|
238
|
+
"name": "balanceOf",
|
|
239
|
+
"outputs": [
|
|
240
|
+
{
|
|
241
|
+
"name": "balance",
|
|
242
|
+
"type": "uint256"
|
|
243
|
+
}
|
|
244
|
+
],
|
|
245
|
+
"payable": false,
|
|
246
|
+
"stateMutability": "view",
|
|
247
|
+
"type": "function"
|
|
248
|
+
}
|
|
249
|
+
];
|
|
250
|
+
/**
|
|
251
|
+
* Server-side Polygon payment maker for CLI/backend usage
|
|
252
|
+
* Uses direct private key signing without browser providers.
|
|
253
|
+
* Similar to BasePaymentMaker but for Polygon network.
|
|
254
|
+
*/
|
|
255
|
+
class ServerPaymentMaker {
|
|
256
|
+
constructor(polygonRPCUrl, walletClient, chainId, logger) {
|
|
257
|
+
if (!polygonRPCUrl) {
|
|
258
|
+
throw new Error('polygonRPCUrl was empty');
|
|
259
|
+
}
|
|
260
|
+
if (!walletClient) {
|
|
261
|
+
throw new Error('walletClient was empty');
|
|
262
|
+
}
|
|
263
|
+
if (!walletClient.account) {
|
|
264
|
+
throw new Error('walletClient.account was empty');
|
|
265
|
+
}
|
|
266
|
+
if (!chainId) {
|
|
267
|
+
throw new Error('chainId was empty');
|
|
268
|
+
}
|
|
269
|
+
this.signingClient = walletClient.extend(viem.publicActions);
|
|
270
|
+
this.logger = logger ?? new common.ConsoleLogger();
|
|
271
|
+
this.chainId = chainId;
|
|
272
|
+
}
|
|
273
|
+
getSourceAddress(_params) {
|
|
274
|
+
return this.signingClient.account.address;
|
|
275
|
+
}
|
|
276
|
+
async generateJWT({ paymentRequestId, codeChallenge, accountId }) {
|
|
277
|
+
const headerObj = { alg: 'ES256K' };
|
|
278
|
+
const payloadObj = {
|
|
279
|
+
sub: this.signingClient.account.address,
|
|
280
|
+
iss: 'accounts.atxp.ai',
|
|
281
|
+
aud: 'https://auth.atxp.ai',
|
|
282
|
+
iat: Math.floor(Date.now() / 1000),
|
|
283
|
+
exp: Math.floor(Date.now() / 1000) + 60 * 60,
|
|
284
|
+
...(codeChallenge ? { code_challenge: codeChallenge } : {}),
|
|
285
|
+
...(paymentRequestId ? { payment_request_id: paymentRequestId } : {}),
|
|
286
|
+
...(accountId ? { account_id: accountId } : {}),
|
|
287
|
+
};
|
|
288
|
+
const header = toBase64Url(JSON.stringify(headerObj));
|
|
289
|
+
const payload = toBase64Url(JSON.stringify(payloadObj));
|
|
290
|
+
const message = `${header}.${payload}`;
|
|
291
|
+
// Convert message to bytes
|
|
292
|
+
const messageBytes = typeof Buffer !== 'undefined'
|
|
293
|
+
? Buffer.from(message, 'utf8')
|
|
294
|
+
: new TextEncoder().encode(message);
|
|
295
|
+
// Sign the message with raw bytes
|
|
296
|
+
const signResult = await this.signingClient.signMessage({
|
|
297
|
+
account: this.signingClient.account,
|
|
298
|
+
message: { raw: messageBytes },
|
|
299
|
+
});
|
|
300
|
+
// For ES256K, signature is typically 65 bytes (r,s,v)
|
|
301
|
+
// Server expects the hex signature string (with 0x prefix) to be base64url encoded
|
|
302
|
+
// This creates: base64url("0x6eb2565...") not base64url(rawBytes)
|
|
303
|
+
// Pass the hex string directly to toBase64Url which will UTF-8 encode and base64url it
|
|
304
|
+
const signature = toBase64Url(signResult);
|
|
305
|
+
const jwt = `${header}.${payload}.${signature}`;
|
|
306
|
+
this.logger.info(`Generated ES256K JWT: ${jwt}`);
|
|
307
|
+
return jwt;
|
|
308
|
+
}
|
|
309
|
+
async makePayment(destinations, _memo, _paymentRequestId) {
|
|
310
|
+
this.logger.info(`Making payment with ${destinations.length} destination(s)`);
|
|
311
|
+
// Filter to polygon chain destinations
|
|
312
|
+
const polygonDestinations = destinations.filter(d => d.chain === 'polygon');
|
|
313
|
+
if (polygonDestinations.length === 0) {
|
|
314
|
+
this.logger.debug('SimplePolygonPaymentMaker: No polygon destinations found, cannot handle payment');
|
|
315
|
+
return null; // Cannot handle these destinations
|
|
316
|
+
}
|
|
317
|
+
// Pick first polygon destination
|
|
318
|
+
const destination = polygonDestinations[0];
|
|
319
|
+
// Validate currency
|
|
320
|
+
if (destination.currency !== 'USDC') {
|
|
321
|
+
throw new Error(`Unsupported currency: ${destination.currency}. Only USDC is supported on Polygon.`);
|
|
322
|
+
}
|
|
323
|
+
// Get USDC contract address for this chain
|
|
324
|
+
const usdcAddress = client.getPolygonUSDCAddress(this.chainId);
|
|
325
|
+
// Convert amount to smallest unit (USDC has 6 decimals)
|
|
326
|
+
const amountInSmallestUnit = destination.amount.multipliedBy(10 ** USDC_DECIMALS);
|
|
327
|
+
this.logger.info(`Transferring ${destination.amount.toString()} USDC to ${destination.address}`);
|
|
328
|
+
this.logger.info(`Amount in smallest unit: ${amountInSmallestUnit.toString()}`);
|
|
329
|
+
try {
|
|
330
|
+
// Check balance first
|
|
331
|
+
const balance = await this.signingClient.readContract({
|
|
332
|
+
address: usdcAddress,
|
|
333
|
+
abi: ERC20_ABI,
|
|
334
|
+
functionName: 'balanceOf',
|
|
335
|
+
args: [this.signingClient.account.address],
|
|
336
|
+
});
|
|
337
|
+
this.logger.info(`Current USDC balance: ${balance.toString()}`);
|
|
338
|
+
if (balance < BigInt(amountInSmallestUnit.toFixed(0))) {
|
|
339
|
+
throw new Error(`Insufficient USDC balance. Have: ${balance.toString()}, Need: ${amountInSmallestUnit.toString()}`);
|
|
340
|
+
}
|
|
341
|
+
// Encode the transfer function call
|
|
342
|
+
const data = viem.encodeFunctionData({
|
|
343
|
+
abi: ERC20_ABI,
|
|
344
|
+
functionName: 'transfer',
|
|
345
|
+
args: [destination.address, BigInt(amountInSmallestUnit.toFixed(0))],
|
|
346
|
+
});
|
|
347
|
+
// Send the transaction
|
|
348
|
+
const hash = await this.signingClient.sendTransaction({
|
|
349
|
+
account: this.signingClient.account,
|
|
350
|
+
to: usdcAddress,
|
|
351
|
+
data,
|
|
352
|
+
chain: this.signingClient.chain,
|
|
353
|
+
});
|
|
354
|
+
this.logger.info(`Transaction sent: ${hash}`);
|
|
355
|
+
// Wait for confirmation
|
|
356
|
+
const receipt = await this.signingClient.waitForTransactionReceipt({ hash });
|
|
357
|
+
if (receipt.status === 'success') {
|
|
358
|
+
this.logger.info(`Payment successful! Transaction: ${hash}`);
|
|
359
|
+
return {
|
|
360
|
+
transactionId: hash,
|
|
361
|
+
chain: 'polygon',
|
|
362
|
+
currency: 'USDC',
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
throw new Error(`Transaction failed: ${hash}`);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
this.logger.error(`Payment failed: ${error}`);
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Polygon account for server-side/CLI usage
|
|
378
|
+
*
|
|
379
|
+
* This account type works without browser providers and uses direct private key signing.
|
|
380
|
+
* It uses direct wallet signing (similar to BaseAccount) rather than ephemeral wallets
|
|
381
|
+
* and spend permissions.
|
|
382
|
+
*
|
|
383
|
+
* For browser-based applications with wallet providers, use PolygonBrowserAccount.initialize() instead.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* // Server-side usage
|
|
388
|
+
* const account = new PolygonServerAccount(
|
|
389
|
+
* 'https://polygon-rpc.com',
|
|
390
|
+
* '0x_your_private_key',
|
|
391
|
+
* 137 // Polygon mainnet
|
|
392
|
+
* );
|
|
393
|
+
* ```
|
|
394
|
+
*/
|
|
395
|
+
class PolygonServerAccount {
|
|
396
|
+
constructor(polygonRPCUrl, sourceSecretKey, chainId = 137) {
|
|
397
|
+
if (!polygonRPCUrl) {
|
|
398
|
+
throw new Error('Polygon RPC URL is required');
|
|
399
|
+
}
|
|
400
|
+
if (!sourceSecretKey) {
|
|
401
|
+
throw new Error('Source secret key is required');
|
|
402
|
+
}
|
|
403
|
+
if (!chainId) {
|
|
404
|
+
throw new Error('Chain ID is required');
|
|
405
|
+
}
|
|
406
|
+
this.chainId = chainId;
|
|
407
|
+
this.account = accounts.privateKeyToAccount(sourceSecretKey);
|
|
408
|
+
// Determine network name for accountId
|
|
409
|
+
const networkName = chainId === 137 ? 'polygon' : 'polygon_amoy';
|
|
410
|
+
this.accountId = `${networkName}:${this.account.address}`;
|
|
411
|
+
// Get the appropriate chain configuration
|
|
412
|
+
const chain = this.getChain(chainId);
|
|
413
|
+
this.walletClient = viem.createWalletClient({
|
|
414
|
+
account: this.account,
|
|
415
|
+
chain,
|
|
416
|
+
transport: viem.http(polygonRPCUrl),
|
|
417
|
+
});
|
|
418
|
+
this.paymentMakers = [
|
|
419
|
+
new ServerPaymentMaker(polygonRPCUrl, this.walletClient, chainId)
|
|
420
|
+
];
|
|
421
|
+
}
|
|
422
|
+
getChain(chainId) {
|
|
423
|
+
switch (chainId) {
|
|
424
|
+
case 137:
|
|
425
|
+
return chains.polygon;
|
|
426
|
+
case 80002:
|
|
427
|
+
return chains.polygonAmoy;
|
|
428
|
+
default:
|
|
429
|
+
throw new Error(`Unsupported Polygon chain ID: ${chainId}. Supported: 137 (mainnet), 80002 (Amoy testnet)`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Get sources for this account
|
|
434
|
+
*/
|
|
435
|
+
async getSources() {
|
|
436
|
+
// Determine chain enum value
|
|
437
|
+
const chain = this.chainId === 137 ? common.ChainEnum.Polygon : common.ChainEnum.PolygonAmoy;
|
|
438
|
+
return [{
|
|
439
|
+
address: this.account.address,
|
|
440
|
+
chain,
|
|
441
|
+
walletType: common.WalletTypeEnum.EOA
|
|
442
|
+
}];
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
Object.defineProperty(exports, "ATXPAccount", {
|
|
447
|
+
enumerable: true,
|
|
448
|
+
get: function () { return common.ATXPAccount; }
|
|
449
|
+
});
|
|
450
|
+
exports.DirectWalletPaymentMaker = DirectWalletPaymentMaker;
|
|
451
|
+
exports.MainWalletPaymentMaker = DirectWalletPaymentMaker;
|
|
452
|
+
exports.PolygonAccount = PolygonBrowserAccount;
|
|
453
|
+
exports.PolygonBrowserAccount = PolygonBrowserAccount;
|
|
454
|
+
exports.PolygonServerAccount = PolygonServerAccount;
|
|
455
|
+
exports.ServerPaymentMaker = ServerPaymentMaker;
|
|
456
|
+
exports.SimplePolygonAccount = PolygonServerAccount;
|
|
457
|
+
exports.SimplePolygonPaymentMaker = ServerPaymentMaker;
|
|
458
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/directWalletPaymentMaker.ts","../src/polygonBrowserAccount.ts","../src/serverPaymentMaker.ts","../src/polygonServerAccount.ts"],"sourcesContent":[null,null,null,null],"names":["USDC_DECIMALS","polygon","ConsoleLogger","getPolygonUSDCAddress","buildES256KJWTMessage","completeES256KJWT","encodeFunctionData","ChainEnum","WalletTypeEnum","publicActions","privateKeyToAccount","createWalletClient","http","polygonAmoy"],"mappings":";;;;;;;;AAUA,MAAMA,eAAa,GAAG,CAAC;AASvB;;;;AAIG;MACU,wBAAwB,CAAA;IAKnC,WAAA,CACU,aAAqB,EACrB,QAA4B,EACpC,MAAe,EACf,OAAA,GAAkBC,cAAO,CAAC,EAAE,EAAA;QAHpB,IAAA,CAAA,aAAa,GAAb,aAAa;QACb,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAIhB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAIC,oBAAa,EAAE;AAC3C,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO;AACtB,QAAA,IAAI,CAAC,WAAW,GAAGC,4BAAqB,CAAC,OAAO,CAAC;IACnD;AAEA,IAAA,gBAAgB,CAAC,OA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