gethstorage-sdk 5.0.4 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -125,7 +125,7 @@ interface EstimateGasRequest {
125
125
  chunkHashes?: string[];
126
126
  /** Size of each data chunk, in KB. Defaults to DEFAULT_MAX_CHUNK_SIZE_KB. */
127
127
  maxChunkSize?: number;
128
- /** Maximum number of chunks requested in a single call. Defaults to MAX_CHUNKS. */
128
+ /** Maximum number of chunks requested in a single call. Defaults to and is capped at MAX_CHUNKS. */
129
129
  maxChunks?: number;
130
130
  }
131
131
  interface UploadRequest extends EstimateGasRequest {
@@ -307,7 +307,7 @@ declare class FlatDirectory {
307
307
  /**
308
308
  * Fetch chunk hashes for multiple files
309
309
  * @param keys - Array of file keys
310
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
310
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
311
311
  * @returns Object mapping file keys to their chunk hashes
312
312
  */
313
313
  fetchHashes(keys: string[], maxChunks?: number): Promise<Record<string, string[]>>;
@@ -666,7 +666,7 @@ var FlatDirectory = class _FlatDirectory {
666
666
  /**
667
667
  * Fetch chunk hashes for multiple files
668
668
  * @param keys - Array of file keys
669
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
669
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
670
670
  * @returns Object mapping file keys to their chunk hashes
671
671
  */
672
672
  async fetchHashes(keys, maxChunks) {
@@ -768,7 +768,7 @@ var FlatDirectory = class _FlatDirectory {
768
768
  }
769
769
  async #fetchChunkHashes(fileInfos, maxChunks) {
770
770
  const allHashes = {};
771
- const chunkLimit = maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS;
771
+ const chunkLimit = Math.min(maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS, MAX_CHUNKS);
772
772
  const batchArray = [];
773
773
  let currentBatch = {};
774
774
  let currentChunkCount = 0;
@@ -792,13 +792,14 @@ var FlatDirectory = class _FlatDirectory {
792
792
  }
793
793
  if (batchArray.length > 0) {
794
794
  const contract = new ethers3.Contract(this.#contractAddrChecked, FlatDirectoryAbi, this.#walletChecked);
795
- const hashResults = await Promise.all(batchArray.map((batch) => {
795
+ const hashResults = [];
796
+ for (const batch of batchArray) {
796
797
  const fileChunksArray = Object.keys(batch).map((name) => ({
797
798
  name,
798
799
  chunkIds: batch[name]
799
800
  }));
800
- return getChunkHashes(contract, fileChunksArray);
801
- }));
801
+ hashResults.push(await getChunkHashes(contract, fileChunksArray));
802
+ }
802
803
  hashResults.flat().forEach(({ name, chunkId, hash }) => {
803
804
  allHashes[name][chunkId] = hash;
804
805
  });
@@ -711,7 +711,7 @@ var FlatDirectory = class _FlatDirectory {
711
711
  /**
712
712
  * Fetch chunk hashes for multiple files
713
713
  * @param keys - Array of file keys
714
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
714
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
715
715
  * @returns Object mapping file keys to their chunk hashes
716
716
  */
717
717
  async fetchHashes(keys, maxChunks) {
@@ -813,7 +813,7 @@ var FlatDirectory = class _FlatDirectory {
813
813
  }
814
814
  async #fetchChunkHashes(fileInfos, maxChunks) {
815
815
  const allHashes = {};
816
- const chunkLimit = maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS;
816
+ const chunkLimit = Math.min(maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS, MAX_CHUNKS);
817
817
  const batchArray = [];
818
818
  let currentBatch = {};
819
819
  let currentChunkCount = 0;
@@ -837,13 +837,14 @@ var FlatDirectory = class _FlatDirectory {
837
837
  }
838
838
  if (batchArray.length > 0) {
839
839
  const contract = new import_ethers3.ethers.Contract(this.#contractAddrChecked, FlatDirectoryAbi, this.#walletChecked);
840
- const hashResults = await Promise.all(batchArray.map((batch) => {
840
+ const hashResults = [];
841
+ for (const batch of batchArray) {
841
842
  const fileChunksArray = Object.keys(batch).map((name) => ({
842
843
  name,
843
844
  chunkIds: batch[name]
844
845
  }));
845
- return getChunkHashes(contract, fileChunksArray);
846
- }));
846
+ hashResults.push(await getChunkHashes(contract, fileChunksArray));
847
+ }
847
848
  hashResults.flat().forEach(({ name, chunkId, hash }) => {
848
849
  allHashes[name][chunkId] = hash;
849
850
  });
@@ -125,7 +125,7 @@ interface EstimateGasRequest {
125
125
  chunkHashes?: string[];
126
126
  /** Size of each data chunk, in KB. Defaults to DEFAULT_MAX_CHUNK_SIZE_KB. */
127
127
  maxChunkSize?: number;
128
- /** Maximum number of chunks requested in a single call. Defaults to MAX_CHUNKS. */
128
+ /** Maximum number of chunks requested in a single call. Defaults to and is capped at MAX_CHUNKS. */
129
129
  maxChunks?: number;
130
130
  }
131
131
  interface UploadRequest extends EstimateGasRequest {
@@ -307,7 +307,7 @@ declare class FlatDirectory {
307
307
  /**
308
308
  * Fetch chunk hashes for multiple files
309
309
  * @param keys - Array of file keys
310
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
310
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
311
311
  * @returns Object mapping file keys to their chunk hashes
312
312
  */
313
313
  fetchHashes(keys: string[], maxChunks?: number): Promise<Record<string, string[]>>;
@@ -125,7 +125,7 @@ interface EstimateGasRequest {
125
125
  chunkHashes?: string[];
126
126
  /** Size of each data chunk, in KB. Defaults to DEFAULT_MAX_CHUNK_SIZE_KB. */
127
127
  maxChunkSize?: number;
128
- /** Maximum number of chunks requested in a single call. Defaults to MAX_CHUNKS. */
128
+ /** Maximum number of chunks requested in a single call. Defaults to and is capped at MAX_CHUNKS. */
129
129
  maxChunks?: number;
130
130
  }
131
131
  interface UploadRequest extends EstimateGasRequest {
@@ -307,7 +307,7 @@ declare class FlatDirectory {
307
307
  /**
308
308
  * Fetch chunk hashes for multiple files
309
309
  * @param keys - Array of file keys
310
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
310
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
311
311
  * @returns Object mapping file keys to their chunk hashes
312
312
  */
313
313
  fetchHashes(keys: string[], maxChunks?: number): Promise<Record<string, string[]>>;
@@ -666,7 +666,7 @@ var FlatDirectory = class _FlatDirectory {
666
666
  /**
667
667
  * Fetch chunk hashes for multiple files
668
668
  * @param keys - Array of file keys
669
- * @param maxChunks - Maximum number of chunks requested in a single call, defaults to MAX_CHUNKS
669
+ * @param maxChunks - Maximum number of chunks requested in a single call, defaults to and is capped at MAX_CHUNKS
670
670
  * @returns Object mapping file keys to their chunk hashes
671
671
  */
672
672
  async fetchHashes(keys, maxChunks) {
@@ -768,7 +768,7 @@ var FlatDirectory = class _FlatDirectory {
768
768
  }
769
769
  async #fetchChunkHashes(fileInfos, maxChunks) {
770
770
  const allHashes = {};
771
- const chunkLimit = maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS;
771
+ const chunkLimit = Math.min(maxChunks && maxChunks > 0 ? maxChunks : MAX_CHUNKS, MAX_CHUNKS);
772
772
  const batchArray = [];
773
773
  let currentBatch = {};
774
774
  let currentChunkCount = 0;
@@ -792,13 +792,14 @@ var FlatDirectory = class _FlatDirectory {
792
792
  }
793
793
  if (batchArray.length > 0) {
794
794
  const contract = new ethers3.Contract(this.#contractAddrChecked, FlatDirectoryAbi, this.#walletChecked);
795
- const hashResults = await Promise.all(batchArray.map((batch) => {
795
+ const hashResults = [];
796
+ for (const batch of batchArray) {
796
797
  const fileChunksArray = Object.keys(batch).map((name) => ({
797
798
  name,
798
799
  chunkIds: batch[name]
799
800
  }));
800
- return getChunkHashes(contract, fileChunksArray);
801
- }));
801
+ hashResults.push(await getChunkHashes(contract, fileChunksArray));
802
+ }
802
803
  hashResults.flat().forEach(({ name, chunkId, hash }) => {
803
804
  allHashes[name][chunkId] = hash;
804
805
  });
package/package.json CHANGED
@@ -1,65 +1,65 @@
1
- {
2
- "name": "gethstorage-sdk",
3
- "version": "5.0.4",
4
- "description": "EthStorage flat directory upload sdk (calldata only)",
5
- "files": [
6
- "dist"
7
- ],
8
- "main": "./dist/node/index.cjs",
9
- "types": "./dist/node/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "browser": "./dist/browser/index.mjs",
13
- "node": {
14
- "import": "./dist/node/index.mjs",
15
- "require": "./dist/node/index.cjs"
16
- },
17
- "types": "./dist/node/index.d.ts",
18
- "default": "./dist/node/index.mjs"
19
- },
20
- "./file": {
21
- "node": {
22
- "import": "./dist/node/file.mjs",
23
- "require": "./dist/node/file.cjs"
24
- },
25
- "types": "./dist/node/file.d.ts"
26
- }
27
- },
28
- "scripts": {
29
- "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
30
- "dev": "tsup --watch --env.NODE_ENV development",
31
- "prepublishOnly": "npm run build"
32
- },
33
- "dependencies": {
34
- "dotenv": "^16.4.5",
35
- "ethers": "^6.17.0",
36
- "p-limit": "^7.2.0"
37
- },
38
- "repository": {
39
- "type": "git",
40
- "url": "git+https://github.com/0xCampanula/gethstorage-sdk.git"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/0xCampanula/gethstorage-sdk/issues"
44
- },
45
- "homepage": "https://github.com/0xCampanula/gethstorage-sdk/main/",
46
- "keywords": [
47
- "File",
48
- "Upload"
49
- ],
50
- "author": "ethsorage",
51
- "license": "ISC",
52
- "devDependencies": {
53
- "tsup": "^8.5.1",
54
- "typescript": "^5.9.3"
55
- },
56
- "resolutions": {
57
- "strip-ansi": "7.1.0",
58
- "color-convert": "2.0.1",
59
- "color-name": "1.1.4"
60
- },
61
- "overrides": {
62
- "rollup": ">=4.59.0",
63
- "picomatch": ">=4.0.4"
64
- }
65
- }
1
+ {
2
+ "name": "gethstorage-sdk",
3
+ "version": "5.0.5",
4
+ "description": "EthStorage flat directory upload sdk (calldata only)",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "main": "./dist/node/index.cjs",
9
+ "types": "./dist/node/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "browser": "./dist/browser/index.mjs",
13
+ "node": {
14
+ "import": "./dist/node/index.mjs",
15
+ "require": "./dist/node/index.cjs"
16
+ },
17
+ "types": "./dist/node/index.d.ts",
18
+ "default": "./dist/node/index.mjs"
19
+ },
20
+ "./file": {
21
+ "node": {
22
+ "import": "./dist/node/file.mjs",
23
+ "require": "./dist/node/file.cjs"
24
+ },
25
+ "types": "./dist/node/file.d.ts"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup",
30
+ "dev": "tsup --watch --env.NODE_ENV development",
31
+ "prepublishOnly": "npm run build"
32
+ },
33
+ "dependencies": {
34
+ "dotenv": "^16.4.5",
35
+ "ethers": "^6.17.0",
36
+ "p-limit": "^7.2.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/0xCampanula/gethstorage-sdk.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/0xCampanula/gethstorage-sdk/issues"
44
+ },
45
+ "homepage": "https://github.com/0xCampanula/gethstorage-sdk/main/",
46
+ "keywords": [
47
+ "File",
48
+ "Upload"
49
+ ],
50
+ "author": "ethsorage",
51
+ "license": "ISC",
52
+ "devDependencies": {
53
+ "tsup": "^8.5.1",
54
+ "typescript": "^5.9.3"
55
+ },
56
+ "resolutions": {
57
+ "strip-ansi": "7.1.0",
58
+ "color-convert": "2.0.1",
59
+ "color-name": "1.1.4"
60
+ },
61
+ "overrides": {
62
+ "rollup": ">=4.59.0",
63
+ "picomatch": ">=4.0.4"
64
+ }
65
+ }