From 6421bd360c2d3c39c91cc872d2660acaa563fdd6 Mon Sep 17 00:00:00 2001 From: MiZiet <55240109+MiZiet@users.noreply.github.com> Date: Tue, 29 Dec 2020 16:19:11 +0100 Subject: [PATCH] Use derive call in Bounty's useCounter (#4290) * Use derive call in Bounty's useCounter * Remove derive.treasury from useCall --- packages/page-bounties/src/useCounter.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/page-bounties/src/useCounter.ts b/packages/page-bounties/src/useCounter.ts index e71f5c1f12..3399ae3fe4 100644 --- a/packages/page-bounties/src/useCounter.ts +++ b/packages/page-bounties/src/useCounter.ts @@ -1,18 +1,17 @@ // Copyright 2017-2020 @polkadot/app-bounties authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { BountyIndex } from '@polkadot/types/interfaces'; - import { useMemo } from 'react'; +import { DeriveBounties } from '@polkadot/api-derive/types'; import { useApi, useCall } from '@polkadot/react-hooks'; export default function useCounter (): number { const { api, isApiReady } = useApi(); - const bounties = useCall(isApiReady && (api.query.bounties || api.query.treasury)?.bountyCount); + const bounties = useCall(isApiReady && api.derive.bounties?.bounties); return useMemo( - () => bounties?.toNumber() || 0, + () => bounties?.length || 0, [bounties] ); }