Pārlūkot izejas kodu

fixed web3 formatters mismatch

Bas van Kervel 10 gadi atpakaļ
vecāks
revīzija
ceb0739ba1
9 mainītis faili ar 73 papildinājumiem un 174 dzēšanām
  1. 13 26
      rpc/api/admin_js.go
  2. 0 28
      rpc/api/db_js.go
  3. 8 15
      rpc/api/debug_js.go
  4. 3 6
      rpc/api/eth_js.go
  5. 7 14
      rpc/api/miner_js.go
  6. 4 24
      rpc/api/net_js.go
  7. 4 6
      rpc/api/personal_js.go
  8. 2 14
      rpc/api/ssh_js.go
  9. 32 41
      rpc/api/utils.go

+ 13 - 26
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'
 		})
 	]
 });

+ 0 - 28
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:
 	[

+ 8 - 15
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:

+ 3 - 6
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'
 		})
 	]
 });

+ 7 - 14
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:

+ 4 - 24
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'
 		})
 	]
 });

+ 4 - 6
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'
 		})
 	]
 });

+ 2 - 14
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'
 		})
 	]
 });

+ 32 - 41
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",