From 6c98feeb740315e6c912e3fa334e510f92d9dc84 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 9 Dec 2022 08:01:29 +0200 Subject: [PATCH] Add missing 1 offset to slash retrieval (#8507) --- packages/react-hooks/src/useAvailableSlashes.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-hooks/src/useAvailableSlashes.ts b/packages/react-hooks/src/useAvailableSlashes.ts index 26e840e403..b7bf637700 100644 --- a/packages/react-hooks/src/useAvailableSlashes.ts +++ b/packages/react-hooks/src/useAvailableSlashes.ts @@ -8,7 +8,7 @@ import type { PalletStakingUnappliedSlash } from '@polkadot/types/lookup'; import { useEffect, useState } from 'react'; -import { BN, BN_ONE, BN_ZERO } from '@polkadot/util'; +import { BN, BN_HUNDRED, BN_ONE, BN_ZERO } from '@polkadot/util'; import { createNamedHook } from './createNamedHook'; import { useApi } from './useApi'; @@ -28,9 +28,10 @@ function useAvailableSlashesImpl (): [BN, PalletStakingUnappliedSlash[]][] { let unsub: Unsub | undefined; const [from, offset] = api.query.staking?.earliestUnappliedSlash ? [earliestSlash && earliestSlash.unwrapOr(null), BN_ZERO] - : [indexes?.activeEra, api.consts.staking?.slashDeferDuration]; + // future depth (one more than activeEra for delay) + : [indexes?.activeEra, BN_ONE.add(api.consts.staking?.slashDeferDuration || BN_HUNDRED)]; - if (mountedRef.current && indexes && from && offset) { + if (mountedRef.current && indexes && from) { const range: BN[] = []; const end = indexes.activeEra.add(offset); let start = new BN(from);