mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-01-22 00:30:03 +00:00
convert nameLookup to formik with handleSubmit
remove debugTable from addDomain
This commit is contained in:
parent
b0439c6ce1
commit
ca3669224f
@ -69,21 +69,6 @@ const AddDomain = withFormik({
|
|||||||
const { methods: { domains, setDomainPrice, updateDomainPrice } } = ENSSubdomainRegistry
|
const { methods: { domains, setDomainPrice, updateDomainPrice } } = ENSSubdomainRegistry
|
||||||
const { sha3 } = window.web3.utils
|
const { sha3 } = window.web3.utils
|
||||||
const hashedDomain = hash(domainName)
|
const hashedDomain = hash(domainName)
|
||||||
const debugTable = await ['eth', 'stateofus', 'stateofus.eth', 'freedomain', 'freedomain.eth', domainName]
|
|
||||||
.map(async str => {
|
|
||||||
const result = {};
|
|
||||||
result['domainName'] = str;
|
|
||||||
result['sha3Result'] = await getDomain(sha3(str), domains);
|
|
||||||
result['sha3State'] = result.sha3Result.state
|
|
||||||
result['sha3Price'] = result.sha3Result.price
|
|
||||||
result['nameHashResult'] = await getDomain(hash(str), domains);
|
|
||||||
result['nameHashState'] = result['nameHashResult'].state
|
|
||||||
result['nameHashPrice'] = result['nameHashResult'].price
|
|
||||||
result['sha3String'] = sha3(str);
|
|
||||||
result['nameHashString'] = hash(str);
|
|
||||||
return result;
|
|
||||||
})
|
|
||||||
Promise.all(debugTable).then(v => { console.table(v) });
|
|
||||||
const { state } = await getDomain(hashedDomain, domains);
|
const { state } = await getDomain(hashedDomain, domains);
|
||||||
setPrice(
|
setPrice(
|
||||||
!!Number(state) ? updateDomainPrice : setDomainPrice,
|
!!Number(state) ? updateDomainPrice : setDomainPrice,
|
||||||
|
@ -1,21 +1,52 @@
|
|||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import { Button, Field, TextInput, Card } from '../../ui/components'
|
import { Button, Field, TextInput, Card } from '../../ui/components'
|
||||||
|
import { withFormik } from 'formik';
|
||||||
|
import PublicResolver from 'Embark/contracts/PublicResolver';
|
||||||
|
import { hash } from 'eth-ens-namehash';
|
||||||
|
|
||||||
|
const formatName = domainName => domainName.includes('.') ? domainName : `${domainName}.stateofus.eth`;
|
||||||
const cardStyle = {
|
const cardStyle = {
|
||||||
width: '75%',
|
width: '75%',
|
||||||
marginLeft: '15%',
|
marginLeft: '15%',
|
||||||
padding: '30px'
|
padding: '30px'
|
||||||
}
|
}
|
||||||
|
|
||||||
const NameLookup = () => (
|
const InnerForm = ({
|
||||||
|
values,
|
||||||
|
errors,
|
||||||
|
touched,
|
||||||
|
handleChange,
|
||||||
|
handleBlur,
|
||||||
|
handleSubmit,
|
||||||
|
isSubmitting,
|
||||||
|
}) => (
|
||||||
<Card style={cardStyle}>
|
<Card style={cardStyle}>
|
||||||
<Field label="Enter Domain or Status Name" wide>
|
<form onSubmit={handleSubmit}>
|
||||||
<TextInput wide required />
|
<Field label="Enter Domain or Status Name" wide>
|
||||||
</Field>
|
<TextInput
|
||||||
<Button mode="strong" type="submit" wide>
|
value={values.domainName}
|
||||||
Get Address
|
name="domainName"
|
||||||
</Button>
|
onChange={handleChange}
|
||||||
|
wide
|
||||||
|
required />
|
||||||
|
</Field>
|
||||||
|
<Button mode="strong" type="submit" wide>
|
||||||
|
Get Address
|
||||||
|
</Button>
|
||||||
|
</form>
|
||||||
</Card>
|
</Card>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const NameLookup = withFormik({
|
||||||
|
mapPropsToValues: props => ({ domainName: '' }),
|
||||||
|
handleSubmit(values, { setSubmitting }) {
|
||||||
|
const { domainName } = values;
|
||||||
|
PublicResolver.methods.addr(hash(formatName(domainName)))
|
||||||
|
.call()
|
||||||
|
.then(res =>{
|
||||||
|
console.log('addr', res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})(InnerForm)
|
||||||
|
|
||||||
export default NameLookup;
|
export default NameLookup;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import EmbarkJS from 'Embark/EmbarkJS';
|
import EmbarkJS from 'Embark/EmbarkJS';
|
||||||
import ENSRegistry from 'Embark/contracts/ENSRegistry';
|
import ENSRegistry from 'Embark/contracts/ENSRegistry';
|
||||||
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
||||||
import PublicResolver from 'Embark/contracts/PublicResolver';
|
|
||||||
import TestToken from 'Embark/contracts/TestToken';
|
import TestToken from 'Embark/contracts/TestToken';
|
||||||
import React, { Fragment } from 'react';
|
import React, { Fragment } from 'react';
|
||||||
import { Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel } from 'react-bootstrap';
|
import { Form, FormGroup, FormControl, HelpBlock, Button, ControlLabel } from 'react-bootstrap';
|
||||||
@ -9,7 +8,6 @@ import AddDomain from './ens/addDomain';
|
|||||||
import RegisterSubDomain from './ens/registerSubDomain';
|
import RegisterSubDomain from './ens/registerSubDomain';
|
||||||
import TokenPermissions from './standard/TokenPermission';
|
import TokenPermissions from './standard/TokenPermission';
|
||||||
import SetupENS from './ens/setupENS';
|
import SetupENS from './ens/setupENS';
|
||||||
import { hash } from 'eth-ens-namehash';
|
|
||||||
|
|
||||||
const FieldGroup = ({ id, label, help, ...props }) => (
|
const FieldGroup = ({ id, label, help, ...props }) => (
|
||||||
<FormGroup controlId={id}>
|
<FormGroup controlId={id}>
|
||||||
@ -40,9 +38,6 @@ setTimeout(() => ENSRegistry.getPastEvents(
|
|||||||
'allEvents',
|
'allEvents',
|
||||||
{},
|
{},
|
||||||
(err, res) => {
|
(err, res) => {
|
||||||
PublicResolver.methods.addr(hash('bobby.stateofus.eth')).call().then(res =>{
|
|
||||||
console.log('addr', res);
|
|
||||||
});
|
|
||||||
console.log(err, res) }), 2000)
|
console.log(err, res) }), 2000)
|
||||||
|
|
||||||
export default ENSSubManagement;
|
export default ENSSubManagement;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user