mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 11:38:12 +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 {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addFunctionsToContract = function (contract, abi) {
|
var addFunctionsToContract = function (contract) {
|
||||||
abi.filter(function (json) {
|
contract.abi.filter(function (json) {
|
||||||
return json.type === 'function';
|
return json.type === 'function';
|
||||||
}).map(function (json) {
|
}).map(function (json) {
|
||||||
return new SolidityFunction(contract._web3, json, contract.address);
|
return new SolidityFunction(contract._web3, json, contract.address);
|
||||||
@ -2778,8 +2778,8 @@ var addFunctionsToContract = function (contract, abi) {
|
|||||||
* @param {Contract} contract
|
* @param {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addEventsToContract = function (contract, abi) {
|
var addEventsToContract = function (contract) {
|
||||||
var events = abi.filter(function (json) {
|
var events = contract.abi.filter(function (json) {
|
||||||
return json.type === 'event';
|
return json.type === 'event';
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2843,6 +2843,10 @@ var checkForContractAddress = function(contract, callback){
|
|||||||
|
|
||||||
contract.address = receipt.contractAddress;
|
contract.address = receipt.contractAddress;
|
||||||
|
|
||||||
|
// attach events and methods again after we have
|
||||||
|
addFunctionsToContract(contract);
|
||||||
|
addEventsToContract(contract);
|
||||||
|
|
||||||
// call callback for the second time
|
// call callback for the second time
|
||||||
if(callback)
|
if(callback)
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
@ -2951,6 +2955,11 @@ ContractFactory.prototype.new = function () {
|
|||||||
ContractFactory.prototype.at = function (address, callback) {
|
ContractFactory.prototype.at = function (address, callback) {
|
||||||
var contract = new Contract(this.web3, this.abi, address);
|
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) {
|
if (callback) {
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
}
|
}
|
||||||
@ -2968,11 +2977,7 @@ var Contract = function (web3, abi, address) {
|
|||||||
this._web3 = web3;
|
this._web3 = web3;
|
||||||
this.transactionHash = null;
|
this.transactionHash = null;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
this.abi = abi;
|
||||||
// this functions are not part of prototype,
|
|
||||||
// because we dont want to spoil the interface
|
|
||||||
addFunctionsToContract(this, abi);
|
|
||||||
addEventsToContract(this, abi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ContractFactory;
|
module.exports = ContractFactory;
|
||||||
@ -5879,6 +5884,7 @@ RequestManager.prototype.setProvider = function (p) {
|
|||||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||||
|
|
||||||
|
|
||||||
// start polling
|
// start polling
|
||||||
if (!this.timeout) {
|
if (!this.timeout) {
|
||||||
this.poll();
|
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);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = null;
|
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
|
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
callback(null, sync);
|
callback(null, sync);
|
||||||
}, 1);
|
}, 0);
|
||||||
|
|
||||||
self.lastSyncState = sync;
|
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 {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addFunctionsToContract = function (contract, abi) {
|
var addFunctionsToContract = function (contract) {
|
||||||
abi.filter(function (json) {
|
contract.abi.filter(function (json) {
|
||||||
return json.type === 'function';
|
return json.type === 'function';
|
||||||
}).map(function (json) {
|
}).map(function (json) {
|
||||||
return new SolidityFunction(contract._web3, json, contract.address);
|
return new SolidityFunction(contract._web3, json, contract.address);
|
||||||
@ -2778,8 +2778,8 @@ var addFunctionsToContract = function (contract, abi) {
|
|||||||
* @param {Contract} contract
|
* @param {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addEventsToContract = function (contract, abi) {
|
var addEventsToContract = function (contract) {
|
||||||
var events = abi.filter(function (json) {
|
var events = contract.abi.filter(function (json) {
|
||||||
return json.type === 'event';
|
return json.type === 'event';
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -2843,6 +2843,10 @@ var checkForContractAddress = function(contract, callback){
|
|||||||
|
|
||||||
contract.address = receipt.contractAddress;
|
contract.address = receipt.contractAddress;
|
||||||
|
|
||||||
|
// attach events and methods again after we have
|
||||||
|
addFunctionsToContract(contract);
|
||||||
|
addEventsToContract(contract);
|
||||||
|
|
||||||
// call callback for the second time
|
// call callback for the second time
|
||||||
if(callback)
|
if(callback)
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
@ -2951,6 +2955,11 @@ ContractFactory.prototype.new = function () {
|
|||||||
ContractFactory.prototype.at = function (address, callback) {
|
ContractFactory.prototype.at = function (address, callback) {
|
||||||
var contract = new Contract(this.web3, this.abi, address);
|
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) {
|
if (callback) {
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
}
|
}
|
||||||
@ -2968,11 +2977,7 @@ var Contract = function (web3, abi, address) {
|
|||||||
this._web3 = web3;
|
this._web3 = web3;
|
||||||
this.transactionHash = null;
|
this.transactionHash = null;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
this.abi = abi;
|
||||||
// this functions are not part of prototype,
|
|
||||||
// because we dont want to spoil the interface
|
|
||||||
addFunctionsToContract(this, abi);
|
|
||||||
addEventsToContract(this, abi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ContractFactory;
|
module.exports = ContractFactory;
|
||||||
@ -5879,6 +5884,7 @@ RequestManager.prototype.setProvider = function (p) {
|
|||||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||||
|
|
||||||
|
|
||||||
// start polling
|
// start polling
|
||||||
if (!this.timeout) {
|
if (!this.timeout) {
|
||||||
this.poll();
|
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);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = null;
|
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
|
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
callback(null, sync);
|
callback(null, sync);
|
||||||
}, 1);
|
}, 0);
|
||||||
|
|
||||||
self.lastSyncState = sync;
|
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 {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addFunctionsToContract = function (contract, abi) {
|
var addFunctionsToContract = function (contract) {
|
||||||
abi.filter(function (json) {
|
contract.abi.filter(function (json) {
|
||||||
return json.type === 'function';
|
return json.type === 'function';
|
||||||
}).map(function (json) {
|
}).map(function (json) {
|
||||||
return new SolidityFunction(contract._web3, json, contract.address);
|
return new SolidityFunction(contract._web3, json, contract.address);
|
||||||
@ -69,8 +69,8 @@ var addFunctionsToContract = function (contract, abi) {
|
|||||||
* @param {Contract} contract
|
* @param {Contract} contract
|
||||||
* @param {Array} abi
|
* @param {Array} abi
|
||||||
*/
|
*/
|
||||||
var addEventsToContract = function (contract, abi) {
|
var addEventsToContract = function (contract) {
|
||||||
var events = abi.filter(function (json) {
|
var events = contract.abi.filter(function (json) {
|
||||||
return json.type === 'event';
|
return json.type === 'event';
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -134,6 +134,10 @@ var checkForContractAddress = function(contract, callback){
|
|||||||
|
|
||||||
contract.address = receipt.contractAddress;
|
contract.address = receipt.contractAddress;
|
||||||
|
|
||||||
|
// attach events and methods again after we have
|
||||||
|
addFunctionsToContract(contract);
|
||||||
|
addEventsToContract(contract);
|
||||||
|
|
||||||
// call callback for the second time
|
// call callback for the second time
|
||||||
if(callback)
|
if(callback)
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
@ -242,6 +246,11 @@ ContractFactory.prototype.new = function () {
|
|||||||
ContractFactory.prototype.at = function (address, callback) {
|
ContractFactory.prototype.at = function (address, callback) {
|
||||||
var contract = new Contract(this.web3, this.abi, address);
|
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) {
|
if (callback) {
|
||||||
callback(null, contract);
|
callback(null, contract);
|
||||||
}
|
}
|
||||||
@ -259,11 +268,7 @@ var Contract = function (web3, abi, address) {
|
|||||||
this._web3 = web3;
|
this._web3 = web3;
|
||||||
this.transactionHash = null;
|
this.transactionHash = null;
|
||||||
this.address = address;
|
this.address = address;
|
||||||
|
this.abi = abi;
|
||||||
// this functions are not part of prototype,
|
|
||||||
// because we dont want to spoil the interface
|
|
||||||
addFunctionsToContract(this, abi);
|
|
||||||
addEventsToContract(this, abi);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ContractFactory;
|
module.exports = ContractFactory;
|
||||||
|
@ -141,6 +141,7 @@ RequestManager.prototype.setProvider = function (p) {
|
|||||||
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
RequestManager.prototype.startPolling = function (data, pollId, callback, uninstall) {
|
||||||
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
this.polls[pollId] = {data: data, id: pollId, callback: callback, uninstall: uninstall};
|
||||||
|
|
||||||
|
|
||||||
// start polling
|
// start polling
|
||||||
if (!this.timeout) {
|
if (!this.timeout) {
|
||||||
this.poll();
|
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);
|
clearTimeout(this.timeout);
|
||||||
this.timeout = null;
|
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
|
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
callback(null, sync);
|
callback(null, sync);
|
||||||
}, 1);
|
}, 0);
|
||||||
|
|
||||||
self.lastSyncState = sync;
|
self.lastSyncState = sync;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user