@@ -613,6 +613,15 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
613613 this . _retrieveMapKeys ( creator , blockHash , args ) ) ) ;
614614 }
615615
616+ if ( this . supportMulti && creator . meta . type . isMap ) {
617+ // When using double map storage function, user need to pass double map key as an array
618+ decorated . multi = decorateMethod ( ( args : unknown [ ] ) : Observable < Codec [ ] > =>
619+ creator . meta . type . asMap . hashers . length === 1
620+ ? this . _retrieveMulti ( args . map ( ( a ) => [ creator , [ a ] ] ) , blockHash )
621+ : this . _retrieveMulti ( args . map ( ( a ) => [ creator , a as unknown [ ] ] ) , blockHash )
622+ ) ;
623+ }
624+
616625 /* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
617626
618627 return this . _decorateFunctionMeta ( creator as unknown as MetaDecoration , decorated ) as unknown as QueryableStorageEntry < ApiType > ;
@@ -647,17 +656,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
647656 }
648657
649658 // retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
650- private _retrieveMulti ( keys : [ StorageEntry , unknown [ ] ] [ ] ) : Observable < Codec [ ] > {
659+ private _retrieveMulti ( keys : [ StorageEntry , unknown [ ] ] [ ] , blockHash ?: Uint8Array ) : Observable < Codec [ ] > {
651660 if ( ! keys . length ) {
652661 return of ( [ ] ) ;
653662 }
654663
655- const queryCall = this . hasSubscriptions
664+ const queryCall = this . hasSubscriptions && ! blockHash
656665 ? this . _rpcCore . state . subscribeStorage
657666 : this . _rpcCore . state . queryStorageAt ;
658667
659668 return combineLatest (
660- arrayChunk ( keys , PAGE_SIZE_V ) . map ( ( keys ) => queryCall ( keys ) )
669+ arrayChunk ( keys , PAGE_SIZE_V ) . map ( ( k ) =>
670+ blockHash
671+ ? queryCall ( k , blockHash )
672+ : queryCall ( k )
673+ )
661674 ) . pipe (
662675 map ( arrayFlatten )
663676 ) ;
0 commit comments