Cater for Abi type offsets in 1+ (#3514)

* Cater for Abi type offsets in 1+

* Update packages/api-contract/src/MetaRegistry.ts
This commit is contained in:
Jaco
2021-05-11 10:01:27 +02:00
committed by GitHub
parent cc0ad9b04b
commit 206fb49df5
2 changed files with 14 additions and 7 deletions
+2 -2
View File
@@ -45,13 +45,13 @@ export class Abi {
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');
this.json = json;
this.registry = new MetaRegistry(chainProperties);
this.registry = new MetaRegistry(json.metadataVersion as string, chainProperties);
this.project = this.registry.createType('ContractProject', json);
this.registry.setMetaTypes(this.project.types);
this.project.types.forEach((_, index) =>
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + 1) })
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) })
);
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
this.#createMessage(spec, index, {