@ocap/tx-pipeline 1.18.22 → 1.18.24

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.
@@ -1,4 +1,4 @@
1
- const Mcrypto = require('@ocap/mcrypto');
1
+ const { toTxHash } = require('@ocap/mcrypto');
2
2
  const { getMessageType } = require('@ocap/message');
3
3
  const { fromBase64, toUint8Array } = require('@ocap/util');
4
4
  const { CustomError: Error } = require('@ocap/util/lib/error');
@@ -6,8 +6,6 @@ const { CustomError: Error } = require('@ocap/util/lib/error');
6
6
  // eslint-disable-next-line global-require
7
7
  const debug = require('debug')(`${require('../../package.json').name}:pipe:decode-tx`);
8
8
 
9
- const sha256 = Mcrypto.Hasher.SHA2.hash256;
10
- const toTxHash = (buffer) => sha256(buffer, 1).replace(/^0x/, '').toUpperCase();
11
9
  const Transaction = getMessageType('Transaction').fn;
12
10
 
13
11
  module.exports = function DecodeTx(context, next) {
package/lib/runner.js CHANGED
@@ -21,6 +21,13 @@ class PipelineRunner extends EventEmitter {
21
21
  }
22
22
 
23
23
  run(context, done) {
24
+ const attachErrorProps = (err, opts) => {
25
+ if (opts && opts.persistError) {
26
+ err.props = err.props || {};
27
+ err.props.persist = true;
28
+ }
29
+ };
30
+
24
31
  const call = async (fn, err, next, opts) => {
25
32
  const paramCount = fn.length;
26
33
  const hasError = Boolean(err);
@@ -31,12 +38,19 @@ class PipelineRunner extends EventEmitter {
31
38
  return;
32
39
  }
33
40
  if (!hasError && paramCount < 3) {
34
- await fn(context, next);
41
+ await fn(context, (e) => {
42
+ if (e) {
43
+ attachErrorProps(e, opts);
44
+ }
45
+ next(e);
46
+ });
35
47
  return;
36
48
  }
37
49
 
38
50
  // Here we are skipping remaining
39
51
  } catch (e) {
52
+ attachErrorProps(e, opts);
53
+
40
54
  if (process.env.NODE_ENV !== 'test') {
41
55
  console.error('call pipe failed', fn.name || '<anonymous>', e);
42
56
  }
@@ -44,11 +58,6 @@ class PipelineRunner extends EventEmitter {
44
58
  // replace the error
45
59
  // eslint-disable-next-line no-param-reassign
46
60
  err = e;
47
-
48
- if (opts && opts.persistError) {
49
- err.props = err.props || {};
50
- err.props.persist = true;
51
- }
52
61
  }
53
62
 
54
63
  // continue
@@ -62,7 +71,7 @@ class PipelineRunner extends EventEmitter {
62
71
 
63
72
  // all done
64
73
  if (!pipe) {
65
- defer(() => done(err, context), err);
74
+ defer(() => done(err, context));
66
75
  return;
67
76
  }
68
77
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.18.22",
6
+ "version": "1.18.24",
7
7
  "description": "Pipeline runner and common pipelines to process transactions",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -29,16 +29,16 @@
29
29
  "elliptic": "6.5.3"
30
30
  },
31
31
  "dependencies": {
32
- "@arcblock/did": "1.18.22",
33
- "@arcblock/did-util": "1.18.22",
34
- "@ocap/mcrypto": "1.18.22",
35
- "@ocap/message": "1.18.22",
36
- "@ocap/state": "1.18.22",
37
- "@ocap/util": "1.18.22",
38
- "@ocap/wallet": "1.18.22",
32
+ "@arcblock/did": "1.18.24",
33
+ "@arcblock/did-util": "1.18.24",
34
+ "@ocap/mcrypto": "1.18.24",
35
+ "@ocap/message": "1.18.24",
36
+ "@ocap/state": "1.18.24",
37
+ "@ocap/util": "1.18.24",
38
+ "@ocap/wallet": "1.18.24",
39
39
  "debug": "^4.3.4",
40
40
  "empty-value": "^1.0.1",
41
41
  "lodash": "^4.17.21"
42
42
  },
43
- "gitHead": "7f833da5b1ed75fd2f2427925d0cbb84af33b36b"
43
+ "gitHead": "2b3c7ab2de31bd3ef55ae32cec5c007d5e13d306"
44
44
  }