-
Notifications
You must be signed in to change notification settings - Fork 2
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
Re-enable numeraires in onboarding #203
Conversation
retry: 1, | ||
retryDelay: 0, |
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.
A single retry feels ok, without specifying these, react-query tends to retry indefinitely.
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: seems like react-query defaults to three consecutive retries?
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.
Hmm. Maybe it's the delay then that causes such long retry times. Alas, for our case, we want to fail fast given this is not a critical setting to select.
if (!chainId) { | ||
if (isError) { | ||
console.error(`Could not load numeraires for chainId: ${chainId}`); | ||
} | ||
return []; |
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 the !chainId conditional was necessary. Removing.
const { selectedNumeraires, selectNumeraire, saveNumeraires, networkChainId } = | ||
useStore(useNumerairesSelector); | ||
|
||
// 'chainId' from 'useChainIdQuery' is not available during onboarding, | ||
// this forces you to use two sources to guarantee 'chainId' for both settings and onboarding | ||
const { numeraires } = useNumeraires(chainId ?? networkChainId); |
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.
Instead of doing both (serving the settings & onboarding simultaneously internally), I changed the component so that chainId is passed in
// If query errors or there aren't numeraires in the registry, can skip | ||
useEffect(() => { | ||
if (numeraires.length === 0) { | ||
void onSuccess(); | ||
if (isError || (!isLoading && numeraires.length === 0)) { | ||
onSuccess(); | ||
} | ||
}, [numeraires]); | ||
}, [numeraires.length, isError, isLoading]); |
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 previous source of the bug. During the loading state, the numeraires array was length zero. Hence it was being skipped. Now it only skips if there is an error or it's still loading.
|
||
const [loading, setLoading] = useState(false); | ||
|
||
const handleSubmit = () => { | ||
setLoading(true); | ||
void (async function () { | ||
await saveNumeraires(); | ||
await chrome.runtime.sendMessage(ServicesMessage.ChangeNumeraires); | ||
await onSuccess(); | ||
void chrome.runtime.sendMessage(ServicesMessage.ChangeNumeraires); |
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.
Does not feel necessary to await the response here, hold up the UI from progressing. The fire-and-forget works.
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.
retry: 1, | ||
retryDelay: 0, |
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: seems like react-query defaults to three consecutive retries?
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.
Should we enforce a selection?
Choosing a numeraire does not feel like a critical setting selection. If there is a fetching error, we want to skip it and not fail hard at this step. Think we are ok to keep it as optional.
retry: 1, | ||
retryDelay: 0, |
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.
Hmm. Maybe it's the delay then that causes such long retry times. Alas, for our case, we want to fail fast given this is not a critical setting to select.
Bug fix. Now that a numeraire is available in the registry, Prax should be recognizing it and during onboarding, giving the users an opportunity to use it. This will enable usdc prices in minifront.
However, due to a react useEffect loading bug, it is skipping this step. This PR fixes that.