-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Parameterize SmartTransactionsController state by ChainId for MultiChain + Integrate PollingController Mixin #210
Conversation
275b4f2
to
d2070ab
Compare
b4222f6
to
b3a7a22
Compare
b3a7a22
to
bcab24b
Compare
…nfirmSmartTransaction is now private
ebc6818
to
c34e0b3
Compare
8a8b836
to
1a1bcbf
Compare
@@ -117,3 +117,5 @@ export type SignedTransaction = any; | |||
|
|||
// TODO | |||
export type SignedCanceledTransaction = any; | |||
|
|||
export type Hex = `0x${string}`; |
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.
Could this be imported from @metamask/utils
?
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 suppose we could. I assume this is used somewhere else in the extension dependency graph so probably not adding any weight. I just feel silly adding the full package just to pull in a type here...
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.
cc @mcmire how do you generally think about these cases ☝️ ?
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.
Drive by comment: 0x{string}
isn't Hex, and @metamask/utils
is used by lots of other packages, so this shouldn't be in a general utility library if its is to be named Hex
. Unbounded (length) hex strings are currently not possible in TypeScript (microsoft/TypeScript#43335).
You can maybe get typescript to full check 30ish characters or so, more if you make use of a "trampoline", but type checking will be so slow it'll be unusable.
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.
That's true — the Hex
type isn't as useful as it could be. For what it's worth we do have some ways to double check that a string is a real hex string at runtime in @metamask/utils
, although we might not be using them as much as we should. I tend to think of Hex
as more of a signal to readers than an actual constraint for consumers.
Since it's basically an approximation and easy to write, I'm okay with copying this and not importing it from @metamask/utils
. If we need something else from utils then we can always bring the package in later.
@@ -117,3 +117,5 @@ export type SignedTransaction = any; | |||
|
|||
// TODO | |||
export type SignedCanceledTransaction = any; | |||
|
|||
export type Hex = `0x${string}`; |
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.
That's true — the Hex
type isn't as useful as it could be. For what it's worth we do have some ways to double check that a string is a real hex string at runtime in @metamask/utils
, although we might not be using them as much as we should. I tend to think of Hex
as more of a signal to readers than an actual constraint for consumers.
Since it's basically an approximation and easy to write, I'm okay with copying this and not importing it from @metamask/utils
. If we need something else from utils then we can always bring the package in later.
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring: Next stepsTake a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with |
Time to update jest #210 (comment) @mcmire ? Jest package wasn't changed in this PR so this must be a new audit finding? |
@SocketSecurity ignore ws@7.5.9 |
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.
Getting closer!
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.
One more thing and then I think we're good 😅
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.
Thanks for your patience — everything looks good now! (I was getting the test failure locally — I don't think requests are being mocked in this package fully. Should be able to re-run.)
@adonesky1 @mcmire I see this went with |
…ain + Integrate PollingController Mixin (#210) * integrating multichain controller upgrades * add test * cleanup * need to move confirmSmartTransaction tests into another test since confirmSmartTransaction is now private * actually for now leave it as a public method * cleanup * fix typeerror? * add test + cleanup * add a test + bump test coverage * update type * fix type issue * address feedback * fix provider logic * update test coverage threshholds * make a private and public version of updateSmartTransaction * fix capitalization" * addressing feedback * replace @ethersproject/providers with @metamask/eth-query * cleanup * address more feedback * remove @ethersproject/bignumber * make confirmSmartTransaction a private method * remove comment * getTransaction -> getTransactionByHash * fix ethquery mock
…ain + Integrate PollingController Mixin (#210) * integrating multichain controller upgrades * add test * cleanup * need to move confirmSmartTransaction tests into another test since confirmSmartTransaction is now private * actually for now leave it as a public method * cleanup * fix typeerror? * add test + cleanup * add a test + bump test coverage * update type * fix type issue * address feedback * fix provider logic * update test coverage threshholds * make a private and public version of updateSmartTransaction * fix capitalization" * addressing feedback * replace @ethersproject/providers with @metamask/eth-query * cleanup * address more feedback * remove @ethersproject/bignumber * make confirmSmartTransaction a private method * remove comment * getTransaction -> getTransactionByHash * fix ethquery mock
…ain + Integrate PollingController Mixin (#210) * integrating multichain controller upgrades * add test * cleanup * need to move confirmSmartTransaction tests into another test since confirmSmartTransaction is now private * actually for now leave it as a public method * cleanup * fix typeerror? * add test + cleanup * add a test + bump test coverage * update type * fix type issue * address feedback * fix provider logic * update test coverage threshholds * make a private and public version of updateSmartTransaction * fix capitalization" * addressing feedback * replace @ethersproject/providers with @metamask/eth-query * cleanup * address more feedback * remove @ethersproject/bignumber * make confirmSmartTransaction a private method * remove comment * getTransaction -> getTransactionByHash * fix ethquery mock
Resolves: https://github.com/MetaMask/MetaMask-planning/issues/1039
Integrates new
PollingController
abstraction into theSmartTransactionsController
, implements the_executePoll
method and parameterizes theupdateSmartTransactions
method by networkClientId such that pending SmartTransaction statuses can be polled for concurrently across different chains.A note: As is our current controller refactor strategy, these changes are additive, backwards compatible and coexist alongside the existing globally selected network pattern. Once we fully adopt this polling pattern we should no longer access the root
liveness
andfees
state but rather access these values by chainId fromlivenessByChainId
andfeesByChainId
.Added
PollingController
mixin into theSmartTransactionsController
and implements the abstract_executePoll
method.Changed
networkClientId
argument to theupdateSmartTransaction
method which, if passed, is used fetch the chainId that corresponds to thenetworkClientId
and is then used to fetch and update the status of pending smart transactions for that chainId.