mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +00:00
fix bug passing BigNumber as contract method arg (#896)
This commit is contained in:
parent
dbefa39e52
commit
db6efd5f23
@ -65,7 +65,10 @@ SolidityFunction.prototype.extractDefaultBlock = function (args) {
|
||||
SolidityFunction.prototype.validateArgs = function (args) {
|
||||
var inputArgs = args.filter(function (a) {
|
||||
// filter the options object but not arguments that are arrays
|
||||
return !(utils.isObject(a) === true && utils.isArray(a) === false);
|
||||
return !( (utils.isObject(a) === true) &&
|
||||
(utils.isArray(a) === false) &&
|
||||
(utils.isBigNumber(a) === false)
|
||||
);
|
||||
});
|
||||
if (inputArgs.length !== this._inputTypes.length) {
|
||||
throw errors.InvalidNumberOfSolidityArgs();
|
||||
|
@ -478,6 +478,30 @@ describe('contract', function () {
|
||||
contract.send(address, 17, {from: address, gas: 50000, gasPrice: 3000, value: 10000});
|
||||
});
|
||||
|
||||
it('should sendTransaction with bigNum param and optional params', function () {
|
||||
var provider = new FakeHttpProvider();
|
||||
var web3 = new Web3(provider);
|
||||
var signature = 'send(address,uint256)';
|
||||
var address = '0x1234567890123456789012345678901234567891';
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.method, 'eth_sendTransaction');
|
||||
assert.deepEqual(payload.params, [{
|
||||
data: '0x' + sha3(signature).slice(0, 8) +
|
||||
'0000000000000000000000001234567890123456789012345678901234567891' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000011' ,
|
||||
to: address,
|
||||
from: address,
|
||||
gas: '0xc350',
|
||||
gasPrice: '0xbb8',
|
||||
value: '0x2710'
|
||||
}]);
|
||||
});
|
||||
|
||||
var contract = web3.eth.contract(desc).at(address);
|
||||
|
||||
contract.send(address, new BigNumber(17), {from: address, gas: 50000, gasPrice: 3000, value: 10000});
|
||||
});
|
||||
|
||||
it('should explicitly sendTransaction with optional params', function () {
|
||||
var provider = new FakeHttpProvider();
|
||||
var web3 = new Web3(provider);
|
||||
|
Loading…
x
Reference in New Issue
Block a user