From 84c6973f25f6d35fbb451b57628eff02fa197fc7 Mon Sep 17 00:00:00 2001 From: dafuga Date: Thu, 9 Nov 2023 17:56:21 -0800 Subject: [PATCH] fix: fixing token selector on send/receive page --- src/components/elements/input/token/selector.svelte | 3 +++ src/lib/evm/data/tokens.json | 9 ++++++--- src/pages/transfer/form.svelte | 6 ------ src/pages/transfer/index.svelte | 3 ++- src/pages/transfer/managers/transferManager.ts | 5 +++-- src/stores/tokens.ts | 1 + 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/elements/input/token/selector.svelte b/src/components/elements/input/token/selector.svelte index 36ac1b5f..bac0d083 100644 --- a/src/components/elements/input/token/selector.svelte +++ b/src/components/elements/input/token/selector.svelte @@ -18,6 +18,7 @@ export let tokenOptions: Token[] | undefined = undefined export let onTokenSelect: (token: Token) => void export let showTokensWithoutBalance: boolean = false + export let includeEvmTokens: boolean = false $: { if (defaultToken) { @@ -48,6 +49,8 @@ } else { filteredTokens = $tokens?.filter((token) => { + if (token.evm && !includeEvmTokens) return false + const blockchainMatches = token.chainId.equals($activeBlockchain.chainId) let balanceExists if (!showTokensWithoutBalance) { diff --git a/src/lib/evm/data/tokens.json b/src/lib/evm/data/tokens.json index 9a53260a..de780d12 100644 --- a/src/lib/evm/data/tokens.json +++ b/src/lib/evm/data/tokens.json @@ -17,7 +17,8 @@ "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": "" + "chain_rank": "", + "evm": true }, { "key": "evm-usdt", @@ -33,7 +34,8 @@ "logo": "https://raw.githubusercontent.com/eoscafe/eos-airdrops/master/logos/USDT.png", "created_at": "2022-08-15T13:34:32.002Z" }, - "chain_rank": "" + "chain_rank": "", + "evm": true }, { "key": "evm-tlos", @@ -49,6 +51,7 @@ "logo": "", "created_at": "2022-08-15T13:34:32.004Z" }, - "chain_rank": "" + "chain_rank": "", + "evm": true } ] \ No newline at end of file diff --git a/src/pages/transfer/form.svelte b/src/pages/transfer/form.svelte index 8a29dc80..aeb63a91 100644 --- a/src/pages/transfer/form.svelte +++ b/src/pages/transfer/form.svelte @@ -63,14 +63,8 @@ let generatingOptions = false - $: console.log({ balances: $balances }) - $: balance = $balances.find((balance) => balance.tokenKey === from?.key) - $: console.log({ balance, from }) - - console.log({ tokens: $tokens }) - async function generateOptions(evmSession?: EvmSession) { if (!!generatingOptions) return diff --git a/src/pages/transfer/index.svelte b/src/pages/transfer/index.svelte index 240ed31e..320fa720 100644 --- a/src/pages/transfer/index.svelte +++ b/src/pages/transfer/index.svelte @@ -60,7 +60,8 @@ async function transfer() { try { - transactResult = await transferManager?.transfer(deposit, received) + console.log({deposit}) + transactResult = await transferManager?.transfer(deposit, from!.symbol) } catch (error) { return (errorMessage = `Could not transfer. Error: ${ error.underlyingError?.message || JSON.stringify(error) === '{}' diff --git a/src/pages/transfer/managers/transferManager.ts b/src/pages/transfer/managers/transferManager.ts index 92c83eab..0bad5c85 100644 --- a/src/pages/transfer/managers/transferManager.ts +++ b/src/pages/transfer/managers/transferManager.ts @@ -27,13 +27,14 @@ export abstract class TransferManager { /* eslint-disable @typescript-eslint/no-unused-vars */ transfer( _amount: string, - _tokenSymibol: Asset.SymbolType + _tokenSymbol: Asset.SymbolType, + _amountReceived?: string ): Promise { throw new Error('transfer() not implemented') } transferFee(_amount?: string, tokenSymbol?: Asset.SymbolType): Promise { - return Promise.resolve(Asset.from(0, tokenSymbol|| '4,EOS')) + return Promise.resolve(Asset.from(0, tokenSymbol || '4,EOS')) } /* eslint-enable @typescript-eslint/no-unused-vars */ diff --git a/src/stores/tokens.ts b/src/stores/tokens.ts index 83cbd382..dd022e43 100644 --- a/src/stores/tokens.ts +++ b/src/stores/tokens.ts @@ -20,6 +20,7 @@ export interface Token { price?: number logo?: string balance?: Asset | string + evm?: boolean } export interface TokenKeyParams {