Skip to content

Commit

Permalink
chore: bump assets-controllers to v37 (#26984)
Browse files Browse the repository at this point in the history
## **Description**

Bump assets-controllers to v37

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26984?quickstart=1)

## **Related issues**

Fixes:
Related:
https://github.com/MetaMask/core/blob/main/packages/assets-controllers/CHANGELOG.md#3700

## **Manual testing steps**

1. Go to NFTs tab, make sure you are able to see your NFTs and NFT
details.
2. Use Test-dapp to watch-NFTs and make sure you are able to add your
NFTs.
3. Make sure token detection is working

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent 5e08c06 commit 97dce9f
Show file tree
Hide file tree
Showing 25 changed files with 882 additions and 227 deletions.
66 changes: 24 additions & 42 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,28 +591,24 @@ export default class MetamaskController extends EventEmitter {
state: initState.TokenListController,
});

this.assetsContractController = new AssetsContractController(
{
chainId: getCurrentChainId({ metamask: this.networkController.state }),
onPreferencesStateChange: (listener) =>
this.preferencesController.store.subscribe(listener),
onNetworkDidChange: (cb) =>
networkControllerMessenger.subscribe(
'NetworkController:networkDidChange',
() => {
const networkState = this.networkController.state;
return cb(networkState);
},
),
getNetworkClientById: this.networkController.getNetworkClientById.bind(
this.networkController,
),
},
{
provider: this.provider,
},
initState.AssetsContractController,
);
const assetsContractControllerMessenger =
this.controllerMessenger.getRestricted({
name: 'AssetsContractController',
allowedActions: [
'NetworkController:getNetworkClientById',
'NetworkController:getNetworkConfigurationByNetworkClientId',
'NetworkController:getSelectedNetworkClient',
'NetworkController:getState',
],
allowedEvents: [
'PreferencesController:stateChange',
'NetworkController:networkDidChange',
],
});
this.assetsContractController = new AssetsContractController({
messenger: assetsContractControllerMessenger,
chainId: getCurrentChainId({ metamask: this.networkController.state }),
});

const tokensControllerMessenger = this.controllerMessenger.getRestricted({
name: 'TokensController',
Expand Down Expand Up @@ -648,32 +644,18 @@ export default class MetamaskController extends EventEmitter {
`${this.networkController.name}:getNetworkClientById`,
'AccountsController:getSelectedAccount',
'AccountsController:getAccount',
'AssetsContractController:getERC721AssetName',
'AssetsContractController:getERC721AssetSymbol',
'AssetsContractController:getERC721TokenURI',
'AssetsContractController:getERC721OwnerOf',
'AssetsContractController:getERC1155BalanceOf',
'AssetsContractController:getERC1155TokenURI',
],
});
this.nftController = new NftController({
state: initState.NftController,
messenger: nftControllerMessenger,
chainId: getCurrentChainId({ metamask: this.networkController.state }),
getERC721AssetName: this.assetsContractController.getERC721AssetName.bind(
this.assetsContractController,
),
getERC721AssetSymbol:
this.assetsContractController.getERC721AssetSymbol.bind(
this.assetsContractController,
),
getERC721TokenURI: this.assetsContractController.getERC721TokenURI.bind(
this.assetsContractController,
),
getERC721OwnerOf: this.assetsContractController.getERC721OwnerOf.bind(
this.assetsContractController,
),
getERC1155BalanceOf:
this.assetsContractController.getERC1155BalanceOf.bind(
this.assetsContractController,
),
getERC1155TokenURI: this.assetsContractController.getERC1155TokenURI.bind(
this.assetsContractController,
),
onNftAdded: ({ address, symbol, tokenId, standard, source }) =>
this.metaMetricsController.trackEvent({
event: MetaMetricsEventName.NftAdded,
Expand Down
20 changes: 10 additions & 10 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@
"TextEncoder": true
},
"packages": {
"@metamask/assets-controllers>multiformats": true
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true
}
},
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@ensdomains/content-hash>multihashes": {
Expand Down Expand Up @@ -693,13 +701,13 @@
"setTimeout": true
},
"packages": {
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true,
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/base-controller": true,
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
Expand Down Expand Up @@ -735,14 +743,6 @@
"uuid": true
}
},
"@metamask/assets-controllers>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down
20 changes: 10 additions & 10 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@
"TextEncoder": true
},
"packages": {
"@metamask/assets-controllers>multiformats": true
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true
}
},
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@ensdomains/content-hash>multihashes": {
Expand Down Expand Up @@ -693,13 +701,13 @@
"setTimeout": true
},
"packages": {
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true,
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/base-controller": true,
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
Expand Down Expand Up @@ -735,14 +743,6 @@
"uuid": true
}
},
"@metamask/assets-controllers>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down
20 changes: 10 additions & 10 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@
"TextEncoder": true
},
"packages": {
"@metamask/assets-controllers>multiformats": true
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true
}
},
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@ensdomains/content-hash>multihashes": {
Expand Down Expand Up @@ -693,13 +701,13 @@
"setTimeout": true
},
"packages": {
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true,
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/base-controller": true,
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
Expand Down Expand Up @@ -735,14 +743,6 @@
"uuid": true
}
},
"@metamask/assets-controllers>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down
20 changes: 10 additions & 10 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@
"TextEncoder": true
},
"packages": {
"@metamask/assets-controllers>multiformats": true
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true
}
},
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@ensdomains/content-hash>multihashes": {
Expand Down Expand Up @@ -785,13 +793,13 @@
"setTimeout": true
},
"packages": {
"@ensdomains/content-hash>multicodec>uint8arrays>multiformats": true,
"@ethereumjs/tx>@ethereumjs/util": true,
"@ethersproject/contracts": true,
"@ethersproject/providers": true,
"@metamask/abi-utils": true,
"@metamask/assets-controllers>@metamask/base-controller": true,
"@metamask/assets-controllers>@metamask/polling-controller": true,
"@metamask/assets-controllers>multiformats": true,
"@metamask/contract-metadata": true,
"@metamask/controller-utils": true,
"@metamask/eth-query": true,
Expand Down Expand Up @@ -827,14 +835,6 @@
"uuid": true
}
},
"@metamask/assets-controllers>multiformats": {
"globals": {
"TextDecoder": true,
"TextEncoder": true,
"console.warn": true,
"crypto.subtle.digest": true
}
},
"@metamask/base-controller": {
"globals": {
"setTimeout": true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
"@metamask/address-book-controller": "^5.0.0",
"@metamask/announcement-controller": "^7.0.0",
"@metamask/approval-controller": "^7.0.0",
"@metamask/assets-controllers": "^36.0.0",
"@metamask/assets-controllers": "^37.0.0",
"@metamask/base-controller": "^7.0.0",
"@metamask/bitcoin-wallet-snap": "^0.6.0",
"@metamask/browser-passworder": "^4.3.0",
Expand Down
Loading

0 comments on commit 97dce9f

Please sign in to comment.