mirror of https://github.com/status-im/web3.js.git
fixed for defaultBlock formatter
This commit is contained in:
parent
33a3fc7bcd
commit
99ea9cdc1c
|
@ -1147,11 +1147,12 @@ var setupMethods = function (obj, methods) {
|
|||
var args = Array.prototype.slice.call(arguments);
|
||||
var call = method.getCall(args);
|
||||
var callback = method.extractCallback(args);
|
||||
method.validateArgs(args);
|
||||
var params = method.formatInput(args);
|
||||
method.validateArgs(params);
|
||||
|
||||
var payload = {
|
||||
method: call,
|
||||
params: method.formatInput(args)
|
||||
params: params
|
||||
};
|
||||
|
||||
if (callback) {
|
||||
|
@ -1775,7 +1776,7 @@ var getBalance = new Method({
|
|||
name: 'getBalance',
|
||||
call: 'eth_getBalance',
|
||||
params: 2,
|
||||
inputFormatter: [null, formatters.inputBlockNumberFormatter],
|
||||
inputFormatter: [utils.toHex, formatters.inputBlockNumberFormatter],
|
||||
outputFormatter: formatters.inputNumberFormatter
|
||||
});
|
||||
|
||||
|
@ -2289,7 +2290,7 @@ var outputNumberFormatter = function (number) {
|
|||
};
|
||||
|
||||
var inputBlockNumberFormatter = function (blockNumber) {
|
||||
return blockNumber === null ? -1 : blockNumber;
|
||||
return blockNumber === undefined ? "pending" : utils.toHex(blockNumber); // instead use default block number here
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -62,11 +62,12 @@ var setupMethods = function (obj, methods) {
|
|||
var args = Array.prototype.slice.call(arguments);
|
||||
var call = method.getCall(args);
|
||||
var callback = method.extractCallback(args);
|
||||
method.validateArgs(args);
|
||||
var params = method.formatInput(args);
|
||||
method.validateArgs(params);
|
||||
|
||||
var payload = {
|
||||
method: call,
|
||||
params: method.formatInput(args)
|
||||
params: params
|
||||
};
|
||||
|
||||
if (callback) {
|
||||
|
|
|
@ -78,7 +78,7 @@ var getBalance = new Method({
|
|||
name: 'getBalance',
|
||||
call: 'eth_getBalance',
|
||||
params: 2,
|
||||
inputFormatter: [null, formatters.inputBlockNumberFormatter],
|
||||
inputFormatter: [utils.toHex, formatters.inputBlockNumberFormatter],
|
||||
outputFormatter: formatters.inputNumberFormatter
|
||||
});
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ var outputNumberFormatter = function (number) {
|
|||
};
|
||||
|
||||
var inputBlockNumberFormatter = function (blockNumber) {
|
||||
return blockNumber === null ? -1 : blockNumber;
|
||||
return blockNumber === undefined ? "pending" : utils.toHex(blockNumber); // instead use default block number here
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,12 +11,24 @@ var tests = [{
|
|||
result: '0x31981',
|
||||
formattedResult: '0x31981',
|
||||
call: 'eth_getBalance'
|
||||
}, {
|
||||
args: [0x12d, 0x1],
|
||||
formattedArgs: ['0x12d', '0x1'],
|
||||
result: '0x31981',
|
||||
formattedResult: '0x31981',
|
||||
call: 'eth_getBalance'
|
||||
}, {
|
||||
args: [0x12d],
|
||||
formattedArgs: ['0x12d', 'pending'], // here we might want to get current defaultBlock
|
||||
result: '0x31981',
|
||||
formattedResult: '0x31981',
|
||||
call: 'eth_getBalance'
|
||||
}];
|
||||
|
||||
describe('eth', function () {
|
||||
describe(method, function () {
|
||||
tests.forEach(function (test, index) {
|
||||
it('sync test:' + index, function () {
|
||||
it('sync test: ' + index, function () {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
|
|
Loading…
Reference in New Issue