@ocap/tx-pipeline 1.30.26 → 1.31.1
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/appchain-sovereign-hub.d.mts +160 -0
- package/esm/appchain-sovereign-hub.mjs +348 -0
- package/esm/arcvault-external-adapter.d.mts +166 -0
- package/esm/arcvault-external-adapter.mjs +376 -0
- package/esm/encrypted-nft-envelope.d.mts +172 -0
- package/esm/encrypted-nft-envelope.mjs +458 -0
- package/esm/evm-simplified-bridge.d.mts +1370 -0
- package/esm/evm-simplified-bridge.mjs +3875 -0
- package/esm/give-to-mint-karma.d.mts +472 -0
- package/esm/give-to-mint-karma.mjs +1057 -0
- package/esm/helpers/replay-guard.d.mts +15 -0
- package/esm/helpers/replay-guard.mjs +23 -0
- package/esm/index.d.mts +10 -5
- package/esm/index.mjs +14 -10
- package/esm/legacy-protocol-sunset.d.mts +251 -0
- package/esm/legacy-protocol-sunset.mjs +1519 -0
- package/esm/library.d.mts +16 -0
- package/esm/library.mjs +17 -0
- package/esm/native-abt-exchange.d.mts +2055 -0
- package/esm/native-abt-exchange.mjs +7250 -0
- package/esm/ofac-screening.d.mts +17 -0
- package/esm/ofac-screening.mjs +39 -0
- package/esm/pipes/anti-land-attack.mjs +1 -1
- package/esm/pipes/decode-itx.mjs +46 -4
- package/esm/pipes/decode-tx.d.mts +2 -3
- package/esm/pipes/decode-tx.mjs +56 -115
- package/esm/pipes/extract-signer.mjs +2 -2
- package/esm/pipes/extract-state.mjs +14 -3
- package/esm/pipes/post-execution-invariant-gate.d.mts +61 -0
- package/esm/pipes/post-execution-invariant-gate.mjs +789 -0
- package/esm/pipes/pre-flight-waf.d.mts +73 -0
- package/esm/pipes/pre-flight-waf.mjs +756 -0
- package/esm/pipes/take-state-snapshot.mjs +3 -2
- package/esm/pipes/update-owner.mjs +39 -4
- package/esm/pipes/verify-account-migration.mjs +14 -4
- package/esm/pipes/verify-blocked.mjs +1 -1
- package/esm/pipes/verify-delegation.d.mts +22 -3
- package/esm/pipes/verify-delegation.mjs +259 -36
- package/esm/pipes/verify-list-size.mjs +1 -1
- package/esm/pipes/verify-multisig-v2.mjs +15 -7
- package/esm/pipes/verify-multisig.mjs +15 -7
- package/esm/pipes/verify-sender.mjs +1 -1
- package/esm/pipes/verify-signature.mjs +35 -6
- package/esm/pipes/verify-signer.mjs +2 -2
- package/esm/pipes/verify-state-diff.mjs +3 -3
- package/esm/pipes/verify-token-access.mjs +1 -1
- package/esm/pipes/verify-token-balance.mjs +13 -5
- package/esm/pipes/verify-transferrable.d.mts +8 -1
- package/esm/pipes/verify-transferrable.mjs +3 -3
- package/esm/pipes/verify-tx-input.mjs +2 -2
- package/esm/pipes/verify-tx-size.mjs +46 -2
- package/esm/pipes/verify-tx.mjs +5 -7
- package/esm/pipes/verify-updater.mjs +1 -1
- package/esm/social-economy-factories.d.mts +346 -0
- package/esm/social-economy-factories.mjs +845 -0
- package/esm/super-suites-foundation.d.mts +513 -0
- package/esm/super-suites-foundation.mjs +1241 -0
- package/esm/transaction-block.d.mts +471 -0
- package/esm/transaction-block.mjs +1906 -0
- package/esm/uniswap-erc7683-solver.d.mts +201 -0
- package/esm/uniswap-erc7683-solver.mjs +321 -0
- package/esm/uniswap-lp-copilot.d.mts +113 -0
- package/esm/uniswap-lp-copilot.mjs +320 -0
- package/esm/uniswap-router.d.mts +335 -0
- package/esm/uniswap-router.mjs +578 -0
- package/esm/uniswap-token-factory-graduation.d.mts +187 -0
- package/esm/uniswap-token-factory-graduation.mjs +426 -0
- package/esm/uniswap-v4-hook.d.mts +173 -0
- package/esm/uniswap-v4-hook.mjs +517 -0
- package/lib/appchain-sovereign-hub.cjs +352 -0
- package/lib/appchain-sovereign-hub.d.cts +160 -0
- package/lib/arcvault-external-adapter.cjs +383 -0
- package/lib/arcvault-external-adapter.d.cts +166 -0
- package/lib/encrypted-nft-envelope.cjs +477 -0
- package/lib/encrypted-nft-envelope.d.cts +172 -0
- package/lib/evm-simplified-bridge.cjs +3943 -0
- package/lib/evm-simplified-bridge.d.cts +1370 -0
- package/lib/give-to-mint-karma.cjs +1084 -0
- package/lib/give-to-mint-karma.d.cts +472 -0
- package/lib/helpers/replay-guard.cjs +27 -0
- package/lib/helpers/replay-guard.d.cts +15 -0
- package/lib/index.cjs +49 -16
- package/lib/index.d.cts +10 -5
- package/lib/legacy-protocol-sunset.cjs +1543 -0
- package/lib/legacy-protocol-sunset.d.cts +251 -0
- package/lib/library.cjs +303 -0
- package/lib/library.d.cts +16 -0
- package/lib/native-abt-exchange.cjs +7322 -0
- package/lib/native-abt-exchange.d.cts +2055 -0
- package/lib/ofac-screening.cjs +42 -0
- package/lib/ofac-screening.d.cts +17 -0
- package/lib/pipes/anti-land-attack.cjs +2 -2
- package/lib/pipes/decode-itx.cjs +46 -4
- package/lib/pipes/decode-itx.d.cts +1 -1
- package/lib/pipes/decode-tx.cjs +55 -116
- package/lib/pipes/decode-tx.d.cts +3 -4
- package/lib/pipes/extract-signer.cjs +2 -2
- package/lib/pipes/extract-state.cjs +14 -3
- package/lib/pipes/post-execution-invariant-gate.cjs +800 -0
- package/lib/pipes/post-execution-invariant-gate.d.cts +61 -0
- package/lib/pipes/pre-flight-waf.cjs +772 -0
- package/lib/pipes/pre-flight-waf.d.cts +73 -0
- package/lib/pipes/take-state-snapshot.cjs +3 -2
- package/lib/pipes/update-owner.cjs +40 -5
- package/lib/pipes/update-owner.d.cts +1 -1
- package/lib/pipes/verify-account-migration.cjs +14 -4
- package/lib/pipes/verify-blocked.cjs +1 -1
- package/lib/pipes/verify-delegation.cjs +259 -36
- package/lib/pipes/verify-delegation.d.cts +22 -3
- package/lib/pipes/verify-list-size.cjs +1 -1
- package/lib/pipes/verify-multisig-v2.cjs +15 -7
- package/lib/pipes/verify-multisig.cjs +15 -7
- package/lib/pipes/verify-sender.cjs +1 -1
- package/lib/pipes/verify-service-fee.d.cts +1 -1
- package/lib/pipes/verify-signature.cjs +35 -6
- package/lib/pipes/verify-signature.d.cts +1 -1
- package/lib/pipes/verify-signer.cjs +2 -2
- package/lib/pipes/verify-state-diff.cjs +4 -4
- package/lib/pipes/verify-token-access.cjs +2 -2
- package/lib/pipes/verify-token-balance.cjs +13 -5
- package/lib/pipes/verify-transferrable.cjs +3 -3
- package/lib/pipes/verify-transferrable.d.cts +8 -1
- package/lib/pipes/verify-tx-input.cjs +3 -3
- package/lib/pipes/verify-tx-size.cjs +46 -2
- package/lib/pipes/verify-tx-size.d.cts +1 -1
- package/lib/pipes/verify-tx.cjs +6 -8
- package/lib/pipes/verify-tx.d.cts +1 -1
- package/lib/pipes/verify-updater.cjs +1 -1
- package/lib/social-economy-factories.cjs +852 -0
- package/lib/social-economy-factories.d.cts +346 -0
- package/lib/super-suites-foundation.cjs +1257 -0
- package/lib/super-suites-foundation.d.cts +513 -0
- package/lib/transaction-block.cjs +1941 -0
- package/lib/transaction-block.d.cts +471 -0
- package/lib/uniswap-erc7683-solver.cjs +327 -0
- package/lib/uniswap-erc7683-solver.d.cts +201 -0
- package/lib/uniswap-lp-copilot.cjs +328 -0
- package/lib/uniswap-lp-copilot.d.cts +113 -0
- package/lib/uniswap-router.cjs +593 -0
- package/lib/uniswap-router.d.cts +335 -0
- package/lib/uniswap-token-factory-graduation.cjs +431 -0
- package/lib/uniswap-token-factory-graduation.d.cts +187 -0
- package/lib/uniswap-v4-hook.cjs +527 -0
- package/lib/uniswap-v4-hook.d.cts +173 -0
- package/package.json +11 -10
- package/esm/helpers/dedup-height.d.mts +0 -16
- package/esm/helpers/dedup-height.mjs +0 -61
- package/lib/helpers/dedup-height.cjs +0 -72
- package/lib/helpers/dedup-height.d.cts +0 -16
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
3
|
+
|
|
4
|
+
//#region src/ofac-screening.ts
|
|
5
|
+
/**
|
|
6
|
+
* Official Chainalysis OFAC Sanctions Screening Oracle deployed across Ethereum, Base, Arbitrum, and Optimism.
|
|
7
|
+
*/
|
|
8
|
+
const CHAINALYSIS_OFAC_ORACLE_ADDRESS = "0x40C57923924B5c5c5455c48D93317139ADDaC8fb";
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes an EVM 0x address (lowercased) or OCAP DID (stripping optional `did:abt:` prefix)
|
|
11
|
+
* so sanctions screening cannot be bypassed via mixed-case EIP-55 hex or `did:abt:` prefixing.
|
|
12
|
+
*/
|
|
13
|
+
function normalizeScreeningAddress(address) {
|
|
14
|
+
const trimmed = String(address || "").trim();
|
|
15
|
+
if (!trimmed) return "";
|
|
16
|
+
const withoutDidPrefix = trimmed.replace(/^did:abt:/i, "");
|
|
17
|
+
if (!withoutDidPrefix) return "";
|
|
18
|
+
return /^0x[0-9a-fA-F]+$/.test(withoutDidPrefix) ? withoutDidPrefix.toLowerCase() : withoutDidPrefix;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Screens a list of addresses (EVM 0x addresses or OCAP DIDs) against an OFAC sanctions blocklist.
|
|
22
|
+
* Normalizes EVM hex addresses to lowercase and strips `did:abt:` prefixes to prevent bypasses.
|
|
23
|
+
*/
|
|
24
|
+
function assertNotOfacSanctioned(addresses, ofacBlocklist) {
|
|
25
|
+
if (!ofacBlocklist) return;
|
|
26
|
+
const normalizedBlocklist = /* @__PURE__ */ new Set();
|
|
27
|
+
for (const entry of ofacBlocklist) {
|
|
28
|
+
const norm = normalizeScreeningAddress(entry);
|
|
29
|
+
if (norm) normalizedBlocklist.add(norm);
|
|
30
|
+
}
|
|
31
|
+
if (normalizedBlocklist.size === 0) return;
|
|
32
|
+
for (const addr of addresses) {
|
|
33
|
+
if (!addr) continue;
|
|
34
|
+
const normalized = normalizeScreeningAddress(addr);
|
|
35
|
+
if (normalized && normalizedBlocklist.has(normalized)) throw new _ocap_util_lib_error.CustomError("OFAC_SANCTIONED_ADDRESS", `Address ${addr} is blocked by OFAC sanctions screening (oracle: ${CHAINALYSIS_OFAC_ORACLE_ADDRESS})`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.CHAINALYSIS_OFAC_ORACLE_ADDRESS = CHAINALYSIS_OFAC_ORACLE_ADDRESS;
|
|
41
|
+
exports.assertNotOfacSanctioned = assertNotOfacSanctioned;
|
|
42
|
+
exports.normalizeScreeningAddress = normalizeScreeningAddress;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/ofac-screening.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Official Chainalysis OFAC Sanctions Screening Oracle deployed across Ethereum, Base, Arbitrum, and Optimism.
|
|
4
|
+
*/
|
|
5
|
+
declare const CHAINALYSIS_OFAC_ORACLE_ADDRESS = "0x40C57923924B5c5c5455c48D93317139ADDaC8fb";
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes an EVM 0x address (lowercased) or OCAP DID (stripping optional `did:abt:` prefix)
|
|
8
|
+
* so sanctions screening cannot be bypassed via mixed-case EIP-55 hex or `did:abt:` prefixing.
|
|
9
|
+
*/
|
|
10
|
+
declare function normalizeScreeningAddress(address: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Screens a list of addresses (EVM 0x addresses or OCAP DIDs) against an OFAC sanctions blocklist.
|
|
13
|
+
* Normalizes EVM hex addresses to lowercase and strips `did:abt:` prefixes to prevent bypasses.
|
|
14
|
+
*/
|
|
15
|
+
declare function assertNotOfacSanctioned(addresses: Array<string | undefined | null>, ofacBlocklist?: Iterable<string>): void;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CHAINALYSIS_OFAC_ORACLE_ADDRESS, assertNotOfacSanctioned, normalizeScreeningAddress };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
-
let lodash_get = require("lodash/get");
|
|
4
|
-
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
5
3
|
let _ocap_util = require("@ocap/util");
|
|
6
4
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
5
|
+
let lodash_get = require("lodash/get");
|
|
6
|
+
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
7
7
|
|
|
8
8
|
//#region src/pipes/anti-land-attack.ts
|
|
9
9
|
function CreateAntiLandAttackPipe({ senderState = "senderState", receiverState = "receiverState" } = {}) {
|
package/lib/pipes/decode-itx.cjs
CHANGED
|
@@ -19,8 +19,42 @@ let _ocap_message = require("@ocap/message");
|
|
|
19
19
|
* sees a single, stable shape regardless of wire format.
|
|
20
20
|
*/
|
|
21
21
|
function toJspbObject(typeUrl, inner) {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const typeName = (0, _ocap_message.fromTypeUrl)(typeUrl);
|
|
23
|
+
const msg = (0, _ocap_message.createMessage)(typeName, inner);
|
|
24
|
+
const converted = msg?.toObject ? msg.toObject() : inner;
|
|
25
|
+
if (typeName === "DelegateTx" && converted && typeof converted === "object") {
|
|
26
|
+
const rawOps = Array.isArray(inner.opsList) ? inner.opsList : Array.isArray(inner.ops) ? inner.ops : [];
|
|
27
|
+
const outOps = Array.isArray(converted.opsList) ? converted.opsList : [];
|
|
28
|
+
const tokenExtKeys = [
|
|
29
|
+
"maxPerTx",
|
|
30
|
+
"windowLimit",
|
|
31
|
+
"windowSeconds",
|
|
32
|
+
"windowStart",
|
|
33
|
+
"windowSpent",
|
|
34
|
+
"coSignAllowance",
|
|
35
|
+
"coSignRequired",
|
|
36
|
+
"requirePinnedPayee",
|
|
37
|
+
"notifyBeforeDebit",
|
|
38
|
+
"notifyLeadSeconds"
|
|
39
|
+
];
|
|
40
|
+
for (let i = 0; i < rawOps.length && i < outOps.length; i++) {
|
|
41
|
+
const rawLimit = rawOps[i]?.limit;
|
|
42
|
+
const outLimit = outOps[i]?.limit;
|
|
43
|
+
if (rawLimit && typeof rawLimit === "object" && outLimit && typeof outLimit === "object") {
|
|
44
|
+
if (rawLimit.unlimited !== void 0) outLimit.unlimited = rawLimit.unlimited;
|
|
45
|
+
const rawTokens = Array.isArray(rawLimit.tokensList) ? rawLimit.tokensList : Array.isArray(rawLimit.tokens) ? rawLimit.tokens : [];
|
|
46
|
+
const outTokens = Array.isArray(outLimit.tokensList) ? outLimit.tokensList : [];
|
|
47
|
+
for (let j = 0; j < rawTokens.length && j < outTokens.length; j++) {
|
|
48
|
+
const rt = rawTokens[j];
|
|
49
|
+
const ot = outTokens[j];
|
|
50
|
+
if (rt && typeof rt === "object" && ot && typeof ot === "object") {
|
|
51
|
+
for (const k of tokenExtKeys) if (rt[k] !== void 0) ot[k] = rt[k];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return converted;
|
|
24
58
|
}
|
|
25
59
|
function normalizeItx(raw) {
|
|
26
60
|
if (!raw || typeof raw !== "object") return null;
|
|
@@ -53,15 +87,23 @@ function normalizeItx(raw) {
|
|
|
53
87
|
}
|
|
54
88
|
function DecodeItx(context, next) {
|
|
55
89
|
try {
|
|
90
|
+
context._preFlightWafScanned = false;
|
|
91
|
+
context._preFlightVerified = false;
|
|
92
|
+
context._preFlightSnapshotApplied = false;
|
|
93
|
+
context._rawTxItxBeforeNormalize = context.tx?.itx;
|
|
56
94
|
const normalized = normalizeItx(context.tx.itx);
|
|
57
95
|
if (!normalized) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "Failed to decode itx"));
|
|
58
96
|
Object.defineProperty(context, "itx", {
|
|
59
97
|
value: normalized.value,
|
|
60
|
-
enumerable: true
|
|
98
|
+
enumerable: true,
|
|
99
|
+
configurable: true,
|
|
100
|
+
writable: true
|
|
61
101
|
});
|
|
62
102
|
Object.defineProperty(context, "txType", {
|
|
63
103
|
value: normalized.typeUrl,
|
|
64
|
-
enumerable: true
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true
|
|
65
107
|
});
|
|
66
108
|
context.logger?.info("Tx decoded", {
|
|
67
109
|
txBase64: context.txBase64,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ITxOnlyContext } from "@ocap/types";
|
|
2
1
|
import { CustomError } from "@ocap/util/lib/error";
|
|
2
|
+
import { ITxOnlyContext } from "@ocap/types";
|
|
3
3
|
|
|
4
4
|
//#region src/pipes/decode-itx.d.ts
|
|
5
5
|
declare function DecodeItx(context: ITxOnlyContext, next: (err?: CustomError) => void): void;
|
package/lib/pipes/decode-tx.cjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const require_helpers_dedup_height = require('../helpers/dedup-height.cjs');
|
|
4
3
|
const require_package = require('../package.cjs');
|
|
5
4
|
const require_helpers_unwrap_opaque_any = require('../helpers/unwrap-opaque-any.cjs');
|
|
6
|
-
let
|
|
7
|
-
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
5
|
+
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
8
6
|
let _ocap_util = require("@ocap/util");
|
|
9
7
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
10
8
|
let _ocap_message = require("@ocap/message");
|
|
11
|
-
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
12
9
|
let _ocap_message_cbor = require("@ocap/message/cbor");
|
|
13
10
|
let _ocap_message_protobuf = require("@ocap/message/protobuf");
|
|
14
11
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
@@ -74,39 +71,6 @@ function hasCborSelfDescribeTag(buf) {
|
|
|
74
71
|
return buf.length >= _ocap_message_cbor.CANONICAL_SELF_DESCRIBE_PREFIX.length && buf[0] === _ocap_message_cbor.CANONICAL_SELF_DESCRIBE_PREFIX[0] && buf[1] === _ocap_message_cbor.CANONICAL_SELF_DESCRIBE_PREFIX[1] && buf[2] === _ocap_message_cbor.CANONICAL_SELF_DESCRIBE_PREFIX[2];
|
|
75
72
|
}
|
|
76
73
|
const NON_CANONICAL_MESSAGE = "Transaction encoding is not canonical";
|
|
77
|
-
const V1_MULTISIG_TX_TYPES = new Set(["fg:t:exchange", "fg:t:exchange_v2"]);
|
|
78
|
-
function assertCanonicalActiveTx(context) {
|
|
79
|
-
if (!context?.txBase64) return;
|
|
80
|
-
const txBuffer = (0, _ocap_util.toUint8Array)((0, _ocap_util.fromBase64)(context.txBase64));
|
|
81
|
-
const isCbor = hasCborSelfDescribeTag(txBuffer);
|
|
82
|
-
const unsignedTx = (0, lodash_cloneDeep.default)(isCbor ? (0, _ocap_message_cbor.decodeTx)(txBuffer) : (0, _ocap_message_protobuf.decodeTx)(txBuffer));
|
|
83
|
-
unsignedTx.signature = void 0;
|
|
84
|
-
const sigs = (0, _ocap_util_lib_get_list_field.getListField)(unsignedTx, "signatures");
|
|
85
|
-
if (sigs.length > 0) {
|
|
86
|
-
for (const sig of sigs) if (!isCanonicalSigData(sig.data, isCbor)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", NON_CANONICAL_MESSAGE);
|
|
87
|
-
try {
|
|
88
|
-
(0, _ocap_util_lib_get_list_field.setListField)(unsignedTx, "signatures", sigs.map((x) => {
|
|
89
|
-
const stripped = (0, lodash_omit.default)(x, ["signature", "extra"]);
|
|
90
|
-
if (stripped.data) stripped.data = require_helpers_unwrap_opaque_any.unwrapOpaqueAnyData((0, _ocap_message.decodeAny)(stripped.data));
|
|
91
|
-
return stripped;
|
|
92
|
-
}));
|
|
93
|
-
} catch {
|
|
94
|
-
throw new _ocap_util_lib_error.CustomError("INVALID_TX", "Can not decode base64 encoded transaction");
|
|
95
|
-
}
|
|
96
|
-
const unsignedBytes = isCbor ? (0, _ocap_message_cbor.encodeTx)(unsignedTx) : (0, _ocap_message_protobuf.encodeTx)(unsignedTx);
|
|
97
|
-
Object.defineProperty(context, "unsignedTxHash", {
|
|
98
|
-
value: (0, _ocap_mcrypto.toTxHash)(unsignedBytes),
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true
|
|
101
|
-
});
|
|
102
|
-
const multiSignV2Txs = (0, lodash_get.default)(context, "config.transaction.multiSignV2Txs", []);
|
|
103
|
-
const txType = context.txType;
|
|
104
|
-
if (txType && !multiSignV2Txs.includes(txType)) {
|
|
105
|
-
if (!V1_MULTISIG_TX_TYPES.has(txType)) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Expect 0 multi signatures but found ${sigs.length}`);
|
|
106
|
-
if (sigs.length > 1) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Expect 1 multi signatures but found ${sigs.length}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
74
|
function DecodeTx(context, next) {
|
|
111
75
|
let nonCanonical = false;
|
|
112
76
|
try {
|
|
@@ -121,85 +85,61 @@ function DecodeTx(context, next) {
|
|
|
121
85
|
const unsignedTx = (0, lodash_cloneDeep.default)(tx);
|
|
122
86
|
unsignedTx.signature = void 0;
|
|
123
87
|
const sigs = (0, _ocap_util_lib_get_list_field.getListField)(unsignedTx, "signatures");
|
|
124
|
-
const finalizeDecode = (dedupActive) => {
|
|
125
|
-
if (sigs.length > 0) {
|
|
126
|
-
if (dedupActive) {
|
|
127
|
-
for (const sig of sigs) if (!isCanonicalSigData(sig.data, isCbor)) {
|
|
128
|
-
nonCanonical = true;
|
|
129
|
-
throw new _ocap_util_lib_error.CustomError("INVALID_TX", NON_CANONICAL_MESSAGE);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
(0, _ocap_util_lib_get_list_field.setListField)(unsignedTx, "signatures", sigs.map((x) => {
|
|
133
|
-
const stripped = (0, lodash_omit.default)(x, ["signature", "extra"]);
|
|
134
|
-
if (stripped.data) if (dedupActive) stripped.data = require_helpers_unwrap_opaque_any.unwrapOpaqueAnyData((0, _ocap_message.decodeAny)(stripped.data));
|
|
135
|
-
else try {
|
|
136
|
-
stripped.data = require_helpers_unwrap_opaque_any.unwrapOpaqueAnyData((0, _ocap_message.decodeAny)(stripped.data));
|
|
137
|
-
} catch {}
|
|
138
|
-
return stripped;
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
const unsignedBytes = isCbor ? (0, _ocap_message_cbor.encodeTx)(unsignedTx) : (0, _ocap_message_protobuf.encodeTx)(unsignedTx);
|
|
142
|
-
Object.defineProperty(context, "tx", {
|
|
143
|
-
value: tx,
|
|
144
|
-
enumerable: true,
|
|
145
|
-
configurable: true
|
|
146
|
-
});
|
|
147
|
-
Object.defineProperty(context, "txEncoding", {
|
|
148
|
-
value: isCbor ? "cbor" : "protobuf",
|
|
149
|
-
enumerable: true,
|
|
150
|
-
configurable: true
|
|
151
|
-
});
|
|
152
|
-
Object.defineProperty(context, "txSize", {
|
|
153
|
-
value: Buffer.byteLength(txBuffer),
|
|
154
|
-
enumerable: true,
|
|
155
|
-
configurable: true
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(context, "txHash", {
|
|
158
|
-
value: (0, _ocap_mcrypto.toTxHash)(txBuffer),
|
|
159
|
-
enumerable: true,
|
|
160
|
-
configurable: true
|
|
161
|
-
});
|
|
162
|
-
Object.defineProperty(context, "unsignedTxHash", {
|
|
163
|
-
value: (0, _ocap_mcrypto.toTxHash)(unsignedBytes),
|
|
164
|
-
enumerable: true,
|
|
165
|
-
configurable: true
|
|
166
|
-
});
|
|
167
|
-
const pinned = context.extra?.txTime;
|
|
168
|
-
const pinnedMs = pinned === void 0 || pinned === null || pinned === "" ? NaN : new Date(pinned).getTime();
|
|
169
|
-
Object.defineProperty(context, "txTime", {
|
|
170
|
-
value: Number.isFinite(pinnedMs) ? new Date(pinnedMs).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
171
|
-
enumerable: true,
|
|
172
|
-
configurable: true
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(context, "txBaseGas", {
|
|
175
|
-
value: true,
|
|
176
|
-
enumerable: true,
|
|
177
|
-
writable: true,
|
|
178
|
-
configurable: true
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
88
|
if (sigs.length > 0) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
89
|
+
for (const sig of sigs) if (!isCanonicalSigData(sig.data, isCbor)) {
|
|
90
|
+
nonCanonical = true;
|
|
91
|
+
throw new _ocap_util_lib_error.CustomError("INVALID_TX", NON_CANONICAL_MESSAGE);
|
|
92
|
+
}
|
|
93
|
+
(0, _ocap_util_lib_get_list_field.setListField)(unsignedTx, "signatures", sigs.map((x) => {
|
|
94
|
+
const stripped = (0, lodash_omit.default)(x, ["signature", "extra"]);
|
|
95
|
+
if (stripped.data) stripped.data = require_helpers_unwrap_opaque_any.unwrapOpaqueAnyData((0, _ocap_message.decodeAny)(stripped.data));
|
|
96
|
+
return stripped;
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
const unsignedBytes = isCbor ? (0, _ocap_message_cbor.encodeTx)(unsignedTx) : (0, _ocap_message_protobuf.encodeTx)(unsignedTx);
|
|
100
|
+
Object.defineProperty(context, "tx", {
|
|
101
|
+
value: tx,
|
|
102
|
+
enumerable: true,
|
|
103
|
+
configurable: true
|
|
104
|
+
});
|
|
105
|
+
Object.defineProperty(context, "txEncoding", {
|
|
106
|
+
value: isCbor ? "cbor" : "protobuf",
|
|
107
|
+
enumerable: true,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(context, "txSize", {
|
|
111
|
+
value: Buffer.byteLength(txBuffer),
|
|
112
|
+
enumerable: true,
|
|
113
|
+
configurable: true,
|
|
114
|
+
writable: true
|
|
115
|
+
});
|
|
116
|
+
context._extraSizeCounted = false;
|
|
117
|
+
context._preFlightWafScanned = false;
|
|
118
|
+
context._preFlightVerified = false;
|
|
119
|
+
context._preFlightSnapshotApplied = false;
|
|
120
|
+
Object.defineProperty(context, "txHash", {
|
|
121
|
+
value: (0, _ocap_mcrypto.toTxHash)(txBuffer),
|
|
122
|
+
enumerable: true,
|
|
123
|
+
configurable: true
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(context, "unsignedTxHash", {
|
|
126
|
+
value: (0, _ocap_mcrypto.toTxHash)(unsignedBytes),
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true
|
|
129
|
+
});
|
|
130
|
+
const pinned = context.extra?.txTime;
|
|
131
|
+
const pinnedMs = pinned === void 0 || pinned === null || pinned === "" ? NaN : new Date(pinned).getTime();
|
|
132
|
+
Object.defineProperty(context, "txTime", {
|
|
133
|
+
value: Number.isFinite(pinnedMs) ? new Date(pinnedMs).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
|
|
134
|
+
enumerable: true,
|
|
135
|
+
configurable: true
|
|
136
|
+
});
|
|
137
|
+
Object.defineProperty(context, "txBaseGas", {
|
|
138
|
+
value: true,
|
|
139
|
+
enumerable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
configurable: true
|
|
142
|
+
});
|
|
203
143
|
} catch (err) {
|
|
204
144
|
debug$1("failed to decode transaction", {
|
|
205
145
|
txBase64: context.txBase64,
|
|
@@ -211,5 +151,4 @@ function DecodeTx(context, next) {
|
|
|
211
151
|
}
|
|
212
152
|
|
|
213
153
|
//#endregion
|
|
214
|
-
exports.assertCanonicalActiveTx = assertCanonicalActiveTx;
|
|
215
154
|
exports.default = DecodeTx;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { IBaseContext } from "@ocap/types";
|
|
2
1
|
import { CustomError } from "@ocap/util/lib/error";
|
|
2
|
+
import { IBaseContext } from "@ocap/types";
|
|
3
3
|
|
|
4
4
|
//#region src/pipes/decode-tx.d.ts
|
|
5
|
-
declare function
|
|
6
|
-
declare function DecodeTx(context: IBaseContext, next: (err?: CustomError) => void): void | Promise<void>;
|
|
5
|
+
declare function DecodeTx(context: IBaseContext, next: (err?: CustomError) => void): void;
|
|
7
6
|
//#endregion
|
|
8
|
-
export {
|
|
7
|
+
export { DecodeTx as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
-
let _ocap_state = require("@ocap/state");
|
|
4
|
-
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
5
3
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
4
|
+
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
5
|
+
let _ocap_state = require("@ocap/state");
|
|
6
6
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
7
7
|
let lodash_set = require("lodash/set");
|
|
8
8
|
lodash_set = require_rolldown_runtime.__toESM(lodash_set);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
3
|
const require_package = require('../package.cjs');
|
|
4
|
+
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
5
|
+
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
4
6
|
let _ocap_state = require("@ocap/state");
|
|
5
7
|
let lodash_get = require("lodash/get");
|
|
6
8
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
7
|
-
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
8
|
-
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
9
9
|
let debug = require("debug");
|
|
10
10
|
debug = require_rolldown_runtime.__toESM(debug);
|
|
11
11
|
let lodash_set = require("lodash/set");
|
|
@@ -67,7 +67,18 @@ function CreateExtractStatePipe({ from, to, table, status = "OK", message }) {
|
|
|
67
67
|
return next(new _ocap_util_lib_error.CustomError(status, message ? message(missing, role || table || "") : `Invalid state extracted for ${role || table}: ${missing}`, { persist: true }));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
const dedupedResult = Array.isArray(address) ? (() => {
|
|
71
|
+
const seen = /* @__PURE__ */ new Set();
|
|
72
|
+
return result.filter((r) => {
|
|
73
|
+
const stateObj = r;
|
|
74
|
+
const key = stateObj?.address || stateObj?.hash;
|
|
75
|
+
if (!key) return true;
|
|
76
|
+
if (seen.has(key)) return false;
|
|
77
|
+
seen.add(key);
|
|
78
|
+
return true;
|
|
79
|
+
});
|
|
80
|
+
})() : result;
|
|
81
|
+
(0, lodash_set.default)(context, to, Array.isArray(address) ? dedupedResult : result.shift());
|
|
71
82
|
next();
|
|
72
83
|
};
|
|
73
84
|
}
|