From 762f9f418fd1e7a2fb5996a6d34781dcb35fc9e6 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 24 Oct 2023 10:57:00 +0200 Subject: [PATCH] fix: upgrade fr32-sha2-256-trunc-254-padded-binary-tree-multihash --- packages/upload-client/package.json | 4 ++-- packages/upload-client/src/index.js | 4 +++- packages/upload-client/test/index.test.js | 2 +- pnpm-lock.yaml | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/upload-client/package.json b/packages/upload-client/package.json index 4a4d92a4d..452971e96 100644 --- a/packages/upload-client/package.json +++ b/packages/upload-client/package.json @@ -18,7 +18,7 @@ "build": "tsc --build", "check": "tsc --build", "test": "npm-run-all -p -r mock test:all", - "test:all": "run-s test:browser test:node", + "test:all": "run-s test:node test:browser", "test:node": "hundreds -r html -r text mocha 'test/**/!(*.browser).test.js' -n experimental-vm-modules -n no-warnings", "test:browser": "playwright-test 'test/**/!(*.node).test.js'", "mock": "run-p mock:*", @@ -72,7 +72,7 @@ "@ucanto/interface": "^9.0.0", "@ucanto/transport": "^9.0.0", "@web3-storage/capabilities": "workspace:^", - "fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^1.1.4", + "fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^2.0.0", "ipfs-utils": "^9.0.14", "multiformats": "^12.1.2", "p-retry": "^5.1.2", diff --git a/packages/upload-client/src/index.js b/packages/upload-client/src/index.js index e1e90033a..d6fac0651 100644 --- a/packages/upload-client/src/index.js +++ b/packages/upload-client/src/index.js @@ -13,7 +13,7 @@ export { Store, Upload, UnixFS, CAR } export * from './sharding.js' const CONCURRENT_REQUESTS = 3 -const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + PieceHasher.size +const PIECE_MULTIHASH_SIZE = PieceHasher.prefix.length + 1 + PieceHasher.size /** * Uploads a file to the service and returns the root data CID for the @@ -133,6 +133,8 @@ async function uploadBlockStream(conf, blocks, options = {}) { const digestBytes = new Uint8Array(PIECE_MULTIHASH_SIZE) hasher.write(bytes) hasher.digestInto(digestBytes, 0, true) + // TODO: should we? + // hasher.free() const digest = Digest.decode(digestBytes) return /** @type {import('@web3-storage/capabilities/types').PieceLink} */ ( Link.create(raw.code, digest) diff --git a/packages/upload-client/test/index.test.js b/packages/upload-client/test/index.test.js index 2804ac020..be3af15af 100644 --- a/packages/upload-client/test/index.test.js +++ b/packages/upload-client/test/index.test.js @@ -577,7 +577,7 @@ describe('uploadCAR', () => { assert.equal(pieceCIDs.length, 1) assert.equal( pieceCIDs[0].toString(), - 'bafkzcibbammseumg3mjlev5odi5bpcsrp4gg62d7xnx44zkxzvgedq7nxldbc' + 'bafkzcibcoibrsisrq3nrfmsxvynduf4kkf7qy33ip65w7ttfk7guyqod5w5mmei' ) }) }) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a624e71dc..f524c7c54 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -423,8 +423,8 @@ importers: specifier: workspace:^ version: link:../capabilities fr32-sha2-256-trunc254-padded-binary-tree-multihash: - specifier: ^1.1.4 - version: 1.1.4 + specifier: ^2.0.0 + version: 2.0.0 ipfs-utils: specifier: ^9.0.14 version: 9.0.14 @@ -6442,8 +6442,8 @@ packages: engines: {node: '>= 0.6'} dev: true - /fr32-sha2-256-trunc254-padded-binary-tree-multihash@1.1.4: - resolution: {integrity: sha512-+IpghzGszM7ebMuYzoILYvQMHXgtyZbIwlx2VYY4yLsT4SVU02ur6g7LCoLAxaD9GIv2oTAdiuHUxBH1liEQ7g==} + /fr32-sha2-256-trunc254-padded-binary-tree-multihash@2.0.0: + resolution: {integrity: sha512-Gmxst5vaJd8dO/Ip+/F+9IbdNY1Ujp9gL0eWN3fiHS4/ORTvC5WUnM4QlJw+wci0yKIIzXfPBUP/SppxcXolAQ==} dev: false /fraction.js@4.3.7: