From 85072c9142a4a0dd40b06d2ad055e2d5f6df7bba Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Thu, 31 Mar 2022 15:14:27 +0300 Subject: [PATCH 1/4] feat: getSendGasLimitERC20 --- src/assets/native.ts | 28 ++++++++++++++-------------- src/assets/sendGasLimits.ts | 23 +++++++++++++++++++++-- src/chains.ts | 6 +++++- src/index.ts | 3 ++- src/types.ts | 7 ++++++- 5 files changed, 48 insertions(+), 19 deletions(-) diff --git a/src/assets/native.ts b/src/assets/native.ts index 0f46a7e42..05c1b8eba 100644 --- a/src/assets/native.ts +++ b/src/assets/native.ts @@ -1,12 +1,12 @@ import { TESTNET_NATIVE } from './testnet' -import { AssetMap, ChainId } from '../types' +import { AssetMap, ChainId, AssetTypes } from '../types' import { sendGasLimits } from '../assets/sendGasLimits' const nativeAssets: AssetMap = { BTC: { name: 'Bitcoin', chain: ChainId.Bitcoin, - type: 'native', + type: AssetTypes.native, code: 'BTC', coinGeckoId: 'bitcoin', color: '#f7931a', @@ -16,7 +16,7 @@ const nativeAssets: AssetMap = { BCH: { name: 'Bitcoin Cash', chain: ChainId.BitcoinCash, - type: 'native', + type: AssetTypes.native, code: 'BCH', coinGeckoId: 'bitcoin-cash', color: '#a1db5e', @@ -26,7 +26,7 @@ const nativeAssets: AssetMap = { ETH: { name: 'Ether', chain: ChainId.Ethereum, - type: 'native', + type: AssetTypes.native, code: 'ETH', coinGeckoId: 'ethereum', color: '#627eea', @@ -36,7 +36,7 @@ const nativeAssets: AssetMap = { RBTC: { name: 'Rootstock BTC', chain: ChainId.Rootstock, - type: 'native', + type: AssetTypes.native, code: 'RBTC', coinGeckoId: 'rootstock', color: '#006e3c', @@ -46,7 +46,7 @@ const nativeAssets: AssetMap = { BNB: { name: 'Binance Coin', chain: ChainId.BinanceSmartChain, - type: 'native', + type: AssetTypes.native, code: 'BNB', coinGeckoId: 'binancecoin', color: '#f9a825', @@ -56,7 +56,7 @@ const nativeAssets: AssetMap = { NEAR: { name: 'Near', chain: ChainId.Near, - type: 'native', + type: AssetTypes.native, code: 'NEAR', coinGeckoId: 'near', color: '#000000', @@ -66,7 +66,7 @@ const nativeAssets: AssetMap = { SOL: { name: 'Solana', chain: ChainId.Solana, - type: 'native', + type: AssetTypes.native, code: 'SOL', coinGeckoId: 'solana', color: '#008080', @@ -76,7 +76,7 @@ const nativeAssets: AssetMap = { MATIC: { name: 'Matic', chain: ChainId.Polygon, - type: 'native', + type: AssetTypes.native, code: 'MATIC', coinGeckoId: 'matic-network', color: '#8247E5', @@ -86,7 +86,7 @@ const nativeAssets: AssetMap = { ARBETH: { name: 'Arbitrum ETH', chain: ChainId.Arbitrum, - type: 'native', + type: AssetTypes.native, code: 'ARBETH', coinGeckoId: 'ethereum', color: '#28A0EF', @@ -97,7 +97,7 @@ const nativeAssets: AssetMap = { FUSE: { name: 'Fuse Network', chain: ChainId.Fuse, - type: 'native', + type: AssetTypes.native, code: 'FUSE', coinGeckoId: 'fuse-network-token', color: '#46e8b6', @@ -107,7 +107,7 @@ const nativeAssets: AssetMap = { LUNA: { name: 'Luna', chain: ChainId.Terra, - type: 'native', + type: AssetTypes.native, code: 'LUNA', coinGeckoId: 'terra-luna', color: '#008080', @@ -117,7 +117,7 @@ const nativeAssets: AssetMap = { UST: { name: 'TerraUSD', chain: ChainId.Terra, - type: 'native', + type: AssetTypes.native, code: 'UST', decimals: 6, color: '#0083ff', @@ -128,7 +128,7 @@ const nativeAssets: AssetMap = { AVAX: { name: 'Avalanche', chain: ChainId.Avalanche, - type: 'native', + type: AssetTypes.native, code: 'AVAX', coinGeckoId: 'avalanche-2', color: '#E84141', diff --git a/src/assets/sendGasLimits.ts b/src/assets/sendGasLimits.ts index 111f98358..543c5589d 100644 --- a/src/assets/sendGasLimits.ts +++ b/src/assets/sendGasLimits.ts @@ -1,11 +1,30 @@ +import { ChainId } from '../types' +import { nonERC20SupportChain } from '../chains' + const sendGasLimits = { BTC: 290, NATIVE_EVM: 21000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE ERC20_EVM: 90000, // EVM -> ETH, RBTC, MATIC, BNB, AVAX, FUSE TERRA: 100000, // applies on both native and ERC2 Terra assets - ARBETH: 620000, + ARBETH: 620000, // for native asset is around ~420k and for ERC20 ~540k NEAR: 10000000000000, SOL: 1000000 } -export { sendGasLimits } +const getSendGasLimitERC20 = (chainId: ChainId): number | null => { + if (nonERC20SupportChain(chainId)) { + return null + } + + switch (chainId) { + case ChainId.Arbitrum: + return sendGasLimits.ARBETH + case ChainId.Terra: + return sendGasLimits.TERRA + default: + // EVM standard gas limit + return sendGasLimits.ERC20_EVM + } +} + +export { sendGasLimits, getSendGasLimitERC20 } diff --git a/src/chains.ts b/src/chains.ts index f7a533688..ab9db95f8 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -215,4 +215,8 @@ function isEthereumChain(chain: ChainId) { ].includes(chain) } -export { chains, isEthereumChain } +function nonERC20SupportChain(chain: ChainId) { + return [ChainId.Bitcoin, ChainId.BitcoinCash, ChainId.Near, ChainId.Solana].includes(chain) +} + +export { chains, isEthereumChain, nonERC20SupportChain } diff --git a/src/index.ts b/src/index.ts index 8f3c20a76..dd4097630 100755 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import BigNumber from 'bignumber.js' import { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap } from './assets' import { chains, isEthereumChain } from './chains' import { dappChains } from './dapps' -import { Asset, ChainId } from './types' +import { Asset, AssetTypes, ChainId } from './types' function unitToCurrency(asset: Asset, value: number | BigNumber): BigNumber { const multiplier = new BigNumber(10).pow(asset.decimals) @@ -25,5 +25,6 @@ export { unitToCurrency, currencyToUnit, Asset, + AssetTypes, ChainId } diff --git a/src/types.ts b/src/types.ts index 6ac86c56a..253fd8ba5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -13,7 +13,12 @@ export interface Chain { formatTransactionHash: (hash: string) => string } -export type AssetType = 'native' | 'erc20' +export enum AssetTypes { + native = 'native', + erc20 = 'erc20' +} + +export type AssetType = AssetTypes.native | AssetTypes.erc20 export enum ChainId { Bitcoin = 'bitcoin', From 8ea0614f12af9a9737386803ddf1ddc8a286fefa Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Thu, 31 Mar 2022 16:30:30 +0300 Subject: [PATCH 2/4] feat: export types and methods --- src/assets/index.ts | 3 ++- src/assets/native.ts | 2 +- src/index.ts | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/assets/index.ts b/src/assets/index.ts index 449d7d3f8..443d8b3ee 100644 --- a/src/assets/index.ts +++ b/src/assets/index.ts @@ -1,5 +1,6 @@ import { nativeAssets, testnetNativeAssets } from './native' import { erc20Assets, testnetErc20Assets, chainToTokenAddressMap, chainToTestnetTokenAddressMap } from './erc20' +import { getSendGasLimitERC20 } from './sendGasLimits' const assets = { ...nativeAssets, @@ -11,4 +12,4 @@ const testnetAssets = { ...testnetErc20Assets } -export { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap } +export { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap, getSendGasLimitERC20 } diff --git a/src/assets/native.ts b/src/assets/native.ts index 05c1b8eba..55214c1c4 100644 --- a/src/assets/native.ts +++ b/src/assets/native.ts @@ -1,6 +1,6 @@ import { TESTNET_NATIVE } from './testnet' import { AssetMap, ChainId, AssetTypes } from '../types' -import { sendGasLimits } from '../assets/sendGasLimits' +import { sendGasLimits } from './sendGasLimits' const nativeAssets: AssetMap = { BTC: { diff --git a/src/index.ts b/src/index.ts index dd4097630..c98c89f43 100755 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,14 @@ import BigNumber from 'bignumber.js' -import { assets, testnetAssets, chainToTokenAddressMap, chainToTestnetTokenAddressMap } from './assets' +import { + assets, + testnetAssets, + chainToTokenAddressMap, + chainToTestnetTokenAddressMap, + getSendGasLimitERC20 +} from './assets' import { chains, isEthereumChain } from './chains' import { dappChains } from './dapps' -import { Asset, AssetTypes, ChainId } from './types' +import { Asset, AssetType, AssetTypes, ChainId } from './types' function unitToCurrency(asset: Asset, value: number | BigNumber): BigNumber { const multiplier = new BigNumber(10).pow(asset.decimals) @@ -19,12 +25,14 @@ export { chainToTokenAddressMap, testnetAssets, chainToTestnetTokenAddressMap, + getSendGasLimitERC20, chains, dappChains, isEthereumChain, unitToCurrency, currencyToUnit, Asset, + AssetType, AssetTypes, ChainId } From 92756d7d3a9084dfb1f520ca6674a596982e36da Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Mon, 4 Apr 2022 16:14:10 +0300 Subject: [PATCH 3/4] feat: evmCompatible & supportsNonNativeAssets --- src/assets/sendGasLimits.ts | 4 ++-- src/chains.ts | 40 ++++++++++++++++++++++++++----------- src/types.ts | 2 ++ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/assets/sendGasLimits.ts b/src/assets/sendGasLimits.ts index 543c5589d..b5b8a32be 100644 --- a/src/assets/sendGasLimits.ts +++ b/src/assets/sendGasLimits.ts @@ -1,5 +1,5 @@ import { ChainId } from '../types' -import { nonERC20SupportChain } from '../chains' +import { supportsNonNativeAssets } from '../chains' const sendGasLimits = { BTC: 290, @@ -12,7 +12,7 @@ const sendGasLimits = { } const getSendGasLimitERC20 = (chainId: ChainId): number | null => { - if (nonERC20SupportChain(chainId)) { + if (!supportsNonNativeAssets(chainId)) { return null } diff --git a/src/chains.ts b/src/chains.ts index ab9db95f8..978e47675 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -28,6 +28,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 1, // 0,1 blocks per minute * 180 minutes (3 hours) -> 18 blocks wait period txFailureTimeout: 10800000, // 3 hours in ms + evmCompatible: false, + supportsNonNativeAssets: false, // TODO: include network types in validation isValidAddress: (address) => !!validateBitcoinAddress(address), formatAddress: (address) => address, @@ -44,6 +46,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 1, // ~0,1 blocks per minute * 180 minutes (3 hours) -> 18 blocks wait period txFailureTimeout: 10800000, // 3 hours in ms + evmCompatible: false, + supportsNonNativeAssets: false, // TODO: include network types in validation isValidAddress: (address) => isValidBitcoinCashAddress(address), formatAddress: (address) => formatBitcoinCashAddress(address), @@ -60,6 +64,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 3, // ~4 blocks per minute * 30 minutes -> 120 blocks wait period txFailureTimeout: 1800000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -75,6 +81,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~3 blocks per minute * 30 minutes -> 90 blocks wait period txFailureTimeout: 1800000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string, network?: string) => toChecksumAddress(with0x(hexAddress), getRSKChainID(network)), @@ -91,6 +99,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~20 blocks per minute * 10 minutes -> 200 blocks wait period txFailureTimeout: 600000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -106,6 +116,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 10, // ~50 blocks per minute * 5 minutes -> 250 blocks wait period txFailureTimeout: 300000, // in ms + evmCompatible: false, + supportsNonNativeAssets: false, isValidAddress: (address) => isValidNearAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidNearTx(hash), @@ -121,6 +133,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 31, // ~120 blocks per minute * 5 minutes -> 600 blocks wait period txFailureTimeout: 300000, // in ms + evmCompatible: false, + supportsNonNativeAssets: false, isValidAddress: (address) => isValidSolanaAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidSolanaTx(hash), @@ -136,6 +150,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 1, // ~10 blocks per minute * 15 minutes -> 150 blocks wait period txFailureTimeout: 900000, // in ms + evmCompatible: false, + supportsNonNativeAssets: true, isValidAddress: (address) => isValidTerraAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidTerraTx(hash), @@ -151,6 +167,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~30 blocks per minute * 10 minutes -> 300 blocks wait period txFailureTimeout: 600000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -166,6 +184,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~15 blocks per minute * 10 minutes -> 150 blocks wait period txFailureTimeout: 600000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -181,6 +201,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~12 blocks per minute * 15 minutes -> 180 blocks wait period txFailureTimeout: 900000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -196,6 +218,8 @@ const chains: { [key in ChainId]: Chain } = { safeConfirmations: 5, // ~15 blocks per minute * 10 minutes -> 150 blocks wait period txFailureTimeout: 600000, // in ms + evmCompatible: true, + supportsNonNativeAssets: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -204,19 +228,11 @@ const chains: { [key in ChainId]: Chain } = { } function isEthereumChain(chain: ChainId) { - return [ - ChainId.BinanceSmartChain, - ChainId.Ethereum, - ChainId.Rootstock, - ChainId.Polygon, - ChainId.Avalanche, - ChainId.Arbitrum, - ChainId.Fuse - ].includes(chain) + return chains[chain].evmCompatible } -function nonERC20SupportChain(chain: ChainId) { - return [ChainId.Bitcoin, ChainId.BitcoinCash, ChainId.Near, ChainId.Solana].includes(chain) +function supportsNonNativeAssets(chain: ChainId) { + return chains[chain].supportsNonNativeAssets } -export { chains, isEthereumChain, nonERC20SupportChain } +export { chains, isEthereumChain, supportsNonNativeAssets } diff --git a/src/types.ts b/src/types.ts index 253fd8ba5..7308d6cf4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -7,6 +7,8 @@ export interface Chain { } safeConfirmations: number txFailureTimeout: number + evmCompatible: boolean + supportsNonNativeAssets: boolean isValidAddress: (address: string, network?: string) => boolean formatAddress: (address: string, network?: string) => string isValidTransactionHash: (hash: string) => boolean From 37427c5c1e29ac6f4d397fcebecdcb05c3d07ce9 Mon Sep 17 00:00:00 2001 From: Slav Keremidchiev Date: Tue, 10 May 2022 17:57:52 +0300 Subject: [PATCH 4/4] chore: rename supportsNonNativeAssets to hasTokens --- src/assets/sendGasLimits.ts | 6 +++--- src/chains.ts | 30 +++++++++++++++--------------- src/types.ts | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/assets/sendGasLimits.ts b/src/assets/sendGasLimits.ts index b5b8a32be..842eeb757 100644 --- a/src/assets/sendGasLimits.ts +++ b/src/assets/sendGasLimits.ts @@ -1,5 +1,5 @@ import { ChainId } from '../types' -import { supportsNonNativeAssets } from '../chains' +import { hasTokens } from '../chains' const sendGasLimits = { BTC: 290, @@ -12,8 +12,8 @@ const sendGasLimits = { } const getSendGasLimitERC20 = (chainId: ChainId): number | null => { - if (!supportsNonNativeAssets(chainId)) { - return null + if (!hasTokens(chainId)) { + throw new Error(`Chain '${chainId}' doesn't support tokens!`) } switch (chainId) { diff --git a/src/chains.ts b/src/chains.ts index 978e47675..e0fcf7c9d 100644 --- a/src/chains.ts +++ b/src/chains.ts @@ -29,7 +29,7 @@ const chains: { [key in ChainId]: Chain } = { // 0,1 blocks per minute * 180 minutes (3 hours) -> 18 blocks wait period txFailureTimeout: 10800000, // 3 hours in ms evmCompatible: false, - supportsNonNativeAssets: false, + hasTokens: false, // TODO: include network types in validation isValidAddress: (address) => !!validateBitcoinAddress(address), formatAddress: (address) => address, @@ -47,7 +47,7 @@ const chains: { [key in ChainId]: Chain } = { // ~0,1 blocks per minute * 180 minutes (3 hours) -> 18 blocks wait period txFailureTimeout: 10800000, // 3 hours in ms evmCompatible: false, - supportsNonNativeAssets: false, + hasTokens: false, // TODO: include network types in validation isValidAddress: (address) => isValidBitcoinCashAddress(address), formatAddress: (address) => formatBitcoinCashAddress(address), @@ -65,7 +65,7 @@ const chains: { [key in ChainId]: Chain } = { // ~4 blocks per minute * 30 minutes -> 120 blocks wait period txFailureTimeout: 1800000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -82,7 +82,7 @@ const chains: { [key in ChainId]: Chain } = { // ~3 blocks per minute * 30 minutes -> 90 blocks wait period txFailureTimeout: 1800000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string, network?: string) => toChecksumAddress(with0x(hexAddress), getRSKChainID(network)), @@ -100,7 +100,7 @@ const chains: { [key in ChainId]: Chain } = { // ~20 blocks per minute * 10 minutes -> 200 blocks wait period txFailureTimeout: 600000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -117,7 +117,7 @@ const chains: { [key in ChainId]: Chain } = { // ~50 blocks per minute * 5 minutes -> 250 blocks wait period txFailureTimeout: 300000, // in ms evmCompatible: false, - supportsNonNativeAssets: false, + hasTokens: false, isValidAddress: (address) => isValidNearAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidNearTx(hash), @@ -134,7 +134,7 @@ const chains: { [key in ChainId]: Chain } = { // ~120 blocks per minute * 5 minutes -> 600 blocks wait period txFailureTimeout: 300000, // in ms evmCompatible: false, - supportsNonNativeAssets: false, + hasTokens: false, isValidAddress: (address) => isValidSolanaAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidSolanaTx(hash), @@ -151,7 +151,7 @@ const chains: { [key in ChainId]: Chain } = { // ~10 blocks per minute * 15 minutes -> 150 blocks wait period txFailureTimeout: 900000, // in ms evmCompatible: false, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (address) => isValidTerraAddress(address), formatAddress: (address) => address, isValidTransactionHash: (hash: string) => isValidTerraTx(hash), @@ -168,7 +168,7 @@ const chains: { [key in ChainId]: Chain } = { // ~30 blocks per minute * 10 minutes -> 300 blocks wait period txFailureTimeout: 600000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -185,7 +185,7 @@ const chains: { [key in ChainId]: Chain } = { // ~15 blocks per minute * 10 minutes -> 150 blocks wait period txFailureTimeout: 600000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -202,7 +202,7 @@ const chains: { [key in ChainId]: Chain } = { // ~12 blocks per minute * 15 minutes -> 180 blocks wait period txFailureTimeout: 900000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -219,7 +219,7 @@ const chains: { [key in ChainId]: Chain } = { // ~15 blocks per minute * 10 minutes -> 150 blocks wait period txFailureTimeout: 600000, // in ms evmCompatible: true, - supportsNonNativeAssets: true, + hasTokens: true, isValidAddress: (hexAddress: string) => isValidAddress(with0x(hexAddress)), formatAddress: (hexAddress: string) => toChecksumAddress(with0x(hexAddress)), isValidTransactionHash: (hash: string) => isValidHex(hash), @@ -231,8 +231,8 @@ function isEthereumChain(chain: ChainId) { return chains[chain].evmCompatible } -function supportsNonNativeAssets(chain: ChainId) { - return chains[chain].supportsNonNativeAssets +function hasTokens(chain: ChainId) { + return chains[chain].hasTokens } -export { chains, isEthereumChain, supportsNonNativeAssets } +export { chains, isEthereumChain, hasTokens } diff --git a/src/types.ts b/src/types.ts index 7308d6cf4..cfcda73ca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,7 +8,7 @@ export interface Chain { safeConfirmations: number txFailureTimeout: number evmCompatible: boolean - supportsNonNativeAssets: boolean + hasTokens: boolean isValidAddress: (address: string, network?: string) => boolean formatAddress: (address: string, network?: string) => string isValidTransactionHash: (hash: string) => boolean