mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-02-03 06:13:53 +00:00
add setup ENS button
This commit is contained in:
parent
2c853c6b0c
commit
a4ab4207d2
28
app/components/ens/setupENS.js
Normal file
28
app/components/ens/setupENS.js
Normal file
@ -0,0 +1,28 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import { Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel } from 'react-bootstrap';
|
||||
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
||||
import web3Utils from 'web3-utils'
|
||||
import { hash } from 'eth-ens-namehash'
|
||||
|
||||
const zeroBytes32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
const getUserAddress = contract => contract._provider.publicConfigStore._state.selectedAddress;
|
||||
const dispatchSetup = (ENSRegistry) => {
|
||||
const { methods: { setSubnodeOwner } } = ENSRegistry;
|
||||
const { sha3 } = web3Utils
|
||||
setSubnodeOwner(zeroBytes32, sha3('eth'), getUserAddress(ENSRegistry))
|
||||
.send()
|
||||
.then(res => { console.log(res) })
|
||||
setSubnodeOwner(hash('eth'), sha3('stateofus'), ENSSubdomainRegistry._address)
|
||||
.send()
|
||||
.then(res => { console.log(res) })
|
||||
setSubnodeOwner(hash('eth'), sha3('stateofus'), ENSSubdomainRegistry._address)
|
||||
.send()
|
||||
.then(res => { console.log(res) })
|
||||
}
|
||||
const SetupEns = ({ ENSRegistry }) => (
|
||||
<Fragment>
|
||||
<Button bsStyle="primary" onClick={() => dispatchSetup(ENSRegistry)}>ADD INITIAL NODES TO ENS</Button>
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
export default SetupEns;
|
@ -1,8 +1,9 @@
|
||||
import EmbarkJS from 'Embark/EmbarkJS';
|
||||
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
||||
import ENSRegistry from 'Embark/contracts/ENSRegistry';
|
||||
import React, { Fragment } from 'react';
|
||||
import { Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel } from 'react-bootstrap';
|
||||
import AddDomain from './ens/addDomain'
|
||||
import SetupENS from './ens/setupENS'
|
||||
|
||||
const FieldGroup = ({ id, label, help, ...props }) => (
|
||||
<FormGroup controlId={id}>
|
||||
@ -17,7 +18,14 @@ const ENSSubManagement = (props) => (
|
||||
<h2 style={{textAlign: 'center'}}>Subdomain Management</h2>
|
||||
<h3>Add Domain</h3>
|
||||
<AddDomain />
|
||||
<hr/>
|
||||
<SetupENS ENSRegistry={ENSRegistry} />
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
//console.log(ENSRegistry);
|
||||
setTimeout(() => ENSRegistry.getPastEvents(
|
||||
'allEvents',
|
||||
{},
|
||||
(err, res) => { console.log(err, res) }), 2000)
|
||||
export default ENSSubManagement
|
||||
|
Loading…
x
Reference in New Issue
Block a user