@@ -36,15 +36,14 @@ const getBalance$ = (
3636 api . query . System . Account . watchValue ( addr ) ,
3737 api . constants . Balances . ExistentialDeposit ( ) ,
3838 ] ) . pipe (
39- map ( ( [ { data } , existentialDeposit ] ) => {
39+ map ( ( [ { data, providers, consumers } , existentialDeposit ] ) => {
40+ const accountExists = providers + consumers > 0
41+ const accountEd = accountExists ? existentialDeposit : 0n
4042 // https://wiki.polkadot.network/learn/learn-account-balances/
4143 // Total tokens in the account
42- const total = data . reserved + data . free
44+ const total = data . reserved + data . free + accountEd
4345 // Portion of "free" balance that can't be transferred.
44- const untouchable =
45- total == 0n
46- ? 0n
47- : maxBigInt ( data . frozen - data . reserved , existentialDeposit )
46+ const untouchable = maxBigInt ( data . frozen - data . reserved , accountEd )
4847 // Portion of "free" balance that can be transferred
4948 const spendable = data . free - untouchable
5049 // Portion of "total" balance that is somehow locked
@@ -53,7 +52,7 @@ const getBalance$ = (
5352 return {
5453 raw : {
5554 ...data ,
56- existentialDeposit : total > 0n ? existentialDeposit : 0n ,
55+ existentialDeposit : accountEd ,
5756 } ,
5857 total,
5958 locked,
0 commit comments