Skip to content

Commit

Permalink
fix: getting transfer page working again
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Oct 27, 2023
1 parent d20f61f commit c8c7cf2
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 14 deletions.
File renamed without changes.
54 changes: 54 additions & 0 deletions src/lib/evm/data/tokens.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
]
2 changes: 1 addition & 1 deletion src/lib/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/transfer/form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions src/pages/transfer/managers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {TransferManager} from './transferManager'

interface TransferType {
transferClass: typeof TransferManager
tokenKey: string
tokenName: string
tokenContract: NameType
from: string
fromLabel: string
Expand All @@ -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',
Expand All @@ -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)',
Expand All @@ -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',
Expand All @@ -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)',
Expand All @@ -55,16 +55,16 @@ 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',
toLabel: 'TLOS (EVM)',
},
'TLOS (EVM) - TLOS': {
transferClass: EvmTelosBridge,
tokenKey: 'evm-tlos',
tokenName: 'TLOS (EVM)',
tokenContract: 'telos.evm',
from: 'evm',
fromLabel: 'TLOS (EVM)',
Expand Down
14 changes: 11 additions & 3 deletions src/stores/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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
}

Expand Down

0 comments on commit c8c7cf2

Please sign in to comment.