Skip to content

Commit

Permalink
Merge branch '1.x' into issue/1648
Browse files Browse the repository at this point in the history
  • Loading branch information
nivida committed Nov 6, 2019
2 parents 4e4d341 + 1c0ad97 commit d624492
Show file tree
Hide file tree
Showing 18 changed files with 251 additions and 39 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ Released with 1.0.0-beta.37 code base.
### Fixed

- Fix TS types for eth.subscribe syncing, newBlockHeaders, pendingTransactions (#3159)
- Improve web3-eth-abi decodeParameters error message (#3134)
6 changes: 3 additions & 3 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions packages/web3-core-helpers/package-lock.json

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

1 change: 1 addition & 0 deletions packages/web3-core-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"web3-utils": "1.2.2"
},
"devDependencies": {
"@types/node": "^12.12.5",
"definitelytyped-header-parser": "^1.0.1",
"dtslint": "0.4.2"
}
Expand Down
8 changes: 7 additions & 1 deletion packages/web3-eth-abi/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,13 @@ ABICoder.prototype.decodeParameter = function (type, bytes) {
*/
ABICoder.prototype.decodeParameters = function (outputs, bytes) {
if (outputs.length > 0 && (!bytes || bytes === '0x' || bytes === '0X')) {
throw new Error('Returned values aren\'t valid, did it run Out of Gas?');
throw new Error(
'Returned values aren\'t valid, did it run Out of Gas? ' +
'You might also see this error if you are not using the ' +
'correct ABI for the contract you are retrieving data from, ' +
'requesting data from a block number that does not exist, ' +
'or querying a node which is not fully synced.'
);
}

var res = ethersAbiCoder.decode(this.mapTypes(outputs), '0x' + bytes.replace(/0x/i, ''));
Expand Down
31 changes: 16 additions & 15 deletions packages/web3-eth-accounts/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"eth-lib": "0.2.7",
"ethereumjs-common": "^1.3.2",
"ethereumjs-tx": "^2.1.1",
"scrypt-shim": "github:web3-js/scrypt-shim",
"@web3-js/scrypt-shim": "^0.1.0",
"underscore": "1.9.1",
"uuid": "3.3.2",
"web3-core": "1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-accounts/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Accounts.prototype.signTransaction = function signTransaction(tx, privateKey, ca
error = false,
transactionOptions = {},
result,
hasTxSigningOptions = !!((tx.chain && tx.hardfork) || tx.common);
hasTxSigningOptions = !!(tx && ((tx.chain && tx.hardfork) || tx.common));

callback = callback || function() {
};
Expand Down
5 changes: 5 additions & 0 deletions packages/web3-providers-ipc/package-lock.json

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

1 change: 1 addition & 0 deletions packages/web3-providers-ipc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"web3-core-helpers": "1.2.2"
},
"devDependencies": {
"@types/node": "^12.12.5",
"definitelytyped-header-parser": "^1.0.1",
"dtslint": "0.4.2"
}
Expand Down
35 changes: 18 additions & 17 deletions packages/web3-providers-ws/package-lock.json

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

2 changes: 1 addition & 1 deletion packages/web3-providers-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"underscore": "1.9.1",
"web3-core-helpers": "1.2.2",
"websocket": "github:web3-js/WebSocket-Node#polyfill/globalThis"
"@web3-js/websocket": "^1.0.29"
},
"devDependencies": {
"definitelytyped-header-parser": "^1.0.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/web3-shh/package-lock.json

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

1 change: 1 addition & 0 deletions packages/web3-shh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"web3-net": "1.2.2"
},
"devDependencies": {
"@types/node": "^12.12.5",
"definitelytyped-header-parser": "^1.0.1",
"dtslint": "0.4.2"
}
Expand Down
68 changes: 68 additions & 0 deletions test/e2e.method.call.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
var assert = require('assert');
var Basic = require('./sources/Basic');
var Misc = require('./sources/Misc');
var utils = require('./helpers/test.utils');
var Web3 = utils.getWeb3();

describe('method.call [ @E2E ]', function() {
var web3;
var accounts;
var basic;
var instance;
var options;

var basicOptions = {
data: Basic.bytecode,
gasPrice: '1',
gas: 4000000
};

var miscOptions = {
data: Misc.bytecode,
gasPrice: '1',
gas: 4000000
};

before(async function(){
web3 = new Web3('http://localhost:8545');
accounts = await web3.eth.getAccounts();

basic = new web3.eth.Contract(Basic.abi, basicOptions);
instance = await basic.deploy().send({from: accounts[0]});
})

it('retrieves a uint value', async function(){
var expected = '1';

await instance
.methods
.setValue(expected)
.send({from: accounts[0]});

var value = await instance
.methods
.getValue()
.call({from: accounts[0]});

assert.equal(value, expected);
});

it('errors correctly when abi and bytecode do not match', async function(){
// Misc n.eq Basic
var wrong = new web3.eth.Contract(Basic.abi, miscOptions);
var wrongInstance = await wrong.deploy().send({from: accounts[0]});

try {
await wrongInstance
.methods
.getValue()
.call();

assert.fail();

} catch(err){
assert(err.message.includes("Returned values aren't valid"));
assert(err.message.includes('the correct ABI'));
}
})
});
Loading

0 comments on commit d624492

Please sign in to comment.