ContractRegistry always has own registry instance (#2705)

* ContractRegistry always has own registry instance

* Hacky Bytes notation

* Revert Bytes (for now, keep it simple)

* Apply suggestions from code review

* Expand on found error
This commit is contained in:
Jaco Greeff
2020-10-11 13:49:41 +02:00
committed by GitHub
parent c38afd4b5d
commit c098036ca5
5 changed files with 34 additions and 32 deletions
+2 -3
View File
@@ -5,7 +5,6 @@ import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AnyJson, Registry } from '@polkadot/types/types';
import { ApiObject } from '../types';
import { TypeRegistry } from '@polkadot/types';
import { assert } from '@polkadot/util';
import Abi from '../Abi';
@@ -20,11 +19,11 @@ export default abstract class Base<ApiType extends ApiTypes> {
protected readonly _decorateMethod: DecorateMethod<ApiType>;
constructor (api: ApiObject<ApiType>, abi: AnyJson | Abi, decorateMethod: DecorateMethod<ApiType>) {
this.registry = new TypeRegistry();
this.abi = abi instanceof Abi
? abi
: new Abi(this.registry, abi);
: new Abi(abi);
this.api = api;
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(this.api.rx.tx.contracts && this.api.rx.tx.contracts.putCode, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');