@ocap/indexdb 1.18.92 → 1.18.94

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/lib/db.js +4 -0
  2. package/lib/util.js +14 -1
  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
@@ -69,13 +69,18 @@ const createIndexedDelegation = (x, ctx) => {
69
69
  data: x.data,
70
70
  genesisTime: x.context.genesisTime,
71
71
  renaissanceTime: x.context.renaissanceTime,
72
- ops: x.ops,
72
+ // https://discuss.elastic.co/t/updating-an-object-field/110735
73
+ ops: [x.ops],
73
74
  };
74
75
  if (ctx.senderState) {
75
76
  result.from = get(ctx, 'senderState.address', '');
77
+ } else {
78
+ result.from = get(ctx, 'tx.from', '');
76
79
  }
77
80
  if (ctx.receiverState) {
78
81
  result.to = get(ctx, 'receiverState.address', '');
82
+ } else {
83
+ result.to = get(ctx, 'itx.to', '');
79
84
  }
80
85
  return result;
81
86
  };
@@ -407,6 +412,13 @@ const formatTxAfterRead = (tx) => {
407
412
  return tx;
408
413
  };
409
414
 
415
+ const formatDelegationAfterRead = (delegation) => {
416
+ // https://discuss.elastic.co/t/updating-an-object-field/110735
417
+ const ops = Array.isArray(delegation.ops) ? delegation.ops[0] : delegation.ops;
418
+ delegation.ops = Object.keys(ops).map((x) => ({ key: x, value: ops[x] }));
419
+ return delegation;
420
+ };
421
+
410
422
  const parseDateTime = (str) => {
411
423
  if (!str) {
412
424
  return '';
@@ -554,4 +566,5 @@ module.exports = {
554
566
  parseDateTime,
555
567
  formatTokenMeta,
556
568
  isDefaultTokenChanged,
569
+ formatDelegationAfterRead,
557
570
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.92",
6
+ "version": "1.18.94",
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.92",
29
- "@ocap/util": "1.18.92",
28
+ "@ocap/state": "1.18.94",
29
+ "@ocap/util": "1.18.94",
30
30
  "kareem": "^2.4.1",
31
31
  "lodash": "^4.17.21"
32
32
  },
33
- "gitHead": "166a276e6865f140e5eed88aced8a4ad39186a74"
33
+ "gitHead": "6e23a66fb0adcd1359e21b4fde180860b4c305b3"
34
34
  }