From a58fad06a7955247e4f01dd98cd97bab2d82f71f Mon Sep 17 00:00:00 2001 From: Maciej Hirsz Date: Tue, 24 Jan 2017 22:02:52 +0100 Subject: [PATCH] JSON-RPC interfaces with documentation (#4276) * Extended Markdown generator * Synced and extended all JSON-RPC interfaces * Fix linter errors * Format `parity_listAccounts` output in API * typo --- js/src/api/rpc/parity/parity.js | 44 +- js/src/jsonrpc/.gitignore | 1 + js/src/jsonrpc/interfaces/eth.js | 540 ++++++--- js/src/jsonrpc/interfaces/net.js | 10 +- js/src/jsonrpc/interfaces/parity.js | 1449 ++++++++++++++++++------- js/src/jsonrpc/interfaces/personal.js | 64 +- js/src/jsonrpc/interfaces/shh.js | 4 +- js/src/jsonrpc/interfaces/signer.js | 66 +- js/src/jsonrpc/interfaces/web3.js | 12 +- 9 files changed, 1611 insertions(+), 579 deletions(-) create mode 100644 js/src/jsonrpc/.gitignore diff --git a/js/src/api/rpc/parity/parity.js b/js/src/api/rpc/parity/parity.js index 174ad3fbf..500803e12 100644 --- a/js/src/api/rpc/parity/parity.js +++ b/js/src/api/rpc/parity/parity.js @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { inAddress, inAddresses, inData, inHex, inNumber16, inOptions } from '../../format/input'; +import { inAddress, inAddresses, inData, inHex, inNumber16, inOptions, inBlockNumber } from '../../format/input'; import { outAccountInfo, outAddress, outAddresses, outChainStatus, outHistogram, outNumber, outPeers, outTransaction } from '../../format/output'; export default class Parity { @@ -101,6 +101,11 @@ export default class Parity { .execute('parity_enode'); } + encryptMessage (pubkey, data) { + return this._transport + .execute('parity_encryptMessage', inHex(pubkey), inHex(data)); + } + executeUpgrade () { return this._transport .execute('parity_executeUpgrade'); @@ -111,6 +116,17 @@ export default class Parity { .execute('parity_extraData'); } + futureTransactions () { + return this._transport + .execute('parity_futureTransactions'); + } + + gasCeilTarget () { + return this._transport + .execute('parity_gasCeilTarget') + .then(outNumber); + } + gasFloorTarget () { return this._transport .execute('parity_gasFloorTarget') @@ -156,11 +172,22 @@ export default class Parity { .execute('parity_killAccount', inAddress(account), password); } + listAccounts (count, offset = null, blockNumber = 'latest') { + return this._transport + .execute('parity_listAccounts', count, inAddress(offset), inBlockNumber(blockNumber)) + .then((accounts) => (accounts || []).map(outAddress)); + } + listRecentDapps () { return this._transport .execute('parity_listRecentDapps'); } + listStorageKeys (address, count, hash = null, blockNumber = 'latest') { + return this._transport + .execute('parity_listStorageKeys', inAddress(address), count, inHex(hash), inBlockNumber(blockNumber)); + } + removeAddress (address) { return this._transport .execute('parity_removeAddress', inAddress(address)); @@ -311,16 +338,31 @@ export default class Parity { .execute('parity_setDappsAddresses', dappId, inAddresses(addresses)); } + setEngineSigner (address, password) { + return this._transport + .execute('parity_setEngineSigner', inAddress(address), password); + } + setExtraData (data) { return this._transport .execute('parity_setExtraData', inData(data)); } + setGasCeilTarget (quantity) { + return this._transport + .execute('parity_setGasCeilTarget', inNumber16(quantity)); + } + setGasFloorTarget (quantity) { return this._transport .execute('parity_setGasFloorTarget', inNumber16(quantity)); } + setMaxTransactionGas (quantity) { + return this._transport + .execute('parity_setMaxTransactionGas', inNumber16(quantity)); + } + setMinGasPrice (quantity) { return this._transport .execute('parity_setMinGasPrice', inNumber16(quantity)); diff --git a/js/src/jsonrpc/.gitignore b/js/src/jsonrpc/.gitignore new file mode 100644 index 000000000..d8f8d4692 --- /dev/null +++ b/js/src/jsonrpc/.gitignore @@ -0,0 +1 @@ +docs diff --git a/js/src/jsonrpc/interfaces/eth.js b/js/src/jsonrpc/interfaces/eth.js index 3a136ab7e..735c4baa8 100644 --- a/js/src/jsonrpc/interfaces/eth.js +++ b/js/src/jsonrpc/interfaces/eth.js @@ -15,14 +15,38 @@ // along with Parity. If not, see . import { Address, BlockNumber, Data, Hash, Quantity } from '../types'; +import { withPreamble, fromDecimal, withComment, DUMMY } from '../helpers'; -export default { +export default withPreamble(` + +## The default block parameter + +The following methods have an optional extra \`defaultBlock\` parameter: + +- [eth_estimateGas](#eth_estimategas) +- [eth_getBalance](#eth_getbalance) +- [eth_getCode](#eth_getcode) +- [eth_getTransactionCount](#eth_gettransactioncount) +- [eth_getStorageAt](#eth_getstorageat) +- [eth_call](#eth_call) + +When requests are made that act on the state of Ethereum, the last parameter determines the height of the block. + +The following options are possible for the \`defaultBlock\` parameter: + +- \`Quantity\`/\`Integer\` - an integer block number; +- \`String "earliest"\` - for the earliest/genesis block; +- \`String "latest"\` - for the latest mined block; +- \`String "pending"\` - for the pending state/transactions. + +`, { accounts: { desc: 'Returns a list of addresses owned by client.', params: [], returns: { type: Array, - desc: '20 Bytes - addresses owned by the client' + desc: '20 Bytes - addresses owned by the client.', + example: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'] } }, @@ -31,7 +55,8 @@ export default { params: [], returns: { type: Quantity, - desc: 'integer of the current block number the client is on' + desc: 'integer of the current block number the client is on.', + example: fromDecimal(1207) } }, @@ -40,49 +65,56 @@ export default { params: [ { type: Object, - desc: 'The transaction call object', + desc: 'The transaction call object.', format: 'inputCallFormatter', details: { from: { type: Address, - desc: '20 Bytes - The address the transaction is send from', + desc: '20 Bytes - The address the transaction is send from.', optional: true }, to: { type: Address, - desc: '20 Bytes - The address the transaction is directed to' + desc: '20 Bytes - The address the transaction is directed to.' }, gas: { type: Quantity, - desc: 'Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions', + desc: 'Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.', optional: true }, gasPrice: { type: Quantity, - desc: 'Integer of the gasPrice used for each paid gas', + desc: 'Integer of the gasPrice used for each paid gas.', optional: true }, value: { type: Quantity, - desc: 'Integer of the value send with this transaction', + desc: 'Integer of the value sent with this transaction.', optional: true }, data: { type: Data, - desc: 'Hash of the method signature and encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI)', + desc: '4 byte hash of the method signature followed by encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI).', optional: true } + }, + example: { + from: '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', + value: fromDecimal(100000) } }, { type: BlockNumber, - desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter)', - format: 'inputDefaultBlockNumberFormatter' + desc: 'Integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + optional: true } ], returns: { type: Data, - desc: 'the return value of executed contract' + desc: 'the return value of executed contract.', + example: '0x' } }, @@ -91,7 +123,8 @@ export default { params: [], returns: { type: Address, - desc: 'The current coinbase address' + desc: 'The current coinbase address.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' } }, @@ -100,12 +133,14 @@ export default { params: [ { type: String, - desc: 'The source code' + desc: 'The source code.', + example: '/* some serpent */' } ], returns: { type: Data, - desc: 'The compiled source code' + desc: 'The compiled source code.', + example: '0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056' } }, @@ -114,12 +149,14 @@ export default { params: [ { type: String, - desc: 'The source code' + desc: 'The source code.', + example: 'contract test { function multiply(uint a) returns(uint d) { return a * 7; } }' } ], returns: { type: Data, - desc: 'The compiled source code' + desc: 'The compiled source code.', + example: '0x605880600c6000396000f3006000357c010000000000000000000000000000000000000000000000000000000090048063c6888fa114602e57005b603d6004803590602001506047565b8060005260206000f35b60006007820290506053565b91905056' } }, @@ -128,12 +165,14 @@ export default { params: [ { type: String, - desc: 'The source code' + desc: 'The source code.', + example: '(returnlll (suicide (caller)))' } ], returns: { type: Data, - desc: 'The compiled source code' + desc: 'The compiled source code.', + example: '0x603880600c6000396000f3006001600060e060020a600035048063c6888fa114601857005b6021600435602b565b8060005260206000f35b600081600702905091905056' } }, @@ -142,18 +181,27 @@ export default { params: [ { type: Object, - desc: 'see [eth_sendTransaction](#eth_sendTransaction)', - format: 'inputCallFormatter' + desc: 'See [eth_call](#eth_call) parameters, expect that all properties are optional.', + format: 'inputCallFormatter', + example: DUMMY // will be replaced with { ... } by the generator + }, + { + type: BlockNumber, + desc: 'Integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + optional: true } ], returns: { type: Quantity, - desc: 'The amount of gas used', - format: 'utils.toDecimal' + desc: 'The amount of gas used.', + format: 'utils.toDecimal', + example: fromDecimal(21000) } }, fetchQueuedTransactions: { + nodoc: 'Not present in Rust code', desc: '?', params: [ '?' @@ -165,6 +213,7 @@ export default { }, flush: { + nodoc: 'Not present in Rust code', desc: '?', params: [], returns: { @@ -178,7 +227,8 @@ export default { params: [], returns: { type: Quantity, - desc: 'integer of the current gas price in wei' + desc: 'integer of the current gas price in wei.', + example: fromDecimal(10000000000000) } }, @@ -187,19 +237,22 @@ export default { params: [ { type: Address, - desc: '20 Bytes - address to check for balance', - format: 'inputAddressFormatter' + desc: '20 Bytes - address to check for balance.', + format: 'inputAddressFormatter', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' }, { type: BlockNumber, - desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter)', - format: 'inputDefaultBlockNumberFormatter' + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + optional: true } ], returns: { type: Quantity, - desc: 'integer of the current balance in wei', - format: 'outputBigNumberFormatter' + desc: 'integer of the current balance in wei.', + format: 'outputBigNumberFormatter', + example: '0x0234c8a3397aab58' } }, @@ -208,16 +261,18 @@ export default { params: [ { type: Hash, - desc: 'Hash of a block' + desc: 'Hash of a block.', + example: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' }, { type: Boolean, - desc: 'If `true` it returns the full transaction objects, if `false` only the hashes of the transactions' + desc: 'If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.', + example: true } ], returns: { type: Object, - desc: 'A block object, or `null` when no block was found', + desc: 'A block object, or `null` when no block was found.', details: { number: { type: Quantity, @@ -294,6 +349,27 @@ export default { type: Array, desc: 'Array of uncle hashes' } + }, + example: { + number: fromDecimal(436), + hash: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', + parentHash: '0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5', + sealFields: ['0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2', '0x0000000000000042'], + sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', + logsBloom: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331', + transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', + stateRoot: '0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff', + miner: '0x4e65fda2159562a496f9f3522f89122a3088497a', + difficulty: fromDecimal(163591), + totalDifficulty: fromDecimal(163591), + extraData: '0x0000000000000000000000000000000000000000000000000000000000000000', + size: fromDecimal(163591), + gasLimit: fromDecimal(653145), + minGasPrice: fromDecimal(653145), + gasUsed: fromDecimal(653145), + timestamp: fromDecimal(1424182926), + transactions: [DUMMY, DUMMY], // will be replaced with [{ ... }, { ... }] by the generator + uncles: ['0x1606e5...', '0xd5145a9...'] } } }, @@ -303,11 +379,13 @@ export default { params: [ { type: BlockNumber, - desc: 'integer of a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter)' + desc: 'integer of a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter).', + example: fromDecimal(436) }, { type: Boolean, - desc: 'If `true` it returns the full transaction objects, if `false` only the hashes of the transactions' + desc: 'If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.', + example: true } ], returns: 'See [eth_getBlockByHash](#eth_getblockbyhash)' @@ -318,12 +396,14 @@ export default { params: [ { type: Hash, - desc: '32 Bytes - hash of a block' + desc: '32 Bytes - hash of a block.', + example: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238' } ], returns: { type: Quantity, - desc: 'integer of the number of transactions in this block' + desc: 'integer of the number of transactions in this block.', + example: fromDecimal(11) } }, @@ -332,12 +412,14 @@ export default { params: [ { type: BlockNumber, - desc: 'integer of a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter)' + desc: 'integer of a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter).', + example: fromDecimal(232) } ], returns: { type: Quantity, - desc: 'integer of the number of transactions in this block' + desc: 'integer of the number of transactions in this block.', + example: fromDecimal(10) } }, @@ -346,18 +428,21 @@ export default { params: [ { type: Address, - desc: '20 Bytes - address', - format: 'inputAddressFormatter' + desc: '20 Bytes - address.', + format: 'inputAddressFormatter', + example: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b' }, { type: BlockNumber, - desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter)', - format: 'inputDefaultBlockNumberFormatter' + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + example: fromDecimal(2) } ], returns: { type: Data, - desc: 'the code from the given address' + desc: 'the code from the given address.', + example: '0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056' } }, @@ -366,7 +451,8 @@ export default { params: [], returns: { type: Array, - desc: 'Array of available compilers' + desc: 'Array of available compilers.', + example: ['solidity', 'lll', 'serpent'] } }, @@ -375,16 +461,31 @@ export default { params: [ { type: Quantity, - desc: 'The filter id' + desc: 'The filter id.', + example: fromDecimal(22) } ], returns: { type: Array, - desc: 'Array of log objects, or an empty array if nothing has changed since last poll' + desc: 'Array of log objects, or an empty array if nothing has changed since last poll.', + example: [ + { + logIndex: fromDecimal(1), + blockNumber: fromDecimal(436), + blockHash: '0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d', + transactionHash: '0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf', + transactionIndex: fromDecimal(0), + address: '0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d', + data: '0x0000000000000000000000000000000000000000000000000000000000000000', + topics: ['0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5'] + }, + DUMMY // will be replaced with { ... } by the generator + ] } }, getFilterChangesEx: { + nodoc: 'Not present in Rust code', // https://github.com/ethereum/wiki/wiki/Proposal:-Reversion-Notification desc: '?', params: [ '?' @@ -400,13 +501,15 @@ export default { params: [ { type: Quantity, - desc: 'The filter id' + desc: 'The filter id.', + example: fromDecimal(22) } ], returns: 'See [eth_getFilterChanges](#eth_getfilterchanges)' }, getFilterLogsEx: { + nodoc: 'Not present in Rust code', // https://github.com/ethereum/wiki/wiki/Proposal:-Reversion-Notification desc: '?', params: [ '?' @@ -422,13 +525,17 @@ export default { params: [ { type: Object, - desc: 'The filter object, see [eth_newFilter parameters](#eth_newfilter)' + desc: 'The filter object, see [eth_newFilter parameters](#eth_newfilter).', + example: { + topics: ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b'] + } } ], returns: 'See [eth_getFilterChanges](#eth_getfilterchanges)' }, getLogsEx: { + nodoc: 'Not present in Rust code', // https://github.com/ethereum/wiki/wiki/Proposal:-Reversion-Notification desc: '?', params: [ '?' @@ -444,22 +551,27 @@ export default { params: [ { type: Address, - desc: '20 Bytes - address of the storage' + desc: '20 Bytes - address of the storage.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' }, { type: Quantity, - desc: 'integer of the position in the storage', - format: 'utils.toHex' + desc: 'integer of the position in the storage.', + format: 'utils.toHex', + example: fromDecimal(0) }, { type: BlockNumber, - desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter)', - format: 'inputDefaultBlockNumberFormatter' + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + example: fromDecimal(2), + optional: true } ], returns: { type: Data, - desc: 'the value at this storage position' + desc: 'the value at this storage position.', + example: '0x0000000000000000000000000000000000000000000000000000000000000003' } }, @@ -468,7 +580,8 @@ export default { params: [ { type: Hash, - desc: '32 Bytes - hash of a transaction' + desc: '32 Bytes - hash of a transaction.', + example: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238' } ], returns: { @@ -520,6 +633,19 @@ export default { type: Data, desc: 'the data send along with the transaction.' } + }, + example: { + hash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', + nonce: fromDecimal(0), + blockHash: '0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b', + blockNumber: fromDecimal(5599), + transactionIndex: fromDecimal(1), + from: '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + to: '0x85h43d8a49eeb85d32cf465507dd71d507100c1', + value: fromDecimal(520464), + gas: fromDecimal(520464), + gasPrice: '0x09184e72a000', + input: '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360' } } }, @@ -529,11 +655,13 @@ export default { params: [ { type: Hash, - desc: 'hash of a block' + desc: 'hash of a block.', + example: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' }, { type: Quantity, - desc: 'integer of the transaction index position' + desc: 'integer of the transaction index position.', + example: fromDecimal(0) } ], returns: 'See [eth_getBlockByHash](#eth_gettransactionbyhash)' @@ -544,11 +672,13 @@ export default { params: [ { type: BlockNumber, - desc: 'a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter)' + desc: 'a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter).', + example: fromDecimal(668) }, { type: Quantity, - desc: 'The transaction index position' + desc: 'The transaction index position.', + example: fromDecimal(0) } ], returns: 'See [eth_getBlockByHash](#eth_gettransactionbyhash)' @@ -559,27 +689,31 @@ export default { params: [ { type: Address, - desc: '20 Bytes - address' + desc: '20 Bytes - address.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' }, { type: BlockNumber, - desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter)', - format: 'inputDefaultBlockNumberFormatter' + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`, see the [default block parameter](#the-default-block-parameter).', + format: 'inputDefaultBlockNumberFormatter', + optional: true } ], returns: { type: Quantity, - desc: 'integer of the number of transactions send from this address', - format: 'utils.toDecimal' + desc: 'integer of the number of transactions send from this address.', + format: 'utils.toDecimal', + example: fromDecimal(1) } }, getTransactionReceipt: { - desc: 'Returns the receipt of a transaction by transaction hash.\n**Note** That the receipt is not available for pending transactions.', + desc: 'Returns the receipt of a transaction by transaction hash.\n\n**Note** That the receipt is available even for pending transactions.', params: [ { type: Hash, - desc: 'hash of a transaction' + desc: 'hash of a transaction.', + example: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238' } ], returns: { @@ -619,35 +753,52 @@ export default { type: Array, desc: 'Array of log objects, which this transaction generated.' } + }, + example: { + transactionHash: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', + transactionIndex: fromDecimal(1), + blockNumber: fromDecimal(11), + blockHash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', + cumulativeGasUsed: fromDecimal(13244), + gasUsed: fromDecimal(1244), + contractAddress: withComment('0xb60e8dd61c5d32be8058bb8eb970870f07233155', 'or null, if none was created'), + logs: withComment( + [DUMMY, DUMMY], // will be replaced with [{ ... }, { ... }] by the generator + 'logs as returned by eth_getFilterLogs, etc.' + ) } } }, getUncleByBlockHashAndIndex: { - desc: 'Returns information about a uncle of a block by hash and uncle index position.', + desc: 'Returns information about a uncle of a block by hash and uncle index position.\n\n**Note:** An uncle doesn\'t contain individual transactions.', params: [ { type: Hash, - desc: 'Hash a block' + desc: 'Hash of a block.', + example: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b' }, { type: Quantity, - desc: 'The uncle\'s index position' + desc: 'The uncle\'s index position.', + example: fromDecimal(0) } ], returns: 'See [eth_getBlockByHash](#eth_getblockbyhash)' }, getUncleByBlockNumberAndIndex: { - desc: 'Returns information about a uncle of a block by number and uncle index position.', + desc: 'Returns information about a uncle of a block by number and uncle index position.\n\n**Note:** An uncle doesn\'t contain individual transactions.', params: [ { type: BlockNumber, - desc: 'a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter)' + desc: 'a block number, or the string `\'earliest\'`, `\'latest\'` or `\'pending\'`, as in the [default block parameter](#the-default-block-parameter).', + example: fromDecimal(668) }, { type: Quantity, - desc: 'The uncle\'s index position' + desc: 'The uncle\'s index position.', + example: fromDecimal(0) } ], returns: 'See [eth_getBlockByHash](#eth_getblockbyhash)' @@ -658,12 +809,14 @@ export default { params: [ { type: Hash, - desc: '32 Bytes - hash of a block' + desc: '32 Bytes - hash of a block.', + example: '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238' } ], returns: { type: Quantity, - desc: 'integer of the number of uncles in this block' + desc: 'integer of the number of uncles in this block.', + example: fromDecimal(0) } }, @@ -672,21 +825,29 @@ export default { params: [ { type: BlockNumber, - desc: 'integer of a block number, or the string \'latest\', \'earliest\' or \'pending\', see the [default block parameter](#the-default-block-parameter)' + desc: 'integer of a block number, or the string \'latest\', \'earliest\' or \'pending\', see the [default block parameter](#the-default-block-parameter).', + example: fromDecimal(232) } ], returns: { type: Quantity, - desc: 'integer of the number of uncles in this block' + desc: 'integer of the number of uncles in this block.', + example: fromDecimal(1) } }, getWork: { - desc: 'Returns the hash of the current block, the seedHash, and the boundary condition to be met (\'target\').', + desc: 'Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target").', params: [], returns: { type: Array, - desc: 'Array with the following properties:' + desc: 'Array with the following properties:\n - `Data`, 32 Bytes - current block header pow-hash.\n - `Data`, 32 Bytes - the seed hash used for the DAG.\n - `Data`, 32 Bytes - the boundary condition ("target"), 2^256 / difficulty.\n - `Quantity`, the current block number.', + example: [ + '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef', + '0x5EED00000000000000000000000000005EED0000000000000000000000000000', + '0xd1ff1c01710000000000000000000000d1ff1c01710000000000000000000000', + fromDecimal(1) + ] } }, @@ -695,11 +856,13 @@ export default { params: [], returns: { type: Quantity, - desc: 'number of hashes per second' + desc: 'number of hashes per second.', + example: fromDecimal(906) } }, inspectTransaction: { + nodoc: 'Not present in Rust code', desc: '?', params: [ '?' @@ -715,7 +878,8 @@ export default { params: [], returns: { type: Boolean, - desc: '`true` of the client is mining, otherwise `false`' + desc: '`true` of the client is mining, otherwise `false`.', + example: true } }, @@ -724,12 +888,22 @@ export default { params: [], returns: { type: Quantity, - desc: 'A filter id' + desc: 'A filter id.', + example: fromDecimal(1) } }, newFilter: { - desc: 'Creates a filter object, based on filter options, to notify when the state changes (logs).\nTo check if the state has changed, call [eth_getFilterChanges](#eth_getfilterchanges).', + desc: `Creates a filter object, based on filter options, to notify when the state changes (logs). + To check if the state has changed, call [eth_getFilterChanges](#eth_getfilterchanges). + + ##### A note on specifying topic filters: + Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters: + * \`[]\` "anything" + * \`[A]\` "A in first position (and anything after)" + * \`[null, B]\` "anything in first position AND B in second position (and anything after)" + * \`[A, B]\` "A in first position AND B in second position (and anything after)" + * \`[[A, B], [A, B]]\` "(A OR B) in first position AND (A OR B) in second position (and anything after)"`.replace(/^[^\S\n]+/gm, ''), params: [{ type: Object, desc: 'The filter options:', @@ -753,23 +927,35 @@ export default { }, topics: { type: Array, - desc: 'Array of 32 Bytes `DATA` topics. Topics are order-dependent. Each topic can also be an array of DATA with \'or\' options.', + desc: 'Array of 32 Bytes `Data` topics. Topics are order-dependent. It\'s possible to pass in `null` to match any topic, or a subarray of multiple topics of which one should be matching.', optional: true }, limit: { - type: Number, - desc: 'The maximum number of entries to retrieve (latest first)', + type: Quantity, + desc: 'The maximum number of entries to retrieve (latest first).', optional: true } + }, + example: { + fromBlock: fromDecimal(1), + toBlock: fromDecimal(2), + address: '0x8888f1f195afa192cfee860698584c030f4c9db1', + topics: withComment([ + withComment('0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', 'This topic in first position'), + withComment(null, 'Any topic in second position'), + withComment(['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc'], 'Either topic of the two in third position') + ], '... and anything after') } }], returns: { type: Quantity, - desc: 'The filter id' + desc: 'The filter id.', + example: fromDecimal(1) } }, newFilterEx: { + nodoc: 'Not present in Rust code', // https://github.com/ethereum/wiki/wiki/Proposal:-Reversion-Notification desc: '?', params: [ '?' @@ -781,15 +967,17 @@ export default { }, newPendingTransactionFilter: { - desc: 'Creates a filter in the node, to notify when new pending transactions arrive.\nTo check if the state has changed, call [eth_getFilterChanges](#eth_getfilterchanges).', + desc: 'Creates a filter in the node, to notify when new pending transactions arrive.\n\nTo check if the state has changed, call [eth_getFilterChanges](#eth_getfilterchanges).', params: [], returns: { type: Quantity, - desc: 'A filter id' + desc: 'A filter id.', + example: fromDecimal(1) } }, notePassword: { + nodoc: 'Not present in Rust code', desc: '?', params: [ '?' @@ -801,6 +989,7 @@ export default { }, pendingTransactions: { + nodoc: 'Not present in Rust code', desc: '?', params: [], returns: { @@ -814,11 +1003,13 @@ export default { params: [], returns: { type: String, - desc: 'The current ethereum protocol version' + desc: 'The current ethereum protocol version.', + example: fromDecimal(99) } }, register: { + nodoc: 'Not present in Rust code', desc: '?', params: [ '?' @@ -830,16 +1021,18 @@ export default { }, sendRawTransaction: { - desc: 'Creates new message call transaction or a contract creation for signed transactions.', + desc: 'Creates new message call transaction or a contract creation for signed transactions.\n\n**Note:** `eth_submitTransaction` is an alias of this method.', params: [ { type: Data, - desc: 'The signed transaction data' + desc: 'The signed transaction data.', + example: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' } ], returns: { type: Hash, - desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available' + desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available\n\nUse [eth_getTransactionReceipt](#eth_gettransactionreceipt) to get the contract address, after the transaction was mined, when you created a contract.', + example: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' } }, @@ -847,16 +1040,17 @@ export default { desc: 'Creates new message call transaction or a contract creation, if the data field contains code.', params: [ { - type: Object, desc: 'The transaction object', + type: Object, + desc: 'The transaction object.', format: 'inputTransactionFormatter', details: { from: { type: Address, - desc: '20 Bytes - The address the transaction is send from' + desc: '20 Bytes - The address the transaction is send from.' }, to: { type: Address, - desc: '20 Bytes - (optional when creating new contract) The address the transaction is directed to' + desc: '20 Bytes - (optional when creating new contract) The address the transaction is directed to.' }, gas: { type: Quantity, @@ -866,13 +1060,13 @@ export default { }, gasPrice: { type: Quantity, - desc: 'Integer of the gasPrice used for each paid gas', + desc: 'Integer of the gasPrice used for each paid gas.', optional: true, default: 'To-Be-Determined' }, value: { type: Quantity, - desc: 'Integer of the value send with this transaction', + desc: 'Integer of the value sent with this transaction.', optional: true }, data: { @@ -884,12 +1078,21 @@ export default { desc: 'Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.', optional: true } + }, + example: { + from: '0xb60e8dd61c5d32be8058bb8eb970870f07233155', + to: '0xd46e8dd67c5d32be8058bb8eb970870f072445675', + gas: fromDecimal(30400), + gasPrice: fromDecimal(10000000000000), + value: fromDecimal(2441406250), + data: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' } } ], returns: { type: Hash, - desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available' + desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.\n\nUse [eth_getTransactionReceipt](#eth_gettransactionreceipt) to get the contract address, after the transaction was mined, when you created a contract.', + example: '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331' } }, @@ -898,28 +1101,108 @@ export default { params: [ { type: Address, - desc: '20 Bytes - address', - format: 'inputAddressFormatter' + desc: '20 Bytes - address.', + format: 'inputAddressFormatter', + example: '0xd1ade25ccd3d550a7eb532ac759cac7be09c2719' }, { type: Data, - desc: 'Transaction hash to sign' + desc: 'Transaction hash to sign.', + example: withComment('0x5363686f6f6c627573', 'Schoolbus') } ], returns: { type: Data, - desc: 'Signed data' + desc: 'Signed data.', + example: '0x2ac19db245478a06032e69cdbd2b54e648b78431d0a47bd1fbab18f79f820ba407466e37adbe9e84541cab97ab7d290f4a64a5825c876d22109f3bf813254e8628' } }, signTransaction: { - desc: '?', + desc: 'Signs transactions without dispatching it to the network. It can be later submitted using [eth_sendRawTransaction](#eth_sendrawtransaction).', params: [ - '?' + { + type: Object, + desc: 'see [eth_sendTransaction](#eth_sendTransaction).', + format: 'inputCallFormatter', + example: DUMMY // will be replaced with { ... } by the generator + } ], returns: { - type: Boolean, - desc: 'whether the call was successful' + type: Object, + desc: 'Signed transaction and it\'s details:', + details: { + raw: { + type: Data, + desc: 'The signed, RLP encoded transaction.' + }, + tx: { + type: Object, + desc: 'Transaction object:', + details: { + hash: { + type: Hash, + desc: '32 Bytes - hash of the transaction.' + }, + nonce: { + type: Quantity, + desc: 'the number of transactions made by the sender prior to this one.' + }, + blockHash: { + type: Hash, + desc: '32 Bytes - hash of the block where this transaction was in. `null` when its pending.' + }, + blockNumber: { + type: BlockNumber, + desc: 'block number where this transaction was in. `null` when its pending.' + }, + transactionIndex: { + type: Quantity, + desc: 'integer of the transactions index position in the block. `null` when its pending.' + }, + from: { + type: Address, + desc: '20 Bytes - address of the sender.' + }, + to: { + type: Address, + desc: '20 Bytes - address of the receiver. `null` when its a contract creation transaction.' + }, + value: { + type: Quantity, + desc: 'value transferred in Wei.' + }, + gasPrice: { + type: Quantity, + desc: 'gas price provided by the sender in Wei.' + }, + gas: { + type: Quantity, + desc: 'gas provided by the sender.' + }, + input: { + type: Data, + desc: 'the data send along with the transaction.' + } + } + } + }, + example: { + raw: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', + tx: { + hash: '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b', + nonce: fromDecimal(0), + blockHash: '0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b', + blockNumber: fromDecimal(5599), + transactionIndex: fromDecimal(1), + from: '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + to: '0x85h43d8a49eeb85d32cf465507dd71d507100c1', + value: fromDecimal(520464), + gas: fromDecimal(520464), + gasPrice: '0x09184e72a000', + input: '0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360' + } + } } }, @@ -928,20 +1211,24 @@ export default { params: [ { type: Data, - desc: '8 Bytes - The nonce found (64 bits)' + desc: '8 Bytes - The nonce found (64 bits).', + example: '0x0000000000000001' }, { type: Data, - desc: '32 Bytes - The header\'s pow-hash (256 bits)' + desc: '32 Bytes - The header\'s pow-hash (256 bits)', + example: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' }, { type: Data, - desc: '32 Bytes - The mix digest (256 bits)' + desc: '32 Bytes - The mix digest (256 bits).', + example: '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000' } ], returns: { type: Boolean, - desc: '`true` if the provided solution is valid, otherwise `false`' + desc: '`true` if the provided solution is valid, otherwise `false`.', + example: true } }, @@ -950,16 +1237,19 @@ export default { params: [ { type: Data, - desc: 'a hexadecimal string representation (32 bytes) of the hash rate' + desc: 'a hexadecimal string representation (32 bytes) of the hash rate.', + example: '0x0000000000000000000000000000000000000000000000000000000000500000' }, { - type: String, - desc: 'A random hexadecimal(32 bytes) ID identifying the client' + type: Data, + desc: 'A random hexadecimal(32 bytes) ID identifying the client.', + example: '0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c' } ], returns: { type: Boolean, - desc: '`true` if submitting went through succesfully and `false` otherwise' + desc: '`true` if submitting went through succesfully and `false` otherwise.', + example: true } }, @@ -968,7 +1258,7 @@ export default { params: [], returns: { type: Object, - desc: 'An object with sync status data or `FALSE`, when not syncing', + desc: 'An object with sync status data or `FALSE`, when not syncing.', format: 'outputSyncingFormatter', details: { startingBlock: { @@ -995,7 +1285,12 @@ export default { type: Quantity, desc: 'Total amount of snapshot chunks processed' } - } + }, + example: withComment({ + startingBlock: fromDecimal(900), + currentBlock: fromDecimal(902), + highestBlock: fromDecimal(1108) + }, 'Or `false` when not syncing') } }, @@ -1004,16 +1299,19 @@ export default { params: [ { type: Quantity, - desc: 'The filter id' + desc: 'The filter id.', + example: fromDecimal(11) } ], returns: { type: Boolean, - desc: '`true` if the filter was successfully uninstalled, otherwise `false`' + desc: '`true` if the filter was successfully uninstalled, otherwise `false`.', + example: true } }, unregister: { + nodoc: 'Not present in Rust code', desc: '?', params: [ '?' @@ -1023,4 +1321,4 @@ export default { desc: 'whether the call was successful' } } -}; +}); diff --git a/js/src/jsonrpc/interfaces/net.js b/js/src/jsonrpc/interfaces/net.js index ee8cd9069..028f416df 100644 --- a/js/src/jsonrpc/interfaces/net.js +++ b/js/src/jsonrpc/interfaces/net.js @@ -15,6 +15,7 @@ // along with Parity. If not, see . import { Quantity } from '../types'; +import { fromDecimal } from '../helpers'; export default { listening: { @@ -22,7 +23,8 @@ export default { params: [], returns: { type: Boolean, - desc: '`true` when listening, otherwise `false`.' + desc: '`true` when listening, otherwise `false`.', + example: true } }, @@ -32,7 +34,8 @@ export default { returns: { type: Quantity, desc: 'Integer of the number of connected peers', - format: 'utils.toDecimal' + format: 'utils.toDecimal', + example: fromDecimal(2) } }, @@ -41,7 +44,8 @@ export default { params: [], returns: { type: String, - desc: 'The current network protocol version' + desc: 'The current network protocol version', + example: '8995' } } }; diff --git a/js/src/jsonrpc/interfaces/parity.js b/js/src/jsonrpc/interfaces/parity.js index 1f6caca4a..788dd695a 100644 --- a/js/src/jsonrpc/interfaces/parity.js +++ b/js/src/jsonrpc/interfaces/parity.js @@ -14,71 +14,125 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { Address, Data, Hash, Quantity } from '../types'; +import { Address, Data, Hash, Quantity, BlockNumber } from '../types'; +import { fromDecimal, withComment, DUMMY } from '../helpers'; + +const SECTION_MINING = 'Block Authoring (aka "mining")'; +const SECTION_DEV = 'Development'; +const SECTION_NODE = 'Node Settings'; +const SECTION_NET = 'Network Information'; +const SECTION_ACCOUNTS = 'Accounts (read-only) and Signatures'; + +const transactionDetails = { + hash: { + type: Hash, + desc: '32 Bytes - hash of the transaction.' + }, + nonce: { + type: Quantity, + desc: 'The number of transactions made by the sender prior to this one.' + }, + blockHash: { + type: Hash, + desc: '32 Bytes - hash of the block where this transaction was in. `null` when its pending.' + }, + blockNumber: { + type: BlockNumber, + desc: 'Block number where this transaction was in. `null` when its pending.' + }, + transactionIndex: { + type: Quantity, + desc: 'Integer of the transactions index position in the block. `null` when its pending.' + }, + from: { + type: Address, + desc: '20 Bytes - address of the sender.' + }, + to: { + type: Address, + desc: '20 Bytes - address of the receiver. `null` when its a contract creation transaction.' + }, + value: { + type: Quantity, + desc: 'Value transferred in Wei.' + }, + gasPrice: { + type: Quantity, + desc: 'Gas price provided by the sender in Wei.' + }, + gas: { + type: Quantity, + desc: 'Gas provided by the sender.' + }, + input: { + type: Data, + desc: 'The data send along with the transaction.' + }, + raw: { + type: Data, + desc: 'Raw transaction data.' + }, + publicKey: { + type: Data, + desc: 'Public key of the signer.' + }, + networkId: { + type: Quantity, + desc: 'The network id of the transaction, if any.' + }, + standardV: { + type: Quantity, + desc: 'The standardized V field of the signature (0 or 1).' + }, + v: { + type: Quantity, + desc: 'The V field of the signature.' + }, + r: { + type: Quantity, + desc: 'The R field of the signature.' + }, + s: { + type: Quantity, + desc: 'The S field of the signature.' + }, + minBlock: { + type: BlockNumber, + optional: true, + desc: 'Block number, tag or `null`.' + } +}; export default { - acceptNonReservedPeers: { - desc: '?', - params: [], - returns: { - type: Boolean, - desc: '?' - } - }, - accountsInfo: { - desc: 'returns a map of accounts as an object', + section: SECTION_ACCOUNTS, + desc: 'Provides metadata for accounts.', params: [], returns: { - type: Array, - desc: 'Account metadata', + type: Object, + desc: 'Maps account address to metadata.', details: { name: { type: String, desc: 'Account name' } - } - } - }, - - allAccountsInfo: { - desc: 'returns a map of accounts as an object', - params: [], - returns: { - type: Array, - desc: 'Account metadata', - details: { - name: { - type: String, - desc: 'Account name' + }, + example: { + '0x0024d0c7ab4c52f723f3aaf0872b9ea4406846a4': { + name: 'Foo' }, - meta: { - type: String, - desc: 'Encoded JSON string the defines additional account metadata' + '0x004385d8be6140e6f889833f68b51e17b6eacb29': { + name: 'Bar' }, - uuid: { - type: String, - desc: 'The account Uuid, or null if not available/unknown/not applicable.' + '0x009047ed78fa2be48b62aaf095b64094c934dab0': { + name: 'Baz' } } } }, - addReservedPeer: { - desc: '?', - params: [ - { - type: String, - desc: 'Enode' - } - ], - returns: { - type: Boolean, - desc: '?' - } - }, - chainStatus: { + section: SECTION_NET, desc: 'Returns the information on warp sync blocks', params: [], returns: { @@ -94,122 +148,126 @@ export default { } }, - checkRequest: { - desc: 'Returns the transactionhash of the requestId (received from parity_postTransaction) if the request was confirmed', - params: [ - { - type: Quantity, - desc: 'The requestId to check for' - } - ], - returns: { - type: Hash, - desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available' - } - }, - consensusCapability: { - desc: 'Returns an object or string detailing the state of parity capability of maintaining consensus', + desc: 'Returns information on current consensus capability.', params: [], returns: { type: Object, - desc: 'Either "capable", {"capableUntil":N}, {"incapableSince":N} or "unknown" (N is a block number)' + desc: 'or `String` - Either `"capable"`, `{"capableUntil":N}`, `{"incapableSince":N}` or `"unknown"` (`N` is a block number).', + example: 'capable' } }, dappsPort: { - desc: 'Returns the port the dapps are running on, error if not enabled', + section: SECTION_NODE, + desc: 'Returns the port the dapps are running on, error if not enabled.', params: [], returns: { type: Quantity, - desc: 'The port number' + desc: 'The port number', + example: 8080 } }, dappsInterface: { - desc: 'Returns the interface the dapps are running on, error if not enabled', + section: SECTION_NODE, + desc: 'Returns the interface the dapps are running on, error if not enabled.', params: [], returns: { type: String, - desc: 'The interface' + desc: 'The interface', + example: '127.0.0.1' } }, defaultExtraData: { + section: SECTION_MINING, desc: 'Returns the default extra data', params: [], returns: { type: Data, - desc: 'Extra data' + desc: 'Extra data', + example: '0xd5830106008650617269747986312e31342e30826c69' } }, devLogs: { - desc: 'Returns latest logs of your node', + section: SECTION_DEV, + desc: 'Returns latest stdout logs of your node.', params: [], returns: { type: Array, - desc: 'Development logs' + desc: 'Development logs', + example: [ + '2017-01-20 18:14:19 Updated conversion rate to Ξ1 = US$10.63 (11199212000 wei/gas)', + '2017-01-20 18:14:19 Configured for DevelopmentChain using InstantSeal engine', + '2017-01-20 18:14:19 Operating mode: active', + '2017-01-20 18:14:19 State DB configuration: fast', + '2017-01-20 18:14:19 Starting Parity/v1.6.0-unstable-2ae8b4c-20170120/x86_64-linux-gnu/rustc1.14.0' + ] } }, devLogsLevels: { - desc: 'Returns current log level settings', + section: SECTION_DEV, + desc: 'Returns current logging level settings. Logging level can be set with `--logging` and be one of: `""` (default), `"info"`, `"debug"`, `"warn"`, `"error"`, `"trace"`.', params: [], returns: { type: String, - decs: 'Current log level' - } - }, - - dropNonReservedPeers: { - desc: '?', - params: [], - returns: { - type: Boolean, - desc: '?' + decs: 'Current log level.', + example: 'debug' } }, enode: { - desc: 'Returns the node enode URI', + section: SECTION_NODE, + desc: 'Returns the node enode URI.', params: [], returns: { type: String, - desc: 'Enode URI' - } - }, - - executeUpgrade: { - desc: 'Performs an upgrade', - params: [], - returns: { - type: Boolean, - desc: 'returns true if the upgrade to the release specified in parity_upgradeReady was successfully executed, false if not' + desc: 'Enode URI', + example: 'enode://050929adcfe47dbe0b002cb7ef2bf91ca74f77c4e0f68730e39e717f1ce38908542369ae017148bee4e0d968340885e2ad5adea4acd19c95055080a4b625df6a@172.17.0.1:30303' } }, extraData: { - desc: 'Returns currently set extra data', + section: SECTION_MINING, + desc: 'Returns currently set extra data.', params: [], returns: { type: Data, - desc: 'Extra data' + desc: 'Extra data.', + example: '0xd5830106008650617269747986312e31342e30826c69' } }, gasFloorTarget: { - desc: 'Returns current target for gas floor', + section: SECTION_MINING, + desc: 'Returns current target for gas floor.', params: [], returns: { type: Quantity, - desc: 'Gas Floor Target', - format: 'outputBigNumberFormatter' + desc: 'Gas floor target.', + format: 'outputBigNumberFormatter', + example: fromDecimal(4700000) + } + }, + + gasCeilTarget: { + section: SECTION_MINING, + desc: 'Returns current target for gas ceiling.', + params: [], + returns: { + type: Quantity, + desc: 'Gas ceiling target.', + format: 'outputBigNumberFormatter', + example: fromDecimal(6283184) } }, gasPriceHistogram: { - desc: 'Returns a snapshot of the historic gas prices', + section: SECTION_NET, + desc: 'Returns a snapshot of the historic gas prices.', params: [], returns: { type: Object, @@ -217,123 +275,28 @@ export default { details: { bucketBounds: { type: Array, - desc: 'Array of U256 bound values' + desc: 'Array of bound values.' }, count: { type: Array, - desc: 'Array of U64 counts' + desc: 'Array of counts.' } + }, + example: { + bucketBounds: ['0x4a817c800', '0x525433d01', '0x5a26eb202', '0x61f9a2703', '0x69cc59c04', '0x719f11105', '0x7971c8606', '0x81447fb07', '0x891737008', '0x90e9ee509', '0x98bca5a0a'], + counts: [487, 9, 7, 1, 8, 0, 0, 0, 0, 14] } } }, generateSecretPhrase: { - desc: 'Creates a secret phrase that can be associated with an account', + section: SECTION_ACCOUNTS, + desc: 'Creates a secret phrase that can be associated with an account.', params: [], returns: { type: String, - desc: 'The secret phrase' - } - }, - - getDappsAddresses: { - desc: 'Returns the list of accounts available to a specific dapp', - params: [ - { - type: String, - desc: 'Dapp Id' - } - ], - returns: { - type: Array, - desc: 'The list of available accounts' - } - }, - - getNewDappsWhitelist: { - desc: 'Returns the list of accounts available to a new dapps', - params: [], - returns: { - type: Array, - desc: 'The list of available accounts' - } - }, - - hashContent: { - desc: 'Creates a hash of the file as retrieved', - params: [ - { - type: String, - desc: 'The url of the content' - } - ], - returns: { - type: Hash, - desc: 'The hash of the content' - } - }, - - importGethAccounts: { - desc: 'Imports a list of accounts from geth', - params: [ - { - type: Array, - desc: 'List of the geth addresses to import' - } - ], - returns: { - type: Array, - desc: 'Array of the imported addresses' - } - }, - - killAccount: { - desc: 'Deletes an account', - params: [ - { - type: Address, - desc: 'The account to remove' - }, - { - type: String, - desc: 'Account password' - } - ], - returns: { - type: Boolean, - desc: 'true on success' - } - }, - - listRecentDapps: { - desc: 'Returns a list of the most recent active dapps', - params: [], - returns: { - type: Array, - desc: 'Array of Dapp Ids' - } - }, - - removeAddress: { - desc: 'Removes an address from the addressbook', - params: [ - { - type: Address, - desc: 'The address to remove' - } - ], - returns: { - type: Boolean, - desc: 'true on success' - } - }, - - listGethAccounts: { - desc: 'Returns a list of the accounts available from Geth', - params: [], - returns: { - type: Array, - desc: '20 Bytes addresses owned by the client.' + desc: 'The secret phrase.', + example: 'boasting breeches reshape reputably exit handrail stony jargon moneywise unhinge handed ruby' } }, @@ -342,102 +305,557 @@ export default { params: [], returns: { type: Object, - desc: 'Mapping of `tx hash` into status object.' + desc: 'Mapping of transaction hashes to status objects status object.', + example: { + '0x09e64eb1ae32bb9ac415ce4ddb3dbad860af72d9377bb5f073c9628ab413c532': { + status: 'mined', + transaction: { + from: '0x00a329c0648769a73afac7f9381e08fb43dbea72', + to: '0x00a289b43e1e4825dbedf2a78ba60a640634dc40', + value: '0xfffff', + blockHash: null, + blockNumber: null, + creates: null, + gas: '0xe57e0', + gasPrice: '0x2d20cff33', + hash: '0x09e64eb1ae32bb9ac415ce4ddb3dbad860af72d9377bb5f073c9628ab413c532', + input: '0x', + minBlock: null, + networkId: null, + nonce: '0x0', + publicKey: '0x3fa8c08c65a83f6b4ea3e04e1cc70cbe3cd391499e3e05ab7dedf28aff9afc538200ff93e3f2b2cb5029f03c7ebee820d63a4c5a9541c83acebe293f54cacf0e', + raw: '0xf868808502d20cff33830e57e09400a289b43e1e4825dbedf2a78ba60a640634dc40830fffff801ca034c333b0b91cd832a3414d628e3fea29a00055cebf5ba59f7038c188404c0cf3a0524fd9b35be170439b5ffe89694ae0cfc553cb49d1d8b643239e353351531532', + standardV: '0x1', + v: '0x1c', + r: '0x34c333b0b91cd832a3414d628e3fea29a00055cebf5ba59f7038c188404c0cf3', + s: '0x524fd9b35be170439b5ffe89694ae0cfc553cb49d1d8b643239e353351531532', + transactionIndex: null + } + }, + '0x...': DUMMY + } } }, minGasPrice: { + section: SECTION_MINING, desc: 'Returns currently set minimal gas price', params: [], returns: { type: Quantity, desc: 'Minimal Gas Price', - format: 'outputBigNumberFormatter' + format: 'outputBigNumberFormatter', + example: fromDecimal(11262783488) } }, mode: { - desc: 'Get the mode. Results one of: "active", "passive", "dark", "offline".', + section: SECTION_NODE, + desc: 'Get the mode. Results one of: `"active"`, `"passive"`, `"dark"`, `"offline"`.', params: [], returns: { type: String, - desc: 'The mode' + desc: 'The mode.', + example: 'active' } }, netChain: { + section: SECTION_NET, desc: 'Returns the name of the connected chain.', params: [], returns: { type: String, - desc: 'chain name' + desc: 'chain name.', + example: 'homestead' } }, netPeers: { + section: SECTION_NET, desc: 'Returns number of peers.', params: [], returns: { - type: Quantity, - desc: 'Number of peers' - } - }, - - netMaxPeers: { - desc: 'Returns maximal number of peers.', - params: [], - returns: { - type: Quantity, - desc: 'Maximal number of peers' + type: Object, + desc: 'Number of peers', + details: { + active: { + type: Quantity, + desc: 'Number of active peers.' + }, + connected: { + type: Quantity, + desc: 'Number of connected peers.' + }, + max: { + type: Quantity, + desc: 'Maximum number of connected peers.' + }, + peers: { + type: Array, + desc: 'List of all peers with details.' + } + }, + example: { + active: 0, + connected: 25, + max: 25, + peers: [DUMMY, DUMMY, DUMMY, DUMMY] + } } }, netPort: { + section: SECTION_NET, desc: 'Returns network port the node is listening on.', params: [], returns: { type: Quantity, - desc: 'Port Number' + desc: 'Port number', + example: 30303 + } + }, + + nextNonce: { + section: SECTION_NET, + desc: 'Returns next available nonce for transaction from given account. Includes pending block and transaction queue.', + params: [ + { + type: Address, + desc: 'Account', + example: '0x00A289B43e1e4825DbEDF2a78ba60a640634DC40' + } + ], + returns: { + type: Quantity, + desc: 'Next valid nonce', + example: fromDecimal(12) + } + }, + + nodeName: { + section: SECTION_NODE, + desc: 'Returns node name, set when starting parity with `--identity NAME`.', + params: [], + returns: { + type: String, + desc: 'Node name.', + example: 'Doge' + } + }, + + pendingTransactions: { + section: SECTION_NET, + desc: 'Returns a list of transactions currently in the queue.', + params: [], + returns: { + type: Array, + desc: 'Transactions ordered by priority', + details: transactionDetails, + example: [ + { + blockHash: null, + blockNumber: null, + creates: null, + from: '0xee3ea02840129123d5397f91be0391283a25bc7d', + gas: '0x23b58', + gasPrice: '0xba43b7400', + hash: '0x160b3c30ab1cf5871083f97ee1cee3901cfba3b0a2258eb337dd20a7e816b36e', + input: '0x095ea7b3000000000000000000000000bf4ed7b27f1d666546e30d74d50d173d20bca75400000000000000000000000000002643c948210b4bd99244ccd64d5555555555', + minBlock: null, + networkId: 1, + nonce: '0x5', + publicKey: '0x96157302dade55a1178581333e57d60ffe6fdf5a99607890456a578b4e6b60e335037d61ed58aa4180f9fd747dc50d44a7924aa026acbfb988b5062b629d6c36', + r: '0x92e8beb19af2bad0511d516a86e77fa73004c0811b2173657a55797bdf8558e1', + raw: '0xf8aa05850ba43b740083023b5894bb9bc244d798123fde783fcc1c72d3bb8c18941380b844095ea7b3000000000000000000000000bf4ed7b27f1d666546e30d74d50d173d20bca75400000000000000000000000000002643c948210b4bd99244ccd64d555555555526a092e8beb19af2bad0511d516a86e77fa73004c0811b2173657a55797bdf8558e1a062b4d4d125bbcb9c162453bc36ca156537543bb4414d59d1805d37fb63b351b8', + s: '0x62b4d4d125bbcb9c162453bc36ca156537543bb4414d59d1805d37fb63b351b8', + standardV: '0x1', + to: '0xbb9bc244d798123fde783fcc1c72d3bb8c189413', + transactionIndex: null, + v: '0x26', + value: '0x0' + }, + DUMMY, + DUMMY + ] + } + }, + + pendingTransactionsStats: { + desc: 'Returns propagation stats for transactions in the queue.', + params: [], + returns: { + type: Object, + desc: 'mapping of transaction hashes to stats.', + example: { + '0xdff37270050bcfba242116c745885ce2656094b2d3a0f855649b4a0ee9b5d15a': { + firstSeen: 3032066, + propagatedTo: { + '0x605e04a43b1156966b3a3b66b980c87b7f18522f7f712035f84576016be909a2798a438b2b17b1a8c58db314d88539a77419ca4be36148c086900fba487c9d39': 1, + '0xbab827781c852ecf52e7c8bf89b806756329f8cbf8d3d011e744a0bc5e3a0b0e1095257af854f3a8415ebe71af11b0c537f8ba797b25972f519e75339d6d1864': 1 + } + } + } + } + }, + + phraseToAddress: { + section: SECTION_ACCOUNTS, + desc: 'Converts a secret phrase into the corresponding address.', + params: [ + { + type: String, + desc: 'The phrase', + example: 'stylus outing overhand dime radial seducing harmless uselessly evasive tastiness eradicate imperfect' + } + ], + returns: { + type: Address, + desc: 'Corresponding address', + example: '0x004385d8be6140e6f889833f68b51e17b6eacb29' + } + }, + + releasesInfo: { + desc: 'returns a ReleasesInfo object describing the current status of releases', + params: [], + returns: { + type: Object, + desc: 'Information on current releases, `null` if not available.', + details: { + fork: { + type: Quantity, + desc: 'Block number representing the last known fork for this chain, which may be in the future.' + }, + minor: { + type: Object, + desc: 'Information about latest minor update to current version, `null` if this is the latest minor version.' + }, + track: { + type: Object, + desc: 'Information about the latest release in this track.' + } + }, + example: null + } + }, + + registryAddress: { + section: SECTION_NET, + desc: 'The address for the global registry.', + params: [], + returns: { + type: Address, + desc: 'The registry address.', + example: '0x3bb2bb5c6c9c9b7f4ef430b47dc7e026310042ea' + } + }, + + rpcSettings: { + section: SECTION_NET, + desc: 'Provides current JSON-RPC API settings.', + params: [], + returns: { + type: Object, + desc: 'JSON-RPC settings.', + details: { + enabled: { + type: Boolean, + desc: '`true` if JSON-RPC is enabled (default).' + }, + interface: { + type: String, + desc: 'Interface on which JSON-RPC is running.' + }, + port: { + type: Quantity, + desc: 'Port on which JSON-RPC is running.' + } + }, + example: { + enabled: true, + interface: 'local', + port: 8545 + } + } + }, + + signerPort: { + section: SECTION_NODE, + desc: 'Returns the port the signer is running on, error if not enabled', + params: [], + returns: { + type: Quantity, + desc: 'The port number', + example: 8180 + } + }, + + transactionsLimit: { + section: SECTION_MINING, + desc: 'Changes limit for transactions in queue.', + params: [], + returns: { + type: Quantity, + desc: 'Current max number of transactions in queue.', + format: 'outputBigNumberFormatter', + example: 1024 + } + }, + + unsignedTransactionsCount: { + section: SECTION_NET, + desc: 'Returns number of unsigned transactions when running with Trusted Signer. Error otherwise', + params: [], + returns: { + type: Quantity, + desc: 'Number of unsigned transactions', + example: 0 + } + }, + + versionInfo: { + desc: 'Provides information about running version of Parity.', + params: [], + returns: { + type: Object, + desc: 'Information on current version.', + details: { + hash: { + type: Hash, + desc: '20 Byte hash of the current build.' + }, + track: { + type: String, + desc: 'Track on which it was released, one of: `"stable"`, `"beta"`, `"nightly"`, `"testing"`, `"null"` (unknown or self-built).' + }, + version: { + type: Object, + desc: 'Version number composed of `major`, `minor` and `patch` integers.' + } + }, + example: { + hash: '0x2ae8b4ca278dd7b896090366615fef81cbbbc0e0', + track: 'null', + version: { + major: 1, + minor: 6, + patch: 0 + } + } + } + }, + + listAccounts: { + desc: 'Returns all addresses if Fat DB is enabled (`--fat-db`), `null` otherwise.', + section: SECTION_ACCOUNTS, + params: [ + { + type: Quantity, + desc: 'Integer number of addresses to display in a batch.', + example: 5 + }, + { + type: Address, + desc: '20 Bytes - Offset address from which the batch should start in order, or `null`.', + example: null + }, + { + type: BlockNumber, + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`.', + format: 'inputDefaultBlockNumberFormatter', + optional: true + } + ], + returns: { + type: Array, + desc: 'Requested number of `Address`es or `null` if Fat DB is not enabled.', + example: [ + '0x7205b1bb42edce6e0ced37d1fd0a9d684f5a860f', + '0x98a2559a814c300b274325c92df1682ae0d344e3', + '0x2d7a7d0adf9c5f9073fefbdc18188bd23c68b633', + '0xd4bb3284201db8b03c06d8a3057dd32538e3dfda', + '0xa6396904b08aa31300ca54278b8e066ecc38e4a0' + ] + } + }, + + listStorageKeys: { + desc: 'Returns all storage keys of the given address (first parameter) if Fat DB is enabled (`--fat-db`), `null` otherwise.', + params: [ + { + type: Address, + desc: '20 Bytes - Account for which to retrieve the storage keys.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + }, + { + type: Quantity, + desc: 'Integer number of addresses to display in a batch.', + example: 5 + }, + { + type: Hash, + desc: '32 Bytes - Offset storage key from which the batch should start in order, or `null`.', + example: null + }, + { + type: BlockNumber, + desc: 'integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`.', + format: 'inputDefaultBlockNumberFormatter', + optional: true + } + ], + returns: { + type: Array, + desc: 'Requested number of 32 byte long storage keys for the given account or `null` if Fat DB is not enabled.', + example: [ + '0xaab1a2940583e213f1d57a3ed358d5f5406177c8ff3c94516bfef3ea62d00c22', + '0xba8469eca5641b186e86cbc5343dfa5352df04feb4564cd3cf784f213aaa0319', + '0x769d107ba778d90205d7a159e820c41c20bf0783927b426c602561e74b7060e5', + '0x0289865bcaa58f7f5bf875495ac7af81e3630eb88a3a0358407c7051a850624a', + '0x32e0536502b9163b0a1ce6e3aabd95fa4a2bf602bbde1b9118015648a7a51178' + ] + } + }, + + encryptMessage: { + desc: 'Encrypt some data with a public key under ECIES.', + params: [ + { + type: Hash, + desc: 'Public EC key generated with `secp256k1` curve, truncated to the last 64 bytes.', + example: '0xD219959D466D666060284733A80DDF025529FEAA8337169540B3267B8763652A13D878C40830DD0952639A65986DBEC611CF2171A03CFDC37F5A40537068AA4F' + }, + { + type: Data, + desc: 'The message to encrypt.', + example: withComment('0x68656c6c6f20776f726c64', '"hello world"') + } + ], + returns: { + type: Data, + desc: 'Encrypted message.', + example: '0x0491debeec5e874a453f84114c084c810708ebcb553b02f1b8c05511fa4d1a25fa38eb49a32c815e2b39b7bcd56d66648bf401067f15413dae683084ca7b01e21df89be9ec4bc6c762a657dbd3ba1540f557e366681b53629bb2c02e1443b5c0adc6b68f3442c879456d6a21ec9ed07847fa3c3ecb73ec7ee9f8e32d' + } + }, + + futureTransactions: { + desc: 'Returns all future transactions from transaction queue.', + params: [], + returns: { + type: Array, + desc: 'Transaction list.', + details: transactionDetails, + example: [ + { + hash: '0x80de421cd2e7e46824a91c343ca42b2ff339409eef09e2d9d73882462f8fce31', + nonce: '0x1', + blockHash: null, + blockNumber: null, + transactionIndex: null, + from: '0xe53e478c072265e2d9a99a4301346700c5fbb406', + to: '0xf5d405530dabfbd0c1cab7a5812f008aa5559adf', + value: '0x2efc004ac03a4996', + gasPrice: '0x4a817c800', + gas: '0x5208', + input: '0x', + creates: null, + raw: '0xf86c018504a817c80082520894f5d405530dabfbd0c1cab7a5812f008aa5559adf882efc004ac03a49968025a0b40c6967a7e8bbdfd99a25fd306b9ef23b80e719514aeb7ddd19e2303d6fc139a06bf770ab08119e67dc29817e1412a0e3086f43da308c314db1b3bca9fb6d32bd', + publicKey: '0xeba33fd74f06236e17475bc5b6d1bac718eac048350d77d3fc8fbcbd85782a57c821255623c4fd1ebc9d555d07df453b2579ee557b7203fc256ca3b3401e4027', + networkId: 1, + standardV: '0x0', + v: '0x25', + r: '0xb40c6967a7e8bbdfd99a25fd306b9ef23b80e719514aeb7ddd19e2303d6fc139', + s: '0x6bf770ab08119e67dc29817e1412a0e3086f43da308c314db1b3bca9fb6d32bd', + minBlock: null + }, + DUMMY, + DUMMY + ] + } + }, + + /* + * `parity_accounts` module methods + * ================================ + */ + allAccountsInfo: { + subdoc: 'accounts', + desc: 'returns a map of accounts as an object.', + params: [], + returns: { + type: Array, + desc: 'Account metadata.', + details: { + name: { + type: String, + desc: 'Account name.' + }, + meta: { + type: String, + desc: 'Encoded JSON string the defines additional account metadata.' + }, + uuid: { + type: String, + desc: 'The account Uuid, or `null` if not available/unknown/not applicable.' + } + }, + example: { + '0x00a289b43e1e4825dbedf2a78ba60a640634dc40': { + meta: '{}', + name: 'Foobar', + uuid: '0b9e70e6-235b-682d-a15c-2a98c71b3945' + } + } } }, newAccountFromPhrase: { - desc: 'Creates a new account from a recovery passphrase', + subdoc: 'accounts', + desc: 'Creates a new account from a recovery phrase.', params: [ { type: String, - desc: 'Phrase' + desc: 'Recovery phrase.', + example: 'stylus outing overhand dime radial seducing harmless uselessly evasive tastiness eradicate imperfect' }, { type: String, - desc: 'Password' + desc: 'Password.', + example: 'hunter2' } ], returns: { type: Address, - desc: 'The created address' + desc: 'The created address.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' } }, newAccountFromSecret: { - desc: 'Creates a new account from a private ethstore secret key', + subdoc: 'accounts', + desc: 'Creates a new account from a private ethstore secret key.', params: [ { type: Data, - desc: 'Secret, 32-byte hex' + desc: 'Secret, 32-byte hex', + example: '0x1db2c0cf57505d0f4a3d589414f0a0025ca97421d2cd596a9486bc7e2cd2bf8b' }, { type: String, - desc: 'Password' + desc: 'Password', + example: 'hunter2' } ], returns: { type: Address, - desc: 'The created address' + desc: 'The created address.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' } }, newAccountFromWallet: { + subdoc: 'accounts', desc: 'Creates a new account from a JSON import', params: [ { @@ -455,318 +873,521 @@ export default { } }, - nextNonce: { - desc: 'Returns next available nonce for transaction from given account. Includes pending block and transaction queue.', - params: [ - { - type: Address, - desc: 'Account' - } - ], - returns: { - type: Quantity, - desc: 'Next valid nonce' - } - }, - - nodeName: { - desc: 'Returns node name (identity)', - params: [], - returns: { - type: String, - desc: 'Node name' - } - }, - - pendingTransactions: { - desc: 'Returns a list of transactions currently in the queue.', - params: [], - returns: { - type: Array, - desc: 'Transactions ordered by priority' - } - }, - - pendingTransactionsStats: { - desc: 'Returns propagation stats for transactions in the queue', - params: [], - returns: { - type: Object, - desc: 'mapping of `tx hash` into `stats`' - } - }, - - phraseToAddress: { - desc: 'Converts a secret phrase into the corresponting address', - params: [ - { - type: String, - desc: 'The secret' - } - ], - returns: { - type: Address, - desc: 'Corresponding address' - } - }, - - postTransaction: { - desc: 'Posts a transaction to the Signer.', - params: [ - { - type: Object, - desc: 'see [eth_sendTransaction](#eth_sendTransaction)', - format: 'inputCallFormatter' - } - ], - returns: { - type: Quantity, - desc: 'The id of the actual transaction', - format: 'utils.toDecimal' - } - }, - - releasesInfo: { - desc: 'returns a ReleasesInfo object describing the current status of releases', - params: [], - returns: { - type: Object, - desc: '"fork":N,"minor":null,"this_fork":MN,"track":R} (N is a block number representing the latest known fork of this chain which may be in the future, MN is a block number representing the latest known fork that the currently running binary can sync past or null if not known, R is a ReleaseInfo object describing the latest release in this release track)' - } - }, - - removeReservedPeer: { - desc: '?', - params: [ - { - type: String, - desc: 'Encode' - } - ], - returns: { - type: Boolean, - desc: '?' - } - }, - - registryAddress: { - desc: 'The address for the global registry', - params: [], - returns: { - type: Address, - desc: 'The registry address' - } - }, - - rpcSettings: { - desc: 'Returns basic settings of rpc (enabled, port, interface).', - params: [], - returns: { - type: Object, - desc: 'JSON object containing rpc settings' - } - }, - setAccountName: { + subdoc: 'accounts', desc: 'Sets a name for the account', params: [ { type: Address, - desc: 'Address' + desc: 'Address', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' }, { type: String, - desc: 'Name' + desc: 'Name', + example: 'Foobar' } ], returns: { - type: Object, - desc: 'Returns null in all cases' + type: Boolean, + desc: '`true` if the call was successful.', + example: true } }, setAccountMeta: { + subdoc: 'accounts', desc: 'Sets metadata for the account', params: [ { type: Address, - desc: 'Address' + desc: 'Address', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' }, { type: String, - desc: 'Metadata (JSON encoded)' - } - ], - returns: { - type: Object, - desc: 'Returns null in all cases' - } - }, - - setAuthor: { - desc: 'Changes author (coinbase) for mined blocks.', - params: [ - { - type: Address, - desc: '20 Bytes - Address', - format: 'inputAddressFormatter' + desc: 'Metadata (JSON encoded)', + example: '{"foo":"bar"}' } ], returns: { type: Boolean, - desc: 'whether the call was successful' + desc: '`true` if the call was successful.', + example: true + } + }, + + testPassword: { + subdoc: 'accounts', + desc: 'Checks if a given password can unlock a given account, without actually unlocking it.', + params: [ + { + type: Address, + desc: 'Account to test.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + }, + { + type: String, + desc: 'Password to test.', + example: 'hunter2' + } + ], + returns: { + type: Boolean, + desc: '`true` if the account and password are valid.', + example: true + } + }, + + changePassword: { + subdoc: 'accounts', + desc: 'Change the password for a given account.', + params: [ + { + type: Address, + desc: 'Address of the account.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + }, + { + type: String, + desc: 'Old password.', + example: 'hunter2' + }, + { + type: String, + desc: 'New password.', + example: 'bazqux5' + } + ], + returns: { + type: Boolean, + desc: '`true` if the call was successful.', + example: true + } + }, + + killAccount: { + subdoc: 'accounts', + desc: 'Deletes an account.', + params: [ + { + type: Address, + desc: 'The account to remove.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + }, + { + type: String, + desc: 'Account password.', + example: 'hunter2' + } + ], + returns: { + type: Boolean, + desc: '`true` if the call was successful.', + example: true + } + }, + + removeAddress: { + subdoc: 'accounts', + desc: 'Removes an address from the addressbook.', + params: [ + { + type: Address, + desc: 'The address to remove.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + } + ], + returns: { + type: Boolean, + desc: '`true`if the call was successful.', + example: true } }, setDappsAddresses: { - desc: 'Sets the available addresses for a dapp', + subdoc: 'accounts', + desc: 'Sets the available addresses for a dapp.', params: [ { type: String, - desc: 'Dapp Id' + desc: 'Dapp Id.', + example: 'web' }, { type: Array, - desc: 'Array of available accounts available to the dapp' + desc: 'Array of available accounts available to the dapp.', + example: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'] } ], returns: { type: Boolean, - desc: 'True if the call succeeded' + desc: '`true` if the call was successful.', + example: true } }, - setExtraData: { - desc: 'Changes extra data for newly mined blocks', + getDappsAddresses: { + subdoc: 'accounts', + desc: 'Returns the list of accounts available to a specific dapp.', params: [ { - type: Data, - desc: 'Extra Data', - format: 'utils.toHex' + type: String, + desc: 'Dapp Id.', + example: 'web' } ], returns: { - type: Boolean, - desc: 'whether the call was successful' + type: Array, + desc: 'The list of available accounts.', + example: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'] } }, - setGasFloorTarget: { - desc: 'Changes current gas floor target.', + setNewDappsWhitelist: { + subdoc: 'accounts', + desc: 'Sets the list of accounts available to new dapps.', params: [ { - type: Quantity, - desc: 'Gas Floor Target', - format: 'utils.toHex' + type: Array, + desc: 'List of accounts available by default.', + example: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'] } ], returns: { type: Boolean, - desc: 'whether the call was successful' + desc: '`true` if the call was successful', + example: true } }, + getNewDappsWhitelist: { + subdoc: 'accounts', + desc: 'Returns the list of accounts available to a new dapps.', + params: [], + returns: { + type: Array, + desc: 'The list of available accounts, can be `null`.', + example: ['0x407d73d8a49eeb85d32cf465507dd71d507100c1'] + } + }, + + listRecentDapps: { + subdoc: 'accounts', + desc: 'Returns a list of the most recent active dapps.', + params: [], + returns: { + type: Array, + desc: 'Array of Dapp Ids.', + example: ['web'] + } + }, + + importGethAccounts: { + subdoc: 'accounts', + desc: 'Imports a list of accounts from Geth.', + params: [ + { + type: Array, + desc: 'List of the Geth addresses to import.' + } + ], + returns: { + type: Array, + desc: 'Array of the imported addresses.' + } + }, + + listGethAccounts: { + subdoc: 'accounts', + desc: 'Returns a list of the accounts available from Geth.', + params: [], + returns: { + type: Array, + desc: '20 Bytes addresses owned by the client.' + } + }, + + /* + * `parity_set` module methods + * =========================== + */ setMinGasPrice: { + subdoc: 'set', desc: 'Changes minimal gas price for transaction to be accepted to the queue.', params: [ { type: Quantity, desc: 'Minimal gas price', - format: 'utils.toHex' + format: 'utils.toHex', + example: fromDecimal(1000) } ], returns: { type: Boolean, - desc: 'whether the call was successful' + desc: 'whether the call was successful', + example: true } }, - setMode: { - desc: 'Changes the mode', + setGasFloorTarget: { + subdoc: 'set', + desc: 'Sets a new gas floor target for mined blocks..', params: [ { - type: String, - desc: 'The mode to set, one of "active", "passive", "dark", "offline"' + type: Quantity, + desc: '(default: `0x0`) Gas floor target.', + format: 'utils.toHex', + example: fromDecimal(1000) } ], returns: { type: Boolean, - desc: 'True if the call succeeded' + desc: '`true` if the call was successful.', + example: true } }, - setNewDappsWhitelist: { - desc: 'Sets the list of accounts available to new dapps', + setGasCeilTarget: { + subdoc: 'set', + desc: 'Sets new gas ceiling target for mined blocks.', params: [ { - type: Array, - desc: 'List of accounts available by default' + type: Quantity, + desc: '(default: `0x0`) Gas ceiling target.', + format: 'utils.toHex', + example: fromDecimal(10000000000) } ], returns: { type: Boolean, - desc: 'True if the call succeeded' + desc: '`true` if the call was successful.', + example: true + } + }, + + setExtraData: { + subdoc: 'set', + desc: 'Changes extra data for newly mined blocks', + params: [ + { + type: Data, + desc: 'Extra Data', + format: 'utils.toHex', + example: '0x' + } + ], + returns: { + type: Boolean, + desc: 'whether the call was successful', + example: true + } + }, + + setAuthor: { + subdoc: 'set', + desc: 'Changes author (coinbase) for mined blocks.', + params: [ + { + type: Address, + desc: '20 Bytes - Address', + format: 'inputAddressFormatter', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + } + ], + returns: { + type: Boolean, + desc: '`true` if the call was successful.', + example: true + } + }, + + setMaxTransactionGas: { + subdoc: 'set', + desc: 'Sets the maximum amount of gas a single transaction may consume.', + params: [ + { + type: Quantity, + desc: 'Gas amount', + format: 'utils.toHex', + example: fromDecimal(100000) + } + ], + returns: { + type: Boolean, + desc: '`true` if the call was successful.', + example: true } }, setTransactionsLimit: { + subdoc: 'set', desc: 'Changes limit for transactions in queue.', params: [ { type: Quantity, desc: 'New Limit', - format: 'utils.toHex' + format: 'utils.toHex', + example: fromDecimal(1000) } ], returns: { type: Boolean, - desc: 'whether the call was successful' + desc: 'whether the call was successful', + example: true } }, - signerPort: { - desc: 'Returns the port the signer is running on, error if not enabled', - params: [], + addReservedPeer: { + subdoc: 'set', + desc: 'Add a reserved peer.', + params: [ + { + type: String, + desc: 'Enode address', + example: 'enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770' + } + ], returns: { - type: Quantity, - desc: 'The port number' + type: Boolean, + desc: '`true` if successful.', + example: true } }, - transactionsLimit: { - desc: 'Changes limit for transactions in queue.', - params: [], + removeReservedPeer: { + subdoc: 'set', + desc: 'Remove a reserved peer.', + params: [ + { + type: String, + desc: 'Encode address', + example: 'enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770' + } + ], returns: { - type: Quantity, - desc: 'Current max number of transactions in queue', - format: 'outputBigNumberFormatter' + type: Boolean, + desc: '`true` if successful.', + example: true } }, - unsignedTransactionsCount: { - desc: 'Returns number of unsigned transactions when running with Trusted Signer. Error otherwise', + dropNonReservedPeers: { + subdoc: 'set', + desc: 'Set Parity to drop all non-reserved peers. To restore default behavior call [parity_acceptNonReservedPeers](#parity_acceptnonreservedpeers).', params: [], returns: { - type: Quantity, - desc: 'Number of unsigned transactions' + type: Boolean, + desc: '`true` if successful.', + example: true + } + }, + + acceptNonReservedPeers: { + subdoc: 'set', + desc: 'Set Parity to accept non-reserved peers (default behavior).', + params: [], + returns: { + type: Boolean, + desc: '`true` if successful.', + example: true + } + }, + + hashContent: { + subdoc: 'set', + desc: 'Creates a hash of a file at a given URL.', + params: [ + { + type: String, + desc: 'The url of the content.', + example: 'https://raw.githubusercontent.com/ethcore/parity/master/README.md' + } + ], + returns: { + type: Hash, + desc: 'The SHA-3 hash of the content.', + example: '0x2547ea3382099c7c76d33dd468063b32d41016aacb02cbd51ebc14ff5d2b6a43' + } + }, + + setMode: { + subdoc: 'set', + desc: 'Changes the operating mode of Parity.', + params: [ + { + type: String, + desc: 'The mode to set, one of:\n * `"active"` - Parity continuously syncs the chain.\n * `"passive"` - Parity syncs initially, then sleeps and wakes regularly to resync.\n * `"dark"` - Parity syncs only when the RPC is active.\n * `"offline"` - Parity doesn\'t sync.\n', + example: 'passive' + } + ], + returns: { + type: Boolean, + desc: '`true` if the call succeeded.', + example: true + } + }, + + setEngineSigner: { + subdoc: 'set', + desc: 'Sets an authority account for signing consensus messages. For more information check the [[Proof of Authority Chains]] page.', + params: [ + { + type: Address, + desc: 'Identifier of a valid authority account.', + example: '0x407d73d8a49eeb85d32cf465507dd71d507100c1' + }, + { + type: String, + desc: 'Passphrase to unlock the account.', + example: 'hunter2' + } + ], + returns: { + type: Boolean, + desc: 'True if the call succeeded', + example: true } }, upgradeReady: { - desc: 'returns a ReleaseInfo object describing the release which is available for upgrade or null if none is available', + subdoc: 'set', + desc: 'Returns a ReleaseInfo object describing the release which is available for upgrade or `null` if none is available.', params: [], returns: { type: Object, - desc: '{"binary":H,"fork":15100,"is_critical":true,"version":V} where H is the Keccak-256 checksum of the release parity binary and V is a VersionInfo object describing the release' + desc: 'Details or `null` if no new release is available.', + details: { + version: { + type: Object, + desc: 'Information on the version.' + }, + is_critical: { + type: Boolean, + desc: 'Does this release contain critical security updates?' + }, + fork: { + type: Quantity, + desc: 'The latest fork that this release can handle.' + }, + binary: { + type: Data, + desc: 'Keccak-256 checksum of the release parity binary, if known.', + optional: true + } + }, + example: null } }, - versionInfo: { - desc: 'returns a VersionInfo object describing our current version', + executeUpgrade: { + subdoc: 'set', + desc: 'Attempts to upgrade Parity to the version specified in [parity_upgradeReady](#parity_upgradeready).', params: [], returns: { - type: Object, - desc: '{"hash":H,"track":T,"version":{"major":N,"minor":N,"patch":N}} (H is a 160-bit Git commit hash, T is a ReleaseTrack, either "stable", "beta", "nightly" or "unknown" and N is a version number)' + type: Boolean, + desc: 'returns `true` if the upgrade to the new release was successfully executed, `false` if not.', + example: true } } }; diff --git a/js/src/jsonrpc/interfaces/personal.js b/js/src/jsonrpc/interfaces/personal.js index 945057084..6833febcf 100644 --- a/js/src/jsonrpc/interfaces/personal.js +++ b/js/src/jsonrpc/interfaces/personal.js @@ -18,30 +18,36 @@ import { Address, Data, Quantity } from '../types'; export default { listAccounts: { - desc: 'Returns a list of addresses owned by client.', + desc: 'Lists all stored accounts.', params: [], returns: { type: Array, - desc: '20 Bytes addresses owned by the client.' + desc: 'A list of 20 byte account identifiers.', + example: [ + '0x7bf87721a96849d168de02fd6ea5986a3a147383', + '0xca807a90fd64deed760fb98bf0869b475c469348' + ] } }, newAccount: { - desc: 'Creates new account', + desc: 'Creates new account.\n\n**Note:** it becomes the new current unlocked account. There can only be one unlocked account at a time.', params: [ { type: String, - desc: 'Password' + desc: 'Password for the new account.', + example: 'hunter2' } ], returns: { type: Address, - desc: 'The created address' + desc: '20 Bytes - The identifier of the new account.', + example: '0x8f0227d45853a50eefd48dd4fec25d5b3fd2295e' } }, signAndSendTransaction: { - desc: 'Sends and signs a transaction given account passphrase. Does not require the account to be unlocked nor unlocks the account for future transactions. ', + desc: 'Sends transaction and signs it in a single call. The account does not need to be unlocked to make this call, and will not be left unlocked after.', params: [ { type: Object, @@ -49,59 +55,83 @@ export default { details: { from: { type: Address, - desc: '20 Bytes - The address the transaction is send from' + desc: '20 Bytes - The address of the account to unlock and send the transaction from.' }, to: { type: Address, - desc: '20 Bytes - (optional when creating new contract) The address the transaction is directed to' + desc: '20 Bytes - (optional when creating new contract) The address the transaction is directed to.' }, gas: { type: Quantity, - desc: 'Integer of the gas provided for the transaction execution. It will return unused gas', + desc: 'Integer of the gas provided for the transaction execution. It will return unused gas.', optional: true, default: 90000 }, gasPrice: { type: Quantity, - desc: 'Integer of the gasPrice used for each paid gas', + desc: 'Integer of the gasPrice used for each paid gas.', optional: true, default: 'To-Be-Determined' }, value: { type: Quantity, - desc: 'Integer of the value send with this transaction', + desc: 'Integer of the value send with this transaction.', optional: true }, data: { type: Data, - desc: 'The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI)' + desc: 'The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see [Ethereum Contract ABI](https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI).' }, nonce: { type: Quantity, desc: 'Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.', optional: true } + }, + example: { + from: '0x407d73d8a49eeb85d32cf465507dd71d507100c1', + to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b', + data: '0x41cd5add4fd13aedd64521e363ea279923575ff39718065d38bd46f0e6632e8e', + value: '0x186a0' } }, { type: String, - desc: 'Passphrase to unlock `from` account.' + desc: 'Passphrase to unlock the `from` account.', + example: 'hunter2' } ], returns: { type: Data, - desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available' + desc: '32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available', + example: '0x62e05075829655752e146a129a044ad72e95ce33e48ff48118b697e15e7b41e4' } }, unlockAccount: { - desc: '?', + desc: 'Unlocks specified account for use.\n\nIf permanent unlocking is disabled (the default) then the duration argument will be ignored, and the account will be unlocked for a single signing. With permanent locking enabled, the duration sets the number of seconds to hold the account open for. It will default to 300 seconds. Passing 0 unlocks the account indefinitely.\n\nThere can only be one unlocked account at a time.', params: [ - '?', '?', '?' + { + type: Address, + desc: '20 Bytes - The address of the account to unlock.', + example: '0x8f0227d45853a50eefd48dd4fec25d5b3fd2295e' + }, + { + type: String, + desc: 'Passphrase to unlock the account.', + example: 'hunter2' + }, + { + type: Quantity, + default: 300, + desc: 'Integer or `null` - Duration in seconds how long the account should remain unlocked for.', + example: null + } ], returns: { type: Boolean, - desc: 'whether the call was successful' + desc: 'whether the call was successful', + example: true } } }; diff --git a/js/src/jsonrpc/interfaces/shh.js b/js/src/jsonrpc/interfaces/shh.js index b8d6ecfd1..c78c6bc5c 100644 --- a/js/src/jsonrpc/interfaces/shh.js +++ b/js/src/jsonrpc/interfaces/shh.js @@ -41,7 +41,7 @@ export default { optional: true }, topics: { - type: Array, desc: 'Array of `DATA` topics, for the receiver to identify messages' + type: Array, desc: 'Array of `Data` topics, for the receiver to identify messages' }, payload: { type: Data, desc: 'The payload of the message' @@ -117,7 +117,7 @@ export default { optional: true }, topics: { - type: Array, desc: 'Array of `DATA` topics which the incoming message\'s topics should match. You can use the following combinations' + type: Array, desc: 'Array of `Data` topics which the incoming message\'s topics should match. You can use the following combinations' } } } diff --git a/js/src/jsonrpc/interfaces/signer.js b/js/src/jsonrpc/interfaces/signer.js index 2e0559898..25819428b 100644 --- a/js/src/jsonrpc/interfaces/signer.js +++ b/js/src/jsonrpc/interfaces/signer.js @@ -14,33 +14,38 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . -import { Quantity, Data } from '../types'; +import { Quantity, Data, BlockNumber } from '../types'; +import { fromDecimal } from '../helpers'; export default { generateAuthorizationToken: { - desc: 'Generates a new authorization token', + desc: 'Generates a new authorization token.', params: [], returns: { type: String, - desc: 'The new authorization token' + desc: 'The new authorization token.', + example: 'bNGY-iIPB-j7zK-RSYZ' } }, generateWebProxyAccessToken: { - desc: 'Generates a new web proxy access token', + desc: 'Generates a new web proxy access token.', params: [], returns: { type: String, - desc: 'The new web proxy access token' + desc: 'The new web proxy access token.', + example: 'MOWm0tEJjwthDiTU' } }, requestsToConfirm: { - desc: 'Returns a list of the transactions requiring authorization', + desc: 'Returns a list of the transactions awaiting authorization.', params: [], returns: { + // TODO: Types of the fields of transaction objects? Link to a transaction object in another page? type: Array, - desc: 'A list of the outstanding transactions' + desc: 'A list of the outstanding transactions.', + example: [] } }, @@ -49,20 +54,41 @@ export default { params: [ { type: Quantity, - desc: 'The request id' + desc: 'The request id.', + example: fromDecimal(1) }, { type: Object, - desc: 'The request options' + desc: 'Modify the transaction before confirmation.', + details: { + gasPrice: { + type: Quantity, + desc: 'Modify the gas price provided by the sender in Wei.', + optional: true + }, + gas: { + type: Quantity, + desc: 'Gas provided by the sender in Wei.', + optional: true + }, + minBlock: { + type: BlockNumber, + desc: 'Integer block number, or the string `\'latest\'`, `\'earliest\'` or `\'pending\'`. Request will not be propagated till the given block is reached.', + optional: true + } + }, + example: {} }, { type: String, - desc: 'The account password' + desc: 'The account password', + example: 'hunter2' } ], returns: { type: Boolean, - desc: 'The status of the confirmation' + desc: 'The status of the confirmation', + example: true } }, @@ -71,16 +97,19 @@ export default { params: [ { type: Quantity, - desc: 'The request id' + desc: 'Integer - The request id', + example: fromDecimal(1) }, { type: Data, - desc: 'Signed request (transaction RLP)' + desc: 'Signed request (RLP encoded transaction)', + example: '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675' } ], returns: { type: Boolean, - desc: 'The status of the confirmation' + desc: 'The status of the confirmation', + example: true } }, @@ -89,12 +118,14 @@ export default { params: [ { type: Quantity, - desc: 'The request id' + desc: 'Integer - The request id', + example: fromDecimal(1) } ], returns: { type: Boolean, - desc: 'The status of the rejection' + desc: 'The status of the rejection', + example: true } }, @@ -103,7 +134,8 @@ export default { params: [], returns: { type: Boolean, - desc: 'true when enabled, false when disabled' + desc: '`true` when enabled, `false` when disabled.', + example: true } } }; diff --git a/js/src/jsonrpc/interfaces/web3.js b/js/src/jsonrpc/interfaces/web3.js index af35ee218..4869832a5 100644 --- a/js/src/jsonrpc/interfaces/web3.js +++ b/js/src/jsonrpc/interfaces/web3.js @@ -15,6 +15,7 @@ // along with Parity. If not, see . import { Data } from '../types'; +import { withComment } from '../helpers'; export default { clientVersion: { @@ -22,21 +23,24 @@ export default { params: [], returns: { type: String, - desc: 'The current client version' + desc: 'The current client version', + example: 'Parity//v1.5.0-unstable-9db3f38-20170103/x86_64-linux-gnu/rustc1.14.0' } }, sha3: { - desc: 'Returns Keccak-256 (*not* the standardized SHA3-256) of the given data.', + desc: 'Returns Keccak-256 (**not** the standardized SHA3-256) of the given data.', params: [ { type: String, - desc: 'The data to convert into a SHA3 hash' + desc: 'The data to convert into a SHA3 hash.', + example: withComment('0x68656c6c6f20776f726c64', '"hello world"') } ], returns: { type: Data, - desc: 'The SHA3 result of the given string' + desc: 'The Keccak-256 hash of the given string.', + example: '0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad' } } };