From 74ab2b8efccdc891ac23d8d2e58af4ad2a41f257 Mon Sep 17 00:00:00 2001 From: kvhnuke <10602065+kvhnuke@users.noreply.github.com> Date: Wed, 20 Sep 2023 12:57:02 -0700 Subject: [PATCH] fix: multiple bugs --- .../providers/haskoin/index.ts | 3 +++ .../activity-handlers/providers/ss/index.ts | 5 ++++- .../src/providers/ethereum/networks/rsk.ts | 12 +++++++++--- .../src/ui/action/composables/account-info.ts | 19 +++++++++++++------ .../components/custom-evm-token.vue | 4 ++-- .../components/network-assets-item.vue | 2 +- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/haskoin/index.ts b/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/haskoin/index.ts index 7dd9c5f51..5d4837d30 100644 --- a/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/haskoin/index.ts +++ b/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/haskoin/index.ts @@ -43,6 +43,9 @@ export default async ( if (relevantOut) { toAddress = relevantOut.address; value = relevantOut.value; + } else { + toAddress = tx.outputs[0].address; + value = Number(tx.outputs[0].value); } } diff --git a/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/ss/index.ts b/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/ss/index.ts index 636fcc197..1a0af2958 100644 --- a/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/ss/index.ts +++ b/packages/extension/src/providers/bitcoin/libs/activity-handlers/providers/ss/index.ts @@ -37,7 +37,7 @@ export default async ( }); return cleanedTxs.map((tx) => { const isIncoming = !tx.vin.find((i) => i.addresses![0] === address); - + console.log(isIncoming, tx.vin, tx.vout, address); let toAddress = ""; let value = 0; @@ -56,6 +56,9 @@ export default async ( if (relevantOut) { toAddress = relevantOut.addresses![0]; value = Number(relevantOut.value); + } else { + toAddress = tx.vout[0].addresses![0]; + value = Number(tx.vout[0].value); } } diff --git a/packages/extension/src/providers/ethereum/networks/rsk.ts b/packages/extension/src/providers/ethereum/networks/rsk.ts index c07c52fcf..3661eea3f 100644 --- a/packages/extension/src/providers/ethereum/networks/rsk.ts +++ b/packages/extension/src/providers/ethereum/networks/rsk.ts @@ -2,8 +2,11 @@ import { CoingeckoPlatform, NetworkNames } from "@enkryptcom/types"; import { EvmNetwork, EvmNetworkOptions } from "../types/evm-network"; import { EtherscanActivity } from "../libs/activity-handlers"; import wrapActivityHandler from "@/libs/activity-state/wrap-activity-handler"; -import { toChecksumAddress } from "ethereumjs-util"; -import { isAddress } from "web3-utils"; +import { + toChecksumAddress, + isValidChecksumAddress, + isValidAddress, +} from "ethereumjs-util"; import assetsInfoHandler from "@/providers/ethereum/libs/assets-handlers/assetinfo-mew"; const rootstockOptions: EvmNetworkOptions = { @@ -29,7 +32,10 @@ rootstockOptions.displayAddress = (address: string) => { return toChecksumAddress(address, rootstockOptions.chainID); }; rootstockOptions.isAddress = (address: string) => { - return isAddress(address, parseInt(rootstockOptions.chainID)); + return ( + isValidAddress(address) || + isValidChecksumAddress(address, rootstockOptions.chainID) + ); }; const rootstock = new EvmNetwork(rootstockOptions); diff --git a/packages/extension/src/ui/action/composables/account-info.ts b/packages/extension/src/ui/action/composables/account-info.ts index cd6581796..467654c0c 100644 --- a/packages/extension/src/ui/action/composables/account-info.ts +++ b/packages/extension/src/ui/action/composables/account-info.ts @@ -10,24 +10,31 @@ export default ( ) => { const marketData = new MarketData(); const fiatAmount = ref(defaultFiatVal); - const cryptoAmount = computed(() => { + + const cryptoAmountRaw = computed(() => { const selectedAccountIdx = accountInfo.value.activeAccounts.findIndex( (acc) => acc.address === accountInfo.value.selectedAccount?.address ); - let balance = "0"; if (selectedAccountIdx > -1) { - balance = accountInfo.value.activeBalances[selectedAccountIdx]; + const balance = accountInfo.value.activeBalances[selectedAccountIdx]; + return balance; } - return balance !== "~" ? formatFloatingPointValue(balance).value : balance; + return "0"; + }); + + const cryptoAmount = computed(() => { + return cryptoAmountRaw.value !== "~" + ? formatFloatingPointValue(cryptoAmountRaw.value).value + : cryptoAmountRaw.value; }); const updateFiatValues = async () => { fiatAmount.value = defaultFiatVal; - if (network.value.coingeckoID && cryptoAmount.value != "~") { + if (network.value.coingeckoID && cryptoAmountRaw.value != "~") { fiatAmount.value = `${ formatFiatValue( await marketData.getTokenValue( - cryptoAmount.value, + cryptoAmountRaw.value, network.value.coingeckoID, "USD" ) diff --git a/packages/extension/src/ui/action/views/network-assets/components/custom-evm-token.vue b/packages/extension/src/ui/action/views/network-assets/components/custom-evm-token.vue index 160a774e2..142332884 100644 --- a/packages/extension/src/ui/action/views/network-assets/components/custom-evm-token.vue +++ b/packages/extension/src/ui/action/views/network-assets/components/custom-evm-token.vue @@ -141,7 +141,7 @@ watch([contractAddress, props], async () => { if (isValidAddress.value) { const api = (await props.network.api()) as API; - const info = await api.getTokenInfo(contractAddress.value!); + const info = await api.getTokenInfo(contractAddress.value!.toLowerCase()); if (info.name !== "Unknown") { let icon = props.network.icon; @@ -168,7 +168,7 @@ watch([contractAddress, props], async () => { symbol: info.symbol, decimals: info.decimals, icon, - contract: contractAddress.value!, + contract: contractAddress.value!.toLowerCase(), coingeckoID, }); diff --git a/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue b/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue index e64b24695..c0e831e84 100644 --- a/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue +++ b/packages/extension/src/ui/action/views/network-assets/components/network-assets-item.vue @@ -43,7 +43,7 @@
-

{{ token.balanceUSDf }}

+

${{ token.balanceUSDf }}

@{{ token.valuef }}