From f1f30d04ed4d837cbe3ccce72d91f7a0bd04e86f Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 7 Jul 2015 11:56:50 +0200 Subject: [PATCH] removed redundant code in examples --- example/contract.html | 16 +++------------- example/contract_array.html | 15 +++------------ example/event_inc.html | 1 - 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/example/contract.html b/example/contract.html index 542ea19..63b07c1 100644 --- a/example/contract.html +++ b/example/contract.html @@ -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'; - } - }); + document.getElementById('status').innerText = 'Mined!'; + document.getElementById('call').style.visibility = 'visible'; }); } diff --git a/example/contract_array.html b/example/contract_array.html index a601a98..16a1677 100644 --- a/example/contract_array.html +++ b/example/contract_array.html @@ -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'; - } - }); + document.getElementById('status').innerText = 'Mined!'; + document.getElementById('call').style.visibility = 'visible'; }); } diff --git a/example/event_inc.html b/example/event_inc.html index 690437d..e3cc942 100644 --- a/example/event_inc.html +++ b/example/event_inc.html @@ -47,7 +47,6 @@ } contract = c; - console.log('address: ' + contract.address); document.getElementById('status').innerText = 'Mined!'; document.getElementById('call').style.visibility = 'visible';