From bed3f9f4c577fbe49ccfa67d5f86a82519e4cf3a Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 16 Sep 2019 11:40:54 +0200 Subject: [PATCH] Add rpc_methods (#1397) * Add rpc_methods * Adjust interface tests * Add account_nextIndex & contracts_call, filter * Rework AbstractArray includes with some * Adjust tests * Ordering * Correct definitions (pull in from methods) * Be agressive on filtering, regardless of isOptional * async/await in filterRpcMethods * map Text[] -> string[] * Correct naming for account_nextIndex * Remove/don't remove rpc_methods as applicable * Cleanup method handling errors --- packages/api/src/base/Decorate.ts | 41 ++++++++++++++++++- packages/api/src/base/Init.ts | 3 ++ packages/rpc-core/src/index.spec.ts | 2 +- packages/rpc-core/src/index.ts | 14 ++++++- packages/rpc-core/src/jsonrpc.types.ts | 14 ++++++- packages/rpc-provider/src/coder/index.ts | 2 - packages/type-jsonrpc/src/account.ts | 34 +++++++++++++++ packages/type-jsonrpc/src/contracts.ts | 35 ++++++++++++++++ packages/type-jsonrpc/src/create/method.ts | 3 +- packages/type-jsonrpc/src/index.ts | 6 +++ packages/type-jsonrpc/src/rpc.ts | 30 ++++++++++++++ packages/type-jsonrpc/src/types.ts | 2 + packages/types/src/codec/AbstractArray.ts | 7 ++++ packages/types/src/interfaceRegistry.ts | 16 +++++++- .../src/interfaces/contracts/definitions.ts | 17 ++++++++ .../types/src/interfaces/contracts/types.ts | 36 +++++++++++++++- .../types/src/interfaces/rpc/definitions.ts | 4 ++ packages/types/src/interfaces/rpc/types.ts | 8 ++++ 18 files changed, 262 insertions(+), 12 deletions(-) create mode 100644 packages/type-jsonrpc/src/account.ts create mode 100644 packages/type-jsonrpc/src/contracts.ts create mode 100644 packages/type-jsonrpc/src/rpc.ts diff --git a/packages/api/src/base/Decorate.ts b/packages/api/src/base/Decorate.ts index 2e49574a3e..1378b5672c 100644 --- a/packages/api/src/base/Decorate.ts +++ b/packages/api/src/base/Decorate.ts @@ -2,6 +2,7 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { RpcMethod } from '@polkadot/jsonrpc/types'; import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types'; import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces'; import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ModulesWithCalls } from '@polkadot/types/types'; @@ -14,6 +15,7 @@ import { map, switchMap } from 'rxjs/operators'; import decorateDerive from '@polkadot/api-derive'; import { Constants } from '@polkadot/api-metadata/consts/types'; import { Storage } from '@polkadot/api-metadata/storage/types'; +import jsonrpc from '@polkadot/jsonrpc'; import RpcCore from '@polkadot/rpc-core'; import { WsProvider } from '@polkadot/rpc-provider'; import { Metadata, Null, u64 } from '@polkadot/types'; @@ -62,6 +64,8 @@ export default abstract class Decorate extends Events { protected _rpcCore: RpcCore; + private _rpcMap: Map = new Map(); + protected _runtimeMetadata?: Metadata; protected _runtimeVersion?: RuntimeVersion; @@ -133,14 +137,49 @@ export default abstract class Decorate extends Events { return output; } + // Filter all RPC methods based on the results of the rpc_methods call. We do this in the following + // manner to cater for both old and new: + // - when the number of entries are 0, only remove the ones with isOptional (account & contracts) + // - when non-zero, remove anything that is not in the array (we don't do this) + protected async filterRpcMethods (): Promise { + let methods: string[]; + + try { + // we ignore the version (adjust as versions change, for now only "1") + methods = (await this._rpcCore.rpc.methods().toPromise()).methods.map((t) => t.toString()); + } catch (error) { + // the method is not there, we adjust accordingly + methods = []; + } + + // this is true when the RPC has entries + const hasResults = methods.length !== 0; + + // loop through all entries we have (populated in decorate) and filter as required + [...this._rpcMap.entries()] + .filter(([key, { isOptional }]): boolean => + // only remove when we have results and method missing, or with no results if optional + hasResults + ? !methods.includes(key) && key !== 'rpc_methods' // rpc_methods doesn't appear, v1 + : isOptional || key === 'rpc_methods' // we didn't find this one, remove + ) + .forEach(([_, { method, section }]): void => { + delete (this._rpc as any)[section][method]; + delete (this._rx.rpc as any)[section][method]; + }); + } + protected decorateRpc (rpc: RpcCore, decorateMethod: Decorate['decorateMethod']): DecoratedRpc { - return ['author', 'chain', 'state', 'system'].reduce((out, _sectionName): DecoratedRpc => { + return Object.keys(jsonrpc).reduce((out, _sectionName): DecoratedRpc => { const sectionName = _sectionName as keyof DecoratedRpc; // out and section here are horrors to get right from a typing perspective :() (out as any)[sectionName] = Object.entries(rpc[sectionName]).reduce((section, [methodName, method]): DecoratedRpcSection => { (section as any)[methodName] = decorateMethod(method, { methodName }); + // add this endpoint mapping to our internal map - we use this for filters + this._rpcMap.set(`${sectionName}_${methodName}`, jsonrpc[sectionName].methods[methodName]); + return section; }, {} as unknown as DecoratedRpcSection); diff --git a/packages/api/src/base/Init.ts b/packages/api/src/base/Init.ts index 8c2e70e83e..f08b40dd8e 100644 --- a/packages/api/src/base/Init.ts +++ b/packages/api/src/base/Init.ts @@ -108,6 +108,9 @@ export default abstract class Init extends Decorate { ...(typesChain[chain.toString()] || {}) }); + // filter the RPC methods (this does an rpc-methods call) + await this.filterRpcMethods(); + // retrieve metadata, either from chain or as pass-in via options const metadataKey = `${genesisHash}-${runtimeVersion.specVersion}`; const metadata = metadataKey in optMetadata diff --git a/packages/rpc-core/src/index.spec.ts b/packages/rpc-core/src/index.spec.ts index 462ffe5360..1efcadefed 100644 --- a/packages/rpc-core/src/index.spec.ts +++ b/packages/rpc-core/src/index.spec.ts @@ -20,7 +20,7 @@ describe('Api', (): void => { Object.keys(rpc).filter((key): boolean => !key.startsWith('_')) ).toEqual([ 'provider', - 'author', 'chain', 'state', 'system' + 'account', 'author', 'chain', 'contracts', 'rpc', 'state', 'system' ]); }); }); diff --git a/packages/rpc-core/src/index.ts b/packages/rpc-core/src/index.ts index 9726bbd90e..3cef718023 100644 --- a/packages/rpc-core/src/index.ts +++ b/packages/rpc-core/src/index.ts @@ -56,10 +56,16 @@ export default class Rpc implements RpcInterface { public readonly provider: ProviderInterface; + public readonly account: RpcInterface['account']; + public readonly author: RpcInterface['author']; public readonly chain: RpcInterface['chain']; + public readonly contracts: RpcInterface['contracts']; + + public readonly rpc: RpcInterface['rpc']; + public readonly state: RpcInterface['state']; public readonly system: RpcInterface['system']; @@ -75,8 +81,11 @@ export default class Rpc implements RpcInterface { this.provider = provider; + this.account = this.createInterface('account'); this.author = this.createInterface('author'); + this.contracts = this.createInterface('contracts'); this.chain = this.createInterface('chain'); + this.rpc = this.createInterface('rpc'); this.state = this.createInterface('state'); this.system = this.createInterface('system'); } @@ -161,7 +170,10 @@ export default class Rpc implements RpcInterface { catchError((error): any => { const message = this.createErrorMessage(method, error); - l.error(message); + // don't scare with old nodes, this is handled transparently + if (rpcName !== 'rpc_methods') { + l.error(message); + } return throwError(new Error(message)); }), diff --git a/packages/rpc-core/src/jsonrpc.types.ts b/packages/rpc-core/src/jsonrpc.types.ts index f8afc2539d..cc0e5617d8 100644 --- a/packages/rpc-core/src/jsonrpc.types.ts +++ b/packages/rpc-core/src/jsonrpc.types.ts @@ -4,11 +4,15 @@ import { Observable } from 'rxjs'; import { Vec } from '@polkadot/types/codec'; import { Bytes, Metadata, StorageData, StorageKey, Text, u64 } from '@polkadot/types'; -import { BlockNumber, Extrinsic, Hash, Header, SignedBlock } from '@polkadot/types/interfaces/runtime'; -import { ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RuntimeVersion, StorageChangeSet } from '@polkadot/types/interfaces/rpc'; +import { AccountId, BlockNumber, Extrinsic, Hash, Header, Index, SignedBlock } from '@polkadot/types/interfaces/runtime'; +import { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts'; +import { ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, NetworkState, PeerInfo, RpcMethods, RuntimeVersion, StorageChangeSet } from '@polkadot/types/interfaces/rpc'; import { Codec, IExtrinsic } from '@polkadot/types/types'; export interface RpcInterface { + account: { + nextIndex(accountId: AccountId | Uint8Array | string): Observable; + }; author: { insertKey(keyType: Text | string, suri: Text | string, publicKey: Bytes | Uint8Array | string): Observable; pendingExtrinsics(): Observable>; @@ -25,6 +29,12 @@ export interface RpcInterface { subscribeFinalizedHeads(): Observable
; subscribeNewHeads(): Observable
; }; + contracts: { + call(callRequest: ContractCallRequest, at?: Hash | Uint8Array | string): Observable; + }; + rpc: { + methods(): Observable; + }; state: { call(method: Text | string, data: Bytes | Uint8Array | string, block?: Hash | Uint8Array | string): Observable; getChildKeys(childStorageKey: any, key: any, block?: Hash | Uint8Array | string): Observable>; diff --git a/packages/rpc-provider/src/coder/index.ts b/packages/rpc-provider/src/coder/index.ts index fe88ff885a..3cc7f07af5 100644 --- a/packages/rpc-provider/src/coder/index.ts +++ b/packages/rpc-provider/src/coder/index.ts @@ -56,8 +56,6 @@ export default class RpcCoder { ? '' : ' (' + `${data}`.substr(0, 10) + ')'; - console.error(`${code}: ${message}${_data}`); - throw new Error(`${code}: ${message}${_data}`); } } diff --git a/packages/type-jsonrpc/src/account.ts b/packages/type-jsonrpc/src/account.ts new file mode 100644 index 0000000000..d14f1bbf5e --- /dev/null +++ b/packages/type-jsonrpc/src/account.ts @@ -0,0 +1,34 @@ +// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { RpcMethodOpt } from './types'; + +import createMethod from './create/method'; +import createParam from './create/param'; + +// NOTE order here is the same as in Rust, alphabetical below + +const nextIndex: RpcMethodOpt = { + description: 'Retrieves the next accountIndex as available on the node', + isOptional: true, + params: [ + createParam('accountId', 'AccountId') + ], + type: 'Index' +}; + +const section = 'account'; + +/** + * @summary Calls to retrieve system info. + */ +export default { + isDeprecated: false, + isHidden: false, + description: '(Optional) Methods that retrieves account-specific information', + section, + methods: { + nextIndex: createMethod(section, 'nextIndex', nextIndex) + } +}; diff --git a/packages/type-jsonrpc/src/contracts.ts b/packages/type-jsonrpc/src/contracts.ts new file mode 100644 index 0000000000..17b2ee0adb --- /dev/null +++ b/packages/type-jsonrpc/src/contracts.ts @@ -0,0 +1,35 @@ +// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { RpcMethodOpt } from './types'; + +import createMethod from './create/method'; +import createParam from './create/param'; + +// NOTE order here is the same as in Rust, alphabetical below + +const call: RpcMethodOpt = { + description: 'Executes a call to a contract', + isOptional: true, + params: [ + createParam('callRequest', 'ContractCallRequest'), + createParam('at', 'Hash', { isOptional: true }) + ], + type: 'ContractExecResult' +}; + +const section = 'contracts'; + +/** + * @summary Calls to retrieve system info. + */ +export default { + isDeprecated: false, + isHidden: false, + description: '(Optional) Methods that performs actions on contracts', + section, + methods: { + call: createMethod(section, 'call', call) + } +}; diff --git a/packages/type-jsonrpc/src/create/method.ts b/packages/type-jsonrpc/src/create/method.ts index 79fe621b4c..6abccbaba8 100644 --- a/packages/type-jsonrpc/src/create/method.ts +++ b/packages/type-jsonrpc/src/create/method.ts @@ -6,11 +6,12 @@ import { RpcMethodOpt, RpcMethod } from '../types'; import { isUndefined } from '@polkadot/util'; -export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod { +export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isOptional = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod { return { description, isDeprecated, isHidden, + isOptional, isSigned, isSubscription: !isUndefined(pubsub), method, diff --git a/packages/type-jsonrpc/src/index.ts b/packages/type-jsonrpc/src/index.ts index d60af6f77d..dfc157ffdc 100644 --- a/packages/type-jsonrpc/src/index.ts +++ b/packages/type-jsonrpc/src/index.ts @@ -4,14 +4,20 @@ import { RpcSection } from './types'; +import account from './account'; import author from './author'; import chain from './chain'; +import contracts from './contracts'; +import rpc from './rpc'; import state from './state'; import system from './system'; const interfaces: Record = { + account, author, chain, + contracts, + rpc, state, system }; diff --git a/packages/type-jsonrpc/src/rpc.ts b/packages/type-jsonrpc/src/rpc.ts new file mode 100644 index 0000000000..c2138a27a8 --- /dev/null +++ b/packages/type-jsonrpc/src/rpc.ts @@ -0,0 +1,30 @@ +// Copyright 2017-2019 @polkadot/jsonrpc authors & contributors +// This software may be modified and distributed under the terms +// of the Apache-2.0 license. See the LICENSE file for details. + +import { RpcMethodOpt } from './types'; + +import createMethod from './create/method'; + +// NOTE order here is the same as in Rust, alphabetical below + +const methods: RpcMethodOpt = { + description: 'Retrieves the list of RPC methods that are exposed by the node', + params: [], + type: 'RpcMethods' +}; + +const section = 'rpc'; + +/** + * @summary Calls to retrieve system info. + */ +export default { + isDeprecated: false, + isHidden: false, + description: 'Retrieves information about the RPC endpoints', + section, + methods: { + methods: createMethod(section, 'methods', methods) + } +}; diff --git a/packages/type-jsonrpc/src/types.ts b/packages/type-jsonrpc/src/types.ts index ac5711f6f4..69fc4763fe 100644 --- a/packages/type-jsonrpc/src/types.ts +++ b/packages/type-jsonrpc/src/types.ts @@ -16,6 +16,7 @@ export interface RpcMethodOpt { description: string; isDeprecated?: boolean; isHidden?: boolean; + isOptional?: boolean; isSigned?: boolean; isSubscription?: boolean; params: RpcParam[]; @@ -28,6 +29,7 @@ export interface RpcMethod { description: string; isDeprecated: boolean; isHidden: boolean; + isOptional: boolean; isSigned: boolean; isSubscription: boolean; method: string; diff --git a/packages/types/src/codec/AbstractArray.ts b/packages/types/src/codec/AbstractArray.ts index 3ea2d13115..a536e0c511 100644 --- a/packages/types/src/codec/AbstractArray.ts +++ b/packages/types/src/codec/AbstractArray.ts @@ -135,4 +135,11 @@ export default abstract class AbstractArray extends Array im public map (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[] { return this.toArray().map(callbackfn, thisArg); } + + /** + * @description Checks if the array includes a specific value + */ + public includes (check: any): boolean { + return this.some((value: T): boolean => value.eq(check)); + } } diff --git a/packages/types/src/interfaceRegistry.ts b/packages/types/src/interfaceRegistry.ts index be68e8778a..d0b86fdeaa 100644 --- a/packages/types/src/interfaceRegistry.ts +++ b/packages/types/src/interfaceRegistry.ts @@ -10,7 +10,7 @@ import { BabeAuthorityWeight, BabeBlockWeight, BabeWeight, RawBabePreDigest, Raw import { BalanceLock, VestingSchedule, WithdrawReasons } from './interfaces/balances'; import { MemberCount, ProposalIndex, Votes } from './interfaces/collective'; import { AuthorityId } from './interfaces/consensus'; -import { AliveContractInfo, CodeHash, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, SeedOf, TombstoneContractInfo, TrieId } from './interfaces/contracts'; +import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, SeedOf, TombstoneContractInfo, TrieId } from './interfaces/contracts'; import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from './interfaces/democracy'; import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from './interfaces/deprecated'; import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from './interfaces/elections'; @@ -26,7 +26,7 @@ import { BlockAttestations, IncludedBlocks, MoreAttestations } from './interface import { EcdsaSignature, EthereumAddress } from './interfaces/claims'; import { AttestedCandidate, AuctionIndex, BalanceUpload, Bidder, CandidateReceipt, CollatorSignature, EgressQueueRoot, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, NewBidder, ParaId, ParaIdOf, ParachainDispatchOrigin, SlotRange, SubId, UpwardMessage, ValidatorIndex, ValidityAttestation, ValidityVote, WinningData, WinningDataEntry } from './interfaces/parachains'; import { CallMetadataV0, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, EventMetadataV0, EventMetadataV1, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, MapTypeV0, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MetadataV0, MetadataV1, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleMetadataV0, ModuleMetadataV1, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeV0, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, RuntimeModuleMetadataV0, StorageEntryModifierV6, StorageEntryModifierV7, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageMetadataV0 } from './interfaces/metadata'; -import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc'; +import { ApiId, ChainProperties, ExtrinsicOrHash, ExtrinsicStatus, Health, KeyValueOption, NetworkState, PeerInfo, RpcMethods, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from './interfaces/rpc'; export interface InterfaceRegistry { bool: bool; @@ -344,6 +344,15 @@ export interface InterfaceRegistry { CodeHash: CodeHash; 'Option': Option; 'Vec': Vec; + ContractCallRequest: ContractCallRequest; + 'Option': Option; + 'Vec': Vec; + ContractExecResultSuccess: ContractExecResultSuccess; + 'Option': Option; + 'Vec': Vec; + ContractExecResult: ContractExecResult; + 'Option': Option; + 'Vec': Vec; ContractInfo: ContractInfo; 'Option': Option; 'Vec': Vec; @@ -929,6 +938,9 @@ export interface InterfaceRegistry { PeerInfo: PeerInfo; 'Option': Option; 'Vec': Vec; + RpcMethods: RpcMethods; + 'Option': Option; + 'Vec': Vec; RuntimeVersionApi: RuntimeVersionApi; 'Option': Option; 'Vec': Vec; diff --git a/packages/types/src/interfaces/contracts/definitions.ts b/packages/types/src/interfaces/contracts/definitions.ts index 844f9f6664..bea1ae9e46 100644 --- a/packages/types/src/interfaces/contracts/definitions.ts +++ b/packages/types/src/interfaces/contracts/definitions.ts @@ -13,6 +13,23 @@ export default { lastWrite: 'Option' }, CodeHash: 'Hash', + ContractCallRequest: { + origin: 'AccountId', + dest: 'AccountId', + value: 'Balance', + gasLimit: 'u64', + inputData: 'Bytes' + }, + ContractExecResultSuccess: { + status: 'u8', + data: 'Bytes' + }, + ContractExecResult: { + _enum: { + Success: 'ContractExecResultSuccess', + Error: 'Null' + } + }, ContractInfo: { _enum: { Alive: 'AliveContractInfo', diff --git a/packages/types/src/interfaces/contracts/types.ts b/packages/types/src/interfaces/contracts/types.ts index 01db6c9ff5..831be4abdc 100644 --- a/packages/types/src/interfaces/contracts/types.ts +++ b/packages/types/src/interfaces/contracts/types.ts @@ -3,8 +3,8 @@ import { Codec } from '../../types'; import { Compact, Enum, Option, Struct } from '../../codec'; -import { Bytes, Null, bool, u32, u64 } from '../../primitive'; -import { Balance, BlockNumber, Hash } from '../runtime'; +import { Bytes, Null, bool, u32, u64, u8 } from '../../primitive'; +import { AccountId, Balance, BlockNumber, Hash } from '../runtime'; /** Struct */ export interface AliveContractInfo extends Struct { @@ -25,6 +25,38 @@ export interface AliveContractInfo extends Struct { /** Hash */ export type CodeHash = Hash; +/** Struct */ +export interface ContractCallRequest extends Struct { + /** AccountId */ + readonly origin: AccountId; + /** AccountId */ + readonly dest: AccountId; + /** Balance */ + readonly value: Balance; + /** u64 */ + readonly gasLimit: u64; + /** Bytes */ + readonly inputData: Bytes; +} + +/** Enum */ +export interface ContractExecResult extends Enum { + /** 0:: Success(ContractExecResultSuccess) */ + readonly isSuccess: boolean; + /** ContractExecResultSuccess */ + readonly asSuccess: ContractExecResultSuccess; + /** 1:: Error */ + readonly isError: boolean; +} + +/** Struct */ +export interface ContractExecResultSuccess extends Struct { + /** u8 */ + readonly status: u8; + /** Bytes */ + readonly data: Bytes; +} + /** Enum */ export interface ContractInfo extends Enum { /** 0:: Alive(AliveContractInfo) */ diff --git a/packages/types/src/interfaces/rpc/definitions.ts b/packages/types/src/interfaces/rpc/definitions.ts index c2d07b6a49..65c4be3eba 100644 --- a/packages/types/src/interfaces/rpc/definitions.ts +++ b/packages/types/src/interfaces/rpc/definitions.ts @@ -43,6 +43,10 @@ export default { bestHash: 'Hash', bestNumber: 'BlockNumber' }, + RpcMethods: { + version: 'u32', + methods: 'Vec' + }, RuntimeVersionApi: '(ApiId, u32)', RuntimeVersion: { specName: 'Text', diff --git a/packages/types/src/interfaces/rpc/types.ts b/packages/types/src/interfaces/rpc/types.ts index 2088c36110..369a9ab93e 100644 --- a/packages/types/src/interfaces/rpc/types.ts +++ b/packages/types/src/interfaces/rpc/types.ts @@ -88,6 +88,14 @@ export interface PeerInfo extends Struct { readonly bestNumber: BlockNumber; } +/** Struct */ +export interface RpcMethods extends Struct { + /** u32 */ + readonly version: u32; + /** Vec */ + readonly methods: Vec; +} + /** Struct */ export interface RuntimeVersion extends Struct { /** Text */