Add missing 1 offset to slash retrieval (#8507)

This commit is contained in:
Jaco 2022-12-09 08:01:29 +02:00 committed by GitHub
parent a5708a2fa6
commit 6c98feeb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);