@ocap/resolver 1.18.143 → 1.18.145

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/token-flow.js +18 -5
  2. package/package.json +12 -12
package/lib/token-flow.js CHANGED
@@ -121,6 +121,10 @@ const getTransferFlow = (tx, tokenAddress) => {
121
121
  return txTransfers;
122
122
  };
123
123
 
124
+ const getVaultAccounts = (config) => {
125
+ return Object.values(config.vaults).flat();
126
+ };
127
+
124
128
  const verifyAccountRisk = async ({ accountAddress, tokenAddress }, resolver, ctx = {}) => {
125
129
  // validate request params
126
130
  const { error } = paramsSchema.validate({ accountAddress, tokenAddress, resolver });
@@ -132,6 +136,7 @@ const verifyAccountRisk = async ({ accountAddress, tokenAddress }, resolver, ctx
132
136
  const checkedTx = new Map();
133
137
  const accountQueue = [accountAddress];
134
138
  const maxAccountSize = 400;
139
+ const vaultAccounts = getVaultAccounts(resolver.config);
135
140
 
136
141
  while (accountQueue.length) {
137
142
  // limit
@@ -151,7 +156,7 @@ const verifyAccountRisk = async ({ accountAddress, tokenAddress }, resolver, ctx
151
156
  if (checkedAccounts.has(address)) continue;
152
157
 
153
158
  const transactions = await resolver._getAllResults('transactions', (paging) =>
154
- resolver.listTransactions({ paging, accountFilter: { accounts: address } }, ctx)
159
+ resolver.listTransactions({ paging, accountFilter: { accounts: [address] } }, ctx)
155
160
  );
156
161
  const accountState = await resolver.getAccountState({ address }, ctx);
157
162
  if (!accountState) {
@@ -191,6 +196,8 @@ const verifyAccountRisk = async ({ accountAddress, tokenAddress }, resolver, ctx
191
196
  const accountsToQueue = transferOutList
192
197
  .filter((item) => {
193
198
  if (accountQueue.includes(item.address)) return false;
199
+ // Skip vault accounts
200
+ if (vaultAccounts.includes(item.address)) return false;
194
201
  // skip gas、fee
195
202
  if (['gas', 'fee'].includes(item.action)) return false;
196
203
  // Skip not token holders
@@ -252,8 +259,9 @@ const listTokenFlows = async (
252
259
 
253
260
  const tokenState = await resolver.tokenCache.get(tokenAddress);
254
261
  const minAmount = fromTokenToUnit(1, tokenState?.decimal || 18);
255
- const maxAccountSize = Math.min(400, paging.size || 400);
256
- const maxDepth = Math.min(6, depth);
262
+ const maxAccountSize = Math.min(200, paging.size || 200);
263
+ const maxDepth = Math.min(5, depth);
264
+ const vaultAccounts = getVaultAccounts(resolver.config);
257
265
 
258
266
  const tokenFlows = [];
259
267
  const checkedAccounts = new Map();
@@ -271,10 +279,12 @@ const listTokenFlows = async (
271
279
  if (checkedAccounts.has(address)) continue;
272
280
  // Skip not token holders
273
281
  if (schemas.tokenHolder.validate(address).error) continue;
282
+ // Skip vault accounts
283
+ if (vaultAccounts.includes(address)) continue;
274
284
 
275
285
  const transactions = await resolver._getAllResults('transactions', (page) =>
276
286
  resolver.listTransactions(
277
- { paging: page, accountFilter: { accounts: address }, tokenFilter: { tokens: tokenAddress } },
287
+ { paging: page, accountFilter: { accounts: [address] }, tokenFilter: { tokens: [tokenAddress] } },
278
288
  ctx
279
289
  )
280
290
  );
@@ -288,6 +298,8 @@ const listTokenFlows = async (
288
298
  const txTransfers = checkedTx.get(tx.hash).filter((item) => {
289
299
  if (direction === 'OUT' && item.from !== address) return false;
290
300
  if (direction === 'IN' && item.to !== address) return false;
301
+ // Skip too small amount
302
+ if (item.value.lt(minAmount)) return false;
291
303
  return true;
292
304
  });
293
305
 
@@ -297,8 +309,9 @@ const listTokenFlows = async (
297
309
  // push to end of queue
298
310
  accountsToQueue = accountsToQueue.concat(
299
311
  txTransfers
300
- .filter((item) => item.value.gte(minAmount))
301
312
  .map((item) => (direction === 'IN' ? item.from : item.to))
313
+ // Skip vault accounts
314
+ .filter((item) => !vaultAccounts.includes(item))
302
315
  );
303
316
  }
304
317
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.143",
6
+ "version": "1.18.145",
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.143",
26
- "@arcblock/did-util": "1.18.143",
27
- "@arcblock/validator": "1.18.143",
28
- "@ocap/config": "1.18.143",
29
- "@ocap/indexdb": "1.18.143",
30
- "@ocap/mcrypto": "1.18.143",
31
- "@ocap/message": "1.18.143",
32
- "@ocap/state": "1.18.143",
33
- "@ocap/tx-protocols": "1.18.143",
34
- "@ocap/util": "1.18.143",
25
+ "@arcblock/did": "1.18.145",
26
+ "@arcblock/did-util": "1.18.145",
27
+ "@arcblock/validator": "1.18.145",
28
+ "@ocap/config": "1.18.145",
29
+ "@ocap/indexdb": "1.18.145",
30
+ "@ocap/mcrypto": "1.18.145",
31
+ "@ocap/message": "1.18.145",
32
+ "@ocap/state": "1.18.145",
33
+ "@ocap/tx-protocols": "1.18.145",
34
+ "@ocap/util": "1.18.145",
35
35
  "debug": "^4.3.6",
36
36
  "lodash": "^4.17.21"
37
37
  },
38
- "gitHead": "d60db9ab9a62de1d99cf1fba59866592860bed22"
38
+ "gitHead": "52b533ef56196496dc068fbf86ea07afbb87366e"
39
39
  }