@ocap/statedb-sqlite 1.29.14 → 1.29.16

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.
package/esm/db.mjs CHANGED
@@ -112,6 +112,7 @@ var SqliteStateDB = class extends StateDB {
112
112
  schema: {
113
113
  jsonFields: [
114
114
  "ops",
115
+ "deny",
115
116
  "data",
116
117
  "context"
117
118
  ],
@@ -164,6 +164,8 @@ interface DelegationTable {
164
164
  from_: string | null;
165
165
  to_: string | null;
166
166
  ops: string | null;
167
+ deny: string | null;
168
+ validUntil: number | null;
167
169
  data: string | null;
168
170
  context: string | null;
169
171
  }
@@ -0,0 +1,7 @@
1
+ import { Kysely } from "kysely";
2
+
3
+ //#region src/migrations/002-delegation-extensions.d.ts
4
+ declare function up(db: Kysely<unknown>): Promise<void>;
5
+ declare function down(_db: Kysely<unknown>): Promise<void>;
6
+ //#endregion
7
+ export { down, up };
@@ -0,0 +1,16 @@
1
+ import { __exportAll } from "../_virtual/rolldown_runtime.mjs";
2
+ import { sql } from "kysely";
3
+
4
+ //#region src/migrations/002-delegation-extensions.ts
5
+ var _002_delegation_extensions_exports = /* @__PURE__ */ __exportAll({
6
+ down: () => down,
7
+ up: () => up
8
+ });
9
+ async function up(db) {
10
+ await sql`ALTER TABLE delegation ADD COLUMN deny TEXT`.execute(db);
11
+ await sql`ALTER TABLE delegation ADD COLUMN validUntil INTEGER DEFAULT 0`.execute(db);
12
+ }
13
+ async function down(_db) {}
14
+
15
+ //#endregion
16
+ export { _002_delegation_extensions_exports, down, up };
@@ -1,4 +1,5 @@
1
1
  import { _001_genesis_exports } from "./001-genesis.mjs";
2
+ import { _002_delegation_extensions_exports } from "./002-delegation-extensions.mjs";
2
3
  import { Migrator } from "kysely";
3
4
 
4
5
  //#region src/migrations/index.ts
@@ -29,7 +30,10 @@ var InMemoryMigrationProvider = class {
29
30
  async function runMigrations(db) {
30
31
  const { error, results } = await new Migrator({
31
32
  db,
32
- provider: new InMemoryMigrationProvider({ "001-genesis": _001_genesis_exports })
33
+ provider: new InMemoryMigrationProvider({
34
+ "001-genesis": _001_genesis_exports,
35
+ "002-delegation-extensions": _002_delegation_extensions_exports
36
+ })
33
37
  }).migrateToLatest();
34
38
  results?.forEach((it) => {
35
39
  if (it.status === "Success") {} else if (it.status === "Error") console.error(`Migration "${it.migrationName}" failed`);
@@ -46,7 +50,10 @@ async function runMigrations(db) {
46
50
  async function rollbackMigrations(db) {
47
51
  const migrator = new Migrator({
48
52
  db,
49
- provider: new InMemoryMigrationProvider({ "001-genesis": _001_genesis_exports })
53
+ provider: new InMemoryMigrationProvider({
54
+ "001-genesis": _001_genesis_exports,
55
+ "002-delegation-extensions": _002_delegation_extensions_exports
56
+ })
50
57
  });
51
58
  let hasMore = true;
52
59
  while (hasMore) {
package/lib/db.cjs CHANGED
@@ -114,6 +114,7 @@ var SqliteStateDB = class extends _ocap_statedb.StateDB {
114
114
  schema: {
115
115
  jsonFields: [
116
116
  "ops",
117
+ "deny",
117
118
  "data",
118
119
  "context"
119
120
  ],
@@ -164,6 +164,8 @@ interface DelegationTable {
164
164
  from_: string | null;
165
165
  to_: string | null;
166
166
  ops: string | null;
167
+ deny: string | null;
168
+ validUntil: number | null;
167
169
  data: string | null;
168
170
  context: string | null;
169
171
  }
@@ -0,0 +1,23 @@
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ let kysely = require("kysely");
3
+
4
+ //#region src/migrations/002-delegation-extensions.ts
5
+ var _002_delegation_extensions_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
6
+ down: () => down,
7
+ up: () => up
8
+ });
9
+ async function up(db) {
10
+ await kysely.sql`ALTER TABLE delegation ADD COLUMN deny TEXT`.execute(db);
11
+ await kysely.sql`ALTER TABLE delegation ADD COLUMN validUntil INTEGER DEFAULT 0`.execute(db);
12
+ }
13
+ async function down(_db) {}
14
+
15
+ //#endregion
16
+ Object.defineProperty(exports, '_002_delegation_extensions_exports', {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _002_delegation_extensions_exports;
20
+ }
21
+ });
22
+ exports.down = down;
23
+ exports.up = up;
@@ -0,0 +1,7 @@
1
+ import { Kysely } from "kysely";
2
+
3
+ //#region src/migrations/002-delegation-extensions.d.ts
4
+ declare function up(db: Kysely<unknown>): Promise<void>;
5
+ declare function down(_db: Kysely<unknown>): Promise<void>;
6
+ //#endregion
7
+ export { down, up };
@@ -1,5 +1,6 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_migrations_001_genesis = require('./001-genesis.cjs');
3
+ const require_migrations_002_delegation_extensions = require('./002-delegation-extensions.cjs');
3
4
  let kysely = require("kysely");
4
5
 
5
6
  //#region src/migrations/index.ts
@@ -30,7 +31,10 @@ var InMemoryMigrationProvider = class {
30
31
  async function runMigrations(db) {
31
32
  const { error, results } = await new kysely.Migrator({
32
33
  db,
33
- provider: new InMemoryMigrationProvider({ "001-genesis": require_migrations_001_genesis._001_genesis_exports })
34
+ provider: new InMemoryMigrationProvider({
35
+ "001-genesis": require_migrations_001_genesis._001_genesis_exports,
36
+ "002-delegation-extensions": require_migrations_002_delegation_extensions._002_delegation_extensions_exports
37
+ })
34
38
  }).migrateToLatest();
35
39
  results?.forEach((it) => {
36
40
  if (it.status === "Success") {} else if (it.status === "Error") console.error(`Migration "${it.migrationName}" failed`);
@@ -47,7 +51,10 @@ async function runMigrations(db) {
47
51
  async function rollbackMigrations(db) {
48
52
  const migrator = new kysely.Migrator({
49
53
  db,
50
- provider: new InMemoryMigrationProvider({ "001-genesis": require_migrations_001_genesis._001_genesis_exports })
54
+ provider: new InMemoryMigrationProvider({
55
+ "001-genesis": require_migrations_001_genesis._001_genesis_exports,
56
+ "002-delegation-extensions": require_migrations_002_delegation_extensions._002_delegation_extensions_exports
57
+ })
51
58
  });
52
59
  let hasMore = true;
53
60
  while (hasMore) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ocap/statedb-sqlite",
3
3
  "description": "OCAP statedb adapter that uses SQLite as backend",
4
- "version": "1.29.14",
4
+ "version": "1.29.16",
5
5
  "author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ArcBlock/blockchain/issues",
@@ -14,7 +14,7 @@
14
14
  "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)"
15
15
  ],
16
16
  "devDependencies": {
17
- "@ocap/statedb-test": "1.29.14"
17
+ "@ocap/statedb-test": "1.29.16"
18
18
  },
19
19
  "homepage": "https://github.com/ArcBlock/blockchain/tree/master/statedb/sqlite",
20
20
  "keywords": [
@@ -63,10 +63,10 @@
63
63
  "clean": "rm -rf lib esm"
64
64
  },
65
65
  "dependencies": {
66
- "@ocap/state": "1.29.14",
67
- "@ocap/statedb": "1.29.14",
68
- "@ocap/types": "1.29.14",
69
- "@ocap/util": "1.29.14",
66
+ "@ocap/state": "1.29.16",
67
+ "@ocap/statedb": "1.29.16",
68
+ "@ocap/types": "1.29.16",
69
+ "@ocap/util": "1.29.16",
70
70
  "debug": "^4.4.3",
71
71
  "better-sqlite3": "^11.8.1",
72
72
  "kysely": "^0.27.0",