mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48:13 +00:00
add in-output until eth_getBlockByHash
This commit is contained in:
parent
9c0d3e3c63
commit
51a075c62d
53
dist/ethereum.js
vendored
53
dist/ethereum.js
vendored
@ -1623,23 +1623,23 @@ var utils = require('../utils/utils');
|
||||
|
||||
|
||||
var blockCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
|
||||
};
|
||||
|
||||
var transactionCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||
var transactionFromBlockCall = function (args) {
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||
};
|
||||
|
||||
var uncleCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockHashAndNumber';
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
|
||||
};
|
||||
|
||||
var transactionCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||
var getBlockTransactionCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||
};
|
||||
|
||||
var uncleCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
|
||||
};
|
||||
|
||||
/// @returns an array of objects describing web3.eth api methods
|
||||
@ -1648,16 +1648,16 @@ var methods = [
|
||||
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
||||
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
||||
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter},
|
||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter},
|
||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
||||
{ name: 'getBlockTransactionCount', call: transactionCountCall },
|
||||
{ name: 'getBlockUncleCount', call: uncleCountCall },
|
||||
{ name: 'getBlockTransactionCount', call: getBlockTransactionCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||
{ name: 'getBlockUncleCount', call: uncleCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
||||
{ name: 'getTransactionFromBlock', call: transactionCall, outputFormatter: formatters.outputTransactionFormatter },
|
||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2},
|
||||
{ name: 'getTransactionFromBlock', call: transactionFromBlockCall, outputFormatter: formatters.outputTransactionFormatter, inputFormatter: utils.toHex },
|
||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2, outputFormatter: utils.toDecimal},
|
||||
{ name: 'sendTransaction', call: 'eth_sendTransaction', inputFormatter: formatters.inputTransactionFormatter },
|
||||
{ name: 'call', call: 'eth_call', addDefaultblock: 2},
|
||||
{ name: 'call', call: 'eth_call', addDefaultblock: 2, inputFormatter: formatters.inputCallFormatter },
|
||||
{ name: 'compile.solidity', call: 'eth_compileSolidity' },
|
||||
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
||||
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
||||
@ -1671,13 +1671,13 @@ var methods = [
|
||||
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
||||
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
||||
{ name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
|
||||
{ name: 'transaction', call: transactionCall, newMethod: 'eth.getTransaction' },
|
||||
{ name: 'transaction', call: transactionFromBlockCall, newMethod: 'eth.getTransaction' },
|
||||
{ name: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
|
||||
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
||||
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
||||
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
||||
{ name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
|
||||
{ name: 'transactionCount', call: transactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
|
||||
{ name: 'transactionCount', call: getBlockTransactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
|
||||
{ name: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
|
||||
{ name: 'logs', call: 'eth_logs' }
|
||||
];
|
||||
@ -2067,6 +2067,24 @@ var outputTransactionFormatter = function (tx){
|
||||
return tx;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats the input of a call and converts all values to HEX
|
||||
*
|
||||
* @method inputCallFormatter
|
||||
* @param {Object} transaction options
|
||||
* @returns object
|
||||
*/
|
||||
var inputCallFormatter = function (options){
|
||||
|
||||
// make code -> data
|
||||
if (options.code) {
|
||||
options.data = options.code;
|
||||
delete options.code;
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats the output of a block to its proper values
|
||||
*
|
||||
@ -2161,6 +2179,7 @@ module.exports = {
|
||||
convertToBigNumber: convertToBigNumber,
|
||||
inputTransactionFormatter: inputTransactionFormatter,
|
||||
outputTransactionFormatter: outputTransactionFormatter,
|
||||
inputCallFormatter: inputCallFormatter,
|
||||
outputBlockFormatter: outputBlockFormatter,
|
||||
outputLogFormatter: outputLogFormatter,
|
||||
inputPostFormatter: inputPostFormatter,
|
||||
@ -2423,7 +2442,7 @@ var requestManager = function() {
|
||||
if(typeof data.inputFormatter === 'function') {
|
||||
data.params = Array.prototype.map.call(data.params, function(item, index){
|
||||
// format everything besides the defaultblock, which is already formated
|
||||
return (index+1 < data.addDefaultblock)
|
||||
return (!data.addDefaultblock || index+1 < data.addDefaultblock)
|
||||
? data.inputFormatter(item)
|
||||
: item;
|
||||
});
|
||||
|
8
dist/ethereum.js.map
vendored
8
dist/ethereum.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/ethereum.min.js
vendored
2
dist/ethereum.min.js
vendored
File diff suppressed because one or more lines are too long
@ -25,23 +25,23 @@ var utils = require('../utils/utils');
|
||||
|
||||
|
||||
var blockCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? "eth_getBlockByHash" : "eth_getBlockByNumber";
|
||||
};
|
||||
|
||||
var transactionCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||
var transactionFromBlockCall = function (args) {
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||
};
|
||||
|
||||
var uncleCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockHashAndNumber';
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleByBlockHashAndIndex' : 'eth_getUncleByBlockNumberAndIndex';
|
||||
};
|
||||
|
||||
var transactionCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||
var getBlockTransactionCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||
};
|
||||
|
||||
var uncleCountCall = function (args) {
|
||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
|
||||
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getUncleCountByBlockHash' : 'eth_getUncleCountByBlockNumber';
|
||||
};
|
||||
|
||||
/// @returns an array of objects describing web3.eth api methods
|
||||
@ -50,16 +50,16 @@ var methods = [
|
||||
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
||||
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
||||
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter},
|
||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter},
|
||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
||||
{ name: 'getBlockTransactionCount', call: transactionCountCall },
|
||||
{ name: 'getBlockUncleCount', call: uncleCountCall },
|
||||
{ name: 'getBlockTransactionCount', call: getBlockTransactionCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||
{ name: 'getBlockUncleCount', call: uncleCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
||||
{ name: 'getTransactionFromBlock', call: transactionCall, outputFormatter: formatters.outputTransactionFormatter },
|
||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2},
|
||||
{ name: 'getTransactionFromBlock', call: transactionFromBlockCall, outputFormatter: formatters.outputTransactionFormatter, inputFormatter: utils.toHex },
|
||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2, outputFormatter: utils.toDecimal},
|
||||
{ name: 'sendTransaction', call: 'eth_sendTransaction', inputFormatter: formatters.inputTransactionFormatter },
|
||||
{ name: 'call', call: 'eth_call', addDefaultblock: 2},
|
||||
{ name: 'call', call: 'eth_call', addDefaultblock: 2, inputFormatter: formatters.inputCallFormatter },
|
||||
{ name: 'compile.solidity', call: 'eth_compileSolidity' },
|
||||
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
||||
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
||||
@ -73,13 +73,13 @@ var methods = [
|
||||
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
||||
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
||||
{ name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
|
||||
{ name: 'transaction', call: transactionCall, newMethod: 'eth.getTransaction' },
|
||||
{ name: 'transaction', call: transactionFromBlockCall, newMethod: 'eth.getTransaction' },
|
||||
{ name: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
|
||||
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
||||
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
||||
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
||||
{ name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
|
||||
{ name: 'transactionCount', call: transactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
|
||||
{ name: 'transactionCount', call: getBlockTransactionCountCall, newMethod: 'eth.getBlockTransactionCount' },
|
||||
{ name: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
|
||||
{ name: 'logs', call: 'eth_logs' }
|
||||
];
|
||||
|
@ -70,6 +70,24 @@ var outputTransactionFormatter = function (tx){
|
||||
return tx;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats the input of a call and converts all values to HEX
|
||||
*
|
||||
* @method inputCallFormatter
|
||||
* @param {Object} transaction options
|
||||
* @returns object
|
||||
*/
|
||||
var inputCallFormatter = function (options){
|
||||
|
||||
// make code -> data
|
||||
if (options.code) {
|
||||
options.data = options.code;
|
||||
delete options.code;
|
||||
}
|
||||
|
||||
return options;
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats the output of a block to its proper values
|
||||
*
|
||||
@ -164,6 +182,7 @@ module.exports = {
|
||||
convertToBigNumber: convertToBigNumber,
|
||||
inputTransactionFormatter: inputTransactionFormatter,
|
||||
outputTransactionFormatter: outputTransactionFormatter,
|
||||
inputCallFormatter: inputCallFormatter,
|
||||
outputBlockFormatter: outputBlockFormatter,
|
||||
outputLogFormatter: outputLogFormatter,
|
||||
inputPostFormatter: inputPostFormatter,
|
||||
|
@ -43,7 +43,7 @@ var requestManager = function() {
|
||||
if(typeof data.inputFormatter === 'function') {
|
||||
data.params = Array.prototype.map.call(data.params, function(item, index){
|
||||
// format everything besides the defaultblock, which is already formated
|
||||
return (index+1 < data.addDefaultblock)
|
||||
return (!data.addDefaultblock || index+1 < data.addDefaultblock)
|
||||
? data.inputFormatter(item)
|
||||
: item;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user