@ocap/tx-pipeline 1.30.26 → 1.31.0

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.
Files changed (149) hide show
  1. package/esm/appchain-sovereign-hub.d.mts +160 -0
  2. package/esm/appchain-sovereign-hub.mjs +348 -0
  3. package/esm/arcvault-external-adapter.d.mts +166 -0
  4. package/esm/arcvault-external-adapter.mjs +376 -0
  5. package/esm/encrypted-nft-envelope.d.mts +172 -0
  6. package/esm/encrypted-nft-envelope.mjs +458 -0
  7. package/esm/evm-simplified-bridge.d.mts +1370 -0
  8. package/esm/evm-simplified-bridge.mjs +3875 -0
  9. package/esm/give-to-mint-karma.d.mts +472 -0
  10. package/esm/give-to-mint-karma.mjs +1057 -0
  11. package/esm/helpers/replay-guard.d.mts +15 -0
  12. package/esm/helpers/replay-guard.mjs +23 -0
  13. package/esm/index.d.mts +10 -5
  14. package/esm/index.mjs +14 -10
  15. package/esm/legacy-protocol-sunset.d.mts +251 -0
  16. package/esm/legacy-protocol-sunset.mjs +1519 -0
  17. package/esm/library.d.mts +16 -0
  18. package/esm/library.mjs +17 -0
  19. package/esm/native-abt-exchange.d.mts +2055 -0
  20. package/esm/native-abt-exchange.mjs +7250 -0
  21. package/esm/ofac-screening.d.mts +17 -0
  22. package/esm/ofac-screening.mjs +39 -0
  23. package/esm/pipes/anti-land-attack.mjs +1 -1
  24. package/esm/pipes/decode-itx.mjs +43 -4
  25. package/esm/pipes/decode-tx.d.mts +2 -3
  26. package/esm/pipes/decode-tx.mjs +53 -115
  27. package/esm/pipes/extract-signer.mjs +2 -2
  28. package/esm/pipes/extract-state.mjs +14 -3
  29. package/esm/pipes/post-execution-invariant-gate.d.mts +61 -0
  30. package/esm/pipes/post-execution-invariant-gate.mjs +789 -0
  31. package/esm/pipes/pre-flight-waf.d.mts +34 -0
  32. package/esm/pipes/pre-flight-waf.mjs +603 -0
  33. package/esm/pipes/take-state-snapshot.mjs +3 -2
  34. package/esm/pipes/update-owner.mjs +39 -4
  35. package/esm/pipes/verify-account-migration.mjs +14 -4
  36. package/esm/pipes/verify-blocked.mjs +1 -1
  37. package/esm/pipes/verify-delegation.d.mts +22 -3
  38. package/esm/pipes/verify-delegation.mjs +259 -36
  39. package/esm/pipes/verify-list-size.mjs +1 -1
  40. package/esm/pipes/verify-multisig-v2.mjs +15 -7
  41. package/esm/pipes/verify-multisig.mjs +15 -7
  42. package/esm/pipes/verify-sender.mjs +1 -1
  43. package/esm/pipes/verify-signature.mjs +35 -6
  44. package/esm/pipes/verify-signer.mjs +2 -2
  45. package/esm/pipes/verify-state-diff.mjs +3 -3
  46. package/esm/pipes/verify-token-access.mjs +1 -1
  47. package/esm/pipes/verify-token-balance.mjs +13 -5
  48. package/esm/pipes/verify-transferrable.d.mts +8 -1
  49. package/esm/pipes/verify-transferrable.mjs +3 -3
  50. package/esm/pipes/verify-tx-input.mjs +2 -2
  51. package/esm/pipes/verify-tx-size.mjs +46 -2
  52. package/esm/pipes/verify-tx.mjs +5 -7
  53. package/esm/pipes/verify-updater.mjs +1 -1
  54. package/esm/social-economy-factories.d.mts +346 -0
  55. package/esm/social-economy-factories.mjs +845 -0
  56. package/esm/super-suites-foundation.d.mts +513 -0
  57. package/esm/super-suites-foundation.mjs +1241 -0
  58. package/esm/transaction-block.d.mts +471 -0
  59. package/esm/transaction-block.mjs +1906 -0
  60. package/esm/uniswap-erc7683-solver.d.mts +201 -0
  61. package/esm/uniswap-erc7683-solver.mjs +321 -0
  62. package/esm/uniswap-lp-copilot.d.mts +113 -0
  63. package/esm/uniswap-lp-copilot.mjs +320 -0
  64. package/esm/uniswap-router.d.mts +335 -0
  65. package/esm/uniswap-router.mjs +578 -0
  66. package/esm/uniswap-token-factory-graduation.d.mts +187 -0
  67. package/esm/uniswap-token-factory-graduation.mjs +426 -0
  68. package/esm/uniswap-v4-hook.d.mts +173 -0
  69. package/esm/uniswap-v4-hook.mjs +517 -0
  70. package/lib/appchain-sovereign-hub.cjs +352 -0
  71. package/lib/appchain-sovereign-hub.d.cts +160 -0
  72. package/lib/arcvault-external-adapter.cjs +383 -0
  73. package/lib/arcvault-external-adapter.d.cts +166 -0
  74. package/lib/encrypted-nft-envelope.cjs +477 -0
  75. package/lib/encrypted-nft-envelope.d.cts +172 -0
  76. package/lib/evm-simplified-bridge.cjs +3943 -0
  77. package/lib/evm-simplified-bridge.d.cts +1370 -0
  78. package/lib/give-to-mint-karma.cjs +1084 -0
  79. package/lib/give-to-mint-karma.d.cts +472 -0
  80. package/lib/helpers/replay-guard.cjs +27 -0
  81. package/lib/helpers/replay-guard.d.cts +15 -0
  82. package/lib/index.cjs +49 -16
  83. package/lib/index.d.cts +10 -5
  84. package/lib/legacy-protocol-sunset.cjs +1543 -0
  85. package/lib/legacy-protocol-sunset.d.cts +251 -0
  86. package/lib/library.cjs +303 -0
  87. package/lib/library.d.cts +16 -0
  88. package/lib/native-abt-exchange.cjs +7322 -0
  89. package/lib/native-abt-exchange.d.cts +2055 -0
  90. package/lib/ofac-screening.cjs +42 -0
  91. package/lib/ofac-screening.d.cts +17 -0
  92. package/lib/pipes/anti-land-attack.cjs +2 -2
  93. package/lib/pipes/decode-itx.cjs +43 -4
  94. package/lib/pipes/decode-itx.d.cts +1 -1
  95. package/lib/pipes/decode-tx.cjs +52 -116
  96. package/lib/pipes/decode-tx.d.cts +3 -4
  97. package/lib/pipes/extract-signer.cjs +2 -2
  98. package/lib/pipes/extract-state.cjs +14 -3
  99. package/lib/pipes/post-execution-invariant-gate.cjs +800 -0
  100. package/lib/pipes/post-execution-invariant-gate.d.cts +61 -0
  101. package/lib/pipes/pre-flight-waf.cjs +616 -0
  102. package/lib/pipes/pre-flight-waf.d.cts +34 -0
  103. package/lib/pipes/take-state-snapshot.cjs +3 -2
  104. package/lib/pipes/update-owner.cjs +40 -5
  105. package/lib/pipes/update-owner.d.cts +1 -1
  106. package/lib/pipes/verify-account-migration.cjs +14 -4
  107. package/lib/pipes/verify-blocked.cjs +1 -1
  108. package/lib/pipes/verify-delegation.cjs +259 -36
  109. package/lib/pipes/verify-delegation.d.cts +22 -3
  110. package/lib/pipes/verify-list-size.cjs +1 -1
  111. package/lib/pipes/verify-multisig-v2.cjs +15 -7
  112. package/lib/pipes/verify-multisig.cjs +15 -7
  113. package/lib/pipes/verify-sender.cjs +1 -1
  114. package/lib/pipes/verify-service-fee.d.cts +1 -1
  115. package/lib/pipes/verify-signature.cjs +35 -6
  116. package/lib/pipes/verify-signature.d.cts +1 -1
  117. package/lib/pipes/verify-signer.cjs +2 -2
  118. package/lib/pipes/verify-state-diff.cjs +4 -4
  119. package/lib/pipes/verify-token-access.cjs +2 -2
  120. package/lib/pipes/verify-token-balance.cjs +13 -5
  121. package/lib/pipes/verify-transferrable.cjs +3 -3
  122. package/lib/pipes/verify-transferrable.d.cts +8 -1
  123. package/lib/pipes/verify-tx-input.cjs +3 -3
  124. package/lib/pipes/verify-tx-size.cjs +46 -2
  125. package/lib/pipes/verify-tx-size.d.cts +1 -1
  126. package/lib/pipes/verify-tx.cjs +6 -8
  127. package/lib/pipes/verify-tx.d.cts +1 -1
  128. package/lib/pipes/verify-updater.cjs +1 -1
  129. package/lib/social-economy-factories.cjs +852 -0
  130. package/lib/social-economy-factories.d.cts +346 -0
  131. package/lib/super-suites-foundation.cjs +1257 -0
  132. package/lib/super-suites-foundation.d.cts +513 -0
  133. package/lib/transaction-block.cjs +1941 -0
  134. package/lib/transaction-block.d.cts +471 -0
  135. package/lib/uniswap-erc7683-solver.cjs +327 -0
  136. package/lib/uniswap-erc7683-solver.d.cts +201 -0
  137. package/lib/uniswap-lp-copilot.cjs +328 -0
  138. package/lib/uniswap-lp-copilot.d.cts +113 -0
  139. package/lib/uniswap-router.cjs +593 -0
  140. package/lib/uniswap-router.d.cts +335 -0
  141. package/lib/uniswap-token-factory-graduation.cjs +431 -0
  142. package/lib/uniswap-token-factory-graduation.d.cts +187 -0
  143. package/lib/uniswap-v4-hook.cjs +527 -0
  144. package/lib/uniswap-v4-hook.d.cts +173 -0
  145. package/package.json +11 -10
  146. package/esm/helpers/dedup-height.d.mts +0 -16
  147. package/esm/helpers/dedup-height.mjs +0 -61
  148. package/lib/helpers/dedup-height.cjs +0 -72
  149. 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" } = {}) {
@@ -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 msg = (0, _ocap_message.createMessage)((0, _ocap_message.fromTypeUrl)(typeUrl), inner);
23
- return msg?.toObject ? msg.toObject() : inner;
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,20 @@ function normalizeItx(raw) {
53
87
  }
54
88
  function DecodeItx(context, next) {
55
89
  try {
90
+ context._rawTxItxBeforeNormalize = context.tx?.itx;
56
91
  const normalized = normalizeItx(context.tx.itx);
57
92
  if (!normalized) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "Failed to decode itx"));
58
93
  Object.defineProperty(context, "itx", {
59
94
  value: normalized.value,
60
- enumerable: true
95
+ enumerable: true,
96
+ configurable: true,
97
+ writable: true
61
98
  });
62
99
  Object.defineProperty(context, "txType", {
63
100
  value: normalized.typeUrl,
64
- enumerable: true
101
+ enumerable: true,
102
+ configurable: true,
103
+ writable: true
65
104
  });
66
105
  context.logger?.info("Tx decoded", {
67
106
  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;
@@ -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 lodash_get = require("lodash/get");
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,58 @@ 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 syncActive = require_helpers_dedup_height.tryResolveDedupHeightActiveSync(context);
183
- if (syncActive === null) return require_helpers_dedup_height.isDedupHeightActive(context).then((dedupActive) => {
184
- try {
185
- finalizeDecode(dedupActive);
186
- } catch (err) {
187
- debug$1("failed to decode transaction", {
188
- txBase64: context.txBase64,
189
- error: err
190
- });
191
- return next(new _ocap_util_lib_error.CustomError("INVALID_TX", nonCanonical ? NON_CANONICAL_MESSAGE : "Can not decode base64 encoded transaction"));
192
- }
193
- next();
194
- }, (err) => {
195
- debug$1("failed to resolve dedup height for transaction", {
196
- txBase64: context.txBase64,
197
- error: err
198
- });
199
- return next(err);
200
- });
201
- finalizeDecode(syncActive);
202
- } else finalizeDecode(true);
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
+ Object.defineProperty(context, "txHash", {
118
+ value: (0, _ocap_mcrypto.toTxHash)(txBuffer),
119
+ enumerable: true,
120
+ configurable: true
121
+ });
122
+ Object.defineProperty(context, "unsignedTxHash", {
123
+ value: (0, _ocap_mcrypto.toTxHash)(unsignedBytes),
124
+ enumerable: true,
125
+ configurable: true
126
+ });
127
+ const pinned = context.extra?.txTime;
128
+ const pinnedMs = pinned === void 0 || pinned === null || pinned === "" ? NaN : new Date(pinned).getTime();
129
+ Object.defineProperty(context, "txTime", {
130
+ value: Number.isFinite(pinnedMs) ? new Date(pinnedMs).toISOString() : (/* @__PURE__ */ new Date()).toISOString(),
131
+ enumerable: true,
132
+ configurable: true
133
+ });
134
+ Object.defineProperty(context, "txBaseGas", {
135
+ value: true,
136
+ enumerable: true,
137
+ writable: true,
138
+ configurable: true
139
+ });
203
140
  } catch (err) {
204
141
  debug$1("failed to decode transaction", {
205
142
  txBase64: context.txBase64,
@@ -211,5 +148,4 @@ function DecodeTx(context, next) {
211
148
  }
212
149
 
213
150
  //#endregion
214
- exports.assertCanonicalActiveTx = assertCanonicalActiveTx;
215
151
  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 assertCanonicalActiveTx(context: IBaseContext): void;
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 { assertCanonicalActiveTx, DecodeTx as default };
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
- (0, lodash_set.default)(context, to, Array.isArray(address) ? result : result.shift());
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
  }