From 1ba8f71da13b43071c85ed774660de9c6aafd49b Mon Sep 17 00:00:00 2001 From: Antoine Estienne Date: Mon, 28 Dec 2020 13:12:12 +0100 Subject: [PATCH] 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 Co-authored-by: Jaco Greeff --- packages/api/src/augment/rpc.ts | 8 ++++++++ packages/types/src/interfaces/eth/rpc.ts | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/api/src/augment/rpc.ts b/packages/api/src/augment/rpc.ts index f3741ac7b3..2312814bc2 100644 --- a/packages/api/src/augment/rpc.ts +++ b/packages/api/src/augment/rpc.ts @@ -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>; + /** + * Returns current client version. + **/ + clientVersion: AugmentedRpc<() => Observable>; /** * 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>; + /** + * Returns sha3 of the given data + **/ + sha3: AugmentedRpc<(_: Bytes | string | Uint8Array) => Observable>; /** * Used for submitting mining hashrate. **/ diff --git a/packages/types/src/interfaces/eth/rpc.ts b/packages/types/src/interfaces/eth/rpc.ts index f7e5bb8055..541b20f773 100644 --- a/packages/types/src/interfaces/eth/rpc.ts +++ b/packages/types/src/interfaces/eth/rpc.ts @@ -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: [],