From ceb0739ba111215d47cc2ff9d80d542fa26d764a Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Mon, 6 Jul 2015 13:08:08 +0200 Subject: [PATCH] fixed web3 formatters mismatch --- rpc/api/admin_js.go | 39 ++++++++-------------- rpc/api/db_js.go | 28 ---------------- rpc/api/debug_js.go | 23 +++++-------- rpc/api/eth_js.go | 9 ++---- rpc/api/miner_js.go | 21 ++++-------- rpc/api/net_js.go | 28 +++------------- rpc/api/personal_js.go | 10 +++--- rpc/api/ssh_js.go | 16 ++------- rpc/api/utils.go | 73 ++++++++++++++++++------------------------ 9 files changed, 73 insertions(+), 174 deletions(-) diff --git a/rpc/api/admin_js.go b/rpc/api/admin_js.go index 40c029fd1..e528b8863 100644 --- a/rpc/api/admin_js.go +++ b/rpc/api/admin_js.go @@ -9,22 +9,19 @@ web3._extend({ name: 'addPeer', call: 'admin_addPeer', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null] }), new web3._extend.Method({ name: 'exportChain', call: 'admin_exportChain', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: function(obj) { return obj; } + inputFormatter: [null] }), new web3._extend.Method({ name: 'importChain', call: 'admin_importChain', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: function(obj) { return obj; } + inputFormatter: [null] }), new web3._extend.Method({ name: 'sleepBlocks', @@ -37,22 +34,19 @@ web3._extend({ name: 'verbosity', call: 'admin_verbosity', params: 1, - inputFormatter: [web3._extend.utils.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [web3._extend.utils.toDecimal] }), new web3._extend.Method({ name: 'setSolc', call: 'admin_setSolc', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null] }), new web3._extend.Method({ name: 'startRPC', call: 'admin_startRPC', params: 4, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputInteger,web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null, web3._extend.utils.toDecimal, null, null] }), new web3._extend.Method({ name: 'stopRPC', @@ -114,22 +108,19 @@ web3._extend({ name: 'stopNatSpec', call: 'admin_stopNatSpec', params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [] }), new web3._extend.Method({ name: 'getContractInfo', call: 'admin_getContractInfo', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: function(obj) { return json.parse(obj); } + inputFormatter: [null], }), new web3._extend.Method({ name: 'httpGet', call: 'admin_httpGet', params: 2, - inputFormatter: [web3._extend.utils.formatInputString,web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null, null] }) ], @@ -137,23 +128,19 @@ web3._extend({ [ new web3._extend.Property({ name: 'nodeInfo', - getter: 'admin_nodeInfo', - outputFormatter: web3._extend.formatters.formatOutputString + getter: 'admin_nodeInfo' }), new web3._extend.Property({ name: 'peers', - getter: 'admin_peers', - outputFormatter: function(obj) { return obj; } + getter: 'admin_peers' }), new web3._extend.Property({ name: 'datadir', - getter: 'admin_datadir', - outputFormatter: web3._extend.formatters.formatOutputString + getter: 'admin_datadir' }), new web3._extend.Property({ name: 'chainSyncStatus', - getter: 'admin_chainSyncStatus', - outputFormatter: function(obj) { return obj; } + getter: 'admin_chainSyncStatus' }) ] }); diff --git a/rpc/api/db_js.go b/rpc/api/db_js.go index 62cdcd20e..91dc95e5b 100644 --- a/rpc/api/db_js.go +++ b/rpc/api/db_js.go @@ -5,34 +5,6 @@ web3._extend({ property: 'db', methods: [ - new web3._extend.Method({ - name: 'getString', - call: 'db_getString', - params: 2, - inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString - }), - new web3._extend.Method({ - name: 'putString', - call: 'db_putString', - params: 3, - inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool - }), - new web3._extend.Method({ - name: 'getHex', - call: 'db_getHex', - params: 2, - inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString - }), - new web3._extend.Method({ - name: 'putHex', - call: 'db_putHex', - params: 3, - inputFormatter: [web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString, web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool - }), ], properties: [ diff --git a/rpc/api/debug_js.go b/rpc/api/debug_js.go index bd3a6dfb2..93fba537e 100644 --- a/rpc/api/debug_js.go +++ b/rpc/api/debug_js.go @@ -9,50 +9,43 @@ web3._extend({ name: 'printBlock', call: 'debug_printBlock', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] }), new web3._extend.Method({ name: 'getBlockRlp', call: 'debug_getBlockRlp', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] }), new web3._extend.Method({ name: 'setHead', call: 'debug_setHead', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] }), new web3._extend.Method({ name: 'processBlock', call: 'debug_processBlock', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: function(obj) { return obj; } + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] }), new web3._extend.Method({ name: 'seedHash', call: 'debug_seedHash', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputString - }) , + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] + }), new web3._extend.Method({ name: 'dumpBlock', call: 'debug_dumpBlock', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: function(obj) { return obj; } + inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter] }), new web3._extend.Method({ name: 'metrics', call: 'debug_metrics', params: 1, - inputFormatter: [web3._extend.formatters.formatInputBool], - outputFormatter: function(obj) { return obj; } + inputFormatter: [null] }) ], properties: diff --git a/rpc/api/eth_js.go b/rpc/api/eth_js.go index 4512cc147..4c3e9e4db 100644 --- a/rpc/api/eth_js.go +++ b/rpc/api/eth_js.go @@ -12,23 +12,20 @@ web3._extend({ name: 'sign', call: 'eth_sign', params: 2, - inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [web3._extend.utils.toAddress, null] }), new web3._extend.Method({ name: 'resend', call: 'eth_resend', params: 3, - inputFormatter: [function(obj) { return obj; },web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null, null, null] }) ], properties: [ new web3._extend.Property({ name: 'pendingTransactions', - getter: 'eth_pendingTransactions', - outputFormatter: function(obj) { return obj; } + getter: 'eth_pendingTransactions' }) ] }); diff --git a/rpc/api/miner_js.go b/rpc/api/miner_js.go index 6290368da..6474166e7 100644 --- a/rpc/api/miner_js.go +++ b/rpc/api/miner_js.go @@ -9,50 +9,43 @@ web3._extend({ name: 'start', call: 'miner_start', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null] }), new web3._extend.Method({ name: 'stop', call: 'miner_stop', params: 1, - inputFormatter: [web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null] }), new web3._extend.Method({ name: 'setExtra', call: 'miner_setExtra', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null] }), new web3._extend.Method({ name: 'setGasPrice', call: 'miner_setGasPrice', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null] }), new web3._extend.Method({ name: 'startAutoDAG', call: 'miner_startAutoDAG', params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [] }), new web3._extend.Method({ name: 'stopAutoDAG', call: 'miner_stopAutoDAG', params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [] }), new web3._extend.Method({ name: 'makeDAG', call: 'miner_makeDAG', params: 1, - inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [web3._extend.formatters.inputDefaultBlockNumberFormatter] }) ], properties: diff --git a/rpc/api/net_js.go b/rpc/api/net_js.go index 1677d9fa6..cc8d7f46e 100644 --- a/rpc/api/net_js.go +++ b/rpc/api/net_js.go @@ -2,45 +2,25 @@ package api const Net_JS = ` web3._extend({ - property: 'network', + property: 'net', methods: [ new web3._extend.Method({ name: 'addPeer', call: 'net_addPeer', params: 1, - inputFormatter: [web3._extend.utils.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputBool - }), - new web3._extend.Method({ - name: 'getPeerCount', - call: 'net_peerCount', - params: 0, - inputFormatter: [], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null] }) ], properties: [ - new web3._extend.Property({ - name: 'listening', - getter: 'net_listening', - outputFormatter: web3._extend.formatters.formatOutputBool - }), - new web3._extend.Property({ - name: 'peerCount', - getter: 'net_peerCount', - outputFormatter: web3._extend.utils.toDecimal - }), new web3._extend.Property({ name: 'peers', - getter: 'net_peers', - outputFormatter: function(obj) { return obj; } + getter: 'net_peers' }), new web3._extend.Property({ name: 'version', - getter: 'net_version', - outputFormatter: web3._extend.formatters.formatOutputString + getter: 'net_version' }) ] }); diff --git a/rpc/api/personal_js.go b/rpc/api/personal_js.go index 463a2c7f5..66014cc02 100644 --- a/rpc/api/personal_js.go +++ b/rpc/api/personal_js.go @@ -9,23 +9,21 @@ web3._extend({ name: 'newAccount', call: 'personal_newAccount', params: 1, - inputFormatter: [web3._extend.formatters.formatInputString], - outputFormatter: web3._extend.formatters.formatOutputString + inputFormatter: [null], + outputFormatter: web3._extend.utils.toAddress }), new web3._extend.Method({ name: 'unlockAccount', call: 'personal_unlockAccount', params: 3, - inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool + inputFormatter: [null, null, null] }) ], properties: [ new web3._extend.Property({ name: 'listAccounts', - getter: 'personal_listAccounts', - outputFormatter: function(obj) { return obj; } + getter: 'personal_listAccounts' }) ] }); diff --git a/rpc/api/ssh_js.go b/rpc/api/ssh_js.go index f401f70f1..c0591bd71 100644 --- a/rpc/api/ssh_js.go +++ b/rpc/api/ssh_js.go @@ -5,25 +5,13 @@ web3._extend({ property: 'shh', methods: [ - new web3._extend.Method({ - name: 'post', - call: 'shh_post', - params: 6, - inputFormatter: [web3._extend.formatters.formatInputString, - web3._extend.formatters.formatInputString, - web3._extend.formatters.formatInputString, - , - , web3._extend.formatters.formatInputInt - , web3._extend.formatters.formatInputInt], - outputFormatter: web3._extend.formatters.formatOutputBool - }), + ], properties: [ new web3._extend.Property({ name: 'version', - getter: 'shh_version', - outputFormatter: web3._extend.formatters.formatOutputInt + getter: 'shh_version' }) ] }); diff --git a/rpc/api/utils.go b/rpc/api/utils.go index 54ca28774..a96d105fb 100644 --- a/rpc/api/utils.go +++ b/rpc/api/utils.go @@ -36,6 +36,7 @@ var ( "debug": []string{ "dumpBlock", "getBlockRlp", + "metrics", "printBlock", "processBlock", "seedHash", @@ -44,49 +45,38 @@ var ( "eth": []string{ "accounts", "blockNumber", - "getBalance", - "protocolVersion", + "call", + "contract", "coinbase", - "mining", + "compile.lll", + "compile.serpent", + "compile.solidity", + "contract", + "defaultAccount", + "defaultBlock", + "estimateGas", + "filter", + "getBalance", + "getBlock", + "getBlockTransactionCount", + "getBlockUncleCount", + "getCode", + "getCompilers", "gasPrice", - "getStorage", - "storageAt", "getStorageAt", + "getTransaction", "getTransactionCount", - "getBlockTransactionCountByHash", - "getBlockTransactionCountByNumber", - "getUncleCountByBlockHash", - "getUncleCountByBlockNumber", - "getData", - "getCode", - "sign", - "sendRawTransaction", - "sendTransaction", - "transact", - "estimateGas", - "call", - "flush", - "getBlockByHash", - "getBlockByNumber", - "getTransactionByHash", - "getTransactionByBlockHashAndIndex", - "getUncleByBlockHashAndIndex", - "getUncleByBlockNumberAndIndex", - "getCompilers", - "compileSolidity", - "newFilter", - "newBlockFilter", - "newPendingTransactionFilter", - "uninstallFilter", - "getFilterChanges", - "getFilterLogs", - "getLogs", + "getTransactionFromBlock", + "getTransactionReceipt", + "getUncle", "hashrate", - "getWork", - "submitWork", + "mining", + "namereg", "pendingTransactions", "resend", - "getTransactionReceipt", + "sendRawTransaction", + "sendTransaction", + "sign", }, "miner": []string{ "hashrate", @@ -101,6 +91,8 @@ var ( "net": []string{ "peerCount", "listening", + "version", + "peers", }, "personal": []string{ "listAccounts", @@ -109,13 +101,12 @@ var ( "unlockAccount", }, "shh": []string{ - "version", "post", + "newIdentify", "hasIdentity", - "newIdentity", - "newFilter", - "uninstallFilter", - "getFilterChanges", + "newGroup", + "addToGroup", + "filter", }, "txpool": []string{ "status",