Skip to content

Use block tracker to poll incoming transactions#1579

Merged
matthewwalsh0 merged 6 commits intomainfrom
refactor/965-block-tracker-incoming-transactions
Aug 22, 2023
Merged

Use block tracker to poll incoming transactions#1579
matthewwalsh0 merged 6 commits intomainfrom
refactor/965-block-tracker-incoming-transactions

Conversation

@matthewwalsh0
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 commented Aug 14, 2023

Explanation

Currently the TransactionController retrieves incoming transactions when explicitly requested via the fetchAll method meaning the cadence of polling is dictated by the client.

This PR removes the fetchAll method and instead uses the blockTracker instance provided to the controller to automatically poll for incoming transactions whenever the current network has a new block.

This polling can be started and stopped using the startIncomingTransactionPolling and stopIncomingTransactionPolling methods respectively. Or an update can be required immediately via the updateIncomingTransactions method.

Additional optional arguments have also been added to the constructor to configure the incoming transaction support.

References

Closes #965

Changelog

@metamask/transaction-controller

  • BREAKING: Remove fetchAll method.
  • BREAKING: Add required getSelectedAddress callback argument to constructor.
  • BREAKING: Update fromBlock and limit types in RemoteTransactionSourceRequest.
  • BREAKING: Add isSupportedNetwork method to RemoteTransactionSource interface.
  • ADDED: Optional incomingTransactions constructor arguments including apiKey, includeTokenTransfers, isEnabled, and updateTransactions.
  • ADDED: startIncomingTransactionPolling, stopIncomingTransactionPolling, and updateIncomingTransactions methods.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review August 15, 2023 11:42
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner August 15, 2023 11:42
OGPoyraz
OGPoyraz previously approved these changes Aug 16, 2023
vinistevam
vinistevam previously approved these changes Aug 18, 2023
Copy link
Copy Markdown
Contributor

@vinistevam vinistevam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing PR @matthewwalsh0 🚀

@matthewwalsh0 matthewwalsh0 dismissed stale reviews from vinistevam and OGPoyraz via cd90e91 August 18, 2023 14:15
@matthewwalsh0 matthewwalsh0 merged commit 921c234 into main Aug 22, 2023
@matthewwalsh0 matthewwalsh0 deleted the refactor/965-block-tracker-incoming-transactions branch August 22, 2023 09:44
@legobeat
Copy link
Copy Markdown
Contributor

Related: MetaMask/eth-block-tracker#169

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants