@ocap/tx-pipeline 1.30.9 → 1.30.11
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/esm/pipes/decode-itx.mjs +1 -0
- package/esm/pipes/take-state-snapshot.mjs +1 -0
- package/esm/pipes/verify-multisig-v2.mjs +2 -1
- package/esm/pipes/verify-multisig.mjs +2 -1
- package/esm/pipes/verify-signature.mjs +1 -0
- package/esm/pipes/verify-state-diff.mjs +2 -0
- package/lib/pipes/decode-itx.cjs +1 -0
- package/lib/pipes/take-state-snapshot.cjs +1 -0
- package/lib/pipes/verify-multisig-v2.cjs +1 -0
- package/lib/pipes/verify-multisig.cjs +1 -0
- package/lib/pipes/verify-signature.cjs +1 -0
- package/lib/pipes/verify-state-diff.cjs +2 -0
- package/package.json +10 -10
package/esm/pipes/decode-itx.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { CustomError } from "@ocap/util/lib/error";
|
|
|
4
4
|
import get from "lodash/get.js";
|
|
5
5
|
import { decodeAny } from "@ocap/message";
|
|
6
6
|
import { getListField, setListField } from "@ocap/util/lib/get-list-field";
|
|
7
|
-
import { toTypeInfo } from "@arcblock/did";
|
|
7
|
+
import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
|
|
8
8
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
9
9
|
import { fromPublicKey } from "@ocap/wallet";
|
|
10
10
|
import omit from "lodash/omit.js";
|
|
@@ -26,6 +26,7 @@ function CreateVerifyMultiSigV2Pipe({ signersKey }) {
|
|
|
26
26
|
for (let i = 0; i < signatures.length; i++) {
|
|
27
27
|
const { signer, pk, delegator, signature, extra = "" } = signatures[i];
|
|
28
28
|
const address = delegator || signer;
|
|
29
|
+
if (isFromPublicKey(address, pk) === false) return next(new CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
|
|
29
30
|
const wallet = fromPublicKey(pk, toTypeInfo(address));
|
|
30
31
|
const txBytes = encodeTxByEncoding(context.txEncoding, tx);
|
|
31
32
|
try {
|
|
@@ -3,7 +3,7 @@ import { unwrapOpaqueAnyData } from "../helpers/unwrap-opaque-any.mjs";
|
|
|
3
3
|
import { CustomError } from "@ocap/util/lib/error";
|
|
4
4
|
import { decodeAny } from "@ocap/message";
|
|
5
5
|
import { deleteListField, getListField, setListField } from "@ocap/util/lib/get-list-field";
|
|
6
|
-
import { toTypeInfo } from "@arcblock/did";
|
|
6
|
+
import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
|
|
7
7
|
import cloneDeep from "lodash/cloneDeep.js";
|
|
8
8
|
import { fromPublicKey } from "@ocap/wallet";
|
|
9
9
|
|
|
@@ -18,6 +18,7 @@ function CreateVerifyMultiSigPipe(numSigs = 0) {
|
|
|
18
18
|
while (signatures.length > 0) {
|
|
19
19
|
const { signer, pk, delegator, signature, data } = signatures.shift();
|
|
20
20
|
const address = delegator || signer;
|
|
21
|
+
if (isFromPublicKey(address, pk) === false) return next(new CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
|
|
21
22
|
const wallet = fromPublicKey(pk, toTypeInfo(address));
|
|
22
23
|
setListField(tx, "signatures", [{
|
|
23
24
|
signer,
|
|
@@ -77,6 +77,7 @@ function fixMigratedReceipts(receipts, statesMap) {
|
|
|
77
77
|
function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
|
|
78
78
|
return function VerifyStateDiff(context, next) {
|
|
79
79
|
const { logger, [snapshotKey]: snapshotStates } = context;
|
|
80
|
+
context.timer?.mark?.("protocolWrite");
|
|
80
81
|
if (!snapshotStates) return next(new CustomError("FORBIDDEN", `context.${snapshotKey} is missing, please call VerifyStateDiff after TakeStateSnapshot`));
|
|
81
82
|
const txState = create(context, "OK", false);
|
|
82
83
|
const contextStates = groupStatesByAddress(context);
|
|
@@ -125,6 +126,7 @@ function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
}
|
|
129
|
+
context.timer?.mark?.("protocolDiff");
|
|
128
130
|
next();
|
|
129
131
|
};
|
|
130
132
|
}
|
package/lib/pipes/decode-itx.cjs
CHANGED
|
@@ -31,6 +31,7 @@ function CreateVerifyMultiSigV2Pipe({ signersKey }) {
|
|
|
31
31
|
for (let i = 0; i < signatures.length; i++) {
|
|
32
32
|
const { signer, pk, delegator, signature, extra = "" } = signatures[i];
|
|
33
33
|
const address = delegator || signer;
|
|
34
|
+
if ((0, _arcblock_did.isFromPublicKey)(address, pk) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
|
|
34
35
|
const wallet = (0, _ocap_wallet.fromPublicKey)(pk, (0, _arcblock_did.toTypeInfo)(address));
|
|
35
36
|
const txBytes = require_helpers_encode_tx_by_context.encodeTxByEncoding(context.txEncoding, tx);
|
|
36
37
|
try {
|
|
@@ -21,6 +21,7 @@ function CreateVerifyMultiSigPipe(numSigs = 0) {
|
|
|
21
21
|
while (signatures.length > 0) {
|
|
22
22
|
const { signer, pk, delegator, signature, data } = signatures.shift();
|
|
23
23
|
const address = delegator || signer;
|
|
24
|
+
if ((0, _arcblock_did.isFromPublicKey)(address, pk) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
|
|
24
25
|
const wallet = (0, _ocap_wallet.fromPublicKey)(pk, (0, _arcblock_did.toTypeInfo)(address));
|
|
25
26
|
(0, _ocap_util_lib_get_list_field.setListField)(tx, "signatures", [{
|
|
26
27
|
signer,
|
|
@@ -32,6 +32,7 @@ async function VerifySignature(context, next) {
|
|
|
32
32
|
console.error("tx.signature verify failed", err);
|
|
33
33
|
return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "tx.signature verify failed"));
|
|
34
34
|
}
|
|
35
|
+
context.timer?.mark?.("verify");
|
|
35
36
|
next();
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -83,6 +83,7 @@ function fixMigratedReceipts(receipts, statesMap) {
|
|
|
83
83
|
function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
|
|
84
84
|
return function VerifyStateDiff(context, next) {
|
|
85
85
|
const { logger, [snapshotKey]: snapshotStates } = context;
|
|
86
|
+
context.timer?.mark?.("protocolWrite");
|
|
86
87
|
if (!snapshotStates) return next(new _ocap_util_lib_error.CustomError("FORBIDDEN", `context.${snapshotKey} is missing, please call VerifyStateDiff after TakeStateSnapshot`));
|
|
87
88
|
const txState = (0, _ocap_state_lib_states_tx.create)(context, "OK", false);
|
|
88
89
|
const contextStates = groupStatesByAddress(context);
|
|
@@ -131,6 +132,7 @@ function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
}
|
|
135
|
+
context.timer?.mark?.("protocolDiff");
|
|
134
136
|
next();
|
|
135
137
|
};
|
|
136
138
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.30.
|
|
6
|
+
"version": "1.30.11",
|
|
7
7
|
"description": "Pipeline runner and common pipelines to process transactions",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"elliptic": "6.5.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@arcblock/did": "1.30.
|
|
53
|
-
"@arcblock/did-util": "1.30.
|
|
54
|
-
"@ocap/client": "1.30.
|
|
55
|
-
"@ocap/mcrypto": "1.30.
|
|
56
|
-
"@ocap/message": "1.30.
|
|
57
|
-
"@ocap/state": "1.30.
|
|
58
|
-
"@ocap/types": "1.30.
|
|
59
|
-
"@ocap/util": "1.30.
|
|
60
|
-
"@ocap/wallet": "1.30.
|
|
52
|
+
"@arcblock/did": "1.30.11",
|
|
53
|
+
"@arcblock/did-util": "1.30.11",
|
|
54
|
+
"@ocap/client": "1.30.11",
|
|
55
|
+
"@ocap/mcrypto": "1.30.11",
|
|
56
|
+
"@ocap/message": "1.30.11",
|
|
57
|
+
"@ocap/state": "1.30.11",
|
|
58
|
+
"@ocap/types": "1.30.11",
|
|
59
|
+
"@ocap/util": "1.30.11",
|
|
60
|
+
"@ocap/wallet": "1.30.11",
|
|
61
61
|
"debug": "^4.4.3",
|
|
62
62
|
"lodash": "^4.17.23"
|
|
63
63
|
}
|