Skip to content

Commit

Permalink
Update account balances each block
Browse files Browse the repository at this point in the history
  • Loading branch information
vkulinich-cl committed Nov 6, 2024
1 parent 6ff9e0e commit ca152ee
Show file tree
Hide file tree
Showing 58 changed files with 409 additions and 349 deletions.
10 changes: 5 additions & 5 deletions src/api/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ export const parseBalanceData = (
id: string,
address: string,
) => {
const freeBalance = new BigNumber(data.free.toHex())
const frozenBalance = new BigNumber(data.frozen.toHex())
const reservedBalance = new BigNumber(data.reserved.toHex())
const balance = freeBalance.minus(frozenBalance)
const freeBalance = data.free.toString()
const frozenBalance = data.frozen.toString()
const reservedBalance = data.reserved.toString()
const balance = BigNumber(freeBalance).minus(frozenBalance).toString()

return {
accountId: address,
assetId: id,
balance,
total: freeBalance.plus(reservedBalance),
total: BigNumber(freeBalance).plus(reservedBalance).toString(),
freeBalance,
reservedBalance,
}
Expand Down
3 changes: 2 additions & 1 deletion src/api/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { useTokenBalance } from "./balances"
import { useAssets } from "providers/assets"
import { Permill } from "@polkadot/types/interfaces"
import BN from "bignumber.js"

export const useMinWithdrawalFee = () => {
const { api } = useRpcProvider()
Expand Down Expand Up @@ -79,7 +80,7 @@ export const useInsufficientFee = (assetId: string, address: string) => {

if (isSufficient) return undefined

if (!balance || balance.gt(0)) return undefined
if (!balance || BN(balance).gt(0)) return undefined

return fee
? {
Expand Down
Loading

0 comments on commit ca152ee

Please sign in to comment.