Skip to content

Commit

Permalink
fix: rsk custom token balance
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Feb 24, 2025
1 parent f122888 commit 80f9f05
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const getTokens = (
url = `${API_ENPOINT2}${supportedNetworks[chain].tbName}/${address}?platform=enkrypt&type=internal`;
return fetch(url)
.then(res => res.json())
.then(json => {
.then((json: any) => {
if (json.error)
return Promise.reject(
`TOKENBALANCE-MEW: ${JSON.stringify(json.error)}`,
Expand Down
10 changes: 7 additions & 3 deletions packages/extension/src/providers/ethereum/types/erc20-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ export class Erc20Token extends BaseToken {
api: EvmAPI,
address: string,
): Promise<string> {
if (this.contract === NATIVE_TOKEN_ADDRESS) return api.getBalance(address);
if (this.contract === NATIVE_TOKEN_ADDRESS)
return api.getBalance(address.toLowerCase());
else {
const contract = new api.web3.Contract(erc20 as any, this.contract);
const contract = new api.web3.Contract(
erc20 as any,
this.contract.toLowerCase(),
);
return contract.methods
.balanceOf(address)
.balanceOf(address.toLowerCase())
.call()
.then((val: BNType) => {
const balance = numberToHex(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@
:toggle="toggleDeposit"
/>
</div>

<!-- prettier-ignore -->
<custom-evm-token
v-if="showAddCustomTokens"
:address="props.accountInfo.selectedAccount?.address!"
:network="props.network as EvmNetwork"
:network="(props.network as EvmNetwork)"
@update:token-added="addCustomAsset"
@update:close="toggleShowAddCustomTokens"
></custom-evm-token>
Expand Down Expand Up @@ -122,7 +122,8 @@ const updateAssets = () => {
assets.value = _assets;
isLoading.value = false;
})
.catch(() => {
.catch(e => {
console.error(e);
if (selectedNetworkName.value !== currentNetwork) return;
isFetchError.value = true;
isLoading.value = false;
Expand Down

0 comments on commit 80f9f05

Please sign in to comment.