mirror of https://github.com/status-im/web3.js.git
removed redundant code in examples
This commit is contained in:
parent
84a3d93c54
commit
f1f30d04ed
|
@ -34,6 +34,7 @@
|
||||||
var watch = web3.eth.filter('latest');
|
var watch = web3.eth.filter('latest');
|
||||||
|
|
||||||
// create contract
|
// create contract
|
||||||
|
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
|
||||||
web3.eth.contract(abi).new({data: code}, function (err, contract) {
|
web3.eth.contract(abi).new({data: code}, function (err, contract) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('contract creation failed!');
|
console.error('contract creation failed!');
|
||||||
|
@ -41,19 +42,8 @@
|
||||||
}
|
}
|
||||||
myContract = contract;
|
myContract = contract;
|
||||||
console.log('address: ' + myContract.address);
|
console.log('address: ' + myContract.address);
|
||||||
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
|
|
||||||
watch.watch(function (err, hash) {
|
|
||||||
var block = web3.eth.getBlock(hash, true);
|
|
||||||
var contractMined = block.transactions.reduce(function (mined, th) {
|
|
||||||
// TODO: compiled code do not have 0x prefix
|
|
||||||
return mined || (th.from === web3.eth.defaultAccount && th.input.indexOf(code) !== -1);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
if (contractMined) {
|
|
||||||
document.getElementById('status').innerText = 'Mined!';
|
document.getElementById('status').innerText = 'Mined!';
|
||||||
document.getElementById('call').style.visibility = 'visible';
|
document.getElementById('call').style.visibility = 'visible';
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
var watch = web3.eth.filter('latest');
|
var watch = web3.eth.filter('latest');
|
||||||
|
|
||||||
// create contract
|
// create contract
|
||||||
|
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
|
||||||
web3.eth.contract(abi).new({data: code}, function (err, contract) {
|
web3.eth.contract(abi).new({data: code}, function (err, contract) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.error('contract creation failed!');
|
console.error('contract creation failed!');
|
||||||
|
@ -41,19 +42,9 @@
|
||||||
}
|
}
|
||||||
myContract = contract;
|
myContract = contract;
|
||||||
console.log('address: ' + myContract.address);
|
console.log('address: ' + myContract.address);
|
||||||
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
|
|
||||||
watch.watch(function (err, hash) {
|
|
||||||
var block = web3.eth.getBlock(hash, true);
|
|
||||||
var contractMined = block.transactions.reduce(function (mined, th) {
|
|
||||||
// TODO: compiled code do not have 0x prefix
|
|
||||||
return mined || (th.from === web3.eth.defaultAccount && th.input.indexOf(code) !== -1);
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
if (contractMined) {
|
|
||||||
document.getElementById('status').innerText = 'Mined!';
|
document.getElementById('status').innerText = 'Mined!';
|
||||||
document.getElementById('call').style.visibility = 'visible';
|
document.getElementById('call').style.visibility = 'visible';
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
contract = c;
|
contract = c;
|
||||||
|
|
||||||
console.log('address: ' + contract.address);
|
console.log('address: ' + contract.address);
|
||||||
document.getElementById('status').innerText = 'Mined!';
|
document.getElementById('status').innerText = 'Mined!';
|
||||||
document.getElementById('call').style.visibility = 'visible';
|
document.getElementById('call').style.visibility = 'visible';
|
||||||
|
|
Loading…
Reference in New Issue