mirror of
https://github.com/status-im/topic-democracy.git
synced 2025-02-22 15:18:10 +00:00
update embark & fix primitive ui
This commit is contained in:
parent
648ff9f6ba
commit
9451a8da50
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import EmbarkJS from 'Embark/EmbarkJS';
|
||||
import Delegation from 'Embark/contracts/Delegation';
|
||||
import EmbarkJS from '../embarkArtifacts/embarkjs';
|
||||
import Delegation from '../embarkArtifacts/contracts/Delegation';
|
||||
import { HashRouter, Route, Redirect, Link } from "react-router-dom";
|
||||
|
||||
import './TopicDemocracy.css';
|
||||
@ -34,7 +34,8 @@ class TopicDemocracy extends React.Component {
|
||||
|
||||
this.state = {
|
||||
error: null,
|
||||
defaultAccount: null
|
||||
defaultAccount: null,
|
||||
deployedAddress: null
|
||||
};
|
||||
}
|
||||
|
||||
@ -43,6 +44,7 @@ class TopicDemocracy extends React.Component {
|
||||
if (err) {
|
||||
return this.setState({ error: err.message || err });
|
||||
}
|
||||
console.log(web3.eth.defaultAccount)
|
||||
this.setState({ defaultAccount: web3.eth.defaultAccount, blockchainEnabled: true })
|
||||
});
|
||||
|
||||
@ -50,7 +52,7 @@ class TopicDemocracy extends React.Component {
|
||||
|
||||
render() {
|
||||
const { classes } = this.props;
|
||||
const { blockchainEnabled, defaultAccount } = this.state;
|
||||
const { blockchainEnabled, defaultAccount, deployedAddress } = this.state;
|
||||
if (!blockchainEnabled) {
|
||||
return (
|
||||
<div>Waiting for blockchain.</div>
|
||||
@ -74,7 +76,7 @@ class TopicDemocracy extends React.Component {
|
||||
</AppBar>
|
||||
<main className={classes.layout}>
|
||||
<Route exact path="/" render={({ match }) => (
|
||||
<DelegationFactoryUI account={defaultAccount} />
|
||||
<DelegationFactoryUI account={defaultAccount} onDeploy={(deployedAddress) => {this.setState({deployedAddress})} } />
|
||||
)} />
|
||||
<Route path="/:address" render={({ match }) => (
|
||||
<DelegationUI account={defaultAccount} Delegation={new EmbarkJS.Blockchain.Contract({ abi: Delegation._jsonInterface, address: match.params.address }) } />
|
||||
|
@ -1,4 +1,4 @@
|
||||
import ERC20Token from 'Embark/contracts/ERC20Token';
|
||||
import ERC20Token from '../../embarkArtifacts/contracts/ERC20Token';
|
||||
import { actions as accountActions } from '../reducers/accounts'
|
||||
|
||||
const { receiveAccounts } = accountActions
|
||||
|
@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Redirect } from "react-router-dom";
|
||||
import { withStyles } from '@material-ui/core/styles';
|
||||
import DelegationFactory from 'Embark/contracts/DelegationFactory';
|
||||
import DelegationFactory from '../../embarkArtifacts/contracts/DelegationFactory';
|
||||
import EthAddress from './EthAddress';
|
||||
import { FormLabel, Paper, Grid } from '@material-ui/core';
|
||||
import TransactionSendButton from './TransactionSendButton';
|
||||
@ -30,30 +31,34 @@ class DelegationFactoryUI extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
parent: null,
|
||||
controller: props.account,
|
||||
defaultDelegate: null
|
||||
parent: "0x0000000000000000000000000000000000000000",
|
||||
defaultDelegate: "0x0000000000000000000000000000000000000000",
|
||||
deployedAddress: null
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const { classes, account } = this.props;
|
||||
const { parent, controller, defaultDelegate } = this.state;
|
||||
const { parent, controller, defaultDelegate, deployedAddress} = this.state;
|
||||
if(deployedAddress) {
|
||||
return (<Redirect to={'/'+deployedAddress} />)
|
||||
}
|
||||
console.log(parent, controller, defaultDelegate);
|
||||
return (
|
||||
<Paper className={classes.paper}>
|
||||
<Grid container spacing={16}>
|
||||
<Grid item>
|
||||
<FormLabel component="legend">Controller</FormLabel>
|
||||
<EthAddress defaultValue={account} control={true} onChange={(controller) => this.setState({controller})} />
|
||||
<EthAddress allowZero={true} defaultValue={account} value={controller} control={true} onChange={(e) => this.setState({controller: e.target.value })} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<FormLabel component="legend">Default Delegate</FormLabel>
|
||||
<EthAddress control={true} onChange={(defaultDelegate) => this.setState({defaultDelegate})} />
|
||||
<EthAddress allowZero={true} control={true} value={defaultDelegate} onChange={(e) => this.setState({defaultDelegate: e.target.value })} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<FormLabel component="legend">Parent Delegation</FormLabel>
|
||||
<EthAddress control={true} onChange={(parent) => this.setState({parent})} />
|
||||
<EthAddress allowZero={true} control={true} value={parent} onChange={(e) => this.setState({parent: e.target.value })} />
|
||||
</Grid>
|
||||
<Grid item>
|
||||
<TransactionSendButton
|
||||
@ -67,7 +72,7 @@ class DelegationFactoryUI extends React.Component {
|
||||
account={account}
|
||||
text="Deploy Delegation"
|
||||
onSend={(txHash) => {console.log("txHash",txHash)}}
|
||||
onResult={(result) => {console.log("result",result.events)}}
|
||||
onResult={(result) => {this.setState({deployedAddress: result.events.InstanceCreated.returnValues.instance})}}
|
||||
onReceipt={(receipt) => {console.log("receipt",receipt)}}
|
||||
onError={(error) => {console.log("error",error)}}
|
||||
/>
|
||||
|
@ -55,7 +55,7 @@ class DelegationUI extends React.Component {
|
||||
|
||||
editDelegationOf(delegate) {
|
||||
const editDelegation = this.state.editDelegation;
|
||||
if(!delegateChain.includes(delegate)){
|
||||
if(!editDelegation.includes(delegate)){
|
||||
editDelegation.push(delegate);
|
||||
this.setState({editDelegation});
|
||||
this.props.Delegation.methods.delegatedTo(delegate).call().then((delegatedTo) => {
|
||||
@ -77,7 +77,7 @@ class DelegationUI extends React.Component {
|
||||
<div className={className} >
|
||||
<div>
|
||||
<p>Delegation:</p>
|
||||
<EthAddress value={Delegation.options.address} />
|
||||
<EthAddress value={Delegation.address} />
|
||||
</div>
|
||||
<div>
|
||||
<small>Delegate Chain:</small>
|
||||
@ -91,7 +91,8 @@ class DelegationUI extends React.Component {
|
||||
</div>
|
||||
<div>
|
||||
<p>Delegate Set</p>
|
||||
<EthAddress defaultValue={editDelegate} control={true} onChange={(editDelegate) => {
|
||||
<EthAddress defaultValue={editDelegate} control={true} onChange={(e) => {
|
||||
let editDelegate = e.target.value;
|
||||
this.setState({editDelegate});
|
||||
if(editDelegate != delegateChain[0]) {
|
||||
this.setState({editDelegation : []});
|
||||
@ -102,8 +103,8 @@ class DelegationUI extends React.Component {
|
||||
{editDelegation.length > 0 &&
|
||||
<Breadcrumbs arial-label="Breadcrumb" maxItems={5}>
|
||||
{
|
||||
editDelegation.map((value) => {
|
||||
return <EthAddress value={value} />
|
||||
editDelegation.map((value, i) => {
|
||||
return <EthAddress key={i} value={value} />
|
||||
})
|
||||
}
|
||||
</Breadcrumbs>
|
||||
|
@ -1,3 +1,4 @@
|
||||
import EmbarkJS from '../../embarkArtifacts/embarkjs';
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Blockies from 'react-blockies';
|
||||
@ -86,6 +87,9 @@ class EthAddress extends React.Component {
|
||||
|
||||
|
||||
setValue(value){
|
||||
if(!value) {
|
||||
value = ""
|
||||
}
|
||||
value = value.trim();
|
||||
const validAddress = /^(0x)?[0-9a-f]{40}$/i.test(value);
|
||||
const acceptedOutput = validAddress && (this.props.allowZero || value != nullAddress);
|
||||
|
@ -1,12 +1,12 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Status Network - Test Demo</title>
|
||||
<title>µTopic Democracy</title>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
</div>
|
||||
<script src="js/dapp.js"></script>
|
||||
<script src="js/dapp.js" charset="UTF-8"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import EmbarkJS from './embarkArtifacts/EmbarkJS';
|
||||
import Delegation from './embarkArtifacts/contracts/Delegation';
|
||||
import DelegationFactory from './embarkArtifacts/contracts/DelegationFactory';
|
||||
import EmbarkJS from '../../embarkArtifacts/embarkjs';
|
||||
import Delegation from '../../embarkArtifacts/contracts/Delegation';
|
||||
import DelegationFactory from '../../embarkArtifacts/contracts/DelegationFactory';
|
||||
|
||||
class DelegationModel {
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import web3 from "Embark/web3"
|
||||
import EmbarkJS from 'Embark/EmbarkJS'
|
||||
import store from './configureStore'
|
||||
import { fetchAndDispatchAccountsWithBalances } from '../actions/accounts'
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
provider: "whisper",
|
||||
available_providers: ["whisper"],
|
||||
},
|
||||
|
@ -40,7 +40,14 @@ module.exports = {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
development:{
|
||||
dappConnection: [
|
||||
"$EMBARK",
|
||||
"$WEB3",
|
||||
"ws://localhost:8546",
|
||||
"http://localhost:8545"
|
||||
]
|
||||
},
|
||||
testnet: {
|
||||
contracts: {
|
||||
MiniMeTokenFactory: {
|
||||
|
@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
default: {
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
ipfs_bin: "ipfs",
|
||||
available_providers: ["ipfs"],
|
||||
upload: {
|
||||
@ -18,7 +18,6 @@ module.exports = {
|
||||
]
|
||||
},
|
||||
development: {
|
||||
enabled: true,
|
||||
upload: {
|
||||
provider: "ipfs",
|
||||
host: "localhost",
|
||||
|
@ -6,7 +6,7 @@ import "./delegation/DelegationFactory.sol";
|
||||
import "./proposal/ProposalFactory.sol";
|
||||
|
||||
/**
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
* @author Ricardo Guilherme Schmidt (Status Research & Development GmbH)
|
||||
*/
|
||||
contract Democracy {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user