@lerna-labs/hydra-sdk 1.0.0-beta.26 → 1.0.0-beta.27

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.
Files changed (2) hide show
  1. package/dist/ipfs/ipfs.js +21 -8
  2. package/package.json +1 -1
package/dist/ipfs/ipfs.js CHANGED
@@ -35,15 +35,28 @@ export function createIpfsClient(config) {
35
35
  * @returns The CID of the wrapping IPFS directory.
36
36
  */
37
37
  async function pinDirectory(dirPath) {
38
- const entries = await fs.readdir(dirPath);
39
38
  const form = new FormData();
40
- for (const entry of entries) {
41
- const filePath = path.join(dirPath, entry);
42
- const stat = await fs.stat(filePath);
43
- if (!stat.isFile())
44
- continue;
45
- const content = await fs.readFile(filePath, 'utf-8');
46
- form.append('file', new Blob([content]), entry);
39
+ const collectFiles = async (rel) => {
40
+ const out = [];
41
+ const dirents = await fs.readdir(path.join(dirPath, rel), { withFileTypes: true });
42
+ for (const dirent of dirents) {
43
+ const childRel = path.join(rel, dirent.name);
44
+ if (dirent.isDirectory()) {
45
+ out.push(...(await collectFiles(childRel)));
46
+ }
47
+ else if (dirent.isFile()) {
48
+ out.push(childRel);
49
+ }
50
+ }
51
+ return out;
52
+ };
53
+ for (const relPath of await collectFiles('')) {
54
+ const buf = await fs.readFile(path.join(dirPath, relPath));
55
+ const content = new Uint8Array(buf).slice().buffer;
56
+ // Kubo reconstructs the directory tree from entry names — always
57
+ // use POSIX separators so Windows callers get the same CID.
58
+ const entryName = relPath.split(path.sep).join('/');
59
+ form.append('file', new Blob([content]), entryName);
47
60
  }
48
61
  const res = await fetch(`${apiUrl}/api/v0/add?pin=true&wrap-with-directory=true&recursive=true`, {
49
62
  method: 'POST',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lerna-labs/hydra-sdk",
3
- "version": "1.0.0-beta.26",
3
+ "version": "1.0.0-beta.27",
4
4
  "description": "TypeScript SDK for managing Cardano Hydra Heads — lifecycle, UTxO queries, wallet management, transaction submission, and signature verification",
5
5
  "keywords": [
6
6
  "cardano",