Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error parsing metadata for pallets storage #695

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/services/pallets/PalletsStorageService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Text, Vec } from '@polkadot/types';
import {
BlockHash,
ModuleMetadataV12,
StorageEntryMetadataV12,
ModuleMetadataV13,
StorageEntryMetadataV13,
} from '@polkadot/types/interfaces';
import { stringCamelCase } from '@polkadot/util';
import { BadRequest, InternalServerError } from 'http-errors';
Expand Down Expand Up @@ -110,7 +110,7 @@ export class PalletsStorageService extends AbstractService {
* @param storageItemMeta polkadot-js StorageEntryMetadataV12
*/
private normalizeStorageItemMeta(
storageItemMeta: StorageEntryMetadataV12
storageItemMeta: StorageEntryMetadataV13
): ISanitizedStorageItemMetadata {
const normalizedStorageItemMeta = sanitizeNumbers(
storageItemMeta
Expand All @@ -128,9 +128,9 @@ export class PalletsStorageService extends AbstractService {
* @param storageId name of the storage item in camel or pascal case
*/
private findStorageItemMeta(
palletMeta: ModuleMetadataV12,
palletMeta: ModuleMetadataV13,
storageItemId: string
): StorageEntryMetadataV12 {
): StorageEntryMetadataV13 {
if (palletMeta.storage.isNone) {
throw new InternalServerError(
`No storage items found in ${palletMeta.name.toString()}'s metadata`
Expand All @@ -156,15 +156,15 @@ export class PalletsStorageService extends AbstractService {
*
* @param palletId identifier for a FRAME pallet as a pallet name or index.
*/
private findPalletMeta(palletId: string): [ModuleMetadataV12, number] {
const { modules } = this.api.runtimeMetadata.asV12;
private findPalletMeta(palletId: string): [ModuleMetadataV13, number] {
const { modules } = this.api.runtimeMetadata.asV13;

const { isValidPalletName, isValidPalletIndex, parsedPalletId } =
this.validPalletId(modules, palletId);

const filtered = modules.filter((mod) => mod.storage.isSome);

let palletMeta: ModuleMetadataV12 | undefined;
let palletMeta: ModuleMetadataV13 | undefined;
let palletIdx: number | undefined;

if (isValidPalletIndex) {
Expand Down Expand Up @@ -210,7 +210,7 @@ export class PalletsStorageService extends AbstractService {
}

private validPalletId(
modules: Vec<ModuleMetadataV12>,
modules: Vec<ModuleMetadataV13>,
palletId: string
): {
isValidPalletName: boolean;
Expand Down