Commit a5a763fc authored by Rob Myers's avatar Rob Myers

Store things.

parent 701ee4ce
{
"presets": ["react", "es2015"]
}
\ No newline at end of file
{
"extends": "airbnb",
"env": {
"browser": true,
"node": true
},
"rules": {
"react/jsx-curly-spacing": [2, "always"],
"react/prefer-stateless-function": [0],
"comma-dangle": [0]
}
}
.symbol {
background-color: lightgrey;
text-align: center;
line-height: 100%;
font-size: 75vmin;
width: 75vmin;
height: 75vmin;
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.symbol-gui {
width: 500px;
height: 400px;
/*visibility: visible;*/
}
body {
margin: 0;
font-family: sans-serif;
}
#background {
float: left;
width: 100vw;
height: 100vh;
position: absolute;
}
@keyframes updating {
from { color: white; }
to { color: lightgray; }
}
#updating {
/* Center the text vertically */
position:absolute;
left:0; right:0;
top:50%;
transform: translateY(-50%);
/* And horizontally */
text-align: center;
color: white;
animation: updating 1s infinite alternate;
font-size: 72px;
text-shadow: 0 0 1em black;
z-index: 2000;
}
#status {
}
.gui {
float: left;
position:absolute;
left:0; right:0;
top:0; bottom:0;
margin: auto;
padding: 0 20px;
background-color: white;
border: 1px solid gray;
border-radius: 5px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>symbol</title>
<link href="css/app.css" rel="stylesheet">
</head>
<body>
<div id="app"></div>
<script src="js/app.js" type="text/javascript"></script>
</body>
</html>
/* A symbol.
Copyright (C) 2016, 2017 Rob Myers <[email protected]>
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/>.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import Symbol from './components/Symbol';
ReactDOM.render(
<Symbol symbol="@" />,
document.getElementById('app')
);
import React from 'react';
const Symbol = props =>
<div className="symbol">
{ props.symbol }
</div>;
Symbol.propTypes = {
symbol: React.PropTypes.string.isRequired
};
export default Symbol;
/* A symbol.
Copyright (C) 2016, 2017 Rob Myers <[email protected]>
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/>.
*/
'use strict';
////////////////////////////////////////////////////////////////////////////////
// Web3 or Mock
////////////////////////////////////////////////////////////////////////////////
if (typeof web3 !== 'undefined') {
var Web3 = require("web3");
window.addEventListener('load', function() {
if (typeof web3 !== 'undefined') {
window.web3 = new Web3(web3.currentProv ider);
} else {
alert('No Web3 found. Please open in an Ethereum waller. ');
}
});
} else {
var _symbol = '☣';
var getNetworkSymbol = function (callback) {
callback(_symbol);
};
var commitNetworkSymbol = function (symbol) {
_symbol = symbol;
// To be handled by value change fallback
setSymbolRepresentation(_symbol);
};
}
0 info it worked if it ends with ok
1 verbose cli [ '/home/rob/.nvm/versions/node/v7.1.0/bin/node',
1 verbose cli '/home/rob/.nvm/versions/node/v7.1.0/bin/npm',
1 verbose cli 'run-script',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 silly lifecycle [email protected]~prebuild: no script for prebuild, continuing
7 info lifecycle [email protected]~build: [email protected]
8 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~build: PATH: /home/rob/.nvm/versions/node/v7.1.0/lib/node_modules/npm/bin/node-gyp-bin:/home/rob/projects/artworld-ethereum/dapps/lottery-token/node_modules/.bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cargo/bin:/home/rob/bin:/home/rob/.nvm/versions/node/v7.1.0/bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cask/bin:/home/rob/go/bin:/home/rob/src/icon-v951src/bin:~/.composer/vendor/bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cargo/bin:/home/rob/.rvm/gems/ruby-2.3.0/bin:/home/rob/.rvm/gems/[email protected]/bin:/home/rob/.rvm/rubies/ruby-2.3.0/bin:/home/rob/bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cask/bin:/home/rob/go/bin:/home/rob/src/icon-v951src/bin:~/.composer/vendor/bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cask/bin:/home/rob/go/bin:/home/rob/src/icon-v951src/bin:~/.composer/vendor/bin:/home/rob/.opam/4.03.0/bin:/home/rob/.cargo/bin:/home/rob/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/rob/.rvm/bin:/home/rob/bin:/usr/local/go/bin:/home/rob/.rvm/bin:/home/rob/bin:/usr/local/go/bin:/home/rob/.rvm/bin:/home/rob/.rvm/bin:/home/rob/bin:/usr/local/go/bin:/home/rob/.rvm/bin:/home/rob/.rvm/bin:/usr/local/share/scala/bin
10 verbose lifecycle [email protected]~build: CWD: /home/rob/projects/artworld-ethereum/dapps/lottery-token
11 silly lifecycle [email protected]~build: Args: [ '-c', 'webpack' ]
12 silly lifecycle [email protected]~build: Returned: code: 2 signal: null
13 info lifecycle [email protected]~build: Failed to exec build script
14 verbose stack Error: [email protected] build: `webpack`
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (/home/rob/.nvm/versions/node/v7.1.0/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/home/rob/.nvm/versions/node/v7.1.0/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid [email protected]
16 verbose cwd /home/rob/projects/artworld-ethereum/dapps/lottery-token/app
17 error Linux 3.16.0-4-amd64
18 error argv "/home/rob/.nvm/versions/node/v7.1.0/bin/node" "/home/rob/.nvm/versions/node/v7.1.0/bin/npm" "run-script" "build"
19 error node v7.1.0
20 error npm v3.10.9
21 error code ELIFECYCLE
22 error [email protected] build: `webpack`
22 error Exit status 2
23 error Failed at the [email protected] build script 'webpack'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the lottery-token package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack
23 error You can get information on how to open an issue for this project with:
23 error npm bugs lottery-token
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls lottery-token
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
pragma solidity ^0.4.4;
library ConvertLib{
function convert(uint amount,uint conversionRate) returns (uint convertedAmount)
{
return amount * conversionRate;
}
}
pragma solidity ^0.4.4;
import "./ConvertLib.sol";
// This is just a simple example of a coin-like contract.
// It is not standards compatible and cannot be expected to talk to other
// coin/token contracts. If you want to create a standards-compliant
// token, see: https://github.com/ConsenSys/Tokens. Cheers!
contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
function MetaCoin() {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
Transfer(msg.sender, receiver, amount);
return true;
}
function getBalanceInEth(address addr) returns(uint){
return ConvertLib.convert(getBalance(addr),2);
}
function getBalance(address addr) returns(uint) {
return balances[addr];
}
}
pragma solidity ^0.4.4;
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
function Migrations() {
owner = msg.sender;
}
function setCompleted(uint completed) restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
var ConvertLib = artifacts.require("./ConvertLib.sol");
var MetaCoin = artifacts.require("./MetaCoin.sol");
module.exports = function(deployer) {
deployer.deploy(ConvertLib);
deployer.link(ConvertLib, MetaCoin);
deployer.deploy(MetaCoin);
};
{
"name": "lottery-symbol",
"version": "1.0.0",
"description": "An Ethereum DApp that allows people to enter a lottery to set its aesthetic properties.",
"main": " ",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack",
"dev": "webpack-dev-server --hot --inline --history-api-fallback"
},
"keywords": [
"ethereum",
"aesthetics"
],
"author": "Rob Myers <[email protected]>",
"license": "GPL-3.0+",
"devDependencies": {
"babel-loader": "^6.3.2",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.26.2",
"eslint": "^3.16.1",
"eslint-config-airbnb": "^14.1.0",
"eslint-loader": "^1.6.3",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"extract-text-webpack-plugin": "^2.0.0",
"react-hot-loader": "^1.3.1",
"sass-loader": "^6.0.2",
"style-loader": "^0.13.2",
"truffle-solidity-loader": "0.0.8",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
},
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2"
}
}
pragma solidity ^0.4.2;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/MetaCoin.sol";
contract TestMetacoin {
function testInitialBalanceUsingDeployedContract() {
MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin());
uint expected = 10000;
Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin initially");
}
function testInitialBalanceWithNewMetaCoin() {
MetaCoin meta = new MetaCoin();
uint expected = 10000;
Assert.equal(meta.getBalance(tx.origin), expected, "Owner should have 10000 MetaCoin initially");
}
}
var MetaCoin = artifacts.require("./MetaCoin.sol");
contract('MetaCoin', function(accounts) {
it("should put 10000 MetaCoin in the first account", function() {
return MetaCoin.deployed().then(function(instance) {
return instance.getBalance.call(accounts[0]);
}).then(function(balance) {
assert.equal(balance.valueOf(), 10000, "10000 wasn't in the first account");
});
});
it("should call a function that depends on a linked library", function() {
var meta;
var metaCoinBalance;
var metaCoinEthBalance;
return MetaCoin.deployed().then(function(instance) {
meta = instance;
return meta.getBalance.call(accounts[0]);
}).then(function(outCoinBalance) {
metaCoinBalance = outCoinBalance.toNumber();
return meta.getBalanceInEth.call(accounts[0]);
}).then(function(outCoinBalanceEth) {
metaCoinEthBalance = outCoinBalanceEth.toNumber();
}).then(function() {
assert.equal(metaCoinEthBalance, 2 * metaCoinBalance, "Library function returned unexpected function, linkage may be broken");
});
});
it("should send coin correctly", function() {
var meta;
// Get initial balances of first and second account.
var account_one = accounts[0];
var account_two = accounts[1];
var account_one_starting_balance;
var account_two_starting_balance;
var account_one_ending_balance;
var account_two_ending_balance;
var amount = 10;
return MetaCoin.deployed().then(function(instance) {
meta = instance;
return meta.getBalance.call(account_one);
}).then(function(balance) {
account_one_starting_balance = balance.toNumber();
return meta.getBalance.call(account_two);
}).then(function(balance) {
account_two_starting_balance = balance.toNumber();
return meta.sendCoin(account_two, amount, {from: account_one});
}).then(function() {
return meta.getBalance.call(account_one);
}).then(function(balance) {
account_one_ending_balance = balance.toNumber();
return meta.getBalance.call(account_two);
}).then(function(balance) {
account_two_ending_balance = balance.toNumber();
assert.equal(account_one_ending_balance, account_one_starting_balance - amount, "Amount wasn't correctly taken from the sender");
assert.equal(account_two_ending_balance, account_two_starting_balance + amount, "Amount wasn't correctly sent to the receiver");
});
});
});
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
const path = require('path');
const webpack = require("webpack");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: './app/js/app.jsx',
output: {
path: path.join(__dirname, "./build"),
filename: 'js/app.js'
},
module: {
loaders: [
{ test: /\.(js|jsx|es6)$/, exclude: /node_modules/,
loaders: ["react-hot-loader", "babel-loader", "eslint-loader"] },
{ test: /\.sol/, loader: 'truffle-solidity-loader' },
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('css-loader!sass-loader')
}
]
},
resolve: {
extensions: [".es6", ".js", ".jsx"]
},
plugins: [
new CopyWebpackPlugin([
{ from: './app/index.html', to: "index.html" },
// { from: './app/images', to: "images" },
// { from: './app/fonts', to: "fonts" }
]),
new ExtractTextPlugin({ filename: 'css/app.css', allChunks: true })
],
devServer: {
stats: 'errors-only',
}
};
{
"presets": ["react", "es2015"]
}
{
"extends": "airbnb",
"env": {
"browser": true,
"node": true
},
"rules": {
"no-console": ["error", { "allow": ["error"] }],
"react/forbid-prop-types": [0, { "forbid": ["array"] }],
"react/jsx-curly-spacing": [2, "always"],
"react/prefer-stateless-function": [0],
}
}
node_modules
contracts/Migrations.sol
\ No newline at end of file
{
"custom-rules-filename": null,
"rules": {
"imports-on-top": true,
"variable-declarations": true,
"array-declarations": true,
"operator-whitespace": true,
"lbrace": true,
"mixedcase": true,
"camelcase": true,
"uppercase": true,
"no-with": true,
"no-empty-blocks": true,
"no-unused-vars": true,
"double-quotes": true,
"blank-lines": true,
"indentation": true,
"whitespace": true,
"deprecated-suicide": true,
"pragma-on-top": true
}
}
\ No newline at end of file
var Web3 = require("web3");
var SolidityEvent = require("web3/lib/web3/event.js");
(function() {
// Planned for future features, logging, etc.
function Provider(provider) {
this.provider = provider;
}
Provider.prototype.send = function() {
this.provider.send.apply(this.provider, arguments);
};