-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>issuehunter</title> | ||
<link rel="stylesheet" type="text/css" href="http://issuehunter.github.io/stylesheets/github-markdown.css"> | ||
<link rel="stylesheet" type="text/css" href="http://issuehunter.github.io/stylesheets/style.css" /> | ||
<script src="https://rawgit.com/ethereum/web3.js/develop/dist/web3.js"></script> | ||
<script src="/src/contract-abi.js"></script> | ||
<script src="/src/app.js"></script> | ||
<script src="/src/add-funds.js"></script> | ||
</head> | ||
<body> | ||
<article class="markdown-body"> | ||
<header class="logo"> | ||
<h1><span class="blue">issue</span><span class="red">hunter</span></h1> | ||
</header> | ||
|
||
<p><a href="/">Back</a></p> | ||
|
||
<div> | ||
<label for="account">Account</label> | ||
<select id="account"></select> | ||
</div> | ||
<div> | ||
<label for="issueId">Issue id</label> | ||
<input id="issueId" type="text" placeholder="issue id"> | ||
</div> | ||
<div> | ||
<label for="amount">Amount (in Ether)</label> | ||
<input id="amount" type="text" placeholder="0.001"> | ||
</div> | ||
<div> | ||
<button onclick="addFunds()">Add funds</button> | ||
</div> | ||
|
||
<h3>Campaign</h3> | ||
<p class="add-funds"> | ||
Status: <strong id="status"></strong></br> | ||
Block: <strong id="block"></strong></br> | ||
Txn: <strong id="txn"></strong></br> | ||
Issue id: <strong id="infoIssueId"></strong></br> | ||
Funded by: <strong id="funder"></strong></br> | ||
Timestamp: <strong id="timestamp"></strong></br> | ||
Value: <strong id="infoAmount"></strong></br> | ||
</p> | ||
</article> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
web3.eth.getAccounts(function (err, accounts) { | ||
if (accounts && accounts.length > 0) { | ||
accounts.forEach(function (account) { | ||
var accountOption = document.createElement("option") | ||
accountOption.innerHTML = account | ||
accountOption.value = account | ||
document.getElementById("account").appendChild(accountOption) | ||
}) | ||
} else { | ||
alert("Connect an account") | ||
} | ||
}) | ||
|
||
function addFunds() { | ||
var account = document.querySelector("#account").value | ||
var issueId = document.querySelector("#issueId").value | ||
var amount = document.querySelector("#amount").value | ||
issueHunter.fund(issueId, {from: account, value: web3.toWei(amount)}, function (err, res) { | ||
if (err) { | ||
alert("Error: " + err) | ||
} else { | ||
document.querySelector("#issueId").value = "" | ||
document.querySelector("#amount").value = "" | ||
document.querySelector(".add-funds #status").innerText = "Waiting for confirmation..." | ||
} | ||
}) | ||
} | ||
|
||
// TODO: listen for CampaignFunded events for a specific issue id | ||
issueHunter.CampaignFunded().watch(function (err, event) { | ||
console.log(event) | ||
document.querySelector(".add-funds #status").innerText = "Confirmed" | ||
document.querySelector(".add-funds #block").innerText = event.blockHash | ||
document.querySelector(".add-funds #txn").innerText = event.transactionHash | ||
document.querySelector(".add-funds #infoIssueId").innerText = web3.toAscii(event.args.issueId) | ||
document.querySelector(".add-funds #funder").innerText = event.args.funder | ||
document.querySelector(".add-funds #timestamp").innerText = Date(event.args.timestamp) | ||
document.querySelector(".add-funds #infoAmount").innerText = web3.fromWei(event.args.amount) | ||
}) |