@atxp/client 0.8.3 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atxp/client",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "description": "ATXP Client - MCP client with OAuth authentication and payment processing",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,27 +33,20 @@
33
33
  "pack:dry": "npm pack --dry-run"
34
34
  },
35
35
  "dependencies": {
36
- "@atxp/common": "0.8.3",
36
+ "@atxp/common": "0.9.0",
37
37
  "@modelcontextprotocol/sdk": "^1.15.0",
38
38
  "bignumber.js": "^9.3.0",
39
39
  "oauth4webapi": "^3.5.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@solana/pay": "^0.2.5",
43
- "@solana/web3.js": "^1.98.1",
44
- "bs58": "^6.0.0",
45
42
  "expo-crypto": ">=14.0.0",
46
- "react-native-url-polyfill": "^2.0.0",
47
- "viem": "^2.34.0"
43
+ "react-native-url-polyfill": "^2.0.0"
48
44
  },
49
45
  "devDependencies": {
50
- "@solana/pay": "^0.2.5",
51
- "@solana/web3.js": "^1.98.1",
52
46
  "@types/node": "^22.13.0",
53
47
  "@types/supertest": "^6.0.3",
54
48
  "@typescript-eslint/eslint-plugin": "^8.38.0",
55
49
  "@typescript-eslint/parser": "^8.38.0",
56
- "bs58": "^6.0.0",
57
50
  "eslint": "^9.32.0",
58
51
  "fetch-mock": "^12.5.2",
59
52
  "happy-dom": "^15.11.6",
@@ -61,7 +54,6 @@
61
54
  "react-native-url-polyfill": "^2.0.0",
62
55
  "supertest": "^7.1.4",
63
56
  "typescript": "^5.7.3",
64
- "viem": "^2.34.0",
65
57
  "vitest": "^3.0.9"
66
58
  }
67
59
  }
