-
-
Notifications
You must be signed in to change notification settings - Fork 205
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 atomic batch transactions #5306
base: main
Are you sure you want to change the base?
Conversation
Create prepare utils.
Add initial unit tests.
Add feature flags util.
@metamaskbot publish-preview |
@metamaskbot publish-preview |
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
log('Retrieved feature flags', featureFlags); | ||
|
||
return featureFlags as TransactionControllerFeatureFlags; | ||
} |
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.
Not blocking for this PR, but I have a doubt if it is ok to use launchdarkly to dynamically get data like this. May be we make our own api for the purpose.
Also, is there a plan at what stage we get rid of using feature flags for this functionality.
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.
It's not dynamically getting data, it's still reliant on the polling that is controlled by the client, so it won't fire a request for each usage.
Both of these usages are also still conceptually "feature flags" as the supported chains are a means to enable the feature progressively as each chain adds support.
Similarly, the contract addresses are a means to "release" new contracts for the user to upgrade to.
Even if they were purely for remote configuration, I think we've been doing this for even longer than feature flags through swaps and smart transactions. Why would we create our own service and infrastructure, and client logic, to achieve what is already possible with one platform?
There is no plans to remove this functionality in future since it's a key part of the management, and security model.
import { | ||
getEIP7702ContractAddresses, | ||
getEIP7702SupportedChains, | ||
} from './feature-flags'; |
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.
NIT: sorting imports
return { | ||
batchId, | ||
}; | ||
} |
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 does not look like utility function, may be it should have been part of controller itself. Also, does not look a good practice to pass functions, messenger to utility function like above.
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 main TransactionController
file is almost 4000 lines long so this is a fundamental part of our controller architecture to modularise functionality in order to keep it readable, maintainable, and testable.
The practice of passing callbacks and the messenger itself is well established as it's the same as what we do with the controllers themselves in the client, it provides a clean abstraction to provide logic in a decoupled way without duplication or unnecessarily coupling distinct pieces of logic.
Explanation
Support atomic batch transactions via EIP-7702, and ERC-7821.
Specifically:
addTransactionBatch
method withTransactionBatchRequest
andTransactionBatchResult
types.execute
call using ERC-7821 ABI.setCode
transaction if needed.isAtomicBatchSupported
method to identify which chains support atomic batch for a given account.batch
TransactionType
.batch
utils to encapsulate all batch-related logic.feature-flags
utils to encapsulate retrieval and fallback of LaunchDarkly configuration.to
of external transaction is not an internal account unlesstransactionType
isbatch
.References
Fixes #4096
Changelog
See
CHANGELOG.md
.Checklist