Skip to content
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: detect incoming transactions using accounts API #4927

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

matthewwalsh0
Copy link
Member

@matthewwalsh0 matthewwalsh0 commented Nov 14, 2024

Explanation

Poll for incoming transactions using the accounts API rather than Etherscan.

Specifically:

  • Remove polling on each new block via PollingBlockTracker.
    • Polling will occur every 30 seconds and support multiple chains simultaneously.
  • Remove etherscan util and EtherscanRemoteTransactionSource.
  • Create accounts-api util and AccountsApiRemoteTransactionSource.
  • Remove ETHERSCAN_SUPPORTED_NETWORKS constant.
  • Replace block number based query optimisation with cursors.
  • Use single instance of IncomingTransactionHelper.
    • Remove IncomingTransactionHelper instance creation from MultichainTrackingHelper.
  • Move caching logic inside RemoteTransactionSource via getCache and updateCache properties.

References

Changelog

See CHANGELOG.md.

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
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review November 21, 2024 13:53
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner November 21, 2024 13:53
@matthewwalsh0 matthewwalsh0 marked this pull request as draft November 21, 2024 17:02
Move cache logic into remote transaction source.
Support queryEntireHistory property.
Support updateTransactions property.
Support includeTokenTransfers property.
Ignore duplicate incoming transactions.
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "19.0.0-preview-690da12e",
  "@metamask-previews/address-book-controller": "6.0.1-preview-690da12e",
  "@metamask-previews/announcement-controller": "7.0.1-preview-690da12e",
  "@metamask-previews/approval-controller": "7.1.1-preview-690da12e",
  "@metamask-previews/assets-controllers": "44.1.0-preview-690da12e",
  "@metamask-previews/base-controller": "7.0.2-preview-690da12e",
  "@metamask-previews/build-utils": "3.0.1-preview-690da12e",
  "@metamask-previews/chain-controller": "0.1.3-preview-690da12e",
  "@metamask-previews/composable-controller": "9.0.1-preview-690da12e",
  "@metamask-previews/controller-utils": "11.4.3-preview-690da12e",
  "@metamask-previews/ens-controller": "15.0.0-preview-690da12e",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-690da12e",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-690da12e",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-690da12e",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-690da12e",
  "@metamask-previews/keyring-controller": "18.0.0-preview-690da12e",
  "@metamask-previews/logging-controller": "6.0.2-preview-690da12e",
  "@metamask-previews/message-manager": "11.0.1-preview-690da12e",
  "@metamask-previews/multichain": "0.0.0-preview-690da12e",
  "@metamask-previews/name-controller": "8.0.1-preview-690da12e",
  "@metamask-previews/network-controller": "22.0.2-preview-690da12e",
  "@metamask-previews/notification-controller": "7.0.0-preview-690da12e",
  "@metamask-previews/notification-services-controller": "0.13.0-preview-690da12e",
  "@metamask-previews/permission-controller": "11.0.3-preview-690da12e",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-690da12e",
  "@metamask-previews/phishing-controller": "12.3.0-preview-690da12e",
  "@metamask-previews/polling-controller": "12.0.1-preview-690da12e",
  "@metamask-previews/preferences-controller": "14.0.0-preview-690da12e",
  "@metamask-previews/profile-sync-controller": "1.0.2-preview-690da12e",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-690da12e",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-690da12e",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-690da12e",
  "@metamask-previews/signature-controller": "22.0.0-preview-690da12e",
  "@metamask-previews/transaction-controller": "39.1.0-preview-690da12e",
  "@metamask-previews/user-operation-controller": "18.0.0-preview-690da12e"
}

@MetaMask MetaMask deleted a comment from github-actions bot Nov 22, 2024
@MetaMask MetaMask deleted a comment from github-actions bot Nov 22, 2024
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

1 similar comment
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "20.0.0-preview-6879d4ce",
  "@metamask-previews/address-book-controller": "6.0.1-preview-6879d4ce",
  "@metamask-previews/announcement-controller": "7.0.1-preview-6879d4ce",
  "@metamask-previews/approval-controller": "7.1.1-preview-6879d4ce",
  "@metamask-previews/assets-controllers": "45.1.0-preview-6879d4ce",
  "@metamask-previews/base-controller": "7.0.2-preview-6879d4ce",
  "@metamask-previews/build-utils": "3.0.1-preview-6879d4ce",
  "@metamask-previews/chain-controller": "0.2.0-preview-6879d4ce",
  "@metamask-previews/composable-controller": "9.0.1-preview-6879d4ce",
  "@metamask-previews/controller-utils": "11.4.3-preview-6879d4ce",
  "@metamask-previews/ens-controller": "15.0.0-preview-6879d4ce",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-6879d4ce",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-6879d4ce",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-6879d4ce",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-6879d4ce",
  "@metamask-previews/keyring-controller": "19.0.0-preview-6879d4ce",
  "@metamask-previews/logging-controller": "6.0.2-preview-6879d4ce",
  "@metamask-previews/message-manager": "11.0.1-preview-6879d4ce",
  "@metamask-previews/multichain": "1.0.0-preview-6879d4ce",
  "@metamask-previews/name-controller": "8.0.1-preview-6879d4ce",
  "@metamask-previews/network-controller": "22.0.2-preview-6879d4ce",
  "@metamask-previews/notification-controller": "7.0.0-preview-6879d4ce",
  "@metamask-previews/notification-services-controller": "0.14.0-preview-6879d4ce",
  "@metamask-previews/permission-controller": "11.0.3-preview-6879d4ce",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-6879d4ce",
  "@metamask-previews/phishing-controller": "12.3.0-preview-6879d4ce",
  "@metamask-previews/polling-controller": "12.0.1-preview-6879d4ce",
  "@metamask-previews/preferences-controller": "15.0.0-preview-6879d4ce",
  "@metamask-previews/profile-sync-controller": "2.0.0-preview-6879d4ce",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-6879d4ce",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-6879d4ce",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-6879d4ce",
  "@metamask-previews/signature-controller": "23.0.0-preview-6879d4ce",
  "@metamask-previews/transaction-controller": "40.1.0-preview-6879d4ce",
  "@metamask-previews/user-operation-controller": "19.0.0-preview-6879d4ce"
}

@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "20.0.0-preview-76d52936",
  "@metamask-previews/address-book-controller": "6.0.1-preview-76d52936",
  "@metamask-previews/announcement-controller": "7.0.1-preview-76d52936",
  "@metamask-previews/approval-controller": "7.1.1-preview-76d52936",
  "@metamask-previews/assets-controllers": "45.1.0-preview-76d52936",
  "@metamask-previews/base-controller": "7.0.2-preview-76d52936",
  "@metamask-previews/build-utils": "3.0.1-preview-76d52936",
  "@metamask-previews/chain-controller": "0.2.0-preview-76d52936",
  "@metamask-previews/composable-controller": "9.0.1-preview-76d52936",
  "@metamask-previews/controller-utils": "11.4.3-preview-76d52936",
  "@metamask-previews/ens-controller": "15.0.0-preview-76d52936",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-76d52936",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-76d52936",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-76d52936",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-76d52936",
  "@metamask-previews/keyring-controller": "19.0.0-preview-76d52936",
  "@metamask-previews/logging-controller": "6.0.2-preview-76d52936",
  "@metamask-previews/message-manager": "11.0.1-preview-76d52936",
  "@metamask-previews/multichain": "1.0.0-preview-76d52936",
  "@metamask-previews/name-controller": "8.0.1-preview-76d52936",
  "@metamask-previews/network-controller": "22.0.2-preview-76d52936",
  "@metamask-previews/notification-controller": "7.0.0-preview-76d52936",
  "@metamask-previews/notification-services-controller": "0.14.0-preview-76d52936",
  "@metamask-previews/permission-controller": "11.0.3-preview-76d52936",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-76d52936",
  "@metamask-previews/phishing-controller": "12.3.0-preview-76d52936",
  "@metamask-previews/polling-controller": "12.0.1-preview-76d52936",
  "@metamask-previews/preferences-controller": "15.0.0-preview-76d52936",
  "@metamask-previews/profile-sync-controller": "2.0.0-preview-76d52936",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-76d52936",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-76d52936",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-76d52936",
  "@metamask-previews/signature-controller": "23.0.0-preview-76d52936",
  "@metamask-previews/transaction-controller": "40.1.0-preview-76d52936",
  "@metamask-previews/user-operation-controller": "19.0.0-preview-76d52936"
}

