Skip to content

Commit 9e06ca4

Browse files
authored
Merge branch 'main' into 240311-fix-prototype-polluting-assignments
2 parents bad6ed4 + 0c78d6d commit 9e06ca4

File tree

70 files changed

+1095
-346
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1095
-346
lines changed

docs/contributing.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,11 @@ If you're developing your project locally and want to test changes to a package,
7272
7373
> **Example:**
7474
>
75-
> - If you're a member of MetaMask, your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and your clone of the `core` repo is at the same level as your project, add the following to `resolutions`:
75+
> - If your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and your clone of the `core` repo is at the same level as your project, add the following to `resolutions`:
7676
>
7777
> ```
7878
> "@metamask/controller-utils@^1.1.4": "file:../core/packages/controller-utils"
7979
> ```
80-
>
81-
> - If you are an individual contributor, your project uses NPM, `@metamask/assets-controllers` is listed in dependencies at `^3.4.7`, and your fork of the `core` repo is at the same level as your project, add the following to `overrides`:
82-
>
83-
> ```
84-
> "@metamask/assets-controllers@^3.4.7": "file:../core/packages/assets-controllers"
85-
> ```
8680
8781
4. Run `yarn install`.
8882
@@ -145,17 +139,11 @@ To use a preview build for a package within a project, you need to override the
145139
146140
> **Example:**
147141
>
148-
> - If you're a member of MetaMask, your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and you want to use the preview version `1.2.3-preview-e2df9b4`, add the following to `resolutions`:
142+
> - If your project uses Yarn, `@metamask/controller-utils` is listed in dependencies at `^1.1.4`, and you want to use the preview version `1.2.3-preview-e2df9b4`, add the following to `resolutions`:
149143
>
150144
> ```
151145
> "@metamask/controller-utils@^1.1.4": "npm:@metamask-previews/[email protected]"
152146
> ```
153-
>
154-
> - If you are an individual contributor, your project uses NPM, `@metamask/assets-controllers` is listed in dependencies at `^3.4.7`, and you want to use the preview version `4.5.6-preview-bc2a997` published under `@foo`, add the following to `overrides`:
155-
>
156-
> ```
157-
> "@metamask/assets-controllers@^3.4.7": "npm:@foo/[email protected]"
158-
> ```
159147
160148
4. Run `yarn install`.
161149

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/core-monorepo",
3-
"version": "125.0.0",
3+
"version": "130.0.0",
44
"private": true,
55
"description": "Monorepo for packages shared between MetaMask clients",
66
"repository": {
@@ -85,7 +85,7 @@
8585
"simple-git-hooks": "^2.8.0",
8686
"ts-node": "^10.9.1",
8787
"tsup": "^8.0.2",
88-
"typescript": "~4.8.4",
88+
"typescript": "~4.9.5",
8989
"yargs": "^17.7.2"
9090
},
9191
"packageManager": "[email protected]",

packages/accounts-controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"ts-jest": "^27.1.4",
6464
"typedoc": "^0.24.8",
6565
"typedoc-plugin-missing-exports": "^2.0.0",
66-
"typescript": "~4.8.4"
66+
"typescript": "~4.9.5"
6767
},
6868
"peerDependencies": {
6969
"@metamask/keyring-controller": "^14.0.0",

packages/address-book-controller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
},
4343
"dependencies": {
4444
"@metamask/base-controller": "^5.0.1",
45-
"@metamask/controller-utils": "^9.0.1",
45+
"@metamask/controller-utils": "^9.0.2",
4646
"@metamask/utils": "^8.3.0"
4747
},
4848
"devDependencies": {
@@ -53,7 +53,7 @@
5353
"ts-jest": "^27.1.4",
5454
"typedoc": "^0.24.8",
5555
"typedoc-plugin-missing-exports": "^2.0.0",
56-
"typescript": "~4.8.4"
56+
"typescript": "~4.9.5"
5757
},
5858
"engines": {
5959
"node": ">=16.0.0"

packages/announcement-controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"ts-jest": "^27.1.4",
5252
"typedoc": "^0.24.8",
5353
"typedoc-plugin-missing-exports": "^2.0.0",
54-
"typescript": "~4.8.4"
54+
"typescript": "~4.9.5"
5555
},
5656
"engines": {
5757
"node": ">=16.0.0"

packages/approval-controller/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"ts-jest": "^27.1.4",
5656
"typedoc": "^0.24.8",
5757
"typedoc-plugin-missing-exports": "^2.0.0",
58-
"typescript": "~4.8.4"
58+
"typescript": "~4.9.5"
5959
},
6060
"engines": {
6161
"node": ">=16.0.0"

packages/assets-controllers/CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [27.2.0]
11+
12+
### Added
13+
14+
- `CodefiTokenPricesServiceV2` exports `SUPPORTED_CHAIN_IDS`, an array of chain IDs supported by Codefi Price API V2. ([#4079](https://github.com/MetaMask/core/pull/4079))
15+
16+
- Added `tokenURI` key to `compareNftMetadata` function to compare nft metadata entries with. ([#3856](https://github.com/MetaMask/core/pull/3856))
17+
18+
## [27.1.0]
19+
20+
### Added
21+
22+
- Add `updateNftMetadata` method to `NftController` to update metadata for the requested NFTs ([#4008](https://github.com/MetaMask/core/pull/4008))
23+
1024
## [27.0.1]
1125

1226
### Fixed
@@ -723,7 +737,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
723737
724738
- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))
725739
726-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
740+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
741+
[27.2.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
742+
[27.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
727743
[27.0.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
728744
[27.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
729745
[26.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]

packages/assets-controllers/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/assets-controllers",
3-
"version": "27.0.1",
3+
"version": "27.2.0",
44
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
55
"keywords": [
66
"MetaMask",
@@ -51,7 +51,7 @@
5151
"@metamask/approval-controller": "^6.0.1",
5252
"@metamask/base-controller": "^5.0.1",
5353
"@metamask/contract-metadata": "^2.4.0",
54-
"@metamask/controller-utils": "^9.0.1",
54+
"@metamask/controller-utils": "^9.0.2",
5555
"@metamask/eth-query": "^4.0.0",
5656
"@metamask/keyring-controller": "^14.0.1",
5757
"@metamask/metamask-eth-abis": "3.0.0",
@@ -85,7 +85,7 @@
8585
"ts-jest": "^27.1.4",
8686
"typedoc": "^0.24.8",
8787
"typedoc-plugin-missing-exports": "^2.0.0",
88-
"typescript": "~4.8.4"
88+
"typescript": "~4.9.5"
8989
},
9090
"peerDependencies": {
9191
"@metamask/accounts-controller": "^12.0.0",

packages/assets-controllers/src/NftController.test.ts

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { v4 } from 'uuid';
3333

3434
import { getFormattedIpfsUrl } from './assetsUtil';
3535
import { Source } from './constants';
36+
import type { Nft } from './NftController';
3637
import { NftController } from './NftController';
3738

3839
const CRYPTOPUNK_ADDRESS = '0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB';
@@ -3437,4 +3438,232 @@ describe('NftController', () => {
34373438
).toBeUndefined();
34383439
});
34393440
});
3441+
3442+
describe('updateNftMetadata', () => {
3443+
it('should update Nft metadata successfully', async () => {
3444+
const { nftController } = setupController();
3445+
const { selectedAddress } = nftController.config;
3446+
const spy = jest.spyOn(nftController, 'updateNft');
3447+
const testNetworkClientId = 'sepolia';
3448+
await nftController.addNft('0xtest', '3', {
3449+
nftMetadata: { name: '', description: '', image: '', standard: '' },
3450+
networkClientId: testNetworkClientId,
3451+
});
3452+
sinon
3453+
.stub(nftController, 'getNftInformation' as keyof typeof nftController)
3454+
.returns({
3455+
name: 'name pudgy',
3456+
image: 'url pudgy',
3457+
description: 'description pudgy',
3458+
});
3459+
const testInputNfts: Nft[] = [
3460+
{
3461+
address: '0xtest',
3462+
description: null,
3463+
favorite: false,
3464+
image: null,
3465+
isCurrentlyOwned: true,
3466+
name: null,
3467+
standard: 'ERC721',
3468+
tokenId: '3',
3469+
tokenURI: 'https://api.pudgypenguins.io/lil/4',
3470+
},
3471+
];
3472+
3473+
await nftController.updateNftMetadata({
3474+
nfts: testInputNfts,
3475+
networkClientId: testNetworkClientId,
3476+
});
3477+
expect(spy).toHaveBeenCalledTimes(1);
3478+
3479+
expect(
3480+
nftController.state.allNfts[selectedAddress][SEPOLIA.chainId][0],
3481+
).toStrictEqual({
3482+
address: '0xtest',
3483+
description: 'description pudgy',
3484+
image: 'url pudgy',
3485+
name: 'name pudgy',
3486+
tokenId: '3',
3487+
standard: 'ERC721',
3488+
favorite: false,
3489+
isCurrentlyOwned: true,
3490+
tokenURI: 'https://api.pudgypenguins.io/lil/4',
3491+
});
3492+
});
3493+
3494+
it('should not update metadata when calls to fetch metadata fail', async () => {
3495+
const { nftController } = setupController();
3496+
const { selectedAddress } = nftController.config;
3497+
const spy = jest.spyOn(nftController, 'updateNft');
3498+
const testNetworkClientId = 'sepolia';
3499+
await nftController.addNft('0xtest', '3', {
3500+
nftMetadata: {
3501+
name: '',
3502+
description: '',
3503+
image: '',
3504+
standard: 'ERC721',
3505+
},
3506+
networkClientId: testNetworkClientId,
3507+
});
3508+
sinon
3509+
.stub(nftController, 'getNftInformation' as keyof typeof nftController)
3510+
.rejects(new Error('Error'));
3511+
const testInputNfts: Nft[] = [
3512+
{
3513+
address: '0xtest',
3514+
description: null,
3515+
favorite: false,
3516+
image: null,
3517+
isCurrentlyOwned: true,
3518+
name: null,
3519+
standard: 'ERC721',
3520+
tokenId: '3',
3521+
},
3522+
];
3523+
3524+
await nftController.updateNftMetadata({
3525+
nfts: testInputNfts,
3526+
networkClientId: testNetworkClientId,
3527+
});
3528+
3529+
expect(spy).toHaveBeenCalledTimes(0);
3530+
expect(
3531+
nftController.state.allNfts[selectedAddress][SEPOLIA.chainId][0],
3532+
).toStrictEqual({
3533+
address: '0xtest',
3534+
description: '',
3535+
favorite: false,
3536+
image: '',
3537+
isCurrentlyOwned: true,
3538+
name: '',
3539+
standard: 'ERC721',
3540+
tokenId: '3',
3541+
});
3542+
});
3543+
3544+
it('should update metadata when some calls to fetch metadata succeed', async () => {
3545+
const { nftController } = setupController();
3546+
const { selectedAddress } = nftController.config;
3547+
const spy = jest.spyOn(nftController, 'updateNft');
3548+
const testNetworkClientId = 'sepolia';
3549+
// Add nfts
3550+
await nftController.addNft('0xtest1', '1', {
3551+
nftMetadata: {
3552+
name: '',
3553+
description: '',
3554+
image: '',
3555+
standard: 'ERC721',
3556+
},
3557+
networkClientId: testNetworkClientId,
3558+
});
3559+
await nftController.addNft('0xtest2', '2', {
3560+
nftMetadata: {
3561+
name: '',
3562+
description: '',
3563+
image: '',
3564+
standard: 'ERC721',
3565+
},
3566+
networkClientId: testNetworkClientId,
3567+
});
3568+
await nftController.addNft('0xtest3', '3', {
3569+
nftMetadata: {
3570+
name: '',
3571+
description: '',
3572+
image: '',
3573+
standard: 'ERC721',
3574+
},
3575+
networkClientId: testNetworkClientId,
3576+
});
3577+
sinon
3578+
.stub(nftController, 'getNftInformation' as keyof typeof nftController)
3579+
.onFirstCall()
3580+
.returns({
3581+
name: 'name pudgy 1',
3582+
image: 'url pudgy 1',
3583+
description: 'description pudgy 2',
3584+
})
3585+
.onSecondCall()
3586+
.returns({
3587+
name: 'name pudgy 2',
3588+
image: 'url pudgy 2',
3589+
description: 'description pudgy 2',
3590+
})
3591+
.onThirdCall()
3592+
.rejects(new Error('Error'));
3593+
3594+
const testInputNfts: Nft[] = [
3595+
{
3596+
address: '0xtest1',
3597+
description: null,
3598+
favorite: false,
3599+
image: null,
3600+
isCurrentlyOwned: true,
3601+
name: null,
3602+
standard: 'ERC721',
3603+
tokenId: '1',
3604+
},
3605+
{
3606+
address: '0xtest2',
3607+
description: null,
3608+
favorite: false,
3609+
image: null,
3610+
isCurrentlyOwned: true,
3611+
name: null,
3612+
standard: 'ERC721',
3613+
tokenId: '2',
3614+
},
3615+
{
3616+
address: '0xtest3',
3617+
description: null,
3618+
favorite: false,
3619+
image: null,
3620+
isCurrentlyOwned: true,
3621+
name: null,
3622+
standard: 'ERC721',
3623+
tokenId: '3',
3624+
},
3625+
];
3626+
3627+
await nftController.updateNftMetadata({
3628+
nfts: testInputNfts,
3629+
networkClientId: testNetworkClientId,
3630+
});
3631+
3632+
expect(spy).toHaveBeenCalledTimes(2);
3633+
expect(
3634+
nftController.state.allNfts[selectedAddress][SEPOLIA.chainId],
3635+
).toStrictEqual([
3636+
{
3637+
address: '0xtest1',
3638+
description: 'description pudgy 2',
3639+
favorite: false,
3640+
image: 'url pudgy 1',
3641+
isCurrentlyOwned: true,
3642+
name: 'name pudgy 1',
3643+
standard: 'ERC721',
3644+
tokenId: '1',
3645+
},
3646+
{
3647+
address: '0xtest2',
3648+
description: 'description pudgy 2',
3649+
favorite: false,
3650+
image: 'url pudgy 2',
3651+
isCurrentlyOwned: true,
3652+
name: 'name pudgy 2',
3653+
standard: 'ERC721',
3654+
tokenId: '2',
3655+
},
3656+
{
3657+
address: '0xtest3',
3658+
tokenId: '3',
3659+
favorite: false,
3660+
isCurrentlyOwned: true,
3661+
name: '',
3662+
description: '',
3663+
image: '',
3664+
standard: 'ERC721',
3665+
},
3666+
]);
3667+
});
3668+
});
34403669
});

0 commit comments

Comments
 (0)