Ensure call is exposed on rx (#5116)
* Ensure call is exposed on rx * Adjust to only top-level detection * .123npm * Adjust check for contractsApi
This commit is contained in:
+1
-1
@@ -37,7 +37,7 @@
|
||||
"@babel/core": "^7.18.9",
|
||||
"@babel/register": "^7.18.9",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/dev": "^0.67.85",
|
||||
"@polkadot/dev": "^0.67.86",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^28.1.6",
|
||||
"copyfiles": "^2.4.1"
|
||||
|
||||
@@ -29,7 +29,7 @@ export abstract class Base<ApiType extends ApiTypes> {
|
||||
} else if (!api.tx.contracts || !isFunction(api.tx.contracts.instantiateWithCode) || api.tx.contracts.instantiateWithCode.meta.args.length !== 6) {
|
||||
throw new Error('The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit');
|
||||
} else if (!api.call.contractsApi || !isFunction(api.call.contractsApi.call)) {
|
||||
throw new Error('Your runtime does not expose the api.call.contractsApi.call method');
|
||||
throw new Error('Your runtime does not expose the api.call.contractsApi.call runtime interfaces');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { map } from 'rxjs';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
|
||||
import { BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isUndefined, logger } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent } from '../util';
|
||||
@@ -26,7 +26,6 @@ export interface ContractConstructor<ApiType extends ApiTypes> {
|
||||
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
|
||||
const l = logger('Contract');
|
||||
|
||||
@@ -78,15 +77,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
});
|
||||
}
|
||||
|
||||
public get hasRpcContractsApi (): boolean {
|
||||
return isFunction(this.api.rx.call.contractsApi?.call);
|
||||
}
|
||||
|
||||
public get query (): MapMessageQuery<ApiType> {
|
||||
if (!this.hasRpcContractsApi) {
|
||||
throw new Error(ERROR_NO_CALL);
|
||||
}
|
||||
|
||||
return this.#query;
|
||||
}
|
||||
|
||||
@@ -132,10 +123,6 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
};
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, storageDepositLimit = null, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||
if (!this.hasRpcContractsApi) {
|
||||
throw new Error(ERROR_NO_CALL);
|
||||
}
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
|
||||
return {
|
||||
|
||||
@@ -278,6 +278,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
this._errors = decoratedApi.errors;
|
||||
this._events = decoratedApi.events;
|
||||
this._query = decoratedApi.query;
|
||||
|
||||
this._rx.call = decoratedApi.rx.call;
|
||||
this._rx.query = decoratedApi.rx.query;
|
||||
|
||||
const tx = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
||||
|
||||
@@ -2044,9 +2044,9 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@polkadot/dev@npm:^0.67.85":
|
||||
version: 0.67.85
|
||||
resolution: "@polkadot/dev@npm:0.67.85"
|
||||
"@polkadot/dev@npm:^0.67.86":
|
||||
version: 0.67.86
|
||||
resolution: "@polkadot/dev@npm:0.67.86"
|
||||
dependencies:
|
||||
"@babel/cli": ^7.18.9
|
||||
"@babel/core": ^7.18.9
|
||||
@@ -2108,7 +2108,7 @@ __metadata:
|
||||
mkdirp: ^1.0.4
|
||||
prettier: ^2.7.1
|
||||
rimraf: ^3.0.2
|
||||
rollup: ^2.77.0
|
||||
rollup: ^2.77.2
|
||||
rollup-plugin-cleanup: ^3.2.1
|
||||
typescript: ^4.7.4
|
||||
yargs: ^17.5.1
|
||||
@@ -2135,7 +2135,7 @@ __metadata:
|
||||
polkadot-exec-rollup: scripts/polkadot-exec-rollup.mjs
|
||||
polkadot-exec-tsc: scripts/polkadot-exec-tsc.mjs
|
||||
polkadot-exec-webpack: scripts/polkadot-exec-webpack.mjs
|
||||
checksum: b800ce26d995d3479c1205570ac9973cf2e067f8529ebe4649dac9209b448cfe3e24c99c5b252b0d014b3566bd65be514cef2f0e2d1b926d0e6fa64fbf9c3d3d
|
||||
checksum: 41ac7a45c3dbbd017b31799b9cee7df5abc2ceb7535f47b1015470a283e7ec0c0f14a95acb6f7c96e950e60cda88d000e87d75ef22f0dd659fd4c9e1cfb22c85
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -9211,9 +9211,9 @@ resolve@^2.0.0-next.3:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"rollup@npm:^2.77.0":
|
||||
version: 2.77.0
|
||||
resolution: "rollup@npm:2.77.0"
|
||||
"rollup@npm:^2.77.2":
|
||||
version: 2.77.2
|
||||
resolution: "rollup@npm:2.77.2"
|
||||
dependencies:
|
||||
fsevents: ~2.3.2
|
||||
dependenciesMeta:
|
||||
@@ -9221,7 +9221,7 @@ resolve@^2.0.0-next.3:
|
||||
optional: true
|
||||
bin:
|
||||
rollup: dist/bin/rollup
|
||||
checksum: 74ccc98429709984a89af636250833e7502d87f1d9c6d96ebfe4b52030ebf94b9f6b84b8ab476670329a61d54b681d35eecdc601bac5b5396b099b1ea69970ef
|
||||
checksum: 5a84fb98a6f858906bceba091430442f6c1f362b07c5fa9123b708f87e39f52640e34a189cd9a1776ceae61300055c78ba648205fa03188451539ebeb19797df
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -9232,7 +9232,7 @@ resolve@^2.0.0-next.3:
|
||||
"@babel/core": ^7.18.9
|
||||
"@babel/register": ^7.18.9
|
||||
"@babel/runtime": ^7.18.9
|
||||
"@polkadot/dev": ^0.67.85
|
||||
"@polkadot/dev": ^0.67.86
|
||||
"@polkadot/typegen": "workspace:packages/typegen"
|
||||
"@types/jest": ^28.1.6
|
||||
copyfiles: ^2.4.1
|
||||
|
||||
Reference in New Issue
Block a user