@ocap/resolver 1.18.156 → 1.18.157

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/lib/index.js CHANGED
@@ -987,8 +987,14 @@ module.exports = class OCAPResolver {
987
987
  }
988
988
  }
989
989
 
990
- // https://github.com/blocklet/abt-wallet/issues/681
991
- if (typeUrl === 'fg:t:deposit_token' || typeUrl === 'fg:t:withdraw_token') {
990
+ if (
991
+ [
992
+ // https://github.com/blocklet/abt-wallet/issues/681
993
+ 'fg:t:deposit_token',
994
+ 'fg:t:withdraw_token',
995
+ 'fg:t:revoke_swap',
996
+ ].includes(typeUrl)
997
+ ) {
992
998
  tx.receipts = getTxReceipts(tx, { config: this.config });
993
999
  }
994
1000
 
@@ -1017,27 +1023,30 @@ module.exports = class OCAPResolver {
1017
1023
  }
1018
1024
 
1019
1025
  async _getAllResults(dataKey, fn, limit) {
1020
- const results = [];
1021
1026
  const pageSize = 100;
1022
-
1023
1027
  const { paging, [dataKey]: firstPage } = await fn({ size: pageSize });
1024
1028
 
1025
1029
  // Skip if total exceeds limit cause we cannot query full data
1026
1030
  if (limit && paging.total > limit) {
1027
1031
  throw new CustomError('EXCEED_LIMIT', `Total exceeds limit ${limit}`);
1028
1032
  }
1029
-
1030
1033
  if (paging.total < pageSize) {
1031
1034
  return firstPage;
1032
1035
  }
1033
1036
 
1034
- results.push(...firstPage);
1037
+ const totalPage = Math.floor(paging.total / pageSize);
1038
+ const cursors = new Array(totalPage).fill(true).map((_, i) => (i + 1) * pageSize);
1039
+ const step = 3;
1040
+ let results = firstPage;
1035
1041
 
1036
- const total = Math.floor(paging.total / pageSize);
1037
- for (let i = 1; i <= total; i++) {
1038
- // eslint-disable-next-line no-await-in-loop
1039
- const { [dataKey]: nextPage } = await fn({ size: pageSize, cursor: i * pageSize });
1040
- results.push(...nextPage);
1042
+ for (let i = 0; i < cursors.length; i += step) {
1043
+ const batchResults = await Promise.all(
1044
+ cursors.slice(i, i + step).map(async (cursor) => {
1045
+ const { [dataKey]: list } = await fn({ size: pageSize, cursor });
1046
+ return list;
1047
+ })
1048
+ );
1049
+ results = results.concat(batchResults.flat());
1041
1050
  }
1042
1051
 
1043
1052
  return results;
package/lib/token-flow.js CHANGED
@@ -198,7 +198,7 @@ const verifyAccountRisk = async (
198
198
  throw e;
199
199
  }
200
200
 
201
- const accountState = await resolver.getAccountState({ address, traceMigration: false }, ctx);
201
+ const accountState = await resolver.getAccountState({ address, traceMigration: false, expandContext: false }, ctx);
202
202
  if (!accountState) {
203
203
  throw new CustomError('INVALID_REQUEST', `Invalid address ${address}`);
204
204
  }
@@ -209,12 +209,10 @@ const verifyAccountRisk = async (
209
209
 
210
210
  // Parse txs to get transfer amounts
211
211
  for (const tx of transactions) {
212
- // fix migrate receipts
213
- await fixMigrateReceipts(tx, resolver, ctx);
214
-
215
212
  // cache tx
216
213
  if (!checkedTx.has(tx.hash)) {
217
- checkedTx.set(tx.hash, await getTransferList(tx, tokenAddress));
214
+ await fixMigrateReceipts(tx, resolver, ctx);
215
+ checkedTx.set(tx.hash, getTransferList(tx, tokenAddress));
218
216
  }
219
217
  const { transferInList, transferOutList } = checkedTx.get(tx.hash);
220
218
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.156",
6
+ "version": "1.18.157",
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": "^29.7.0"
23
23
  },
24
24
  "dependencies": {
25
- "@arcblock/did": "1.18.156",
26
- "@arcblock/did-util": "1.18.156",
27
- "@arcblock/validator": "1.18.156",
28
- "@ocap/config": "1.18.156",
29
- "@ocap/indexdb": "1.18.156",
30
- "@ocap/mcrypto": "1.18.156",
31
- "@ocap/message": "1.18.156",
32
- "@ocap/state": "1.18.156",
33
- "@ocap/tx-protocols": "1.18.156",
34
- "@ocap/util": "1.18.156",
25
+ "@arcblock/did": "1.18.157",
26
+ "@arcblock/did-util": "1.18.157",
27
+ "@arcblock/validator": "1.18.157",
28
+ "@ocap/config": "1.18.157",
29
+ "@ocap/indexdb": "1.18.157",
30
+ "@ocap/mcrypto": "1.18.157",
31
+ "@ocap/message": "1.18.157",
32
+ "@ocap/state": "1.18.157",
33
+ "@ocap/tx-protocols": "1.18.157",
34
+ "@ocap/util": "1.18.157",
35
35
  "debug": "^4.3.6",
36
36
  "lodash": "^4.17.21"
37
37
  },
38
- "gitHead": "955c3e7ae8e06fc037e6591267babaae1623ef23"
38
+ "gitHead": "df2103bb05ee43fdb6b530e05ce608c574fdd5d6"
39
39
  }