@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

@matthewwalsh0 matthewwalsh0 marked this pull request as ready for review November 26, 2024 16:24
@matthewwalsh0 matthewwalsh0 requested a review from a team as a code owner November 26, 2024 16:24
Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "20.0.0-preview-09dff6fd",
  "@metamask-previews/address-book-controller": "6.0.1-preview-09dff6fd",
  "@metamask-previews/announcement-controller": "7.0.1-preview-09dff6fd",
  "@metamask-previews/approval-controller": "7.1.1-preview-09dff6fd",
  "@metamask-previews/assets-controllers": "45.1.0-preview-09dff6fd",
  "@metamask-previews/base-controller": "7.0.2-preview-09dff6fd",
  "@metamask-previews/build-utils": "3.0.1-preview-09dff6fd",
  "@metamask-previews/chain-controller": "0.2.0-preview-09dff6fd",
  "@metamask-previews/composable-controller": "9.0.1-preview-09dff6fd",
  "@metamask-previews/controller-utils": "11.4.3-preview-09dff6fd",
  "@metamask-previews/ens-controller": "15.0.0-preview-09dff6fd",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-09dff6fd",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-09dff6fd",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-09dff6fd",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-09dff6fd",
  "@metamask-previews/keyring-controller": "19.0.0-preview-09dff6fd",
  "@metamask-previews/logging-controller": "6.0.2-preview-09dff6fd",
  "@metamask-previews/message-manager": "11.0.1-preview-09dff6fd",
  "@metamask-previews/multichain": "1.0.0-preview-09dff6fd",
  "@metamask-previews/name-controller": "8.0.1-preview-09dff6fd",
  "@metamask-previews/network-controller": "22.0.2-preview-09dff6fd",
  "@metamask-previews/notification-controller": "7.0.0-preview-09dff6fd",
  "@metamask-previews/notification-services-controller": "0.14.0-preview-09dff6fd",
  "@metamask-previews/permission-controller": "11.0.3-preview-09dff6fd",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-09dff6fd",
  "@metamask-previews/phishing-controller": "12.3.0-preview-09dff6fd",
  "@metamask-previews/polling-controller": "12.0.1-preview-09dff6fd",
  "@metamask-previews/preferences-controller": "15.0.0-preview-09dff6fd",
  "@metamask-previews/profile-sync-controller": "2.0.0-preview-09dff6fd",
  "@metamask-previews/queued-request-controller": "7.0.1-preview-09dff6fd",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-09dff6fd",
  "@metamask-previews/selected-network-controller": "19.0.0-preview-09dff6fd",
  "@metamask-previews/signature-controller": "23.0.0-preview-09dff6fd",
  "@metamask-previews/transaction-controller": "40.1.0-preview-09dff6fd",
  "@metamask-previews/user-operation-controller": "19.0.0-preview-09dff6fd"
}

adonesky1 and others added 4 commits November 26, 2024 20:22
## Changelog

### `@metamask/queued-request-controller`

## 7.1.0

### Removed

- `createQueuedRequestMiddleware` no longer takes a `useRequestQueue`
parameter. All requests are now queued if `shouldEnqueueRequest(req)`
returns true. ([#4941](#4941))


### `@metamask/selected-network-controller

## 19.1.0

### Removed

- The `SelectedNetworkController` constructor no longer expects a
`useRequestPreference` boolean nor an `onPreferencesStateChange`
listener. Removal of these parameters means that `domains` state will
always be added for sites that are granted permissions.
([#4941](#4941))

---------

Co-authored-by: Mark Stacey <[email protected]>
Major release of `@metamask/transaction-controller` to remove global
network usage.

Major release of `@metamask/user-operation-controller` due to
dependency.
…oved (#4978)

## Explanation

Updates the CAIP-25 mutators so that if the only eip155 account or scope
is removed then the entire permission is revoked.

## References

Related: MetaMask/metamask-extension#28709

## Changelog

<!--
If you're making any consumer-facing changes, list those changes here as
if you were updating a changelog, using the template below as a guide.

(CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or
FIXED. For security-related issues, follow the Security Advisory
process.)

Please take care to name the exact pieces of the API you've added or
changed (e.g. types, interfaces, functions, or methods).

If there are any breaking changes, make sure to offer a solution for
consumers to follow once they upgrade to the changes.

Finally, if you're only making changes to development scripts or tests,
you may replace the template below with "None".
-->

### `@metamask/multichain`

- **CHANGED**: `Caip25CaveatMutators.authorizedScopes.removeAccount` now
revokes the CAIP-25 endowment if the only account is removed.
- **CHANGED**: `Caip25CaveatMutators.authorizedScopes.removeScope` now
revokes the CAIP-25 endowment if the only non-wallet scope is removed.
- **CHANGED**: `setEthAccounts` no longer adds `wallet:eip155` to the
optionalScopes if it does not already exist.

## Checklist

- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've highlighted breaking changes using the "BREAKING" category
above as appropriate
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes

---------

Co-authored-by: Alex Donesky <[email protected]>
Release Multichain minor for mutator changes
@matthewwalsh0 matthewwalsh0 requested review from a team as code owners November 26, 2024 20:22
@matthewwalsh0
Copy link
Member Author

@metamaskbot publish-preview

Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "20.0.0-preview-2eec965c",
  "@metamask-previews/address-book-controller": "6.0.1-preview-2eec965c",
  "@metamask-previews/announcement-controller": "7.0.1-preview-2eec965c",
  "@metamask-previews/approval-controller": "7.1.1-preview-2eec965c",
  "@metamask-previews/assets-controllers": "45.1.0-preview-2eec965c",
  "@metamask-previews/base-controller": "7.0.2-preview-2eec965c",
  "@metamask-previews/build-utils": "3.0.1-preview-2eec965c",
  "@metamask-previews/chain-controller": "0.2.0-preview-2eec965c",
  "@metamask-previews/composable-controller": "9.0.1-preview-2eec965c",
  "@metamask-previews/controller-utils": "11.4.3-preview-2eec965c",
  "@metamask-previews/ens-controller": "15.0.0-preview-2eec965c",
  "@metamask-previews/eth-json-rpc-provider": "4.1.6-preview-2eec965c",
  "@metamask-previews/gas-fee-controller": "22.0.1-preview-2eec965c",
  "@metamask-previews/json-rpc-engine": "10.0.1-preview-2eec965c",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.5-preview-2eec965c",
  "@metamask-previews/keyring-controller": "19.0.0-preview-2eec965c",
  "@metamask-previews/logging-controller": "6.0.2-preview-2eec965c",
  "@metamask-previews/message-manager": "11.0.1-preview-2eec965c",
  "@metamask-previews/multichain": "1.1.0-preview-2eec965c",
  "@metamask-previews/name-controller": "8.0.1-preview-2eec965c",
  "@metamask-previews/network-controller": "22.0.2-preview-2eec965c",
  "@metamask-previews/notification-controller": "7.0.0-preview-2eec965c",
  "@metamask-previews/notification-services-controller": "0.14.0-preview-2eec965c",
  "@metamask-previews/permission-controller": "11.0.3-preview-2eec965c",
  "@metamask-previews/permission-log-controller": "3.0.1-preview-2eec965c",
  "@metamask-previews/phishing-controller": "12.3.0-preview-2eec965c",
  "@metamask-previews/polling-controller": "12.0.1-preview-2eec965c",
  "@metamask-previews/preferences-controller": "15.0.0-preview-2eec965c",
  "@metamask-previews/profile-sync-controller": "2.0.0-preview-2eec965c",
  "@metamask-previews/queued-request-controller": "8.0.0-preview-2eec965c",
  "@metamask-previews/rate-limit-controller": "6.0.1-preview-2eec965c",
  "@metamask-previews/selected-network-controller": "20.0.0-preview-2eec965c",
  "@metamask-previews/signature-controller": "23.0.0-preview-2eec965c",
  "@metamask-previews/transaction-controller": "41.0.0-preview-2eec965c",
  "@metamask-previews/user-operation-controller": "20.0.0-preview-2eec965c"
}

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

Successfully merging this pull request may close these issues.

3 participants