Add EVM types (#1771)

* Add EVM types

* Add findError for metadata
This commit is contained in:
Jaco Greeff
2020-01-29 18:26:06 +01:00
committed by GitHub
parent 07063134b8
commit de853d9cc0
9 changed files with 65 additions and 6 deletions
+3 -1
View File
@@ -6,7 +6,7 @@ import { Constants, Storage } from '@polkadot/metadata/Decorated/types';
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
import { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, InterfaceTypes, ModulesWithCalls, Registry } from '@polkadot/types/types';
import { AnyFunction, CallFunction, Codec, CodecArg as Arg, ITuple, InterfaceTypes, ModulesWithCalls, Registry, RegistryTypes } from '@polkadot/types/types';
import { SubmittableExtrinsic } from '../submittable/types';
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecorateMethod, DecoratedRpc, DecoratedRpcSection, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
@@ -131,6 +131,8 @@ export default abstract class Decorate<ApiType extends ApiTypes> extends Events
public abstract createType <K extends InterfaceTypes> (type: K, ...params: any[]): InterfaceRegistry[K];
public abstract registerTypes (types?: RegistryTypes): void;
/**
* @returns `true` if the API operates with subscriptions
*/
-3
View File
@@ -3,7 +3,6 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { SignedBlock } from '@polkadot/types/interfaces';
import { RegistryTypes } from '@polkadot/types/types';
import { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
import DecoratedMeta from '@polkadot/metadata/Decorated';
@@ -55,8 +54,6 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
}
}
public abstract registerTypes (types?: RegistryTypes): void;
protected async loadMeta (): Promise<boolean> {
const { metadata = {} } = this._options;
+9 -2
View File
@@ -6,7 +6,7 @@ import { Constants } from '@polkadot/metadata/Decorated/types';
import { RpcInterface } from '@polkadot/rpc-core/jsonrpc.types';
import { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import { InterfaceRegistry } from '@polkadot/types/interfaceRegistry';
import { CallFunction, InterfaceTypes, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types';
import { CallFunction, InterfaceTypes, RegistryError, RegistryTypes, SignerPayloadRawBase } from '@polkadot/types/types';
import { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedRpc, DecorateMethod, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics, Signer } from '../types';
import { Metadata, createType } from '@polkadot/types';
@@ -243,12 +243,19 @@ export default abstract class ApiBase<ApiType extends ApiTypes> extends Init<Api
}
/**
* @description Finds the definition for a specific [[Call]] based on the index supplied
* @description Finds the definition for a specific [[CallFunction]] based on the index supplied
*/
public findCall (callIndex: Uint8Array | string): CallFunction {
return this.registry.findMetaCall(u8aToU8a(callIndex));
}
/**
* @description Finds the definition for a specific [[RegistryError]] based on the index supplied
*/
public findError (errorIndex: Uint8Array | string): RegistryError {
return this.registry.findMetaError(u8aToU8a(errorIndex));
}
/**
* @description Register additional user-defined of chain-specific types in the type registry
*/
+7
View File
@@ -14,6 +14,7 @@ import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, C
import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { AccountInfo, Amount, AssetOf, InherentOfflineReport, LockPeriods, NewAccountOutcome, OpaqueKey, SessionKey } from '@polkadot/types/interfaces/deprecated';
import { ApprovalFlag, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import { Account, Log } from '@polkadot/types/interfaces/evm';
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
import { AuthorityIndex, AuthorityList, AuthorityWeight, NextAuthority, PendingPause, PendingResume, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import { IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
@@ -509,6 +510,12 @@ export interface InterfaceRegistry {
VoteThreshold: VoteThreshold;
'Option<VoteThreshold>': Option<VoteThreshold>;
'Vec<VoteThreshold>': Vec<VoteThreshold>;
Account: Account;
'Option<Account>': Option<Account>;
'Vec<Account>': Vec<Account>;
Log: Log;
'Option<Log>': Option<Log>;
'Vec<Log>': Vec<Log>;
AssetOptions: AssetOptions;
'Option<AssetOptions>': Option<AssetOptions>;
'Vec<AssetOptions>': Vec<AssetOptions>;
@@ -16,6 +16,7 @@ export { default as contracts } from './contracts/definitions';
export { default as democracy } from './democracy/definitions';
export { default as deprecated } from './deprecated/definitions';
export { default as elections } from './elections/definitions';
export { default as evm } from './evm/definitions';
export { default as genericAsset } from './genericAsset/definitions';
export { default as grandpa } from './grandpa/definitions';
export { default as identity } from './identity/definitions';
@@ -0,0 +1,17 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export default {
types: {
Account: {
nonce: 'U256',
balance: 'U256'
},
Log: {
address: 'H160',
topics: 'Vec<H256>',
data: 'Bytes'
}
}
};
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,23 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { Struct, Vec } from '@polkadot/types/codec';
import { Bytes, H160, H256, U256 } from '@polkadot/types/primitive';
/** Struct */
export interface Account extends Struct {
/** U256 */
readonly nonce: U256;
/** U256 */
readonly balance: U256;
}
/** Struct */
export interface Log extends Struct {
/** H160 */
readonly address: H160;
/** Vec<H256> */
readonly topics: Vec<H256>;
/** Bytes */
readonly data: Bytes;
}
+1
View File
@@ -12,6 +12,7 @@ export * from './contracts/types';
export * from './democracy/types';
export * from './deprecated/types';
export * from './elections/types';
export * from './evm/types';
export * from './genericAsset/types';
export * from './grandpa/types';
export * from './identity/types';