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
This commit is contained in:
@@ -135,4 +135,11 @@ export default abstract class AbstractArray<T extends Codec> extends Array<T> im
|
||||
public map<U> (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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CodeHash>': Option<CodeHash>;
|
||||
'Vec<CodeHash>': Vec<CodeHash>;
|
||||
ContractCallRequest: ContractCallRequest;
|
||||
'Option<ContractCallRequest>': Option<ContractCallRequest>;
|
||||
'Vec<ContractCallRequest>': Vec<ContractCallRequest>;
|
||||
ContractExecResultSuccess: ContractExecResultSuccess;
|
||||
'Option<ContractExecResultSuccess>': Option<ContractExecResultSuccess>;
|
||||
'Vec<ContractExecResultSuccess>': Vec<ContractExecResultSuccess>;
|
||||
ContractExecResult: ContractExecResult;
|
||||
'Option<ContractExecResult>': Option<ContractExecResult>;
|
||||
'Vec<ContractExecResult>': Vec<ContractExecResult>;
|
||||
ContractInfo: ContractInfo;
|
||||
'Option<ContractInfo>': Option<ContractInfo>;
|
||||
'Vec<ContractInfo>': Vec<ContractInfo>;
|
||||
@@ -929,6 +938,9 @@ export interface InterfaceRegistry {
|
||||
PeerInfo: PeerInfo;
|
||||
'Option<PeerInfo>': Option<PeerInfo>;
|
||||
'Vec<PeerInfo>': Vec<PeerInfo>;
|
||||
RpcMethods: RpcMethods;
|
||||
'Option<RpcMethods>': Option<RpcMethods>;
|
||||
'Vec<RpcMethods>': Vec<RpcMethods>;
|
||||
RuntimeVersionApi: RuntimeVersionApi;
|
||||
'Option<RuntimeVersionApi>': Option<RuntimeVersionApi>;
|
||||
'Vec<RuntimeVersionApi>': Vec<RuntimeVersionApi>;
|
||||
|
||||
@@ -13,6 +13,23 @@ export default {
|
||||
lastWrite: 'Option<BlockNumber>'
|
||||
},
|
||||
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',
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -43,6 +43,10 @@ export default {
|
||||
bestHash: 'Hash',
|
||||
bestNumber: 'BlockNumber'
|
||||
},
|
||||
RpcMethods: {
|
||||
version: 'u32',
|
||||
methods: 'Vec<Text>'
|
||||
},
|
||||
RuntimeVersionApi: '(ApiId, u32)',
|
||||
RuntimeVersion: {
|
||||
specName: 'Text',
|
||||
|
||||
@@ -88,6 +88,14 @@ export interface PeerInfo extends Struct {
|
||||
readonly bestNumber: BlockNumber;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface RpcMethods extends Struct {
|
||||
/** u32 */
|
||||
readonly version: u32;
|
||||
/** Vec<Text> */
|
||||
readonly methods: Vec<Text>;
|
||||
}
|
||||
|
||||
/** Struct */
|
||||
export interface RuntimeVersion extends Struct {
|
||||
/** Text */
|
||||
|
||||
Reference in New Issue
Block a user