agentwallet-sdk 2.4.1 → 3.0.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 +264 -19
- package/dist/bridge/client.d.ts +17 -49
- package/dist/bridge/client.d.ts.map +1 -1
- package/dist/bridge/client.js +94 -124
- package/dist/bridge/client.js.map +1 -1
- package/dist/bridge/index.d.ts +4 -2
- package/dist/bridge/index.d.ts.map +1 -1
- package/dist/bridge/index.js +8 -2
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/types.d.ts +100 -19
- package/dist/bridge/types.d.ts.map +1 -1
- package/dist/bridge/types.js +167 -18
- package/dist/bridge/types.js.map +1 -1
- package/dist/bridge/unified.d.ts +101 -0
- package/dist/bridge/unified.d.ts.map +1 -0
- package/dist/bridge/unified.js +284 -0
- package/dist/bridge/unified.js.map +1 -0
- package/dist/chains.d.ts +62 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +108 -0
- package/dist/chains.js.map +1 -0
- package/dist/index.d.ts +15 -506
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/solana/bridge.d.ts +144 -0
- package/dist/solana/bridge.d.ts.map +1 -0
- package/dist/solana/bridge.js +352 -0
- package/dist/solana/bridge.js.map +1 -0
- package/dist/solana/index.d.ts +8 -0
- package/dist/solana/index.d.ts.map +1 -0
- package/dist/solana/index.js +6 -0
- package/dist/solana/index.js.map +1 -0
- package/dist/solana/swap.d.ts +85 -0
- package/dist/solana/swap.d.ts.map +1 -0
- package/dist/solana/swap.js +173 -0
- package/dist/solana/swap.js.map +1 -0
- package/dist/solana/types.d.ts +126 -0
- package/dist/solana/types.d.ts.map +1 -0
- package/dist/solana/types.js +10 -0
- package/dist/solana/types.js.map +1 -0
- package/dist/solana/wallet.d.ts +83 -0
- package/dist/solana/wallet.d.ts.map +1 -0
- package/dist/solana/wallet.js +164 -0
- package/dist/solana/wallet.js.map +1 -0
- package/dist/solana/x402.d.ts +69 -0
- package/dist/solana/x402.d.ts.map +1 -0
- package/dist/solana/x402.js +154 -0
- package/dist/solana/x402.js.map +1 -0
- package/dist/swap/SwapModule.d.ts +4 -1
- package/dist/swap/SwapModule.d.ts.map +1 -1
- package/dist/swap/SwapModule.js +7 -2
- package/dist/swap/SwapModule.js.map +1 -1
- package/dist/swap/types.d.ts +4 -2
- package/dist/swap/types.d.ts.map +1 -1
- package/dist/swap/types.js.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/x402/index.d.ts +1 -1
- package/dist/x402/index.d.ts.map +1 -1
- package/dist/x402/index.js +1 -1
- package/dist/x402/index.js.map +1 -1
- package/dist/x402/types.d.ts +5 -3
- package/dist/x402/types.d.ts.map +1 -1
- package/dist/x402/types.js +17 -2
- package/dist/x402/types.js.map +1 -1
- package/package.json +30 -10
- package/dist/bridge/__tests__/bridge.test.d.ts +0 -2
- package/dist/bridge/__tests__/bridge.test.d.ts.map +0 -1
- package/dist/bridge/__tests__/bridge.test.js +0 -508
- package/dist/bridge/__tests__/bridge.test.js.map +0 -1
- package/dist/swap/__tests__/swap.test.d.ts +0 -2
- package/dist/swap/__tests__/swap.test.d.ts.map +0 -1
- package/dist/swap/__tests__/swap.test.js +0 -272
- package/dist/swap/__tests__/swap.test.js.map +0 -1
- package/dist/x402/__tests__/budget.test.d.ts +0 -2
- package/dist/x402/__tests__/budget.test.d.ts.map +0 -1
- package/dist/x402/__tests__/budget.test.js +0 -114
- package/dist/x402/__tests__/budget.test.js.map +0 -1
- package/dist/x402/__tests__/client.test.d.ts +0 -2
- package/dist/x402/__tests__/client.test.d.ts.map +0 -1
- package/dist/x402/__tests__/client.test.js +0 -107
- package/dist/x402/__tests__/client.test.js.map +0 -1
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
// [MAX-ADDED] UnifiedBridge — Single interface for CCTP V2 transfers across all 17 chains
|
|
2
|
+
// Routes EVM↔EVM, EVM→Solana, and Solana→EVM via BridgeModule + SolanaCCTPBridge.
|
|
3
|
+
//
|
|
4
|
+
// Supported: 16 EVM chains + Solana (17 total)
|
|
5
|
+
// Fee: 0.1% platform fee on bridged amount
|
|
6
|
+
//
|
|
7
|
+
// Usage:
|
|
8
|
+
// const bridge = new UnifiedBridge({ evmSigner: walletClient, solanaWallet: keypair });
|
|
9
|
+
// await bridge.bridge({ amount: 1_000_000n, sourceChain: 'base', destinationChain: 'polygon', destinationAddress: '0x...' });
|
|
10
|
+
import { Connection } from '@solana/web3.js';
|
|
11
|
+
import { BridgeModule, BridgeError } from './client.js';
|
|
12
|
+
import { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, getEstimatedBridgeSeconds, FAST_TRANSFER_CHAINS, } from './types.js';
|
|
13
|
+
import { SolanaCCTPBridge, SolanaBridgeError } from '../solana/bridge.js';
|
|
14
|
+
// ─── UnifiedBridge ───
|
|
15
|
+
/**
|
|
16
|
+
* UnifiedBridge — Cross-chain USDC bridge across all 17 CCTP V2 supported chains.
|
|
17
|
+
*
|
|
18
|
+
* Routing:
|
|
19
|
+
* - EVM → EVM: BridgeModule (approve → burn → attest → mint)
|
|
20
|
+
* - EVM → Solana: BridgeModule burn + SolanaCCTPBridge receive
|
|
21
|
+
* - Solana → EVM: SolanaCCTPBridge burn + EVM receiveMessage
|
|
22
|
+
* - Solana → Solana: throws (use native Solana transfer instead)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { UnifiedBridge } from 'agentwallet-sdk';
|
|
27
|
+
* import { createWalletClient } from 'viem';
|
|
28
|
+
*
|
|
29
|
+
* const bridge = new UnifiedBridge({ evmSigner });
|
|
30
|
+
*
|
|
31
|
+
* // Bridge 1 USDC from Base to Polygon
|
|
32
|
+
* const result = await bridge.bridge({
|
|
33
|
+
* amount: 1_000_000n,
|
|
34
|
+
* sourceChain: 'base',
|
|
35
|
+
* destinationChain: 'polygon',
|
|
36
|
+
* destinationAddress: '0x...',
|
|
37
|
+
* });
|
|
38
|
+
* console.log(bridge.getSupportedChains()); // 17 chains!
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export class UnifiedBridge {
|
|
42
|
+
constructor(config = {}) {
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.solanaConnection = new Connection(config.solanaRpcUrl ?? 'https://api.mainnet-beta.solana.com', 'confirmed');
|
|
45
|
+
}
|
|
46
|
+
// ─── Public API ───
|
|
47
|
+
/**
|
|
48
|
+
* Bridge USDC between any two CCTP V2 supported chains.
|
|
49
|
+
* Routes automatically based on source/destination chain types.
|
|
50
|
+
*/
|
|
51
|
+
async bridge(params) {
|
|
52
|
+
const { amount, sourceChain, destinationChain, destinationAddress, minFinalityThreshold = 0, applyPlatformFee = true, destinationRpcUrl, } = params;
|
|
53
|
+
// Validate before routing (catches unsupported chains, zero amount)
|
|
54
|
+
// Check Solana→Solana before generic same-chain to give the right error code
|
|
55
|
+
const isSolanaSource = sourceChain === 'solana';
|
|
56
|
+
const isSolanaDestination = destinationChain === 'solana';
|
|
57
|
+
if (isSolanaSource && isSolanaDestination) {
|
|
58
|
+
throw new BridgeError('UNSUPPORTED_ROUTE', 'Solana → Solana bridging is not supported. Use native Solana transfers instead.');
|
|
59
|
+
}
|
|
60
|
+
this.validateParams(amount, sourceChain, destinationChain);
|
|
61
|
+
if (!isSolanaSource && !isSolanaDestination) {
|
|
62
|
+
// EVM → EVM
|
|
63
|
+
return this.bridgeEvmToEvm({
|
|
64
|
+
amount,
|
|
65
|
+
sourceChain: sourceChain,
|
|
66
|
+
destinationChain: destinationChain,
|
|
67
|
+
destinationAddress,
|
|
68
|
+
minFinalityThreshold,
|
|
69
|
+
applyPlatformFee,
|
|
70
|
+
destinationRpcUrl,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (isSolanaSource && !isSolanaDestination) {
|
|
74
|
+
// Solana → EVM
|
|
75
|
+
return this.bridgeSolanaToEvm({
|
|
76
|
+
amount,
|
|
77
|
+
destinationChain: destinationChain,
|
|
78
|
+
destinationAddress,
|
|
79
|
+
minFinalityThreshold,
|
|
80
|
+
applyPlatformFee,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// EVM → Solana
|
|
84
|
+
return this.bridgeEvmToSolana({
|
|
85
|
+
amount,
|
|
86
|
+
sourceChain: sourceChain,
|
|
87
|
+
destinationAddress,
|
|
88
|
+
minFinalityThreshold,
|
|
89
|
+
applyPlatformFee,
|
|
90
|
+
destinationRpcUrl,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all supported chains (16 EVM + Solana = 17 total).
|
|
95
|
+
*/
|
|
96
|
+
getSupportedChains() {
|
|
97
|
+
return Object.keys(CCTP_DOMAIN_IDS);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get a bridge quote: fee breakdown + estimated time.
|
|
101
|
+
*/
|
|
102
|
+
getQuote(params) {
|
|
103
|
+
const { amount, sourceChain, destinationChain } = params;
|
|
104
|
+
if (amount <= 0n) {
|
|
105
|
+
throw new BridgeError('INVALID_AMOUNT', 'Quote amount must be > 0');
|
|
106
|
+
}
|
|
107
|
+
const platformFee = calcBridgeFee(amount);
|
|
108
|
+
const outputAmount = amount - platformFee;
|
|
109
|
+
const estimatedTimeSeconds = getEstimatedBridgeSeconds(sourceChain);
|
|
110
|
+
const fastTransferAvailable = FAST_TRANSFER_CHAINS.has(sourceChain);
|
|
111
|
+
return {
|
|
112
|
+
inputAmount: amount,
|
|
113
|
+
platformFee,
|
|
114
|
+
outputAmount,
|
|
115
|
+
fromChain: sourceChain,
|
|
116
|
+
toChain: destinationChain,
|
|
117
|
+
estimatedTimeSeconds,
|
|
118
|
+
fastTransferAvailable,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Check if a route is supported.
|
|
123
|
+
*/
|
|
124
|
+
isRouteSupported(source, destination) {
|
|
125
|
+
if (source === destination)
|
|
126
|
+
return false;
|
|
127
|
+
if (source === 'solana' && destination === 'solana')
|
|
128
|
+
return false;
|
|
129
|
+
return source in CCTP_DOMAIN_IDS && destination in CCTP_DOMAIN_IDS;
|
|
130
|
+
}
|
|
131
|
+
// ─── Internal Routing ───
|
|
132
|
+
async bridgeEvmToEvm(params) {
|
|
133
|
+
const { sourceChain, destinationChain } = params;
|
|
134
|
+
if (!this.config.evmSigner) {
|
|
135
|
+
throw new BridgeError('NO_WALLET_CLIENT', `EVM wallet client required for EVM→EVM bridge (${sourceChain} → ${destinationChain}). ` +
|
|
136
|
+
`Pass evmSigner to UnifiedBridge constructor.`);
|
|
137
|
+
}
|
|
138
|
+
const rpcOverride = this.config.evmRpcOverrides?.[sourceChain];
|
|
139
|
+
const bridge = new BridgeModule(this.config.evmSigner, sourceChain, { rpcUrl: rpcOverride });
|
|
140
|
+
return bridge.bridge(params.amount, destinationChain, {
|
|
141
|
+
destinationAddress: params.destinationAddress,
|
|
142
|
+
minFinalityThreshold: params.minFinalityThreshold,
|
|
143
|
+
applyPlatformFee: params.applyPlatformFee,
|
|
144
|
+
destinationRpcUrl: params.destinationRpcUrl ?? this.config.evmRpcOverrides?.[destinationChain],
|
|
145
|
+
attestationApiUrl: this.config.attestationApiUrl,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async bridgeSolanaToEvm(params) {
|
|
149
|
+
const startMs = Date.now();
|
|
150
|
+
if (!this.config.solanaWallet) {
|
|
151
|
+
throw new SolanaBridgeError('NO_SOLANA_WALLET', 'Solana keypair required for Solana→EVM bridge. ' +
|
|
152
|
+
'Pass solanaWallet to UnifiedBridge constructor.');
|
|
153
|
+
}
|
|
154
|
+
if (!this.config.evmSigner) {
|
|
155
|
+
throw new BridgeError('NO_WALLET_CLIENT', 'EVM wallet client required to receive on destination EVM chain. ' +
|
|
156
|
+
'Pass evmSigner to UnifiedBridge constructor.');
|
|
157
|
+
}
|
|
158
|
+
const applyFee = params.applyPlatformFee !== false;
|
|
159
|
+
const platformFee = applyFee ? calcBridgeFee(params.amount) : 0n;
|
|
160
|
+
const bridgeAmount = params.amount - platformFee;
|
|
161
|
+
// Phase 1: Burn on Solana
|
|
162
|
+
const solanaBridge = new SolanaCCTPBridge({
|
|
163
|
+
connection: this.solanaConnection,
|
|
164
|
+
payer: this.config.solanaWallet,
|
|
165
|
+
});
|
|
166
|
+
const burnResult = await solanaBridge.depositForBurn({
|
|
167
|
+
amount: bridgeAmount,
|
|
168
|
+
destinationChain: params.destinationChain,
|
|
169
|
+
destinationAddress: params.destinationAddress,
|
|
170
|
+
minFinalityThreshold: params.minFinalityThreshold,
|
|
171
|
+
});
|
|
172
|
+
// Phase 2: Poll attestation (Solana uses same IRIS API)
|
|
173
|
+
const attestation = await solanaBridge.waitForAttestation(burnResult.messageHash, this.config.attestationApiUrl);
|
|
174
|
+
// Phase 3: Mint on EVM destination
|
|
175
|
+
const rpcOverride = this.config.evmRpcOverrides?.[params.destinationChain];
|
|
176
|
+
const evmBridge = new BridgeModule(this.config.evmSigner, params.destinationChain, // use dest as source for the receive-only operation
|
|
177
|
+
{ rpcUrl: rpcOverride });
|
|
178
|
+
const evmMintTxHash = await evmBridge.mint(burnResult.messageBytes, attestation, params.destinationChain, rpcOverride);
|
|
179
|
+
return {
|
|
180
|
+
burnTxHash: burnResult.signature,
|
|
181
|
+
mintTxHash: evmMintTxHash,
|
|
182
|
+
amount: bridgeAmount,
|
|
183
|
+
platformFee,
|
|
184
|
+
fromChain: 'solana',
|
|
185
|
+
toChain: params.destinationChain,
|
|
186
|
+
recipient: params.destinationAddress,
|
|
187
|
+
nonce: burnResult.nonce,
|
|
188
|
+
elapsedMs: Date.now() - startMs,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
async bridgeEvmToSolana(params) {
|
|
192
|
+
const startMs = Date.now();
|
|
193
|
+
if (!this.config.evmSigner) {
|
|
194
|
+
throw new BridgeError('NO_WALLET_CLIENT', `EVM wallet client required for ${params.sourceChain}→Solana bridge.`);
|
|
195
|
+
}
|
|
196
|
+
if (!this.config.solanaWallet) {
|
|
197
|
+
throw new SolanaBridgeError('NO_SOLANA_WALLET', 'Solana keypair required to receive USDC on Solana. ' +
|
|
198
|
+
'Pass solanaWallet to UnifiedBridge constructor.');
|
|
199
|
+
}
|
|
200
|
+
const applyFee = params.applyPlatformFee !== false;
|
|
201
|
+
const platformFee = applyFee ? calcBridgeFee(params.amount) : 0n;
|
|
202
|
+
const bridgeAmount = params.amount - platformFee;
|
|
203
|
+
// Solana destination: mintRecipient must be hex of USDC ATA on Solana
|
|
204
|
+
// The caller passes a base58 Solana address; we convert to hex for EVM depositForBurn
|
|
205
|
+
const solanaAddressHex = this.solanaAddressToHex(params.destinationAddress);
|
|
206
|
+
// Phase 1: Burn on EVM (using CCTP domain 5 for Solana)
|
|
207
|
+
const rpcOverride = this.config.evmRpcOverrides?.[params.sourceChain];
|
|
208
|
+
const evmBridge = new BridgeModule(this.config.evmSigner, params.sourceChain, { rpcUrl: rpcOverride });
|
|
209
|
+
const burnResult = await evmBridge.burn(bridgeAmount, 'solana', {
|
|
210
|
+
destinationAddress: solanaAddressHex,
|
|
211
|
+
minFinalityThreshold: params.minFinalityThreshold,
|
|
212
|
+
applyPlatformFee: false, // already deducted
|
|
213
|
+
attestationApiUrl: this.config.attestationApiUrl,
|
|
214
|
+
});
|
|
215
|
+
// Phase 2: Attestation
|
|
216
|
+
const attestation = await evmBridge.waitForAttestation(burnResult.messageHash, this.config.attestationApiUrl);
|
|
217
|
+
// Phase 3: Receive on Solana
|
|
218
|
+
const solanaBridge = new SolanaCCTPBridge({
|
|
219
|
+
connection: this.solanaConnection,
|
|
220
|
+
payer: this.config.solanaWallet,
|
|
221
|
+
});
|
|
222
|
+
// Ensure recipient USDC ATA exists
|
|
223
|
+
const recipientUsdcAta = await solanaBridge.ensureUsdcAta();
|
|
224
|
+
const solanaMintSig = await solanaBridge.receiveMessage({
|
|
225
|
+
message: burnResult.messageBytes,
|
|
226
|
+
attestation,
|
|
227
|
+
recipientUsdcAccount: recipientUsdcAta.toString(),
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
burnTxHash: burnResult.burnTxHash,
|
|
231
|
+
mintTxHash: solanaMintSig,
|
|
232
|
+
amount: bridgeAmount,
|
|
233
|
+
platformFee,
|
|
234
|
+
fromChain: params.sourceChain,
|
|
235
|
+
toChain: 'solana',
|
|
236
|
+
recipient: params.destinationAddress,
|
|
237
|
+
nonce: burnResult.nonce,
|
|
238
|
+
elapsedMs: Date.now() - startMs,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
// ─── Validation ───
|
|
242
|
+
validateParams(amount, sourceChain, destinationChain) {
|
|
243
|
+
if (amount <= 0n) {
|
|
244
|
+
throw new BridgeError('INVALID_AMOUNT', `Amount must be > 0. Got ${amount}. Use USDC base units (1 USDC = 1_000_000).`);
|
|
245
|
+
}
|
|
246
|
+
if (!(sourceChain in CCTP_DOMAIN_IDS)) {
|
|
247
|
+
throw new BridgeError('UNSUPPORTED_CHAIN', `Source chain '${sourceChain}' is not supported. ` +
|
|
248
|
+
`Supported: ${Object.keys(CCTP_DOMAIN_IDS).join(', ')}`);
|
|
249
|
+
}
|
|
250
|
+
if (!(destinationChain in CCTP_DOMAIN_IDS)) {
|
|
251
|
+
throw new BridgeError('UNSUPPORTED_CHAIN', `Destination chain '${destinationChain}' is not supported. ` +
|
|
252
|
+
`Supported: ${Object.keys(CCTP_DOMAIN_IDS).join(', ')}`);
|
|
253
|
+
}
|
|
254
|
+
if (sourceChain === destinationChain) {
|
|
255
|
+
throw new BridgeError('SAME_CHAIN', `Source and destination must differ. Both set to '${sourceChain}'.`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// ─── Helpers ───
|
|
259
|
+
/**
|
|
260
|
+
* Convert a Solana base58 address to a 32-byte hex string for EVM mintRecipient.
|
|
261
|
+
* Per Circle docs: hex-encoded USDC token account address.
|
|
262
|
+
*/
|
|
263
|
+
solanaAddressToHex(base58Address) {
|
|
264
|
+
// bs58 decode → hex encode
|
|
265
|
+
// Import dynamically to avoid requiring bs58 for EVM-only users
|
|
266
|
+
try {
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
268
|
+
const bs58 = require('bs58');
|
|
269
|
+
const decoded = bs58.decode(base58Address);
|
|
270
|
+
return '0x' + Buffer.from(decoded).toString('hex').padStart(64, '0');
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
// If bs58 not available, assume it's already hex
|
|
274
|
+
if (base58Address.startsWith('0x'))
|
|
275
|
+
return base58Address;
|
|
276
|
+
throw new BridgeError('UNSUPPORTED_CHAIN', `Could not convert Solana address to hex: ${base58Address}. ` +
|
|
277
|
+
`Pass the USDC ATA address (base58) for Solana destination.`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// ─── Re-exports ───
|
|
282
|
+
export { BridgeError, SolanaBridgeError };
|
|
283
|
+
export { CCTP_DOMAIN_IDS, BRIDGE_CHAIN_IDS, BRIDGE_RPC_URLS, calcBridgeFee, };
|
|
284
|
+
//# sourceMappingURL=unified.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified.js","sourceRoot":"","sources":["../../src/bridge/unified.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,kFAAkF;AAClF,EAAE;AACF,+CAA+C;AAC/C,2CAA2C;AAC3C,EAAE;AACF,SAAS;AACT,0FAA0F;AAC1F,gIAAgI;AAIhI,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAGL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAEf,aAAa,EACb,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,YAAY,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,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QACvE,CAAC;QAAC,MAAM,CAAC;YACP,iDAAiD;YACjD,IAAI,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO,aAAa,CAAC;YACzD,MAAM,IAAI,WAAW,CACnB,mBAAmB,EACnB,4CAA4C,aAAa,IAAI;gBAC7D,4DAA4D,CAC7D,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED,qBAAqB;AAErB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;AAC1C,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,CAAC"}
|
package/dist/chains.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Address } from 'viem';
|
|
2
|
+
/** Chains supported for swap + x402 + wallet operations */
|
|
3
|
+
export type SupportedChain = 'base' | 'arbitrum' | 'optimism';
|
|
4
|
+
export interface ChainConfig {
|
|
5
|
+
chainId: number;
|
|
6
|
+
name: string;
|
|
7
|
+
/** Public default RPC URL (no API key required) */
|
|
8
|
+
rpcUrl: string;
|
|
9
|
+
/** USDC token contract address (official Circle deployment) */
|
|
10
|
+
usdc: Address;
|
|
11
|
+
/** Uniswap V3 SwapRouter02 address */
|
|
12
|
+
uniswapRouter?: Address;
|
|
13
|
+
/** Uniswap V3 QuoterV2 address */
|
|
14
|
+
uniswapQuoter?: Address;
|
|
15
|
+
/** Wrapped native token address */
|
|
16
|
+
weth?: Address;
|
|
17
|
+
/** x402 network identifier (e.g. "base:8453") */
|
|
18
|
+
x402Network: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Chain configuration for all supported chains.
|
|
22
|
+
*
|
|
23
|
+
* Uniswap V3 addresses verified against:
|
|
24
|
+
* https://docs.uniswap.org/contracts/v3/reference/deployments/
|
|
25
|
+
*
|
|
26
|
+
* USDC addresses verified against:
|
|
27
|
+
* https://www.circle.com/en/multichain-usdc
|
|
28
|
+
*
|
|
29
|
+
* WETH on Base / Optimism is the canonical OP-stack bridged WETH at 0x4200...0006
|
|
30
|
+
* Arbitrum WETH is the standard bridged WETH at 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
|
|
31
|
+
*/
|
|
32
|
+
export declare const CHAIN_CONFIG: Record<SupportedChain, ChainConfig>;
|
|
33
|
+
/** Get chain config — throws a clear error if chain is unknown */
|
|
34
|
+
export declare function getChainConfig(chain: SupportedChain): ChainConfig;
|
|
35
|
+
/** Resolve a chain from chainId — returns undefined if not found */
|
|
36
|
+
export declare function chainFromId(chainId: number): SupportedChain | undefined;
|
|
37
|
+
/** Solana chain identifiers */
|
|
38
|
+
export type SolanaChain = 'solana' | 'solana-devnet';
|
|
39
|
+
/** Solana chain configuration entry */
|
|
40
|
+
export interface SolanaChainConfig {
|
|
41
|
+
/** Solana cluster name (e.g. "mainnet-beta", "devnet") */
|
|
42
|
+
cluster: string;
|
|
43
|
+
/** Public RPC URL */
|
|
44
|
+
rpcUrl: string;
|
|
45
|
+
/** Official USDC SPL token mint address */
|
|
46
|
+
usdcMint: string;
|
|
47
|
+
/** x402 network identifier */
|
|
48
|
+
x402Network: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Solana chain configurations.
|
|
52
|
+
*
|
|
53
|
+
* USDC mints verified against:
|
|
54
|
+
* https://www.circle.com/en/multichain-usdc (Solana)
|
|
55
|
+
*
|
|
56
|
+
* RPC endpoints: Solana Foundation public RPC (free, no key required).
|
|
57
|
+
* For production, use Helius, Alchemy, or QuickNode.
|
|
58
|
+
*/
|
|
59
|
+
export declare const SOLANA_CONFIG: Record<SolanaChain, SolanaChainConfig>;
|
|
60
|
+
/** Get Solana chain config — throws if chain is unknown */
|
|
61
|
+
export declare function getSolanaConfig(chain: SolanaChain): SolanaChainConfig;
|
|
62
|
+
//# sourceMappingURL=chains.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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,CAAC;AAEX,2DAA2D;AAC3D,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAQrE"}
|
package/dist/chains.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// [MAX-ADDED] Shared chain configuration — single source of truth for multi-chain support.
|
|
2
|
+
// Chains: Base, Arbitrum, Optimism (Ethereum is bridge-only, no swap support due to gas).
|
|
3
|
+
/**
|
|
4
|
+
* Chain configuration for all supported chains.
|
|
5
|
+
*
|
|
6
|
+
* Uniswap V3 addresses verified against:
|
|
7
|
+
* https://docs.uniswap.org/contracts/v3/reference/deployments/
|
|
8
|
+
*
|
|
9
|
+
* USDC addresses verified against:
|
|
10
|
+
* https://www.circle.com/en/multichain-usdc
|
|
11
|
+
*
|
|
12
|
+
* WETH on Base / Optimism is the canonical OP-stack bridged WETH at 0x4200...0006
|
|
13
|
+
* Arbitrum WETH is the standard bridged WETH at 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1
|
|
14
|
+
*/
|
|
15
|
+
export const CHAIN_CONFIG = {
|
|
16
|
+
base: {
|
|
17
|
+
chainId: 8453,
|
|
18
|
+
name: 'Base',
|
|
19
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
20
|
+
// Official USDC on Base (Circle native deployment)
|
|
21
|
+
usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
22
|
+
// Uniswap V3 on Base — SwapRouter02 + QuoterV2
|
|
23
|
+
// Source: https://docs.uniswap.org/contracts/v3/reference/deployments/base-deployments
|
|
24
|
+
uniswapRouter: '0x2626664c2603336E57B271c5C0b26F421741e481',
|
|
25
|
+
uniswapQuoter: '0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a',
|
|
26
|
+
// OP-stack canonical WETH
|
|
27
|
+
weth: '0x4200000000000000000000000000000000000006',
|
|
28
|
+
x402Network: 'base:8453',
|
|
29
|
+
},
|
|
30
|
+
arbitrum: {
|
|
31
|
+
chainId: 42161,
|
|
32
|
+
name: 'Arbitrum One',
|
|
33
|
+
rpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
34
|
+
// Official USDC on Arbitrum (Circle native deployment — NOT USDC.e bridged)
|
|
35
|
+
usdc: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
36
|
+
// Uniswap V3 on Arbitrum — SwapRouter02 + QuoterV2
|
|
37
|
+
// Source: https://docs.uniswap.org/contracts/v3/reference/deployments/arbitrum-deployments
|
|
38
|
+
uniswapRouter: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
39
|
+
uniswapQuoter: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
40
|
+
// Standard bridged WETH on Arbitrum
|
|
41
|
+
weth: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
42
|
+
x402Network: 'arbitrum:42161',
|
|
43
|
+
},
|
|
44
|
+
optimism: {
|
|
45
|
+
chainId: 10,
|
|
46
|
+
name: 'OP Mainnet',
|
|
47
|
+
rpcUrl: 'https://mainnet.optimism.io',
|
|
48
|
+
// Official USDC on Optimism (Circle native deployment — NOT USDC.e bridged)
|
|
49
|
+
usdc: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
50
|
+
// Uniswap V3 on Optimism — SwapRouter02 + QuoterV2
|
|
51
|
+
// Source: https://docs.uniswap.org/contracts/v3/reference/deployments/optimism-deployments
|
|
52
|
+
uniswapRouter: '0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45',
|
|
53
|
+
uniswapQuoter: '0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
54
|
+
// OP-stack canonical WETH
|
|
55
|
+
weth: '0x4200000000000000000000000000000000000006',
|
|
56
|
+
x402Network: 'optimism:10',
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
/** Get chain config — throws a clear error if chain is unknown */
|
|
60
|
+
export function getChainConfig(chain) {
|
|
61
|
+
const config = CHAIN_CONFIG[chain];
|
|
62
|
+
if (!config) {
|
|
63
|
+
throw new Error(`Unsupported chain: "${chain}". Supported chains: ${Object.keys(CHAIN_CONFIG).join(', ')}`);
|
|
64
|
+
}
|
|
65
|
+
return config;
|
|
66
|
+
}
|
|
67
|
+
/** Resolve a chain from chainId — returns undefined if not found */
|
|
68
|
+
export function chainFromId(chainId) {
|
|
69
|
+
for (const [key, cfg] of Object.entries(CHAIN_CONFIG)) {
|
|
70
|
+
if (cfg.chainId === chainId)
|
|
71
|
+
return key;
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Solana chain configurations.
|
|
77
|
+
*
|
|
78
|
+
* USDC mints verified against:
|
|
79
|
+
* https://www.circle.com/en/multichain-usdc (Solana)
|
|
80
|
+
*
|
|
81
|
+
* RPC endpoints: Solana Foundation public RPC (free, no key required).
|
|
82
|
+
* For production, use Helius, Alchemy, or QuickNode.
|
|
83
|
+
*/
|
|
84
|
+
export const SOLANA_CONFIG = {
|
|
85
|
+
solana: {
|
|
86
|
+
cluster: 'mainnet-beta',
|
|
87
|
+
rpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
88
|
+
// Official Circle USDC on Solana Mainnet
|
|
89
|
+
usdcMint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
90
|
+
x402Network: 'solana:mainnet',
|
|
91
|
+
},
|
|
92
|
+
'solana-devnet': {
|
|
93
|
+
cluster: 'devnet',
|
|
94
|
+
rpcUrl: 'https://api.devnet.solana.com',
|
|
95
|
+
// Circle USDC on Solana Devnet
|
|
96
|
+
usdcMint: '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU',
|
|
97
|
+
x402Network: 'solana:devnet',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
/** Get Solana chain config — throws if chain is unknown */
|
|
101
|
+
export function getSolanaConfig(chain) {
|
|
102
|
+
const config = SOLANA_CONFIG[chain];
|
|
103
|
+
if (!config) {
|
|
104
|
+
throw new Error(`Unsupported Solana chain: "${chain}". Supported: ${Object.keys(SOLANA_CONFIG).join(', ')}`);
|
|
105
|
+
}
|
|
106
|
+
return config;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=chains.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chains.js","sourceRoot":"","sources":["../src/chains.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,0FAA0F;AAwB1F;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,YAAY,GAAwC;IAC/D,IAAI,EAAE;QACJ,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,0BAA0B;QAClC,mDAAmD;QACnD,IAAI,EAAE,4CAA4C;QAClD,+CAA+C;QAC/C,uFAAuF;QACvF,aAAa,EAAE,4CAA4C;QAC3D,aAAa,EAAE,4CAA4C;QAC3D,0BAA0B;QAC1B,IAAI,EAAE,4CAA4C;QAClD,WAAW,EAAE,WAAW;KACzB;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,8BAA8B;QACtC,4EAA4E;QAC5E,IAAI,EAAE,4CAA4C;QAClD,mDAAmD;QACnD,2FAA2F;QAC3F,aAAa,EAAE,4CAA4C;QAC3D,aAAa,EAAE,4CAA4C;QAC3D,oCAAoC;QACpC,IAAI,EAAE,4CAA4C;QAClD,WAAW,EAAE,gBAAgB;KAC9B;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,EAAE;QACX,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,6BAA6B;QACrC,4EAA4E;QAC5E,IAAI,EAAE,4CAA4C;QAClD,mDAAmD;QACnD,2FAA2F;QAC3F,aAAa,EAAE,4CAA4C;QAC3D,aAAa,EAAE,4CAA4C;QAC3D,0BAA0B;QAC1B,IAAI,EAAE,4CAA4C;QAClD,WAAW,EAAE,aAAa;KAC3B;CACO,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