Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Fix polkadot-js#4419 - using bounties without treasury (polkadot-js#4447
Browse files Browse the repository at this point in the history
)

* Fix issue with no treasury

* Apply review suggestions

* Use BN_ZERO instead of api.createType
  • Loading branch information
ekowalsk authored Jan 18, 2021
1 parent ba15fa8 commit ff616ce
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-hooks/src/useTreasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ export function useTreasury (): Treasury {
const [burn, setBurn] = useState<BN>();

const treasuryBalance = useCall<DeriveBalancesAccount>(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);
Expand Down

0 comments on commit ff616ce

Please sign in to comment.