uvd-x402-sdk 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +782 -0
- package/dist/index-BrBqP1I8.d.ts +199 -0
- package/dist/index-D6Sr4ARD.d.mts +429 -0
- package/dist/index-D6Sr4ARD.d.ts +429 -0
- package/dist/index-DJ4Cvrev.d.mts +199 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1178 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1146 -0
- package/dist/index.mjs.map +1 -0
- package/dist/providers/evm/index.d.mts +84 -0
- package/dist/providers/evm/index.d.ts +84 -0
- package/dist/providers/evm/index.js +740 -0
- package/dist/providers/evm/index.js.map +1 -0
- package/dist/providers/evm/index.mjs +735 -0
- package/dist/providers/evm/index.mjs.map +1 -0
- package/dist/providers/near/index.d.mts +99 -0
- package/dist/providers/near/index.d.ts +99 -0
- package/dist/providers/near/index.js +483 -0
- package/dist/providers/near/index.js.map +1 -0
- package/dist/providers/near/index.mjs +478 -0
- package/dist/providers/near/index.mjs.map +1 -0
- package/dist/providers/solana/index.d.mts +115 -0
- package/dist/providers/solana/index.d.ts +115 -0
- package/dist/providers/solana/index.js +771 -0
- package/dist/providers/solana/index.js.map +1 -0
- package/dist/providers/solana/index.mjs +765 -0
- package/dist/providers/solana/index.mjs.map +1 -0
- package/dist/providers/stellar/index.d.mts +67 -0
- package/dist/providers/stellar/index.d.ts +67 -0
- package/dist/providers/stellar/index.js +306 -0
- package/dist/providers/stellar/index.js.map +1 -0
- package/dist/providers/stellar/index.mjs +301 -0
- package/dist/providers/stellar/index.mjs.map +1 -0
- package/dist/react/index.d.mts +73 -0
- package/dist/react/index.d.ts +73 -0
- package/dist/react/index.js +1218 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +1211 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +103 -0
- package/dist/utils/index.d.ts +103 -0
- package/dist/utils/index.js +575 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +562 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +149 -0
- package/src/chains/index.ts +539 -0
- package/src/client/X402Client.ts +663 -0
- package/src/client/index.ts +1 -0
- package/src/index.ts +166 -0
- package/src/providers/evm/index.ts +394 -0
- package/src/providers/near/index.ts +664 -0
- package/src/providers/solana/index.ts +489 -0
- package/src/providers/stellar/index.ts +376 -0
- package/src/react/index.tsx +417 -0
- package/src/types/index.ts +561 -0
- package/src/utils/index.ts +20 -0
- package/src/utils/x402.ts +295 -0
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* uvd-x402-sdk - Chain Registry
|
|
3
|
+
*
|
|
4
|
+
* Complete configuration for all 15 supported blockchain networks.
|
|
5
|
+
* EVM chains (11): Use ERC-3009 TransferWithAuthorization
|
|
6
|
+
* SVM chains (2): Solana and Fogo - Use SPL tokens with partially-signed transactions
|
|
7
|
+
* Stellar (1): Uses Soroban authorization entries
|
|
8
|
+
* NEAR (1): Uses NEP-366 meta-transactions
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { ChainConfig, NetworkType } from '../types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default facilitator URL for x402 payments
|
|
15
|
+
*/
|
|
16
|
+
export const DEFAULT_FACILITATOR_URL = 'https://facilitator.ultravioletadao.xyz';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* All supported chains configuration
|
|
20
|
+
*
|
|
21
|
+
* To add a new chain:
|
|
22
|
+
* 1. Add chain config below with all required fields
|
|
23
|
+
* 2. Verify USDC contract supports ERC-3009 (transferWithAuthorization) for EVM chains
|
|
24
|
+
* 3. Test on testnet first before enabling
|
|
25
|
+
*/
|
|
26
|
+
export const SUPPORTED_CHAINS: Record<string, ChainConfig> = {
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// EVM CHAINS (11 networks)
|
|
29
|
+
// ============================================================================
|
|
30
|
+
|
|
31
|
+
base: {
|
|
32
|
+
chainId: 8453,
|
|
33
|
+
chainIdHex: '0x2105',
|
|
34
|
+
name: 'base',
|
|
35
|
+
displayName: 'Base',
|
|
36
|
+
networkType: 'evm',
|
|
37
|
+
rpcUrl: 'https://mainnet.base.org',
|
|
38
|
+
explorerUrl: 'https://basescan.org',
|
|
39
|
+
nativeCurrency: {
|
|
40
|
+
name: 'Ethereum',
|
|
41
|
+
symbol: 'ETH',
|
|
42
|
+
decimals: 18,
|
|
43
|
+
},
|
|
44
|
+
usdc: {
|
|
45
|
+
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
46
|
+
decimals: 6,
|
|
47
|
+
name: 'USD Coin',
|
|
48
|
+
version: '2',
|
|
49
|
+
},
|
|
50
|
+
x402: {
|
|
51
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
52
|
+
enabled: true,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
avalanche: {
|
|
57
|
+
chainId: 43114,
|
|
58
|
+
chainIdHex: '0xa86a',
|
|
59
|
+
name: 'avalanche',
|
|
60
|
+
displayName: 'Avalanche C-Chain',
|
|
61
|
+
networkType: 'evm',
|
|
62
|
+
rpcUrl: 'https://avalanche-c-chain-rpc.publicnode.com',
|
|
63
|
+
explorerUrl: 'https://snowtrace.io',
|
|
64
|
+
nativeCurrency: {
|
|
65
|
+
name: 'Avalanche',
|
|
66
|
+
symbol: 'AVAX',
|
|
67
|
+
decimals: 18,
|
|
68
|
+
},
|
|
69
|
+
usdc: {
|
|
70
|
+
address: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
71
|
+
decimals: 6,
|
|
72
|
+
name: 'USD Coin',
|
|
73
|
+
version: '2',
|
|
74
|
+
},
|
|
75
|
+
x402: {
|
|
76
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
77
|
+
enabled: true,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
ethereum: {
|
|
82
|
+
chainId: 1,
|
|
83
|
+
chainIdHex: '0x1',
|
|
84
|
+
name: 'ethereum',
|
|
85
|
+
displayName: 'Ethereum',
|
|
86
|
+
networkType: 'evm',
|
|
87
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
88
|
+
explorerUrl: 'https://etherscan.io',
|
|
89
|
+
nativeCurrency: {
|
|
90
|
+
name: 'Ethereum',
|
|
91
|
+
symbol: 'ETH',
|
|
92
|
+
decimals: 18,
|
|
93
|
+
},
|
|
94
|
+
usdc: {
|
|
95
|
+
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
96
|
+
decimals: 6,
|
|
97
|
+
name: 'USD Coin',
|
|
98
|
+
version: '2',
|
|
99
|
+
},
|
|
100
|
+
x402: {
|
|
101
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
102
|
+
enabled: true,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
polygon: {
|
|
107
|
+
chainId: 137,
|
|
108
|
+
chainIdHex: '0x89',
|
|
109
|
+
name: 'polygon',
|
|
110
|
+
displayName: 'Polygon',
|
|
111
|
+
networkType: 'evm',
|
|
112
|
+
rpcUrl: 'https://polygon-rpc.com',
|
|
113
|
+
explorerUrl: 'https://polygonscan.com',
|
|
114
|
+
nativeCurrency: {
|
|
115
|
+
name: 'Polygon',
|
|
116
|
+
symbol: 'POL',
|
|
117
|
+
decimals: 18,
|
|
118
|
+
},
|
|
119
|
+
usdc: {
|
|
120
|
+
address: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
|
|
121
|
+
decimals: 6,
|
|
122
|
+
name: 'USD Coin',
|
|
123
|
+
version: '2',
|
|
124
|
+
},
|
|
125
|
+
x402: {
|
|
126
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
127
|
+
enabled: true,
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
arbitrum: {
|
|
132
|
+
chainId: 42161,
|
|
133
|
+
chainIdHex: '0xa4b1',
|
|
134
|
+
name: 'arbitrum',
|
|
135
|
+
displayName: 'Arbitrum One',
|
|
136
|
+
networkType: 'evm',
|
|
137
|
+
rpcUrl: 'https://arb1.arbitrum.io/rpc',
|
|
138
|
+
explorerUrl: 'https://arbiscan.io',
|
|
139
|
+
nativeCurrency: {
|
|
140
|
+
name: 'Ethereum',
|
|
141
|
+
symbol: 'ETH',
|
|
142
|
+
decimals: 18,
|
|
143
|
+
},
|
|
144
|
+
usdc: {
|
|
145
|
+
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
146
|
+
decimals: 6,
|
|
147
|
+
name: 'USD Coin',
|
|
148
|
+
version: '2',
|
|
149
|
+
},
|
|
150
|
+
x402: {
|
|
151
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
152
|
+
enabled: true,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
optimism: {
|
|
157
|
+
chainId: 10,
|
|
158
|
+
chainIdHex: '0xa',
|
|
159
|
+
name: 'optimism',
|
|
160
|
+
displayName: 'Optimism',
|
|
161
|
+
networkType: 'evm',
|
|
162
|
+
rpcUrl: 'https://mainnet.optimism.io',
|
|
163
|
+
explorerUrl: 'https://optimistic.etherscan.io',
|
|
164
|
+
nativeCurrency: {
|
|
165
|
+
name: 'Ethereum',
|
|
166
|
+
symbol: 'ETH',
|
|
167
|
+
decimals: 18,
|
|
168
|
+
},
|
|
169
|
+
usdc: {
|
|
170
|
+
address: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
171
|
+
decimals: 6,
|
|
172
|
+
name: 'USD Coin',
|
|
173
|
+
version: '2',
|
|
174
|
+
},
|
|
175
|
+
x402: {
|
|
176
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
177
|
+
enabled: true,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
celo: {
|
|
182
|
+
chainId: 42220,
|
|
183
|
+
chainIdHex: '0xa4ec',
|
|
184
|
+
name: 'celo',
|
|
185
|
+
displayName: 'Celo',
|
|
186
|
+
networkType: 'evm',
|
|
187
|
+
rpcUrl: 'https://forno.celo.org',
|
|
188
|
+
explorerUrl: 'https://celoscan.io',
|
|
189
|
+
nativeCurrency: {
|
|
190
|
+
name: 'Celo',
|
|
191
|
+
symbol: 'CELO',
|
|
192
|
+
decimals: 18,
|
|
193
|
+
},
|
|
194
|
+
usdc: {
|
|
195
|
+
address: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
|
|
196
|
+
decimals: 6,
|
|
197
|
+
name: 'USDC', // Celo uses "USDC" not "USD Coin" for EIP-712
|
|
198
|
+
version: '2',
|
|
199
|
+
},
|
|
200
|
+
x402: {
|
|
201
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
202
|
+
enabled: true,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
hyperevm: {
|
|
207
|
+
chainId: 999,
|
|
208
|
+
chainIdHex: '0x3e7',
|
|
209
|
+
name: 'hyperevm',
|
|
210
|
+
displayName: 'HyperEVM',
|
|
211
|
+
networkType: 'evm',
|
|
212
|
+
rpcUrl: 'https://rpc.hyperliquid.xyz/evm',
|
|
213
|
+
explorerUrl: 'https://hyperevmscan.io',
|
|
214
|
+
nativeCurrency: {
|
|
215
|
+
name: 'Ethereum',
|
|
216
|
+
symbol: 'ETH',
|
|
217
|
+
decimals: 18,
|
|
218
|
+
},
|
|
219
|
+
usdc: {
|
|
220
|
+
address: '0xb88339CB7199b77E23DB6E890353E22632Ba630f',
|
|
221
|
+
decimals: 6,
|
|
222
|
+
name: 'USDC', // HyperEVM uses "USDC" not "USD Coin"
|
|
223
|
+
version: '2',
|
|
224
|
+
},
|
|
225
|
+
x402: {
|
|
226
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
227
|
+
enabled: true,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
unichain: {
|
|
232
|
+
chainId: 130,
|
|
233
|
+
chainIdHex: '0x82',
|
|
234
|
+
name: 'unichain',
|
|
235
|
+
displayName: 'Unichain',
|
|
236
|
+
networkType: 'evm',
|
|
237
|
+
rpcUrl: 'https://unichain-rpc.publicnode.com',
|
|
238
|
+
explorerUrl: 'https://uniscan.xyz',
|
|
239
|
+
nativeCurrency: {
|
|
240
|
+
name: 'Ethereum',
|
|
241
|
+
symbol: 'ETH',
|
|
242
|
+
decimals: 18,
|
|
243
|
+
},
|
|
244
|
+
usdc: {
|
|
245
|
+
address: '0x078d782b760474a361dda0af3839290b0ef57ad6',
|
|
246
|
+
decimals: 6,
|
|
247
|
+
name: 'USDC', // Unichain uses "USDC" not "USD Coin"
|
|
248
|
+
version: '2',
|
|
249
|
+
},
|
|
250
|
+
x402: {
|
|
251
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
252
|
+
enabled: true,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
|
|
256
|
+
monad: {
|
|
257
|
+
chainId: 143,
|
|
258
|
+
chainIdHex: '0x8f',
|
|
259
|
+
name: 'monad',
|
|
260
|
+
displayName: 'Monad',
|
|
261
|
+
networkType: 'evm',
|
|
262
|
+
rpcUrl: 'https://rpc.monad.xyz',
|
|
263
|
+
explorerUrl: 'https://monad.socialscan.io',
|
|
264
|
+
nativeCurrency: {
|
|
265
|
+
name: 'Monad',
|
|
266
|
+
symbol: 'MON',
|
|
267
|
+
decimals: 18,
|
|
268
|
+
},
|
|
269
|
+
usdc: {
|
|
270
|
+
address: '0x754704bc059f8c67012fed69bc8a327a5aafb603',
|
|
271
|
+
decimals: 6,
|
|
272
|
+
name: 'USDC', // Monad uses "USDC" not "USD Coin"
|
|
273
|
+
version: '2',
|
|
274
|
+
},
|
|
275
|
+
x402: {
|
|
276
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
277
|
+
enabled: true,
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
// BSC disabled: USDC doesn't support ERC-3009 transferWithAuthorization
|
|
282
|
+
bsc: {
|
|
283
|
+
chainId: 56,
|
|
284
|
+
chainIdHex: '0x38',
|
|
285
|
+
name: 'bsc',
|
|
286
|
+
displayName: 'BNB Smart Chain',
|
|
287
|
+
networkType: 'evm',
|
|
288
|
+
rpcUrl: 'https://binance.llamarpc.com',
|
|
289
|
+
explorerUrl: 'https://bscscan.com',
|
|
290
|
+
nativeCurrency: {
|
|
291
|
+
name: 'Binance Coin',
|
|
292
|
+
symbol: 'BNB',
|
|
293
|
+
decimals: 18,
|
|
294
|
+
},
|
|
295
|
+
usdc: {
|
|
296
|
+
address: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
297
|
+
decimals: 18, // BSC USDC uses 18 decimals
|
|
298
|
+
name: 'USD Coin',
|
|
299
|
+
version: '2',
|
|
300
|
+
},
|
|
301
|
+
x402: {
|
|
302
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
303
|
+
enabled: false, // Disabled: BSC USDC doesn't support ERC-3009
|
|
304
|
+
},
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
// ============================================================================
|
|
308
|
+
// SVM CHAINS (2 networks) - Solana Virtual Machine
|
|
309
|
+
// ============================================================================
|
|
310
|
+
|
|
311
|
+
solana: {
|
|
312
|
+
chainId: 0, // Non-EVM
|
|
313
|
+
chainIdHex: '0x0',
|
|
314
|
+
name: 'solana',
|
|
315
|
+
displayName: 'Solana',
|
|
316
|
+
networkType: 'svm',
|
|
317
|
+
rpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
318
|
+
explorerUrl: 'https://solscan.io',
|
|
319
|
+
nativeCurrency: {
|
|
320
|
+
name: 'Solana',
|
|
321
|
+
symbol: 'SOL',
|
|
322
|
+
decimals: 9,
|
|
323
|
+
},
|
|
324
|
+
usdc: {
|
|
325
|
+
address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC SPL token mint
|
|
326
|
+
decimals: 6,
|
|
327
|
+
name: 'USD Coin',
|
|
328
|
+
version: '1',
|
|
329
|
+
},
|
|
330
|
+
x402: {
|
|
331
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
332
|
+
enabled: true,
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
fogo: {
|
|
337
|
+
chainId: 0, // Non-EVM (SVM)
|
|
338
|
+
chainIdHex: '0x0',
|
|
339
|
+
name: 'fogo',
|
|
340
|
+
displayName: 'Fogo',
|
|
341
|
+
networkType: 'svm',
|
|
342
|
+
rpcUrl: 'https://rpc.fogo.nightly.app/',
|
|
343
|
+
explorerUrl: 'https://explorer.fogo.nightly.app',
|
|
344
|
+
nativeCurrency: {
|
|
345
|
+
name: 'Fogo',
|
|
346
|
+
symbol: 'FOGO',
|
|
347
|
+
decimals: 9,
|
|
348
|
+
},
|
|
349
|
+
usdc: {
|
|
350
|
+
address: 'uSd2czE61Evaf76RNbq4KPpXnkiL3irdzgLFUMe3NoG', // Fogo USDC mint
|
|
351
|
+
decimals: 6,
|
|
352
|
+
name: 'USDC',
|
|
353
|
+
version: '1',
|
|
354
|
+
},
|
|
355
|
+
x402: {
|
|
356
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
357
|
+
enabled: true,
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
// ============================================================================
|
|
362
|
+
// STELLAR (1 network)
|
|
363
|
+
// ============================================================================
|
|
364
|
+
|
|
365
|
+
stellar: {
|
|
366
|
+
chainId: 0, // Non-EVM
|
|
367
|
+
chainIdHex: '0x0',
|
|
368
|
+
name: 'stellar',
|
|
369
|
+
displayName: 'Stellar',
|
|
370
|
+
networkType: 'stellar',
|
|
371
|
+
rpcUrl: 'https://horizon.stellar.org',
|
|
372
|
+
explorerUrl: 'https://stellar.expert/explorer/public',
|
|
373
|
+
nativeCurrency: {
|
|
374
|
+
name: 'Lumens',
|
|
375
|
+
symbol: 'XLM',
|
|
376
|
+
decimals: 7, // Stellar uses 7 decimals (stroops)
|
|
377
|
+
},
|
|
378
|
+
usdc: {
|
|
379
|
+
address: 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75', // Soroban Asset Contract
|
|
380
|
+
decimals: 7, // Stellar USDC uses 7 decimals
|
|
381
|
+
name: 'USDC',
|
|
382
|
+
version: '1',
|
|
383
|
+
},
|
|
384
|
+
x402: {
|
|
385
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
386
|
+
enabled: true,
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
|
|
390
|
+
// ============================================================================
|
|
391
|
+
// NEAR (1 network) - Uses NEP-366 meta-transactions
|
|
392
|
+
// ============================================================================
|
|
393
|
+
|
|
394
|
+
near: {
|
|
395
|
+
chainId: 0, // Non-EVM
|
|
396
|
+
chainIdHex: '0x0',
|
|
397
|
+
name: 'near',
|
|
398
|
+
displayName: 'NEAR Protocol',
|
|
399
|
+
networkType: 'near',
|
|
400
|
+
rpcUrl: 'https://rpc.mainnet.near.org',
|
|
401
|
+
explorerUrl: 'https://nearblocks.io',
|
|
402
|
+
nativeCurrency: {
|
|
403
|
+
name: 'NEAR',
|
|
404
|
+
symbol: 'NEAR',
|
|
405
|
+
decimals: 24, // NEAR uses 24 decimals (yoctoNEAR)
|
|
406
|
+
},
|
|
407
|
+
usdc: {
|
|
408
|
+
address: '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1', // Native Circle USDC
|
|
409
|
+
decimals: 6,
|
|
410
|
+
name: 'USDC',
|
|
411
|
+
version: '1',
|
|
412
|
+
},
|
|
413
|
+
x402: {
|
|
414
|
+
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
415
|
+
enabled: true, // NEP-366 meta-transactions supported
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Default chain for new users
|
|
422
|
+
*/
|
|
423
|
+
export const DEFAULT_CHAIN = 'base';
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Get chain config by chain ID
|
|
427
|
+
*/
|
|
428
|
+
export function getChainById(chainId: number): ChainConfig | undefined {
|
|
429
|
+
return Object.values(SUPPORTED_CHAINS).find(chain => chain.chainId === chainId);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* Get chain config by name (case-insensitive)
|
|
434
|
+
*/
|
|
435
|
+
export function getChainByName(name: string): ChainConfig | undefined {
|
|
436
|
+
return SUPPORTED_CHAINS[name.toLowerCase()];
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Check if a chain is supported
|
|
441
|
+
*/
|
|
442
|
+
export function isChainSupported(chainIdOrName: number | string): boolean {
|
|
443
|
+
if (typeof chainIdOrName === 'number') {
|
|
444
|
+
return Object.values(SUPPORTED_CHAINS).some(chain => chain.chainId === chainIdOrName);
|
|
445
|
+
}
|
|
446
|
+
return chainIdOrName.toLowerCase() in SUPPORTED_CHAINS;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Get list of enabled chains
|
|
451
|
+
*/
|
|
452
|
+
export function getEnabledChains(): ChainConfig[] {
|
|
453
|
+
return Object.values(SUPPORTED_CHAINS).filter(chain => chain.x402.enabled);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Get list of chains by network type
|
|
458
|
+
*/
|
|
459
|
+
export function getChainsByNetworkType(networkType: NetworkType): ChainConfig[] {
|
|
460
|
+
return Object.values(SUPPORTED_CHAINS).filter(
|
|
461
|
+
chain => chain.networkType === networkType && chain.x402.enabled
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Get all EVM chain IDs (for wallet_switchEthereumChain)
|
|
467
|
+
*/
|
|
468
|
+
export function getEVMChainIds(): number[] {
|
|
469
|
+
return getChainsByNetworkType('evm').map(chain => chain.chainId);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Get list of SVM chains (Solana, Fogo)
|
|
474
|
+
*/
|
|
475
|
+
export function getSVMChains(): ChainConfig[] {
|
|
476
|
+
return Object.values(SUPPORTED_CHAINS).filter(
|
|
477
|
+
chain => chain.networkType === 'svm' && chain.x402.enabled
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Check if a chain is SVM-based (Solana Virtual Machine)
|
|
483
|
+
*/
|
|
484
|
+
export function isSVMChain(chainName: string): boolean {
|
|
485
|
+
const chain = getChainByName(chainName);
|
|
486
|
+
return chain?.networkType === 'svm';
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* Get network type from chain name
|
|
491
|
+
*/
|
|
492
|
+
export function getNetworkType(chainName: string): NetworkType | undefined {
|
|
493
|
+
const chain = getChainByName(chainName);
|
|
494
|
+
return chain?.networkType;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Format transaction URL for block explorer
|
|
499
|
+
*/
|
|
500
|
+
export function getExplorerTxUrl(chainName: string, txHash: string): string | null {
|
|
501
|
+
const chain = getChainByName(chainName);
|
|
502
|
+
if (!chain) return null;
|
|
503
|
+
|
|
504
|
+
switch (chain.networkType) {
|
|
505
|
+
case 'evm':
|
|
506
|
+
return `${chain.explorerUrl}/tx/${txHash}`;
|
|
507
|
+
case 'svm':
|
|
508
|
+
case 'solana': // @deprecated
|
|
509
|
+
return `${chain.explorerUrl}/tx/${txHash}`;
|
|
510
|
+
case 'stellar':
|
|
511
|
+
return `${chain.explorerUrl}/tx/${txHash}`;
|
|
512
|
+
case 'near':
|
|
513
|
+
return `${chain.explorerUrl}/txns/${txHash}`;
|
|
514
|
+
default:
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Format address URL for block explorer
|
|
521
|
+
*/
|
|
522
|
+
export function getExplorerAddressUrl(chainName: string, address: string): string | null {
|
|
523
|
+
const chain = getChainByName(chainName);
|
|
524
|
+
if (!chain) return null;
|
|
525
|
+
|
|
526
|
+
switch (chain.networkType) {
|
|
527
|
+
case 'evm':
|
|
528
|
+
return `${chain.explorerUrl}/address/${address}`;
|
|
529
|
+
case 'svm':
|
|
530
|
+
case 'solana': // @deprecated
|
|
531
|
+
return `${chain.explorerUrl}/account/${address}`;
|
|
532
|
+
case 'stellar':
|
|
533
|
+
return `${chain.explorerUrl}/account/${address}`;
|
|
534
|
+
case 'near':
|
|
535
|
+
return `${chain.explorerUrl}/address/${address}`;
|
|
536
|
+
default:
|
|
537
|
+
return null;
|
|
538
|
+
}
|
|
539
|
+
}
|