Skip to content

Commit

Permalink
removed redundant code in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
debris committed Jul 7, 2015
1 parent 84a3d93 commit f1f30d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
16 changes: 3 additions & 13 deletions example/contract.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,16 @@
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!');
return;
}
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';
});
}

Expand Down
15 changes: 3 additions & 12 deletions example/contract_array.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,17 @@
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!');
return;
}
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';
});
}

Expand Down
1 change: 0 additions & 1 deletion example/event_inc.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
}

contract = c;

console.log('address: ' + contract.address);
document.getElementById('status').innerText = 'Mined!';
document.getElementById('call').style.visibility = 'visible';
Expand Down

0 comments on commit f1f30d0

Please sign in to comment.