@ocap/tx-pipeline 1.28.6 → 1.28.7

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/README.md CHANGED
@@ -5,7 +5,7 @@ Defines the interface of OCAP query resolver.
5
5
  ## Usage
6
6
 
7
7
  ```shell
8
- pnpm install @ocap/tx-pipeline
8
+ bun install @ocap/tx-pipeline
9
9
  ```
10
10
 
11
11
  Then:
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { isSameDid } = require('@ocap/util');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -15,7 +15,7 @@ module.exports = function DecodeItx(context, next) {
15
15
  txType: context.txType,
16
16
  request: context.extra?.request,
17
17
  });
18
- } catch (err) {
18
+ } catch (_err) {
19
19
  return next(new Error('INVALID_TX', 'Failed to decode itx'));
20
20
  }
21
21
 
@@ -3,7 +3,6 @@ const { getMessageType } = require('@ocap/message');
3
3
  const { fromBase64, toUint8Array } = require('@ocap/util');
4
4
  const { CustomError: Error } = require('@ocap/util/lib/error');
5
5
 
6
- // eslint-disable-next-line global-require
7
6
  const debug = require('debug')(`${require('../../package.json').name}:pipe:decode-tx`);
8
7
 
9
8
  const Transaction = getMessageType('Transaction').fn;
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const set = require('lodash/set');
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const set = require('lodash/set');
4
3
  const isEmpty = require('empty-value');
@@ -8,7 +7,6 @@ const { types } = require('@ocap/mcrypto');
8
7
  const { tables } = require('@ocap/state');
9
8
  const { toTypeInfo, toTypeInfoStr } = require('@arcblock/did');
10
9
 
11
- // eslint-disable-next-line global-require
12
10
  const debug = require('debug')(`${require('../../package.json').name}:pipe:extract-state`);
13
11
 
14
12
  const getRelatedAddrList = (x) => (x.hash ? [x.hash] : getRelatedAddresses(x));
@@ -2,7 +2,6 @@ const get = require('lodash/get');
2
2
  const set = require('lodash/set');
3
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
4
 
5
- // eslint-disable-next-line global-require
6
5
  const debug = require('debug')(`${require('../../package.json').name}:pipe:update-owner`);
7
6
 
