Cleanup assignments (#2811)

* Cleanup assignments

* Small adjustments

* Cleanup AnyJson results

* Event toHuman
This commit is contained in:
Jaco Greeff
2020-10-31 12:50:44 +01:00
committed by GitHub
parent 5be8ef8f0d
commit 94a4594d32
16 changed files with 70 additions and 108 deletions
+2 -4
View File
@@ -11,7 +11,7 @@ import { ContractRead, MapMessageExec, MapMessageRead } from './types';
import BN from 'bn.js';
import { map } from 'rxjs/operators';
import ApiBase from '@polkadot/api/base';
import { assert, bnToBn, isFunction, isObject, isUndefined, stringCamelCase } from '@polkadot/util';
import { assert, bnToBn, isFunction, isUndefined, stringCamelCase } from '@polkadot/util';
import Abi from '../Abi';
import { formatData } from '../util';
@@ -20,9 +20,7 @@ import Base from './Base';
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
// map from a JSON result to current-style ContractExecResult
function mapExecResult (registry: Registry, json: AnyJson): ContractExecResult {
assert(isObject(json) && !Array.isArray(json), 'Invalid JSON result retrieved');
function mapExecResult (registry: Registry, json: Record<string, AnyJson>): ContractExecResult {
if (!Object.keys(json).some((key) => ['error', 'success'].includes(key))) {
return registry.createType('ContractExecResult', json);
}