Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tests pass #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/images/placeholder
Empty file.
8 changes: 8 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ <h2>Refund a Ticket</h2>
<span id="refundTicketResult"></span>
</div>

<div class="section">
<h2>Current quota</h2>
Buyer Address: <input type="text" id="refBuyerAddress" />
<button id="currentQuota">Get Current Quota</button>
<!--<input type="text" id="currentQuota" />-->
<span id="currentQuotaResult"></span>
</div>

<hr/>

<div class="section">
Expand Down
24 changes: 24 additions & 0 deletions app/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ function changeQuota(val) {
});
}

// get Quota
function getQuota() {
myConferenceInstance.currentQuota({ from: accounts[0] }).then(
function () {
return myConferenceInstance.quota.call();
}).then(
function (quota) {
if (quota) {
var msgResult;
msgResult = "Change successful - quota is: " + quota.toString();
} else {
msgResult = "Change failed";
}
$("#currentQuotaResult").html(msgResult);
console.log(quota.toString())
$("#currentQuota").val(quota)
});
}


// buyTicket
function buyTicket(buyerAddress, ticketPrice) {

Expand Down Expand Up @@ -195,6 +215,10 @@ window.onload = function() {
changeQuota(val);
});

$("#currentQuota").click(function() {
getQuota();
});

$("#buyTicket").click(function() {
var val = $("#ticketPrice").val();
var buyerAddress = $("#buyerAddress").val();
Expand Down
15 changes: 13 additions & 2 deletions contracts/Conference.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
pragma solidity ^0.4.2;

// FROM https://github.com/eshon/conference.git
// fixes https://github.com/cicorias/conference.git

contract Conference { // can be killed, so the owner gets sent the money in the end

address public organizer;
Expand All @@ -14,7 +19,7 @@ contract Conference { // can be killed, so the owner gets sent the money in the
numRegistrants = 0;
}

function buyTicket() public {
function buyTicket() payable public {
if (numRegistrants >= quota) {
throw; // throw ensures funds will be returned
}
Expand All @@ -28,12 +33,18 @@ contract Conference { // can be killed, so the owner gets sent the money in the
quota = newquota;
}

function currentQuota() public returns (uint) {
if (msg.sender != organizer) { return; }
return quota;
}


function refundTicket(address recipient, uint amount) public {
if (msg.sender != organizer) { return; }
if (registrantsPaid[recipient] == amount) {
address myAddress = this;
if (myAddress.balance >= amount) {
recipient.send(amount);
if (! recipient.send(amount) ) throw;
Refund(recipient, amount);
registrantsPaid[recipient] = 0;
numRegistrants--;
Expand Down
4 changes: 3 additions & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
pragma solidity ^0.4.2;

contract Migrations {
address public owner;
uint public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _
if (msg.sender == owner) _;
}

function Migrations() {
Expand Down
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "conference",
"version": "1.0.0",
"description": "A simple Ethereum smart contract and lightwallet example.",
"main": "truffle.js",
"directories": {
"test": "test"
},
"scripts": {
"compile": "truffle compile",
"migrate": "truffle migrate",
"test":"truffle test",
"run": "truffle serve"
},
"repository": {
"type": "git",
"url": "git+https://github.com/eshon/conference.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/eshon/conference/issues"
},
"homepage": "https://github.com/eshon/conference#readme"
}