Skip to content

Commit

Permalink
fix: multiple bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Sep 20, 2023
1 parent 11559c0 commit 74ab2b8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}

Expand Down
12 changes: 9 additions & 3 deletions packages/extension/src/providers/ethereum/networks/rsk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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);
Expand Down
19 changes: 13 additions & 6 deletions packages/extension/src/ui/action/composables/account-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,31 @@ export default (
) => {
const marketData = new MarketData();
const fiatAmount = ref<string>(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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -168,7 +168,7 @@ watch([contractAddress, props], async () => {
symbol: info.symbol,
decimals: info.decimals,
icon,
contract: contractAddress.value!,
contract: contractAddress.value!.toLowerCase(),
coingeckoID,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</div>

<div class="network-assets__token-price">
<h4>{{ token.balanceUSDf }}</h4>
<h4>${{ token.balanceUSDf }}</h4>
<p>@{{ token.valuef }}</p>
</div>
</a>
Expand Down

1 comment on commit 74ab2b8

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.