@@ -1,20 +0,0 @@
1
- import type { Account, PaymentMaker } from './types.js';
2
- import type { AccountId, Source } from '@atxp/common';
3
- import { LocalAccount } from 'viem';
4
- export declare class BaseAccount implements Account {
5
- accountId: AccountId;
6
- paymentMakers: PaymentMaker[];
7
- private walletClient;
8
- private account;
9
- constructor(baseRPCUrl: string, sourceSecretKey: string);
10
- /**
11
- * Get the LocalAccount (signer) for this account.
12
- * This can be used with the x402 library or other signing operations.
13
- */
14
- getLocalAccount(): LocalAccount;
15
- /**
16
- * Get sources for this account
17
- */
18
- getSources(): Promise<Source[]>;
19
- }
20
- //# sourceMappingURL=baseAccount.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseAccount.d.ts","sourceRoot":"","sources":["../src/baseAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAO,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,EAA0C,YAAY,EAAE,MAAM,MAAM,CAAC;AAG5E,qBAAa,WAAY,YAAW,OAAO;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,OAAO,CAAoB;gBAEvB,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAsBvD;;;OAGG;IACH,eAAe,IAAI,YAAY;IAI/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAOtC"}
@@ -1,46 +0,0 @@
1
- import { privateKeyToAccount } from 'viem/accounts';
2
- import { BasePaymentMaker } from './basePaymentMaker.js';
3
- import { createWalletClient, http } from 'viem';
4
- import { base } from 'viem/chains';
5
-
6
- class BaseAccount {
7
- constructor(baseRPCUrl, sourceSecretKey) {
8
- if (!baseRPCUrl) {
9
- throw new Error('Base RPC URL is required');
10
- }
11
- if (!sourceSecretKey) {
12
- throw new Error('Source secret key is required');
13
- }
14
- this.account = privateKeyToAccount(sourceSecretKey);
15
- // Format accountId as network:address
16
- this.accountId = `base:${this.account.address}`;
17
- this.walletClient = createWalletClient({
18
- account: this.account,
19
- chain: base,
20
- transport: http(baseRPCUrl),
21
- });
22
- this.paymentMakers = [
23
- new BasePaymentMaker(baseRPCUrl, this.walletClient)
24
- ];
25
- }
26
- /**
27
- * Get the LocalAccount (signer) for this account.
28
- * This can be used with the x402 library or other signing operations.
29
- */
30
- getLocalAccount() {
31
- return this.account;
32
- }
33
- /**
34
- * Get sources for this account
35
- */
36
- async getSources() {
37
- return [{
38
- address: this.account.address,
39
- chain: 'base',
40
- walletType: 'eoa'
41
- }];
42
- }
43
- }
44
-
45
- export { BaseAccount };
46
- //# sourceMappingURL=baseAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseAccount.js","sources":["../src/baseAccount.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;MAOa,WAAW,CAAA;IAMtB,WAAA,CAAY,UAAkB,EAAE,eAAuB,EAAA;QACrD,IAAI,CAAC,UAAU,EAAE;AACf,YAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC;QAC7C;QACA,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;QAClD;AAEA,QAAA,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,eAAsB,CAAC;;QAG1D,IAAI,CAAC,SAAS,GAAG,CAAA,KAAA,EAAQ,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA,CAAe;AAC5D,QAAA,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,YAAA,KAAK,EAAE,IAAI;AACX,YAAA,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC;AAC5B,SAAA,CAAC;QACF,IAAI,CAAC,aAAa,GAAG;AACnB,YAAA,IAAI,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY;SACnD;IACH;AAEA;;;AAGG;IACH,eAAe,GAAA;QACb,OAAO,IAAI,CAAC,OAAO;IACrB;AAEA;;AAEG;AACH,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,OAAO,CAAC;AACN,gBAAA,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;AAC7B,gBAAA,KAAK,EAAE,MAAM;AACb,gBAAA,UAAU,EAAE;AACb,aAAA,CAAC;IACJ;AACD;;;;"}
@@ -1,10 +0,0 @@
1
- export declare const USDC_CONTRACT_ADDRESS_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
2
- export declare const USDC_CONTRACT_ADDRESS_BASE_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
3
- /**
4
- * Get USDC contract address for Base chain by chain ID
5
- * @param chainId - Chain ID (8453 for mainnet, 84532 for sepolia)
6
- * @returns USDC contract address
7
- * @throws Error if chain ID is not supported
8
- */
9
- export declare const getBaseUSDCAddress: (chainId: number) => string;
10
- //# sourceMappingURL=baseConstants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseConstants.d.ts","sourceRoot":"","sources":["../src/baseConstants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B,+CAA+C,CAAC;AACvF,eAAO,MAAM,kCAAkC,+CAA+C,CAAC;AAE/F;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG,MASpD,CAAC"}
@@ -1,21 +0,0 @@
1
- const USDC_CONTRACT_ADDRESS_BASE = "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; // USDC on Base mainnet
2
- const USDC_CONTRACT_ADDRESS_BASE_SEPOLIA = "0x036CbD53842c5426634e7929541eC2318f3dCF7e"; // USDC on Base Sepolia testnet
3
- /**
4
- * Get USDC contract address for Base chain by chain ID
5
- * @param chainId - Chain ID (8453 for mainnet, 84532 for sepolia)
6
- * @returns USDC contract address
7
- * @throws Error if chain ID is not supported
8
- */
9
- const getBaseUSDCAddress = (chainId) => {
10
- switch (chainId) {
11
- case 8453: // Base mainnet
12
- return USDC_CONTRACT_ADDRESS_BASE;
13
- case 84532: // Base Sepolia
14
- return USDC_CONTRACT_ADDRESS_BASE_SEPOLIA;
15
- default:
16
- throw new Error(`Unsupported Base Chain ID: ${chainId}. Supported chains: 8453 (mainnet), 84532 (sepolia)`);
17
- }
18
- };
19
-
20
- export { USDC_CONTRACT_ADDRESS_BASE, USDC_CONTRACT_ADDRESS_BASE_SEPOLIA, getBaseUSDCAddress };
21
- //# sourceMappingURL=baseConstants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseConstants.js","sources":["../src/baseConstants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,MAAM,0BAA0B,GAAG,6CAA6C;AAChF,MAAM,kCAAkC,GAAG,6CAA6C;AAE/F;;;;;AAKG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAAe,KAAY;IAC5D,QAAQ,OAAO;QACb,KAAK,IAAI;AACP,YAAA,OAAO,0BAA0B;QACnC,KAAK,KAAK;AACR,YAAA,OAAO,kCAAkC;AAC3C,QAAA;AACE,YAAA,MAAM,IAAI,KAAK,CAAC,8BAA8B,OAAO,CAAA,mDAAA,CAAqD,CAAC;;AAEjH;;;;"}
@@ -1,23 +0,0 @@
1
- import type { PaymentMaker } from './types.js';
2
- import { Logger, Currency, AccountId, PaymentIdentifier, Destination } from '@atxp/common';
3
- import { WalletClient, PublicActions } from "viem";
4
- type ExtendedWalletClient = WalletClient & PublicActions;
5
- export declare class BasePaymentMaker implements PaymentMaker {
6
- protected signingClient: ExtendedWalletClient;
7
- protected logger: Logger;
8
- constructor(baseRPCUrl: string, walletClient: WalletClient, logger?: Logger);
9
- getSourceAddress(_params: {
10
- amount: BigNumber;
11
- currency: Currency;
12
- receiver: string;
13
- memo: string;
14
- }): string;
15
- generateJWT({ paymentRequestId, codeChallenge, accountId }: {
16
- paymentRequestId: string;
17
- codeChallenge: string;
18
- accountId?: AccountId | null;
19
- }): Promise<string>;
20
- makePayment(destinations: Destination[], _memo: string, _paymentRequestId?: string): Promise<PaymentIdentifier | null>;
21
- }
22
- export {};
23
- //# sourceMappingURL=basePaymentMaker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basePaymentMaker.d.ts","sourceRoot":"","sources":["../src/basePaymentMaker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAO,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAKL,YAAY,EACZ,aAAa,EACd,MAAM,MAAM,CAAC;AAMd,KAAK,oBAAoB,GAAG,YAAY,GAAG,aAAa,CAAC;AA6CzD,qBAAa,gBAAiB,YAAW,YAAY;IACnD,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAC9C,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEb,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,MAAM;IAe3E,gBAAgB,CAAC,OAAO,EAAE;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM;IAIpG,WAAW,CAAC,EAAC,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAC,EAAE;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;KAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAsC3J,WAAW,CAAC,YAAY,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;CAmF7H"}
@@ -1,169 +0,0 @@
1
- import { PaymentNetworkError, InsufficientFundsError } from './types.js';
2
- import { ConsoleLogger } from '@atxp/common';
3
- import { publicActions, encodeFunctionData, parseEther } from 'viem';
4
- import { base } from 'viem/chains';
5
- import { BigNumber } from 'bignumber.js';
6
- import { USDC_CONTRACT_ADDRESS_BASE } from './baseConstants.js';
7
-
8
- // Helper function to convert to base64url that works in both Node.js and browsers
9
- function toBase64Url(data) {
10
- // Convert string to base64
11
- const base64 = typeof Buffer !== 'undefined'
12
- ? Buffer.from(data).toString('base64')
13
- : btoa(data);
14
- // Convert base64 to base64url
15
- return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
16
- }
17
- const USDC_DECIMALS = 6;
18
- const ERC20_ABI = [
19
- {
20
- constant: false,
21
- inputs: [
22
- { name: "_to", type: "address" },
23
- { name: "_value", type: "uint256" },
24
- ],
25
- name: "transfer",
26
- outputs: [{ name: "", type: "bool" }],
27
- type: "function",
28
- },
29
- {
30
- "constant": true,
31
- "inputs": [
32
- {
33
- "name": "_owner",
34
- "type": "address"
35
- }
36
- ],
37
- "name": "balanceOf",
38
- "outputs": [
39
- {
40
- "name": "balance",
41
- "type": "uint256"
42
- }
43
- ],
44
- "payable": false,
45
- "stateMutability": "view",
46
- "type": "function"
47
- }
48
- ];
49
- class BasePaymentMaker {
50
- constructor(baseRPCUrl, walletClient, logger) {
51
- if (!baseRPCUrl) {
52
- throw new Error('baseRPCUrl was empty');
53
- }
54
- if (!walletClient) {
55
- throw new Error('walletClient was empty');
56
- }
57
- if (!walletClient.account) {
58
- throw new Error('walletClient.account was empty');
59
- }
60
- this.signingClient = walletClient.extend(publicActions);
61
- this.logger = logger ?? new ConsoleLogger();
62
- }
63
- getSourceAddress(_params) {
64
- return this.signingClient.account.address;
65
- }
66
- async generateJWT({ paymentRequestId, codeChallenge, accountId }) {
67
- const headerObj = { alg: 'ES256K' };
68
- const payloadObj = {
69
- sub: this.signingClient.account.address,
70
- iss: 'accounts.atxp.ai',
71
- aud: 'https://auth.atxp.ai',
72
- iat: Math.floor(Date.now() / 1000),
73
- exp: Math.floor(Date.now() / 1000) + 60 * 60,
74
- ...(codeChallenge ? { code_challenge: codeChallenge } : {}),
75
- ...(paymentRequestId ? { payment_request_id: paymentRequestId } : {}),
76
- ...(accountId ? { account_id: accountId } : {}),
77
- };
78
- const header = toBase64Url(JSON.stringify(headerObj));
79
- const payload = toBase64Url(JSON.stringify(payloadObj));
80
- const message = `${header}.${payload}`;
81
- const messageBytes = typeof Buffer !== 'undefined'
82
- ? Buffer.from(message, 'utf8')
83
- : new TextEncoder().encode(message);
84
- const signResult = await this.signingClient.signMessage({
85
- account: this.signingClient.account,
86
- message: { raw: messageBytes },
87
- });
88
- // For ES256K, signature is typically 65 bytes (r,s,v)
89
- // Server expects the hex signature string (with 0x prefix) to be base64url encoded
90
- // This creates: base64url("0x6eb2565...") not base64url(rawBytes)
91
- // Pass the hex string directly to toBase64Url which will UTF-8 encode and base64url it
92
- const signature = toBase64Url(signResult);
93
- const jwt = `${header}.${payload}.${signature}`;
94
- this.logger.info(`Generated ES256K JWT: ${jwt}`);
95
- return jwt;
96
- }
97
- async makePayment(destinations, _memo, _paymentRequestId) {
98
- // Filter to base chain destinations
99
- const baseDestinations = destinations.filter(d => d.chain === 'base');
100
- if (baseDestinations.length === 0) {
101
- this.logger.debug('BasePaymentMaker: No base destinations found, cannot handle payment');
102
- return null; // Cannot handle these destinations
103
- }
104
- // Pick first base destination
105
- const dest = baseDestinations[0];
106
- const amount = dest.amount;
107
- const currency = dest.currency;
108
- const receiver = dest.address;
109
- if (currency.toUpperCase() !== 'USDC') {
110
- throw new PaymentNetworkError('Only USDC currency is supported; received ' + currency);
111
- }
112
- this.logger.info(`Making payment of ${amount} ${currency} to ${receiver} on Base from ${this.signingClient.account.address}`);
113
- try {
114
- // Check balance before attempting payment
115
- const balanceRaw = await this.signingClient.readContract({
116
- address: USDC_CONTRACT_ADDRESS_BASE,
117
- abi: ERC20_ABI,
118
- functionName: 'balanceOf',
119
- args: [this.signingClient.account.address],
120
- });
121
- const balance = new BigNumber(balanceRaw.toString()).dividedBy(10 ** USDC_DECIMALS);
122
- if (balance.lt(amount)) {
123
- this.logger.warn(`Insufficient ${currency} balance for payment. Required: ${amount}, Available: ${balance}`);
124
- throw new InsufficientFundsError(currency, amount, balance, 'base');
125
- }
126
- // Convert amount to USDC units (6 decimals) as BigInt
127
- const amountInUSDCUnits = BigInt(amount.multipliedBy(10 ** USDC_DECIMALS).toFixed(0));
128
- const data = encodeFunctionData({
129
- abi: ERC20_ABI,
130
- functionName: "transfer",
131
- args: [receiver, amountInUSDCUnits],
132
- });
133
- const hash = await this.signingClient.sendTransaction({
134
- chain: base,
135
- account: this.signingClient.account,
136
- to: USDC_CONTRACT_ADDRESS_BASE,
137
- data: data,
138
- value: parseEther('0'),
139
- maxPriorityFeePerGas: parseEther('0.000000001')
140
- });
141
- // Wait for transaction confirmation with more blocks to ensure propagation
142
- this.logger.info(`Waiting for transaction confirmation: ${hash}`);
143
- const receipt = await this.signingClient.waitForTransactionReceipt({
144
- hash: hash,
145
- confirmations: 1
146
- });
147
- if (receipt.status === 'reverted') {
148
- throw new PaymentNetworkError(`Transaction reverted: ${hash}`, new Error('Transaction reverted on chain'));
149
- }
150
- this.logger.info(`Transaction confirmed: ${hash} in block ${receipt.blockNumber}`);
151
- // Return payment result with chain and currency
152
- return {
153
- transactionId: hash,
154
- chain: 'base',
155
- currency: 'USDC'
156
- };
157
- }
158
- catch (error) {
159
- if (error instanceof InsufficientFundsError || error instanceof PaymentNetworkError) {
160
- throw error;
161
- }
162
- // Wrap other errors in PaymentNetworkError
163
- throw new PaymentNetworkError(`Payment failed on Base network: ${error.message}`, error);
164
- }
165
- }
166
- }
167
-
168
- export { BasePaymentMaker };
169
- //# sourceMappingURL=basePaymentMaker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"basePaymentMaker.js","sources":["../src/basePaymentMaker.ts"],"sourcesContent":[null],"names":["PaymentNetworkErrorClass","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a,EAAE,IAAI;AACnB,gBAAA,KAAK,EAAE,MAAM;AACb,gBAAA,QAAQ,EAAE;aACX;QACH;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,KAAK,YAAYC,sBAA2B,IAAI,KAAK,YAAYD,mBAAwB,EAAE;AAC7F,gBAAA,MAAM,KAAK;YACb;;YAGA,MAAM,IAAIA,mBAAwB,CAAC,CAAA,gCAAA,EAAoC,KAAe,CAAC,OAAO,CAAA,CAAE,EAAE,KAAc,CAAC;QACnH;IACF;AAED;;;;"}
@@ -1,13 +0,0 @@
1
- import type { Account, PaymentMaker } from './types.js';
2
- import type { AccountId, Source } from '@atxp/common';
3
- export declare class SolanaAccount implements Account {
4
- accountId: AccountId;
5
- paymentMakers: PaymentMaker[];
6
- private sourcePublicKey;
7
- constructor(solanaEndpoint: string, sourceSecretKey: string);
8
- /**
9
- * Get sources for this account
10
- */
11
- getSources(): Promise<Source[]>;
12
- }
13
- //# sourceMappingURL=solanaAccount.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solanaAccount.d.ts","sourceRoot":"","sources":["../src/solanaAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtD,qBAAa,aAAc,YAAW,OAAO;IAC3C,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,CAAC,eAAe,CAAS;gBAEpB,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAiB3D;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAOtC"}
@@ -1,34 +0,0 @@
1
- import { SolanaPaymentMaker } from './solanaPaymentMaker.js';
2
- import { Keypair } from '@solana/web3.js';
3
- import bs58 from 'bs58';
4
-
5
- class SolanaAccount {
6
- constructor(solanaEndpoint, sourceSecretKey) {
7
- if (!solanaEndpoint) {
8
- throw new Error('Solana endpoint is required');
9
- }
10
- if (!sourceSecretKey) {
11
- throw new Error('Source secret key is required');
12
- }
13
- const source = Keypair.fromSecretKey(bs58.decode(sourceSecretKey));
14
- this.sourcePublicKey = source.publicKey.toBase58();
15
- // Format accountId as network:address
16
- this.accountId = `solana:${this.sourcePublicKey}`;
17
- this.paymentMakers = [
18
- new SolanaPaymentMaker(solanaEndpoint, sourceSecretKey)
19
- ];
20
- }
21
- /**
22
- * Get sources for this account
23
- */
24
- async getSources() {
25
- return [{
26
- address: this.sourcePublicKey,
27
- chain: 'solana',
28
- walletType: 'eoa'
29
- }];
30
- }
31
- }
32
-
33
- export { SolanaAccount };
34
- //# sourceMappingURL=solanaAccount.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solanaAccount.js","sources":["../src/solanaAccount.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;MAMa,aAAa,CAAA;IAKxB,WAAA,CAAY,cAAsB,EAAE,eAAuB,EAAA;QACzD,IAAI,CAAC,cAAc,EAAE;AACnB,YAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;QAChD;QACA,IAAI,CAAC,eAAe,EAAE;AACpB,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;QAClD;AACA,QAAA,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAClE,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;;QAGlD,IAAI,CAAC,SAAS,GAAG,CAAA,OAAA,EAAU,IAAI,CAAC,eAAe,EAAe;QAC9D,IAAI,CAAC,aAAa,GAAG;AACnB,YAAA,IAAI,kBAAkB,CAAC,cAAc,EAAE,eAAe;SACvD;IACH;AAEA;;AAEG;AACH,IAAA,MAAM,UAAU,GAAA;AACd,QAAA,OAAO,CAAC;gBACN,OAAO,EAAE,IAAI,CAAC,eAAe;AAC7B,gBAAA,KAAK,EAAE,QAAQ;AACf,gBAAA,UAAU,EAAE;AACb,aAAA,CAAC;IACJ;AACD;;;;"}
@@ -1,25 +0,0 @@
1
- import type { PaymentMaker } from './types.js';
2
- import { ValidateTransferError as _ValidateTransferError } from "@solana/pay";
3
- import BigNumber from "bignumber.js";
4
- import { Currency, AccountId, PaymentIdentifier, Destination } from '@atxp/common';
5
- import { Logger } from '@atxp/common';
6
- export declare const ValidateTransferError: typeof _ValidateTransferError;
7
- export declare class SolanaPaymentMaker implements PaymentMaker {
8
- private connection;
9
- private source;
10
- private logger;
11
- constructor(solanaEndpoint: string, sourceSecretKey: string, logger?: Logger);
12
- getSourceAddress(_params: {
13
- amount: BigNumber;
14
- currency: Currency;
15
- receiver: string;
16
- memo: string;
17
- }): string;
18
- generateJWT: ({ paymentRequestId, codeChallenge, accountId }: {
19
- paymentRequestId: string;
20
- codeChallenge: string;
21
- accountId?: AccountId | null;
22
- }) => Promise<string>;
23
- makePayment: (destinations: Destination[], memo: string, _paymentRequestId?: string) => Promise<PaymentIdentifier | null>;
24
- }
25
- //# sourceMappingURL=solanaPaymentMaker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solanaPaymentMaker.d.ts","sourceRoot":"","sources":["../src/solanaPaymentMaker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAkB,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG9F,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAe,QAAQ,EAAE,SAAS,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhG,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAMtC,eAAO,MAAM,qBAAqB,+BAAyB,CAAC;AAE5D,qBAAa,kBAAmB,YAAW,YAAY;IACrD,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,MAAM,CAAS;gBAEX,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAY5E,gBAAgB,CAAC,OAAO,EAAE;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM;IAI1G,WAAW,GAAS,gDAA8C;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAA;KAAC,KAAG,OAAO,CAAC,MAAM,CAAC,CAelK;IAED,WAAW,GAAU,cAAc,WAAW,EAAE,EAAE,MAAM,MAAM,EAAE,oBAAoB,MAAM,KAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAyF7H;CACF"}
@@ -1,108 +0,0 @@
1
- import { PaymentNetworkError, InsufficientFundsError } from './types.js';
2
- import { PublicKey, ComputeBudgetProgram, sendAndConfirmTransaction, Connection, Keypair } from '@solana/web3.js';
3
- import { ValidateTransferError as ValidateTransferError$1, createTransfer } from '@solana/pay';
4
- import { getAssociatedTokenAddress, getAccount } from '@solana/spl-token';
5
- import bs58 from 'bs58';
6
- import BigNumber from 'bignumber.js';
7
- import { generateJWT, ConsoleLogger } from '@atxp/common';
8
- import { importJWK } from 'jose';
9
-
10
- // this is a global public key for USDC on the solana mainnet
11
- const USDC_MINT = new PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
12
- const ValidateTransferError = ValidateTransferError$1;
13
- class SolanaPaymentMaker {
14
- constructor(solanaEndpoint, sourceSecretKey, logger) {
15
- this.generateJWT = async ({ paymentRequestId, codeChallenge, accountId }) => {
16
- // Solana/Web3.js secretKey is 64 bytes:
17
- // first 32 bytes are the private scalar, last 32 are the public key.
18
- // JWK expects only the 32-byte private scalar for 'd'
19
- const jwk = {
20
- kty: 'OKP',
21
- crv: 'Ed25519',
22
- d: Buffer.from(this.source.secretKey.slice(0, 32)).toString('base64url'),
23
- x: Buffer.from(this.source.publicKey.toBytes()).toString('base64url'),
24
- };
25
- const privateKey = await importJWK(jwk, 'EdDSA');
26
- if (!(privateKey instanceof CryptoKey)) {
27
- throw new Error('Expected CryptoKey from importJWK');
28
- }
29
- return generateJWT(this.source.publicKey.toBase58(), privateKey, paymentRequestId || '', codeChallenge || '', accountId);
30
- };
31
- this.makePayment = async (destinations, memo, _paymentRequestId) => {
32
- // Filter to solana chain destinations
33
- const solanaDestinations = destinations.filter(d => d.chain === 'solana');
34
- if (solanaDestinations.length === 0) {
35
- this.logger.debug('SolanaPaymentMaker: No solana destinations found, cannot handle payment');
36
- return null; // Cannot handle these destinations
37
- }
38
- // Pick first solana destination
39
- const dest = solanaDestinations[0];
40
- const amount = dest.amount;
41
- const currency = dest.currency;
42
- const receiver = dest.address;
43
- if (currency.toUpperCase() !== 'USDC') {
44
- throw new PaymentNetworkError('Only USDC currency is supported; received ' + currency);
45
- }
46
- const receiverKey = new PublicKey(receiver);
47
- this.logger.info(`Making payment of ${amount} ${currency} to ${receiver} on Solana from ${this.source.publicKey.toBase58()}`);
48
- try {
49
- // Check balance before attempting payment
50
- const tokenAccountAddress = await getAssociatedTokenAddress(USDC_MINT, this.source.publicKey);
51
- const tokenAccount = await getAccount(this.connection, tokenAccountAddress);
52
- const balance = new BigNumber(tokenAccount.amount.toString()).dividedBy(10 ** 6); // USDC has 6 decimals
53
- if (balance.lt(amount)) {
54
- this.logger.warn(`Insufficient ${currency} balance for payment. Required: ${amount}, Available: ${balance}`);
55
- throw new InsufficientFundsError(currency, amount, balance, 'solana');
56
- }
57
- // Get the destination token account address (this will be the transactionId)
58
- const destinationTokenAccount = await getAssociatedTokenAddress(USDC_MINT, receiverKey);
59
- // Increase compute units to handle both memo and token transfer
60
- // Memo uses ~6000 CUs, token transfer needs ~6500 CUs
61
- const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
62
- units: 50000,
63
- });
64
- const addPriorityFee = ComputeBudgetProgram.setComputeUnitPrice({
65
- microLamports: 20000,
66
- });
67
- const transaction = await createTransfer(this.connection, this.source.publicKey, {
68
- amount: amount,
69
- recipient: receiverKey,
70
- splToken: USDC_MINT,
71
- memo,
72
- });
73
- transaction.add(modifyComputeUnits);
74
- transaction.add(addPriorityFee);
75
- const transactionSignature = await sendAndConfirmTransaction(this.connection, transaction, [this.source]);
76
- // Return transaction signature as transactionId and token account address as transactionSubId
77
- return {
78
- transactionId: transactionSignature,
79
- transactionSubId: destinationTokenAccount.toBase58(),
80
- chain: 'solana',
81
- currency: 'USDC'
82
- };
83
- }
84
- catch (error) {
85
- if (error instanceof InsufficientFundsError || error instanceof PaymentNetworkError) {
86
- throw error;
87
- }
88
- // Wrap other errors in PaymentNetworkError
89
- throw new PaymentNetworkError(`Payment failed on Solana network: ${error.message}`, error);
90
- }
91
- };
92
- if (!solanaEndpoint) {
93
- throw new Error('Solana endpoint is required');
94
- }
95
- if (!sourceSecretKey) {
96
- throw new Error('Source secret key is required');
97
- }
98
- this.connection = new Connection(solanaEndpoint, { commitment: 'confirmed' });
99
- this.source = Keypair.fromSecretKey(bs58.decode(sourceSecretKey));
100
- this.logger = logger ?? new ConsoleLogger();
101
- }
102
- getSourceAddress(_params) {
103
- return this.source.publicKey.toBase58();
104
- }
105
- }
106
-
107
- export { SolanaPaymentMaker, ValidateTransferError };
108
- //# sourceMappingURL=solanaPaymentMaker.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"solanaPaymentMaker.js","sources":["../src/solanaPaymentMaker.ts"],"sourcesContent":[null],"names":["_ValidateTransferError"],"mappings":";;;;;;;;;AAYA;AACA,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,8CAA8C,CAAC;AAExE,MAAM,qBAAqB,GAAGA;MAExB,kBAAkB,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