Disable staking for unknown rewards handling (#10108)
* Disable staking for unknown rewards handling * claimedRewards * Adjust * Remove unused import * No need for ?. protect
This commit is contained in:
parent
fd3c502890
commit
e0c792c030
@ -2,7 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiPromise } from '@polkadot/api';
|
||||
import type { PalletStakingExposure } from '@polkadot/types/lookup';
|
||||
import type { u32, Vec } from '@polkadot/types';
|
||||
import type { PalletStakingExposure, PalletStakingStakingLedger } from '@polkadot/types/lookup';
|
||||
import type { Route, TFunction } from './types.js';
|
||||
|
||||
import Component from '@polkadot/app-staking';
|
||||
@ -44,6 +45,19 @@ function needsApiCheck (api: ApiPromise): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const v = api.registry.createType<PalletStakingStakingLedger>(
|
||||
unwrapStorageType(api.registry, api.query.staking.ledger.creator.meta.type),
|
||||
{ claimedRewards: [1, 2, 3] }
|
||||
);
|
||||
|
||||
assert((v as unknown as { claimedRewards: Vec<u32> }).claimedRewards.eq([1, 2, 3]), 'Needs a claimedRewards array');
|
||||
} catch {
|
||||
console.warn('No known claimedRewards inside staking ledger, disabling staking route');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user