From 51d4c45c48cf3465e3ad635cfdd312b3400bf86d Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Tue, 2 Oct 2018 15:56:11 +0200 Subject: [PATCH] Add toJSON function for substrate meta (#188) --- packages/type-storage/src/substrate.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/type-storage/src/substrate.ts b/packages/type-storage/src/substrate.ts index 7ecf3472ec..364391113d 100644 --- a/packages/type-storage/src/substrate.ts +++ b/packages/type-storage/src/substrate.ts @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -import { StorageFunctionModifier, StorageFunctionType } from '@polkadot/types/Metadata'; +import { StorageFunctionMetadata, StorageFunctionModifier, StorageFunctionType } from '@polkadot/types/Metadata'; import Text from '@polkadot/types/Text'; import Vector from '@polkadot/types/codec/Vector'; @@ -15,18 +15,16 @@ interface SubstrateMetadata { // Small helper function to factorize code on this page. const createRuntimeFunction = (method: string, key: string, { documentation, type }: SubstrateMetadata) => - // TODO The expected 2nd argument is a StorageFunctionMetadata, but we - // actually only need the fields `documentation` and `type` of it, so in - // order to not input other fields (byteLength, fromJSON...) we lazily cast - // as any. createFunction( new Text('Substrate'), new Text(key), { documentation: new Vector(Text, [documentation]), modifier: new StorageFunctionModifier().fromJSON(0), - type: new StorageFunctionType(0, type) - } as any, + type: new StorageFunctionType(0, type), + toJSON: (): any => + key + } as StorageFunctionMetadata, { isUnhashed: true, method