Skip to content

Commit

Permalink
Starting to put dapps and tokens live.
Browse files Browse the repository at this point in the history
  • Loading branch information
rheaplex committed Mar 24, 2016
1 parent bb7f150 commit fd18f95
Show file tree
Hide file tree
Showing 51 changed files with 1,569 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ Artworld Ethereum

Ethereum art projects.

See projects/ for project sources.
See dapps/ for project sources.

truffle-meteor-build is a build helper script
truffle-meteor-build is a build helper script for dapps.

See tokens/ for token details.

Dependencies
------------
Expand Down Expand Up @@ -36,3 +38,10 @@ Then open the UI in a web browser
chromium environments/development/meteor/index.html

If you stop testrpc you'll need to deploy again when you restart it.

Deploying
---------

Note that we use port 8546.

geth --unlock <account id> --rpc --rpcport 8546 --rpccorsdomain localhost
12 changes: 12 additions & 0 deletions dapps/hot-cold/app/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
notices-for-facebook-graph-api-2
1.2.0-standard-minifiers-package
1.2.0-meteor-platform-split
1.2.0-cordova-changes
1.2.0-breaking-changes
1 change: 1 addition & 0 deletions dapps/hot-cold/app/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions dapps/hot-cold/app/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

lqwpxe55lh9nnszrp6
23 changes: 23 additions & 0 deletions dapps/hot-cold/app/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base # Packages every Meteor app needs to have
mobile-experience # Packages for a great mobile UX
mongo # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
session # Client-side reactive dictionary for your app
jquery # Helpful client-side library
tracker # Meteor's client-side reactive programming library

standard-minifiers # JS/CSS minifiers run for production mode
es5-shim # ECMAScript 5 compatibility for older browsers.
ecmascript # Enable ECMAScript2015+ syntax in app code

autopublish # Publish all data to the clients (for prototyping)
insecure # Allow all DB writes from clients (for prototyping)
ethereum:elements
ethereum:accounts
frozeman:template-var
2 changes: 2 additions & 0 deletions dapps/hot-cold/app/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions dapps/hot-cold/app/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
80 changes: 80 additions & 0 deletions dapps/hot-cold/app/.meteor/versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
3stack:[email protected]
alexvandesande:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
ethereum:[email protected]
ethereum:[email protected]
ethereum:[email protected]
ethereum:[email protected]
[email protected]
frozeman:[email protected]
frozeman:[email protected]
frozeman:[email protected]
frozeman:[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]_1
numeral:[email protected]_1
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
20 changes: 20 additions & 0 deletions dapps/hot-cold/app/hot-cold.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body {
text-align: center;
font-family: sans;
}

h1 {
font-size: 72pt;
}

h1 {
font-size: 128pt;
}

#hot {
color: #550000;
}

#cold {
color: #000044;
}
21 changes: 21 additions & 0 deletions dapps/hot-cold/app/hot-cold.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<head>
<title>Hot/Cold</title>
</head>

<body>
{{> hot_cold }}
{{> dapp_modalPlaceholder}}
</body>

<template name="hot_cold">
<h1 id="temperatures">
<span id="hot">{{ hot }}</span><br/>
<span id="cold">{{ cold }}</span><br/>
</h1>
</template>

<template name="swap_hot_cold">
<h2>Swap temperatures</h2>
<h3>Pay gas from account:</h3>
{{> dapp_selectAccount accounts=my_accounts}}
</template>
109 changes: 109 additions & 0 deletions dapps/hot-cold/app/hot-cold.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/* HotCold - Ethereum contract of relational physical/perceptual properties.
Copyright (C) 2015, 2016 Rhea Myers <rob@Rhea Myers.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

var SWAP_ACCOUNT_SELECTOR = '.dapp-modal-container .dapp-select-account';

var bytesToString = function (value) {
return web3.toAscii(value).replace(/\0+$/, "");
};

if (Meteor.isClient) {

Template.hot_cold.helpers({
hot: function () {
return Session.get('hot');
},
cold: function () {
return Session.get('cold');
}
});

// Keep track of when we're updating the contract state on the blockchain
// and don't show the update dialog during that time so the user doesn't
// waste gas trying to change it again.
var updating = false;

Template.hot_cold.events({
'click': function(){
if (! updating) {
EthElements.Modal.question({
template: 'swap_hot_cold',
data: {
my_accounts: EthAccounts.find().fetch()
},
ok: function(){
updating = true;
var hot_cold = HotCold.deployed();
// Update the state on the blockchain
var account = TemplateVar.getFrom(SWAP_ACCOUNT_SELECTOR, 'value');
hot_cold.swap({ from: account }).then(function(value) {
updating = false;
}).catch(function(e) {
console.log(e);
alert("Error sending toggling; see log.");
});
},
cancel: true
});
}
}
});

// Why do we put this inside window.onload?
// Truffle adds init code *after* this file is inlined, so we can't access
// HotCold.deployed here as it doesn't exist until the init code is called.
window.onload = function() {

EthAccounts.init();

var hot_cold = HotCold.deployed();

hot_cold.hot.call().then(function(value) {
var string_value = bytesToString(value);
Session.setDefault('hot', string_value);
});

hot_cold.cold.call().then(function(value) {
var string_value = bytesToString(value);
Session.setDefault('cold', string_value);
});

hot_cold.Swap({}, function(error, result){
if (! error) {
// Store the new state in local storage, updating the UI as a result
// Session.set('hot', bytesToString(result.args.hot));
// Session.set('hot', bytesToString(result.args.cold));
// BUT events with more than one value are borked in webthree.js atm
hot_cold.hot.call().then(function(value) {
var string_value = bytesToString(value);
Session.set('hot', string_value);
});

hot_cold.cold.call().then(function(value) {
var string_value = bytesToString(value);
Session.set('cold', string_value);
});
}
});
};
}

if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}
43 changes: 43 additions & 0 deletions dapps/hot-cold/contracts/HotCold.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* HotCold - Ethereum contract of relational physical/perceptual properties.
Copyright (C) 2015, 2016 Rhea Myers <rob@Rhea Myers.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

contract HotCold {

// Public generates a getter, e.g contract.hot()

bytes4 public hot;
bytes4 public cold;

event Swap (bytes4 hot, bytes4 cold);

// Swaps the values, so not const. And doesn't return a value, so no return.

function swap () {
bytes4 temp = hot;
hot = cold;
cold = temp;
Swap(hot, cold);
}

// Constructor, called during contract creation, cannot be called after

function HotCold () {
cold = "cold";
hot = "hot";
}

}
1 change: 1 addition & 0 deletions dapps/hot-cold/environments/development/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit fd18f95

Please sign in to comment.