Skip to content

Commit

Permalink
Merge pull request web3#203 from frozeman/develop
Browse files Browse the repository at this point in the history
added estimateGas method
  • Loading branch information
debris committed May 12, 2015
2 parents cd2e462 + 22ef4a1 commit 8f63640
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 10 deletions.
9 changes: 9 additions & 0 deletions dist/web3-light.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3-light.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dist/web3-light.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/web3.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/web3.js.map

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dist/web3.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions lib/web3/eth.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ var call = new Method({
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({
name: 'compile.solidity',
call: 'eth_compileSolidity',
Expand Down Expand Up @@ -217,6 +225,7 @@ var methods = [
getTransactionFromBlock,
getTransactionCount,
call,
estimateGas,
sendTransaction,
compileSolidity,
compileLLL,
Expand Down
41 changes: 41 additions & 0 deletions test/web3.eth.call.js
Original file line number Diff line number Diff line change
@@ -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);

25 changes: 25 additions & 0 deletions test/web3.eth.estimateGas.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 8f63640

Please sign in to comment.