mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-24 03:58: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) {
|
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) {
|
var transactionFromBlockCall = function (args) {
|
||||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||||
};
|
};
|
||||||
|
|
||||||
var uncleCall = function (args) {
|
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) {
|
var getBlockTransactionCountCall = function (args) {
|
||||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||||
};
|
};
|
||||||
|
|
||||||
var uncleCountCall = function (args) {
|
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
|
/// @returns an array of objects describing web3.eth api methods
|
||||||
@ -1648,16 +1648,16 @@ var methods = [
|
|||||||
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
||||||
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
||||||
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
||||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter},
|
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter},
|
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||||
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
||||||
{ name: 'getBlockTransactionCount', call: transactionCountCall },
|
{ name: 'getBlockTransactionCount', call: getBlockTransactionCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||||
{ name: 'getBlockUncleCount', call: uncleCountCall },
|
{ name: 'getBlockUncleCount', call: uncleCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||||
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
||||||
{ name: 'getTransactionFromBlock', call: transactionCall, outputFormatter: formatters.outputTransactionFormatter },
|
{ name: 'getTransactionFromBlock', call: transactionFromBlockCall, outputFormatter: formatters.outputTransactionFormatter, inputFormatter: utils.toHex },
|
||||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2},
|
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2, outputFormatter: utils.toDecimal},
|
||||||
{ name: 'sendTransaction', call: 'eth_sendTransaction', inputFormatter: formatters.inputTransactionFormatter },
|
{ 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.solidity', call: 'eth_compileSolidity' },
|
||||||
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
||||||
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
||||||
@ -1671,13 +1671,13 @@ var methods = [
|
|||||||
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
||||||
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
||||||
{ name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
|
{ 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: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
|
||||||
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
||||||
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
||||||
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
||||||
{ name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
|
{ 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: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
|
||||||
{ name: 'logs', call: 'eth_logs' }
|
{ name: 'logs', call: 'eth_logs' }
|
||||||
];
|
];
|
||||||
@ -2067,6 +2067,24 @@ var outputTransactionFormatter = function (tx){
|
|||||||
return 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
|
* Formats the output of a block to its proper values
|
||||||
*
|
*
|
||||||
@ -2161,6 +2179,7 @@ module.exports = {
|
|||||||
convertToBigNumber: convertToBigNumber,
|
convertToBigNumber: convertToBigNumber,
|
||||||
inputTransactionFormatter: inputTransactionFormatter,
|
inputTransactionFormatter: inputTransactionFormatter,
|
||||||
outputTransactionFormatter: outputTransactionFormatter,
|
outputTransactionFormatter: outputTransactionFormatter,
|
||||||
|
inputCallFormatter: inputCallFormatter,
|
||||||
outputBlockFormatter: outputBlockFormatter,
|
outputBlockFormatter: outputBlockFormatter,
|
||||||
outputLogFormatter: outputLogFormatter,
|
outputLogFormatter: outputLogFormatter,
|
||||||
inputPostFormatter: inputPostFormatter,
|
inputPostFormatter: inputPostFormatter,
|
||||||
@ -2423,7 +2442,7 @@ var requestManager = function() {
|
|||||||
if(typeof data.inputFormatter === 'function') {
|
if(typeof data.inputFormatter === 'function') {
|
||||||
data.params = Array.prototype.map.call(data.params, function(item, index){
|
data.params = Array.prototype.map.call(data.params, function(item, index){
|
||||||
// format everything besides the defaultblock, which is already formated
|
// format everything besides the defaultblock, which is already formated
|
||||||
return (index+1 < data.addDefaultblock)
|
return (!data.addDefaultblock || index+1 < data.addDefaultblock)
|
||||||
? data.inputFormatter(item)
|
? data.inputFormatter(item)
|
||||||
: 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) {
|
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) {
|
var transactionFromBlockCall = function (args) {
|
||||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getTransactionByBlockHashAndIndex' : 'eth_getTransactionByBlockNumberAndIndex';
|
||||||
};
|
};
|
||||||
|
|
||||||
var uncleCall = function (args) {
|
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) {
|
var getBlockTransactionCountCall = function (args) {
|
||||||
return (utils.isString(args[0]) && !isFinite(args[0])) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
return (utils.isString(args[0]) && args[0].indexOf('0x') === 0) ? 'eth_getBlockTransactionCountByHash' : 'eth_getBlockTransactionCountByNumber';
|
||||||
};
|
};
|
||||||
|
|
||||||
var uncleCountCall = function (args) {
|
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
|
/// @returns an array of objects describing web3.eth api methods
|
||||||
@ -50,16 +50,16 @@ var methods = [
|
|||||||
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
{ name: 'getStorage', call: 'eth_getStorage', addDefaultblock: 2},
|
||||||
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
{ name: 'getStorageAt', call: 'eth_getStorageAt', addDefaultblock: 3, inputFormatter: utils.toHex},
|
||||||
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
{ name: 'getData', call: 'eth_getData', addDefaultblock: 2},
|
||||||
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter},
|
{ name: 'getBlock', call: blockCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||||
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter},
|
{ name: 'getUncle', call: uncleCall, outputFormatter: formatters.outputBlockFormatter, inputFormatter: utils.toHex},
|
||||||
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
{ name: 'getCompilers', call: 'eth_getCompilers' },
|
||||||
{ name: 'getBlockTransactionCount', call: transactionCountCall },
|
{ name: 'getBlockTransactionCount', call: getBlockTransactionCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||||
{ name: 'getBlockUncleCount', call: uncleCountCall },
|
{ name: 'getBlockUncleCount', call: uncleCountCall, outputFormatter: utils.toDecimal, inputFormatter: utils.toHex },
|
||||||
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
{ name: 'getTransaction', call: 'eth_getTransactionByHash', outputFormatter: formatters.outputTransactionFormatter },
|
||||||
{ name: 'getTransactionFromBlock', call: transactionCall, outputFormatter: formatters.outputTransactionFormatter },
|
{ name: 'getTransactionFromBlock', call: transactionFromBlockCall, outputFormatter: formatters.outputTransactionFormatter, inputFormatter: utils.toHex },
|
||||||
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2},
|
{ name: 'getTransactionCount', call: 'eth_getTransactionCount', addDefaultblock: 2, outputFormatter: utils.toDecimal},
|
||||||
{ name: 'sendTransaction', call: 'eth_sendTransaction', inputFormatter: formatters.inputTransactionFormatter },
|
{ 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.solidity', call: 'eth_compileSolidity' },
|
||||||
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
{ name: 'compile.lll', call: 'eth_compileLLL' },
|
||||||
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
{ name: 'compile.serpent', call: 'eth_compileSerpent' },
|
||||||
@ -73,13 +73,13 @@ var methods = [
|
|||||||
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
{ name: 'codeAt', call: 'eth_codeAt', newMethod: 'eth.getData' },
|
||||||
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
{ name: 'transact', call: 'eth_transact', newMethod: 'eth.sendTransaction' },
|
||||||
{ name: 'block', call: blockCall, newMethod: 'eth.getBlock' },
|
{ 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: 'uncle', call: uncleCall, newMethod: 'eth.getUncle' },
|
||||||
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
{ name: 'compilers', call: 'eth_compilers', newMethod: 'eth.getCompilers' },
|
||||||
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
{ name: 'solidity', call: 'eth_solidity', newMethod: 'eth.compile.solidity' },
|
||||||
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
{ name: 'lll', call: 'eth_lll', newMethod: 'eth.compile.lll' },
|
||||||
{ name: 'serpent', call: 'eth_serpent', newMethod: 'eth.compile.serpent' },
|
{ 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: 'uncleCount', call: uncleCountCall, newMethod: 'eth.getBlockUncleCount' },
|
||||||
{ name: 'logs', call: 'eth_logs' }
|
{ name: 'logs', call: 'eth_logs' }
|
||||||
];
|
];
|
||||||
|
@ -70,6 +70,24 @@ var outputTransactionFormatter = function (tx){
|
|||||||
return 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
|
* Formats the output of a block to its proper values
|
||||||
*
|
*
|
||||||
@ -164,6 +182,7 @@ module.exports = {
|
|||||||
convertToBigNumber: convertToBigNumber,
|
convertToBigNumber: convertToBigNumber,
|
||||||
inputTransactionFormatter: inputTransactionFormatter,
|
inputTransactionFormatter: inputTransactionFormatter,
|
||||||
outputTransactionFormatter: outputTransactionFormatter,
|
outputTransactionFormatter: outputTransactionFormatter,
|
||||||
|
inputCallFormatter: inputCallFormatter,
|
||||||
outputBlockFormatter: outputBlockFormatter,
|
outputBlockFormatter: outputBlockFormatter,
|
||||||
outputLogFormatter: outputLogFormatter,
|
outputLogFormatter: outputLogFormatter,
|
||||||
inputPostFormatter: inputPostFormatter,
|
inputPostFormatter: inputPostFormatter,
|
||||||
|
@ -43,7 +43,7 @@ var requestManager = function() {
|
|||||||
if(typeof data.inputFormatter === 'function') {
|
if(typeof data.inputFormatter === 'function') {
|
||||||
data.params = Array.prototype.map.call(data.params, function(item, index){
|
data.params = Array.prototype.map.call(data.params, function(item, index){
|
||||||
// format everything besides the defaultblock, which is already formated
|
// format everything besides the defaultblock, which is already formated
|
||||||
return (index+1 < data.addDefaultblock)
|
return (!data.addDefaultblock || index+1 < data.addDefaultblock)
|
||||||
? data.inputFormatter(item)
|
? data.inputFormatter(item)
|
||||||
: item;
|
: item;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user