@ocap/tx-pipeline 1.19.15 → 1.19.17

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2018-2019 ArcBlock
1
+ Copyright 2018-2025 ArcBlock
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -3,15 +3,16 @@ const { groupStatesByAddress } = require('./verify-state-diff');
3
3
 
4
4
  module.exports = function CreateTakeStateSnapshotPipe({ key = 'stateSnapshot' } = {}) {
5
5
  return async function TakeStateSnapshot(context, next) {
6
- const { statedb, config } = context;
6
+ const { statedb } = context;
7
7
 
8
8
  // feeVaultState and gasVaultState is usually add to context at the end, so we need to query it here
9
- if (!context.feeVaultState) {
10
- context.feeVaultState = await statedb.account.get(config.vaults.txFee, context);
11
- }
12
- if (context.gasVault && !context.gasVaultState) {
13
- context.gasVaultState = await statedb.account.get(context.gasVault, context);
14
- }
9
+ const [feeVaultState, gasVaultState] = await Promise.all([
10
+ context.feeVault && !context.feeVaultState ? statedb.account.get(context.feeVault, context) : null,
11
+ context.gasVault && !context.gasVaultState ? statedb.account.get(context.gasVault, context) : null,
12
+ ]);
13
+
14
+ if (feeVaultState) context.feeVaultState = feeVaultState;
15
+ if (gasVaultState) context.gasVaultState = gasVaultState;
15
16
 
16
17
  const statesMap = groupStatesByAddress(context);
17
18
 
@@ -21,10 +22,10 @@ module.exports = function CreateTakeStateSnapshotPipe({ key = 'stateSnapshot' }
21
22
  const states = await Promise.all(
22
23
  (mintHook?.compiled || []).map((x) => {
23
24
  const address = x.args.to;
24
- return statesMap[address] || statedb.account.get(address, context);
25
+ return statedb.account.get(address, context);
25
26
  })
26
27
  );
27
- states.forEach((x) => {
28
+ states.filter(Boolean).forEach((x) => {
28
29
  statesMap[x.address] = x;
29
30
  });
30
31
  }
@@ -48,8 +48,11 @@ function findStates(address, statesMap) {
48
48
  // Try to find state from migrated addresses
49
49
  const matchedAddress = Object.keys(statesMap).find((x) => {
50
50
  const state = statesMap[x];
51
- const relatedAddresses = getRelatedAddresses(state);
52
- return !state.migratedTo?.length && relatedAddresses.some((y) => isSameDid(y, address));
51
+ if (state) {
52
+ const relatedAddresses = getRelatedAddresses(state);
53
+ return !state.migratedTo?.length && relatedAddresses.some((y) => isSameDid(y, address));
54
+ }
55
+ return false;
53
56
  });
54
57
  return statesMap[matchedAddress];
55
58
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.19.15",
6
+ "version": "1.19.17",
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.19.15",
33
- "@arcblock/did-util": "1.19.15",
34
- "@ocap/mcrypto": "1.19.15",
35
- "@ocap/message": "1.19.15",
36
- "@ocap/state": "1.19.15",
37
- "@ocap/util": "1.19.15",
38
- "@ocap/wallet": "1.19.15",
32
+ "@arcblock/did": "1.19.17",
33
+ "@arcblock/did-util": "1.19.17",
34
+ "@ocap/mcrypto": "1.19.17",
35
+ "@ocap/message": "1.19.17",
36
+ "@ocap/state": "1.19.17",
37
+ "@ocap/util": "1.19.17",
38
+ "@ocap/wallet": "1.19.17",
39
39
  "debug": "^4.3.6",
40
40
  "empty-value": "^1.0.1",
41
41
  "lodash": "^4.17.21"
42
42
  },
43
- "gitHead": "ab6cd19ab8633c815ab0235b7ab5d80fc071de15"
43
+ "gitHead": "d25d8b52053b0e3254a28c3b44ea5e447ce1c08a"
44
44
  }