diff --git a/packages/api-derive/src/staking/stakerRewards.ts b/packages/api-derive/src/staking/stakerRewards.ts index c9ad0217d2ac..1dcca87824b2 100644 --- a/packages/api-derive/src/staking/stakerRewards.ts +++ b/packages/api-derive/src/staking/stakerRewards.ts @@ -168,11 +168,15 @@ export function _stakerRewardsEras (instanceId: string, api: DeriveApi): (eras: } export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive?: boolean) => Observable { - return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive = false): Observable => - combineLatest([ + return memo(instanceId, (accountIds: (Uint8Array | string)[], eras: EraIndex[], withActive = false): Observable => { + // Ensures that when number or string types are passed in they are sanitized + // Ref: https://github.com/polkadot-js/api/issues/5910 + const sanitizedEras: EraIndex[] = eras.map((e) => typeof e === 'number' || typeof e === 'string' ? api.registry.createType('u32', e) : e); + + return combineLatest([ api.derive.staking.queryMulti(accountIds, { withClaimedRewardsEras: true, withLedger: true }), - api.derive.staking._stakerExposures(accountIds, eras, withActive), - api.derive.staking._stakerRewardsEras(eras, withActive) + api.derive.staking._stakerExposures(accountIds, sanitizedEras, withActive), + api.derive.staking._stakerRewardsEras(sanitizedEras, withActive) ]).pipe( switchMap(([queries, exposures, erasResult]): Observable => { const allRewards = queries.map(({ claimedRewardsEras, stakingLedger, stashId }, index): DeriveStakerReward[] => @@ -208,7 +212,8 @@ export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds ) ); }) - ) + ); + } ); }