diff --git a/packages/api/src/base/Decorate.ts b/packages/api/src/base/Decorate.ts index e30883c287..9da068d1f5 100644 --- a/packages/api/src/base/Decorate.ts +++ b/packages/api/src/base/Decorate.ts @@ -17,7 +17,7 @@ import DecoratedMeta from '@polkadot/metadata/Decorated'; import getHasher from '@polkadot/metadata/Decorated/storage/fromMetadata/getHasher'; import RpcCore from '@polkadot/rpc-core'; import { WsProvider } from '@polkadot/rpc-provider'; -import { Metadata, Null, Option, Text, TypeRegistry, u64 } from '@polkadot/types'; +import { Metadata, Null, Option, Raw, Text, TypeRegistry, u64 } from '@polkadot/types'; import Linkage, { LinkageResult } from '@polkadot/types/codec/Linkage'; import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants'; import StorageKey, { StorageEntry, unwrapStorageType } from '@polkadot/types/primitive/StorageKey'; @@ -452,16 +452,17 @@ export default abstract class Decorate extends Events )) ) .pipe( - switchMap((keys): Observable<[StorageKey[], Option[]]> => + switchMap((keys): Observable<[StorageKey[], Option[]]> => combineLatest([ of(keys.map((key) => key.decodeArgsFromMeta(meta))), - this._rpcCore.state.subscribeStorage[]>(keys) + // since we have a default constructed key, we have Option as the result + this._rpcCore.state.subscribeStorage[]>(keys) ]) ), map(([keys, values]): [StorageKey, Codec][] => keys.map((key, index): [StorageKey, Codec] => [ key, - this.createType(outputType, values[index].unwrapOrDefault()) + this.createType(outputType, values[index].unwrapOr(undefined)) ]) ) );