Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify onboarding #231

Merged
merged 6 commits into from
Nov 8, 2024
Merged

Simplify onboarding #231

merged 6 commits into from
Nov 8, 2024

Conversation

grod220
Copy link
Contributor

@grod220 grod220 commented Nov 7, 2024

Closes #226
Closes #227
Closes #221

  • Lots of deletions related to onboarding flow
  • Removes wallet birthday from being a user-facing concept
  • Onboarding automatically chooses random rpc + frontend for user
  • Removes "Forgot password?" flow
  • Only generates 12 word seedphrases

Comment on lines -20 to -25
if (!grpcEndpoint) {
return redirect(PagePath.SET_GRPC_ENDPOINT);
}
if (!frontendUrl) {
return redirect(PagePath.SET_DEFAULT_FRONTEND);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks no longer necessary as we now set all of these at once and not separate steps

@@ -65,36 +58,11 @@ export const GenerateSeedPhrase = () => {
disabled={!reveal}
text={phrase.join(' ')}
label={<span className='font-bold text-muted-foreground'>Copy to clipboard</span>}
className='m-auto w-48'
className='m-auto'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI bug fix. After clicking copy, it would jump to the left. This fixes that.

<p className='text-center text-muted-foreground'>
Need help? Contact{' '}
<a
className='cursor-pointer text-teal hover:underline'
target='_blank'
href='https://discord.com/channels/824484045370818580/1077672871251415141'
href='https://discord.com/channels/824484045370818580/1245108769143394457'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The support channel

Comment on lines +116 to +131
* Removes key/value from db (waits on ongoing migration). If there is a default, sets that.
*/
async remove<K extends keyof T>(key: K): Promise<void> {
await this.withDbLock(async () => {
await this.storage.remove(String(key));
// Prevent removing dbVersion
if (key === 'dbVersion') {
throw new Error('Cannot remove dbVersion');
}

const specificKey = key as K & Exclude<keyof T, 'dbVersion'>;
const defaultValue = this.defaults[specificKey];
if (defaultValue !== undefined) {
await this._set({ [specificKey]: defaultValue } as Record<K, T[K]>);
} else {
await this.storage.remove(String(specificKey));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort of a bug here. When removing from storage, we should 1) ensure the consumer is not deleted the version key and 2) if it has a default (like say an empty array) we should set it as that and not undefined. This caused a bug while I was working on this PR.

@grod220 grod220 requested a review from a team November 7, 2024 19:49
Comment on lines 34 to 35
// Fetch the block height from a specific RPC endpoint with a request-level timeout that superceeds
// the channel transport-level timeout to prevent hanging requests.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: could we add this comment back? It’s helpful for contextualizing the DEFAULT_TRANSPORT_OPTS timeout.

Comment on lines 23 to 28
const { appParameters } = await createPromiseClient(
AppService,
createGrpcWebTransport({ baseUrl: randomRpc.url }),
).appParameters({}, DEFAULT_TRANSPORT_OPTS);
if (!appParameters?.chainId) {
throw new Error('No chain id');
Copy link
Contributor

@TalDerei TalDerei Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: move the numeraires selection logic after an rpc endpoint has been chosen and the block height has been successfully queried.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can move the numeraires query down, but curious, what makes it better being lower than the other queries?

const result = await tendermintClient.getStatus({}, { signal: AbortSignal.timeout(timeoutMs) });
if (!result.syncInfo) {
throw new Error('No syncInfo in getStatus result');
if (seedPhraseOrigin === SEED_PHRASE_ORIGIN.NEWLY_GENERATED) {
Copy link
Contributor

@TalDerei TalDerei Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: based on other comments below, maybe we should avoid guarding the grpc promise client logic by wallet type (seed versus imported) and instead apply the guard only to the wallet birthday height logic?

const walletBirthday = Number(result.syncInfo.latestBlockHeight);
await localExtStorage.set('walletCreationBlockHeight', walletBirthday);

to also prevent setting a faulty grpc endpoint in local extension storage for imported wallets

await localExtStorage.set('grpcEndpoint', randomRpc.url);

which would similarly block onboarding by causing syncing to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea 👍

Comment on lines 34 to 41
const tendermintClient = createPromiseClient(
TendermintProxyService,
createGrpcWebTransport({ baseUrl: randomRpc.url }),
);
const result = await tendermintClient.getStatus({}, DEFAULT_TRANSPORT_OPTS);
if (!result.syncInfo) {
throw new Error('No syncInfo in getStatus result');
}
Copy link
Contributor

@TalDerei TalDerei Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think we should revert to using react query (useLatestBlockHeightWithFallback) for randomly sampling the rpc. The dynamic block height fetching needs fallback support, using a recursive callback to try another endpoint if the current one fails. Currently, if a faulty rpc isn't queryable due to an unresponsive server or network error, it would cause onboarding to fail with an error. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need react query for this call (given there is not reliance upon the render lifecycle). However, it does feel like we already have this code to do retries and should use it. Will add 👍

@@ -138,6 +138,7 @@ export const useGrpcEndpointForm = (isOnboarding: boolean) => {
setConfirmChangedChainIdPromise(undefined);
}

await clearWalletCreationHeight(); // changing chain id means the wallet birthday is no longer valid
Copy link
Contributor

@TalDerei TalDerei Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: manually tested across different chain Ids, and it properly clears the wallet height 👍

@TalDerei
Copy link
Contributor

TalDerei commented Nov 7, 2024

left some suggestions mainly around rpc selection; great work streamlining the onboarding flow!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TalDerei a little dependency injection allowed me to add these lovely tests

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!

@grod220 grod220 force-pushed the simplify-onboarding branch from 2e90c28 to c8f6e51 Compare November 8, 2024 03:43
@grod220
Copy link
Contributor Author

grod220 commented Nov 8, 2024

Will need final leadership review before deploying, but can follow up with necessary follow up PRs for additional changes

@grod220 grod220 merged commit 2d0e9d1 into main Nov 8, 2024
3 checks passed
@grod220 grod220 deleted the simplify-onboarding branch November 8, 2024 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants