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

Fix crash due to failed estimated gas limit #6055

Merged
merged 9 commits into from
Sep 12, 2024
Merged

Conversation

walmat
Copy link
Contributor

@walmat walmat commented Aug 28, 2024

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 problematic String() cast which I presume was causing a lot of the issues. https://github.com/rainbow-me/rainbow/pull/6055/files#r1739045385

This could've been returning undefined but then cast to a string 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

  • test raps e2e (swaps, send erc20, send ens, etc.)

Copy link

linear bot commented Aug 28, 2024

@walmat walmat marked this pull request as draft August 28, 2024 19:39
} catch (e) {
return String(quote?.defaultGasLimit) || String(default_estimate);
return quote?.defaultGasLimit || default_estimate;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

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;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

and here

@walmat walmat marked this pull request as ready for review August 30, 2024 16:32
@walmat walmat requested review from brunobar79 and benisgold August 30, 2024 16:32
Copy link
Member

@benisgold benisgold left a 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

@brunobar79
Copy link
Member

Launch in simulator or device for 51f93b8

@brunobar79 brunobar79 requested review from estebanmino and removed request for brunobar79 September 9, 2024 17:29
src/raps/actions/unlock.ts Outdated Show resolved Hide resolved
@brunobar79
Copy link
Member

Launch in simulator or device for e91ef96

@walmat walmat merged commit 56e9585 into develop Sep 12, 2024
8 checks passed
@walmat walmat deleted the @matthew/APP-1819 branch September 12, 2024 16:27
walmat added a commit that referenced this pull request Sep 20, 2024
ibrahimtaveras00 added a commit that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants