Skip to content

Commit d3200e3

Browse files
0x-r4bbitiurimatias
authored andcommitted
fix: revert custom deploy() API for EmbarkJS.Contract
`.deploy()` is an alias to `.new()` and in other tools also no longer used as API to deploy instances. In addition, we don't want it to shadow the original web3 `deploy()` API which actually caused a breeaking change.
1 parent 0461fa0 commit d3200e3

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

dapps/tests/app/test/simple_storage_deploy_spec.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ const {Utils} = artifacts.require('EmbarkJS');
55
contract("SimpleStorage Deploy", function () {
66
let simpleStorageInstance;
77
before(async () => {
8-
simpleStorageInstance = await SimpleStorage.deploy([150]);
8+
return new Promise(async (resolve, reject) => {
9+
const gas = await SimpleStorage.deploy({arguments: [150]}).estimateGas();
10+
11+
Utils.secureSend(web3, SimpleStorage.deploy({arguments: [150]}), {gas, from: web3.eth.defaultAccount}, true, function(err, receipt) {
12+
if(err) {
13+
return reject(err);
14+
}
15+
simpleStorageInstance = SimpleStorage;
16+
simpleStorageInstance.options.address = receipt.contractAddress;
17+
resolve();
18+
});
19+
});
920
});
1021

1122
it("should set constructor value", async function () {

packages/embarkjs/embarkjs/src/lib/blockchain.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ function Contract(options) {
313313
});
314314

315315
// Assign helpers too
316-
for(const method of ["deploy", "new", "at", "send", "deployed"]) {
316+
for(const method of ["new", "at", "send", "deployed"]) {
317317
// Make sure we don't override original methods here.
318318
if (originalMethods.includes(method)) {
319319
console.log(method + " is a reserved word and will not be aliased as a helper");
@@ -328,7 +328,7 @@ function Contract(options) {
328328
return ContractClass;
329329
}
330330

331-
Contract.prototype.deploy = function(args, _options, _txOptions) {
331+
Contract.prototype.new = function(args, _options, _txOptions) {
332332
const self = this;
333333
const options = Object.assign({
334334
arguments: args || [],
@@ -358,8 +358,6 @@ Contract.prototype.deploy = function(args, _options, _txOptions) {
358358
return this._deployPromise;
359359
};
360360

361-
Contract.prototype.new = Contract.prototype.deploy;
362-
363361
Contract.prototype.at = function(address) {
364362
return new Contract({abi: this.abi, code: this.code, address: address});
365363
};

0 commit comments

Comments
 (0)