-
Notifications
You must be signed in to change notification settings - Fork 3
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
Simplify onboarding #231
Conversation
if (!grpcEndpoint) { | ||
return redirect(PagePath.SET_GRPC_ENDPOINT); | ||
} | ||
if (!frontendUrl) { | ||
return redirect(PagePath.SET_DEFAULT_FRONTEND); | ||
} |
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.
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' |
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.
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' |
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.
The support channel
* 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)); | ||
} |
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.
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.
// 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. |
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.
suggestion: could we add this comment back? It’s helpful for contextualizing the DEFAULT_TRANSPORT_OPTS
timeout.
const { appParameters } = await createPromiseClient( | ||
AppService, | ||
createGrpcWebTransport({ baseUrl: randomRpc.url }), | ||
).appParameters({}, DEFAULT_TRANSPORT_OPTS); | ||
if (!appParameters?.chainId) { | ||
throw new Error('No chain id'); |
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.
suggestion: move the numeraires selection logic after an rpc endpoint has been chosen and the block height has been successfully queried.
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.
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) { |
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.
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.
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.
good idea 👍
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'); | ||
} |
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.
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?
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.
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 |
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.
comment: manually tested across different chain Ids, and it properly clears the wallet height 👍
left some suggestions mainly around rpc selection; great work streamlining the onboarding flow! |
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.
@TalDerei a little dependency injection allowed me to add these lovely tests
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.
very nice!
2e90c28
to
c8f6e51
Compare
Will need final leadership review before deploying, but can follow up with necessary follow up PRs for additional changes |
Closes #226
Closes #227
Closes #221