mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-22 11:08:33 +00:00
fixed contract creation
This commit is contained in:
parent
59ef6cd8a5
commit
6253e6bdf8
29
dist/web3-light.js
vendored
29
dist/web3-light.js
vendored
@ -2761,8 +2761,8 @@ var encodeConstructorParams = function (abi, params) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addFunctionsToContract = function (contract, abi) {
|
||||
abi.filter(function (json) {
|
||||
var addFunctionsToContract = function (contract) {
|
||||
contract.abi.filter(function (json) {
|
||||
return json.type === 'function';
|
||||
}).map(function (json) {
|
||||
return new SolidityFunction(contract._web3, json, contract.address);
|
||||
@ -2778,8 +2778,8 @@ var addFunctionsToContract = function (contract, abi) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addEventsToContract = function (contract, abi) {
|
||||
var events = abi.filter(function (json) {
|
||||
var addEventsToContract = function (contract) {
|
||||
var events = contract.abi.filter(function (json) {
|
||||
return json.type === 'event';
|
||||
});
|
||||
|
||||
@ -2843,6 +2843,10 @@ var checkForContractAddress = function(contract, callback){
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
// attach events and methods again after we have
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
// call callback for the second time
|
||||
if(callback)
|
||||
callback(null, contract);
|
||||
@ -2950,6 +2954,11 @@ ContractFactory.prototype.new = function () {
|
||||
*/
|
||||
ContractFactory.prototype.at = function (address, callback) {
|
||||
var contract = new Contract(this.web3, this.abi, address);
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
if (callback) {
|
||||
callback(null, contract);
|
||||
@ -2968,11 +2977,7 @@ var Contract = function (web3, abi, address) {
|
||||
this._web3 = web3;
|
||||
this.transactionHash = null;
|
||||
this.address = address;
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(this, abi);
|
||||
addEventsToContract(this, abi);
|
||||
this.abi = abi;
|
||||
};
|
||||
|
||||
module.exports = ContractFactory;
|
||||
@ -5879,6 +5884,7 @@ RequestManager.prototype.setProvider = function (p) {
|
||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||
|
||||
|
||||
// start polling
|
||||
if (!this.timeout) {
|
||||
this.poll();
|
||||
@ -5918,7 +5924,8 @@ RequestManager.prototype.reset = function (keepIsSyncing) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.timeout) {
|
||||
// stop polling
|
||||
if(Object.keys(this.polls).length === 0 && this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
@ -6067,7 +6074,7 @@ var pollSyncing = function(self) {
|
||||
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||
setTimeout(function() {
|
||||
callback(null, sync);
|
||||
}, 1);
|
||||
}, 0);
|
||||
|
||||
self.lastSyncState = sync;
|
||||
}
|
||||
|
8
dist/web3-light.min.js
vendored
8
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
29
dist/web3.js
vendored
29
dist/web3.js
vendored
@ -2761,8 +2761,8 @@ var encodeConstructorParams = function (abi, params) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addFunctionsToContract = function (contract, abi) {
|
||||
abi.filter(function (json) {
|
||||
var addFunctionsToContract = function (contract) {
|
||||
contract.abi.filter(function (json) {
|
||||
return json.type === 'function';
|
||||
}).map(function (json) {
|
||||
return new SolidityFunction(contract._web3, json, contract.address);
|
||||
@ -2778,8 +2778,8 @@ var addFunctionsToContract = function (contract, abi) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addEventsToContract = function (contract, abi) {
|
||||
var events = abi.filter(function (json) {
|
||||
var addEventsToContract = function (contract) {
|
||||
var events = contract.abi.filter(function (json) {
|
||||
return json.type === 'event';
|
||||
});
|
||||
|
||||
@ -2843,6 +2843,10 @@ var checkForContractAddress = function(contract, callback){
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
// attach events and methods again after we have
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
// call callback for the second time
|
||||
if(callback)
|
||||
callback(null, contract);
|
||||
@ -2950,6 +2954,11 @@ ContractFactory.prototype.new = function () {
|
||||
*/
|
||||
ContractFactory.prototype.at = function (address, callback) {
|
||||
var contract = new Contract(this.web3, this.abi, address);
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
if (callback) {
|
||||
callback(null, contract);
|
||||
@ -2968,11 +2977,7 @@ var Contract = function (web3, abi, address) {
|
||||
this._web3 = web3;
|
||||
this.transactionHash = null;
|
||||
this.address = address;
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(this, abi);
|
||||
addEventsToContract(this, abi);
|
||||
this.abi = abi;
|
||||
};
|
||||
|
||||
module.exports = ContractFactory;
|
||||
@ -5879,6 +5884,7 @@ RequestManager.prototype.setProvider = function (p) {
|
||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||
|
||||
|
||||
// start polling
|
||||
if (!this.timeout) {
|
||||
this.poll();
|
||||
@ -5918,7 +5924,8 @@ RequestManager.prototype.reset = function (keepIsSyncing) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.timeout) {
|
||||
// stop polling
|
||||
if(Object.keys(this.polls).length === 0 && this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
@ -6067,7 +6074,7 @@ var pollSyncing = function(self) {
|
||||
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||
setTimeout(function() {
|
||||
callback(null, sync);
|
||||
}, 1);
|
||||
}, 0);
|
||||
|
||||
self.lastSyncState = sync;
|
||||
}
|
||||
|
8
dist/web3.js.map
vendored
8
dist/web3.js.map
vendored
File diff suppressed because one or more lines are too long
10
dist/web3.min.js
vendored
10
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -52,8 +52,8 @@ var encodeConstructorParams = function (abi, params) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addFunctionsToContract = function (contract, abi) {
|
||||
abi.filter(function (json) {
|
||||
var addFunctionsToContract = function (contract) {
|
||||
contract.abi.filter(function (json) {
|
||||
return json.type === 'function';
|
||||
}).map(function (json) {
|
||||
return new SolidityFunction(contract._web3, json, contract.address);
|
||||
@ -69,8 +69,8 @@ var addFunctionsToContract = function (contract, abi) {
|
||||
* @param {Contract} contract
|
||||
* @param {Array} abi
|
||||
*/
|
||||
var addEventsToContract = function (contract, abi) {
|
||||
var events = abi.filter(function (json) {
|
||||
var addEventsToContract = function (contract) {
|
||||
var events = contract.abi.filter(function (json) {
|
||||
return json.type === 'event';
|
||||
});
|
||||
|
||||
@ -134,6 +134,10 @@ var checkForContractAddress = function(contract, callback){
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
// attach events and methods again after we have
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
// call callback for the second time
|
||||
if(callback)
|
||||
callback(null, contract);
|
||||
@ -241,6 +245,11 @@ ContractFactory.prototype.new = function () {
|
||||
*/
|
||||
ContractFactory.prototype.at = function (address, callback) {
|
||||
var contract = new Contract(this.web3, this.abi, address);
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(contract);
|
||||
addEventsToContract(contract);
|
||||
|
||||
if (callback) {
|
||||
callback(null, contract);
|
||||
@ -259,11 +268,7 @@ var Contract = function (web3, abi, address) {
|
||||
this._web3 = web3;
|
||||
this.transactionHash = null;
|
||||
this.address = address;
|
||||
|
||||
// this functions are not part of prototype,
|
||||
// because we dont want to spoil the interface
|
||||
addFunctionsToContract(this, abi);
|
||||
addEventsToContract(this, abi);
|
||||
this.abi = abi;
|
||||
};
|
||||
|
||||
module.exports = ContractFactory;
|
||||
|
@ -141,6 +141,7 @@ RequestManager.prototype.setProvider = function (p) {
|
||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||
|
||||
|
||||
// start polling
|
||||
if (!this.timeout) {
|
||||
this.poll();
|
||||
@ -180,7 +181,8 @@ RequestManager.prototype.reset = function (keepIsSyncing) {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.timeout) {
|
||||
// stop polling
|
||||
if(Object.keys(this.polls).length === 0 && this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
this.timeout = null;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ var pollSyncing = function(self) {
|
||||
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||
setTimeout(function() {
|
||||
callback(null, sync);
|
||||
}, 1);
|
||||
}, 0);
|
||||
|
||||
self.lastSyncState = sync;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user