From c234a24ee23f7d716cf0c726ab2f94aee2d7202e Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Fri, 19 Oct 2018 12:30:36 -0400 Subject: [PATCH] wait for sign before showing tx confirmation screen --- app/components/ens/registerSubDomain.js | 64 +++++++++++++------------ 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/app/components/ens/registerSubDomain.js b/app/components/ens/registerSubDomain.js index 1f15add..89fb923 100644 --- a/app/components/ens/registerSubDomain.js +++ b/app/components/ens/registerSubDomain.js @@ -81,13 +81,13 @@ const InnerForm = ({ button={ @@ -133,13 +133,13 @@ const InnerForm = ({
{!isSubmitting ? - - : - } + + : + } { setStatus(null); formRef.current.dispatchEvent(new Event('submit')) }} form={formRef} />
@@ -193,24 +193,26 @@ const RegisterSubDomain = withFormik({ const gas = editAccount ? gasEstimated + 1000 : gasEstimated * 2; console.log("Register would work. :D Gas estimated: " + gasEstimated, { gas }, gasEstimated + 1000); console.log("Trying: register(\"" + subdomainHash + "\",\"" + domainNameHash + "\",\"" + resolveToAddr + "\",\"" + zeroBytes32 + "\",\"" + zeroBytes32 + "\")"); - if (preRegisteredCallback) preRegisteredCallback(); - toSend.send({ gas }).then((txId) => { - if (txId.status == "0x1" || txId.status == "0x01"){ - console.log("Register send success. :)"); - } else { - console.log("Register send errored. :( Out of gas? "); - } - console.dir(txId) - }).catch(err => { - console.log("Register send errored. :( Out of gas?"); - console.dir(err) - }).finally(() => { - // REQUIRED UNTIL THIS ISSUES IS RESOLVED: https://github.com/jaredpalmer/formik/issues/597 - setTimeout(() => { - registeredCallbackFn(resolveToAddr, statusAddress || zeroBytes32); - }, 200); - setSubmitting(false); - }); + toSend.send({ gas }) + .on('transactionHash', (txHash) => { if (preRegisteredCallback) preRegisteredCallback(txHash); }) + .then((txId) => { + if (txId.status == "0x1" || txId.status == "0x01"){ + console.log("Register send success. :)"); + } else { + console.log("Register send errored. :( Out of gas? "); + } + console.dir(txId) + }).catch(err => { + console.log("Register send errored. :( Out of gas?"); + console.dir(err) + }) + .on('confirmation', (confirmationNumber, receipt) => { + // REQUIRED UNTIL THIS ISSUES IS RESOLVED: https://github.com/jaredpalmer/formik/issues/597 + setTimeout(() => { + registeredCallbackFn(resolveToAddr, statusAddress || zeroBytes32); + }, 200); + setSubmitting(false); + }) }).catch(err => { console.log("Register would error. :/ Already Registered? Have Token Balance? Is Allowance set?") console.dir(err)