Merge branch 'contract_overhaul' into batch
Conflicts: dist/web3-light.js.map dist/web3-light.min.js dist/web3.js.map dist/web3.min.js
This commit is contained in:
commit
b2ff2ffe37
|
@ -1648,7 +1648,7 @@ ContractFactory.prototype.new = function () {
|
|||
|
||||
if (!callback) {
|
||||
var address = web3.eth.sendTransaction(options);
|
||||
return this.at(address, callback);
|
||||
return this.at(address);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
@ -2721,7 +2721,7 @@ SolidityFunction.prototype.call = function () {
|
|||
var payload = this.toPayload(args);
|
||||
|
||||
if (!callback) {
|
||||
var output = web3.eth.call(payload, callback);
|
||||
var output = web3.eth.call(payload);
|
||||
return this.unpackOutput(output);
|
||||
}
|
||||
|
||||
|
@ -3302,16 +3302,23 @@ Property.prototype.formatOutput = function (result) {
|
|||
Property.prototype.attachToObject = function (obj) {
|
||||
var proto = {
|
||||
get: this.get.bind(this),
|
||||
set: this.set.bind(this)
|
||||
};
|
||||
|
||||
var name = this.name.split('.');
|
||||
if (name.length > 1) {
|
||||
obj[name[0]] = obj[name[0]] || {};
|
||||
Object.defineProperty(obj[name[0]], name[1], proto);
|
||||
} else {
|
||||
Object.defineProperty(obj, name[0], proto);
|
||||
var names = this.name.split('.');
|
||||
var name = names[0];
|
||||
if (names.length > 1) {
|
||||
obj[names[0]] = obj[names[0]] || {};
|
||||
obj = obj[names[0]];
|
||||
name = names[1];
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, name, proto);
|
||||
|
||||
var toAsyncName = function (prefix, name) {
|
||||
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
||||
};
|
||||
|
||||
obj[toAsyncName('get', name)] = this.getAsync.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -3327,15 +3334,20 @@ Property.prototype.get = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Should be used to set value of the property
|
||||
* Should be used to asynchrounously get value of property
|
||||
*
|
||||
* @method set
|
||||
* @param {Object} new value of the property
|
||||
* @method getAsync
|
||||
* @param {Function}
|
||||
*/
|
||||
Property.prototype.set = function (value) {
|
||||
return RequestManager.getInstance().send({
|
||||
method: this.setter,
|
||||
params: [this.formatInput(value)]
|
||||
Property.prototype.getAsync = function (callback) {
|
||||
var self = this;
|
||||
RequestManager.getInstance().sendAsync({
|
||||
method: this.getter
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(err, self.formatOutput(result));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1648,7 +1648,7 @@ ContractFactory.prototype.new = function () {
|
|||
|
||||
if (!callback) {
|
||||
var address = web3.eth.sendTransaction(options);
|
||||
return this.at(address, callback);
|
||||
return this.at(address);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
@ -2721,7 +2721,7 @@ SolidityFunction.prototype.call = function () {
|
|||
var payload = this.toPayload(args);
|
||||
|
||||
if (!callback) {
|
||||
var output = web3.eth.call(payload, callback);
|
||||
var output = web3.eth.call(payload);
|
||||
return this.unpackOutput(output);
|
||||
}
|
||||
|
||||
|
@ -3302,16 +3302,23 @@ Property.prototype.formatOutput = function (result) {
|
|||
Property.prototype.attachToObject = function (obj) {
|
||||
var proto = {
|
||||
get: this.get.bind(this),
|
||||
set: this.set.bind(this)
|
||||
};
|
||||
|
||||
var name = this.name.split('.');
|
||||
if (name.length > 1) {
|
||||
obj[name[0]] = obj[name[0]] || {};
|
||||
Object.defineProperty(obj[name[0]], name[1], proto);
|
||||
} else {
|
||||
Object.defineProperty(obj, name[0], proto);
|
||||
var names = this.name.split('.');
|
||||
var name = names[0];
|
||||
if (names.length > 1) {
|
||||
obj[names[0]] = obj[names[0]] || {};
|
||||
obj = obj[names[0]];
|
||||
name = names[1];
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, name, proto);
|
||||
|
||||
var toAsyncName = function (prefix, name) {
|
||||
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
||||
};
|
||||
|
||||
obj[toAsyncName('get', name)] = this.getAsync.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -3327,15 +3334,20 @@ Property.prototype.get = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Should be used to set value of the property
|
||||
* Should be used to asynchrounously get value of property
|
||||
*
|
||||
* @method set
|
||||
* @param {Object} new value of the property
|
||||
* @method getAsync
|
||||
* @param {Function}
|
||||
*/
|
||||
Property.prototype.set = function (value) {
|
||||
return RequestManager.getInstance().send({
|
||||
method: this.setter,
|
||||
params: [this.formatInput(value)]
|
||||
Property.prototype.getAsync = function (callback) {
|
||||
var self = this;
|
||||
RequestManager.getInstance().sendAsync({
|
||||
method: this.getter
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(err, self.formatOutput(result));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -133,7 +133,7 @@ ContractFactory.prototype.new = function () {
|
|||
|
||||
if (!callback) {
|
||||
var address = web3.eth.sendTransaction(options);
|
||||
return this.at(address, callback);
|
||||
return this.at(address);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
|
|
@ -99,7 +99,7 @@ SolidityFunction.prototype.call = function () {
|
|||
var payload = this.toPayload(args);
|
||||
|
||||
if (!callback) {
|
||||
var output = web3.eth.call(payload, callback);
|
||||
var output = web3.eth.call(payload);
|
||||
return this.unpackOutput(output);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,16 +63,23 @@ Property.prototype.formatOutput = function (result) {
|
|||
Property.prototype.attachToObject = function (obj) {
|
||||
var proto = {
|
||||
get: this.get.bind(this),
|
||||
set: this.set.bind(this)
|
||||
};
|
||||
|
||||
var name = this.name.split('.');
|
||||
if (name.length > 1) {
|
||||
obj[name[0]] = obj[name[0]] || {};
|
||||
Object.defineProperty(obj[name[0]], name[1], proto);
|
||||
} else {
|
||||
Object.defineProperty(obj, name[0], proto);
|
||||
var names = this.name.split('.');
|
||||
var name = names[0];
|
||||
if (names.length > 1) {
|
||||
obj[names[0]] = obj[names[0]] || {};
|
||||
obj = obj[names[0]];
|
||||
name = names[1];
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, name, proto);
|
||||
|
||||
var toAsyncName = function (prefix, name) {
|
||||
return prefix + name.charAt(0).toUpperCase() + name.slice(1);
|
||||
};
|
||||
|
||||
obj[toAsyncName('get', name)] = this.getAsync.bind(this);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -88,15 +95,20 @@ Property.prototype.get = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Should be used to set value of the property
|
||||
* Should be used to asynchrounously get value of property
|
||||
*
|
||||
* @method set
|
||||
* @param {Object} new value of the property
|
||||
* @method getAsync
|
||||
* @param {Function}
|
||||
*/
|
||||
Property.prototype.set = function (value) {
|
||||
return RequestManager.getInstance().send({
|
||||
method: this.setter,
|
||||
params: [this.formatInput(value)]
|
||||
Property.prototype.getAsync = function (callback) {
|
||||
var self = this;
|
||||
RequestManager.getInstance().sendAsync({
|
||||
method: this.getter
|
||||
}, function (err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(err, self.formatOutput(result));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -32,6 +32,26 @@ describe('web3.eth', function () {
|
|||
// then
|
||||
assert.strictEqual(test.formattedResult, result);
|
||||
});
|
||||
|
||||
it('async get property test: ' + index, function (done) {
|
||||
|
||||
// given
|
||||
var provider = new FakeHttpProvider();
|
||||
web3.setProvider(provider);
|
||||
provider.injectResult(test.result);
|
||||
provider.injectValidation(function (payload) {
|
||||
assert.equal(payload.jsonrpc, '2.0');
|
||||
assert.equal(payload.method, test.call);
|
||||
assert.deepEqual(payload.params, []);
|
||||
});
|
||||
|
||||
// when
|
||||
web3.eth.getBlockNumber(function (err, result) {
|
||||
assert.strictEqual(test.formattedResult, result);
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue