@acala-network/chopsticks-db 0.9.4-2 → 0.9.4-4

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.
@@ -0,0 +1,15 @@
1
+ import { BlockEntry, Database, KeyValueEntry } from '@acala-network/chopsticks-core';
2
+ import { DataSource } from 'typeorm';
3
+ import { HexString } from '@polkadot/util/types';
4
+ export declare abstract class BaseSqlDatabase implements Database {
5
+ abstract datasource: Promise<DataSource>;
6
+ close: () => Promise<void>;
7
+ saveBlock(block: BlockEntry): Promise<void>;
8
+ queryBlock(hash: HexString): Promise<BlockEntry | null>;
9
+ queryBlockByNumber(number: number): Promise<BlockEntry | null>;
10
+ queryHighestBlock(): Promise<BlockEntry | null>;
11
+ deleteBlock(hash: HexString): Promise<void>;
12
+ blocksCount(): Promise<number>;
13
+ saveStorage(blockHash: HexString, key: HexString, value: HexString | null): Promise<void>;
14
+ queryStorage(blockHash: HexString, key: HexString): Promise<KeyValueEntry | null>;
15
+ }
@@ -0,0 +1,29 @@
1
+ import { BlockEntry, Database, KeyValueEntry } from '@acala-network/chopsticks-core';
2
+ import { DBSchema, IDBPDatabase } from 'idb';
3
+ interface Schema extends DBSchema {
4
+ keyValue: {
5
+ key: string;
6
+ value: string | null;
7
+ };
8
+ block: {
9
+ key: string;
10
+ value: BlockEntry;
11
+ indexes: {
12
+ byNumber: number;
13
+ };
14
+ };
15
+ }
16
+ export declare class IdbDatabase implements Database {
17
+ datasource: Promise<IDBPDatabase<Schema>>;
18
+ constructor(location: string);
19
+ close(): Promise<void>;
20
+ saveBlock(block: BlockEntry): Promise<void>;
21
+ queryBlock(hash: `0x${string}`): Promise<BlockEntry | null>;
22
+ queryBlockByNumber(number: number): Promise<BlockEntry | null>;
23
+ queryHighestBlock(): Promise<BlockEntry | null>;
24
+ deleteBlock(hash: `0x${string}`): Promise<void>;
25
+ blocksCount(): Promise<number>;
26
+ saveStorage(blockHash: `0x${string}`, key: `0x${string}`, value: `0x${string}` | null): Promise<void>;
27
+ queryStorage(blockHash: `0x${string}`, key: `0x${string}`): Promise<KeyValueEntry | null>;
28
+ }
29
+ export {};
@@ -0,0 +1,4 @@
1
+ import { BlockEntry, KeyValueEntry } from '@acala-network/chopsticks-core';
2
+ import { EntitySchema } from 'typeorm';
3
+ export declare const KeyValuePair: EntitySchema<KeyValueEntry>;
4
+ export declare const BlockEntity: EntitySchema<BlockEntry>;
@@ -0,0 +1,2 @@
1
+ import { DataSource } from 'typeorm';
2
+ export declare const openDb: (dbPath: string) => Promise<DataSource>;
@@ -0,0 +1,6 @@
1
+ import { DataSource } from 'typeorm';
2
+ import { BaseSqlDatabase } from './base-sql.js';
3
+ export declare class SqliteDatabase extends BaseSqlDatabase {
4
+ datasource: Promise<DataSource>;
5
+ constructor(location: string);
6
+ }
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@acala-network/chopsticks-db",
3
- "version": "0.9.4-2",
3
+ "version": "0.9.4-4",
4
4
  "author": "Acala Developers <hello@acala.network>",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "clean": "rm -rf dist",
9
- "build": "yarn clean && yarn build:cjs && yarn build:esm && yarn build:types",
10
- "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
11
- "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm",
12
- "build:types": "tsc -p tsconfig.json --emitDeclarationOnly --outDir dist/types"
8
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
9
+ "build": "yarn clean && yarn build:cjs && yarn build:esm",
10
+ "build:cjs": "swc ./src --config-file ../../.cjsswcrc -d dist/cjs && tsc -p tsconfig.json --declarationDir dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
11
+ "build:esm": "swc ./src --config-file ../../.esmswcrc -d dist/esm && tsc -p tsconfig.json --declarationDir dist/esm"
13
12
  },
14
13
  "dependencies": {
15
- "@acala-network/chopsticks-core": "0.9.4-2",
14
+ "@acala-network/chopsticks-core": "0.9.4-4",
16
15
  "@polkadot/util": "^12.5.1",
17
16
  "idb": "^7.1.1",
18
17
  "sqlite3": "^5.1.6",
@@ -25,26 +24,20 @@
25
24
  },
26
25
  "files": [
27
26
  "dist/esm/**",
28
- "dist/cjs/**",
29
- "dist/types/**"
27
+ "dist/cjs/**"
30
28
  ],
31
29
  "main": "./dist/cjs/index.js",
32
30
  "module": "./dist/esm/index.js",
33
- "types": "./dist/types/index.d.ts",
34
31
  "exports": {
35
32
  ".": {
36
- "types": "./dist/types/index.d.ts",
37
33
  "require": "./dist/cjs/index.js",
38
34
  "import": "./dist/esm/index.js",
39
35
  "default": "./dist/esm/index.js"
40
36
  },
41
37
  "./*": {
42
- "types": "./dist/types/*.d.ts",
43
38
  "require": "./dist/cjs/*.js",
44
39
  "import": "./dist/esm/*.js",
45
40
  "default": "./dist/esm/*.js"
46
- },
47
- "./package.json": "./package.json",
48
- "./package.cjs.json": "./dist/cjs/package.json"
41
+ }
49
42
  }
50
43
  }
File without changes
File without changes
File without changes
File without changes
File without changes