Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Upgrade web3 #1852

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/truffle-artifactor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"mocha": "5.2.0",
"require-nocache": "^1.0.0",
"temp": "^0.8.3",
"truffle-contract": "^4.0.15",
"web3": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"truffle-contract": "^4.0.15"
},
"dependencies": {
"fs-extra": "6.0.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/truffle-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
"truffle-blockchain-utils": "^0.0.9",
"truffle-contract-schema": "^3.0.9",
"truffle-error": "^0.0.4",
"truffle-interface-adapter": "^0.1.5",
"web3": "1.0.0-beta.37",
"web3-core-promievent": "1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.37",
"web3-utils": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"web3-core-promievent": "1.0.0-beta.48",
"web3-eth-abi": "1.0.0-beta.55",
"web3-utils": "1.0.0-beta.55",
"truffle-interface-adapter": "^0.1.5"
},
"devDependencies": {
"async": "2.6.1",
Expand Down
15 changes: 12 additions & 3 deletions packages/truffle-contract/test/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ describe("Methods", function() {
await example.triggerRequireError();
assert.fail();
} catch (e) {
assert(e.message.includes("failing transaction"), "should return failed tx message!");
assert(
e.message.includes("failing transaction"),
"should return failed tx message!"
);
assert(e.receipt === undefined, "Expected no receipt");
}
});
Expand All @@ -435,7 +438,10 @@ describe("Methods", function() {
await example.triggerAssertError();
assert.fail();
} catch (e) {
assert(e.message.includes("failing transaction"), "should return failed tx message!");
assert(
e.message.includes("failing transaction"),
"should return failed tx message!"
);
assert(e.receipt === undefined, "Excected no receipt");
}
});
Expand All @@ -448,7 +454,10 @@ describe("Methods", function() {
await example.runsOutOfGas();
assert.fail();
} catch (e) {
assert(e.message.includes("gas required exceeds allowance"), "should return gas allowance error");
assert(
e.message.includes("gas required exceeds allowance"),
"should return gas allowance error"
);
assert(e.receipt === undefined, "Expected no receipt");
}
});
Expand Down
8 changes: 4 additions & 4 deletions packages/truffle-core/lib/templates/example.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var Example = artifacts.require("Example");
const Example = artifacts.require("Example");

contract("Example", function(accounts) {
it("should assert true", function(done) {
var example = Example.deployed();
contract("Example", function(_accounts) {
it("asserts true", async function(done) {
await Example.deployed();
assert.isTrue(true);
done();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/truffle-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"truffle-solidity-utils": "^1.2.2",
"truffle-workflow-compile": "^2.0.14",
"universal-analytics": "^0.4.17",
"web3": "1.0.0-beta.37",
"web3": "1.0.0-beta.55",
"xregexp": "^4.2.4",
"yargs": "^8.0.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-debugger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"truffle-decoder": "^3.0.3",
"truffle-expect": "^0.0.8",
"truffle-solidity-utils": "^1.2.2",
"web3": "1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"web3-eth-abi": "1.0.0-beta.55"
},
"devDependencies": {
"async": "2.6.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-decode-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"dependencies": {
"bn.js": "^4.11.8",
"lodash.clonedeep": "^4.5.0",
"web3": "1.0.0-beta.55",
"lodash.escaperegexp": "^4.1.2",
"web3": "1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.52"
"web3-eth-abi": "1.0.0-beta.55"
},
"main": "dist/index.js",
"types": "src/index.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-decoder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"lodash.clonedeep": "^4.5.0",
"lodash.isequal": "^4.5.0",
"lodash.merge": "^4.6.1",
"truffle-decode-utils": "^1.0.12",
"web3": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"truffle-decode-utils": "^1.0.12"
},
"peerDependencies": {
"truffle": "^5.0.14"
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-deployer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"ganache-core": "2.5.5",
"mocha": "5.2.0",
"truffle-reporters": "^1.0.9",
"truffle-workflow-compile": "^2.0.14",
"web3": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"truffle-workflow-compile": "^2.0.14"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-external-compile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"dependencies": {
"debug": "^4.1.0",
"glob": "^7.1.2",
"truffle-contract-schema": "^3.0.9",
"web3-utils": "1.0.0-beta.55",
"truffle-expect": "^0.0.8",
"web3-utils": "1.0.0-beta.37"
"truffle-contract-schema": "^3.0.9"
},
"devDependencies": {
"chai": "4.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-hdwallet-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ganache-core": "2.5.5",
"js-scrypt": "^0.2.0",
"mocha": "^5.1.1",
"web3": "1.0.0-beta.37",
"web3": "1.0.0-beta.55",
"web3-provider-engine": "https://github.com/trufflesuite/provider-engine#web3-one",
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2"
Expand All @@ -39,7 +39,7 @@
"dependencies": {
"any-promise": "^1.3.0",
"bindings": "^1.3.1",
"web3": "1.0.0-beta.37",
"web3": "1.0.0-beta.55",
"websocket": "^1.0.28"
}
}
8 changes: 2 additions & 6 deletions packages/truffle-interface-adapter/lib/web3-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,10 @@ export class Web3Shim extends Web3 {
public networkType: NetworkType;

constructor(options?: Web3ShimOptions) {
super();
options.provider ? super(options.provider) : super();

if (options) {
this.networkType = options.networkType || "ethereum";

if (options.provider) {
this.setProvider(options.provider);
}
} else {
this.networkType = "ethereum";
}
Expand Down Expand Up @@ -84,4 +80,4 @@ export class Web3Shim extends Web3 {
quorumOverloads.getTransaction(this);
quorumOverloads.getTransactionReceipt(this);
}
}
}
2 changes: 1 addition & 1 deletion packages/truffle-interface-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
},
"dependencies": {
"bn.js": "^4.11.8",
"web3": "1.0.0-beta.37"
"web3": "1.0.0-beta.55"
}
}
6 changes: 1 addition & 5 deletions packages/truffle-migrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ const Migrate = {

wrapProvider: function(provider) {
return {
send: function(payload, callback) {
provider.send(payload, function(err, result) {
err ? callback(err) : callback(err, result);
});
}
send: (method, params) => provider.send(method, params)
};
},

Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
"async": "2.6.1",
"emittery": "^0.4.0",
"node-dir": "0.1.17",
"web3": "1.0.0-beta.55",
"truffle-config": "^1.1.11",
"truffle-deployer": "^3.0.16",
"truffle-expect": "^0.0.8",
"truffle-interface-adapter": "^0.1.5",
"truffle-reporters": "^1.0.9",
"truffle-require": "^2.0.11",
"web3": "1.0.0-beta.37"
"truffle-require": "^2.0.11"
},
"devDependencies": {
"mocha": "5.2.0",
Expand Down
9 changes: 4 additions & 5 deletions packages/truffle-provider/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var debug = require("debug")("provider"); // eslint-disable-line no-unused-vars
var Web3 = require("web3");
var Web3Shim = require("truffle-interface-adapter").Web3Shim;

var wrapper = require("./wrapper");
const debug = require("debug")("provider");
const Web3 = require("web3").default;
const Web3Shim = require("truffle-interface-adapter").Web3Shim;
const wrapper = require("./wrapper");

module.exports = {
wrap: function(provider, options) {
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"homepage": "https://github.com/trufflesuite/truffle-provider#readme",
"dependencies": {
"truffle-error": "^0.0.4",
"truffle-interface-adapter": "^0.1.5",
"web3": "1.0.0-beta.37"
"web3": "1.0.0-beta.55",
"truffle-interface-adapter": "^0.1.5"
},
"devDependencies": {
"ganache-core": "2.5.5",
Expand Down
41 changes: 19 additions & 22 deletions packages/truffle-provider/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,24 @@ module.exports = {

// before send/sendAsync
preHook: function(options) {
return function(payload) {
return function(method, params) {
if (options.verbose) {
// for request payload debugging
options.logger.log(
" > " +
JSON.stringify(payload, null, 2)
JSON.stringify(method, params, null, 2)
.split("\n")
.join("\n > ")
);
}

return payload;
return { method, params };
};
},

// after send/sendAsync
postHook: function(options) {
return function(payload, error, result) {
if (error != null) {
// wrap errors in internal error class
error = new ProviderError(error.message, options);
return [payload, error, result];
}

return function(method, params, result) {
if (options.verbose) {
options.logger.log(
" < " +
Expand All @@ -84,8 +78,7 @@ module.exports = {
.join("\n < ")
);
}

return [payload, error, result];
return result;
};
},

Expand All @@ -100,16 +93,20 @@ module.exports = {
* Return the wrapped function matching the original function's signature.
*/
send: function(originalSend, preHook, postHook) {
return function(payload, callback) {
payload = preHook(payload);

originalSend(payload, function(error, result) {
var modified = postHook(payload, error, result);
payload = modified[0];
error = modified[1];
result = modified[2];

callback(error, result);
return function(inputMethod, inputParams) {
return new Promise((resolve, reject) => {
let { method, params } = preHook(inputMethod, inputParams);

return originalSend(method, params)
.then(result => {
const modifiedResult = postHook(method, params, result);
resolve(modifiedResult);
})
.catch(error => {
// wrap errors in internal error class
error = new ProviderError(error.message, options);
reject(error);
});
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion packages/truffle-reporters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"node-emoji": "^1.8.1",
"ora": "^3.0.0",
"web3-utils": "1.0.0-beta.37"
"web3-utils": "1.0.0-beta.55"
},
"gitHead": "b207efb3c1409746537293b3e0fc27350029188e"
}
16 changes: 8 additions & 8 deletions packages/truffle-reporters/reporters/migrations-V5/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class Reporter {
constructor() {
this.deployer = null;
this.migration = null;
this.currentGasTotal = new web3Utils.BN(0);
this.currentCostTotal = new web3Utils.BN(0);
this.finalCostTotal = new web3Utils.BN(0);
this.currentGasTotal = web3Utils.toBN(0);
this.currentCostTotal = web3Utils.toBN(0);
this.finalCostTotal = web3Utils.toBN(0);
this.deployments = 0;
this.separator = "\n";
this.summary = [];
Expand Down Expand Up @@ -95,8 +95,8 @@ class Reporter {
const cost = web3Utils.fromWei(this.currentCostTotal, "ether");
this.finalCostTotal = this.finalCostTotal.add(this.currentCostTotal);

this.currentGasTotal = new web3Utils.BN(0);
this.currentCostTotal = new web3Utils.BN(0);
this.currentGasTotal = web3Utils.toBN(0);
this.currentCostTotal = web3Utils.toBN(0);

return {
gas: gas.toString(10),
Expand Down Expand Up @@ -321,9 +321,9 @@ class Reporter {

const balance = await data.contract.web3.eth.getBalance(tx.from);

const gasPrice = new web3Utils.BN(tx.gasPrice);
const gas = new web3Utils.BN(data.receipt.gasUsed);
const value = new web3Utils.BN(tx.value);
const gasPrice = web3Utils.toBN(tx.gasPrice);
const gas = web3Utils.toBN(data.receipt.gasUsed);
const value = web3Utils.toBN(tx.value);
const cost = gasPrice.mul(gas).add(value);

data.gasPrice = web3Utils.fromWei(gasPrice, "gwei");
Expand Down
4 changes: 2 additions & 2 deletions packages/truffle-require/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
},
"dependencies": {
"original-require": "1.0.1",
"web3": "1.0.0-beta.55",
"truffle-config": "^1.1.11",
"truffle-expect": "^0.0.8",
"truffle-interface-adapter": "^0.1.5",
"web3": "1.0.0-beta.37"
"truffle-interface-adapter": "^0.1.5"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/truffle-solidity-loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const schema = {
};

let isCompilingContracts = false; // Global mutex variable
module.exports = (source, map, meta) => {
module.exports = (_source, _map, _meta) => {
let WebpackOptions = getOptions(this) || {};
validateOptions(schema, WebpackOptions, "truffle-solidity-loader");

Expand Down
Loading