removed redundant code in examples

This commit is contained in:
Marek Kotewicz 2015-07-07 11:56:50 +02:00
parent 84a3d93c54
commit f1f30d04ed
3 changed files with 6 additions and 26 deletions

View File

@ -34,6 +34,7 @@
var watch = web3.eth.filter('latest');
// create contract
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
web3.eth.contract(abi).new({data: code}, function (err, contract) {
if (err) {
console.error('contract creation failed!');
@ -41,19 +42,8 @@
}
myContract = contract;
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('call').style.visibility = 'visible';
}
});
});
}

View File

@ -34,6 +34,7 @@
var watch = web3.eth.filter('latest');
// create contract
document.getElementById('status').innerText = "transaction sent, waiting for confirmation";
web3.eth.contract(abi).new({data: code}, function (err, contract) {
if (err) {
console.error('contract creation failed!');
@ -41,19 +42,9 @@
}
myContract = contract;
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('call').style.visibility = 'visible';
}
});
});
}

View File

@ -47,7 +47,6 @@
}
contract = c;
console.log('address: ' + contract.address);
document.getElementById('status').innerText = 'Mined!';
document.getElementById('call').style.visibility = 'visible';