From bcf89389a6808bdf0bd32761417867d021951c40 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 29 Nov 2023 18:10:43 +0600 Subject: [PATCH 1/3] feat: add path to storage options --- packages/storage/src/abstract.ts | 1 + packages/storage/src/level.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/storage/src/abstract.ts b/packages/storage/src/abstract.ts index 9ce0b1da..2d5615a9 100644 --- a/packages/storage/src/abstract.ts +++ b/packages/storage/src/abstract.ts @@ -17,6 +17,7 @@ export abstract class Storage { export interface GenericStorageOptions { scope?: string; + path?: string; } /** diff --git a/packages/storage/src/level.ts b/packages/storage/src/level.ts index 97525548..c324dcbc 100644 --- a/packages/storage/src/level.ts +++ b/packages/storage/src/level.ts @@ -32,7 +32,9 @@ export class LevelDBStorage extends Storage { options = options ?? {}; - this.db = new ClassicLevel('./db', { + const dbPath = options.path || './db' + + this.db = new ClassicLevel(dbPath, { keyEncoding: 'utf8', valueEncoding: superJsonEncoding, createIfMissing: true, From 235d207d77c0ea90a084a36bfa362b50e6bc0159 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 29 Nov 2023 18:25:07 +0600 Subject: [PATCH 2/3] feat: add LevelStorageOptions --- packages/storage/src/abstract.ts | 1 - packages/storage/src/level.ts | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/storage/src/abstract.ts b/packages/storage/src/abstract.ts index 2d5615a9..9ce0b1da 100644 --- a/packages/storage/src/abstract.ts +++ b/packages/storage/src/abstract.ts @@ -17,7 +17,6 @@ export abstract class Storage { export interface GenericStorageOptions { scope?: string; - path?: string; } /** diff --git a/packages/storage/src/level.ts b/packages/storage/src/level.ts index c324dcbc..d83dcf17 100644 --- a/packages/storage/src/level.ts +++ b/packages/storage/src/level.ts @@ -22,17 +22,21 @@ const superJsonEncoding: IEncoding< name: 'super-json-encoding', }; +export interface LevelStorageOptions extends GenericStorageOptions { + path?: string; +} + export class LevelDBStorage extends Storage { protected db: ClassicLevel; /** Key for storing ids included in the scope */ scopeIdsKey?: string; - constructor(options?: GenericStorageOptions) { + constructor(options?: LevelStorageOptions) { super(); options = options ?? {}; - const dbPath = options.path || './db' + const dbPath = options.path || './db'; this.db = new ClassicLevel(dbPath, { keyEncoding: 'utf8', From 1a83a91e8467c6cddbb15c67d08cbe30fb6d9633 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 29 Nov 2023 18:26:25 +0600 Subject: [PATCH 3/3] feat: update superjson --- examples/client/package.json | 2 +- examples/manager/package.json | 2 +- packages/client/package.json | 2 +- packages/contracts-manger/package.json | 2 +- packages/node-api/package.json | 2 +- packages/node/package.json | 2 +- packages/pubsub/package.json | 2 +- packages/react/package.json | 2 +- packages/storage/package.json | 2 +- pnpm-lock.yaml | 47 +++++++++++--------------- 10 files changed, 29 insertions(+), 36 deletions(-) diff --git a/examples/client/package.json b/examples/client/package.json index 770dba54..17a567c9 100644 --- a/examples/client/package.json +++ b/examples/client/package.json @@ -26,7 +26,7 @@ "luxon": "^3.3.0" }, "dependencies": { - "superjson": "^1.13.1" + "superjson": "^2.2.1" }, "eslintConfig": { "extends": [ diff --git a/examples/manager/package.json b/examples/manager/package.json index 01e22270..d80e494c 100644 --- a/examples/manager/package.json +++ b/examples/manager/package.json @@ -27,7 +27,7 @@ "@windingtree/contracts": "^1.0.0", "@windingtree/sdk-types": "workspace:*", "@windingtree/sdk-utils": "workspace:*", - "superjson": "^1.13.1" + "superjson": "^2.2.1" }, "eslintConfig": { "extends": [ diff --git a/packages/client/package.json b/packages/client/package.json index 1c4cbffa..9d0d33cf 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -47,7 +47,7 @@ "@windingtree/sdk-types": "workspace:*", "@windingtree/sdk-utils": "workspace:*", "libp2p": "^0.46.14", - "superjson": "^2.0.0", + "superjson": "^2.2.1", "viem": "^1.3.0" }, "scripts": { diff --git a/packages/contracts-manger/package.json b/packages/contracts-manger/package.json index 6f8e1aa9..cf3068e6 100644 --- a/packages/contracts-manger/package.json +++ b/packages/contracts-manger/package.json @@ -31,7 +31,7 @@ "@windingtree/contracts": "^1.0.0", "@windingtree/sdk-logger": "workspace:*", "@windingtree/sdk-types": "workspace:*", - "superjson": "^1.13.1", + "superjson": "^2.2.1", "viem": "^1.3.0" }, "devDependencies": { diff --git a/packages/node-api/package.json b/packages/node-api/package.json index 524b0c6f..17b0f684 100644 --- a/packages/node-api/package.json +++ b/packages/node-api/package.json @@ -74,7 +74,7 @@ "@windingtree/sdk-types": "workspace:*", "abitype": "^0.9.3", "jose": "^4.14.4", - "superjson": "^1.13.1", + "superjson": "^2.2.1", "viem": "^1.3.0", "zod": "^3.21.4" }, diff --git a/packages/node/package.json b/packages/node/package.json index 88c7b8cd..31009608 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -45,7 +45,7 @@ "@windingtree/sdk-types": "workspace:*", "@windingtree/sdk-utils": "workspace:*", "libp2p": "^0.46.14", - "superjson": "^2.0.0", + "superjson": "^2.2.1", "viem": "^1.3.0" }, "scripts": { diff --git a/packages/pubsub/package.json b/packages/pubsub/package.json index bccb1d85..63b513c8 100644 --- a/packages/pubsub/package.json +++ b/packages/pubsub/package.json @@ -38,7 +38,7 @@ "@windingtree/sdk-utils": "workspace:*", "libp2p": "^0.46.14", "multiformats": "^12.0.1", - "superjson": "^1.13.1" + "superjson": "^2.2.1" }, "scripts": { "build": "tsup", diff --git a/packages/react/package.json b/packages/react/package.json index d698f8f2..75501230 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -57,7 +57,7 @@ "eslint-config-react-app": "^7.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", - "superjson": "^1.13.1", + "superjson": "^2.2.1", "typescript": "^5.1.6", "viem": "^1.3.0" }, diff --git a/packages/storage/package.json b/packages/storage/package.json index 1a8cdb7a..38568028 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -62,7 +62,7 @@ "buffer": "^6.0.3", "classic-level": "^1.3.0", "level-transcoder": "^1.0.1", - "superjson": "^1.13.1" + "superjson": "^2.2.1" }, "scripts": { "build": "tsup", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8b3d566d..89350bbc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -84,8 +84,8 @@ importers: examples/client: dependencies: superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 devDependencies: '@libp2p/interface': specifier: ^0.1.3 @@ -223,8 +223,8 @@ importers: specifier: workspace:* version: link:../../packages/utils superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 devDependencies: '@types/luxon': specifier: ^3.3.0 @@ -411,8 +411,8 @@ importers: specifier: ^0.46.14 version: 0.46.14 superjson: - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^2.2.1 + version: 2.2.1 viem: specifier: ^1.3.0 version: 1.3.0(typescript@5.1.6)(zod@3.21.4) @@ -442,8 +442,8 @@ importers: specifier: workspace:* version: link:../types superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 viem: specifier: ^1.3.0 version: 1.3.0(typescript@5.1.6)(zod@3.21.4) @@ -569,8 +569,8 @@ importers: specifier: ^0.46.14 version: 0.46.14 superjson: - specifier: ^2.0.0 - version: 2.0.0 + specifier: ^2.2.1 + version: 2.2.1 viem: specifier: ^1.3.0 version: 1.3.0(typescript@5.1.6)(zod@3.21.4) @@ -612,8 +612,8 @@ importers: specifier: ^4.14.4 version: 4.14.4 superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 viem: specifier: ^1.3.0 version: 1.3.0(typescript@5.1.6)(zod@3.21.4) @@ -667,8 +667,8 @@ importers: specifier: ^12.0.1 version: 12.0.1 superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 packages/queue: dependencies: @@ -730,8 +730,8 @@ importers: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 typescript: specifier: ^5.1.6 version: 5.1.6 @@ -793,8 +793,8 @@ importers: specifier: ^1.0.1 version: 1.0.1 superjson: - specifier: ^1.13.1 - version: 1.13.1 + specifier: ^2.2.1 + version: 2.2.1 packages/test-utils: dependencies: @@ -11322,18 +11322,11 @@ packages: ts-interface-checker: 0.1.13 dev: true - /superjson@1.13.1: - resolution: {integrity: sha512-AVH2eknm9DEd3qvxM4Sq+LTCkSXE2ssfh1t11MHMXyYXFQyQ1HLgVvV+guLTsaQnJU3gnaVo34TohHPulY/wLg==} - engines: {node: '>=10'} - dependencies: - copy-anything: 3.0.5 - - /superjson@2.0.0: - resolution: {integrity: sha512-W3n+NJ7TFjaLle8ihIIvsr/bbuKpnxeatsyjmhy7iSkom+/cshaHziCQAWXrHGWJVQSQFDOuES6C3nSEvcbrQg==} + /superjson@2.2.1: + resolution: {integrity: sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==} engines: {node: '>=16'} dependencies: copy-anything: 3.0.5 - dev: false /supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==}