mirror of
https://github.com/status-im/ens-usernames.git
synced 2025-01-21 00:00:47 +00:00
add address resolve field to register sub-domain
This commit is contained in:
parent
80ca121edd
commit
c02a8b5959
@ -1,3 +1,4 @@
|
||||
import web3 from "Embark/web3"
|
||||
import ENSSubdomainRegistry from 'Embark/contracts/ENSSubdomainRegistry';
|
||||
import ENSRegistry from 'Embark/contracts/ENSRegistry';
|
||||
import React, { Fragment } from 'react';
|
||||
@ -36,20 +37,36 @@ const InnerForm = ({
|
||||
onBlur={handleBlur}
|
||||
value={values.domainName}
|
||||
/>
|
||||
<FieldGroup
|
||||
id="address"
|
||||
name="address"
|
||||
type="text"
|
||||
label="Address domain resolves to"
|
||||
onChange={handleChange}
|
||||
onBlur={handleBlur}
|
||||
value={values.address}
|
||||
error={errors.address}
|
||||
/>
|
||||
<Button bsStyle="primary" type="submit" disabled={isSubmitting || !!Object.keys(errors).length}>{!isSubmitting ? 'Submit' : 'Submitting to the Blockchain - (this may take awhile)'}</Button>
|
||||
</form>
|
||||
)
|
||||
|
||||
const RegisterSubDomain = withFormik({
|
||||
mapPropsToValues: props => ({ subDomain: '', domainName: '' }),
|
||||
validate(values) {
|
||||
const errors = {};
|
||||
const { address } = values;
|
||||
if (address && !web3.utils.isAddress(address)) errors.address = 'Not a valid address'
|
||||
return errors;
|
||||
},
|
||||
handleSubmit(values, { setSubmitting }) {
|
||||
const { subDomain, domainName } = values;
|
||||
const { soliditySha3 } = window.web3.utils;
|
||||
const { subDomain, domainName, address } = values;
|
||||
const { soliditySha3 } = web3.utils;
|
||||
const { methods: { register } } = ENSSubdomainRegistry;
|
||||
register(
|
||||
soliditySha3(subDomain),
|
||||
hash(domainName),
|
||||
zeroAddress,
|
||||
address || zeroAddress,
|
||||
zeroBytes32,
|
||||
zeroBytes32
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user