From ff616ce89fb4bad3470bf3b60cefb6cdf67ec4ba Mon Sep 17 00:00:00 2001 From: Ewa Kowalska <30404388+ekowalsk@users.noreply.github.com> Date: Mon, 18 Jan 2021 20:58:55 +0100 Subject: [PATCH] Fix #4419 - using bounties without treasury (#4447) * Fix issue with no treasury * Apply review suggestions * Use BN_ZERO instead of api.createType --- packages/react-hooks/src/useTreasury.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-hooks/src/useTreasury.ts b/packages/react-hooks/src/useTreasury.ts index 89863ca7b8..644853b203 100644 --- a/packages/react-hooks/src/useTreasury.ts +++ b/packages/react-hooks/src/useTreasury.ts @@ -27,9 +27,13 @@ export function useTreasury (): Treasury { const [burn, setBurn] = useState(); const treasuryBalance = useCall(api.derive.balances.account, [TREASURY_ACCOUNT]); - const spendPeriod = api.consts.treasury.spendPeriod; + const spendPeriod = api.consts.treasury ? api.consts.treasury.spendPeriod : BN_ZERO; useEffect(() => { + if (!api.consts.treasury) { + return; + } + setValue(treasuryBalance?.freeBalance.gtn(0) ? treasuryBalance.freeBalance : undefined);