@ocap/state 1.29.4 → 1.29.6

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.
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { IAccountState } from "@ocap/types";
3
+ import * as joi0 from "joi";
3
4
 
4
5
  //#region src/states/account.d.ts
5
6
  declare namespace account_d_exports {
6
7
  export { create, ensureChecksumAddress, isMigrated, schema, update, updateOrCreate, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi0.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
10
11
  declare const update: (state: IAccountState, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
11
12
  declare const updateOrCreate: (state: IAccountState | null, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
@@ -1,12 +1,13 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { schemas } from "@arcblock/validator";
3
3
  import { IAssetState } from "@ocap/types";
4
+ import * as joi0 from "joi";
4
5
 
5
6
  //#region src/states/asset.d.ts
6
7
  declare namespace asset_d_exports {
7
8
  export { create, schema, schemas, update, validate };
8
9
  }
9
- declare const schema: any;
10
+ declare const schema: joi0.ObjectSchema<any>;
10
11
  declare const create: (attrs: Partial<IAssetState>, context: StateContextInput) => IAssetState;
11
12
  declare const update: (state: IAssetState, attrs: Partial<IAssetState>, context: StateContextInput) => IAssetState;
12
13
  declare const validate: (state: IAssetState) => IAssetState;
@@ -30,6 +30,7 @@ declare class Blacklist {
30
30
  isBlocked(address: string): Promise<boolean>;
31
31
  isTrusted(address: string): Promise<boolean>;
32
32
  getTrustedAccountConfig(address: string): Promise<TrustedAccountConfig | null | undefined>;
33
+ dispose(): void;
33
34
  dump(): void;
34
35
  }
35
36
  //#endregion
@@ -19,17 +19,10 @@ var Blacklist = class {
19
19
  this.getBlockedAccounts = getBlockedAccounts;
20
20
  this.getTrustedAccounts = getTrustedAccounts;
21
21
  if (dumpPath && dumpInterval > 0) {
22
- this.timer = setTimeout(() => {
22
+ this.timer = setInterval(() => {
23
23
  this.dump();
24
- this.timer = setTimeout(() => {
25
- this.dump();
26
- }, dumpInterval);
27
- this.timer.unref();
28
24
  }, dumpInterval);
29
25
  this.timer.unref();
30
- process.on("beforeExit", () => {
31
- this.dump();
32
- });
33
26
  }
34
27
  }
35
28
  has(key) {
@@ -56,6 +49,13 @@ var Blacklist = class {
56
49
  if (typeof this.getTrustedAccounts === "function") return (await this.getTrustedAccounts()).find((x) => isSameDid(x.address, address));
57
50
  return null;
58
51
  }
52
+ dispose() {
53
+ if (this.timer) {
54
+ clearInterval(this.timer);
55
+ this.timer = void 0;
56
+ }
57
+ if (this.dumpPath) this.dump();
58
+ }
59
59
  dump() {
60
60
  try {
61
61
  const exported = this.filter.saveAsJSON();
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { IEvidenceState } from "@ocap/types";
3
+ import * as joi7 from "joi";
3
4
 
4
5
  //#region src/states/evidence.d.ts
5
6
  declare namespace evidence_d_exports {
6
7
  export { create, schema, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi7.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IEvidenceState>, context: StateContextInput) => IEvidenceState;
10
11
  declare const validate: (state: IEvidenceState) => IEvidenceState;
11
12
  //#endregion
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { IRollupBlock } from "@ocap/types";
3
+ import * as joi2 from "joi";
3
4
 
4
5
  //#region src/states/rollup-block.d.ts
5
6
  declare namespace rollup_block_d_exports {
6
7
  export { create, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi2.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IRollupBlock>, context: StateContextInput) => IRollupBlock;
10
11
  declare const update: (state: IRollupBlock, context: StateContextInput) => IRollupBlock;
11
12
  declare const validate: (state: IRollupBlock) => IRollupBlock;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { IRollupState } from "@ocap/types";
3
+ import * as joi3 from "joi";
3
4
 
4
5
  //#region src/states/rollup.d.ts
5
6
  declare namespace rollup_d_exports {
6
7
  export { close, create, migrateContract, migrateVault, pause, resume, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi3.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IRollupState>, context: StateContextInput) => IRollupState;
10
11
  declare const update: (state: IRollupState, updates: Partial<IRollupState>, context: StateContextInput) => IRollupState;
11
12
  declare const pause: (state: IRollupState, context: StateContextInput) => IRollupState;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { IStakeState } from "@ocap/types";
3
+ import * as joi6 from "joi";
3
4
 
4
5
  //#region src/states/stake.d.ts
5
6
  declare namespace stake_d_exports {
6
7
  export { create, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi6.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IStakeState>, context: StateContextInput) => IStakeState;
10
11
  declare const update: (state: IStakeState, attrs: Partial<IStakeState>, context: StateContextInput) => IStakeState;
11
12
  declare const validate: (state: IStakeState) => IStakeState;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { ITokenFactoryState } from "@ocap/types";
3
+ import * as joi1 from "joi";
3
4
 
4
5
  //#region src/states/token-factory.d.ts
5
6
  declare namespace token_factory_d_exports {
6
7
  export { create, curveSchema, update, validate };
7
8
  }
8
- declare const curveSchema: any;
9
+ declare const curveSchema: joi1.AlternativesSchema<any>;
9
10
  declare const create: (attrs: Partial<ITokenFactoryState>, context: StateContextInput) => ITokenFactoryState;
10
11
  declare const update: (state: ITokenFactoryState, attrs: Partial<ITokenFactoryState>, context: StateContextInput) => ITokenFactoryState;
11
12
  declare const validate: (state: ITokenFactoryState) => ITokenFactoryState;
@@ -1,12 +1,13 @@
1
1
  import { StateContextInput } from "../contexts/state.mjs";
2
2
  import { ITokenState } from "@ocap/types";
3
+ import * as joi4 from "joi";
3
4
 
4
5
  //#region src/states/token.d.ts
5
6
  declare namespace token_d_exports {
6
7
  export { create, metadataSchema, stateSchema, update, validate };
7
8
  }
8
- declare const metadataSchema: any;
9
- declare const stateSchema: any;
9
+ declare const metadataSchema: joi4.ObjectSchema<any>;
10
+ declare const stateSchema: joi4.ObjectSchema<any>;
10
11
  declare const create: (attrs: Partial<ITokenState>, context: StateContextInput) => ITokenState;
11
12
  declare const update: (state: ITokenState, attrs: Partial<ITokenState>) => ITokenState;
12
13
  declare const validate: (state: ITokenState) => ITokenState;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IAccountState } from "@ocap/types";
3
+ import * as joi0 from "joi";
3
4
 
4
5
  //#region src/states/account.d.ts
5
6
  declare namespace account_d_exports {
6
7
  export { create, ensureChecksumAddress, isMigrated, schema, update, updateOrCreate, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi0.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
10
11
  declare const update: (state: IAccountState, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
11
12
  declare const updateOrCreate: (state: IAccountState | null, attrs: Partial<IAccountState>, context: StateContextInput) => IAccountState;
@@ -1,12 +1,13 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IAssetState } from "@ocap/types";
3
+ import * as joi2 from "joi";
3
4
  import { schemas } from "@arcblock/validator";
4
5
 
5
6
  //#region src/states/asset.d.ts
6
7
  declare namespace asset_d_exports {
7
8
  export { create, schema, schemas, update, validate };
8
9
  }
9
- declare const schema: any;
10
+ declare const schema: joi2.ObjectSchema<any>;
10
11
  declare const create: (attrs: Partial<IAssetState>, context: StateContextInput) => IAssetState;
11
12
  declare const update: (state: IAssetState, attrs: Partial<IAssetState>, context: StateContextInput) => IAssetState;
12
13
  declare const validate: (state: IAssetState) => IAssetState;
@@ -22,17 +22,10 @@ var Blacklist = class {
22
22
  this.getBlockedAccounts = getBlockedAccounts;
23
23
  this.getTrustedAccounts = getTrustedAccounts;
24
24
  if (dumpPath && dumpInterval > 0) {
25
- this.timer = setTimeout(() => {
25
+ this.timer = setInterval(() => {
26
26
  this.dump();
27
- this.timer = setTimeout(() => {
28
- this.dump();
29
- }, dumpInterval);
30
- this.timer.unref();
31
27
  }, dumpInterval);
32
28
  this.timer.unref();
33
- process.on("beforeExit", () => {
34
- this.dump();
35
- });
36
29
  }
37
30
  }
38
31
  has(key) {
@@ -59,6 +52,13 @@ var Blacklist = class {
59
52
  if (typeof this.getTrustedAccounts === "function") return (await this.getTrustedAccounts()).find((x) => (0, _ocap_util.isSameDid)(x.address, address));
60
53
  return null;
61
54
  }
55
+ dispose() {
56
+ if (this.timer) {
57
+ clearInterval(this.timer);
58
+ this.timer = void 0;
59
+ }
60
+ if (this.dumpPath) this.dump();
61
+ }
62
62
  dump() {
63
63
  try {
64
64
  const exported = this.filter.saveAsJSON();
@@ -30,6 +30,7 @@ declare class Blacklist {
30
30
  isBlocked(address: string): Promise<boolean>;
31
31
  isTrusted(address: string): Promise<boolean>;
32
32
  getTrustedAccountConfig(address: string): Promise<TrustedAccountConfig | null | undefined>;
33
+ dispose(): void;
33
34
  dump(): void;
34
35
  }
35
36
  //#endregion
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IEvidenceState } from "@ocap/types";
3
+ import * as joi7 from "joi";
3
4
 
4
5
  //#region src/states/evidence.d.ts
5
6
  declare namespace evidence_d_exports {
6
7
  export { create, schema, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi7.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IEvidenceState>, context: StateContextInput) => IEvidenceState;
10
11
  declare const validate: (state: IEvidenceState) => IEvidenceState;
11
12
  //#endregion
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IRollupBlock } from "@ocap/types";
3
+ import * as joi0 from "joi";
3
4
 
4
5
  //#region src/states/rollup-block.d.ts
5
6
  declare namespace rollup_block_d_exports {
6
7
  export { create, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi0.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IRollupBlock>, context: StateContextInput) => IRollupBlock;
10
11
  declare const update: (state: IRollupBlock, context: StateContextInput) => IRollupBlock;
11
12
  declare const validate: (state: IRollupBlock) => IRollupBlock;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IRollupState } from "@ocap/types";
3
+ import * as joi1 from "joi";
3
4
 
4
5
  //#region src/states/rollup.d.ts
5
6
  declare namespace rollup_d_exports {
6
7
  export { close, create, migrateContract, migrateVault, pause, resume, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi1.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IRollupState>, context: StateContextInput) => IRollupState;
10
11
  declare const update: (state: IRollupState, updates: Partial<IRollupState>, context: StateContextInput) => IRollupState;
11
12
  declare const pause: (state: IRollupState, context: StateContextInput) => IRollupState;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { IStakeState } from "@ocap/types";
3
+ import * as joi3 from "joi";
3
4
 
4
5
  //#region src/states/stake.d.ts
5
6
  declare namespace stake_d_exports {
6
7
  export { create, schema, update, validate };
7
8
  }
8
- declare const schema: any;
9
+ declare const schema: joi3.ObjectSchema<any>;
9
10
  declare const create: (attrs: Partial<IStakeState>, context: StateContextInput) => IStakeState;
10
11
  declare const update: (state: IStakeState, attrs: Partial<IStakeState>, context: StateContextInput) => IStakeState;
11
12
  declare const validate: (state: IStakeState) => IStakeState;
@@ -1,11 +1,12 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { ITokenFactoryState } from "@ocap/types";
3
+ import * as joi4 from "joi";
3
4
 
4
5
  //#region src/states/token-factory.d.ts
5
6
  declare namespace token_factory_d_exports {
6
7
  export { create, curveSchema, update, validate };
7
8
  }
8
- declare const curveSchema: any;
9
+ declare const curveSchema: joi4.AlternativesSchema<any>;
9
10
  declare const create: (attrs: Partial<ITokenFactoryState>, context: StateContextInput) => ITokenFactoryState;
10
11
  declare const update: (state: ITokenFactoryState, attrs: Partial<ITokenFactoryState>, context: StateContextInput) => ITokenFactoryState;
11
12
  declare const validate: (state: ITokenFactoryState) => ITokenFactoryState;
@@ -1,12 +1,13 @@
1
1
  import { StateContextInput } from "../contexts/state.cjs";
2
2
  import { ITokenState } from "@ocap/types";
3
+ import * as joi5 from "joi";
3
4
 
4
5
  //#region src/states/token.d.ts
5
6
  declare namespace token_d_exports {
6
7
  export { create, metadataSchema, stateSchema, update, validate };
7
8
  }
8
- declare const metadataSchema: any;
9
- declare const stateSchema: any;
9
+ declare const metadataSchema: joi5.ObjectSchema<any>;
10
+ declare const stateSchema: joi5.ObjectSchema<any>;
10
11
  declare const create: (attrs: Partial<ITokenState>, context: StateContextInput) => ITokenState;
11
12
  declare const update: (state: ITokenState, attrs: Partial<ITokenState>) => ITokenState;
12
13
  declare const validate: (state: ITokenState) => ITokenState;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.29.4",
6
+ "version": "1.29.6",
7
7
  "description": "State management utilities for OCAP blockchain",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -36,17 +36,18 @@
36
36
  "lint": "biome check",
37
37
  "lint:fix": "biome check --write",
38
38
  "test": "bun test",
39
- "coverage": "bun test --coverage"
39
+ "coverage": "bun test --coverage",
40
+ "clean": "rm -rf lib esm"
40
41
  },
41
42
  "dependencies": {
42
- "@arcblock/did": "1.29.4",
43
- "@arcblock/validator": "1.29.4",
44
- "@ocap/contract": "1.29.4",
45
- "@ocap/mcrypto": "1.29.4",
46
- "@ocap/message": "1.29.4",
47
- "@ocap/types": "1.29.4",
48
- "@ocap/util": "1.29.4",
49
- "@ocap/wallet": "1.29.4",
43
+ "@arcblock/did": "1.29.6",
44
+ "@arcblock/validator": "1.29.6",
45
+ "@ocap/contract": "1.29.6",
46
+ "@ocap/mcrypto": "1.29.6",
47
+ "@ocap/message": "1.29.6",
48
+ "@ocap/types": "1.29.6",
49
+ "@ocap/util": "1.29.6",
50
+ "@ocap/wallet": "1.29.6",
50
51
  "bloom-filters": "^1.3.9",
51
52
  "lodash": "^4.17.23"
52
53
  },