Skip to content

Commit 2c28efd

Browse files
Gozalaachingbrain
andauthored
fix: regressions introduced by new releases of CID & multicodec (#3442)
Few regressions had been introduced by multiformats/js-cid@0e11f03#diff-25a6634263c1b1f6fc4697a04e2b9904ea4b042a89af59dc93ec1f5d44848a26 multiformats/js-multicodec@25cf33f This changes fix two remaining problems: 1. Change type of codec from string to code name. 2. No longer import removed JSON file and use exported table instead. Co-authored-by: achingbrain <[email protected]>
1 parent 52f578e commit 2c28efd

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"dependencies": {
5353
"any-signal": "^2.0.0",
5454
"bignumber.js": "^9.0.0",
55-
"cids": "1.0.2",
55+
"cids": "^1.0.0",
5656
"debug": "^4.1.1",
5757
"form-data": "^3.0.0",
5858
"ipfs-core-utils": "^0.5.3",
@@ -68,7 +68,7 @@
6868
"merge-options": "^2.0.0",
6969
"multiaddr": "^8.0.0",
7070
"multibase": "^3.0.0",
71-
"multicodec": "2.0.4",
71+
"multicodec": "^2.0.1",
7272
"multihashes": "^3.0.1",
7373
"nanoid": "^3.1.12",
7474
"native-abort-controller": "~0.0.3",

src/dag/put.js

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module.exports = configure((api, opts) => {
2828
const cid = new CID(options.cid)
2929
encodingOptions = {
3030
...options,
31+
// @ts-expect-error - https://github.com/multiformats/js-cid/pull/138
3132
format: multicodec.getName(cid.code),
3233
hashAlg: multihash.decode(cid.multihash).name
3334
}

src/lib/ipld-formats.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ module.exports = ({ formats = [], loadFormat = noop } = {}) => {
3636
/**
3737
* Attempts to load an IPLD format for the passed CID
3838
*
39-
* @param {string} codec - The code to load the format for
39+
* @param {import('multicodec').CodecName} codec - The code to load the format for
4040
* @returns {Promise<object>} - An IPLD format
4141
*/
4242
const loadResolver = async (codec) => {
43+
// @ts-ignore - codec is a string and not a CodecName
4344
const number = multicodec.getNumber(codec)
4445
const format = configuredFormats[number] || await loadFormat(codec)
4546

0 commit comments

Comments
 (0)