Fix apps-routing for staking (Westend) (#10394)
* Fix apps-routing for staking (Westend) * comment
This commit is contained in:
parent
b79463b576
commit
0cf860f5d7
@ -45,15 +45,25 @@ function needsApiCheck (api: ApiPromise): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// For compatibility - `api.query.staking.ledger` returns `legacyClaimedRewards` instead of `claimedRewards` as of v1.4
|
||||
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');
|
||||
if ((v as unknown as { claimedRewards: Vec<u32> }).claimedRewards) {
|
||||
assert((v as unknown as { claimedRewards: Vec<u32> }).claimedRewards.eq([1, 2, 3]), 'Needs a claimedRewards array');
|
||||
} else {
|
||||
const v = api.registry.createType<PalletStakingStakingLedger>(
|
||||
unwrapStorageType(api.registry, api.query.staking.ledger.creator.meta.type),
|
||||
{ legacyClaimedRewards: [1, 2, 3] }
|
||||
);
|
||||
|
||||
assert(v.legacyClaimedRewards.eq([1, 2, 3]), 'Needs a legacyClaimedRewards array');
|
||||
}
|
||||
} catch {
|
||||
console.warn('No known claimedRewards inside staking ledger, disabling staking route');
|
||||
console.warn('No known legacyClaimedRewards or claimedRewards inside staking ledger, disabling staking route');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user