Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
fix: balances
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwelde committed Apr 21, 2021
1 parent e1f36d9 commit f7d9601
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/services/BalanceUtilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
PublicIdentity,
BlockchainUtils,
} from '@kiltprotocol/sdk-js'
import { Balances as KiltBalances } from '@kiltprotocol/types'
import BN from 'bn.js'
import React from 'react'
import { Store } from 'redux'
Expand Down Expand Up @@ -46,8 +47,10 @@ class BalanceUtilities {
}

public static async getMyBalance(identity: IMyIdentity): Promise<BN> {
const balance: BN = await Balance.getBalance(identity.identity.address)
return balance
const balance: KiltBalances = await Balance.getBalances(
identity.identity.address
)
return balance.free
}

public static connectMyIdentities(
Expand Down Expand Up @@ -117,21 +120,21 @@ class BalanceUtilities {

private static listener(
account: PublicIdentity['address'],
balance: BN,
change: BN
balance: KiltBalances,
change: KiltBalances
): void {
if (!change.isZero()) {
const inDeCreased = `${change.gtn(0) ? 'in' : 'de'}creased`
if (!change.free.isZero()) {
const inDeCreased = `${change.free.gtn(0) ? 'in' : 'de'}creased`

notify(
<div>
Balance of <ContactPresentation address={account} /> {inDeCreased} by{' '}
<KiltToken amount={change} colored />.
<KiltToken amount={change.free} colored />.
</div>
)
}
persistentStoreInstance.store.dispatch(
Balances.Store.updateBalance(account, balance)
Balances.Store.updateBalance(account, balance.free)
)
}
}
Expand Down

0 comments on commit f7d9601

Please sign in to comment.