-
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
Changes from 2 commits
bf5764c
8bcb787
67c559d
6b278ef
debf8b6
e51e414
b6c4538
f38c061
5421434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,8 @@ export const estimateUnlockAndCrosschainSwap = async ({ | |
}); | ||
} | ||
|
||
let unlockGasLimit; | ||
|
||
if (swapAssetNeedsUnlocking) { | ||
unlockGasLimit = await estimateApprove({ | ||
const unlockGasLimit = await estimateApprove({ | ||
owner: accountAddress, | ||
tokenAddress: sellTokenAddress, | ||
spender: allowanceTarget, | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. this will bubble up to the estimation and use the |
||
} | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
|
||
return gasLimit.toString(); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,6 @@ export const estimateUnlockAndSwap = async ({ | |
let swapAssetNeedsUnlocking = false; | ||
|
||
const nativeAsset = isLowerCaseMatch(ETH_ADDRESS_AGGREGATOR, sellTokenAddress) || isNativeAsset(sellTokenAddress, chainId); | ||
|
||
if (!isNativeAssetUnwrapping && !nativeAsset) { | ||
swapAssetNeedsUnlocking = await assetNeedsUnlocking({ | ||
owner: accountAddress, | ||
|
@@ -65,12 +64,8 @@ export const estimateUnlockAndSwap = async ({ | |
if (gasLimitFromMetadata) { | ||
return gasLimitFromMetadata; | ||
} | ||
} | ||
|
||
let unlockGasLimit; | ||
|
||
if (swapAssetNeedsUnlocking) { | ||
unlockGasLimit = await estimateApprove({ | ||
const unlockGasLimit = await estimateApprove({ | ||
owner: accountAddress, | ||
tokenAddress: sellTokenAddress, | ||
spender: getRainbowRouterContractAddress(chainId), | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. and here |
||
} | ||
|
||
return gasLimit.toString(); | ||
}; | ||
|
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