8
7
  module.exports = function CreateUpdateOwnerPipe({ assets, owner }) {
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { getListField } = require('@ocap/util/lib/get-list-field');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-await-in-loop */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
  const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
@@ -1,6 +1,3 @@
1
- /* eslint-disable no-continue */
2
- /* eslint-disable no-await-in-loop */
3
- /* eslint-disable no-restricted-syntax */
4
1
  const get = require('lodash/get');
5
2
  const set = require('lodash/set');
6
3
  const isEmpty = require('empty-value');
@@ -10,7 +7,6 @@ const { toBN } = require('@ocap/util');
10
7
  const { toDelegateAddress } = require('@arcblock/did-util');
11
8
  const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
12
9
 
13
- // eslint-disable-next-line global-require
14
10
  // const debug = require('debug')(`${require('../../package.json').name}:pipe:verify-delegation`);
15
11
 
16
12
  const ZERO = toBN(0);
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const omit = require('lodash/omit');
4
3
  const cloneDeep = require('lodash/cloneDeep');
@@ -37,7 +36,7 @@ module.exports = function CreateVerifyMultiSigV2Pipe({ signersKey }) {
37
36
  if (decoded && ['json', 'vc'].includes(decoded.type)) {
38
37
  try {
39
38
  decoded.value = JSON.parse(Buffer.from(decoded.value, 'base64'));
40
- } catch (e) {
39
+ } catch (_e) {
41
40
  // Do nothing
42
41
  }
43
42
  }
@@ -59,7 +58,6 @@ module.exports = function CreateVerifyMultiSigV2Pipe({ signersKey }) {
59
58
 
60
59
  const message = createMessage('Transaction', tx);
61
60
  try {
62
- // eslint-disable-next-line no-await-in-loop
63
61
  if ((await wallet.verify(message.serializeBinary(), signature, true, extra)) === false) {
64
62
  return next(new Error('INVALID_SIGNATURE', `Signature for ${address} is not valid`));
65
63
  }
@@ -33,14 +33,13 @@ module.exports = function CreateVerifyMultiSigPipe(numSigs = 0) {
33
33
  if (decoded && ['json', 'vc'].includes(decoded.type)) {
34
34
  try {
35
35
  decoded.value = JSON.parse(Buffer.from(decoded.value, 'base64'));
36
- } catch (e) {
36
+ } catch (_e) {
37
37
  // Do nothing
38
38
  }
39
39
  }
40
40
 
41
41
  tx.signatures = [{ signer, pk, delegator, data: decoded }].concat(signatures);
42
42
  const message = createMessage('Transaction', tx);
43
- // eslint-disable-next-line no-await-in-loop
44
43
  if ((await wallet.verify(message.serializeBinary(), signature)) === false) {
45
44
  return next(new Error('INVALID_SIGNATURE', `Multi signature for ${address} is not valid`));
46
45
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
 
@@ -1,9 +1,7 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
  const { getListField } = require('@ocap/util/lib/get-list-field');
5
4
 
6
- // eslint-disable-next-line global-require
7
5
  const debug = require('debug')(`${require('../../package.json').name}:pipe:verify-signer`);
8
6
 
9
7
  module.exports = function CreateVerifySignerPipe({ signer }) {
@@ -1,5 +1,3 @@
1
- /* eslint-disable no-await-in-loop */
2
- /* eslint-disable consistent-return */
3
1
  const isEqual = require('lodash/isEqual');
4
2
  const mergeWith = require('lodash/mergeWith');
5
3
  const clone = require('lodash/clone');
@@ -21,7 +19,7 @@ function groupStatesByAddress(context) {
21
19
  const statesMap = {};
22
20
 
23
21
  for (const stateOrStates of Object.values(context)) {
24
- const states = [].concat(stateOrStates).filter((x) => x && x.address && x.tokens && x.context);
22
+ const states = [].concat(stateOrStates).filter((x) => x?.address && x.tokens && x.context);
25
23
 
26
24
  for (const state of states) {
27
25
  const curStates = statesMap[state.address];
@@ -33,7 +31,6 @@ function groupStatesByAddress(context) {
33
31
  // Use the state that recently retrieved from database
34
32
  if ((state._retrievedAt || 0) > (curStates._retrievedAt || 0)) {
35
33
  statesMap[state.address] = state;
36
- continue;
37
34
  }
38
35
  }
39
36
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const isEmpty = require('empty-value');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const isEmpty = require('empty-value');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const isEmpty = require('empty-value');
4
3
  const { BN } = require('@ocap/util');
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const isEmpty = require('empty-value');
4
3
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -22,8 +21,7 @@ module.exports = function VerifyTx(context, next) {
22
21
  return next(new Error('INVALID_CHAIN_ID', `Invalid chain id: expected ${expected}, got ${chainId}`));
23
22
  }
24
23
  const n = Number(nonce);
25
- // eslint-disable-next-line no-restricted-globals
26
- if (isNaN(n) || n < 0) {
24
+ if (Number.isNaN(n) || n < 0) {
27
25
  return next(new Error('INVALID_NONCE', 'tx.nonce should be a positive integer'));
28
26
  }
29
27
 
@@ -1,9 +1,7 @@
1
- /* eslint-disable no-restricted-syntax */
2
1
  const get = require('lodash/get');
3
2
  const { CustomError: Error } = require('@ocap/util/lib/error');
4
3
  const { getRelatedAddresses } = require('@ocap/util/lib/get-related-addr');
5
4
 
6
- // eslint-disable-next-line global-require
7
5
  const debug = require('debug')(`${require('../../package.json').name}:pipe:verify-owner`);
8
6
 
9
7
  /**
package/lib/runner.js CHANGED
@@ -1,9 +1,8 @@
1
- const EventEmitter = require('events');
1
+ const EventEmitter = require('node:events');
2
2
 
3
3
  /* istanbul ignore next */
4
- function nextTick(fn) {
5
- // eslint-disable-next-line
6
- process.nextTick(fn.bind.apply(fn, arguments));
4
+ function nextTick(fn, ...args) {
5
+ process.nextTick(fn.bind(fn, ...args));
7
6
  }
8
7
 
9
8
  /* istanbul ignore next */
@@ -22,7 +21,7 @@ class PipelineRunner extends EventEmitter {
22
21
 
23
22
  run(context, done) {
24
23
  const attachErrorProps = (err, opts) => {
25
- if (opts && opts.persistError) {
24
+ if (opts?.persistError) {
26
25
  err.props = err.props || {};
27
26
  err.props.persist = true;
28
27
  }
@@ -40,7 +39,7 @@ class PipelineRunner extends EventEmitter {
40
39
 
41
40
  if (!hasError && paramCount < 3) {
42
41
  // Check if this pipe should be skipped
43
- if (opts && opts.shouldSkip) {
42
+ if (opts?.shouldSkip) {
44
43
  const skip = typeof opts.shouldSkip === 'function' ? opts.shouldSkip(context) : opts.shouldSkip;
45
44
  if (skip) {
46
45
  next();
@@ -66,7 +65,6 @@ class PipelineRunner extends EventEmitter {
66
65
  }
67
66
 
68
67
  // replace the error
69
- // eslint-disable-next-line no-param-reassign
70
68
  err = e;
71
69
  }
72
70
 
package/package.json CHANGED
@@ -3,44 +3,41 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.28.6",
6
+ "version": "1.28.7",
7
7
  "description": "Pipeline runner and common pipelines to process transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
10
10
  "lib"
11
11
  ],
12
+ "scripts": {
13
+ "lint": "biome check",
14
+ "lint:fix": "biome check --write",
15
+ "test": "bun test",
16
+ "test:ci": "bun test --coverage",
17
+ "coverage": "bun test --coverage"
18
+ },
12
19
  "keywords": [],
13
20
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
14
21
  "license": "MIT",
15
22
  "devDependencies": {
16
- "jest": "^29.7.0",
17
- "start-server-and-test": "^1.14.0",
18
- "@ocap/e2e-test": "1.28.6",
19
- "@ocap/statedb-memory": "1.28.6"
23
+ "@ocap/e2e-test": "1.28.7",
24
+ "@ocap/statedb-memory": "1.28.7"
20
25
  },
21
26
  "resolutions": {
22
27
  "bn.js": "5.2.2",
23
28
  "elliptic": "6.5.3"
24
29
  },
25
30
  "dependencies": {
31
+ "@arcblock/did": "1.28.7",
32
+ "@arcblock/did-util": "1.28.7",
33
+ "@ocap/client": "1.28.7",
34
+ "@ocap/mcrypto": "1.28.7",
35
+ "@ocap/message": "1.28.7",
36
+ "@ocap/state": "1.28.7",
37
+ "@ocap/util": "1.28.7",
38
+ "@ocap/wallet": "1.28.7",
26
39
  "debug": "^4.3.6",
27
40
  "empty-value": "^1.0.1",
28
- "lodash": "^4.17.21",
29
- "@arcblock/did": "1.28.6",
30
- "@arcblock/did-util": "1.28.6",
31
- "@ocap/client": "1.28.6",
32
- "@ocap/mcrypto": "1.28.6",
33
- "@ocap/message": "1.28.6",
34
- "@ocap/state": "1.28.6",
35
- "@ocap/util": "1.28.6",
36
- "@ocap/wallet": "1.28.6"
37
- },
38
- "scripts": {
39
- "lint": "eslint tests lib",
40
- "lint:fix": "eslint --fix tests lib",
41
- "start": "node tools/start-chain.js",
42
- "test": "jest --forceExit --detectOpenHandles",
43
- "test:ci": "jest --forceExit --detectOpenHandles --coverage",
44
- "coverage": "start-server-and-test start http://127.0.0.1:4003 test:ci"
41
+ "lodash": "^4.17.21"
45
42
  }
46
- }
43
+ }
package/LICENSE DELETED
@@ -1,13 +0,0 @@
1
- Copyright 2018-2025 ArcBlock
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.