added estimateGas method

This commit is contained in:
Fabian Vogelsteller 2015-05-12 15:33:13 +02:00
parent cd2e4622c6
commit 22ef4a1958
9 changed files with 101 additions and 10 deletions

9
dist/web3-light.js vendored
View File

@ -1970,6 +1970,14 @@ var call = new Method({
inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter] inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
}); });
var estimateGas = new Method({
name: 'estimateGas',
call: 'eth_estimateGas',
params: 1,
inputFormatter: [formatters.inputTransactionFormatter],
outputFormatter: utils.toDecimal
});
var compileSolidity = new Method({ var compileSolidity = new Method({
name: 'compile.solidity', name: 'compile.solidity',
call: 'eth_compileSolidity', call: 'eth_compileSolidity',
@ -2013,6 +2021,7 @@ var methods = [
getTransactionFromBlock, getTransactionFromBlock,
getTransactionCount, getTransactionCount,
call, call,
estimateGas,
sendTransaction, sendTransaction,
compileSolidity, compileSolidity,
compileLLL, compileLLL,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9
dist/web3.js vendored
View File

@ -1970,6 +1970,14 @@ var call = new Method({
inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter] inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
}); });
var estimateGas = new Method({
name: 'estimateGas',
call: 'eth_estimateGas',
params: 1,
inputFormatter: [formatters.inputTransactionFormatter],
outputFormatter: utils.toDecimal
});
var compileSolidity = new Method({ var compileSolidity = new Method({
name: 'compile.solidity', name: 'compile.solidity',
call: 'eth_compileSolidity', call: 'eth_compileSolidity',
@ -2013,6 +2021,7 @@ var methods = [
getTransactionFromBlock, getTransactionFromBlock,
getTransactionCount, getTransactionCount,
call, call,
estimateGas,
sendTransaction, sendTransaction,
compileSolidity, compileSolidity,
compileLLL, compileLLL,

4
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

5
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -174,6 +174,14 @@ var call = new Method({
inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter] inputFormatter: [formatters.inputTransactionFormatter, formatters.inputDefaultBlockNumberFormatter]
}); });
var estimateGas = new Method({
name: 'estimateGas',
call: 'eth_estimateGas',
params: 1,
inputFormatter: [formatters.inputTransactionFormatter],
outputFormatter: utils.toDecimal
});
var compileSolidity = new Method({ var compileSolidity = new Method({
name: 'compile.solidity', name: 'compile.solidity',
call: 'eth_compileSolidity', call: 'eth_compileSolidity',
@ -217,6 +225,7 @@ var methods = [
getTransactionFromBlock, getTransactionFromBlock,
getTransactionCount, getTransactionCount,
call, call,
estimateGas,
sendTransaction, sendTransaction,
compileSolidity, compileSolidity,
compileLLL, compileLLL,

41
test/web3.eth.call.js Normal file
View File

@ -0,0 +1,41 @@
var web3 = require('../index');
var testMethod = require('./helpers/test.method.js');
var method = 'call';
var tests = [{
args: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: 11,
gasPrice: 11
}],
formattedArgs: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: '0xb',
gasPrice: '0xb'
}, 'latest'],
result: '0x31981',
formattedResult: '0x31981',
call: 'eth_'+ method
},{
args: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: 11,
gasPrice: 11
}, 11],
formattedArgs: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: '0xb',
gasPrice: '0xb'
}, '0xb'],
result: '0x31981',
formattedResult: '0x31981',
call: 'eth_'+ method
}];
testMethod.runTests('eth', method, tests);

View File

@ -0,0 +1,25 @@
var web3 = require('../index');
var testMethod = require('./helpers/test.method.js');
var method = 'estimateGas';
var tests = [{
args: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: 11,
gasPrice: 11
}],
formattedArgs: [{
to: '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
data: '0x23455654',
gas: '0xb',
gasPrice: '0xb'
}],
result: '0x31981',
formattedResult: 203137,
call: 'eth_'+ method
}];
testMethod.runTests('eth', method, tests);