-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: Support gas fee flows in swaps #12495
base: main
Are you sure you want to change the base?
feat: Support gas fee flows in swaps #12495
Conversation
Bitrise🔄🔄🔄 Commit hash: d1c85a7 Note
|
Bitrise❌❌❌ Commit hash: 1b2166e Note
Tip
|
Quality Gate passedIssues Measures |
let tradeGasFeeEstimates; | ||
const tradeTransaction = selectedQuote.trade; | ||
|
||
if (isEIP1559Network) { |
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.
Minor, is it worth encapsulating all this logic in the existing getTransactionPropertiesFromGasEstimates
but also passing the quote
argument?
|
||
let approvalGasFeeEstimates; | ||
|
||
if (isEIP1559Network) { |
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.
If we expanded getTransactionPropertiesFromGasEstimates
, could we just call again here but with the approval transaction or quote instead?
|
||
const { TransactionController } = Engine.context; | ||
|
||
const transactionGasFeeResponse = await TransactionController.estimateGasFee({ |
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 use the transaction controller utils file here instead?
@@ -156,3 +156,11 @@ export const selectNetworkClientId = createSelector( | |||
(networkControllerState: NetworkState) => | |||
networkControllerState.selectedNetworkClientId, | |||
); | |||
|
|||
export const selectIsEIP1559Network = createSelector( |
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.
We could also determine this from the gas fee estimate type, but this is better as it reduces coupling on the gas fee controller ❤️
|
||
const mockSelectedNetworkClientId = '1'; | ||
|
||
describe('NetworkController Selectors', () => { |
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.
Minor, but Redux discourage testing unit selectors in favour of mocking state in all component and hook tests so they get covered there.
const { maxFeePerGas } = transactionGasFeeEstimates?.high ?? {}; | ||
const { maxPriorityFeePerGas } = transactionGasFeeEstimates?.high ?? {}; | ||
|
||
const baseAndPriorityFeePerGas = maxPriorityFeePerGas |
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.
Is this needed in mobile since we add this return straight to the transaction params? And estimatedBaseFeeGwei
also?
Tested and seems to be working |
Description
This PR aims to adapt
estimateGasFee
fromTransactionController
for swapstrade
andapproval
transactions. For more information please see the extension PR applies same functionality: MetaMask/metamask-extension#27612Also adding basic unit tests for
QuoteView
screen.Related issues
Fixes: https://github.com/MetaMask/mobile-planning/issues/2026
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist