Conversation
js/src/contracts/verification.js
Outdated
let subId = null; | ||
let resolved = false; | ||
|
||
return new Promise((resolve, reject) => { | ||
contract | ||
.subscribe('Requested', { | ||
fromBlock: 0, toBlock: 'pending' | ||
fromBlock: 0, toBlock: 'pending', limit: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always prefer single property per line.
defaultMessage='Your account is already verified.' | ||
/> | ||
</p> | ||
</div> | ||
); | ||
} else if (isVerified === false) { | ||
} else if (accountIsVerified === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else should be sufficient - prop set as bool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a nullable bool. i know this is ugly, but spamming the props
didn't feel right either. not happy with this 😕
/> | ||
</p> | ||
</div> | ||
); | ||
} else if (hasRequested === false) { | ||
} else if (accountHasRequested === false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a nullable bool. i know this is ugly, but spamming the props
didn't feel right either. not happy with this 😕
|
||
import EmailVerificationABI from '~/contracts/abi/email-verification.json'; | ||
import VerificationStore, { | ||
LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE | ||
} from './store'; | ||
import { isServerRunning, hasReceivedCode, postToServer } from '~/3rdparty/email-verification'; | ||
const ZERO20 = '0x0000000000000000000000000000000000000000'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line before const.
if (address === ZERO20) { | ||
this.isAbleToRequest = true; | ||
} else { | ||
this.isAbleToRequest = new Error('Another account has been verified using this e-mail.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have preferred another way instead of a bool + Error type mixed. (e.g. set to bool in previous statement, as Error here)
this.isAbleToRequest = new Error('Another account has been verified using this e-mail.'); | ||
} | ||
}) | ||
.catch((err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not error? We are not gaining anything by not typing 2 letters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a common pattern in the Node.js ecosystem, from the Node.js docs to MDN to lots of well-known modules. I'm fine with moving to error
if you mind.
@@ -67,6 +67,18 @@ export default class SMSVerificationStore extends VerificationStore { | |||
return hasReceivedCode(this.number, this.account, this.isTestnet); | |||
} | |||
|
|||
// SMS verification events don't contain the phone number, so we will have to | |||
// send a new request every single time. See below. | |||
@action checkIfAbleToRequest = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkIf? Doesn't sound like something is being set? (Maybe switch
or set
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, don't like switch
, setIfAbleToRequest
is ok. isAbleToRequest
sounds like it's fully pure, so check
seemed like a compromise. will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert
might also work.
this.isVerified = isVerified; | ||
const accountIsVerified = checkIfVerified(contract, account) | ||
.then((accountIsVerified) => { | ||
this.accountIsVerified = accountIsVerified; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just be aware that MobX will complain here (since it is async) as soon as switched to strict mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will mobx recognise load
as an async action if we return the Promise.all
below?
js/src/modals/Verification/store.js
Outdated
return request.postTransaction(options, values); | ||
}) | ||
.then((handle) => { | ||
// TODO: The "request rejected" error doesn't have any property to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is a TODO? Possibly rather a note?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to find a better solution, although we're technically limited right now.
@@ -231,20 +231,22 @@ class Verification extends Component { | |||
} else if (method === 'email') { | |||
fields.push({ | |||
key: 'email', | |||
label: 'email address', | |||
label: 'e-mail address', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would obviously have preferred FormattedMessage here - it is coming more and more to the fore.
Style & coding issues that detracts a bit from maintainability and ease of understanding, however nothing functional broken nor buggy. |
Hopefully addresses #4280. 😛
Let's assume you
request
ed email verification usingfoo@bar
and then aborted the process. The request has been sent to the contract, but the verification server hasn't issued any email.Right now, the verification process assumes that in this case you will want to continue verifying
foo@bar
. Trying to verifyfoo@baz
will fail, because the UI happily accepts it, but doesn't send a new request.The PR makes the specific stores able to determine wether a new request shall be sent, using a method called
shallRequestAgain
. For email verification, it compares theemailHash
of the pastrequest
and the values now entered in the UI.For sms verification, we have no such information in the
request
tx, so it will always send anotherrequest
. This may cost the user more money, but given that it fails otherwise, it seems like a reasonable tradeoff.All of this goes along with commits at ethcore/sms-verification and at ethcore/email-verification to make sure the server really picks the latest
Requested
event to verify theemailHash
.