Add frontier RPCs (& types for them) (#2976)

* Add frontier RPCs (& types for them)

* Add filters

* Cleanup optional params

* Add ethereum module aliasses

* Split rpc

* Split net RPC

* full block details

* onlyHex

* Revert onlyHex change
This commit is contained in:
Jaco Greeff
2020-12-22 15:30:48 +01:00
committed by GitHub
parent bbdf0e3192
commit 80209da5c5
17 changed files with 1063 additions and 38 deletions
+92 -2
View File
@@ -19,7 +19,7 @@ import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHashe
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
import type { EthereumAccountId, EthereumLookupSource } from '@polkadot/types/interfaces/ethereum';
import type { EthAccount, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilterAddress, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionCondition, EthTransactionRequest, EthTransactionStatus, EthWork, EthereumAccountId, EthereumLookupSource, EthereumSignature } from '@polkadot/types/interfaces/eth';
import type { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
import type { AnySignature, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
@@ -36,7 +36,7 @@ import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/ty
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H160, H256, H512, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9, ValidatorCount } from '@polkadot/types/interfaces/session';
@@ -284,6 +284,12 @@ declare module '@polkadot/types/types/registry' {
ExtrinsicsWeight: ExtrinsicsWeight;
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
H64: H64;
'Option<H64>': Option<H64>;
'Vec<H64>': Vec<H64>;
H128: H128;
'Option<H128>': Option<H128>;
'Vec<H128>': Vec<H128>;
H160: H160;
'Option<H160>': Option<H160>;
'Vec<H160>': Vec<H160>;
@@ -293,6 +299,12 @@ declare module '@polkadot/types/types/registry' {
H512: H512;
'Option<H512>': Option<H512>;
'Vec<H512>': Vec<H512>;
H1024: H1024;
'Option<H1024>': Option<H1024>;
'Vec<H1024>': Vec<H1024>;
H2048: H2048;
'Option<H2048>': Option<H2048>;
'Vec<H2048>': Vec<H2048>;
Hash: Hash;
'Option<Hash>': Option<Hash>;
'Vec<Hash>': Vec<Hash>;
@@ -1835,6 +1847,84 @@ declare module '@polkadot/types/types/registry' {
EthereumLookupSource: EthereumLookupSource;
'Option<EthereumLookupSource>': Option<EthereumLookupSource>;
'Vec<EthereumLookupSource>': Vec<EthereumLookupSource>;
EthereumSignature: EthereumSignature;
'Option<EthereumSignature>': Option<EthereumSignature>;
'Vec<EthereumSignature>': Vec<EthereumSignature>;
EthAccount: EthAccount;
'Option<EthAccount>': Option<EthAccount>;
'Vec<EthAccount>': Vec<EthAccount>;
EthBlock: EthBlock;
'Option<EthBlock>': Option<EthBlock>;
'Vec<EthBlock>': Vec<EthBlock>;
EthBloom: EthBloom;
'Option<EthBloom>': Option<EthBloom>;
'Vec<EthBloom>': Vec<EthBloom>;
EthCallRequest: EthCallRequest;
'Option<EthCallRequest>': Option<EthCallRequest>;
'Vec<EthCallRequest>': Vec<EthCallRequest>;
EthFilter: EthFilter;
'Option<EthFilter>': Option<EthFilter>;
'Vec<EthFilter>': Vec<EthFilter>;
EthFilterAddress: EthFilterAddress;
'Option<EthFilterAddress>': Option<EthFilterAddress>;
'Vec<EthFilterAddress>': Vec<EthFilterAddress>;
EthFilterTopic: EthFilterTopic;
'Option<EthFilterTopic>': Option<EthFilterTopic>;
'Vec<EthFilterTopic>': Vec<EthFilterTopic>;
EthFilterTopicEntry: EthFilterTopicEntry;
'Option<EthFilterTopicEntry>': Option<EthFilterTopicEntry>;
'Vec<EthFilterTopicEntry>': Vec<EthFilterTopicEntry>;
EthFilterTopicInner: EthFilterTopicInner;
'Option<EthFilterTopicInner>': Option<EthFilterTopicInner>;
'Vec<EthFilterTopicInner>': Vec<EthFilterTopicInner>;
EthHeader: EthHeader;
'Option<EthHeader>': Option<EthHeader>;
'Vec<EthHeader>': Vec<EthHeader>;
EthLog: EthLog;
'Option<EthLog>': Option<EthLog>;
'Vec<EthLog>': Vec<EthLog>;
EthReceipt: EthReceipt;
'Option<EthReceipt>': Option<EthReceipt>;
'Vec<EthReceipt>': Vec<EthReceipt>;
EthRichBlock: EthRichBlock;
'Option<EthRichBlock>': Option<EthRichBlock>;
'Vec<EthRichBlock>': Vec<EthRichBlock>;
EthRichHeader: EthRichHeader;
'Option<EthRichHeader>': Option<EthRichHeader>;
'Vec<EthRichHeader>': Vec<EthRichHeader>;
EthStorageProof: EthStorageProof;
'Option<EthStorageProof>': Option<EthStorageProof>;
'Vec<EthStorageProof>': Vec<EthStorageProof>;
EthSubKind: EthSubKind;
'Option<EthSubKind>': Option<EthSubKind>;
'Vec<EthSubKind>': Vec<EthSubKind>;
EthSubParams: EthSubParams;
'Option<EthSubParams>': Option<EthSubParams>;
'Vec<EthSubParams>': Vec<EthSubParams>;
EthSubResult: EthSubResult;
'Option<EthSubResult>': Option<EthSubResult>;
'Vec<EthSubResult>': Vec<EthSubResult>;
EthSyncInfo: EthSyncInfo;
'Option<EthSyncInfo>': Option<EthSyncInfo>;
'Vec<EthSyncInfo>': Vec<EthSyncInfo>;
EthSyncStatus: EthSyncStatus;
'Option<EthSyncStatus>': Option<EthSyncStatus>;
'Vec<EthSyncStatus>': Vec<EthSyncStatus>;
EthTransaction: EthTransaction;
'Option<EthTransaction>': Option<EthTransaction>;
'Vec<EthTransaction>': Vec<EthTransaction>;
EthTransactionCondition: EthTransactionCondition;
'Option<EthTransactionCondition>': Option<EthTransactionCondition>;
'Vec<EthTransactionCondition>': Vec<EthTransactionCondition>;
EthTransactionRequest: EthTransactionRequest;
'Option<EthTransactionRequest>': Option<EthTransactionRequest>;
'Vec<EthTransactionRequest>': Vec<EthTransactionRequest>;
EthTransactionStatus: EthTransactionStatus;
'Option<EthTransactionStatus>': Option<EthTransactionStatus>;
'Vec<EthTransactionStatus>': Vec<EthTransactionStatus>;
EthWork: EthWork;
'Option<EthWork>': Option<EthWork>;
'Vec<EthWork>': Vec<EthWork>;
DoubleMapTypeV9: DoubleMapTypeV9;
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
+2 -2
View File
@@ -186,11 +186,11 @@ export abstract class AbstractInt extends BN implements Codec {
/**
* @description Converts the Object to JSON, typically used for RPC transfers
*/
public toJSON (): any {
public toJSON (onlyHex = false): any {
// FIXME this return type should by string | number, but BN's return type
// is string.
// Maximum allowed integer for JS is 2^53 - 1, set limit at 52
return super.bitLength() > 52
return onlyHex || (super.bitLength() > 52)
? this.toHex()
: this.toNumber();
}
+1 -1
View File
@@ -49,7 +49,7 @@ export { default as contractsAbi } from './contractsAbi/definitions';
export { default as scaleInfo } from './scaleInfo/definitions';
// other useful types
export { default as ethereum } from './ethereum/definitions';
export { default as eth } from './eth/definitions';
// pull in metadata & rpc last, assuming that is uses info from above
export { default as metadata } from './metadata/definitions';
@@ -0,0 +1,232 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
// As per frontier
import type { DefinitionsTypes } from '../../types';
import { rpc } from './rpc';
const types: DefinitionsTypes = {
EthereumAccountId: 'GenericEthereumAccountId',
EthereumLookupSource: 'GenericEthereumLookupSource',
EthereumSignature: '[u8; 65]',
EthAccount: {
address: 'H160',
balance: 'U256',
nonce: 'U256',
codeHash: 'H256',
storageHash: 'H256',
accountProof: 'Vec<Bytes>',
storageProof: 'Vec<EthStorageProof>'
},
EthBlock: {
_alias: {
blockHash: 'hash',
blockSize: 'size'
},
blockHash: 'Option<H256>',
parentHash: 'H256',
sha3Uncles: 'H256',
author: 'H160',
miner: 'H160',
stateRoot: 'H256',
transactionsRoot: 'H256',
receiptsRoot: 'H256',
number: 'Option<U256>',
gasUsed: 'U256',
gasLimit: 'U256',
extraData: 'Bytes',
logsBloom: 'H2048',
timestamp: 'U256',
difficulty: 'U256',
totalDifficulty: 'Option<U256>',
sealFields: 'Vec<Bytes>',
uncles: 'Vec<H256>',
transactions: 'Vec<EthTransaction>',
blockSize: 'Option<U256>'
},
EthBloom: 'H2048',
EthCallRequest: {
from: 'Option<H160>',
to: 'Option<H160>',
gasPrice: 'Option<U256>',
gas: 'Option<U256>',
value: 'Option<U256>',
data: 'Option<Bytes>',
nonce: 'Option<U256>'
},
EthFilter: {
fromBlock: 'Option<BlockNumber>',
toBlock: 'Option<BlockNumber>',
blockHash: 'Option<H256>',
address: 'Option<EthFilterAddress>',
topics: 'Option<EthFilterTopic>'
},
EthFilterAddress: {
_enum: {
Single: 'H160',
Multiple: 'Vec<H160>',
Null: 'Null'
}
},
EthFilterTopic: {
_enum: {
Single: 'EthFilterTopicInner',
Multiple: 'Vec<EthFilterTopicInner>',
Null: 'Null'
}
},
EthFilterTopicEntry: 'Option<H256>',
EthFilterTopicInner: {
_enum: {
Single: 'EthFilterTopicEntry',
Multiple: 'Vec<EthFilterTopicEntry>',
Null: 'Null'
}
},
EthHeader: {
_alias: {
blockHash: 'hash',
blockSize: 'size'
},
blockHash: 'Option<H256>',
parentHash: 'H256',
sha3Uncles: 'H256',
author: 'H160',
miner: 'H160',
stateRoot: 'H256',
transactionsRoot: 'H256',
receiptsRoot: 'H256',
number: 'Option<U256>',
gasUsed: 'U256',
gasLimit: 'U256',
extraData: 'Bytes',
logsBloom: 'H2048',
timestamp: 'U256',
difficulty: 'U256',
sealFields: 'Vec<Bytes>',
blockSize: 'Option<U256>'
},
EthLog: {
address: 'H160',
topics: 'Vec<H256>',
data: 'Bytes',
blockHash: 'Option<H256>',
blockNumber: 'Option<U256>',
transactionHash: 'Option<H256>',
transactionIndex: 'Option<U256>',
logIndex: 'Option<U256>',
transactionLogIndex: 'Option<U256>',
removed: 'bool'
},
EthReceipt: {
transactionHash: 'Option<H256>',
transactionIndex: 'Option<U256>',
blockHash: 'Option<H256>',
from: 'Option<H160>',
to: 'Option<H160>',
blockNumber: 'Option<U256>',
cumulativeGasUsed: 'U256',
gasUsed: 'Option<U256>',
contractAddress: 'Option<H160>',
logs: 'Vec<EthLog>',
root: 'Option<H256>',
logsBloom: 'H2048',
statusCode: 'Option<U64>'
},
EthRichBlock: 'EthBlock',
EthRichHeader: 'EthHeader',
EthStorageProof: {
key: 'U256',
value: 'U256',
proof: 'Vec<Bytes>'
},
EthSubKind: {
_enum: ['newHeads', 'logs', 'newPendingTransactions', 'syncing']
},
EthSubParams: {
_enum: {
None: 'Null',
Logs: 'EthFilter'
}
},
EthSubResult: {
_enum: {
Header: 'EthRichHeader',
Log: 'EthLog',
TransactionHash: 'H256',
SyncState: 'EthSyncStatus'
}
},
EthSyncInfo: {
startingBlock: 'U256',
currentBlock: 'U256',
highestBlock: 'U256',
warpChunksAmount: 'Option<U256>',
warpChunksProcessed: 'Option<U256>'
},
EthSyncStatus: {
_enum: {
Info: 'EthSyncInfo',
None: 'Null'
}
},
EthTransaction: {
blockHash: 'Option<H256>',
blockNumber: 'Option<U256>',
chainId: 'Option<u64>',
condition: 'Option<EthTransactionCondition>',
creates: 'Option<H160>',
from: 'H160',
gas: 'U256',
gasPrice: 'U256',
hash: 'H256',
input: 'Bytes',
nonce: 'U256',
publicKey: 'Option<H512>',
r: 'U256',
raw: 'Bytes',
s: 'U256',
standardV: 'U256',
to: 'Option<H160>',
transactionIndex: 'Option<U256>',
v: 'U256',
value: 'U256'
},
EthTransactionCondition: {
_enum: {
block: 'u64',
time: 'u64'
}
},
EthTransactionRequest: {
from: 'Option<H160>',
to: 'Option<H160>',
gasPrice: 'Option<U256>',
gas: 'Option<U256>',
value: 'Option<U256>',
data: 'Option<Bytes>',
nonce: 'Option<U256>'
},
EthTransactionStatus: {
transactionHash: 'H256',
transactionIndex: 'u32',
from: 'H160',
to: 'Option<H160>',
contractAddress: 'Option<H160>',
logs: 'Vec<EthLog>',
logsBloom: 'EthBloom'
},
EthWork: {
pow_hash: 'H256',
seed_hash: 'H256',
target: 'H256',
number: 'Option<u64>'
}
};
export default { rpc, types };
+272
View File
@@ -0,0 +1,272 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// As per frontier
import type { DefinitionsRpc } from '../../types';
// We use aliasSection here to override since these are in another namespace
const netRpc: DefinitionsRpc = {
listening: {
aliasSection: 'net',
description: 'Returns true if client is actively listening for network connections. Otherwise false.',
params: [],
type: 'bool'
},
peerCount: {
aliasSection: 'net',
description: 'Returns number of peers connected to node.',
params: [],
type: 'String'
},
version: {
aliasSection: 'net',
description: 'Returns protocol version.',
params: [],
type: 'String'
}
};
export const rpc: DefinitionsRpc = {
...netRpc,
accounts: {
description: 'Returns accounts list.',
params: [],
type: 'Vec<H160>'
},
blockNumber: {
description: 'Returns balance of the given account.',
params: [],
type: 'U256'
},
call: {
description: 'Call contract, returning the output data.',
params: [
{ name: 'request', type: 'EthCallRequest' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'Bytes'
},
chainId: {
description: 'Returns the chain ID used for transaction signing at the current best block. None is returned if not available.',
params: [],
type: 'U64'
},
coinbase: {
description: 'Returns block author.',
params: [],
type: 'H160'
},
estimateGas: {
description: 'Estimate gas needed for execution of given contract.',
params: [
{ name: 'request', type: 'EthCallRequest' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'U256'
},
gasPrice: {
description: 'Returns current gas price.',
params: [],
type: 'U256'
},
getBalance: {
description: 'Returns balance of the given account.',
params: [
{ name: 'address', type: 'H160' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'U256'
},
getBlockByHash: {
description: 'Returns block with given hash.',
params: [
{ name: 'hash', type: 'H256' },
{ name: 'full', type: 'bool' }
],
type: 'Option<EthRichBlock>'
},
getBlockByNumber: {
description: 'Returns block with given number.',
params: [
{ name: 'block', type: 'BlockNumber' },
{ name: 'full', type: 'bool' }
],
type: 'Option<EthRichBlock>'
},
getBlockTransactionCountByHash: {
description: 'Returns the number of transactions in a block with given hash.',
params: [
{ name: 'hash', type: 'H256' }
],
type: 'U256'
},
getBlockTransactionCountByNumber: {
description: 'Returns the number of transactions in a block with given block number.',
params: [
{ name: 'block', type: 'BlockNumber' }
],
type: 'U256'
},
getCode: {
description: 'Returns the code at given address at given time (block number).',
params: [
{ name: 'address', type: 'H160' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'Bytes'
},
getLogs: {
description: 'Returns logs matching given filter object.',
params: [
{ name: 'filter', type: 'EthFilter' }
],
type: 'Vec<EthLog>'
},
getStorageAt: {
description: 'Returns content of the storage at given address.',
params: [
{ name: 'address', type: 'H160' },
{ name: 'index', type: 'U256' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'H256'
},
getTransactionByBlockHashAndIndex: {
description: 'Returns transaction at given block hash and index.',
params: [
{ name: 'hash', type: 'H256' },
{ name: 'index', type: 'U256' }
],
type: 'EthTransaction'
},
getTransactionByBlockNumberAndIndex: {
description: 'Returns transaction by given block number and index.',
params: [
{ name: 'number', type: 'BlockNumber' },
{ name: 'index', type: 'U256' }
],
type: 'EthTransaction'
},
getTransactionByHash: {
description: 'Get transaction by its hash.',
params: [
{ name: 'hash', type: 'H256' }
],
type: 'EthTransaction'
},
getTransactionCount: {
description: 'Returns the number of transactions sent from given address at given time (block number).',
params: [
{ name: 'hash', type: 'H256' },
{ isOptional: true, name: 'number', type: 'BlockNumber' }
],
type: 'U256'
},
getTransactionReceipt: {
description: 'Returns transaction receipt by transaction hash.',
params: [
{ name: 'hash', type: 'H256' }
],
type: 'EthReceipt'
},
getUncleByBlockHashAndIndex: {
description: 'Returns an uncles at given block and index.',
params: [
{ name: 'hash', type: 'H256' },
{ name: 'index', type: 'U256' }
],
type: 'EthRichBlock'
},
getUncleByBlockNumberAndIndex: {
description: 'Returns an uncles at given block and index.',
params: [
{ name: 'number', type: 'BlockNumber' },
{ name: 'index', type: 'U256' }
],
type: 'EthRichBlock'
},
getUncleCountByBlockHash: {
description: 'Returns the number of uncles in a block with given hash.',
params: [
{ name: 'hash', type: 'H256' }
],
type: 'U256'
},
getUncleCountByBlockNumber: {
description: 'Returns the number of uncles in a block with given block number.',
params: [
{ name: 'number', type: 'BlockNumber' }
],
type: 'U256'
},
getWork: {
description: 'Returns the hash of the current block, the seedHash, and the boundary condition to be met.',
params: [],
type: 'EthWork'
},
hashrate: {
description: 'Returns the number of hashes per second that the node is mining with.',
params: [],
type: 'U256'
},
mining: {
description: 'Returns true if client is actively mining new blocks.',
params: [],
type: 'bool'
},
protocolVersion: {
description: 'Returns protocol version encoded as a string (quotes are necessary).',
params: [],
type: 'u64'
},
sendRawTransaction: {
description: 'Sends signed transaction, returning its hash.',
params: [
{ name: 'bytes', type: 'Bytes' }
],
type: 'H256'
},
sendTransaction: {
description: 'Sends transaction; will block waiting for signer to return the transaction hash',
params: [
{ name: 'tx', type: 'EthTransactionRequest' }
],
type: 'H256'
},
submitHashrate: {
description: 'Used for submitting mining hashrate.',
params: [
{ name: 'index', type: 'U256' },
{ name: 'hash', type: 'H256' }
],
type: 'bool'
},
submitWork: {
description: 'Used for submitting a proof-of-work solution.',
params: [
{ name: 'nonce', type: 'H64' },
{ name: 'headerHash', type: 'H256' },
{ name: 'mixDigest', type: 'H256' }
],
type: 'bool'
},
subscribe: {
description: 'Subscribe to Eth subscription.',
params: [
{ name: 'kind', type: 'EthSubKind' },
{ isOptional: true, name: 'params', type: 'EthSubParams' }
],
pubsub: [
'subscription',
'subscribe',
'unsubscribe'
],
type: 'Null'
},
syncing: {
description: 'Returns an object with data about the sync status or false.',
params: [],
type: 'EthSyncStatus'
}
};
+274
View File
@@ -0,0 +1,274 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Bytes, Enum, GenericEthereumAccountId, GenericEthereumLookupSource, Option, Struct, U256, U64, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { BlockNumber, H160, H2048, H256, H512 } from '@polkadot/types/interfaces/runtime';
/** @name EthAccount */
export interface EthAccount extends Struct {
readonly address: H160;
readonly balance: U256;
readonly nonce: U256;
readonly codeHash: H256;
readonly storageHash: H256;
readonly accountProof: Vec<Bytes>;
readonly storageProof: Vec<EthStorageProof>;
}
/** @name EthBlock */
export interface EthBlock extends Struct {
readonly blockHash: Option<H256>;
readonly parentHash: H256;
readonly sha3Uncles: H256;
readonly author: H160;
readonly miner: H160;
readonly stateRoot: H256;
readonly transactionsRoot: H256;
readonly receiptsRoot: H256;
readonly number: Option<U256>;
readonly gasUsed: U256;
readonly gasLimit: U256;
readonly extraData: Bytes;
readonly logsBloom: H2048;
readonly timestamp: U256;
readonly difficulty: U256;
readonly totalDifficulty: Option<U256>;
readonly sealFields: Vec<Bytes>;
readonly uncles: Vec<H256>;
readonly transactions: Vec<EthTransaction>;
readonly blockSize: Option<U256>;
}
/** @name EthBloom */
export interface EthBloom extends H2048 {}
/** @name EthCallRequest */
export interface EthCallRequest extends Struct {
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly gasPrice: Option<U256>;
readonly gas: Option<U256>;
readonly value: Option<U256>;
readonly data: Option<Bytes>;
readonly nonce: Option<U256>;
}
/** @name EthereumAccountId */
export interface EthereumAccountId extends GenericEthereumAccountId {}
/** @name EthereumLookupSource */
export interface EthereumLookupSource extends GenericEthereumLookupSource {}
/** @name EthereumSignature */
export interface EthereumSignature extends U8aFixed {}
/** @name EthFilter */
export interface EthFilter extends Struct {
readonly fromBlock: Option<BlockNumber>;
readonly toBlock: Option<BlockNumber>;
readonly blockHash: Option<H256>;
readonly address: Option<EthFilterAddress>;
readonly topics: Option<EthFilterTopic>;
}
/** @name EthFilterAddress */
export interface EthFilterAddress extends Enum {
readonly isSingle: boolean;
readonly asSingle: H160;
readonly isMultiple: boolean;
readonly asMultiple: Vec<H160>;
readonly isNull: boolean;
}
/** @name EthFilterTopic */
export interface EthFilterTopic extends Enum {
readonly isSingle: boolean;
readonly asSingle: EthFilterTopicInner;
readonly isMultiple: boolean;
readonly asMultiple: Vec<EthFilterTopicInner>;
readonly isNull: boolean;
}
/** @name EthFilterTopicEntry */
export interface EthFilterTopicEntry extends Option<H256> {}
/** @name EthFilterTopicInner */
export interface EthFilterTopicInner extends Enum {
readonly isSingle: boolean;
readonly asSingle: EthFilterTopicEntry;
readonly isMultiple: boolean;
readonly asMultiple: Vec<EthFilterTopicEntry>;
readonly isNull: boolean;
}
/** @name EthHeader */
export interface EthHeader extends Struct {
readonly blockHash: Option<H256>;
readonly parentHash: H256;
readonly sha3Uncles: H256;
readonly author: H160;
readonly miner: H160;
readonly stateRoot: H256;
readonly transactionsRoot: H256;
readonly receiptsRoot: H256;
readonly number: Option<U256>;
readonly gasUsed: U256;
readonly gasLimit: U256;
readonly extraData: Bytes;
readonly logsBloom: H2048;
readonly timestamp: U256;
readonly difficulty: U256;
readonly sealFields: Vec<Bytes>;
readonly blockSize: Option<U256>;
}
/** @name EthLog */
export interface EthLog extends Struct {
readonly address: H160;
readonly topics: Vec<H256>;
readonly data: Bytes;
readonly blockHash: Option<H256>;
readonly blockNumber: Option<U256>;
readonly transactionHash: Option<H256>;
readonly transactionIndex: Option<U256>;
readonly logIndex: Option<U256>;
readonly transactionLogIndex: Option<U256>;
readonly removed: bool;
}
/** @name EthReceipt */
export interface EthReceipt extends Struct {
readonly transactionHash: Option<H256>;
readonly transactionIndex: Option<U256>;
readonly blockHash: Option<H256>;
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly blockNumber: Option<U256>;
readonly cumulativeGasUsed: U256;
readonly gasUsed: Option<U256>;
readonly contractAddress: Option<H160>;
readonly logs: Vec<EthLog>;
readonly root: Option<H256>;
readonly logsBloom: H2048;
readonly statusCode: Option<U64>;
}
/** @name EthRichBlock */
export interface EthRichBlock extends EthBlock {}
/** @name EthRichHeader */
export interface EthRichHeader extends EthHeader {}
/** @name EthStorageProof */
export interface EthStorageProof extends Struct {
readonly key: U256;
readonly value: U256;
readonly proof: Vec<Bytes>;
}
/** @name EthSubKind */
export interface EthSubKind extends Enum {
readonly isNewHeads: boolean;
readonly isLogs: boolean;
readonly isNewPendingTransactions: boolean;
readonly isSyncing: boolean;
}
/** @name EthSubParams */
export interface EthSubParams extends Enum {
readonly isNone: boolean;
readonly isLogs: boolean;
readonly asLogs: EthFilter;
}
/** @name EthSubResult */
export interface EthSubResult extends Enum {
readonly isHeader: boolean;
readonly asHeader: EthRichHeader;
readonly isLog: boolean;
readonly asLog: EthLog;
readonly isTransactionHash: boolean;
readonly asTransactionHash: H256;
readonly isSyncState: boolean;
readonly asSyncState: EthSyncStatus;
}
/** @name EthSyncInfo */
export interface EthSyncInfo extends Struct {
readonly startingBlock: U256;
readonly currentBlock: U256;
readonly highestBlock: U256;
readonly warpChunksAmount: Option<U256>;
readonly warpChunksProcessed: Option<U256>;
}
/** @name EthSyncStatus */
export interface EthSyncStatus extends Enum {
readonly isInfo: boolean;
readonly asInfo: EthSyncInfo;
readonly isNone: boolean;
}
/** @name EthTransaction */
export interface EthTransaction extends Struct {
readonly blockHash: Option<H256>;
readonly blockNumber: Option<U256>;
readonly chainId: Option<u64>;
readonly condition: Option<EthTransactionCondition>;
readonly creates: Option<H160>;
readonly from: H160;
readonly gas: U256;
readonly gasPrice: U256;
readonly hash: H256;
readonly input: Bytes;
readonly nonce: U256;
readonly publicKey: Option<H512>;
readonly r: U256;
readonly raw: Bytes;
readonly s: U256;
readonly standardV: U256;
readonly to: Option<H160>;
readonly transactionIndex: Option<U256>;
readonly v: U256;
readonly value: U256;
}
/** @name EthTransactionCondition */
export interface EthTransactionCondition extends Enum {
readonly isBlock: boolean;
readonly asBlock: u64;
readonly isTime: boolean;
readonly asTime: u64;
}
/** @name EthTransactionRequest */
export interface EthTransactionRequest extends Struct {
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly gasPrice: Option<U256>;
readonly gas: Option<U256>;
readonly value: Option<U256>;
readonly data: Option<Bytes>;
readonly nonce: Option<U256>;
}
/** @name EthTransactionStatus */
export interface EthTransactionStatus extends Struct {
readonly transactionHash: H256;
readonly transactionIndex: u32;
readonly from: H160;
readonly to: Option<H160>;
readonly contractAddress: Option<H160>;
readonly logs: Vec<EthLog>;
readonly logsBloom: EthBloom;
}
/** @name EthWork */
export interface EthWork extends Struct {
readonly pow_hash: H256;
readonly seed_hash: H256;
readonly target: H256;
readonly number: Option<u64>;
}
export type PHANTOM_ETH = 'eth';
@@ -1,15 +0,0 @@
// Copyright 2017-2020 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types';
export default {
rpc: {},
types: {
EthereumAccountId: 'GenericEthereumAccountId',
EthereumLookupSource: 'GenericEthereumLookupSource'
}
} as Definitions;
@@ -1,12 +0,0 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { GenericEthereumAccountId, GenericEthereumLookupSource } from '@polkadot/types';
/** @name EthereumAccountId */
export interface EthereumAccountId extends GenericEthereumAccountId {}
/** @name EthereumLookupSource */
export interface EthereumLookupSource extends GenericEthereumLookupSource {}
export type PHANTOM_ETHEREUM = 'ethereum';
+9 -3
View File
@@ -10,13 +10,19 @@ const jsonrpc: Record<string, Record<string, DefinitionRpcExt>> = {};
Object
.keys(definitions)
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0)
.forEach((section): void => {
jsonrpc[section] = {};
.forEach((_section): void => {
jsonrpc[_section] = {};
Object
.entries(definitions[section as 'babe'].rpc)
.entries(definitions[_section as 'babe'].rpc)
.forEach(([method, def]): void => {
const isSubscription = !!(def as DefinitionRpcSub).pubsub;
const section = def.aliasSection || _section;
// allow for section overrides
if (!jsonrpc[section]) {
jsonrpc[section] = {};
}
jsonrpc[section][method] = ({ ...def, isSubscription, jsonrpc: `${section}_${method}`, method, section });
});
@@ -61,9 +61,13 @@ export default {
normal: 'Weight',
operational: 'Weight'
},
H64: '[u8; 8; H64]',
H128: '[u8; 16; H64]',
H160: '[u8; 20; H160]',
H256: '[u8; 32; H256]',
H512: '[u8; 64; H512]',
H1024: '[u8; 128; H1024]',
H2048: '[u8; 256; H2048]',
Hash: 'H256',
Header: {
parentHash: 'Hash',
@@ -102,15 +102,27 @@ export interface FixedU128 extends UInt {}
/** @name FixedU64 */
export interface FixedU64 extends UInt {}
/** @name H1024 */
export interface H1024 extends U8aFixed {}
/** @name H128 */
export interface H128 extends U8aFixed {}
/** @name H160 */
export interface H160 extends U8aFixed {}
/** @name H2048 */
export interface H2048 extends U8aFixed {}
/** @name H256 */
export interface H256 extends U8aFixed {}
/** @name H512 */
export interface H512 extends U8aFixed {}
/** @name H64 */
export interface H64 extends U8aFixed {}
/** @name Hash */
export interface Hash extends H256 {}
+1 -1
View File
@@ -40,7 +40,7 @@ export * from './poll/types';
export * from './purchase/types';
export * from './contractsAbi/types';
export * from './scaleInfo/types';
export * from './ethereum/types';
export * from './eth/types';
export * from './metadata/types';
export * from './rpc/types';
export * from './author/types';
+2
View File
@@ -21,8 +21,10 @@ export interface DefinitionRpcParam {
export interface DefinitionRpc {
alias?: string[];
aliasSection?: string;
description: string;
endpoint?: string;
isSigned?: boolean;
params: DefinitionRpcParam[];
type: DefinitionTypeType;
}