@@ -7,10 +7,7 @@ import { useEffect, useState } from 'react'
7
7
/**
8
8
* Hook that returns the native token balance of the given `address`.
9
9
*/
10
- export const useBalance = (
11
- address ?: string | AccountId ,
12
- fractionDigits = 2 ,
13
- ) => {
10
+ export const useBalance = ( address ?: string | AccountId ) => {
14
11
const { api } = useInkathon ( )
15
12
const [ freeBalance , setFreeBalance ] = useState < BN > ( )
16
13
const [ reservedBalance , setReservedBalance ] = useState < BN > ( )
@@ -21,7 +18,7 @@ export const useBalance = (
21
18
22
19
useEffect ( ( ) => {
23
20
; ( async ( ) => {
24
- if ( ! api || ! address ) {
21
+ if ( ! api ) {
25
22
setFreeBalance ( undefined )
26
23
setReservedBalance ( undefined )
27
24
setBalance ( undefined )
@@ -31,16 +28,19 @@ export const useBalance = (
31
28
return
32
29
}
33
30
34
- const result = await getBalance ( api , address , fractionDigits )
31
+ const result = await getBalance ( api , address )
35
32
36
33
setFreeBalance ( result . freeBalance )
37
34
setReservedBalance ( result . reservedBalance )
38
35
setBalance ( result . balance )
39
- setBalanceFormatted ( `${ result . balanceFormatted } ${ result . tokenSymbol } ` )
36
+ setBalanceFormatted (
37
+ result . balanceFormatted &&
38
+ `${ result . balanceFormatted } ${ result . tokenSymbol } ` ,
39
+ )
40
40
setTokenSymbol ( result . tokenSymbol )
41
41
setTokenDecimals ( result . tokenDecimals )
42
42
} ) ( )
43
- } , [ api , address , fractionDigits ] )
43
+ } , [ api , address ] )
44
44
45
45
return {
46
46
freeBalance,
0 commit comments