-
-
Notifications
You must be signed in to change notification settings - Fork 231
Add gasFeeEstimates
for batch transactions
#5886
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
base: main
Are you sure you want to change the base?
Conversation
…a publish batch hook
Co-authored-by: Matthew Walsh <[email protected]>
…:MetaMask/core into feat/add-batch-transaction-approval-type
…-estimate-gas-batch-transaction
…-estimate-gas-batch-transaction
…-estimate-gas-batch-transaction
…estimate-gas-fee-batch-tx
gasFeeEstimates
for batch transactionsgasFeeEstimates
for batch transactions
status: TransactionStatus; | ||
|
||
/** When the transaction was created. */ | ||
time: number; |
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.
Rather than adding these purely to support the DefaultGasFeeFlow
, could we instead just use mock values at the point of calling? To minimise the complexity here as much as possible?
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.
Sure, I removed the time
property, I'm keeping status
to filter it in the next PR and filter unapproved transactionBatches
in the GasFeePoller
.
}, | ||
}); | ||
|
||
txBatchMeta.gasFeeEstimates = gasFeeResponse.estimates; |
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 nature of gas fee estimates is they change per block, so should this ticket also update the GasFeePoller
to update the batch metadata overtime, or is that a separate dedicated ticket?
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.
Yeah, we split into two tickets, and I'm currently working on it on a separate PR.
}); | ||
|
||
const gasFeeResponse = await defaultGasFeeFlow.getGasFees({ | ||
ethQuery: getEthQuery(networkClientId), |
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, should we define ethQuery
as a variable as we'd likely need it in future, and helps readability?
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.
Suro, done.
@@ -1450,6 +1504,8 @@ describe('Batch Utils', () => { | |||
|
|||
const result = await resultPromise; | |||
expect(result?.batchId).toMatch(/^0x[0-9a-f]{32}$/u); | |||
expect(simulateGasBatchMock).toHaveBeenCalledTimes(1); | |||
expect(getGasFeesMock).toHaveBeenCalledTimes(1); |
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 this warrant dedicated separate unit tests to verify that gas limit and gas fees are actually set on the batch metadata in the state?
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.
I've created a dedicated test for updating gas properties.
316f3d8
Explanation
This PR enhances
TransactionBatchMeta
by adding support forgasFeeEstimates
,time
, andstatus
.When both
useHook
andrequireApproval
aretrue
, the batch approval flow is triggered, andgasFeeEstimates
are populated using theDefaultGasFeeFlow
. These estimates are then passed along with the request to be consumed by the client.Changes
TransactionBatchMeta
to include:gasFeeEstimates
status
prepareApprovalData
References
Changelog
Checklist