fixed contract deploy

This commit is contained in:
Fabian Vogelsteller 2015-07-07 19:46:26 +02:00
parent dbb976acf4
commit 3b941cfd43
10 changed files with 42 additions and 129 deletions

26
dist/web3-light.js vendored
View File

@ -1605,9 +1605,9 @@ var utils = require('../utils/utils');
var Filter = require('./filter'); var Filter = require('./filter');
var watches = require('./watches'); var watches = require('./watches');
var AllSolidityEvents = function (json, address) { var AllSolidityEvents = function (json, contract) {
this._json = json; this._json = json;
this._address = address; this._contract = contract;
}; };
AllSolidityEvents.prototype.encode = function (options) { AllSolidityEvents.prototype.encode = function (options) {
@ -1621,7 +1621,7 @@ AllSolidityEvents.prototype.encode = function (options) {
}); });
result.topics = [null, null, null, null, null]; // match all topics result.topics = [null, null, null, null, null]; // match all topics
result.address = this._address; result.address = this._contract.address;
return result; return result;
}; };
@ -1640,7 +1640,7 @@ AllSolidityEvents.prototype.decode = function (data) {
return data; return data;
} }
var event = new SolidityEvent(match, this._address); var event = new SolidityEvent(match, this._contract);
return event.decode(data); return event.decode(data);
}; };
@ -1781,7 +1781,7 @@ var addFunctionsToContract = function (contract, abi) {
abi.filter(function (json) { abi.filter(function (json) {
return json.type === 'function'; return json.type === 'function';
}).map(function (json) { }).map(function (json) {
return new SolidityFunction(json, contract.address); return new SolidityFunction(json, contract);
}).forEach(function (f) { }).forEach(function (f) {
f.attachToContract(contract); f.attachToContract(contract);
}); });
@ -1799,11 +1799,11 @@ var addEventsToContract = function (contract, abi) {
return json.type === 'event'; return json.type === 'event';
}); });
var All = new AllEvents(events, contract.address); var All = new AllEvents(events, contract);
All.attachToContract(contract); All.attachToContract(contract);
events.map(function (json) { events.map(function (json) {
return new SolidityEvent(json, contract.address); return new SolidityEvent(json, contract);
}).forEach(function (e) { }).forEach(function (e) {
e.attachToContract(contract); e.attachToContract(contract);
}); });
@ -2392,10 +2392,10 @@ var watches = require('./watches');
/** /**
* This prototype should be used to create event filters * This prototype should be used to create event filters
*/ */
var SolidityEvent = function (json, address) { var SolidityEvent = function (json, contract) {
this._params = json.inputs; this._params = json.inputs;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
this._anonymous = json.anonymous; this._anonymous = json.anonymous;
}; };
@ -2466,7 +2466,7 @@ SolidityEvent.prototype.encode = function (indexed, options) {
result.topics = []; result.topics = [];
if (!this._anonymous) { if (!this._anonymous) {
result.address = this._address; result.address = this._contract.address;
result.topics.push('0x' + this.signature()); result.topics.push('0x' + this.signature());
} }
@ -3056,7 +3056,7 @@ var sha3 = require('../utils/sha3');
/** /**
* This prototype should be used to call/sendTransaction to solidity functions * This prototype should be used to call/sendTransaction to solidity functions
*/ */
var SolidityFunction = function (json, address) { var SolidityFunction = function (json, contract) {
this._inputTypes = json.inputs.map(function (i) { this._inputTypes = json.inputs.map(function (i) {
return i.type; return i.type;
}); });
@ -3065,7 +3065,7 @@ var SolidityFunction = function (json, address) {
}); });
this._constant = json.constant; this._constant = json.constant;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
}; };
SolidityFunction.prototype.extractCallback = function (args) { SolidityFunction.prototype.extractCallback = function (args) {
@ -3092,7 +3092,7 @@ SolidityFunction.prototype.toPayload = function (args) {
if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) { if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
options = args[args.length - 1]; options = args[args.length - 1];
} }
options.to = this._address; options.to = this._contract.address;
options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args); options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
return options; return options;
}; };

File diff suppressed because one or more lines are too long

26
dist/web3.js vendored
View File

@ -1605,9 +1605,9 @@ var utils = require('../utils/utils');
var Filter = require('./filter'); var Filter = require('./filter');
var watches = require('./watches'); var watches = require('./watches');
var AllSolidityEvents = function (json, address) { var AllSolidityEvents = function (json, contract) {
this._json = json; this._json = json;
this._address = address; this._contract = contract;
}; };
AllSolidityEvents.prototype.encode = function (options) { AllSolidityEvents.prototype.encode = function (options) {
@ -1621,7 +1621,7 @@ AllSolidityEvents.prototype.encode = function (options) {
}); });
result.topics = [null, null, null, null, null]; // match all topics result.topics = [null, null, null, null, null]; // match all topics
result.address = this._address; result.address = this._contract.address;
return result; return result;
}; };
@ -1640,7 +1640,7 @@ AllSolidityEvents.prototype.decode = function (data) {
return data; return data;
} }
var event = new SolidityEvent(match, this._address); var event = new SolidityEvent(match, this._contract);
return event.decode(data); return event.decode(data);
}; };
@ -1781,7 +1781,7 @@ var addFunctionsToContract = function (contract, abi) {
abi.filter(function (json) { abi.filter(function (json) {
return json.type === 'function'; return json.type === 'function';
}).map(function (json) { }).map(function (json) {
return new SolidityFunction(json, contract.address); return new SolidityFunction(json, contract);
}).forEach(function (f) { }).forEach(function (f) {
f.attachToContract(contract); f.attachToContract(contract);
}); });
@ -1799,11 +1799,11 @@ var addEventsToContract = function (contract, abi) {
return json.type === 'event'; return json.type === 'event';
}); });
var All = new AllEvents(events, contract.address); var All = new AllEvents(events, contract);
All.attachToContract(contract); All.attachToContract(contract);
events.map(function (json) { events.map(function (json) {
return new SolidityEvent(json, contract.address); return new SolidityEvent(json, contract);
}).forEach(function (e) { }).forEach(function (e) {
e.attachToContract(contract); e.attachToContract(contract);
}); });
@ -2392,10 +2392,10 @@ var watches = require('./watches');
/** /**
* This prototype should be used to create event filters * This prototype should be used to create event filters
*/ */
var SolidityEvent = function (json, address) { var SolidityEvent = function (json, contract) {
this._params = json.inputs; this._params = json.inputs;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
this._anonymous = json.anonymous; this._anonymous = json.anonymous;
}; };
@ -2466,7 +2466,7 @@ SolidityEvent.prototype.encode = function (indexed, options) {
result.topics = []; result.topics = [];
if (!this._anonymous) { if (!this._anonymous) {
result.address = this._address; result.address = this._contract.address;
result.topics.push('0x' + this.signature()); result.topics.push('0x' + this.signature());
} }
@ -3056,7 +3056,7 @@ var sha3 = require('../utils/sha3');
/** /**
* This prototype should be used to call/sendTransaction to solidity functions * This prototype should be used to call/sendTransaction to solidity functions
*/ */
var SolidityFunction = function (json, address) { var SolidityFunction = function (json, contract) {
this._inputTypes = json.inputs.map(function (i) { this._inputTypes = json.inputs.map(function (i) {
return i.type; return i.type;
}); });
@ -3065,7 +3065,7 @@ var SolidityFunction = function (json, address) {
}); });
this._constant = json.constant; this._constant = json.constant;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
}; };
SolidityFunction.prototype.extractCallback = function (args) { SolidityFunction.prototype.extractCallback = function (args) {
@ -3092,7 +3092,7 @@ SolidityFunction.prototype.toPayload = function (args) {
if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) { if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
options = args[args.length - 1]; options = args[args.length - 1];
} }
options.to = this._address; options.to = this._contract.address;
options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args); options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
return options; return options;
}; };

87
dist/web3.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/web3.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -27,9 +27,9 @@ var utils = require('../utils/utils');
var Filter = require('./filter'); var Filter = require('./filter');
var watches = require('./watches'); var watches = require('./watches');
var AllSolidityEvents = function (json, address) { var AllSolidityEvents = function (json, contract) {
this._json = json; this._json = json;
this._address = address; this._contract = contract;
}; };
AllSolidityEvents.prototype.encode = function (options) { AllSolidityEvents.prototype.encode = function (options) {
@ -43,7 +43,7 @@ AllSolidityEvents.prototype.encode = function (options) {
}); });
result.topics = [null, null, null, null, null]; // match all topics result.topics = [null, null, null, null, null]; // match all topics
result.address = this._address; result.address = this._contract.address;
return result; return result;
}; };
@ -62,7 +62,7 @@ AllSolidityEvents.prototype.decode = function (data) {
return data; return data;
} }
var event = new SolidityEvent(match, this._address); var event = new SolidityEvent(match, this._contract);
return event.decode(data); return event.decode(data);
}; };

View File

@ -57,7 +57,7 @@ var addFunctionsToContract = function (contract, abi) {
abi.filter(function (json) { abi.filter(function (json) {
return json.type === 'function'; return json.type === 'function';
}).map(function (json) { }).map(function (json) {
return new SolidityFunction(json, contract.address); return new SolidityFunction(json, contract);
}).forEach(function (f) { }).forEach(function (f) {
f.attachToContract(contract); f.attachToContract(contract);
}); });
@ -75,11 +75,11 @@ var addEventsToContract = function (contract, abi) {
return json.type === 'event'; return json.type === 'event';
}); });
var All = new AllEvents(events, contract.address); var All = new AllEvents(events, contract);
All.attachToContract(contract); All.attachToContract(contract);
events.map(function (json) { events.map(function (json) {
return new SolidityEvent(json, contract.address); return new SolidityEvent(json, contract);
}).forEach(function (e) { }).forEach(function (e) {
e.attachToContract(contract); e.attachToContract(contract);
}); });

View File

@ -30,10 +30,10 @@ var watches = require('./watches');
/** /**
* This prototype should be used to create event filters * This prototype should be used to create event filters
*/ */
var SolidityEvent = function (json, address) { var SolidityEvent = function (json, contract) {
this._params = json.inputs; this._params = json.inputs;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
this._anonymous = json.anonymous; this._anonymous = json.anonymous;
}; };
@ -104,7 +104,7 @@ SolidityEvent.prototype.encode = function (indexed, options) {
result.topics = []; result.topics = [];
if (!this._anonymous) { if (!this._anonymous) {
result.address = this._address; result.address = this._contract.address;
result.topics.push('0x' + this.signature()); result.topics.push('0x' + this.signature());
} }

View File

@ -29,7 +29,7 @@ var sha3 = require('../utils/sha3');
/** /**
* This prototype should be used to call/sendTransaction to solidity functions * This prototype should be used to call/sendTransaction to solidity functions
*/ */
var SolidityFunction = function (json, address) { var SolidityFunction = function (json, contract) {
this._inputTypes = json.inputs.map(function (i) { this._inputTypes = json.inputs.map(function (i) {
return i.type; return i.type;
}); });
@ -38,7 +38,7 @@ var SolidityFunction = function (json, address) {
}); });
this._constant = json.constant; this._constant = json.constant;
this._name = utils.transformToFullName(json); this._name = utils.transformToFullName(json);
this._address = address; this._contract = contract;
}; };
SolidityFunction.prototype.extractCallback = function (args) { SolidityFunction.prototype.extractCallback = function (args) {
@ -65,7 +65,7 @@ SolidityFunction.prototype.toPayload = function (args) {
if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) { if (args.length > this._inputTypes.length && utils.isObject(args[args.length -1])) {
options = args[args.length - 1]; options = args[args.length - 1];
} }
options.to = this._address; options.to = this._contract.address;
options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args); options.data = '0x' + this.signature() + coder.encodeParams(this._inputTypes, args);
return options; return options;
}; };

View File

@ -218,7 +218,7 @@ describe('lib/web3/event', function () {
describe('encode', function () { describe('encode', function () {
tests.forEach(function (test, index) { tests.forEach(function (test, index) {
it('test no: ' + index, function () { it('test no: ' + index, function () {
var event = new SolidityEvent(test.abi, address); var event = new SolidityEvent(test.abi, {address: address});
event.signature = function () { // inject signature event.signature = function () { // inject signature
return signature.slice(2); return signature.slice(2);
}; };