-
Notifications
You must be signed in to change notification settings - Fork 635
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
Fix crash due to failed estimated gas limit #6055
Conversation
} catch (e) { | ||
return String(quote?.defaultGasLimit) || String(default_estimate); | ||
return quote?.defaultGasLimit || default_estimate; |
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.
my guess was this was causing an issue with the string case on quote?.defaultGasLimit when undefined
@@ -71,7 +69,14 @@ export const estimateUnlockAndCrosschainSwap = async ({ | |||
quote, | |||
}); | |||
|
|||
if (swapGasLimit === null || swapGasLimit === undefined || isNaN(Number(swapGasLimit))) { | |||
return null; |
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.
this will bubble up to the estimation and use the basic_swap
defaults for the chain
const gasLimit = gasLimits.concat(swapGasLimit).reduce((acc, limit) => add(acc, limit), '0'); | ||
if (isNaN(Number(gasLimit))) { | ||
return null; |
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.
same here
@@ -85,7 +80,14 @@ export const estimateUnlockAndSwap = async ({ | |||
quote, | |||
}); | |||
|
|||
if (swapGasLimit === null || swapGasLimit === undefined || isNaN(Number(swapGasLimit))) { | |||
return null; |
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.
and here
const gasLimit = gasLimits.concat(swapGasLimit).reduce((acc, limit) => add(acc, limit), '0'); | ||
if (isNaN(Number(gasLimit))) { | ||
return null; |
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.
and here
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.
Small/probably inconsequential nits
src/__swaps__/screens/Swap/providers/SyncSwapStateAndSharedValues.tsx
Outdated
Show resolved
Hide resolved
This reverts commit 56e9585.
Fixes APP-1819
What changed (plus any additional context for devs)
Biggest change here is adding
NaN
checks throughout raps so we don't receive an invalid gas limit. I also removed a suspiciously problematicString()
cast which I presume was causing a lot of the issues. https://github.com/rainbow-me/rainbow/pull/6055/files#r1739045385This could've been returning
undefined
but then cast to astring
which would've been problematic later on in the flow.Screen recordings / screenshots
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-09-10.at.14.08.11.mp4
What to test