diff --git a/src/lib/evm/abis/erc20.json b/src/lib/evm/data/erc20_abi.json similarity index 100% rename from src/lib/evm/abis/erc20.json rename to src/lib/evm/data/erc20_abi.json diff --git a/src/lib/evm/data/tokens.json b/src/lib/evm/data/tokens.json new file mode 100644 index 00000000..0a9a2027 --- /dev/null +++ b/src/lib/evm/data/tokens.json @@ -0,0 +1,54 @@ +[ + { + "key": "evm-eos", + "symbol": "EOS", + "account": "eosio.evm", + "chain": "eos", + "supply": { + "precision": 4 + }, + "metadata": { + "name": "EOS (EVM)", + "website": "https://eos.io", + "logo": "/images/token-eos-dark.svg", + "created_at": "2022-08-15T13:34:31.994Z", + "desc": { + "en": "EOS (Enterprise Operation System) is a blockchain smart contract platform developed by Block.one, which aims to provide bottom blockchain platform services for high-performance distributed applications.", + "zh": "EOS (Enterprise Operation System) \u662f\u4e00\u4e2a\u533a\u5757\u94fe\u667a\u80fd\u5408\u7ea6\u5e73\u53f0\uff0c\u7531Block.one \u5f00\u53d1\u3002\u5b83\u81f4\u529b\u4e8e\u4e3a\u9ad8\u6027\u80fd\u5206\u5e03\u5f0f\u5e94\u7528\u63d0\u4f9b\u533a\u5757\u94fe\u5e95\u5c42\u670d\u52a1\u3002" + } + }, + "chain_rank": "" + }, + { + "key": "evm-usdt", + "symbol": "USDT", + "account": "eosio.evm", + "chain": "eos", + "supply": { + "precision": 2 + }, + "metadata": { + "name": "USDT (EVM)", + "website": "", + "logo": "https://raw.githubusercontent.com/eoscafe/eos-airdrops/master/logos/USDT.png", + "created_at": "2022-08-15T13:34:32.002Z" + }, + "chain_rank": "" + }, + { + "key": "evm-tlos", + "symbol": "TLOS", + "account": "eosio.evm", + "chain": "telos", + "supply": { + "precision": 4 + }, + "metadata": { + "name": "TLOS (EVM)", + "website": "", + "logo": "", + "created_at": "2022-08-15T13:34:32.004Z" + }, + "chain_rank": "" + } +] \ No newline at end of file diff --git a/src/lib/evm/index.ts b/src/lib/evm/index.ts index f19d0382..a6384865 100644 --- a/src/lib/evm/index.ts +++ b/src/lib/evm/index.ts @@ -7,7 +7,7 @@ import {Asset, Name, NameType} from 'anchor-link' import {BigNumber, ethers} from 'ethers' import {getClient} from '~/api-client' -import erc20_abi from './abis/erc20.json' +import erc20_abi from './data/erc20_abi.json' export type AvailableEvms = 'eos-mainnet' | 'telos' export interface EvmChainConfig { diff --git a/src/pages/transfer/form.svelte b/src/pages/transfer/form.svelte index eef9da39..16e198d4 100644 --- a/src/pages/transfer/form.svelte +++ b/src/pages/transfer/form.svelte @@ -86,10 +86,11 @@ accountBalance = await transferManager.balance() } - const token = $tokens.find(token => token.key === transferManagerData.tokenKey) + const token = $tokens.find(token => token.name === transferManagerData.tokenName) if (!token) { - console.error(`Token ${transferManagerData.tokenKey} not found`) + console.log({tokens: $tokens, tokenKey: transferManagerData.tokenName}) + console.error(`Token ${transferManagerData.tokenName} not found`) return } diff --git a/src/pages/transfer/managers/index.ts b/src/pages/transfer/managers/index.ts index b85fc71c..354aa143 100644 --- a/src/pages/transfer/managers/index.ts +++ b/src/pages/transfer/managers/index.ts @@ -8,7 +8,7 @@ import type {TransferManager} from './transferManager' interface TransferType { transferClass: typeof TransferManager - tokenKey: string + tokenName: string tokenContract: NameType from: string fromLabel: string @@ -19,7 +19,7 @@ interface TransferType { export const transferManagers: {[key: string]: TransferType} = { 'EOS - EOS (EVM)': { transferClass: EosEvmBridge, - tokenKey: 'eos', // change these for actual token key + tokenName: 'EOS', tokenContract: 'eosio.token', from: 'eos', fromLabel: 'EOS', @@ -28,7 +28,7 @@ export const transferManagers: {[key: string]: TransferType} = { }, 'EOS (EVM) - EOS': { transferClass: EvmEosBridge, - tokenKey: 'evm-eos', + tokenName: 'EOS (EVM)', tokenContract: 'eosio.token', from: 'evm', fromLabel: 'EOS (EVM)', @@ -37,7 +37,7 @@ export const transferManagers: {[key: string]: TransferType} = { }, 'USDT - USDT (EVM)': { transferClass: EosEvmBridge, - tokenKey: 'usdt', + tokenName: 'USDT', tokenContract: 'tethertether', from: 'usdt', fromLabel: 'USDT', @@ -46,7 +46,7 @@ export const transferManagers: {[key: string]: TransferType} = { }, 'USDT (EVM) - USDT': { transferClass: EvmEosBridge, - tokenKey: 'evm-usdt', + tokenName: 'USDT (EVM)', tokenContract: 'tethertether', from: 'evm', fromLabel: 'USDT (EVM)', @@ -55,8 +55,8 @@ export const transferManagers: {[key: string]: TransferType} = { }, 'TLOS - TLOS (EVM)': { transferClass: TelosEvmBridge, - tokenKey: 'tlos', - tokenContract: 'telos.token', + tokenName: 'TLOS', + tokenContract: 'eosio.token', from: 'tlos', fromLabel: 'TLOS', to: 'evm', @@ -64,7 +64,7 @@ export const transferManagers: {[key: string]: TransferType} = { }, 'TLOS (EVM) - TLOS': { transferClass: EvmTelosBridge, - tokenKey: 'evm-tlos', + tokenName: 'TLOS (EVM)', tokenContract: 'telos.evm', from: 'evm', fromLabel: 'TLOS (EVM)', diff --git a/src/stores/tokens.ts b/src/stores/tokens.ts index 85a58358..8991e8b9 100644 --- a/src/stores/tokens.ts +++ b/src/stores/tokens.ts @@ -9,6 +9,8 @@ import {activeBlockchain, activePriceTicker, activeSession} from '~/store' import {priceTicker} from '~/price-ticker' import {Balance, balances} from '~/stores/balances' +import evmTokens from '../lib/evm/data/tokens.json' + export interface Token { key: string chainId: ChainId @@ -111,10 +113,16 @@ export function loadTokenMetadata(session: LinkSession) { const sysToken = createTokenFromChainId(session.chainId, get(activePriceTicker)) records.push(sysToken) - for (const t of AntelopeTokens) { - const chain = chainConfig(session.chainId) + const allTokens = [ + ...AntelopeTokens, + ...evmTokens, + ] + + const chain = chainConfig(session.chainId) + for (const t of allTokens) { if (chain.id === t.chain) { + console.log({ t, bool: t.supply && t.supply.precision && t.symbol }) if (t.supply && t.supply.precision && t.symbol) { const symbol: Asset.Symbol = Asset.Symbol.from(`${t.supply.precision},${t.symbol}`) const token = { @@ -125,7 +133,7 @@ export function loadTokenMetadata(session: LinkSession) { logo: t.metadata.logo, } - if (token.symbol.equals(sysToken.symbol) && token.contract === token.contract) { + if (token.symbol.equals(sysToken.symbol) && token.name !== `${sysToken.name} (EVM)`) { continue }