add address resolve field to register sub-domain

This commit is contained in:
Barry Gitarts 2018-05-28 11:34:51 -04:00
parent 80ca121edd
commit c02a8b5959

View File

@ -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
)