convert promise to async await
This commit is contained in:
parent
6553a44e45
commit
ba0d641868
|
@ -60,25 +60,24 @@ const AddDomain = withFormik({
|
||||||
if (!domainName) errors.domainName = 'Required';
|
if (!domainName) errors.domainName = 'Required';
|
||||||
return errors;
|
return errors;
|
||||||
},
|
},
|
||||||
handleSubmit(values, { setSubmitting }) {
|
async handleSubmit(values, { setSubmitting }) {
|
||||||
const { domainName, domainPrice } = values
|
const { domainName, domainPrice } = values
|
||||||
const { methods: { domains, addDomain, setDomainPrice } } = ENSSubdomainRegistry
|
const { methods: { domains, addDomain, setDomainPrice } } = ENSSubdomainRegistry
|
||||||
const hashedDomain = hash(domainName);
|
const hashedDomain = hash(domainName);
|
||||||
getDomain(hashedDomain, domains).then(({ state }) => {
|
const { state } = await getDomain(hashedDomain, domains);
|
||||||
setPrice(
|
setPrice(
|
||||||
!!state ? setDomainPrice : addDomain,
|
!!state ? setDomainPrice : addDomain,
|
||||||
hashedDomain,
|
hashedDomain,
|
||||||
domainPrice
|
domainPrice
|
||||||
)
|
)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
console.log(res);
|
console.log(res);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})(InnerForm)
|
})(InnerForm)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue