Support watching assets on a specific account by Cal-L · Pull Request #1124 · MetaMask/core · GitHub
Skip to content

Support watching assets on a specific account - #1124

Merged
Cal-L merged 9 commits into
mainfrom
patch/5773-improve-watch-asset
Mar 30, 2023
Merged

Support watching assets on a specific account#1124
Cal-L merged 9 commits into
mainfrom
patch/5773-improve-watch-asset

Conversation

@Cal-L

@Cal-L Cal-L commented Mar 8, 2023

Copy link
Copy Markdown
Contributor

Support watching assets on a specific account

The purpose of the changes to is allow a user to store a watched asset to the token states in the TokensController. Why is this needed? The introduction of the Permission System on mobile now allows users to interact with Dapps using accounts that are different than what is active on their wallet screen. This dynamic makes it possible for users to watch assets under the active Dapp account, which may be different than the active wallet account. As a result, we needed to enable passing of an account address to both the watchAsset and addToken method, that would allow for storing of tokens under specific account addresses. All of the listed changes below is backwards compatible and code that uses the TokensController will not need to change.

Description

  • CHANGED:

    • TokensController.watchAsset
      • Added optional interactingAddress: string parameter with the definition of The address of the account that is requesting to watch the asset.
    • TokensController.acceptWatchAsset
      • Now passes an account address (interactingAddress: string || selectedAddress: string) into TokensController.addToken under the ERC20 switch condition.
    • TokensController.addToken
      • If interactingAddress is defined and is not equal to selectedAddress, this method will function the same way but will not update tokens, ignoredTokens, detectedTokens token states.
      • If interactingAddress is not defined, this method will use the selectedAddress and function the same way.
    • SuggestedAssetMeta type
      • Added optional interactingAddress?: string property. This is only populated if interactingAddress is passed into TokensController.watchAsset.

Checklist

  • Tests are included if applicable
  • Any added code is fully documented

Issue

Resolves #???

@Cal-L Cal-L changed the title Patch/5773 improve watch asset Support watching assets on specific accounts Mar 8, 2023
@Cal-L Cal-L changed the title Support watching assets on specific accounts Support watching assets on a specific account Mar 8, 2023
@Cal-L
Cal-L marked this pull request as ready for review March 9, 2023 03:23
@Cal-L
Cal-L requested a review from a team as a code owner March 9, 2023 03:23

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO - Provide selectedAddress as fallback to ensure that suggestedAssetMeta always has an interactingAddress

tommasini
tommasini previously approved these changes Mar 22, 2023

@tommasini tommasini left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@Gudahtt

Gudahtt commented Mar 23, 2023

Copy link
Copy Markdown
Member

Hmm, I hadn't realized before that EIP-747 relied upon the current selected account. I guess we'll need to update https://eips.ethereum.org/EIPS/eip-747 to work more effectively with scenarios where multiple accounts are connected.

@adonesky1

Copy link
Copy Markdown
Contributor

Hmm, I hadn't realized before that EIP-747 relied upon the current selected account. I guess we'll need to update https://eips.ethereum.org/EIPS/eip-747 to work more effectively with scenarios where multiple accounts are connected.

we're discussing related topics in context of adding support for adding NFTs via wallet_watchAsset and architecting changes with multichain in mind. @Cal-L perhaps you should join us to discuss this work in our meeting tomorrow?

Comment thread packages/assets-controllers/src/TokensController.ts Outdated
Gudahtt
Gudahtt previously approved these changes Mar 23, 2023

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Left one suggestion for improved test coverage, and Cal your pending TODO comment looks worth pursing as well, but we don't need to block on that.

@Cal-L
Cal-L dismissed stale reviews from Gudahtt and tommasini via c38d0ec March 28, 2023 23:34
@Cal-L
Cal-L force-pushed the patch/5773-improve-watch-asset branch from c38d0ec to cb2d3d9 Compare March 28, 2023 23:44
@Cal-L
Cal-L marked this pull request as draft March 29, 2023 17:23
@Cal-L

Cal-L commented Mar 29, 2023

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

@Cal-L
Cal-L marked this pull request as ready for review March 29, 2023 20:40
@Cal-L
Cal-L force-pushed the patch/5773-improve-watch-asset branch from cb2d3d9 to eb5cab8 Compare March 30, 2023 04:57

@Gudahtt Gudahtt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@Cal-L
Cal-L merged commit 9952d5f into main Mar 30, 2023
@Cal-L
Cal-L deleted the patch/5773-improve-watch-asset branch March 30, 2023 19:44
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 25, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 25, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 25, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 25, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 25, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 26, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 26, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 26, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 26, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 27, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 27, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 27, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Jul 27, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 3, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 16, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 16, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 17, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 18, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 18, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 22, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
Gudahtt added a commit to MetaMask/metamask-mobile that referenced this pull request Aug 22, 2023
The `@metamask/assets-controllers` patch added as part of the
permission system implementation [1] has been updated to more closely
match how the feature was implemented upstream [2]. It should be
functionally equivalent.

This relates to MetaMask/mobile-planning#877

[1]: #5062
[2]: MetaMask/core#1124
saustrie-consensys added a commit that referenced this pull request Sep 4, 2026
… contract

Replace the assumed transactions contract with the one shipping in onramp-api
PR #1124 (the neobank-proxy forwards raw MoonPay Enterprise verbatim):

- Route: GET /neobank/autoramp-transactions?autoramp_id={id} (flat, not the
  assumed nested /autoramps/{id}/transactions), returning a MoonPay PagedList;
  read the `data` array (single page for now, next_cursor pagination is a
  follow-up).
- Payout hash: flat `transaction_hash` (drop the invented
  payout_transaction_hash and nested payout.transaction_hash).
- Status: the real 8 AutorampTransactionStatus values (FundsReviewInProgress,
  ConversionInProgress, PayoutInProgress, Completed, Failed, RejectedAml,
  RejectedFraud, RejectedMinAmount). The three Rejected* are terminal and
  notable; an unknown status falls back to a non-terminal value. This fixes the
  prior invented enum, which treated rejections as non-terminal and would have
  polled them forever without ever notifying.
- Display fields (amount/currency/moneyAccountAddress) are intentionally left
  unmapped: MoonPay carries them as structured objects, and the mobile-safe DTO
  (TRAM-3925) will pin the wire names.
saustrie-consensys added a commit that referenced this pull request Sep 4, 2026
… hash)

The prior alignment matched onramp-api #1124's internal mock fixture
({ data, next_cursor } + flat transaction_hash), not the real MoonPay/Iron
AutorampTransaction the proxy forwards verbatim. Per Iron's OpenAPI spec the
list is a PagedList with an `items` array and the payout hash is nested at
`payout_crypto_transaction.transaction_hash`. Reading only `data` / a flat hash
would have thrown on every real response (no deposit ever tracked) and never
captured the payout hash.

Make the mapping tolerant of both, since the proxy PR is unmerged and TRAM-3925
will re-shape it again:
- Envelope: read `items` (real Iron), then `data` (proxy fixture), then a bare
  array.
- Payout hash: read nested `payout_crypto_transaction.transaction_hash`, then
  flat `transaction_hash`.
- Tests use the real `{ items, cursor, prev_cursor }` + nested hash as the
  primary case, with the `data` / flat / bare-array fallbacks covered too.
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