@lifi/data-types 4.10.5 → 5.0.0-beta.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 (132) hide show
  1. package/package.json +28 -69
  2. package/{dist/cjs → src/_cjs}/chains/index.js +4 -16
  3. package/src/_cjs/chains/index.js.map +1 -0
  4. package/src/_cjs/chains/supportedChains.evm.int.spec.js +33 -0
  5. package/src/_cjs/chains/supportedChains.evm.int.spec.js.map +1 -0
  6. package/{dist/cjs → src/_cjs}/chains/supportedChains.evm.js +132 -302
  7. package/src/_cjs/chains/supportedChains.evm.js.map +1 -0
  8. package/{dist/cjs → src/_cjs}/chains/supportedChains.js +1 -3
  9. package/src/_cjs/chains/supportedChains.js.map +1 -0
  10. package/src/_cjs/chains/supportedChains.svm.int.spec.js +45 -0
  11. package/src/_cjs/chains/supportedChains.svm.int.spec.js.map +1 -0
  12. package/{dist/cjs → src/_cjs}/chains/supportedChains.svm.js +5 -1
  13. package/src/_cjs/chains/supportedChains.svm.js.map +1 -0
  14. package/src/_cjs/chains/supportedChains.unit.spec.js +87 -0
  15. package/src/_cjs/chains/supportedChains.unit.spec.js.map +1 -0
  16. package/src/_cjs/chains/supportedChains.utxo.int.spec.js +43 -0
  17. package/src/_cjs/chains/supportedChains.utxo.int.spec.js.map +1 -0
  18. package/{dist/cjs → src/_cjs}/chains/supportedChains.utxo.js +5 -7
  19. package/src/_cjs/chains/supportedChains.utxo.js.map +1 -0
  20. package/{dist/cjs → src/_cjs}/chains/utils.js +1 -0
  21. package/src/_cjs/chains/utils.js.map +1 -0
  22. package/src/_cjs/coins/coins.int.spec.js +21 -0
  23. package/src/_cjs/coins/coins.int.spec.js.map +1 -0
  24. package/{dist/cjs → src/_cjs}/coins/coins.js +5 -79
  25. package/src/_cjs/coins/coins.js.map +1 -0
  26. package/src/_cjs/coins/index.js +5 -0
  27. package/src/_cjs/coins/index.js.map +1 -0
  28. package/src/_cjs/index.js +7 -0
  29. package/src/_cjs/index.js.map +1 -0
  30. package/{dist/cjs → src/_cjs}/multicall.js +1 -26
  31. package/src/_cjs/multicall.js.map +1 -0
  32. package/src/_cjs/package.json +1 -0
  33. package/{dist → src/_esm}/chains/index.js +1 -0
  34. package/src/_esm/chains/index.js.map +1 -0
  35. package/src/_esm/chains/supportedChains.evm.int.spec.js +31 -0
  36. package/src/_esm/chains/supportedChains.evm.int.spec.js.map +1 -0
  37. package/{dist → src/_esm}/chains/supportedChains.evm.js +139 -266
  38. package/src/_esm/chains/supportedChains.evm.js.map +1 -0
  39. package/{dist → src/_esm}/chains/supportedChains.js +1 -0
  40. package/src/_esm/chains/supportedChains.js.map +1 -0
  41. package/src/_esm/chains/supportedChains.svm.int.spec.js +43 -0
  42. package/src/_esm/chains/supportedChains.svm.int.spec.js.map +1 -0
  43. package/{dist → src/_esm}/chains/supportedChains.svm.js +6 -2
  44. package/src/_esm/chains/supportedChains.svm.js.map +1 -0
  45. package/{dist → src/_esm}/chains/supportedChains.unit.spec.js +7 -3
  46. package/src/_esm/chains/supportedChains.unit.spec.js.map +1 -0
  47. package/src/_esm/chains/supportedChains.utxo.int.spec.js +41 -0
  48. package/src/_esm/chains/supportedChains.utxo.int.spec.js.map +1 -0
  49. package/{dist → src/_esm}/chains/supportedChains.utxo.js +6 -8
  50. package/src/_esm/chains/supportedChains.utxo.js.map +1 -0
  51. package/{dist → src/_esm}/chains/utils.js +1 -0
  52. package/src/_esm/chains/utils.js.map +1 -0
  53. package/src/_esm/coins/coins.int.spec.js +21 -0
  54. package/src/_esm/coins/coins.int.spec.js.map +1 -0
  55. package/{dist → src/_esm}/coins/coins.js +6 -8
  56. package/src/_esm/coins/coins.js.map +1 -0
  57. package/src/_esm/coins/index.js +2 -0
  58. package/src/_esm/coins/index.js.map +1 -0
  59. package/{dist → src/_esm}/index.js +1 -0
  60. package/src/_esm/index.js.map +1 -0
  61. package/{dist → src/_esm}/multicall.js +17 -16
  62. package/src/_esm/multicall.js.map +1 -0
  63. package/src/_esm/package.json +1 -0
  64. package/{dist → src/_types}/chains/index.d.ts +1 -0
  65. package/src/_types/chains/index.d.ts.map +1 -0
  66. package/{dist/cjs → src/_types}/chains/supportedChains.d.ts +2 -1
  67. package/src/_types/chains/supportedChains.d.ts.map +1 -0
  68. package/src/_types/chains/supportedChains.evm.d.ts +9 -0
  69. package/src/_types/chains/supportedChains.evm.d.ts.map +1 -0
  70. package/src/_types/chains/supportedChains.evm.int.spec.d.ts +2 -0
  71. package/src/_types/chains/supportedChains.evm.int.spec.d.ts.map +1 -0
  72. package/src/_types/chains/supportedChains.svm.d.ts +3 -0
  73. package/src/_types/chains/supportedChains.svm.d.ts.map +1 -0
  74. package/src/_types/chains/supportedChains.svm.int.spec.d.ts +2 -0
  75. package/src/_types/chains/supportedChains.svm.int.spec.d.ts.map +1 -0
  76. package/src/_types/chains/supportedChains.unit.spec.d.ts +2 -0
  77. package/src/_types/chains/supportedChains.unit.spec.d.ts.map +1 -0
  78. package/src/_types/chains/supportedChains.utxo.d.ts +3 -0
  79. package/src/_types/chains/supportedChains.utxo.d.ts.map +1 -0
  80. package/src/_types/chains/supportedChains.utxo.int.spec.d.ts +2 -0
  81. package/src/_types/chains/supportedChains.utxo.int.spec.d.ts.map +1 -0
  82. package/{dist → src/_types}/chains/utils.d.ts +1 -0
  83. package/src/_types/chains/utils.d.ts.map +1 -0
  84. package/{dist → src/_types}/coins/coins.d.ts +3 -1
  85. package/src/_types/coins/coins.d.ts.map +1 -0
  86. package/src/_types/coins/coins.int.spec.d.ts +2 -0
  87. package/src/_types/coins/coins.int.spec.d.ts.map +1 -0
  88. package/src/_types/coins/index.d.ts +2 -0
  89. package/src/_types/coins/index.d.ts.map +1 -0
  90. package/{dist → src/_types}/index.d.ts +1 -0
  91. package/src/_types/index.d.ts.map +1 -0
  92. package/{dist/cjs → src/_types}/multicall.d.ts +1 -0
  93. package/src/_types/multicall.d.ts.map +1 -0
  94. package/src/chains/index.ts +5 -0
  95. package/src/chains/supportedChains.evm.int.spec.ts +47 -0
  96. package/src/chains/supportedChains.evm.ts +902 -0
  97. package/src/chains/supportedChains.svm.int.spec.ts +60 -0
  98. package/src/chains/supportedChains.svm.ts +34 -0
  99. package/src/chains/supportedChains.ts +29 -0
  100. package/src/chains/supportedChains.unit.spec.ts +114 -0
  101. package/src/chains/supportedChains.utxo.int.spec.ts +56 -0
  102. package/src/chains/supportedChains.utxo.ts +93 -0
  103. package/src/chains/utils.ts +3 -0
  104. package/src/coins/coins.int.spec.ts +35 -0
  105. package/src/coins/coins.ts +1930 -0
  106. package/src/coins/index.ts +1 -0
  107. package/src/index.ts +3 -0
  108. package/src/multicall.ts +66 -0
  109. package/dist/chains/supportedChains.d.ts +0 -4
  110. package/dist/chains/supportedChains.evm.d.ts +0 -2
  111. package/dist/chains/supportedChains.svm.d.ts +0 -2
  112. package/dist/chains/supportedChains.unit.spec.d.ts +0 -1
  113. package/dist/chains/supportedChains.utxo.d.ts +0 -2
  114. package/dist/cjs/chains/index.d.ts +0 -5
  115. package/dist/cjs/chains/supportedChains.evm.d.ts +0 -2
  116. package/dist/cjs/chains/supportedChains.svm.d.ts +0 -2
  117. package/dist/cjs/chains/supportedChains.unit.spec.d.ts +0 -1
  118. package/dist/cjs/chains/supportedChains.unit.spec.js +0 -87
  119. package/dist/cjs/chains/supportedChains.utxo.d.ts +0 -2
  120. package/dist/cjs/chains/utils.d.ts +0 -1
  121. package/dist/cjs/coins/coins.d.ts +0 -26
  122. package/dist/cjs/coins/coins.int.spec.d.ts +0 -1
  123. package/dist/cjs/coins/coins.int.spec.js +0 -31
  124. package/dist/cjs/coins/index.d.ts +0 -1
  125. package/dist/cjs/coins/index.js +0 -17
  126. package/dist/cjs/index.d.ts +0 -3
  127. package/dist/cjs/index.js +0 -19
  128. package/dist/coins/coins.int.spec.d.ts +0 -1
  129. package/dist/coins/coins.int.spec.js +0 -29
  130. package/dist/coins/index.d.ts +0 -1
  131. package/dist/coins/index.js +0 -1
  132. package/dist/multicall.d.ts +0 -3
@@ -0,0 +1,60 @@
1
+ import { Connection, PublicKey } from '@solana/web3.js'
2
+ import { describe, expect, test } from 'vitest'
3
+ import { supportedSolanaChains } from './supportedChains.svm'
4
+
5
+ const TokenProgramAddress = 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
6
+ const WalletAddress = '6AUWsSCRFSCbrHKH9s84wfzJXtD6mNzAHs11x6pGEcmJ'
7
+
8
+ describe.concurrent('SVM chains RPC check', () => {
9
+ const rpcUrls = supportedSolanaChains.flatMap((chain) =>
10
+ chain.metamask.rpcUrls.map((rpcUrl) => ({
11
+ rpcUrl: rpcUrl,
12
+ chainId: chain.id,
13
+ chainName: chain.name,
14
+ }))
15
+ )
16
+
17
+ test.for(rpcUrls)(
18
+ `should successfully get chain ID from $chainName - $chainId RPC: $rpcUrl`,
19
+ { timeout: 10_000 },
20
+ async ({ rpcUrl }) => {
21
+ const connection = new Connection(rpcUrl)
22
+ const accountPublicKey = new PublicKey(WalletAddress)
23
+ const tokenProgramPublicKey = new PublicKey(TokenProgramAddress)
24
+ const [blockHeight, slot, balance, tokenAccountsByOwner] =
25
+ await Promise.allSettled([
26
+ connection.getBlockHeight(),
27
+ connection.getSlot(),
28
+ connection.getBalance(accountPublicKey),
29
+ connection.getParsedTokenAccountsByOwner(accountPublicKey, {
30
+ programId: tokenProgramPublicKey,
31
+ }),
32
+ ])
33
+ expect(blockHeight.status).toBe('fulfilled')
34
+ expect(slot.status).toBe('fulfilled')
35
+ expect(balance.status).toBe('fulfilled')
36
+ expect(tokenAccountsByOwner.status).toBe('fulfilled')
37
+ }
38
+ )
39
+ })
40
+
41
+ describe.concurrent('SVM chains block explorer check', () => {
42
+ const blockExplorerUrls = supportedSolanaChains.flatMap((chain) =>
43
+ chain.metamask.blockExplorerUrls.map((blockExplorerUrl) => ({
44
+ blockExplorerUrl: blockExplorerUrl,
45
+ chainId: chain.id,
46
+ chainName: chain.name,
47
+ }))
48
+ )
49
+
50
+ test.for(blockExplorerUrls)(
51
+ `block explorer should be alive $chainName - $chainId - $blockExplorerUrl`,
52
+ { timeout: 10_000 },
53
+ async ({ blockExplorerUrl }) => {
54
+ const response = await fetch(blockExplorerUrl)
55
+ expect(response.url).toBe(blockExplorerUrl)
56
+ expect(response.ok).toBe(true)
57
+ expect(response.status).toBe(200)
58
+ }
59
+ )
60
+ })
@@ -0,0 +1,34 @@
1
+ import type { SolanaChain } from '@lifi/types'
2
+ import { ChainId, ChainKey, ChainType, CoinKey } from '@lifi/types'
3
+
4
+ export const supportedSolanaChains: SolanaChain[] = [
5
+ {
6
+ key: ChainKey.SOL,
7
+ chainType: ChainType.SVM,
8
+ name: 'Solana',
9
+ coin: CoinKey.SOL,
10
+ id: ChainId.SOL,
11
+ mainnet: true,
12
+ logoURI:
13
+ 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/solana.svg',
14
+ faucetUrls: ['https://stakely.io/faucet/solana-sol'],
15
+ metamask: {
16
+ chainId: ChainId.SOL.toString(),
17
+ blockExplorerUrls: [
18
+ 'https://explorer.solana.com/',
19
+ 'https://solscan.io/',
20
+ 'https://solana.fm/',
21
+ ],
22
+ chainName: 'Solana',
23
+ nativeCurrency: {
24
+ name: 'SOL',
25
+ symbol: 'SOL',
26
+ decimals: 9,
27
+ },
28
+ rpcUrls: [
29
+ 'https://api.mainnet-beta.solana.com',
30
+ 'https://solana-rpc.publicnode.com',
31
+ ],
32
+ },
33
+ },
34
+ ]
@@ -0,0 +1,29 @@
1
+ import type { Chain, ChainKey } from '@lifi/types'
2
+ import { supportedEVMChains } from './supportedChains.evm'
3
+ import { supportedSolanaChains } from './supportedChains.svm'
4
+ import { supportedUXTOChains } from './supportedChains.utxo'
5
+
6
+ // This assignment is required to avoid breaking
7
+ // changes with the new non EVM support types release
8
+ // This will be removed in the future
9
+ export const supportedChains = [
10
+ ...supportedEVMChains,
11
+ ...supportedSolanaChains,
12
+ ...supportedUXTOChains,
13
+ ]
14
+
15
+ export const getChainByKey = (chainKey: ChainKey): Chain => {
16
+ const chain = supportedChains.find((c) => c.key === chainKey)
17
+ if (!chain) {
18
+ throw new Error('Invalid chainKey')
19
+ }
20
+ return chain
21
+ }
22
+
23
+ export const getChainById = (chainId: number): Chain => {
24
+ const chain = supportedChains.find((c) => c.id === chainId)
25
+ if (!chain) {
26
+ throw new Error('Invalid chainId')
27
+ }
28
+ return chain
29
+ }
@@ -0,0 +1,114 @@
1
+ import { ChainId, ChainKey, CoinKey } from '@lifi/types'
2
+ import { describe, expect, it, test } from 'vitest'
3
+ import {
4
+ findDefaultToken,
5
+ findTokenByChainIdAndAddress,
6
+ findWrappedGasOnChain,
7
+ } from '../coins'
8
+ import { getChainById, getChainByKey, supportedChains } from './supportedChains'
9
+ import { supportedEVMChains } from './supportedChains.evm'
10
+ import { prefixChainId } from './utils'
11
+
12
+ test('getChainById', () => {
13
+ expect(getChainById(ChainId.ETH)).toBeDefined()
14
+ })
15
+
16
+ test('getChainByKey', () => {
17
+ expect(getChainByKey(ChainKey.ETH)).toBeDefined()
18
+ })
19
+
20
+ test('native token defined for all chains', () => {
21
+ // currently unused chains
22
+ const ignoredChainsForNativeToken = [
23
+ ChainId.FSN,
24
+ ChainId.EXP,
25
+ ChainId.TCH,
26
+ ChainId.UBQ,
27
+ ChainId.MET,
28
+ ChainId.DIO,
29
+ ChainId.TLO,
30
+ ChainId.SHI,
31
+ ChainId.GL1,
32
+ ChainId.RSK,
33
+ ChainId.TBW,
34
+ ]
35
+ const ignoredChainsForWrappedToken = [
36
+ ...ignoredChainsForNativeToken,
37
+ ChainId.BTC,
38
+ ChainId.BCH,
39
+ ChainId.LTC,
40
+ ChainId.DGE,
41
+ ]
42
+ for (const chain of supportedChains) {
43
+ if (ignoredChainsForNativeToken.includes(chain.id)) {
44
+ continue
45
+ }
46
+
47
+ try {
48
+ const gasToken = findDefaultToken(chain.coin, chain.id)
49
+ expect(gasToken).toBeDefined()
50
+ } catch (e) {
51
+ throw new Error(`Failed to load gas token for ${chain.name}(${chain.id})`)
52
+ }
53
+ }
54
+
55
+ for (const chain of supportedChains) {
56
+ if (ignoredChainsForWrappedToken.includes(chain.id)) {
57
+ continue
58
+ }
59
+
60
+ try {
61
+ const wrappedGasToken = findWrappedGasOnChain(chain.id)
62
+ expect(wrappedGasToken).toBeDefined()
63
+ } catch (e) {
64
+ throw new Error(
65
+ `Failed to load wrapped gas token for ${chain.name}(${chain.id})`
66
+ )
67
+ }
68
+ }
69
+ })
70
+
71
+ describe('findTokenByChainIdAndAddress', () => {
72
+ describe('token has no name override', () => {
73
+ it('returns a token with the coin name', () => {
74
+ expect(
75
+ findTokenByChainIdAndAddress(
76
+ ChainId.LNA,
77
+ '0xa219439258ca9da29e9cc4ce5596924745e12b93'
78
+ )!.name
79
+ ).toEqual(CoinKey.USDT)
80
+ })
81
+ })
82
+
83
+ describe('token has a name override', () => {
84
+ it('returns a token with the overrode name', () => {
85
+ expect(
86
+ findTokenByChainIdAndAddress(
87
+ ChainId.SOL,
88
+ '33fsBLA8djQm82RpHmE3SuVrPGtZBWNYExsEUeKX1HXX'
89
+ )!.name
90
+ ).toEqual('Binance USD (Wormhole from Ethereum)')
91
+ })
92
+ })
93
+ })
94
+
95
+ describe('validate chains', () => {
96
+ supportedEVMChains.forEach((chain) => {
97
+ it(`validate chain ${chain.name}`, () => {
98
+ // blockExplorerUrls
99
+ expect(chain.metamask.blockExplorerUrls.length).toBeGreaterThan(0)
100
+ chain.metamask.blockExplorerUrls.forEach((blockExplorerUrl) => {
101
+ expect(blockExplorerUrl.startsWith('https://')).toBeTruthy()
102
+ expect(blockExplorerUrl.endsWith('/')).toBeTruthy()
103
+ })
104
+
105
+ const chainId = prefixChainId(chain.id)
106
+
107
+ // chain ids match
108
+ expect(chainId).toEqual(chain.metamask.chainId)
109
+
110
+ // rpcs defined
111
+ expect(chain.metamask.rpcUrls.length).toBeGreaterThan(0)
112
+ })
113
+ })
114
+ })
@@ -0,0 +1,56 @@
1
+ import { describe, expect, test } from 'vitest'
2
+ import { supportedUXTOChains } from './supportedChains.utxo'
3
+
4
+ describe.concurrent('UTXO chains RPC check', () => {
5
+ const rpcUrls = supportedUXTOChains.flatMap((chain) =>
6
+ chain.metamask.rpcUrls.map((rpcUrl) => ({
7
+ rpcUrl: rpcUrl,
8
+ chainId: chain.id,
9
+ chainName: chain.name,
10
+ }))
11
+ )
12
+
13
+ test.for(rpcUrls)(
14
+ `should successfully get chain ID from $chainName - $chainId RPC: $rpcUrl`,
15
+ { timeout: 10_000 },
16
+ async ({ rpcUrl }) => {
17
+ const response = await fetch(rpcUrl, {
18
+ method: 'POST',
19
+ headers: {
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ body: JSON.stringify({
23
+ jsonrpc: '1.0',
24
+ id: 'curltest',
25
+ method: 'getblockchaininfo',
26
+ params: [],
27
+ }),
28
+ })
29
+ const data = await response.json()
30
+ expect(response.ok).toBeTruthy()
31
+ expect(response.status).toBe(200)
32
+ expect(data.result.blocks).toBeGreaterThan(0)
33
+ }
34
+ )
35
+ })
36
+
37
+ describe.concurrent('UTXO chains block explorer check', () => {
38
+ const blockExplorerUrls = supportedUXTOChains.flatMap((chain) =>
39
+ chain.metamask.blockExplorerUrls.map((blockExplorerUrl) => ({
40
+ blockExplorerUrl: blockExplorerUrl,
41
+ chainId: chain.id,
42
+ chainName: chain.name,
43
+ }))
44
+ )
45
+
46
+ test.for(blockExplorerUrls)(
47
+ `block explorer should be alive $chainName - $chainId - $blockExplorerUrl`,
48
+ { timeout: 10_000 },
49
+ async ({ blockExplorerUrl }) => {
50
+ const response = await fetch(blockExplorerUrl)
51
+ expect(response.url).toBe(blockExplorerUrl)
52
+ expect(response.ok).toBe(true)
53
+ expect(response.status).toBe(200)
54
+ }
55
+ )
56
+ })
@@ -0,0 +1,93 @@
1
+ import type { UTXOChain } from '@lifi/types'
2
+ import { ChainId, ChainKey, ChainType, CoinKey } from '@lifi/types'
3
+
4
+ export const supportedUXTOChains: UTXOChain[] = [
5
+ {
6
+ key: ChainKey.BTC,
7
+ chainType: ChainType.UTXO,
8
+ name: 'Bitcoin',
9
+ coin: CoinKey.BTC,
10
+ id: ChainId.BTC,
11
+ mainnet: true,
12
+ logoURI:
13
+ 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/bitcoin.svg',
14
+ faucetUrls: [],
15
+ metamask: {
16
+ chainId: ChainId.BTC.toString(),
17
+ blockExplorerUrls: ['https://blockchair.com/bitcoin/'],
18
+ chainName: 'Bitcoin',
19
+ nativeCurrency: {
20
+ name: 'BTC',
21
+ symbol: 'BTC',
22
+ decimals: 8,
23
+ },
24
+ rpcUrls: ['https://node-router.thorswap.net/bitcoin'],
25
+ },
26
+ },
27
+ {
28
+ key: ChainKey.BCH,
29
+ chainType: ChainType.UTXO,
30
+ name: 'Bitcoin Cash',
31
+ coin: CoinKey.BCH,
32
+ id: ChainId.BCH,
33
+ mainnet: true,
34
+ logoURI:
35
+ 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/bitcoincash.svg',
36
+ faucetUrls: [],
37
+ metamask: {
38
+ chainId: ChainId.BCH.toString(),
39
+ blockExplorerUrls: ['https://blockchair.com/bitcoin-cash/'],
40
+ chainName: 'Bitcoin Cash',
41
+ nativeCurrency: {
42
+ name: 'BCH',
43
+ symbol: 'BCH',
44
+ decimals: 8,
45
+ },
46
+ rpcUrls: ['https://node-router.thorswap.net/bitcoin-cash'],
47
+ },
48
+ },
49
+ {
50
+ key: ChainKey.LTC,
51
+ chainType: ChainType.UTXO,
52
+ name: 'Litecoin',
53
+ coin: CoinKey.LTC,
54
+ id: ChainId.LTC,
55
+ mainnet: true,
56
+ logoURI:
57
+ 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/litecoin.svg',
58
+ faucetUrls: [],
59
+ metamask: {
60
+ chainId: ChainId.LTC.toString(),
61
+ blockExplorerUrls: ['https://blockchair.com/litecoin/'],
62
+ chainName: 'Litecoin',
63
+ nativeCurrency: {
64
+ name: 'LTC',
65
+ symbol: 'LTC',
66
+ decimals: 8,
67
+ },
68
+ rpcUrls: ['https://node-router.thorswap.net/litecoin'],
69
+ },
70
+ },
71
+ {
72
+ key: ChainKey.DGE,
73
+ chainType: ChainType.UTXO,
74
+ name: 'Dogecoin',
75
+ coin: CoinKey.DOGE,
76
+ id: ChainId.DGE,
77
+ mainnet: true,
78
+ logoURI:
79
+ 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/dogecoin.svg',
80
+ faucetUrls: [],
81
+ metamask: {
82
+ chainId: ChainId.DGE.toString(),
83
+ blockExplorerUrls: ['https://blockchair.com/dogecoin/'],
84
+ chainName: 'Dogecoin',
85
+ nativeCurrency: {
86
+ name: 'DODGE',
87
+ symbol: 'DOGE',
88
+ decimals: 8,
89
+ },
90
+ rpcUrls: ['https://node-router.thorswap.net/dogecoin'],
91
+ },
92
+ },
93
+ ]
@@ -0,0 +1,3 @@
1
+ export const prefixChainId = (chainId: number): string => {
2
+ return '0x' + chainId.toString(16)
3
+ }
@@ -0,0 +1,35 @@
1
+ import type { StaticToken } from '@lifi/types'
2
+ import { describe, expect, test } from 'vitest'
3
+ import { defaultCoins, wrappedTokens } from './coins'
4
+
5
+ describe.concurrent('Coin logo test', { timeout: 30_000 }, () => {
6
+ const allImages: string[] = []
7
+
8
+ // default coins
9
+ allImages.push(
10
+ ...defaultCoins
11
+ .map((coin) => {
12
+ const baseURL = coin.logoURI
13
+ const tokenSpecificURLs = Object.values(coin.chains).flatMap(
14
+ ({ logoURI }) => (logoURI ? [logoURI] : [])
15
+ )
16
+ return [baseURL, ...tokenSpecificURLs]
17
+ })
18
+ .flat()
19
+ )
20
+
21
+ // wrapped tokens
22
+ allImages.push(
23
+ ...Object.values(wrappedTokens).map((token: StaticToken) => token.logoURI!)
24
+ )
25
+
26
+ test.each([...new Set(allImages)])(
27
+ 'check that logoURI %s is valid',
28
+ async (image) => {
29
+ expect(image.startsWith('https://')).toBeTruthy()
30
+ const response = await fetch(image)
31
+ expect(response.status).toEqual(200)
32
+ },
33
+ 2000
34
+ )
35
+ })