@@ -687,13 +687,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
687687
688688 const headKey = iterKey ( ...args ) . toHex ( ) ;
689689 const startSubject = new BehaviorSubject < string > ( headKey ) ;
690- const queryCall = at
690+ const getKeysPaged = at
691691 ? ( startKey : string ) => this . _rpcCore . state . getKeysPaged ( headKey , PAGE_SIZE_K , startKey , at )
692692 : ( startKey : string ) => this . _rpcCore . state . getKeysPaged ( headKey , PAGE_SIZE_K , startKey ) ;
693693 const setMeta = ( key : StorageKey ) => key . setMeta ( meta , section , method ) ;
694694
695695 return startSubject . pipe (
696- switchMap ( queryCall ) ,
696+ switchMap ( getKeysPaged ) ,
697697 map ( ( keys ) => keys . map ( setMeta ) ) ,
698698 tap ( ( keys ) : void => {
699699 setTimeout ( ( ) : void => {
@@ -710,23 +710,25 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
710710 private _retrieveMapKeysPaged ( { iterKey, meta, method, section } : StorageEntry , at : Hash | Uint8Array | string | undefined , opts : PaginationOptions ) : Observable < StorageKey [ ] > {
711711 assert ( iterKey && meta . type . isMap , 'keys can only be retrieved on maps' ) ;
712712
713- const headKey = iterKey ( ...opts . args ) . toHex ( ) ;
714713 const setMeta = ( key : StorageKey ) => key . setMeta ( meta , section , method ) ;
714+ const getKeysPaged = at
715+ ? ( headKey : string ) => this . _rpcCore . state . getKeysPaged ( headKey , opts . pageSize , opts . startKey || headKey , at )
716+ : ( headKey : string ) => this . _rpcCore . state . getKeysPaged ( headKey , opts . pageSize , opts . startKey || headKey ) ;
715717
716- return this . _rpcCore . state . getKeysPaged ( headKey , opts . pageSize , opts . startKey || headKey , at ) . pipe (
718+ return getKeysPaged ( iterKey ( ... opts . args ) . toHex ( ) ) . pipe (
717719 map ( ( keys ) => keys . map ( setMeta ) )
718720 ) ;
719721 }
720722
721723 private _retrieveMapEntries ( entry : StorageEntry , at : Hash | Uint8Array | string | null , args : unknown [ ] ) : Observable < [ StorageKey , Codec ] [ ] > {
722- const query = at
723- ? ( keyset : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keyset , at )
724- : ( keyset : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keyset ) ;
724+ const queryStorageAt = at
725+ ? ( keys : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keys , at )
726+ : ( keys : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keys ) ;
725727
726728 return this . _retrieveMapKeys ( entry , at , args ) . pipe (
727729 switchMap ( ( keys ) =>
728730 keys . length
729- ? combineLatest ( arrayChunk ( keys , PAGE_SIZE_V ) . map ( query ) ) . pipe (
731+ ? combineLatest ( arrayChunk ( keys , PAGE_SIZE_V ) . map ( queryStorageAt ) ) . pipe (
730732 map ( ( valsArr ) =>
731733 arrayFlatten ( valsArr ) . map ( ( value , index ) : [ StorageKey , Codec ] => [ keys [ index ] , value ] )
732734 )
@@ -737,10 +739,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
737739 }
738740
739741 private _retrieveMapEntriesPaged ( entry : StorageEntry , at : Hash | Uint8Array | string | undefined , opts : PaginationOptions ) : Observable < [ StorageKey , Codec ] [ ] > {
742+ const queryStorageAt = at
743+ ? ( keys : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keys , at )
744+ : ( keys : StorageKey [ ] ) => this . _rpcCore . state . queryStorageAt ( keys ) ;
745+
740746 return this . _retrieveMapKeysPaged ( entry , at , opts ) . pipe (
741747 switchMap ( ( keys ) =>
742748 keys . length
743- ? this . _rpcCore . state . queryStorageAt ( keys , at ) . pipe (
749+ ? queryStorageAt ( keys ) . pipe (
744750 map ( ( valsArr ) =>
745751 valsArr . map ( ( value , index ) : [ StorageKey , Codec ] => [ keys [ index ] , value ] )
746752 )
0 commit comments