Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions lib/rpc/eth.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fromAddress, fromNumber } from '../util/format';
import { toAddress, toBlockNumber, toHex, toNumber } from '../util/format'; // eslint-disable-line no-duplicate-imports
import { inAddress, inBlockNumber, inData, inHex, inNumber, outAddress, outNumber } from '../util/format';

export default class Eth {
constructor (transport) {
Expand All @@ -9,45 +8,45 @@ export default class Eth {
accounts () {
return this._transport
.execute('eth_accounts')
.then((accounts) => (accounts || []).map(fromAddress));
.then((accounts) => (accounts || []).map(outAddress));
}

blockNumber () {
return this._transport
.execute('eth_blockNumber')
.then(fromNumber);
.then(outNumber);
}

call (options, blockNumber = 'latest') {
return this._transport
.execute('eth_call', options, toBlockNumber(blockNumber));
.execute('eth_call', options, inBlockNumber(blockNumber));
}

coinbase () {
return this._transport
.execute('eth_coinbase')
.then(fromAddress);
.then(outAddress);
}

compileLLL (code) {
return this._transport
.execute('eth_compileLLL', toHex(code));
.execute('eth_compileLLL', inData(code));
}

compileSerpent (code) {
return this._transport
.execute('eth_compileSerpent', toHex(code));
.execute('eth_compileSerpent', inData(code));
}

compileSolidity (code) {
return this._transport
.execute('eth_compileSolidity', toHex(code));
.execute('eth_compileSolidity', inData(code));
}

estimateGas (options) {
return this._transport
.execute('eth_estimateGas', options)
.then(fromNumber);
.then(outNumber);
}

fetchQueuedTransactions () {
Expand All @@ -63,38 +62,38 @@ export default class Eth {
gasPrice () {
return this._transport
.execute('eth_gasPrice')
.then(fromNumber);
.then(outNumber);
}

getBalance (address, blockNumber = 'latest') {
return this._transport
.execute('eth_getBalance', toAddress(address), toBlockNumber(blockNumber))
.then(fromNumber);
.execute('eth_getBalance', inAddress(address), inBlockNumber(blockNumber))
.then(outNumber);
}

getBlockByHash (hash, full = false) {
return this._transport
.execute('eth_getBlockByHash', toHex(hash), full);
.execute('eth_getBlockByHash', inHex(hash), full);
}

getBlockByNumber (blockNumber = 'latest', full = false) {
return this._transport
.execute('eth_getBlockByNumber', toBlockNumber(blockNumber), full);
.execute('eth_getBlockByNumber', inBlockNumber(blockNumber), full);
}

getBlockTransactionCountByHash (hash) {
return this._transport
.execute('eth_getBlockTransactionCountByHash', toHex(hash));
.execute('eth_getBlockTransactionCountByHash', inHex(hash));
}

getBlockTransactionCountByNumber (blockNumber = 'latest') {
return this._transport
.execute('eth_getBlockTransactionCountByNumber', toBlockNumber(blockNumber));
.execute('eth_getBlockTransactionCountByNumber', inBlockNumber(blockNumber));
}

getCode (address, blockNumber = 'latest') {
return this._transport
.execute('eth_getCode', toAddress(address), toBlockNumber(blockNumber));
.execute('eth_getCode', inAddress(address), inBlockNumber(blockNumber));
}

getCompilers () {
Expand All @@ -104,22 +103,22 @@ export default class Eth {

getFilterChanges (filterId) {
return this._transport
.execute('eth_getFilterChanges', toNumber(filterId));
.execute('eth_getFilterChanges', inNumber(filterId));
}

getFilterChangesEx (filterId) {
return this._transport
.execute('eth_getFilterChangesEx', toNumber(filterId));
.execute('eth_getFilterChangesEx', inNumber(filterId));
}

getFilterLogs (filterId) {
return this._transport
.execute('eth_getFilterLogs', toNumber(filterId));
.execute('eth_getFilterLogs', inNumber(filterId));
}

getFilterLogsEx (filterId) {
return this._transport
.execute('eth_getFilterLogsEx', toNumber(filterId));
.execute('eth_getFilterLogsEx', inNumber(filterId));
}

getLogs (options) {
Expand All @@ -134,52 +133,52 @@ export default class Eth {

getStorageAt (address, index = 0, blockNumber = 'latest') {
return this._transport
.execute('eth_getStorageAt', toAddress(address), toNumber(index), toBlockNumber(blockNumber));
.execute('eth_getStorageAt', inAddress(address), inNumber(index), inBlockNumber(blockNumber));
}

getTransactionByBlockHashAndIndex (hash, index = 0) {
return this._transport
.execute('eth_getTransactionByBlockHashAndIndex', toHex(hash), toNumber(index));
.execute('eth_getTransactionByBlockHashAndIndex', inHex(hash), inNumber(index));
}

getTransactionByBlockNumberAndIndex (blockNumber = 'latest', index = 0) {
return this._transport
.execute('eth_getTransactionByBlockNumberAndIndex', toBlockNumber(blockNumber), toNumber(index));
.execute('eth_getTransactionByBlockNumberAndIndex', inBlockNumber(blockNumber), inNumber(index));
}

getTransactionByHash (hash) {
return this._transport
.execute('eth_getTransactionByHash', toHex(hash));
.execute('eth_getTransactionByHash', inHex(hash));
}

getTransactionCount (address, blockNumber = 'latest') {
return this._transport
.execute('eth_getTransactionCount', toAddress(address), toBlockNumber(blockNumber));
.execute('eth_getTransactionCount', inAddress(address), inBlockNumber(blockNumber));
}

getTransactionReceipt (txhash) {
return this._transport
.execute('eth_getTransactionReceipt', toHex(txhash));
.execute('eth_getTransactionReceipt', inHex(txhash));
}

getUncleByBlockHashAndIndex (hash, index = 0) {
return this._transport
.execute('eth_getUncleByBlockHashAndIndex', toHex(hash), toNumber(index));
.execute('eth_getUncleByBlockHashAndIndex', inHex(hash), inNumber(index));
}

getUncleByBlockNumberAndIndex (blockNumber = 'latest', index = 0) {
return this._transport
.execute('eth_getUncleByBlockNumberAndIndex', toBlockNumber(blockNumber), toNumber(index));
.execute('eth_getUncleByBlockNumberAndIndex', inBlockNumber(blockNumber), inNumber(index));
}

getUncleCountByBlockHash (hash) {
return this._transport
.execute('eth_getUncleCountByBlockHash', toHex(hash));
.execute('eth_getUncleCountByBlockHash', inHex(hash));
}

getUncleCountByBlockNumber (blockNumber = 'latest') {
return this._transport
.execute('eth_getUncleCountByBlockNumber', toBlockNumber(blockNumber));
.execute('eth_getUncleCountByBlockNumber', inBlockNumber(blockNumber));
}

getWork () {
Expand All @@ -190,7 +189,7 @@ export default class Eth {
hashrate () {
return this._transport
.execute('eth_hashrate')
.then(toNumber);
.then(outNumber);
}

inspectTransaction () {
Expand Down Expand Up @@ -245,7 +244,7 @@ export default class Eth {

sendRawTransaction (data) {
return this._transport
.execute('eth_sendRawTransaction', toHex(data));
.execute('eth_sendRawTransaction', inData(data));
}

sendTransaction (options) {
Expand All @@ -254,7 +253,8 @@ export default class Eth {
}

sign () {
return this._transport.execute('eth_sign');
return this._transport
.execute('eth_sign');
}

signTransaction () {
Expand All @@ -264,7 +264,7 @@ export default class Eth {

submitHashrate (hashrate, clientId) {
return this._transport
.execute('eth_submitHashrate', fromNumber(hashrate), clientId);
.execute('eth_submitHashrate', inNumber(hashrate), clientId);
}

submitWork (nonce, powHash, mixDigest) {
Expand All @@ -279,7 +279,7 @@ export default class Eth {

uninstallFilter (filterId) {
return this._transport
.execute('eth_uninstallFilter', toHex(filterId));
.execute('eth_uninstallFilter', inHex(filterId));
}

unregister () {
Expand Down
44 changes: 30 additions & 14 deletions lib/rpc/ethcore.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
import { inAddress, inData, inNumber } from '../util/format';

export default class Ethcore {
constructor (transport) {
this._transport = transport;
}

extraData () {
return this._transport.execute('ethcore_extraData');
return this._transport
.execute('ethcore_extraData');
}

gasFloorTarget () {
return this._transport.execute('ethcore_gasFloorTarget');
return this._transport
.execute('ethcore_gasFloorTarget');
}

minGasPrice () {
return this._transport.execute('ethcore_minGasPrice');
return this._transport
.execute('ethcore_minGasPrice');
}

netChain () {
return this._transport.execute('ethcore_netChain');
return this._transport
.execute('ethcore_netChain');
}

netMaxPeers () {
return this._transport.execute('ethcore_netMaxPeers');
return this._transport
.execute('ethcore_netMaxPeers');
}

netPort () {
return this._transport.execute('ethcore_netPort');
return this._transport
.execute('ethcore_netPort');
}

nodeName () {
return this._transport.execute('ethcore_nodeName');
return this._transport
.execute('ethcore_nodeName');
}

setAuthor (address) {
return this._transport.execute('ethcore_setAuthor');
return this._transport
.execute('ethcore_setAuthor', inAddress(address));
}

setExtraData (data) {
return this._transport.execute('ethcore_setExtraData', data);
return this._transport
.execute('ethcore_setExtraData', inData(data));
}

setGasFloorTarget (quantity) {
return this._transport.execute('ethcore_setGasFloorTarget');
return this._transport
.execute('ethcore_setGasFloorTarget', inNumber(quantity));
}

setMinGasPrice (quantity) {
return this._transport.execute('ethcore_setMinGasPrice', quantity);
return this._transport
.execute('ethcore_setMinGasPrice', inNumber(quantity));
}

setTransactionsLimit (quantity) {
return this._transport.execute('ethcore_setTransactionsLimit', quantity);
return this._transport
.execute('ethcore_setTransactionsLimit', inNumber(quantity));
}

transactionsLimit () {
return this._transport.execute('ethcore_transactionsLimit');
return this._transport
.execute('ethcore_transactionsLimit');
}

rpcSettings () {
return this._transport.execute('ethcore_rpcSettings');
return this._transport
.execute('ethcore_rpcSettings');
}
}
9 changes: 6 additions & 3 deletions lib/rpc/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ export default class Net {
}

listening () {
return this._transport.execute('net_listening');
return this._transport
.execute('net_listening');
}

peerCount () {
return this._transport.execute('net_peerCount');
return this._transport
.execute('net_peerCount');
}

version () {
return this._transport.execute('net_version');
return this._transport
.execute('net_version');
}
}
9 changes: 4 additions & 5 deletions lib/rpc/personal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fromAddress } from '../util/format';
import { toAddress, toNumber } from '../util/format'; // eslint-disable-line no-duplicate-imports
import { inAddress, inNumber, outAddress } from '../util/format';

export default class Personal {
constructor (transport) {
Expand All @@ -9,13 +8,13 @@ export default class Personal {
listAccounts () {
return this._transport
.execute('personal_listAccounts')
.then((accounts) => (accounts || []).map(fromAddress));
.then((accounts) => (accounts || []).map(outAddress));
}

newAccount (password) {
return this._transport
.execute('personal_newAccount', password)
.then(fromAddress);
.then(outAddress);
}

signAndSendTransaction (txObject, password) {
Expand All @@ -25,6 +24,6 @@ export default class Personal {

unlockAccount (account, password, duration = 5) {
return this._transport
.execute('personal_unlockAccount', toAddress(account), password, toNumber(duration));
.execute('personal_unlockAccount', inAddress(account), password, inNumber(duration));
}
}
Loading