add client version and sh3 decorators for web3 (#2993)

* add client version and sh3 decorators for web3

* add web3 to rpcCore

* refactored with correct file

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
This commit is contained in:
Antoine Estienne
2020-12-28 13:12:12 +01:00
committed by GitHub
co-authored by Jaco Greeff
parent 91693bf587
commit 1ba8f71da1
2 changed files with 23 additions and 0 deletions
+8
View File
@@ -152,6 +152,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns the chain ID used for transaction signing at the current best block. None is returned if not available.
**/
chainId: AugmentedRpc<() => Observable<U64>>;
/**
* Returns current client version.
**/
clientVersion: AugmentedRpc<() => Observable<Text>>;
/**
* Returns block author.
**/
@@ -268,6 +272,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Sends transaction; will block waiting for signer to return the transaction hash
**/
sendTransaction: AugmentedRpc<(tx: EthTransactionRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array) => Observable<H256>>;
/**
* Returns sha3 of the given data
**/
sha3: AugmentedRpc<(_: Bytes | string | Uint8Array) => Observable<H256>>;
/**
* Used for submitting mining hashrate.
**/
+15
View File
@@ -26,9 +26,24 @@ const netRpc: DefinitionsRpc = {
type: 'String'
}
};
const web3Rpc: DefinitionsRpc = {
clientVersion: {
aliasSection: 'web3',
description: 'Returns current client version.',
params: [],
type: 'String'
},
sha3: {
aliasSection: 'web3',
description: 'Returns sha3 of the given data',
params: [{ name: 'data', type: 'Bytes' }],
type: 'H256'
}
};
export const rpc: DefinitionsRpc = {
...netRpc,
...web3Rpc,
accounts: {
description: 'Returns accounts list.',
params: [],