Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bump `@metamask/base-controller` from `^8.4.1` to `^8.4.2` ([#6917](https://github.com/MetaMask/core/pull/6917))

### Fixed

- Downgrade `multiformats` to `^9.9.0` to avoid ESM-only dependency ([#6920](https://github.com/MetaMask/core/pull/6920))

## [82.0.0]

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"bn.js": "^5.2.1",
"immer": "^9.0.6",
"lodash": "^4.17.21",
"multiformats": "^13.1.0",
"multiformats": "^9.9.0",
"reselect": "^5.1.1",
"single-call-balance-checker-abi": "^1.0.0",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/src/assetsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
toCaipChainId,
} from '@metamask/utils';
import BN from 'bn.js';
import { CID } from 'multiformats/cid';

import type { Nft, NftMetadata } from './NftController';
import type { AbstractTokenPricesService } from './token-prices-service';
Expand Down Expand Up @@ -268,7 +269,6 @@ export async function getIpfsCIDv1AndPath(ipfsUrl: string): Promise<{
const cid = index !== -1 ? url.substring(0, index) : url;
const path = index !== -1 ? url.substring(index) : undefined;

const { CID } = await import('multiformats');
// We want to ensure that the CID is v1 (https://docs.ipfs.io/concepts/content-addressing/#identifier-formats)
// because most cid v0s appear to be incompatible with IPFS subdomains
return {
Expand Down
13 changes: 13 additions & 0 deletions packages/assets-controllers/src/types/vendor/multiformats.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Partial type definitions for `multiformats/cid`. This only covers the parts
* used in the codebase.
*/
declare module 'multiformats/cid' {
Copy link
Member Author

Choose a reason for hiding this comment

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

multiformats has type definitions but they're not included in the package.json's exports fields, so they are not picked up by TypeScript. We only use a very limited subset of the package's functionality anyway, so I added a minimal definition to cover it.

export class CID {
static parse(cidString: string): CID;

toV1(): CID;

toString(): string;
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ __metadata:
jest: "npm:^27.5.1"
jest-environment-jsdom: "npm:^27.5.1"
lodash: "npm:^4.17.21"
multiformats: "npm:^13.1.0"
multiformats: "npm:^9.9.0"
nock: "npm:^13.3.1"
reselect: "npm:^5.1.1"
single-call-balance-checker-abi: "npm:^1.0.0"
Expand Down Expand Up @@ -12502,10 +12502,10 @@ __metadata:
languageName: node
linkType: hard

"multiformats@npm:^13.1.0":
version: 13.2.2
resolution: "multiformats@npm:13.2.2"
checksum: 10/6e673320e9b06d5fdbbf2bde0d3132f13fac94fb40f36d646265b5c38eba4a28c40a2c76b4efa0c1a23517fe87320e540e9ef7f28d71c1cc3239c91bf6770ce6
"multiformats@npm:^9.9.0":
version: 9.9.0
resolution: "multiformats@npm:9.9.0"
checksum: 10/ad55c7d480d22f4258a68fd88aa2aab744fe0cb1e68d732fc886f67d858b37e3aa6c2cec12b2960ead7730d43be690931485238569952d8a3d7f90fdc726c652
languageName: node
linkType: hard

Expand Down
Loading