@ocap/statedb 1.30.10 → 1.30.12

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/table.mjs CHANGED
@@ -32,12 +32,18 @@ var StateDBTable = class extends Ready {
32
32
  hooks.execPreSync(x, args);
33
33
  const result = await this[`_${x}`](...args);
34
34
  hooks.execPostSync(x, result);
35
+ const ctxArg = args.slice(-1).pop();
36
+ const timer = ctxArg?.timer;
37
+ if (timer?.incrCounter) {
38
+ if (x === "get") timer.incrCounter("stateReads");
39
+ else if (x === "create" || x === "update") timer.incrCounter(this.name === "balance" ? "tokenWrites" : "stateWrites");
40
+ }
35
41
  if ([
36
42
  "create",
37
43
  "update",
38
44
  "reset"
39
45
  ].includes(x)) {
40
- const ctx = args.slice(-1).pop();
46
+ const ctx = ctxArg;
41
47
  if (ctx?.tx) {
42
48
  const events = ctx.events || [];
43
49
  events.push({
package/lib/table.cjs CHANGED
@@ -38,12 +38,18 @@ var StateDBTable = class extends _ocap_util_lib_ready.Ready {
38
38
  hooks.execPreSync(x, args);
39
39
  const result = await this[`_${x}`](...args);
40
40
  hooks.execPostSync(x, result);
41
+ const ctxArg = args.slice(-1).pop();
42
+ const timer = ctxArg?.timer;
43
+ if (timer?.incrCounter) {
44
+ if (x === "get") timer.incrCounter("stateReads");
45
+ else if (x === "create" || x === "update") timer.incrCounter(this.name === "balance" ? "tokenWrites" : "stateWrites");
46
+ }
41
47
  if ([
42
48
  "create",
43
49
  "update",
44
50
  "reset"
45
51
  ].includes(x)) {
46
- const ctx = args.slice(-1).pop();
52
+ const ctx = ctxArg;
47
53
  if (ctx?.tx) {
48
54
  const events = ctx.events || [];
49
55
  events.push({
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.30.10",
6
+ "version": "1.30.12",
7
7
  "description": "Defines the basic interface for OCAP StateDB",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -44,10 +44,10 @@
44
44
  "license": "MIT",
45
45
  "devDependencies": {},
46
46
  "dependencies": {
47
- "@arcblock/did": "1.30.10",
48
- "@ocap/state": "1.30.10",
49
- "@ocap/types": "1.30.10",
50
- "@ocap/util": "1.30.10",
47
+ "@arcblock/did": "1.30.12",
48
+ "@ocap/state": "1.30.12",
49
+ "@ocap/types": "1.30.12",
50
+ "@ocap/util": "1.30.12",
51
51
  "kareem": "^2.4.1",
52
52
  "lodash": "^4.17.23"
53
53
  }