@tomo-inc/chains-service 0.0.2

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/README.md +15 -0
  3. package/package.json +38 -0
  4. package/project.json +59 -0
  5. package/src/api/__tests__/config.ts +21 -0
  6. package/src/api/__tests__/token.test.ts +120 -0
  7. package/src/api/__tests__/transaction.test.ts +86 -0
  8. package/src/api/__tests__/user.test.ts +105 -0
  9. package/src/api/__tests__/wallet.test.ts +73 -0
  10. package/src/api/base.ts +52 -0
  11. package/src/api/index.ts +24 -0
  12. package/src/api/network-data.ts +572 -0
  13. package/src/api/network.ts +81 -0
  14. package/src/api/token.ts +182 -0
  15. package/src/api/transaction.ts +59 -0
  16. package/src/api/types/common.ts +35 -0
  17. package/src/api/types/index.ts +13 -0
  18. package/src/api/types/type.ts +283 -0
  19. package/src/api/user.ts +83 -0
  20. package/src/api/utils/index.ts +34 -0
  21. package/src/api/utils/signature.ts +60 -0
  22. package/src/api/wallet.ts +57 -0
  23. package/src/base/network.ts +55 -0
  24. package/src/base/service.ts +33 -0
  25. package/src/base/token.ts +43 -0
  26. package/src/base/transaction.ts +58 -0
  27. package/src/config.ts +21 -0
  28. package/src/dogecoin/base.ts +39 -0
  29. package/src/dogecoin/config.ts +43 -0
  30. package/src/dogecoin/rpc.ts +449 -0
  31. package/src/dogecoin/service.ts +451 -0
  32. package/src/dogecoin/type.ts +29 -0
  33. package/src/dogecoin/utils-doge.ts +105 -0
  34. package/src/dogecoin/utils.ts +601 -0
  35. package/src/evm/rpc.ts +68 -0
  36. package/src/evm/service.ts +403 -0
  37. package/src/evm/utils.ts +92 -0
  38. package/src/index.ts +28 -0
  39. package/src/solana/config.ts +5 -0
  40. package/src/solana/service.ts +312 -0
  41. package/src/solana/types.ts +91 -0
  42. package/src/solana/utils.ts +635 -0
  43. package/src/types/account.ts +58 -0
  44. package/src/types/dapp.ts +7 -0
  45. package/src/types/gas.ts +53 -0
  46. package/src/types/index.ts +81 -0
  47. package/src/types/network.ts +66 -0
  48. package/src/types/tx.ts +181 -0
  49. package/src/types/wallet.ts +49 -0
  50. package/src/wallet.ts +96 -0
  51. package/tsconfig.json +14 -0
  52. package/tsup.config.ts +18 -0
@@ -0,0 +1,572 @@
1
+ export const loadNetworks = (WALLET_DOMAIN: string) => {
2
+ return [
3
+ {
4
+ chainId: 0,
5
+ chainIndex: 0,
6
+ name: "BITCOIN",
7
+ chainName: "Bitcoin",
8
+ nativeCurrencyName: "BTC",
9
+ nativeCurrencySymbol: "BTC",
10
+ nativeCurrencyDecimals: 8,
11
+ platformType: "BTC",
12
+ icon: "https://static.tomo.inc/token/btc.svg",
13
+ supportSwap: true,
14
+ supportGift: false,
15
+ supportHistory: true,
16
+ },
17
+ {
18
+ chainId: 3,
19
+ chainIndex: 300,
20
+ name: "DOGECOIN",
21
+ chainName: "Dogecoin",
22
+ nativeCurrencyName: "DOGE",
23
+ nativeCurrencySymbol: "DOGE",
24
+ nativeCurrencyDecimals: 8,
25
+ blockExplorerUrl: "https://dogechain.info",
26
+ platformType: "DOGE",
27
+ icon: "https://static.tomo.inc/token/doge.svg",
28
+ supportSwap: false,
29
+ supportGift: true,
30
+ supportHistory: false,
31
+ },
32
+ {
33
+ chainId: 221122420,
34
+ chainIndex: 22112242000,
35
+ name: "DOGEOS_DEVNET",
36
+ chainName: "DogeOS Devnet",
37
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/doge_test`],
38
+ blockExplorerUrl: "https://blockscout.devnet.doge.xyz",
39
+ platformType: "EVM",
40
+ isTestnet: true,
41
+ icon: "/assets/dogeos.svg",
42
+ supportSwap: true,
43
+ supportGift: false,
44
+ supportHistory: false,
45
+ },
46
+ {
47
+ chainId: 1,
48
+ chainIndex: 100,
49
+ name: "ETH",
50
+ chainName: "Ethereum",
51
+ nativeCurrencyName: "ETH",
52
+ nativeCurrencySymbol: "ETH",
53
+ nativeCurrencyDecimals: 18,
54
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/eth`],
55
+ blockExplorerUrl: "https://etherscan.io",
56
+ platformType: "EVM",
57
+ icon: "https://static.tomo.inc/token/eth_new.svg",
58
+ supportSwap: true,
59
+ supportGift: true,
60
+ supportHistory: true,
61
+ },
62
+ {
63
+ chainId: 501,
64
+ chainIndex: 50100,
65
+ name: "SOLANA",
66
+ chainName: "Solana",
67
+ nativeCurrencyName: "SOL",
68
+ nativeCurrencySymbol: "SOL",
69
+ nativeCurrencyDecimals: 9,
70
+ rpcUrls: [
71
+ "https://FLORAL-YOLO-DAYLIGHT.solana-mainnet.quiknode.pro/78b0cda5969b12967ac69cde74e0937ed285d6e5",
72
+ "https://mainnet.helius-rpc.com/?api-key=ac6f0298-d53b-4a04-8389-7966584a67d1",
73
+ "https://empty-smart-wildflower.solana-mainnet.quiknode.pro/ebfb8013883fffdaf5a64952fd6c8b2b2bf3cea8",
74
+ ],
75
+ blockExplorerUrl: "https://solscan.io",
76
+ platformType: "SOLANA",
77
+ icon: "https://static.tomo.inc/token/sol.svg",
78
+ supportSwap: true,
79
+ supportGift: true,
80
+ supportHistory: true,
81
+ },
82
+ {
83
+ chainId: 56,
84
+ chainIndex: 5600,
85
+ name: "BSC",
86
+ chainName: "BNB Chain",
87
+ nativeCurrencyName: "BNB",
88
+ nativeCurrencySymbol: "BNB",
89
+ nativeCurrencyDecimals: 18,
90
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/bsc`],
91
+ blockExplorerUrl: "https://bscscan.com",
92
+ platformType: "EVM",
93
+ icon: "https://static.tomo.inc/token/bsc_new.svg",
94
+ supportSwap: true,
95
+ supportGift: true,
96
+ supportHistory: true,
97
+ },
98
+ {
99
+ chainId: 8453,
100
+ chainIndex: 845300,
101
+ name: "BASE",
102
+ chainName: "Base",
103
+ nativeCurrencyName: "BASE_ETH",
104
+ nativeCurrencySymbol: "ETH",
105
+ nativeCurrencyDecimals: 18,
106
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/base`],
107
+ blockExplorerUrl: "https://base.blockscout.com",
108
+ platformType: "EVM",
109
+ icon: "https://static.tomo.inc/token/base.svg",
110
+ supportSwap: true,
111
+ supportGift: true,
112
+ supportHistory: true,
113
+ },
114
+ {
115
+ chainId: 1100,
116
+ chainIndex: 110000,
117
+ name: "TON",
118
+ chainName: "TON",
119
+ nativeCurrencyName: "TON",
120
+ nativeCurrencySymbol: "TON",
121
+ nativeCurrencyDecimals: 9,
122
+ platformType: "TON",
123
+ icon: "https://static.tomo.inc/token/ton.svg",
124
+ supportSwap: true,
125
+ supportGift: true,
126
+ supportHistory: false,
127
+ },
128
+ {
129
+ chainId: 784,
130
+ chainIndex: 78400,
131
+ name: "SUI",
132
+ chainName: "SUI",
133
+ nativeCurrencyName: "SUI",
134
+ nativeCurrencySymbol: "SUI",
135
+ nativeCurrencyDecimals: 9,
136
+ platformType: "SUI",
137
+ icon: "https://static.tomo.inc/token/sui.svg",
138
+ supportSwap: true,
139
+ supportGift: true,
140
+ supportHistory: true,
141
+ },
142
+ {
143
+ chainId: 42161,
144
+ chainIndex: 4216100,
145
+ name: "ARBITRUM",
146
+ chainName: "Arbitrum One",
147
+ nativeCurrencyName: "ARB_ETH",
148
+ nativeCurrencySymbol: "ETH",
149
+ nativeCurrencyDecimals: 18,
150
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/arbitrum_one`],
151
+ blockExplorerUrl: "https://arbiscan.io",
152
+ platformType: "EVM",
153
+ icon: "https://static.tomo.inc/token/arb.jpeg",
154
+ supportSwap: true,
155
+ supportGift: true,
156
+ supportHistory: true,
157
+ },
158
+ {
159
+ chainId: 59144,
160
+ chainIndex: 5914400,
161
+ name: "LINEA",
162
+ chainName: "Linea",
163
+ nativeCurrencyName: "LINEA_ETH",
164
+ nativeCurrencySymbol: "ETH",
165
+ nativeCurrencyDecimals: 18,
166
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/linea`],
167
+ blockExplorerUrl: "https://lineascan.build",
168
+ platformType: "EVM",
169
+ icon: "https://static.tomo.inc/token/linea.svg",
170
+ supportSwap: true,
171
+ supportGift: true,
172
+ supportHistory: true,
173
+ },
174
+ {
175
+ chainId: 10,
176
+ chainIndex: 1000,
177
+ name: "OPTIMISM",
178
+ chainName: "Optimism",
179
+ nativeCurrencyName: "OP_ETH",
180
+ nativeCurrencySymbol: "ETH",
181
+ nativeCurrencyDecimals: 18,
182
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/optimism`],
183
+ blockExplorerUrl: "https://optimistic.etherscan.io",
184
+ platformType: "EVM",
185
+ icon: "https://static.tomo.inc/token/op.svg",
186
+ supportSwap: true,
187
+ supportGift: true,
188
+ supportHistory: true,
189
+ },
190
+ {
191
+ chainId: 137,
192
+ chainIndex: 13700,
193
+ name: "POLYGON_POS",
194
+ chainName: "Polygon",
195
+ nativeCurrencyName: "POL",
196
+ nativeCurrencySymbol: "POL",
197
+ nativeCurrencyDecimals: 18,
198
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/polygon`],
199
+ blockExplorerUrl: "https://polygonscan.com",
200
+ platformType: "EVM",
201
+ icon: "https://static.tomo.inc/token/polygon.svg",
202
+ supportSwap: true,
203
+ supportGift: true,
204
+ supportHistory: true,
205
+ },
206
+ {
207
+ chainId: 81457,
208
+ chainIndex: 8145700,
209
+ name: "BLAST",
210
+ chainName: "Blast",
211
+ nativeCurrencyName: "BLAST_ETH",
212
+ nativeCurrencySymbol: "ETH",
213
+ nativeCurrencyDecimals: 18,
214
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/blast`],
215
+ blockExplorerUrl: "https://blastscan.io",
216
+ platformType: "EVM",
217
+ icon: "https://static.tomo.inc/token/blast.svg",
218
+ supportSwap: true,
219
+ supportGift: true,
220
+ supportHistory: true,
221
+ },
222
+ {
223
+ chainId: 534352,
224
+ chainIndex: 53435200,
225
+ name: "SCROLL",
226
+ chainName: "Scroll",
227
+ nativeCurrencyName: "SCROLL_ETH",
228
+ nativeCurrencySymbol: "ETH",
229
+ nativeCurrencyDecimals: 18,
230
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/scroll`],
231
+ blockExplorerUrl: "https://scrollscan.com",
232
+ platformType: "EVM",
233
+ icon: "https://static.tomo.inc/token/scroll.svg",
234
+ supportSwap: true,
235
+ supportGift: true,
236
+ supportHistory: true,
237
+ },
238
+ {
239
+ chainId: 43114,
240
+ chainIndex: 4311400,
241
+ name: "AVAX",
242
+ chainName: "Avalanche C",
243
+ nativeCurrencyName: "AVAX",
244
+ nativeCurrencySymbol: "AVAX",
245
+ nativeCurrencyDecimals: 18,
246
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/avalanche`],
247
+ blockExplorerUrl: "https://snowtrace.io",
248
+ platformType: "EVM",
249
+ icon: "https://static.tomo.inc/token/avalanche.svg",
250
+ supportSwap: true,
251
+ supportGift: false,
252
+ supportHistory: true,
253
+ },
254
+ {
255
+ chainId: 324,
256
+ chainIndex: 32400,
257
+ name: "ZKSYNC",
258
+ chainName: "zkSync Era",
259
+ nativeCurrencyName: "ZKSYNC_ETH",
260
+ nativeCurrencySymbol: "ETH",
261
+ nativeCurrencyDecimals: 18,
262
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/zk_sync`],
263
+ blockExplorerUrl: "https://mainnet.era.zksync.io",
264
+ platformType: "EVM",
265
+ icon: "https://static.tomo.inc/token/zksync.png",
266
+ supportSwap: false,
267
+ supportGift: false,
268
+ supportHistory: true,
269
+ },
270
+ {
271
+ chainId: 60808,
272
+ chainIndex: 6080800,
273
+ name: "BOB",
274
+ chainName: "BOB",
275
+ nativeCurrencyName: "BOB_ETH",
276
+ nativeCurrencySymbol: "ETH",
277
+ nativeCurrencyDecimals: 18,
278
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/bob`],
279
+ blockExplorerUrl: "https://rpc.gobob.xyz",
280
+ platformType: "EVM",
281
+ icon: "https://static.tomo.inc/token/bob.png",
282
+ supportSwap: false,
283
+ supportGift: false,
284
+ supportHistory: true,
285
+ },
286
+ {
287
+ chainId: 8333,
288
+ chainIndex: 833300,
289
+ name: "B3",
290
+ chainName: "B3 Mainnet",
291
+ nativeCurrencyName: "B3_ETH",
292
+ nativeCurrencySymbol: "ETH",
293
+ nativeCurrencyDecimals: 18,
294
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/b3`],
295
+ blockExplorerUrl: "https://mainnet-rpc.b3.fun/http",
296
+ platformType: "EVM",
297
+ icon: "https://static.tomo.inc/token/b3.svg",
298
+ supportSwap: false,
299
+ supportGift: true,
300
+ supportHistory: false,
301
+ },
302
+ {
303
+ chainId: 223,
304
+ chainIndex: 22300,
305
+ name: "B2",
306
+ chainName: "B² Network",
307
+ nativeCurrencyName: "B2_BTC",
308
+ nativeCurrencySymbol: "BTC",
309
+ nativeCurrencyDecimals: 18,
310
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/b2`],
311
+ blockExplorerUrl: "https://explorer.bsquared.network",
312
+ platformType: "EVM",
313
+ icon: "https://static.tomo.inc/token/b2.svg",
314
+ supportSwap: false,
315
+ supportGift: true,
316
+ supportHistory: false,
317
+ },
318
+ {
319
+ chainId: 200901,
320
+ chainIndex: 20090100,
321
+ name: "BITLAYER",
322
+ chainName: "Bitlayer",
323
+ nativeCurrencyName: "BITLAYER_BTC",
324
+ nativeCurrencySymbol: "BTC",
325
+ nativeCurrencyDecimals: 18,
326
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/bit_layer`],
327
+ blockExplorerUrl: "https://rpc.bitlayer.org",
328
+ platformType: "EVM",
329
+ icon: "https://static.tomo.inc/token/bitlayer.svg",
330
+ supportSwap: false,
331
+ supportGift: true,
332
+ supportHistory: true,
333
+ },
334
+ {
335
+ chainId: 19484,
336
+ chainIndex: 1948400,
337
+ name: "TRON",
338
+ chainName: "Tron",
339
+ nativeCurrencyName: "TRX",
340
+ nativeCurrencySymbol: "TRX",
341
+ nativeCurrencyDecimals: 6,
342
+ platformType: "TRON",
343
+ blockExplorerUrl: "https://tronscan.org",
344
+ icon: "https://static.tomo.inc/token/tron.svg",
345
+ supportSwap: true,
346
+ supportGift: false,
347
+ supportHistory: true,
348
+ },
349
+ {
350
+ chainId: 4,
351
+ chainIndex: 400,
352
+ name: "COSMOS_HUB",
353
+ chainName: "Cosmos Hub",
354
+ nativeCurrencyName: "ATOM",
355
+ nativeCurrencySymbol: "ATOM",
356
+ nativeCurrencyDecimals: 6,
357
+ platformType: "COSMOS",
358
+ icon: "https://static.tomo.inc/token/cosmos.png",
359
+ supportSwap: false,
360
+ supportGift: false,
361
+ supportHistory: false,
362
+ },
363
+ {
364
+ chainId: 5545,
365
+ chainIndex: 554500,
366
+ name: "DUCKCHAIN",
367
+ chainName: "DuckChain Mainnet",
368
+ nativeCurrencyName: "DUCKCHAIN_TON",
369
+ nativeCurrencySymbol: "TON",
370
+ nativeCurrencyDecimals: 18,
371
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/duck`],
372
+ blockExplorerUrl: "https://scan.duckchain.io",
373
+ platformType: "EVM",
374
+ icon: "https://static.tomo.inc/token/duckchain.svg",
375
+ supportSwap: false,
376
+ supportGift: true,
377
+ supportHistory: false,
378
+ },
379
+ {
380
+ chainId: 47763,
381
+ chainIndex: 4776300,
382
+ name: "NEOX",
383
+ chainName: "Neo X Mainnet",
384
+ nativeCurrencyName: "GAS",
385
+ nativeCurrencySymbol: "GAS",
386
+ nativeCurrencyDecimals: 18,
387
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/neox`],
388
+ blockExplorerUrl: "https://neotube.io",
389
+ platformType: "EVM",
390
+ icon: "https://static.tomo.inc/token/neo.jpg",
391
+ supportSwap: false,
392
+ supportGift: false,
393
+ supportHistory: false,
394
+ },
395
+ {
396
+ chainId: 4200,
397
+ chainIndex: 420000,
398
+ name: "MERLIN",
399
+ chainName: "Merlin Chain",
400
+ nativeCurrencyName: "MERLIN_BTC",
401
+ nativeCurrencySymbol: "BTC",
402
+ nativeCurrencyDecimals: 18,
403
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/merlin`],
404
+ blockExplorerUrl: "https://scan.merlinchain.io",
405
+ platformType: "EVM",
406
+ icon: "https://static.tomo.inc/token/merlin.png",
407
+ supportSwap: false,
408
+ supportGift: true,
409
+ supportHistory: true,
410
+ },
411
+ {
412
+ chainId: 1329,
413
+ chainIndex: 132900,
414
+ name: "SEI",
415
+ chainName: "Sei EVM",
416
+ nativeCurrencyName: "SEI",
417
+ nativeCurrencySymbol: "SEI",
418
+ nativeCurrencyDecimals: 18,
419
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/sei`],
420
+ blockExplorerUrl: "https://seitrace.com",
421
+ platformType: "EVM",
422
+ icon: "https://static.tomo.inc/token/sei.svg",
423
+ supportSwap: false,
424
+ supportGift: false,
425
+ supportHistory: false,
426
+ },
427
+ {
428
+ chainId: 480,
429
+ chainIndex: 48000,
430
+ name: "WORLD_CHAIN",
431
+ chainName: "World Chain",
432
+ nativeCurrencyName: "WORLDCHAIN_ETH",
433
+ nativeCurrencySymbol: "ETH",
434
+ nativeCurrencyDecimals: 18,
435
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/world`],
436
+ blockExplorerUrl: "https://worldchain-mainnet.explorer.alchemy.com",
437
+ platformType: "EVM",
438
+ icon: "https://static.tomo.inc/token/world-chain.jpg",
439
+ supportSwap: false,
440
+ supportGift: false,
441
+ supportHistory: false,
442
+ },
443
+ {
444
+ chainId: 2649,
445
+ chainIndex: 264900,
446
+ name: "AILAYER",
447
+ chainName: "AILayer",
448
+ nativeCurrencyName: "AILAYER_BTC",
449
+ nativeCurrencySymbol: "BTC",
450
+ nativeCurrencyDecimals: 18,
451
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/ai_layer`],
452
+ blockExplorerUrl: "https://mainnet-explorer.ailayer.xyz",
453
+ platformType: "EVM",
454
+ icon: "https://static.tomo.inc/token/ailayer.svg",
455
+ supportSwap: false,
456
+ supportGift: true,
457
+ supportHistory: false,
458
+ },
459
+ {
460
+ chainId: 227,
461
+ chainIndex: 22700,
462
+ name: "PROM",
463
+ chainName: "Prom",
464
+ nativeCurrencyName: "PROM",
465
+ nativeCurrencySymbol: "PROM",
466
+ nativeCurrencyDecimals: 18,
467
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/prom_test`],
468
+ blockExplorerUrl: "https://promscan.io",
469
+ platformType: "EVM",
470
+ icon: "https://static.tomo.inc/token/prom-testnet.svg",
471
+ supportSwap: false,
472
+ supportGift: false,
473
+ supportHistory: false,
474
+ },
475
+ {
476
+ chainId: 1625,
477
+ chainIndex: 162500,
478
+ name: "GRAVITY",
479
+ chainName: "Gravity Alpha",
480
+ nativeCurrencyName: "G",
481
+ nativeCurrencySymbol: "G",
482
+ nativeCurrencyDecimals: 18,
483
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/gravity`],
484
+ blockExplorerUrl: "https://explorer.gravity.xyz",
485
+ platformType: "EVM",
486
+ icon: "https://static.tomo.inc/token/gravity.jpg",
487
+ supportSwap: false,
488
+ supportGift: true,
489
+ supportHistory: false,
490
+ },
491
+ {
492
+ chainId: 204,
493
+ chainIndex: 20400,
494
+ name: "OPBNB",
495
+ chainName: "opBNB",
496
+ nativeCurrencyName: "OP_BNB",
497
+ nativeCurrencySymbol: "BNB",
498
+ nativeCurrencyDecimals: 18,
499
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/op_bnb`],
500
+ blockExplorerUrl: "https://opbnb.bscscan.com",
501
+ platformType: "EVM",
502
+ icon: "https://static.tomo.inc/token/opbnb.svg",
503
+ supportSwap: false,
504
+ supportGift: false,
505
+ supportHistory: false,
506
+ },
507
+ {
508
+ chainId: 21000000,
509
+ chainIndex: 2100000000,
510
+ name: "CORN",
511
+ chainName: "Corn",
512
+ nativeCurrencyName: "BTCN",
513
+ nativeCurrencySymbol: "BTCN",
514
+ nativeCurrencyDecimals: 18,
515
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/corn`],
516
+ blockExplorerUrl: "https://maizenet-explorer.usecorn.com",
517
+ platformType: "EVM",
518
+ icon: "https://static.tomo.inc/token/corn-logo.svg",
519
+ supportSwap: false,
520
+ supportGift: true,
521
+ supportHistory: false,
522
+ },
523
+ {
524
+ chainId: 126,
525
+ chainIndex: 12600,
526
+ name: "MOVEMENT_MAINNET",
527
+ chainName: "Movement Mainnet",
528
+ nativeCurrencyName: "MOVE",
529
+ nativeCurrencySymbol: "MOVE",
530
+ nativeCurrencyDecimals: 8,
531
+ rpcUrls: ["https://mainnet.movementnetwork.xyz/v1"],
532
+ blockExplorerUrl: "https://explorer.movementnetwork.xyz",
533
+ platformType: "APTOS",
534
+ icon: "https://static.tomo.inc/token/movement.svg",
535
+ supportSwap: false,
536
+ supportGift: false,
537
+ supportHistory: false,
538
+ },
539
+ {
540
+ chainId: 80094,
541
+ chainIndex: 8009400,
542
+ name: "BERACHAIN_MAINNET",
543
+ chainName: "Berachain Mainnet",
544
+ nativeCurrencyName: "BERA Token",
545
+ nativeCurrencySymbol: "BERA",
546
+ nativeCurrencyDecimals: 18,
547
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/bera`],
548
+ blockExplorerUrl: "https://berascan.com",
549
+ platformType: "EVM",
550
+ icon: "https://static.tomo.inc/token/berachain.svg",
551
+ supportSwap: false,
552
+ supportGift: false,
553
+ supportHistory: false,
554
+ },
555
+ {
556
+ chainId: 1514,
557
+ chainIndex: 151400,
558
+ name: "STORY_MAINNET",
559
+ chainName: "Story Mainnet",
560
+ nativeCurrencyName: "IP",
561
+ nativeCurrencySymbol: "IP",
562
+ nativeCurrencyDecimals: 18,
563
+ rpcUrls: [`${WALLET_DOMAIN}/rpc/v1/story`],
564
+ blockExplorerUrl: "https://mainnet.storyscan.xyz",
565
+ platformType: "EVM",
566
+ icon: "https://static.tomo.inc/token/story.jpg",
567
+ supportSwap: false,
568
+ supportGift: false,
569
+ supportHistory: false,
570
+ },
571
+ ];
572
+ };
@@ -0,0 +1,81 @@
1
+ import { ChainTypes, SupportedChainTypes } from "@tomo-inc/wallet-utils";
2
+ import { loadNetworks } from "./network-data";
3
+ import { BasePublicService } from "./base";
4
+ import { IPublicApiBaseConfig } from "./types";
5
+ import { INetwork, TomoAppInfo } from "../types";
6
+
7
+ import { cache } from "@tomo-inc/wallet-utils";
8
+
9
+ export class NetworkAPIs extends BasePublicService {
10
+ private static instance: NetworkAPIs;
11
+ public chains: INetwork[] = [];
12
+ public currentChainId: string = "1";
13
+
14
+ private constructor(apiBase: IPublicApiBaseConfig, tomoAppInfo: TomoAppInfo) {
15
+ super(apiBase, tomoAppInfo);
16
+ const chains = loadNetworks(apiBase.rpcBaseUrl);
17
+
18
+ this.chains = chains.map((chain) => {
19
+ const nativeCurrency = {
20
+ symbol: chain.nativeCurrencySymbol || "",
21
+ decimals: chain.nativeCurrencyDecimals || 18,
22
+ name: chain.nativeCurrencyName || "",
23
+ };
24
+ delete chain.nativeCurrencySymbol;
25
+ delete chain.nativeCurrencyDecimals;
26
+ delete chain.nativeCurrencyName;
27
+ return {
28
+ ...chain,
29
+ nativeCurrency,
30
+ };
31
+ });
32
+
33
+ this.currentChainId = "1";
34
+ }
35
+
36
+ public static getInstance(apiBase: IPublicApiBaseConfig, tomoAppInfo: TomoAppInfo) {
37
+ if (!this.instance) {
38
+ this.instance = new NetworkAPIs(apiBase, tomoAppInfo);
39
+ }
40
+ return this.instance;
41
+ }
42
+
43
+ public getCacheId(chainType: ChainTypes | ""): string {
44
+ return `tomo-${chainType}-currentChainId`;
45
+ }
46
+
47
+ public getAllNetworks(chainType: ChainTypes | ""): any[] {
48
+ if (chainType === "") {
49
+ return this.chains;
50
+ }
51
+ return this.chains.filter((chain) => chain.platformType === chainType.toUpperCase());
52
+ }
53
+
54
+ public async getCurrentNetwork(chainType: ChainTypes): Promise<string> {
55
+ if (!SupportedChainTypes?.[chainType]) {
56
+ throw new Error(`Chain ${chainType} is not supported`);
57
+ }
58
+
59
+ const cacheId = this.getCacheId(chainType);
60
+ const currentChainId = cache.get(cacheId);
61
+ return currentChainId || SupportedChainTypes?.[chainType]?.chainId || this.currentChainId || "";
62
+ }
63
+
64
+ public async setCurrentNetwork(chainType: ChainTypes | "", chainId: string): Promise<void> {
65
+ if (chainType && !SupportedChainTypes?.[chainType]) {
66
+ throw new Error(`Chain ${chainType} is not supported`);
67
+ }
68
+ this.currentChainId = chainId;
69
+ const cacheId = this.getCacheId(chainType);
70
+ const isTemp = false;
71
+ cache.set(cacheId, chainId, isTemp);
72
+ }
73
+
74
+ public getNetworkByChainId(chainId: string) {
75
+ return this.chains.find((chain) => chain.chainId === Number(chainId));
76
+ }
77
+
78
+ public getNetworkByChainIndex(chainIndex: number) {
79
+ return this.chains.find((chain) => chain.chainIndex === chainIndex);
80
+ }
81
+ }