@ocap/resolver 1.18.100 → 1.18.102

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/index.js +31 -1
  2. package/package.json +12 -12
package/lib/index.js CHANGED
@@ -466,7 +466,20 @@ module.exports = class OCAPResolver {
466
466
  }
467
467
 
468
468
  getDelegateState({ address }, ctx) {
469
- return this._getState({ table: 'delegation', id: address, dataKey: 'data', onRead: formatDelegationOps, ctx });
469
+ return this._getState({
470
+ table: 'delegation',
471
+ id: address,
472
+ dataKey: 'data',
473
+ onRead: async (state) => {
474
+ if (state) {
475
+ formatDelegationOps(state);
476
+ await this.formatDelegateState(state);
477
+ }
478
+
479
+ return state;
480
+ },
481
+ ctx,
482
+ });
470
483
  }
471
484
 
472
485
  async getAccountTokens({ address, token }, ctx) {
@@ -897,6 +910,9 @@ module.exports = class OCAPResolver {
897
910
  if (listKey === 'transactions') {
898
911
  tx = await this.formatTx(tx, ctx);
899
912
  }
913
+ if (listKey === 'delegations') {
914
+ tx = await this.formatDelegateState(tx);
915
+ }
900
916
 
901
917
  return tx;
902
918
  })
@@ -1057,6 +1073,20 @@ module.exports = class OCAPResolver {
1057
1073
 
1058
1074
  return ctx;
1059
1075
  }
1076
+
1077
+ async formatDelegateState(state) {
1078
+ if (Array.isArray(state.ops) && state.ops.length > 0) {
1079
+ await Promise.all(
1080
+ state.ops.map(async (op) => {
1081
+ if (op.value.limit && Array.isArray(op.value.limit.tokens)) {
1082
+ op.value.limit.tokens = await this.formatTokenArray(op.value.limit.tokens || []);
1083
+ }
1084
+ })
1085
+ );
1086
+ }
1087
+
1088
+ return state;
1089
+ }
1060
1090
  };
1061
1091
 
1062
1092
  module.exports.formatData = formatData;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.100",
6
+ "version": "1.18.102",
7
7
  "description": "GraphQL resolver built upon ocap statedb and GQL layer",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -22,18 +22,18 @@
22
22
  "jest": "^27.5.1"
23
23
  },
24
24
  "dependencies": {
25
- "@arcblock/did": "1.18.100",
26
- "@arcblock/did-util": "1.18.100",
27
- "@arcblock/validator": "1.18.100",
28
- "@ocap/config": "1.18.100",
29
- "@ocap/indexdb": "1.18.100",
30
- "@ocap/mcrypto": "1.18.100",
31
- "@ocap/message": "1.18.100",
32
- "@ocap/state": "1.18.100",
33
- "@ocap/tx-protocols": "1.18.100",
34
- "@ocap/util": "1.18.100",
25
+ "@arcblock/did": "1.18.102",
26
+ "@arcblock/did-util": "1.18.102",
27
+ "@arcblock/validator": "1.18.102",
28
+ "@ocap/config": "1.18.102",
29
+ "@ocap/indexdb": "1.18.102",
30
+ "@ocap/mcrypto": "1.18.102",
31
+ "@ocap/message": "1.18.102",
32
+ "@ocap/state": "1.18.102",
33
+ "@ocap/tx-protocols": "1.18.102",
34
+ "@ocap/util": "1.18.102",
35
35
  "debug": "^4.3.4",
36
36
  "lodash": "^4.17.21"
37
37
  },
38
- "gitHead": "600fdfe8e06f2c4db05739d541c47202c92a3c9e"
38
+ "gitHead": "f9735d521051d45331073b3e52c743ad01e3b8e5"
39
39
  }