ens-usernames/app/dapp.js

101 lines
3.3 KiB
JavaScript
Raw Normal View History

2018-06-12 19:56:41 +00:00
import React, { Fragment } from 'react';
2018-05-13 04:31:01 +00:00
import ReactDOM from 'react-dom';
2018-07-06 22:12:09 +00:00
import 'typeface-roboto'
2018-07-09 19:07:55 +00:00
import CssBaseline from '@material-ui/core/CssBaseline';
2018-05-13 04:31:01 +00:00
import { Tabs, Tab } from 'react-bootstrap';
2018-06-12 19:56:41 +00:00
import Toggle from 'react-toggle';
2018-05-13 04:31:01 +00:00
import EmbarkJS from 'Embark/EmbarkJS';
2018-05-17 19:53:23 +00:00
import TopNavbar from './components/topnavbar';
2018-05-13 04:31:01 +00:00
import TestTokenUI from './components/testtoken';
2018-05-17 15:04:47 +00:00
import ERC20TokenUI from './components/erc20token';
import TestToken from 'Embark/contracts/TestToken';
import ENSSubManagement from './components/ensSubManagement';
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
import NameLookup from './components/ens/nameLookup';
import AdminMode from './components/AdminMode';
import TokenPermissions from './components/standard/TokenPermissionConnect';
2018-06-19 19:05:42 +00:00
import web3 from "Embark/web3";
import Paper from '@material-ui/core/Paper';
import Typography from '@material-ui/core/Typography';
2018-07-06 22:12:09 +00:00
import Welcome from './components/ens/welcome';
2018-07-09 19:07:55 +00:00
import Fade from '@material-ui/core/Fade';
import Hidden from '@material-ui/core/Hidden';
2018-05-13 04:31:01 +00:00
import './dapp.css';
2018-06-19 19:05:42 +00:00
const { getNetworkType } = web3.eth.net;
const symbols = {
'ropsten': 'STT',
'private': 'SNT',
'main': 'SNT'
}
2018-05-13 04:31:01 +00:00
class App extends React.Component {
constructor(props) {
2018-06-12 19:56:41 +00:00
super(props)
2018-05-13 04:31:01 +00:00
}
2018-07-09 19:07:55 +00:00
state = { admin: false, searching: false };
2018-05-13 04:31:01 +00:00
componentDidMount(){
2018-05-13 04:31:01 +00:00
__embarkContext.execWhenReady(() => {
2018-06-19 19:05:42 +00:00
getNetworkType().then(network => { this.setState({ network })});
2018-05-13 04:31:01 +00:00
});
}
2018-06-12 19:56:41 +00:00
render() {
2018-07-09 19:07:55 +00:00
const { admin, network, searching } = this.state;
const toggleSearch = () => { this.setState({ searching: !searching }) };
2018-05-23 19:57:38 +00:00
return (
2018-06-12 19:56:41 +00:00
<div>
2018-07-09 19:07:55 +00:00
<CssBaseline />
<div style={{ display: admin ? 'block' : 'none' }} >
<AdminMode style={{ display: admin ? 'block' : 'none' }}/>
</div>
{!searching && <Fade in={!searching}>
<div>
<Welcome toggleSearch={toggleSearch} />
2018-07-09 19:07:55 +00:00
</div>
</Fade>}
{searching && <Fade in={searching}>
<div>
<NameLookup />
<Hidden mdDown>
<div style={{ textAlign: 'center' }}>
<TokenPermissions
symbol={symbols[network] || 'SNT'}
spender={ENSSubdomainRegistry._address}
methods={TestToken.methods} />
<hr/>
<Toggle onChange={() => { this.setState({ admin: !admin })}} />
<br/>
<span>Admin Mode</span>
</div>
</Hidden>
</div>
</Fade>}
{false &&
<Fragment>
<Paper elevation={4}>
<Typography style={{ fontSize: '2.5rem', padding: '0.5%', textAlign: 'center' }} variant="headline" component="h3"><i style={{ fontSize: '1rem' }}>network </i>{network}</Typography>
</Paper>
<NameLookup />
<div style={{ textAlign: 'center' }}>
<TokenPermissions
symbol={symbols[network] || 'SNT'}
spender={ENSSubdomainRegistry._address}
methods={TestToken.methods} />
<hr/>
<Toggle onChange={() => { this.setState({ admin: !admin })}} />
<br/>
<span>Admin Mode</span>
</div>
</Fragment>}
2018-06-12 19:56:41 +00:00
</div>
);
2018-05-13 04:31:01 +00:00
}
}
2018-06-01 14:25:59 +00:00
export default App;