Provide chain properties for contract registry (#2714)

This commit is contained in:
Jaco Greeff
2020-10-12 15:53:45 +02:00
committed by GitHub
parent 76c206d60d
commit 1643ec7ddf
3 changed files with 11 additions and 6 deletions
+3 -3
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import { AnyJson } from '@polkadot/types/types';
import { InkConstructorSpec, InkMessageSpec } from '@polkadot/types/interfaces';
import { ChainProperties, InkConstructorSpec, InkMessageSpec } from '@polkadot/types/interfaces';
import { AbiConstructor, AbiMessage, AbiMessageParam } from './types';
import { assert, isNumber, isObject, isString, stringCamelCase } from '@polkadot/util';
@@ -28,14 +28,14 @@ export default class Abi extends ContractRegistry {
public readonly messages: AbiMessage[];
constructor (abiJson: AnyJson) {
constructor (abiJson: AnyJson, chainProperties?: ChainProperties) {
const json = isString(abiJson)
? JSON.parse(abiJson) as AnyJson
: abiJson;
assert(isObject(json) && !Array.isArray(json) && json.metadataVersion && isObject(json.spec) && !Array.isArray(json.spec) && Array.isArray(json.spec.constructors) && Array.isArray(json.spec.messages), 'Invalid JSON ABI structure supplied, expected a recent metadata version');
super(json);
super(json, chainProperties);
this.json = json;
this.constructors = this.project.spec.constructors.map((spec: InkConstructorSpec, index) =>