@@ -168,11 +168,15 @@ export function _stakerRewardsEras (instanceId: string, api: DeriveApi): (eras:
168
168
}
169
169
170
170
export function _stakerRewards ( instanceId : string , api : DeriveApi ) : ( accountIds : ( Uint8Array | string ) [ ] , eras : EraIndex [ ] , withActive ?: boolean ) => Observable < DeriveStakerReward [ ] [ ] > {
171
- return memo ( instanceId , ( accountIds : ( Uint8Array | string ) [ ] , eras : EraIndex [ ] , withActive = false ) : Observable < DeriveStakerReward [ ] [ ] > =>
172
- combineLatest ( [
171
+ return memo ( instanceId , ( accountIds : ( Uint8Array | string ) [ ] , eras : EraIndex [ ] , withActive = false ) : Observable < DeriveStakerReward [ ] [ ] > => {
172
+ // Ensures that when number or string types are passed in they are sanitized
173
+ // Ref: https://github.com/polkadot-js/api/issues/5910
174
+ const sanitizedEras : EraIndex [ ] = eras . map ( ( e ) => typeof e === 'number' || typeof e === 'string' ? api . registry . createType ( 'u32' , e ) : e ) ;
175
+
176
+ return combineLatest ( [
173
177
api . derive . staking . queryMulti ( accountIds , { withClaimedRewardsEras : true , withLedger : true } ) ,
174
- api . derive . staking . _stakerExposures ( accountIds , eras , withActive ) ,
175
- api . derive . staking . _stakerRewardsEras ( eras , withActive )
178
+ api . derive . staking . _stakerExposures ( accountIds , sanitizedEras , withActive ) ,
179
+ api . derive . staking . _stakerRewardsEras ( sanitizedEras , withActive )
176
180
] ) . pipe (
177
181
switchMap ( ( [ queries , exposures , erasResult ] ) : Observable < DeriveStakerReward [ ] [ ] > => {
178
182
const allRewards = queries . map ( ( { claimedRewardsEras, stakingLedger, stashId } , index ) : DeriveStakerReward [ ] =>
@@ -208,7 +212,8 @@ export function _stakerRewards (instanceId: string, api: DeriveApi): (accountIds
208
212
)
209
213
) ;
210
214
} )
211
- )
215
+ ) ;
216
+ }
212
217
) ;
213
218
}
214
219
0 commit comments