mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 03:28:07 +00:00
add sync version
This commit is contained in:
parent
08639a1324
commit
a36636e433
115
dist/web3-light.js
vendored
115
dist/web3-light.js
vendored
@ -1820,6 +1820,57 @@ var contract = function (abi) {
|
||||
return new ContractFactory(abi);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory
|
||||
*
|
||||
* @method checkForContractAddress
|
||||
* @param {Object} contract
|
||||
* @param {Function} callback
|
||||
* @returns {Undefined}
|
||||
*/
|
||||
var checkForContractAddress = function(contract, callback){
|
||||
var self = this;
|
||||
var count = 0;
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory instance
|
||||
*
|
||||
@ -1862,54 +1913,26 @@ ContractFactory.prototype.new = function () {
|
||||
var bytes = encodeConstructorParams(this.abi, args);
|
||||
options.data += bytes;
|
||||
|
||||
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
var count = 0;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
if(callback) {
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(hash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(self, contract, callback);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var hash = web3.eth.sendTransaction(options);
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(this, contract);
|
||||
}
|
||||
|
||||
return contract;
|
||||
};
|
||||
|
5
dist/web3-light.min.js
vendored
5
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
115
dist/web3.js
vendored
115
dist/web3.js
vendored
@ -1820,6 +1820,57 @@ var contract = function (abi) {
|
||||
return new ContractFactory(abi);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory
|
||||
*
|
||||
* @method checkForContractAddress
|
||||
* @param {Object} contract
|
||||
* @param {Function} callback
|
||||
* @returns {Undefined}
|
||||
*/
|
||||
var checkForContractAddress = function(contract, callback){
|
||||
var self = this;
|
||||
var count = 0;
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory instance
|
||||
*
|
||||
@ -1862,54 +1913,26 @@ ContractFactory.prototype.new = function () {
|
||||
var bytes = encodeConstructorParams(this.abi, args);
|
||||
options.data += bytes;
|
||||
|
||||
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
var count = 0;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
if(callback) {
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(hash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(self, contract, callback);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var hash = web3.eth.sendTransaction(options);
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(this, contract);
|
||||
}
|
||||
|
||||
return contract;
|
||||
};
|
||||
|
7
dist/web3.min.js
vendored
7
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -96,6 +96,57 @@ var contract = function (abi) {
|
||||
return new ContractFactory(abi);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory
|
||||
*
|
||||
* @method checkForContractAddress
|
||||
* @param {Object} contract
|
||||
* @param {Function} callback
|
||||
* @returns {Undefined}
|
||||
*/
|
||||
var checkForContractAddress = function(contract, callback){
|
||||
var self = this;
|
||||
var count = 0;
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(contract.transactionHash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to create new ContractFactory instance
|
||||
*
|
||||
@ -138,54 +189,26 @@ ContractFactory.prototype.new = function () {
|
||||
var bytes = encodeConstructorParams(this.abi, args);
|
||||
options.data += bytes;
|
||||
|
||||
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
var count = 0;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
|
||||
// wait for receipt
|
||||
var filter = web3.eth.filter('latest', function(e, res){
|
||||
if(!e) {
|
||||
count++;
|
||||
if(callback) {
|
||||
|
||||
// stop watching after 50 blocks (timeout)
|
||||
if(count > 50) {
|
||||
if(callback)
|
||||
callback(new Error('Contract couldn\'t be deployed'));
|
||||
|
||||
filter.stopWatching();
|
||||
|
||||
} else {
|
||||
|
||||
web3.eth.getTransactionReceipt(hash, function(e, receipt){
|
||||
if(receipt) {
|
||||
|
||||
web3.eth.getCode(receipt.contractAddress, function(e, code){
|
||||
if(code.length > 2) {
|
||||
|
||||
contract.address = receipt.contractAddress;
|
||||
|
||||
if(callback) {
|
||||
callback(null, contract);
|
||||
}
|
||||
|
||||
} else {
|
||||
callback(new Error('The contract code couldn\'t be stored'));
|
||||
}
|
||||
|
||||
filter.stopWatching();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
// wait for the contract address adn check if the code was deployed
|
||||
var self = this;
|
||||
web3.eth.sendTransaction(options, function (err, hash) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(self, contract, callback);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var hash = web3.eth.sendTransaction(options);
|
||||
// add the transaction hash
|
||||
contract.transactionHash = hash;
|
||||
checkForContractAddress.call(this, contract);
|
||||
}
|
||||
|
||||
return contract;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user