Skip to content

Commit

Permalink
Merge pull request #439 from axelarnetwork/release/0.5.9
Browse files Browse the repository at this point in the history
Release/0.5.9
  • Loading branch information
alanrsoares authored Oct 17, 2023
2 parents c2041c9 + 0cac58f commit 21cbf41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "axelar-satellite",
"version": "0.5.8",
"version": "0.5.9",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
14 changes: 12 additions & 2 deletions src/hooks/useGetAssetBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const useGetAssetBalance = () => {
*/
const { data: keplrBalance, isLoading: keplrBalanceIsLoading } =
useGetKeplerBalance();

useEffect(
() => {
if (srcChain.module !== "axelarnet" || !keplrConnected) {
Expand Down Expand Up @@ -124,6 +125,13 @@ export const useGetAssetBalance = () => {
};
};

function parseBigIntWithDecimals(bigint: bigint, decimals: number): number {
const divisor = BigInt(10 ** decimals);
const wholePart = Number(bigint / divisor);
const remainder = Number(bigint % divisor) / Number(divisor);
return wholePart + remainder;
}

const useGetEvmBalance = () => {
const { address } = useAccount();
const asset = useSwapStore((state) => state.asset);
Expand Down Expand Up @@ -194,8 +202,10 @@ const useGetEvmBalance = () => {
return setBalance(value);
}

const num =
(erc20Balance ?? BigInt(0)) / BigInt(10 ** (asset?.decimals ?? 0));
const num = parseBigIntWithDecimals(
BigInt(erc20Balance ?? 0),
asset?.decimals ?? 0
);

setBalance(
num.toLocaleString("en", {
Expand Down

1 comment on commit 21cbf41

@vercel
Copy link

@vercel vercel bot commented on 21cbf41 Oct 17, 2023

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.