@ocap/indexdb 1.18.91 → 1.18.93

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.
Files changed (3) hide show
  1. package/lib/db.js +4 -0
  2. package/lib/util.js +10 -0
  3. package/package.json +4 -4
package/lib/db.js CHANGED
@@ -53,6 +53,10 @@ class BaseIndexDB extends Ready {
53
53
  listBlocks() {
54
54
  return [];
55
55
  }
56
+
57
+ listDelegations({ from, to, paging = {}, timeFilter = {} } = {}) {
58
+ throw new Error('listDelegations should be implemented in adapter');
59
+ }
56
60
  }
57
61
 
58
62
  module.exports = BaseIndexDB;
package/lib/util.js CHANGED
@@ -73,9 +73,13 @@ const createIndexedDelegation = (x, ctx) => {
73
73
  };
74
74
  if (ctx.senderState) {
75
75
  result.from = get(ctx, 'senderState.address', '');
76
+ } else {
77
+ result.from = get(ctx, 'tx.from', '');
76
78
  }
77
79
  if (ctx.receiverState) {
78
80
  result.to = get(ctx, 'receiverState.address', '');
81
+ } else {
82
+ result.to = get(ctx, 'itx.to', '');
79
83
  }
80
84
  return result;
81
85
  };
@@ -407,6 +411,11 @@ const formatTxAfterRead = (tx) => {
407
411
  return tx;
408
412
  };
409
413
 
414
+ const formatDelegationAfterRead = (delegation) => {
415
+ delegation.ops = Object.keys(delegation.ops).map((x) => ({ key: x, value: delegation.ops[x] }));
416
+ return delegation;
417
+ };
418
+
410
419
  const parseDateTime = (str) => {
411
420
  if (!str) {
412
421
  return '';
@@ -554,4 +563,5 @@ module.exports = {
554
563
  parseDateTime,
555
564
  formatTokenMeta,
556
565
  isDefaultTokenChanged,
566
+ formatDelegationAfterRead,
557
567
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.91",
6
+ "version": "1.18.93",
7
7
  "description": "Defines the basic interface for OCAP IndexDB",
8
8
  "main": "lib/main.js",
9
9
  "files": [
@@ -25,10 +25,10 @@
25
25
  "jest": "^27.5.1"
26
26
  },
27
27
  "dependencies": {
28
- "@ocap/state": "1.18.91",
29
- "@ocap/util": "1.18.91",
28
+ "@ocap/state": "1.18.93",
29
+ "@ocap/util": "1.18.93",
30
30
  "kareem": "^2.4.1",
31
31
  "lodash": "^4.17.21"
32
32
  },
33
- "gitHead": "5808d49e17c1703ba077ab5a2a4eb65f24947533"
33
+ "gitHead": "de8cc73243a1d3d27c9ecc6af6a7892a3e0c683a"
34
34
  }