@ocap/indexdb 1.17.7 → 1.17.10

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 (2) hide show
  1. package/lib/util.js +27 -14
  2. package/package.json +6 -6
package/lib/util.js CHANGED
@@ -58,15 +58,22 @@ const createIndexedAsset = (x) => ({
58
58
  tags: x.tags,
59
59
  });
60
60
 
61
- const createIndexedDelegation = (x, ctx) => ({
62
- address: x.address,
63
- data: x.data,
64
- genesisTime: x.context.genesisTime,
65
- renaissanceTime: x.context.renaissanceTime,
66
- ops: x.ops,
67
- from: get(ctx, 'senderState.address', ''),
68
- to: get(ctx, 'receiverState.address', ''),
69
- });
61
+ const createIndexedDelegation = (x, ctx) => {
62
+ const result = {
63
+ address: x.address,
64
+ data: x.data,
65
+ genesisTime: x.context.genesisTime,
66
+ renaissanceTime: x.context.renaissanceTime,
67
+ ops: x.ops,
68
+ };
69
+ if (ctx.senderState) {
70
+ result.from = get(ctx, 'senderState.address', '');
71
+ }
72
+ if (ctx.receiverState) {
73
+ result.to = get(ctx, 'receiverState.address', '');
74
+ }
75
+ return result;
76
+ };
70
77
 
71
78
  const createIndexedToken = (x) => ({
72
79
  address: x.address,
@@ -85,7 +92,7 @@ const createIndexedToken = (x) => ({
85
92
  renaissanceTime: x.context.renaissanceTime,
86
93
  });
87
94
 
88
- const createIndexedFactory = async (factory, context) => {
95
+ const createIndexedFactory = (factory, context) => {
89
96
  if (context.factoryTokens && context.factoryTokens.length > 0) {
90
97
  factory.input.tokens = factory.input.tokens.map((token) => formatTokenMeta(token, context.tokenStates));
91
98
  }
@@ -116,7 +123,7 @@ const createIndexedFactory = async (factory, context) => {
116
123
  };
117
124
 
118
125
  // These fields are used internally to filter transactions by some entity
119
- const createIndexedTransaction = (tx, ctx) => {
126
+ const createIndexedTransaction = async (tx, ctx, indexdb) => {
120
127
  tx.accounts = [tx.tx.from, tx.sender, tx.receiver];
121
128
  tx.assets = [];
122
129
  tx.tokens = [];
@@ -142,6 +149,12 @@ const createIndexedTransaction = (tx, ctx) => {
142
149
  if (ctx.delegatorState) {
143
150
  tx.accounts.push(ctx.delegatorState.address);
144
151
  }
152
+ if (ctx.delegationState && ctx.txType === 'fg:t:revoke_delegate') {
153
+ const indexed = await indexdb.delegation.get(ctx.delegationState.address);
154
+ if (indexed) {
155
+ tx.accounts.push(indexed.to);
156
+ }
157
+ }
145
158
  if (Array.isArray(ctx.delegatorStates)) {
146
159
  tx.accounts.push(...ctx.delegatorStates.map((x) => x.address));
147
160
  }
@@ -200,7 +213,7 @@ const createIndexedTransaction = (tx, ctx) => {
200
213
  return tx;
201
214
  };
202
215
 
203
- const createIndexedStake = async (x, ctx) => {
216
+ const createIndexedStake = (x, ctx) => {
204
217
  return {
205
218
  ...pick(x, [
206
219
  'address',
@@ -224,7 +237,7 @@ const createIndexedStake = async (x, ctx) => {
224
237
  };
225
238
  };
226
239
 
227
- const createIndexedRollup = async (x, ctx) => {
240
+ const createIndexedRollup = (x, ctx) => {
228
241
  const rollup = {
229
242
  ...pick(x, [
230
243
  'address',
@@ -275,7 +288,7 @@ const createIndexedRollup = async (x, ctx) => {
275
288
  return rollup;
276
289
  };
277
290
 
278
- const createIndexedRollupBlock = async (x, ctx) => {
291
+ const createIndexedRollupBlock = (x, ctx) => {
279
292
  return {
280
293
  ...pick(x, [
281
294
  'hash',
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.17.7",
6
+ "version": "1.17.10",
7
7
  "description": "Defines the basic interface for OCAP IndexDB",
8
8
  "main": "lib/main.js",
9
9
  "files": [
@@ -22,13 +22,13 @@
22
22
  ],
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "jest": "^27.3.1"
25
+ "jest": "^27.5.1"
26
26
  },
27
27
  "dependencies": {
28
- "@ocap/state": "1.17.7",
29
- "@ocap/util": "1.17.7",
30
- "kareem": "^2.3.2",
28
+ "@ocap/state": "1.17.10",
29
+ "@ocap/util": "1.17.10",
30
+ "kareem": "^2.4.1",
31
31
  "lodash": "^4.17.21"
32
32
  },
33
- "gitHead": "02d9fa7c14c70f0a5fc1dcc5dc5506e43cb71ba5"
33
+ "gitHead": "062c4f18a4e6d370cb1659980c602e8494969dc3"
34
34
  }