Additional check for API connection & decoration in contracts (#3654)

* Additional check for API connection & decoration in contracts

* Remove snuck-in-file
This commit is contained in:
Jaco
2021-06-15 11:08:47 +02:00
committed by GitHub
parent 6015552aab
commit 7cd2fa5f6a
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(isFunction(api.tx.contracts?.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
assert(!!(api && api.isConnected && api.tx && api.tx.contracts && Object.keys(api.tx.contracts).length), 'Your API has not been initialized correctly and it not decorated with the runtime interfaces for contracts as retrieved from the on-chain runtime');
assert(isFunction(api.tx.contracts.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
}
}
+1
View File
@@ -7,6 +7,7 @@ import { TypeRegistry } from '@polkadot/types';
const registry = new TypeRegistry();
export const mockApi = {
isConnected: true,
registry,
tx: {
contracts: {