The Sign up screen creates an account on the phone and then calls onboarding to register with r/demo/users on the blockchain. But the account names in the keystore on the phone and the blockchain are linked. If the account name already exists in r/demo/users, then oboarding fails to register with r/demo/users. And the keystore on the phone may have an account with the same name but different addresses.
We need to keep the keystore in sync with r/demo/users when the user enters name N on the signup screen. The following table covers all cases and the action to take.
Request name N.
N in keystore?
N in r/demo/users?
same addr?
action
yes
yes
yes
Offer to do normal signin, or choose new N
yes
yes
no
Bad case. Choose new N. (Delete N in keystore?)
yes
no
X
Offer to onboard existing account (check if need faucet to add coins), replace it, or choose new N
no
yes
yes
(keystore has same r/demo/users addr with different N2.) Offer to recreate as N in keystore, do signin.
no
yes
no
(keystore doesn't have r/demo/users addr.) Name is unavailable. Choose new N
no
no
X
Create name/addr in keystore, register in r/demo/users
The Sign up screen creates an account on the phone and then calls onboarding to register with r/demo/users on the blockchain. But the account names in the keystore on the phone and the blockchain are linked. If the account name already exists in r/demo/users, then oboarding fails to register with r/demo/users. And the keystore on the phone may have an account with the same name but different addresses.
We need to keep the keystore in sync with r/demo/users when the user enters name N on the signup screen. The following table covers all cases and the action to take.