Repository navigation
Migrate TransactionController to BaseController v2 - #3827
Merged
mcmire merged 28 commits intoMar 7, 2024
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Fundamentally, this commit changes TransactionController so that it inherits from BaseController v2 instead of BaseController v1. This affects the signature of the constructor and the way that state is updated inside of the controller, but it also prompts other changes:
hubproperty, which was an instance of EventEmitter, to emit events at key points in the transaction processing flow. Now, a controller messenger is used instead, and all of the events now use a standard name.Record<string, Json>. As a result, all state property types needed to beJson-compatible. Some types were defined as interfaces and could merely be changed to type aliases, but concessions needed to be made in other cases to achieve compatibility.updateis called, state is recursively frozen at runtime, which means that transactions cannot be modified directly. Hence, numerous places within TransactionController needed to be updated so that transactions were copied before being modified. Some methods were even changed so that instead of directly modifying a transaction, they now return a new version.References
Fixes #3758.
Changelog
@metamask/transaction-controllerChecklist