Commit 8c43fa36 authored by Simon de la Rouviere's avatar Simon de la Rouviere

deep refactor into webpack + metamask/mist. ongoing

parent 4f19fc68
{
"ignore": ["*.min.js"],
"compact": false,
"presets": ["es2015", "react"]
}
......@@ -2,15 +2,10 @@
A dapp that allows for token issuance & management. The purpose for this at this point in time is to be nerdy & decentralized for MVP. Thus should be able to be run locally & remote or just through contracts.
Contracts & Tests are borrowed from Tokens repo. Using Truffle.
Contracts & Tests are borrowed from Tokens repo. Using Truffle (with Webpack).
See here on how to install this Truffle: https://github.com/ConsenSys/truffle/wiki/Using-Truffle-and-Webpack-(beta).
```npm install```
```truffle deploy``` (not always needed as .sol.js is written to development config)
Uglify does not play well with minifying ES6. The react-account-badge has a dependency, IPFS-API, which has a dependecny, "wreck" that has ES6 in it still. In order to remove this, I put the react-account-badge/dist/bundle.js through babel and dump it at rab_bundle.js. ie:
```babel node_modules/react-account-badge/dist/bundle.js --out-file rad_bundle.js```
Note. This can take about a minute to process. This is only for publishing/minifying reasons.
```npm install```
(In here you will need to run "npm run prepublish" in reflux-tx node module to create the lib folder).
```truffle serve```
......@@ -6,5 +6,7 @@
<script src="./app.js"></script>
</head>
<body>
<div id="main">
</div>
</body>
</html>
//for Mist & Metamask support
var Web3 = require("web3");
var Pudding = require("ether-pudding");
var exported = null;
// Bootstrap
if (typeof web3 !== 'undefined') {
// Use the Mist/wallet provider.
exported = new Web3(web3.currentProvider);
} else {
// Use the provider from the config.
// ENV and WEB3_PROVIDER_LOCATION are rewritten by webpack during build
if (ENV == "development") {
exported = new Web3(new Web3.providers.HttpProvider(WEB3_PROVIDER_LOCATION));
}
}
Pudding.setWeb3(exported);
module.exports = exported;
import React from "react";
import {TXComponent} from "reflux-tx";
import TxForm from "./txform.jsx";
var FactoryPage = React.createClass({
getInitialState: function() {
return {
......@@ -5,7 +9,7 @@ var FactoryPage = React.createClass({
}
},
successOnCreation: function(args, receipt) {
histor.pushState(null, '/token/' + receipt.contractAddress);
this.props.history.pushState(null, '/token/' + receipt.contractAddress);
},
render: function() {
return (
......@@ -25,4 +29,4 @@ var FactoryPage = React.createClass({
}
});
window.FactoryPage = FactoryPage;
module.exports = FactoryPage;
import React from 'react';
import { Link } from 'react-router';
var FrontPage = React.createClass({
render: function() {
return (
......@@ -13,4 +16,4 @@ var FrontPage = React.createClass({
}
});
window.FrontPage = FrontPage;
module.exports = FrontPage;
//this is a hack currently.
//The normal ProvidePlugin doesn't seem to work here. Not sure why.
//If done through ProvidePlugin, it keeps producing a zillion warnings
//See babel-loader in Webpack: https://github.com/babel/babel-loader/issues/23
require('babel-runtime/core-js/promise').default = require('bluebird');
require('./main.jsx');
import React from "react";
var InputForm = React.createClass({
getInitialState: function() {
return {
......@@ -15,4 +17,4 @@ var InputForm = React.createClass({
);
}
});
window.InputForm = InputForm;
module.exports = InputForm;
window.Route = ReactRouter.Route;
window.Router = ReactRouter.Router;
window.IndexRoute = ReactRouter.IndexRoute;
window.Link = ReactRouter.Link;
window.TXActions = refluxTX.TXActions;
window.TXComponent = refluxTX.TXComponent;
TXActions.connect({provider: 'http://localhost:8545', confirmCount: 1, bufferSize: 5})
window.web3_rab = new Web3();
console.log(web3);
web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); //default provider until overwritten.
window.AccountBadge = accountBadge.AccountBadge;
window.AccountStore = accountBadge.AccountStore;
import {} from "../stylesheets/app.scss";
import React from "react";
import ReactDOM from "react-dom";
import ReactRouter from "react-router";
import { Router, Route, IndexRoute, Link } from 'react-router';
import { TXActions } from 'reflux-tx';
//import TXActions from "reflux-tx".TXActions;
//import TXComponent from "reflux-tx".TXComponent;
//import AccountBadge from "react-account-badge";
var web3 = require("./bootstrap.js");
//import Web3 from "web3";
//web3? Apparently it is "provided"?
import NavBar from "./navbar.jsx";
import FactoryPage from "./factorypage.jsx";
import FrontPage from "./frontpage.jsx";
import TokenPage from "./tokenpage.jsx";
import TokenSearchPage from "./tokensearchpage.jsx";
//feels like webpack anti-pattern??
//window.Route = ReactRouter.Route;
//window.Router = ReactRouter.Router;
//window.IndexRoute = ReactRouter.IndexRoute;
//window.Link = ReactRouter.Link;
//window.TXActions = refluxTX.TXActions;
//window.TXComponent = refluxTX.TXComponent;
console.log(TXActions);
TXActions.connect(web3, {confirmCount: 1, bufferSize: 5})
//window.web3_rab = new Web3();
//console.log(web3);
//web3 = new Web3();
//web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545')); //default provider until overwritten.
//window.AccountBadge = accountBadge.AccountBadge;
//window.AccountStore = accountBadge.AccountStore;
//remove _k thing from URLS (removing queryKey)
window.histor = History.createHashHistory({
import createHistory from 'history/lib/createHashHistory';
//window.histor = History.createHashHistory({
let history = createHistory({
queryKey: false
});
var App = React.createClass({
let App = React.createClass({
render: function() {
return (
<div className="container">
......@@ -37,10 +64,10 @@ var App = React.createClass({
window.onload = function() {
// check if RPC is online. Why though?
web3.eth.getCoinbase(function(error, coinbase) {
window.MainRouter = Router;
//window.MainRouter = Router;
ReactDOM.render((
//React.render((
<Router history={histor}>
<Router history={history}>
<Route path="/" component={App}>
<IndexRoute component={FrontPage} />
<Route path="/tokensearch" component={TokenSearchPage} />
......@@ -48,7 +75,7 @@ window.onload = function() {
<Route path="/token/:contract_address" component={TokenPage} />
</Route>
</Router>
), document.body);
), document.getElementById('main'));
});
};
import React from "react";
import { Link } from "react-router";
//import AccountBadge from "react-account-badge";
//<AccountBadge web3={web3_rab} />
var NavBar = React.createClass({
render: function() {
return (
......@@ -21,8 +25,8 @@ var NavBar = React.createClass({
<li><Link to={'/factory'}>Create Token Contract</Link></li>
</ul>
<AccountBadge web3={web3_rab} />
</div>
</div>
</nav>
......@@ -31,4 +35,4 @@ var NavBar = React.createClass({
}
});
window.NavBar = NavBar;
module.exports = NavBar;
import React from "react";
var TokenPage = React.createClass({
getInitialState: function() {
return {
......@@ -13,7 +16,8 @@ var TokenPage = React.createClass({
},
componentDidMount: function() {
this.setState({contract_address: this.props.params.contract_address});
var web3_token = web3_rab.eth.contract(Standard_Token.abi).at(this.props.params.contract_address); //for reflux-tx
//var web3_token = web3_rab.eth.contract(Standard_Token.abi).at(this.props.params.contract_address); //for reflux-tx
var web3_token = web3.eth.contract(Standard_Token.abi).at(this.props.params.contract_address); //for reflux-tx
this.setState({web3_token: web3_token});
var addr = AccountStore.getSelectedAddress();
var totalSupply = web3_token.totalSupply.call({from: addr});
......@@ -150,4 +154,4 @@ var TokenPage = React.createClass({
}
});
window.TokenPage = TokenPage;
module.exports = TokenPage;
import React from "react";
var TokenSearchPage = React.createClass({
getInitialState: function() {
return {
......@@ -24,4 +26,4 @@ var TokenSearchPage = React.createClass({
}
});
window.TokenSearchPage = TokenSearchPage;
module.exports = TokenSearchPage;
import React from "react";
import InputForm from "./inputform.jsx";
var TxForm = React.createClass({
getInitialState: function() {
return {
......@@ -40,7 +43,7 @@ var TxForm = React.createClass({
//for now, just collect arguments in order.
//otherwise do something else (like passing a function as a prop)
args = [];
var args = [];
for(var i = 0; i < this.props.inputs.length; i+=1) {
args.push(this.refs[this.props.inputs[i].ref].state.val);
}
......@@ -51,7 +54,7 @@ var TxForm = React.createClass({
if(typeof this.props.web3_token == 'undefined') {
//token creation execution
console.log('creating');
var ST = web3_rab.eth.contract(Standard_Token.abi);
var ST = web3.eth.contract(Standard_Token.abi);
var tx_hash = null;
var that = this;
//var creation_data = ST.new.getData(args[0], {data: Standard_Token.binary});
......@@ -113,4 +116,4 @@ var TxForm = React.createClass({
);
}
});
window.TxForm = TxForm;
module.exports = TxForm;
@import "../../node_modules/bootstrap/dist/css/bootstrap.css";
body { padding-top: 70px; }
{
"presets": [
"es2015"
]
}
node_modules
.DS_Store
# Persona
## About
The Persona contract is a simple representation of a Persona AKA a uPort U. The current fields in the Persona contract corresponding to an Owner address is
* Owner Ethereum address
* Full Name
* Profile Picture
The Full Name and Profile Picture is stored in IPFS as a JSON structure that corresponds to the [Schema.org Person schema](http://schema.org/Person):
```
{
'personSchema' :
{
'name': 'Christian Lundkvist',
'image': {'@type': 'ImageObject',
'name': 'avatar',
'contentUrl' : 'ipfs/QmUSBKeGYPmeHmLDAEHknAm5mFEvPhy2ekJc6sJwtrQ6nk'}
}
}
```
and a hash of this structure is stored in the contract as a `string`. Later on this structure will include more information, and we might want the root hash to be pointing at a commit object in a whole versioned filesystem. We also allow other Dapps to add top-level entries to attach Dapp-specific attributes to the Persona.
## Persona Library
The Persona Library allows you to create and/or view Personas in your Dapp. You need to set a web3 provider using `Persona.setWeb3Provider` in order to access the Ethereum contracts, and you need to set an Ipfs provider using `Persona.setIpfsProvider` to access data stored in IPFS. You also need to set the registry used for Persona lookups by using `Persona.setRegistry()`. This is currently defaulted to the PersonaRegistry used on the ConsenSys testnet.
### Example
See the files `app/index.html` and the corresponding `app/javascripts/app.js` for an example of how to use the Persona Library.
### Usage
To use the Persona library, first include it in your project:
**Node**
```javascript
var Persona = require("persona");
```
Then, setup your Persona object using the code below. IMPORTANT: if you are using
this module for browser, you should configure you Persona object differently (see
code below for Browser).
```javascript
var ipfsApi = require('ipfs-api');
var web3 = require('web3');
Persona.setIpfsProvider(ipfsApi(<hostname>, <port>));
Persona.setWeb3Provider(new web3.providers.HttpProvider('http://localhost:8545'));
```
**Browser**
```html
<!-- Persona library. -->
<script type="text/javascript" src="./dist/persona.js"></script>
```
Configure your Persona object using the code below. IMPORTANT: see that this code
is only valid if you will use it on Browsers (see above).
```javascript
Persona.setIpfsProvider({host: <hostname>, port: <port>});
Persona.setWeb3Provider('http://localhost:8545');
```
### Creating a Persona
```javascript
Persona.newPersona({
'personSchema' :
{
'name': 'Christian Lundkvist',
'image': {'@type': 'ImageObject',
'name': 'avatar',
'contentUrl' : 'ipfs/QmUSBKeGYPmeHmLDAEHknAm5mFEvPhy2ekJc6sJwtrQ6nk'}
}
}).then(function(persona) {
// You now have a persona object stored on the blockchain
// and on ipfs.
console.log(persona.address); // address of persona on blockchain
});
```
### Getting Persona Information
If you have an address of the current Ethereum user, you can get their persona info using the command `Persona.of(address)`. This command looks up the persona contract from the Persona registry. The Persona registry can be set using the `Persona.setRegistry` command.
```javascript
Persona.setRegistry(registryAddress);
web3.getCoinbase(function(err, coinbase) {
Persona.of(coinbase).then(function(persona) {
// You now have a persona object. You can use this to pull information
// off of ipfs to get the persona avatar and JSON information.
// Note: We're using promises here.
return persona.getInfo();
}).then(function(info) {
// This will log something like the original blob passed in:
// {
// 'personSchema' :
// {
// 'name': 'Christian Lundkvist',
// 'image': {'@type': 'ImageObject',
// 'name': 'avatar',
// 'contentUrl' : 'ipfs/QmUSBKeGYPmeHmLDAEHknAm5mFEvPhy2ekJc6sJwtrQ6nk'}
// }
// }
console.log(info);
});
});
```
## Getting started with the demo
The Persona demo uses LightWallet and a remote IPFS node so that you don't have to run your own ethereum client or IPFS client.
### Running from remote server
Access the dapp at `http://104.236.65.136:3000`.
### Running locally
This will still use the remote IPFS and ethereum servers by default. If you want to run your own ethereum and/or IPFS server, modify the variables `ipfsHost` or `web3Host` in the file `app/javascripts/app.js` before you build.
To build and run:
```
git clone https://github.com/ConsenSys/persona.git
cd persona
sudo npm install
npm run build
python -m SimpleHTTPServer 3000
```
Now you can access the Dapp at `http://localhost:3000/app/index.html`.
## Usage of the browser example dapp
If you already have a LightWallet seed, enter it in and hit "Set Seed". This will show the first address corresponding to that seed. Make sure you have some Ether in the address.
To create a new persona, Simply enter your name, and upload your profile picture. Then hit "Submit Persona". You should receive a message "New Persona created!".
To view an existing Persona, enter the contract address under "Persona Identifier". This will show you the Full Name and the profile picture.
This diff is collapsed.
window.onload = function() {
// SETUP AREA
// Configuration settings
// requires config.js to be loaded
var selected_network = config.selection;
var serviceHost = config[selected_network].serviceHost;
var globalRegistryAddress = config[selected_network].personaRegistry;
var ethRpcPort = '8545'
var ipfsPort = '5001'
var ipfsWebPort = '8080'
var ipfsHost = {host: serviceHost, port : ipfsPort}
var web3Host = 'http://' + serviceHost + ':' + ethRpcPort
// temporary web3provider so we
// can do the lookup without setting the seed
console.log('Web3 host:' + web3Host);
var web3 = new Web3();
var web3Prov = new web3.providers.HttpProvider(web3Host);
web3.setProvider(web3Prov);
ipfs.setProvider(ipfsHost);
Persona.setWeb3Provider(web3Prov);
Persona.setIpfsProvider(ipfsHost);
var ipfsWeb = 'http://' + serviceHost + ':' + ipfsWebPort
//var ipfsWeb = 'http://gateway.ipfs.io'
var globalAddress = ''
// WINDOW FUNCTIONS
window.getBalance = function(addr) {
addr = addr || globalAddress;
web3.eth.getBalance(addr, function(err, bal){
web3.eth.getTransactionCount(addr, function(err, nonce) {
//******************
document.getElementById('addr').value = addr + ' (Balance: ' + (bal / 1.0e18) + ' ETH, Nonce: ' + nonce + ')'
//******************
})
})
}
window.setSeed = function() {
var seed = document.getElementById('seed').value;
var password = prompt('Select a password to protect your seed', 'Enter Password');
var keystore = new lightwallet.keystore(seed, password)
keystore.generateNewAddress(password)
globalAddress = '0x' + keystore.getAddresses()[0]
//Use default passwordProvider
keystore.passwordProvider = function (callback) {callback(null, password)}
var web3Prov = new HookedWeb3Provider({
host: web3Host,
transaction_signer: keystore
});
// // workaround for testrpc issues
// var web3Prov = new web3.providers.HttpProvider(web3Host)
// globalAddress = '0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1'
web3.setProvider(web3Prov);
Persona.setWeb3Provider(web3Prov);
getBalance(globalAddress);
// When using a host not on the consensys testnet, can use this
// to register a new registry
// newRegistry(function (err, regAddr) {
// globalRegistryAddress = regAddr;
// console.log(regAddr);
// })
Persona.setRegistry(globalRegistryAddress);
}
window.randomSeed = function() {
var randomSeed = lightwallet.keystore.generateRandomSeed()
document.getElementById('seed').value = randomSeed
}
window.fundWallet = function() {
var testRpcAddr = '0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1'
web3.eth.getBalance(testRpcAddr, function (err, rpcBal) {
if (rpcBal.toNumber() !== 0) {
// testrpc
console.log('rpc 0');
web3.eth.sendTransaction({from: testRpcAddr, to:globalAddress, value: 1000*1.0e18}, function () {});
}
else {
// ConsenSys testnet
console.log('request');
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://testnet.consensys.net/faucet', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded', 'charset=UTF-8')
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
console.log('Paid');
getBalance(globalAddress);
}
else {
console.log(xhr.status);
}
};
xhr.send('address=' + globalAddress);
}
})
}
// This function is called when an image file
// is uploaded
window.ipfsAddImageHandler = function(evt) {
var input = evt.target;
if (input.files && input.files[0]) {
var file = evt.target.files[0];
var reader = new FileReader();
reader.onload = function (e) {
// Split the DataURL to get the raw base64 data
var buf = new buffer.Buffer(e.target.result.split(',')[1], 'base64');
ipfs.add(buf, function (err, hash) {
document.getElementById('inputImageHash').value = hash;
});
};
reader.readAsDataURL(input.files[0]);
}
}
window.uiSubmitNewPersona = function() {
var name = document.getElementById('inputName').value;
var personSchema = {
name: name,
image: {"@type": "ImageObject",
"name" : "avatar",
"contentUrl" : "ipfs/" + document.getElementById('inputImageHash').value
}
};
var info = {
"personSchema": personSchema
}
Persona.newPersona(
info,
{
from: globalAddress,
gas: 1000000,
gasPrice: 200000000000
},
function(err, persona) {
console.log(persona);
//******************
document.getElementById('outputPersonaAddress').value = persona.address;
//******************
});
}
window.uiGetPersonaData = function() {
var userAddress = document.getElementById('inputPersonaAddress').value;
Persona.of(userAddress).then(function(persona) {
return persona.getInfo("personSchema");
}).then(function(info) {
var outputImage = document.getElementById("outputImage");
var outputImageHash = document.getElementById("outputImageHash");
//******************
document.getElementById('outputName').value = info.name;
//******************
outputImage.setAttribute("src", ipfsWeb + '/' + info.image.contentUrl);
outputImageHash.value = info.image.contentUrl;
outputImage.setAttribute("width", 200);
});
};
window.newRegistry = function(callback) {
PersonaRegistry.new({
from: globalAddress,
gas: 1000000,
gasPrice: 80000000000})
.then(function(reg) {
console.log(reg.address);
callback(null, reg.address);
});
};
document.getElementById('inputImageFile').addEventListener('change', ipfsAddImageHandler, false);
};
This diff is collapsed.
config = {
mainnet : {
serviceHost: '104.131.53.68',
personaRegistry: '0x8b5429bdf4e24f508154aa864675a007e618e79e'
},
consensys_testnet : {
serviceHost: '104.236.65.136',
personaRegistry: '0x0cd8bfb176e1f7e41a19504afd0244c0972de2fa'
},
local : {
serviceHost: 'localhost',
personaRegistry: '0x2594e7b9305a6fd4beae5ab9f5f7deb17e1d6014'
},
selection: "consensys_testnet"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
// Required Modules
var ipfs = require('ipfs');
var PromiseLib = require('bluebird');
var PersonaFactory = (PersonaClass, PersonaRegistry) => {
// NOTES
// At run time, there's a class created for us already called
// PersonaClass, provided by Truffle. That class represents the
// PersonaClass contract. The following adds functions to it to make
// it the main point of contact for interacting with personas.
var oldNew = PersonaClass.new; // What is meant by oldNew?
var registryInstance = PersonaRegistry.at(PersonaRegistry.deployed_address);
PersonaClass.prototype.version = '0.2';
// QUESTION: Will people use this?
PersonaClass.prototype.setRegistry = (registryAddress) => {
registryInstance = PersonaRegistry.at(registryAddress);
};
PersonaClass.prototype.of = PromiseLib.promisify( (ownerAddress, callback) => {
registryInstance
.idLookup
.call(ownerAddress)
.then( (personaAddress) => {
callback(null, PersonaClass.at(personaAddress)); })
.catch(callback);
});
PersonaClass.prototype.new = PromiseLib.promisify( (info, txData, callback) => {
if (typeof txData === 'function') {
callback = txData;
txData = {};
}
// NOTES
// info should be a JSON structure with attributes about the persona,
// with top-level keys being classes of attributes. The main class now
// will be 'personSchema' which denotes data corresponding to the
// Schema.org Person spec.
// {
// 'personSchema' :
// {
// 'name': 'Tim Coulter',
// 'image': {'@type': 'ImageObject',
// 'name': 'avatar',
// 'contentUrl' : 'ipfs/QmX...'}
// }
// }
// This info hash will be the same one users get back by calling
// persona.getInfo().
ipfs.addJson(info, (err, ipfsHash) => {
// console.log(err, ipfsHash);
if (err !== null) { reject(err); return; }
var persona = null; // QUESTION: Does this actually get passed to the next step?
oldNew(ipfsHash, txData).then( (instance) => {
// console.log(instance);
persona = instance;
return registryInstance.registerPersona(persona.address, txData);
}).then(function(tx) { callback(null, persona); // QUESTION: passing tx for no reason?
}).catch(callback);
});
});
PersonaClass.prototype.extend({
getInfo(attributeClass) {
return new PromiseLib( (accept, reject) => {
this.ipfsHash.call().then( (ipfsHash) => {
ipfs.catJson(ipfsHash, (err, personaObj) => {
if (err !== null) { reject(err); return; }
var returnVal;
attributeClass === undefined ?
returnVal = personaObj :
returnVal = personaObj[attributeClass];
accept(returnVal);
})
}).catch(reject);
});
}
});
return PersonaClass;
}
typeof module !== 'undefined' ?
module.exports = PersonaFactory(PersonaClass, PersonaRegistry):
window.Persona = PersonaFactory(PersonaClass, PersonaRegistry);
{
"build": {
// Copy ./app/index.html (right hand side) to ./build/index.html.
"index.html": "index.html",
"persona.js": {
"files": [
"javascripts/persona.es6"
],
"post-process": [
"include-contracts"
]
},
"demo.js": {
"files": [
"../node_modules/ipfs-js/ipfs.min.js",
"../node_modules/hooked-web3-provider/build/hooked-web3-provider.js",
"javascripts/ethlightjs.min.js",
"javascripts/buffer.js",
"../build/persona.js",
"javascripts/app.js"
],
"post-process": [
"frontend-dependencies"
]
},
"demo.css": [
// Paths relative to "app" directory that should be
// concatenated and processed during build.
"stylesheets/app.css"
]
},
"deploy": [
"PersonaRegistry"
],
"rpc": {
"host": "localhost",
"port": 8545
}
}
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var Example = (function (_Pudding) {
_inherits(Example, _Pudding);
function Example() {
_classCallCheck(this, Example);
_get(Object.getPrototypeOf(Example.prototype), "constructor", this).apply(this, arguments);
}
return Example;
})(Pudding);
;
// Set up specific data for this class.
Example.abi = [{ "inputs": [], "type": "constructor" }];
Example.binary = "606060405260068060106000396000f3606060405200";
if ("" != "") {
Example.address = "";
// Backward compatibility; Deprecated.
Example.deployed_address = "";
}
Example.generated_with = "1.0.2";
Example.contract_name = "Example";
return Example;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.Example = factory;
}
\ No newline at end of file
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var Persona = (function (_Pudding) {
_inherits(Persona, _Pudding);
function Persona() {
_classCallCheck(this, Persona);
_get(Object.getPrototypeOf(Persona.prototype), "constructor", this).apply(this, arguments);
}
return Persona;
})(Pudding);
;
// Set up specific data for this class.
Persona.abi = [{ "constant": true, "inputs": [], "name": "isRevoked", "outputs": [{ "name": "", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_ipfsHash", "type": "string" }], "name": "setIpfsHash", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "version", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [], "name": "revoke", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "ipfsHash", "outputs": [{ "name": "", "type": "string" }], "type": "function" }, { "constant": true, "inputs": [], "name": "revocationTimestamp", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "inputs": [{ "name": "_ipfsHash", "type": "string" }], "type": "constructor" }];
Persona.binary = "60606040526040516103e63803806103e68339810160405280510160605160008054600160a060020a0319163317815582516001805492819052926020601f6002600019868816156101000201909516949094048401047fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6908101939091608001908390106100d557805160ff19168380011785555b506100b09291505b808211156101055760008155830161009d565b5050600060028190556003805460ff19169055600455506102dd806101096000396000f35b82800160010185558215610095579182015b828111156100955782518260005055916020019190600101906100e7565b509056606060405236156100615760e060020a60003504632bc9ed0281146100635780634e3b62ec1461006f57806354fd4d501461013c5780638da5cb5b14610145578063b6549f7514610157578063c623674f14610194578063e322a468146101ef575b005b6101f860035460ff1681565b60206004803580820135601f81018490049093026080908101604052606084815261006194602493919291840191819083828082843750949650505050505050600054600160a060020a03908116339091161480156100d1575060035460ff16155b15610273578060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061027657805160ff19168380011785555b506102709291505b808211156102a657600081558301610129565b6101f860025481565b6101f8600054600160a060020a031681565b61006160005433600160a060020a03908116911614801561017b575060035460ff16155b15610192576003805460ff19166001179055426004555b565b610202600180546020601f6002600019610100858716150201909316929092049182018190040260809081016040526060828152929190828280156102d55780601f106102aa576101008083540402835291602001916102d5565b6101f860045481565b6060908152602090f35b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156102625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b50505b50565b82800160010185558215610121579182015b82811115610121578251826000505591602001919060010190610288565b5090565b820191906000526020600020905b8154815290600101906020018083116102b857829003601f168201915b50505050508156";
if ("" != "") {
Persona.address = "";
// Backward compatibility; Deprecated.
Persona.deployed_address = "";
}
Persona.generated_with = "1.0.2";
Persona.contract_name = "Persona";
return Persona;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.Persona = factory;
}
\ No newline at end of file
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var PersonaRegistry = (function (_Pudding) {
_inherits(PersonaRegistry, _Pudding);
function PersonaRegistry() {
_classCallCheck(this, PersonaRegistry);
_get(Object.getPrototypeOf(PersonaRegistry.prototype), "constructor", this).apply(this, arguments);
}
return PersonaRegistry;
})(Pudding);
;
// Set up specific data for this class.
PersonaRegistry.abi = [{ "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "idLookup", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "contractAddress", "type": "address" }], "name": "registerPersona", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "version", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [], "name": "removePersona", "outputs": [], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "uint256" }], "name": "idList", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [], "name": "getIdList", "outputs": [{ "name": "", "type": "address[]" }], "type": "function" }, { "inputs": [], "type": "constructor" }];
PersonaRegistry.binary = "6060604052600060028190556001805482825582908015829011604057818360005260206000209182019101604091905b8082111560525783815584016030565b5050505061044e806100566000396000f35b509056606060405236156100565760e060020a600035046318357c6d811461005857806348d665b31461007957806354fd4d50146101495780635cee14d1146101525780636313531f1461027a578063ac0fc11c146102ae575b005b61031c600435600060208190529081526040902054600160a060020a031681565b6100566004356000600082915081600160a060020a0316638da5cb5b6040518160e060020a0281526004018090506020604051808303816000876161da5a03f11561000257505060405151915050600160a060020a0381811633909116141561041457600160a060020a0381811660009081526020819052604081205490911614156103eb57600180548082018083559091908280158290116103955760008390526103959060008051602061042e8339815191529081019083015b808211156104195760008155600101610135565b61033960025481565b33600160a060020a0390811660009081526020819052604081205461005692829116811461019a57604081208054600160a060020a03198116909155600160a060020a031691505b5060005b60015481101561041d5733600160a060020a031660016000508281548110156100025760009190915260008051602061042e8339815191520154600160a060020a03161415610426576001805460001981019081101561000257815460008051602061042e8339815191529190910154600160a060020a0316919083908110156100025760008051602061042e833981519152018054600160a060020a0319169290921790915580546000198101808355909190828015829011610421576104219060008051602061042e833981519152908101908301610135565b61031c600435600180548290811015610002575060005260008051602061042e8339815191520154600160a060020a031681565b61034b60408051602081810183526000825282516001805480840283018401909552848252929390929183018282801561031257602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116102f3575b5050505050905090565b60408051600160a060020a03929092168252519081900360200190f35b60408051918252519081900360200190f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b505060018054849350909150600019810190811015610002575080546000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf5018054600160a060020a03191690911790555b600160a060020a03811660009081526020819052604090208054600160a060020a031916841790555b505050565b5090565b5050565b505050505b60010161019e56b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6";
if ("0x2594e7b9305a6fd4beae5ab9f5f7deb17e1d6014" != "") {
PersonaRegistry.address = "0x2594e7b9305a6fd4beae5ab9f5f7deb17e1d6014";
// Backward compatibility; Deprecated.
PersonaRegistry.deployed_address = "0x2594e7b9305a6fd4beae5ab9f5f7deb17e1d6014";
}
PersonaRegistry.generated_with = "1.0.2";
PersonaRegistry.contract_name = "PersonaRegistry";
return PersonaRegistry;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.PersonaRegistry = factory;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
{
"rpc": {
"host": "104.236.65.136",
"port": 8545
}
}
This diff is collapsed.
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var Example = (function (_Pudding) {
_inherits(Example, _Pudding);
function Example() {
_classCallCheck(this, Example);
_get(Object.getPrototypeOf(Example.prototype), "constructor", this).apply(this, arguments);
}
return Example;
})(Pudding);
;
// Set up specific data for this class.
Example.abi = [{ "inputs": [], "type": "constructor" }];
Example.binary = "606060405260068060106000396000f3606060405200";
if ("" != "") {
Example.address = "";
// Backward compatibility; Deprecated.
Example.deployed_address = "";
}
Example.generated_with = "1.0.2";
Example.contract_name = "Example";
return Example;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.Example = factory;
}
\ No newline at end of file
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var Persona = (function (_Pudding) {
_inherits(Persona, _Pudding);
function Persona() {
_classCallCheck(this, Persona);
_get(Object.getPrototypeOf(Persona.prototype), "constructor", this).apply(this, arguments);
}
return Persona;
})(Pudding);
;
// Set up specific data for this class.
Persona.abi = [{ "constant": true, "inputs": [], "name": "isRevoked", "outputs": [{ "name": "", "type": "bool" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "_ipfsHash", "type": "string" }], "name": "setIpfsHash", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "version", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [], "name": "revoke", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "ipfsHash", "outputs": [{ "name": "", "type": "string" }], "type": "function" }, { "constant": true, "inputs": [], "name": "revocationTimestamp", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "inputs": [{ "name": "_ipfsHash", "type": "string" }], "type": "constructor" }];
Persona.binary = "60606040526040516103e63803806103e68339810160405280510160605160008054600160a060020a0319163317815582516001805492819052926020601f6002600019868816156101000201909516949094048401047fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6908101939091608001908390106100d557805160ff19168380011785555b506100b09291505b808211156101055760008155830161009d565b5050600060028190556003805460ff19169055600455506102dd806101096000396000f35b82800160010185558215610095579182015b828111156100955782518260005055916020019190600101906100e7565b509056606060405236156100615760e060020a60003504632bc9ed0281146100635780634e3b62ec1461006f57806354fd4d501461013c5780638da5cb5b14610145578063b6549f7514610157578063c623674f14610194578063e322a468146101ef575b005b6101f860035460ff1681565b60206004803580820135601f81018490049093026080908101604052606084815261006194602493919291840191819083828082843750949650505050505050600054600160a060020a03908116339091161480156100d1575060035460ff16155b15610273578060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061027657805160ff19168380011785555b506102709291505b808211156102a657600081558301610129565b6101f860025481565b6101f8600054600160a060020a031681565b61006160005433600160a060020a03908116911614801561017b575060035460ff16155b15610192576003805460ff19166001179055426004555b565b610202600180546020601f6002600019610100858716150201909316929092049182018190040260809081016040526060828152929190828280156102d55780601f106102aa576101008083540402835291602001916102d5565b6101f860045481565b6060908152602090f35b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156102625780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b50505b50565b82800160010185558215610121579182015b82811115610121578251826000505591602001919060010190610288565b5090565b820191906000526020600020905b8154815290600101906020018083116102b857829003601f168201915b50505050508156";
if ("" != "") {
Persona.address = "";
// Backward compatibility; Deprecated.
Persona.deployed_address = "";
}
Persona.generated_with = "1.0.2";
Persona.contract_name = "Persona";
return Persona;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.Persona = factory;
}
\ No newline at end of file
"use strict";
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var factory = function factory(Pudding) {
// Inherit from Pudding. The dependency on Babel sucks, but it's
// the easiest way to extend a Babel-based class. Note that the
// resulting .js file does not have a dependency on Babel.
var PersonaRegistry = (function (_Pudding) {
_inherits(PersonaRegistry, _Pudding);
function PersonaRegistry() {
_classCallCheck(this, PersonaRegistry);
_get(Object.getPrototypeOf(PersonaRegistry.prototype), "constructor", this).apply(this, arguments);
}
return PersonaRegistry;
})(Pudding);
;
// Set up specific data for this class.
PersonaRegistry.abi = [{ "constant": true, "inputs": [{ "name": "", "type": "address" }], "name": "idLookup", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [{ "name": "contractAddress", "type": "address" }], "name": "registerPersona", "outputs": [], "type": "function" }, { "constant": true, "inputs": [], "name": "version", "outputs": [{ "name": "", "type": "uint256" }], "type": "function" }, { "constant": false, "inputs": [], "name": "removePersona", "outputs": [], "type": "function" }, { "constant": true, "inputs": [{ "name": "", "type": "uint256" }], "name": "idList", "outputs": [{ "name": "", "type": "address" }], "type": "function" }, { "constant": false, "inputs": [], "name": "getIdList", "outputs": [{ "name": "", "type": "address[]" }], "type": "function" }, { "inputs": [], "type": "constructor" }];
PersonaRegistry.binary = "6060604052600060028190556001805482825582908015829011604057818360005260206000209182019101604091905b8082111560525783815584016030565b5050505061044e806100566000396000f35b509056606060405236156100565760e060020a600035046318357c6d811461005857806348d665b31461007957806354fd4d50146101495780635cee14d1146101525780636313531f1461027a578063ac0fc11c146102ae575b005b61031c600435600060208190529081526040902054600160a060020a031681565b6100566004356000600082915081600160a060020a0316638da5cb5b6040518160e060020a0281526004018090506020604051808303816000876161da5a03f11561000257505060405151915050600160a060020a0381811633909116141561041457600160a060020a0381811660009081526020819052604081205490911614156103eb57600180548082018083559091908280158290116103955760008390526103959060008051602061042e8339815191529081019083015b808211156104195760008155600101610135565b61033960025481565b33600160a060020a0390811660009081526020819052604081205461005692829116811461019a57604081208054600160a060020a03198116909155600160a060020a031691505b5060005b60015481101561041d5733600160a060020a031660016000508281548110156100025760009190915260008051602061042e8339815191520154600160a060020a03161415610426576001805460001981019081101561000257815460008051602061042e8339815191529190910154600160a060020a0316919083908110156100025760008051602061042e833981519152018054600160a060020a0319169290921790915580546000198101808355909190828015829011610421576104219060008051602061042e833981519152908101908301610135565b61031c600435600180548290811015610002575060005260008051602061042e8339815191520154600160a060020a031681565b61034b60408051602081810183526000825282516001805480840283018401909552848252929390929183018282801561031257602002820191906000526020600020905b8154600160a060020a03168152600191909101906020018083116102f3575b5050505050905090565b60408051600160a060020a03929092168252519081900360200190f35b60408051918252519081900360200190f35b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b505060018054849350909150600019810190811015610002575080546000919091527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf5018054600160a060020a03191690911790555b600160a060020a03811660009081526020819052604090208054600160a060020a031916841790555b505050565b5090565b5050565b505050505b60010161019e56b10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6";
if ("0xcd7e9bfd1c57db21e2b4f1e220d371a716079fea" != "") {
PersonaRegistry.address = "0xcd7e9bfd1c57db21e2b4f1e220d371a716079fea";
// Backward compatibility; Deprecated.
PersonaRegistry.deployed_address = "0xcd7e9bfd1c57db21e2b4f1e220d371a716079fea";
}
PersonaRegistry.generated_with = "1.0.2";
PersonaRegistry.contract_name = "PersonaRegistry";
return PersonaRegistry;
};
// Nicety for Node.
factory.load = factory;
if (typeof module != "undefined") {
module.exports = factory;
} else {
// There will only be one version of Pudding in the browser,
// and we can use that.
window.PersonaRegistry = factory;
}
\ No newline at end of file
This diff is collapsed.
contract Example {
function Example() {
// constructor
}
}
contract Persona {
address public owner;
string public ipfsHash;
// For versioning
uint public version;
// For revocation/upgrading/migration
bool public isRevoked;
uint public revocationTimestamp;
modifier ownerNonRevoked { if (msg.sender == owner && !isRevoked) _ }
function Persona(string _ipfsHash) {
owner = msg.sender;
ipfsHash = _ipfsHash;
version = 0;
isRevoked = false;
revocationTimestamp = 0;
}
function setIpfsHash(string _ipfsHash) ownerNonRevoked {
ipfsHash = _ipfsHash;
}
function revoke() ownerNonRevoked {
isRevoked = true;
revocationTimestamp = block.timestamp;
}
}
contract Persona {
address public owner;
}
contract PersonaRegistry {
mapping(address => address) public idLookup;
address[] public idList;
uint public version;
function PersonaRegistry() {
version = 0;
idList.length = 0;
}
function registerPersona(address contractAddress) {
Persona p = Persona(contractAddress);
address _owner = p.owner();
if (_owner == msg.sender) {
if (idLookup[_owner] == 0) {
idList.length++;
idList[idList.length-1] = _owner;
}
idLookup[_owner] = contractAddress;
}
}
function getIdList() returns (address[]){
return idList;
}
function removePersona() {
if (idLookup[msg.sender] != 0) {
Persona p = Persona(idLookup[msg.sender]);
idLookup[msg.sender] = 0;
}
for(uint i = 0; i < idList.length; i++) {
if(idList[i] == msg.sender) {
idList[i] = idList[idList.length-1];
idList.length--;
}
}
}
}
This diff is collapsed.
// Required Modules
var ipfs = require('ipfs-js');
var PromiseLib = require('bluebird');
var Pudding = require('ether-pudding');
var Web3 = require('web3');
var web3 = new Web3();
Pudding.setWeb3(web3);
var PersonaFactory = (PersonaClass, PersonaRegistry) => {
// NOTES
// At run time, there's a class created for us already called
// PersonaClass, provided by Truffle. That class represents the
// PersonaClass contract. The following adds functions to it to make
// it the main point of contact for interacting with personas.
var registryInstance = PersonaRegistry.at(PersonaRegistry.deployed_address);
PersonaClass.setRegistry = (registryAddress) => {
registryInstance = PersonaRegistry.at(registryAddress);
};
PersonaClass.setIpfsProvider = (ipfsProv) => {
ipfs.setProvider(ipfsProv);
};
PersonaClass.setWeb3Provider = (web3Prov) => {
web3.setProvider(web3Prov);
};
PersonaClass.of = PromiseLib.promisify( (ownerAddress, callback) => {
registryInstance
.idLookup
.call(ownerAddress)
.then( (personaAddress) => {
callback(null, PersonaClass.at(personaAddress)); })
.catch(callback);
});
PersonaClass.newPersona = PromiseLib.promisify( (info, txData, callback) => {
if (typeof txData === 'function') {
callback = txData;
txData = {};
}
// NOTES
// info should be a JSON structure with attributes about the persona,
// with top-level keys being classes of attributes. The main class now
// will be 'personSchema' which denotes data corresponding to the
// Schema.org Person spec.
// {
// 'personSchema' :
// {
// 'name': 'Tim Coulter',
// 'image': {'@type': 'ImageObject',
// 'name': 'avatar',
// 'contentUrl' : 'ipfs/QmX...'}
// }
// }
// This info hash will be the same one users get back by calling
// persona.getInfo().
ipfs.addJson(info, (err, ipfsHash) => {
// console.log(err, ipfsHash);
if (err !== null) { throw new Error(err); return; }
var persona = null; // QUESTION: Does this actually get passed to the next step?
PersonaClass.new(ipfsHash, txData).then( (instance) => {
// console.log(instance);
persona = instance;
return registryInstance.registerPersona(persona.address, txData);
}).then(function(tx) { callback(null, persona); // QUESTION: passing tx for no reason?
}).catch(callback);
});
});
PersonaClass.extend({
getInfo(attributeClass) {
return new PromiseLib( (accept, reject) => {
this.ipfsHash.call().then( (ipfsHash) => {
ipfs.catJson(ipfsHash, (err, personaObj) => {
if (err !== null) { reject(err); return; }
var returnVal;
attributeClass === undefined ?
returnVal = personaObj :
returnVal = personaObj[attributeClass];
accept(returnVal);
})
}).catch(reject);
});
}
});
PersonaClass.extend({
updateInfo(newInfo, txData) {
return new PromiseLib( (accept, reject) => {
ipfs.addJson(newInfo, (err, newIpfsHash) => {
if (err !== null) { reject(err); return; }
this.setIpfsHash(newIpfsHash, txData).then( () => {
accept();
}).catch(reject);
})
})
}
});
return PersonaClass;
}
var Persona = require("../config/development/Persona.sol.js").load(Pudding);
var PersonaRegistry = require("../config/development/PersonaRegistry.sol.js").load(Pudding);
module.exports = PersonaFactory(Persona, PersonaRegistry);
{
"name": "persona",
"version": "0.0.4",
"description": "persona contracts and example Dapp",
"main": "lib/persona.js",
"repository": {
"type": "git",
"url": "https://github.com/ConsenSys/persona.git"
},
"homepage": "https://github.com/ConsenSys/persona",
"bugs": {
"url": "https://github.com/ConsenSys/persona/issues"
},
"keywords": [
"Persona"
],
"author": "ConsenSys",
"license": "ISC",
"devDependencies": {
"babel-preset-es2015": "*",
"babelify": "*",
"brfs": "*",
"buffer": "^3.6.0",
"concat-stream": "^1.5.1",
"create-hash": "^1.1.2",
"eth-lightwallet": "*",
"gulp-minify-css": "^1.2.3",
"gulp-util": "^3.0.7",
"indexof": "*",
"vinyl": "^0.5.3"
},
"scripts": {
"build": "browserify -t babelify lib/persona.js --s Persona --o dist/persona.js"
},
"dependencies": {
"better-console": "^0.2.4",
"bluebird": "*",
"buffer": "^3.4.3",
"concat-stream": "^1.5.0",
"create-hash": "^1.1.2",
"del": "^2.2.0",
"ether-pudding": "*",
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.1.0",
"gulp-chmod": "^1.3.0",
"gulp-clone": "^1.0.0",
"gulp-concat": "^2.6.0",
"gulp-concat-css": "^2.2.0",
"gulp-copy": "0.0.2",
"gulp-dedupe": "0.0.2",
"gulp-flatten": "^0.2.0",
"gulp-header": "^1.7.1",
"gulp-help": "^1.6.1",
"gulp-if": "^2.0.0",
"gulp-less": "^3.0.5",
"gulp-minify-css": "^1.2.2",
"gulp-notify": "^2.2.0",
"gulp-plumber": "^1.0.1",
"gulp-print": "^2.0.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-rtlcss": "^0.1.4",
"gulp-uglify": "^1.5.1",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"hooked-web3-provider": "^1.0.0",
"ipfs": "^0.1.1",
"ipfs-api": "2.3.2",
"ipfs-js": "0.0.7",
"is-array": "^1.0.1",
"require-dot-file": "^0.4.0",
"run-sequence": "^1.1.5",
"vinyl": "^0.5.1",
"web3": "*",
"yamljs": "^0.2.4"
},
"authors": [
"Christian Lundkvist",
"Tim Coulter"
]
}
var Persona = require('../lib/persona.js')
var Web3 = require('web3')
var web3 = new Web3();
var ipfs = require('ipfs-js')
var pudding = require('ether-pudding')
pudding.setWeb3(web3);
var Promise = require('bluebird')
var personaInfo = require('./persona_example.json')
var web3prov = new web3.providers.HttpProvider('http://localhost:8545');
web3.setProvider(web3prov);
var ipfsProv = require('ipfs-api')('localhost', '5001');
ipfs.setProvider(ipfsProv);
var personaRegContr = require('../config/development/contracts.json')
var personaRegistry = pudding.whisk(personaRegContr.PersonaRegistry.abi, personaRegContr.PersonaRegistry.binary)
describe('Higher-level Persona APIs', function () {
it("Creates personas and reads info", function(done) {
this.timeout(10000);
var personaInstance;
web3.eth.getAccounts(function(err, acct) {
var personas = [];
personaRegistry.new({from: acct[0]}).then(function (personaReg) {
Persona.setRegistry(personaReg.address);
//console.log('PersonaRegistry: ' + personaReg.address);
var personaPromises = [Persona.newPersona(personaInfo.kobe, {from: acct[0]}),
Persona.newPersona(personaInfo.lebron, {from: acct[1]}),
Persona.newPersona(personaInfo.shaq, {from: acct[2]})];
return Promise.all(personaPromises);
}).then(function() {
// Check that we can recover the Persona info
return Persona.of(acct[0]);
}).then(function(persona0) {
return persona0.getInfo();
}).then(function(info) {
assert.strictEqual(info.schemaPerson.name, 'Kobe Bryant');
return Persona.of(acct[1])
}).then(function(persona1) {
return persona1.getInfo();
}).then(function(info) {
assert.strictEqual(info.schemaPerson.name, 'Lebron James');
return Persona.of(acct[2])
}).then(function(persona2) {
personaInstance = persona2;
return persona2.getInfo();
}).then(function(info) {
assert.strictEqual(info.schemaPerson.name, "Shaquille O'Neal");
// Change the name
info.schemaPerson.name = "New Name";
return personaInstance.updateInfo(info, {from: acct[2]});
}).then(function() {
return personaInstance.getInfo();
}).then(function(info) {
assert.strictEqual(info.schemaPerson.name, 'New Name');
done();
})
});
});
});
var ipfs = require('ipfs-js')
ipfs.api = require('ipfs-api')('localhost', '5001')
describe('IPFS', function () {
it("adds data to IPFS", function(done) {
var targetHash = 'Qmc7CrwGJvRyCYZZU64aPawPj7CJ56vyBxdhxa38Dh1aKt';
var targetText = 'Testing...';
var buf = new Buffer(targetText);
ipfs.add(buf, function(err, hash) {
assert.strictEqual(hash, targetHash);
done();
});
});
it("gets data from IPFS", function(done) {
var targetHash = 'Qmc7CrwGJvRyCYZZU64aPawPj7CJ56vyBxdhxa38Dh1aKt';
var targetText = 'Testing...';
ipfs.cat(targetHash, function(err, data) {
assert.strictEqual(data.toString(), targetText);
done();
});
});
it("adds JSON to IPFS", function(done) {
var targetHash = 'QmPhbf5AoE9SF8RUqjCFf15i9ACZ449YTLUFoGnmrs1QZc';
var jsonObject = {'x' : 1234,
'y' : 'hello',
'arr' : [0,1,2,3,4],
'obj' : {'a' : 'str', 'b' : 123}};
ipfs.addJson(jsonObject, function(err, hash) {
assert.strictEqual(hash, targetHash);
done();
});
});
it("gets JSON from IPFS", function(done) {
var hash = 'QmPhbf5AoE9SF8RUqjCFf15i9ACZ449YTLUFoGnmrs1QZc';
var targetObject = {'x' : 1234,
'y' : 'hello',
'arr' : [0,1,2,3,4],
'obj' : {'a' : 'str', 'b' : 123}};
ipfs.catJson(hash, function(err, jsonObj) {
assert.strictEqual(jsonObj.x, targetObject.x);
assert.strictEqual(jsonObj.y, targetObject.y);
assert.strictEqual(jsonObj.obj.a, targetObject.obj.a);
assert.strictEqual(jsonObj.obj.b, targetObject.obj.b);
for (var i=0; i<targetObject.arr.length; i++) {
assert.strictEqual(jsonObj.arr[i], targetObject.arr[i]);
}
done();
});
});
})
contract('Persona', function(acct) {
var ipfsHash = 'QmYk9cwLQSnNJjLnHUbiRSoKmuJbZGPt8tXVR2q5Ugi1eD';
it("should construct properly", function(done) {
Persona.new(ipfsHash).then(function (persona) {
persona.owner.call().then(function (owner) {
assert.strictEqual(owner, acct[0]);
return persona.ipfsHash.call();
}).then( function(outIpfsHash) {
assert.strictEqual(outIpfsHash, ipfsHash);
done();
});
});
});
it("should set ipfsHash correctly", function(done) {
Persona.new(ipfsHash).then(function (persona) {
var newIpfsHash = 'QmbcuVvbtWZxCv4MQZuzZnyviAhsXNm2kRt53iS7ZWZTh7'
persona.setIpfsHash(newIpfsHash).then( function() {
return persona.ipfsHash.call();
}).then( function (retIpfsHash) {
assert.strictEqual(retIpfsHash, newIpfsHash);
done();
});
});
});
});
{
"kobe": {
"schemaPerson" : {
"@type": "Person",
"name": "Kobe Bryant",
"description": "Enjoys playing Basketball",
"image": [
{
"@type": "ImageObject",
"name": "avatar",
"contentUrl": "ipfs/QmZJ8egj6BfCWYvn72bUiEWaNGpHeGNm1hheXX9e4s4yJ5"
}
],
"birthDate": "1990-01-01",
"taxID": "123-45-6789",
"address": [
{
"@type": "PostalAddress",
"streetAddress": "154 Grand St",
"addressLocality": "New York, NY",
"postalCode": "10013",
"addressCountry": "United States"
}
]
},
"balanc3": {
"generalLedger" : "0xdeadbeef",
"sentInvoices" : "0x4cb053eb53a5d5ec2824da87ab925da8b51d65b7",
"receivedInvoices" : "0x31ac053eb53a5d5234242342335234653463b51d65b7"
}
},
"shaq" : {
"schemaPerson" : {
"@type": "Person",
"name": "Shaquille O'Neal",
"description": "Plays Basketball",
"image": [
{
"@type": "ImageObject",
"name": "avatar",
"contentUrl": "ipfs/QmVcXz6XpB8BecLeU4o2sh6HzckWraPmfSWZPYoCiJUcZe"
}
],
"birthDate": "1990-01-01",
"taxID": "987-65-4321",
"address": [
{
"@type": "PostalAddress",
"streetAddress": "154 Shaq Ave",
"addressLocality": "New York, NY",
"postalCode": "10013",
"addressCountry": "United States"
}
]
},
"balanc3": {
"generalLedger" : "0xdeadbeef",
"sentInvoices" : "0x4cb053eb53a5d5ec2824da87ab925da8b51d65b7",
"receivedInvoices" : "0x31ac053eb53a5d5234242342335234653463b51d65b7"
}
},
"lebron" : {
"schemaPerson" : {
"@type": "Person",
"name": "Lebron James",
"description": "Basketballer",
"image": [
{
"@type": "ImageObject",
"name": "avatar",
"contentUrl": "ipfs/QmXZatebmiE6x4G7Zz25w4L7pa4XH8eL4fybVVPFPp8osD"
}
],
"birthDate": "1990-01-01",
"taxID": "666-66-6666",
"address": [
{
"@type": "PostalAddress",
"streetAddress": "154 Lebron St",
"addressLocality": "New York, NY",
"postalCode": "10013",
"addressCountry": "United States"
}
]
},
"balanc3": {
"generalLedger" : "0xdeadbeef",
"sentInvoices" : "0x4cb053eb53a5d5ec2824da87ab925da8b51d65b7",
"receivedInvoices" : "0x31ac053eb53a5d5234242342335234653463b51d65b7"
}
}
}
contract('PersonaRegistry', function(acct) {
var ipfsHash = 'QmYk9cwLQSnNJjLnHUbiRSoKmuJbZGPt8tXVR2q5Ugi1eD';
var ipfsHash2 = 'QmYk9cwLQSnNJjLnHUbiRSoKmuJbZGPt8tXVR2q5Ugi1eU';
it("should register and remove an address", function(done) {
this.timeout(10000);
var idList, persona2;
PersonaRegistry.new().then(function (reg) {
Persona.new(ipfsHash).then(function (persona) {
reg.registerPersona(persona.address).then(function () {
return reg.idLookup.call(acct[0]);
}).then(function(returnedAddr) {
assert.strictEqual(returnedAddr, persona.address);
return reg.getIdList.call();
}).then(function (i) {
idList = i;
assert.strictEqual(idList.length, 1);
assert.strictEqual(idList[0], acct[0]);
return Persona.new(ipfsHash, {from: acct[1]});
}).then(function (p) {
persona2 = p;
return reg.registerPersona(persona2.address, {from: acct[1]})
}).then(function () {
return reg.idLookup.call(acct[1]);
}).then(function (returnedAddr2) {
assert.strictEqual(returnedAddr2, persona2.address);
return reg.getIdList.call();
}).then(function (idList2) {
assert.strictEqual(idList2.length, 2);
assert.strictEqual(idList2[0], acct[0]);
assert.strictEqual(idList2[1], acct[1]);
return reg.removePersona({from: acct[0]});
}).then(function () {
return reg.getIdList.call();
}).then( function (idList) {
assert.strictEqual(idList.length, 1);
assert.strictEqual(idList[0], acct[1]);
done();
}).catch(done);
})
})
});
})
This diff is collapsed.
# React Account Badge
This is an account management badge, in which user can choose which account
he wants to use in a given application. He can choose from accounts from his
local node or from light wallet accounts. User can also fully manage his light
wallet. Current actions for lightwallet:
* Create new lightwallet, using entropy provided by mouse movements
* Load wallet from disk
* Load wallet from seed
* Save wallet to disk
* See wallet seed
* Remove wallet from local storage
* Add new address into the wallet
Users can also use a feature called `transfer by dragging` in which you can
transfer funds from one address to another just by dragging source address into
target.
# How to use it
First, copy the style.css file (located at the root folder of this project) to your project
and include it in your html. Second, get the project from github:
```
git clone --depth=1 https://github.com/consensys/react-account-badge
```
Third, include this module into your `package.json` file, poiting it to the folder that you
cloned above.
```
...
"dependencies": {
"react-account-badge":"file../react-account-badge",
...
}
...
```
Finally, use the component!
```javascript
var AccountBadge = require('react-account-badge').AccountBadge;
var Web3 = require('web3');
var web3 = new Web3();
...
<AccountBadge web3={web3}/>
```
This piece of code will show three data on a selected address: the persona
picture (if the address doesn't have one, will show an anonymous picture),
the address and the balance.
If you click on this component, it will open a popup window where you can select
a different address and manage you light wallet account.
To get the selected address from this component, you can use this piece of code
wherever you need it:
```javascript
var AccountStore = require('react-account-badge').AccountStore;
...
var selectedAddress = AccountStore.getSelectedAddress();
```
See folder of `sample-app` for a practical example.
# Using in the browser (bundle.js)
Optionally, you can use the `bundle.js` file that comes in the `dist` directory.
It exposes the object `accountBadge` where you can access the AccountBadge and
AccountStore for use in a browser:
```html
<script src='dist/bundle.js' type='text/javascript'></script>
```
This diff is collapsed.
{
"name": "react-account-badge",
"version": "0.2.0",
"main": "./src/Main.js",
"browserify": {
"transform": [
"reactify"
]
},
"dependencies": {
"babel-preset-react": "^6.1.18",
"babelify": "^7.2.0",
"bluebird": "^3.1.1",
"brfs": "^1.4.2",
"concat-stream": "^1.5.1",
"es6-promise": "^3.0.2",
"eth-lightwallet": "*",
"ethereumjs-tx": "^0.6.11",
"hooked-web3-provider": "^1.0.0",
"ipfs-api": "^2.10.1",
"object-assign": "^4.0.1",
"persona": "file:../persona",
"react": "0.14.x",
"web3": "^0.15.1"
},
"devDependencies": {
"browserify": "*",
"reactify": "^1.1.1"
},
"scripts": {
"build": "browserify -s accountBadge -e ./src/Main.js -o ./dist/bundle.js"
},
"author": {
"name": "Daniel Novy - ConsenSys"
},
"repository": {
"type": "git",
"url": "git+https://github.com/consensys/react-account-badge.git"
},
"license": "MIT"
}
# Sample App for react-account-badge
## Building
```
npm install
npm run build
```
## Running
To run this sample, just open the index.html file on your browser. Make
sure to have a local node running at port 8545 (default). You
will see the component mounted at the top right corner. Click on it
and have fun!
This diff is collapsed.
<html>
<head>
<!-- react-account-badge CSS -->
<link rel="stylesheet" href="style.css?v=3">
</head>
<body>
<div id="react-mount"></div>
<script src="./bundle.js"></script>
</body>
</html>
var React = require('react');
var Web3 = require('web3');
var ReactDOM = require('react-dom');
var AccountBadge = require('react-account-badge').AccountBadge;
var web3 = new Web3();
var Main = React.createClass({
render: function() {
require('react-account-badge').enablePersona();
var style_main =
{padding: '15px', backgroundColor:'red', width:'1500px', height:'800px'};
var style_left =
{padding: '10px', backgroundColor:'blue', float: 'left'};
var style_right =
{padding: '10px', backgroundColor:'white', width:'250px', height:'80px', float: 'right'};
return (
<div style={style_main}>
<div style={style_left}/>
<div style={style_right}>
<AccountBadge web3={web3}/>
</div>
</div>);
}
});
ReactDOM.render(<Main/>, document.getElementById('react-mount'));
{
"name": "sample-app",
"version": "0.0.1",
"description": "",
"main": "main.jsx",
"browserify": {
"transform": [
"reactify"
]
},
"scripts": {
"build": "./node_modules/.bin/browserify -e main.jsx -o ./bundle.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"brfs": "^1.4.2",
"react": "^0.14.3",
"react-account-badge": "file:..",
"react-dom": "^0.14.3",
"web3": "^0.15.1"
},
"devDependencies": {
"browserify": "*",
"reactify": "^1.1.1"
}
}
hr {
display: block;
-webkit-margin-before: 0.5em;
-webkit-margin-after: 0.5em;
-webkit-margin-start: auto;
-webkit-margin-end: auto;
border-style: inset;
border-width: 1px;
}
.background {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
z-index:9999;
}
.accountSelector {
width: 800px;
height: 620px;
margin-left: auto;
margin-right: auto;
margin-top: 100px;
background-color: white;
box-shadow: 10px 10px 5px #000;
border-radius: 10px;
font-family: Arial;
font-size: 26px;
font-weight: bold;
color: #555;
padding:10px;
}
.animated {
-webkit-animation-duration: 0.3s;
animation-duration: 0.3s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-in;
animation-timing-function: ease-in;
}
@-webkit-keyframes bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.3);
}
50% {
opacity: 1;
-webkit-transform: scale(1.05);
}
70% {
-webkit-transform: scale(.9);
}
100% {
-webkit-transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(.3);
}
50% {
opacity: 1;
transform: scale(1.05);
}
70% {
transform: scale(.9);
}
100% {
transform: scale(1);
}
}
.bounceIn {
-webkit-animation-name: bounceIn;
animation-name: bounceIn;
}
.entropyCollector {
width: 600px;
height: 375px;
margin-left: auto;
margin-right: auto;
margin-top: 150px;
background-color: white;
box-shadow: 10px 10px 5px #000;
border-radius: 10px;
font-family: Arial;
font-size: 26px;
font-weight: bold;
color: #555;
padding:10px;
}
.passwordScreen {
width: 400px;
height: 260px;
margin-left: auto;
margin-right: auto;
margin-top: 150px;
background-color: white;
box-shadow: 10px 10px 5px #000;
border-radius: 10px;
font-family: Arial;
font-size: 26px;
font-weight: bold;
color: #555;
padding:10px;
}
.transferScreen {
width: 500px;
height: 260px;
margin-left: auto;
margin-right: auto;
margin-top: 150px;
background-color: white;
box-shadow: 10px 10px 5px #000;
border-radius: 10px;
font-family: Arial;
font-size: 26px;
font-weight: bold;
color: #555;
padding:10px;
}
.enterSeedScreen {
width: 500px;
height: 310px;
margin-left: auto;
margin-right: auto;
margin-top: 150px;
background-color: white;
box-shadow: 10px 10px 5px #000;
border-radius: 10px;
font-family: Arial;
font-size: 26px;
font-weight: bold;
color: #555;
padding:10px;
}
.button {
margin-top: 15px;
padding: 5px;
padding-right: 15px;
padding-left: 15px;
font-family: Arial;
font-size: 20px;
border-radius: 5px;
width: 100px;
background-color: white;
}
.styleSeed {
margin-top: 10px;
margin-bottom: 10px;
font-size:16px;
font-family:Courier;
font-weight:500;
background-color:rgba(0,255,0,0.1);
}
.title {
font-size:22px;
color:#999;
margin-bottom:10px;
}
.addressesLeft {
float:left;
width:390px;
height:450px;
padding:5px;
overflow-y:auto;
}
.addressesRight {
float:right;
width:390px;
height:450px;
padding:5px;
overflow-y:auto;
}
.select {
border-radius:5px;
background-color:white;
font-size:18px;
color:#777;
}
.selectedAddress {
padding-top:24px;
font-size:18px;
padding-left:20px;
float:left;
}
.addressSpot {
font-size:0px;
padding:5px;
}
.addressSpot:hover {
cursor: pointer;
background-color:#eee;
}
.personaImage {
padding-left:4px;
border-radius:7px;
width:45px;
height:45px;
}
.closeModal {
float: right;
font-family: Courier;
font-size: 24px;
font-weight: bold;
padding:5px;
padding-left:10px;
padding-right:10px;
}
.closeModal:hover {
cursor: pointer;
background-color:rgba(150,150,150,0.3);
border-radius: 6px;
}
var config = require('./config.js');
module.exports = {
AccountBadge: require('./components/AccountBadge.jsx'),
AccountStore: require('./flux/AccountStore.js'),
enablePersona: function() {
config.personaEnabled = true;
},
disablePersona: function() {
config.personaEnabled = false;
},
setWeb3Provider: function(host) {
config.web3Provider = host;
},
setIpfsProvider: function(host) {
config.ipfsProvider = host;
},
setPersonaRegistry: function(registry) {
config.personaRegistry = registry;
},
setPersonaCacheTimeout: function(timeout) {
config.personaCacheTimeout = timeout;
},
};
var React = require('react');
var HookedWeb3Provider = require('hooked-web3-provider');
var Transaction = require('ethereumjs-tx');
var AccountSelector = require('./AccountSelector.jsx');
var AddressSpot = require('./AddressSpot.jsx');
var WalletPassword = require('./WalletPassword.jsx');
var Badge = require('./Badge.jsx');
var AccountStore = require('../flux/AccountStore.js');
var Actions = require('../flux/Actions.js');
var config = require('../config.js');
var PersonaStore = require('../flux/PersonaStore.js');
var addresses = [];
// gasPrice will be used when sending a transaction through HookedWeb3Provider when
// it has not been specified by original caller.
var gasPrice;
var AccountBadge = React.createClass({
getInitialState: function() {
return {
accountSelector: false,
selectedAddress: '',
passwordScreen: false,
passwordCallback: null,
}
},
openAddressSelector: function() {
this.setState({accountSelector:true});
},
closeAddressSelector: function() {
this.setState({accountSelector:false});
},
closePasswordScreen: function() {
this.setState({passwordScreen:false});
},
onEnteredPassword: function(password, callback) {
try {
this.state.passwordCallback(password);
this.setState({passwordScreen:false});
} catch (err) {
callback(err);
}
},
onSelect: function(address) {
this.setState({
selectedAddress: address,
accountSelector: false
});
if (this.props.onChangeAddress) {
this.props.onChangeAddress(address);
}
Actions.setSelectedAddress(address);
},
askWalletPassword: function(callback) {
this.setState({passwordScreen: true, passwordCallback: callback});
},
componentWillMount: function() {
var _this = this;
this.enableHookedWeb3Provider();
this.props.web3.eth.getAccounts(function(err, accounts) {
if (err) console.error(err);
addresses = accounts;
if (AccountStore.getSelectedAddress() == '') {
_this.setState({selectedAddress: accounts[0]});
Actions.setSelectedAddress(accounts[0]);
} else {
_this.setState({selectedAddress: AccountStore.getSelectedAddress()});
}
});
this.props.web3.eth.getGasPrice(function(err, price) {
if (err) console.error(err);
gasPrice = '0x' + price.toString(16);
});
},
enableHookedWeb3Provider: function() {
var hasAddress = function(address, callback) {
var found = false;
var addrToCheck = address;
if (!addrToCheck.startsWith('0x')) {
addrToCheck = '0x' + addrToCheck;
}
for (var i = 0; i < addresses.length; i++) {
if (addrToCheck == addresses[i]) {
found = true;
break;
}
}
console.log('found: ' + found);
callback(null, !found);
};
var _this = this;
var signTransaction = function(tx_params, callback) {
//console.log('signTransaction: ' + JSON.stringify(tx_params));
if (!tx_params.gasPrice) {
tx_params.gasPrice = gasPrice;
}
tx_params.gasLimit = tx_params.gas;
var from = tx_params.from;
if (!from.startsWith('0x')) {
from = '0x' + from;
tx_params.from = from;
}
var tx = new Transaction(tx_params);
var rawTx = tx.serialize().toString('hex');
_this.askWalletPassword(function(password) {
if (!password) return;
//console.log('password = [' + password + ']');
//try {
var signed = AccountStore.getKeystore().signTx(rawTx, password, tx_params.from.substring(2));
//console.log('signed: ' + signed);
callback(null, signed);
//} catch (err) {
// console.error(err);
// callback(err, null);
//}
});
};
var provider = new HookedWeb3Provider({
host: 'http://' + config.web3Provider,
transaction_signer: {
hasAddress: hasAddress,
signTransaction: signTransaction
}
});
this.props.web3.setProvider(provider);
},
render: function() {
return (
<div>
<Badge
eid='top-as'
web3={this.props.web3}
address={this.state.selectedAddress}
onClick={this.openAddressSelector}
/>
<AccountSelector
web3={this.props.web3}
onClose={this.closeAddressSelector}
onSelect={this.onSelect}
visible={this.state.accountSelector}
/>
<WalletPassword
onProceed={this.onEnteredPassword}
onCancel={this.closePasswordScreen}
visible={this.state.passwordScreen}
/>
</div>
);
}
});
module.exports = AccountBadge;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment