@ocap/tx-protocols 1.31.9 → 1.32.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 (37) hide show
  1. package/esm/execute.d.mts +6 -1
  2. package/esm/execute.mjs +151 -9
  3. package/esm/gas-security-guard.d.mts +19 -1
  4. package/esm/gas-security-guard.mjs +44 -1
  5. package/esm/index.d.mts +8 -2
  6. package/esm/index.mjs +2 -2
  7. package/esm/pipes/ensure-cost.mjs +39 -2
  8. package/esm/pipes/write-ledger.mjs +18 -3
  9. package/esm/protocols/rollup/bridge-create.mjs +8 -3
  10. package/esm/protocols/rollup/bridge-governance-tx-binding.d.mts +7 -0
  11. package/esm/protocols/rollup/bridge-governance-tx-binding.mjs +212 -0
  12. package/esm/protocols/rollup/bridge-governance-vote.d.mts +49 -0
  13. package/esm/protocols/rollup/bridge-governance-vote.mjs +564 -0
  14. package/esm/protocols/rollup/bridge-migrate.mjs +6 -3
  15. package/esm/protocols/rollup/bridge-v2.d.mts +6 -0
  16. package/esm/protocols/rollup/bridge-v2.mjs +5 -0
  17. package/esm/protocols/rollup/update.d.mts +2 -0
  18. package/esm/protocols/rollup/update.mjs +28 -6
  19. package/lib/execute.cjs +151 -9
  20. package/lib/execute.d.cts +6 -1
  21. package/lib/gas-security-guard.cjs +44 -0
  22. package/lib/gas-security-guard.d.cts +19 -1
  23. package/lib/index.cjs +1 -0
  24. package/lib/index.d.cts +8 -2
  25. package/lib/pipes/ensure-cost.cjs +39 -2
  26. package/lib/pipes/write-ledger.cjs +18 -3
  27. package/lib/protocols/rollup/bridge-create.cjs +8 -3
  28. package/lib/protocols/rollup/bridge-governance-tx-binding.cjs +213 -0
  29. package/lib/protocols/rollup/bridge-governance-tx-binding.d.cts +7 -0
  30. package/lib/protocols/rollup/bridge-governance-vote.cjs +573 -0
  31. package/lib/protocols/rollup/bridge-governance-vote.d.cts +49 -0
  32. package/lib/protocols/rollup/bridge-migrate.cjs +6 -3
  33. package/lib/protocols/rollup/bridge-v2.cjs +5 -0
  34. package/lib/protocols/rollup/bridge-v2.d.cts +6 -0
  35. package/lib/protocols/rollup/update.cjs +28 -6
  36. package/lib/protocols/rollup/update.d.cts +2 -0
  37. package/package.json +16 -16
@@ -64,11 +64,26 @@ const WriteLedger = async (context, next) => {
64
64
  return next();
65
65
  }
66
66
  try {
67
+ const verifiedCtx = context;
68
+ const evaluatedByPipeline = verifiedCtx._ensureTxCostEvaluated === true;
69
+ let canonicalGasHeaders;
70
+ if (evaluatedByPipeline) canonicalGasHeaders = verifiedCtx._verifiedGasStakeHeaders;
71
+ else if (extra?.gasStakeHeaders && typeof extra.gasStakeHeaders === "object" && !Array.isArray(extra.gasStakeHeaders)) {
72
+ const hdr = extra.gasStakeHeaders;
73
+ if (typeof hdr.token === "string" && hdr.token.length > 0 && typeof hdr.pk === "string" && hdr.pk.length > 0) canonicalGasHeaders = {
74
+ token: hdr.token,
75
+ pk: hdr.pk
76
+ };
77
+ }
78
+ const canonicalCoSig = evaluatedByPipeline ? verifiedCtx._verifiedCoSignature : extra?.coSignature && typeof extra.coSignature === "object" && !Array.isArray(extra.coSignature) ? extra.coSignature : void 0;
79
+ const canonicalGasPass = evaluatedByPipeline ? verifiedCtx._verifiedGasPass : extra?.gasPass && typeof extra.gasPass === "object" && !Array.isArray(extra.gasPass) ? extra.gasPass : void 0;
67
80
  let txExtra;
68
- if (extra?.txExtra || extra?.gasStakeHeaders) {
81
+ if (extra?.txExtra || canonicalGasHeaders || canonicalCoSig || canonicalGasPass) {
69
82
  txExtra = {};
70
- if (extra.txExtra) txExtra.txExtra = extra.txExtra;
71
- if (extra.gasStakeHeaders) txExtra.gasStakeHeaders = extra.gasStakeHeaders;
83
+ if (extra?.txExtra) txExtra.txExtra = extra.txExtra;
84
+ if (canonicalGasHeaders) txExtra.gasStakeHeaders = canonicalGasHeaders;
85
+ if (canonicalCoSig) txExtra.coSignature = canonicalCoSig;
86
+ if (canonicalGasPass) txExtra.gasPass = canonicalGasPass;
72
87
  }
73
88
  const formattedTx = (0, _ocap_util_lib_deposit_v2_bridge_fields.stripDefaultDepositV2BridgeFieldsInTx)((0, _ocap_message.formatMessage)("Transaction", tx));
74
89
  const txInput = {
@@ -12,6 +12,7 @@ let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
12
12
  /**
13
13
  * `create_rollup` for a v2 bridge (bridge/docs/ocap-protocols.md §v2.2, row `create_rollup`).
14
14
  */
15
+ const ZERO_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
15
16
  const isHttpUrl = (s) => {
16
17
  try {
17
18
  return typeof s === "string" && ["http:", "https:"].includes(new URL(s).protocol);
@@ -34,11 +35,15 @@ async function verifyBridgeCreate(context, next) {
34
35
  if (!(0, _arcblock_did.isEthereumDid)(owner)) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "The bridge owner must use an ethereum compatible address"));
35
36
  const seeds = context.seedValidators;
36
37
  if (!seeds || seeds.length !== 1 || !_ocap_state.rollup.sameAddress(seeds[0], owner)) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "seed_validators of a v2 bridge must be the bridge owner alone"));
37
- if (!_ocap_state.rollup.isValidRollupContractAddress(itx.contractAddress, "EVM")) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "contractAddress must be an ethereum token address"));
38
- if (itx.vaultAddress && !_ocap_state.rollup.isValidRollupVaultAddress(itx.vaultAddress, "EVM")) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "vaultAddress must be an ethereum address"));
38
+ if (typeof itx.contractAddress !== "string" || itx.contractAddress !== itx.contractAddress.trim() || !_ocap_state.rollup.isValidRollupContractAddress(itx.contractAddress, "EVM")) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "contractAddress must be an ethereum token address"));
39
+ if (!itx.vaultAddress || typeof itx.vaultAddress !== "string" || itx.vaultAddress !== itx.vaultAddress.trim() || !_ocap_state.rollup.isValidRollupVaultAddress(itx.vaultAddress, "EVM")) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "vaultAddress must be an ethereum address"));
39
40
  if (!(itx.minBlockConfirmation >= 1 && itx.minBlockConfirmation <= 100)) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "minBlockConfirmation must be between 1 and 100"));
40
- const ethToken = String(itx.contractAddress).toLowerCase();
41
41
  const { body } = input;
42
+ const ethToken = _ocap_state.rollup.bareEthAddress(itx.contractAddress);
43
+ const ethVault = _ocap_state.rollup.bareEthAddress(itx.vaultAddress);
44
+ const ethGateway = _ocap_state.rollup.bareEthAddress(body.gateway);
45
+ if (ethToken === ZERO_ETH_ADDRESS || ethToken === ethGateway) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "contractAddress must be a non-zero ethereum token address distinct from gateway"));
46
+ if (ethVault === ZERO_ETH_ADDRESS || ethVault === ethToken || ethVault === ethGateway) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "vaultAddress must be a non-zero ethereum address distinct from contractAddress and gateway"));
42
47
  const epoch1 = body.epochs[0];
43
48
  const consents = input.consents;
44
49
  if (consents.length !== epoch1.validators.length) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Every initial validator must sign a BridgeMembership consent"));
@@ -0,0 +1,213 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
3
+ let _ocap_mcrypto = require("@ocap/mcrypto");
4
+ let _ocap_util_lib_error = require("@ocap/util/lib/error");
5
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
6
+ let _arcblock_did = require("@arcblock/did");
7
+ let _ocap_state = require("@ocap/state");
8
+ let _ocap_util = require("@ocap/util");
9
+ let _ocap_message = require("@ocap/message");
10
+ let _ocap_message_cbor = require("@ocap/message/cbor");
11
+ let _ocap_message_protobuf = require("@ocap/message/protobuf");
12
+
13
+ //#region src/protocols/rollup/bridge-governance-tx-binding.ts
14
+ /**
15
+ * On-chain `unsignedTxBytesHex` + `frozenNonce` binding for OCAP `ArcBlockTransaction` governance proposals (#1880).
16
+ *
17
+ * Ensures every `ArcBlockTransaction` co-signed on-chain via `govProposalVote` commits to a canonical unsigned OCAP
18
+ * `Transaction` whose `chainId`, `typeUrl`, `from`, `pk`, `nonce`, `signatures` roster, and decoded `itx` fields
19
+ * match `proposal.action`, and whose `frozenNonce` has not yet been spent on `txFrom`'s on-chain account.
20
+ */
21
+ function invalidTx(msg) {
22
+ throw new _ocap_util_lib_error.CustomError("INVALID_TX", msg);
23
+ }
24
+ function hasCborSelfDescribeTag(buf) {
25
+ 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];
26
+ }
27
+ function normalizeDecodedItx(raw) {
28
+ if (!raw || typeof raw !== "object") invalidTx("unsignedTxBytesHex contains no decodable itx");
29
+ if (typeof raw.typeUrl === "string" && raw.typeUrl) {
30
+ if (typeof raw.value === "string") {
31
+ const decoded = (0, _ocap_message.decodeAny)(raw);
32
+ return {
33
+ typeUrl: raw.typeUrl,
34
+ value: decoded?.value ?? {}
35
+ };
36
+ }
37
+ const inner = {};
38
+ for (const [key, val] of Object.entries(raw)) {
39
+ if (key === "typeUrl" || key === "type_url") continue;
40
+ inner[key] = val;
41
+ }
42
+ const msg = (0, _ocap_message.createMessage)((0, _ocap_message.fromTypeUrl)(raw.typeUrl), inner);
43
+ return {
44
+ typeUrl: raw.typeUrl,
45
+ value: msg?.toObject ? msg.toObject() : inner
46
+ };
47
+ }
48
+ if (typeof raw.type === "string" && raw.type) {
49
+ const typeUrl = (0, _ocap_message.toTypeUrl)(raw.type);
50
+ const typeName = (0, _ocap_message.fromTypeUrl)(typeUrl);
51
+ const inner = raw.value || {};
52
+ const msg = (0, _ocap_message.createMessage)(typeName, inner);
53
+ return {
54
+ typeUrl,
55
+ value: msg?.toObject ? msg.toObject() : inner
56
+ };
57
+ }
58
+ invalidTx("unsignedTxBytesHex itx is missing typeUrl");
59
+ }
60
+ function isEmptyBytesOrStr(v) {
61
+ if (v === void 0 || v === null || v === "") return true;
62
+ if (v instanceof Uint8Array) return v.length === 0;
63
+ return false;
64
+ }
65
+ function assertUpdatePatchMatches(decodedPatch, expected) {
66
+ const expectedKeys = [];
67
+ for (const k of [
68
+ "minDeposit",
69
+ "minWithdraw",
70
+ "maxWithdraw",
71
+ "releaseDailyCap",
72
+ "refundDailyCap"
73
+ ]) if (expected[k] !== void 0) {
74
+ expectedKeys.push(k);
75
+ if (decodedPatch[k] !== expected[k].toString(10)) invalidTx(`unsignedTxBytesHex update_rollup patch.${k} does not match proposal`);
76
+ }
77
+ for (const k of ["releaseGrace", "refundDelay"]) if (expected[k] !== void 0) {
78
+ expectedKeys.push(k);
79
+ if (decodedPatch[k] !== expected[k]) invalidTx(`unsignedTxBytesHex update_rollup patch.${k} does not match proposal`);
80
+ }
81
+ if (expected.pausers !== void 0) {
82
+ expectedKeys.push("pausers");
83
+ if (!Array.isArray(decodedPatch.pausers) || decodedPatch.pausers.length !== expected.pausers.length || decodedPatch.pausers.some((p, i) => {
84
+ try {
85
+ return (0, _ocap_mcrypto.checkedNonZeroAddress)(p, `patch.pausers[${i}]`) !== expected.pausers[i];
86
+ } catch {
87
+ return true;
88
+ }
89
+ })) invalidTx("unsignedTxBytesHex update_rollup patch.pausers does not match proposal");
90
+ }
91
+ if (expected.cancelPendingEpoch === true) {
92
+ expectedKeys.push("cancelPendingEpoch");
93
+ if (decodedPatch.cancelPendingEpoch !== true) invalidTx("unsignedTxBytesHex update_rollup patch.cancelPendingEpoch does not match proposal");
94
+ }
95
+ if (expected.cancelOwnerProposal === true) {
96
+ expectedKeys.push("cancelOwnerProposal");
97
+ if (decodedPatch.cancelOwnerProposal !== true) invalidTx("unsignedTxBytesHex update_rollup patch.cancelOwnerProposal does not match proposal");
98
+ }
99
+ if (expected.proposeOwner !== void 0) {
100
+ expectedKeys.push("proposeOwner");
101
+ const po = decodedPatch.proposeOwner;
102
+ if (!po || typeof po !== "object" || Array.isArray(po)) invalidTx("unsignedTxBytesHex update_rollup patch.proposeOwner must be an object");
103
+ const poKeys = Object.keys(po);
104
+ if (poKeys.length !== 3 || !poKeys.every((k) => k === "address" || k === "pk" || k === "endpoint")) invalidTx("unsignedTxBytesHex update_rollup patch.proposeOwner has unexpected keys");
105
+ let normAddr = "";
106
+ let normPk = "";
107
+ try {
108
+ normAddr = (0, _ocap_mcrypto.checkedNonZeroAddress)(po.address, "proposeOwner.address");
109
+ normPk = (0, _ocap_mcrypto.normalizeUncompressedSecp256k1Pk)((0, _arcblock_did.normalizePublicKeyHex)(po.pk) || String(po.pk ?? ""));
110
+ } catch (err) {
111
+ invalidTx(err.message);
112
+ }
113
+ if (normAddr !== expected.proposeOwner.newOwner || normPk !== expected.proposeOwner.newOwnerPk || po.endpoint !== expected.proposeOwner.endpoint) invalidTx("unsignedTxBytesHex update_rollup patch.proposeOwner does not match proposal");
114
+ }
115
+ if (expected.evmGovernance !== void 0) {
116
+ expectedKeys.push("evmGovernance");
117
+ if ((0, _ocap_mcrypto.canonicalJson)(_ocap_state.rollup.validateStrictEvmGovernance(decodedPatch.evmGovernance, "INVALID_ROLLUP_UPDATE")) !== (0, _ocap_mcrypto.canonicalJson)(expected.evmGovernance)) invalidTx("unsignedTxBytesHex update_rollup patch.evmGovernance does not match proposal");
118
+ }
119
+ const actualKeys = Object.keys(decodedPatch).filter((k) => decodedPatch[k] !== void 0);
120
+ if (actualKeys.length !== expectedKeys.length || !actualKeys.every((k) => expectedKeys.includes(k))) invalidTx("unsignedTxBytesHex update_rollup patch keys do not match proposal.action.patch");
121
+ }
122
+ async function verifyOcapProposalTxBinding(context, proposal) {
123
+ const { action } = proposal;
124
+ if (action.kind === "join_rollup" || action.kind === "leave_rollup") return;
125
+ if (!action.txFrom || action.frozenNonce === void 0 || !action.unsignedTxBytesHex || !action.challenge) invalidTx(`${action.kind} proposal requires txFrom, frozenNonce, unsignedTxBytesHex, and challenge on-chain`);
126
+ if (action.frozenNonce < 1n) invalidTx(`${action.kind}.frozenNonce must be a positive integer`);
127
+ const originBytes = new Uint8Array((0, _ocap_util.hexToBytes)(action.unsignedTxBytesHex.slice(2)));
128
+ if ((0, _ocap_mcrypto.toHexDigest)(_ocap_mcrypto.Hasher.Keccak.hash256(originBytes, 1, "Uint8Array")) !== action.challenge) invalidTx("action.challenge does not match keccak256(action.unsignedTxBytesHex)");
129
+ const isCbor = hasCborSelfDescribeTag(originBytes);
130
+ let decodedTx;
131
+ try {
132
+ decodedTx = isCbor ? (0, _ocap_message_cbor.decodeTx)(originBytes) : (0, _ocap_message_protobuf.decodeTx)(originBytes);
133
+ const reencoded = isCbor ? (0, _ocap_message_cbor.encodeTx)(decodedTx) : (0, _ocap_message_protobuf.encodeTx)(decodedTx);
134
+ if (reencoded.length !== originBytes.length || !reencoded.every((b, i) => b === originBytes[i])) invalidTx("unsignedTxBytesHex is not canonically encoded");
135
+ const problem = (0, _ocap_message.findFormatProblem)("Transaction", decodedTx);
136
+ if (problem && (!isCbor || problem.kind === "invalid-timestamp")) invalidTx("unsignedTxBytesHex failed Transaction format check");
137
+ } catch (err) {
138
+ const e = err;
139
+ if (e?.code === "INVALID_TX") throw err;
140
+ invalidTx(`Failed to decode unsignedTxBytesHex: ${e?.message || String(err)}`);
141
+ }
142
+ if (!isEmptyBytesOrStr(decodedTx.signature)) invalidTx("unsignedTxBytesHex must be an unsigned Transaction (tx.signature must be empty)");
143
+ if (decodedTx.delegator) invalidTx("unsignedTxBytesHex must not set tx.delegator");
144
+ if (decodedTx.serviceFee && decodedTx.serviceFee !== "0") invalidTx("unsignedTxBytesHex must not set non-zero tx.serviceFee");
145
+ if (decodedTx.chainId !== proposal.ocapChainId) invalidTx("unsignedTxBytesHex tx.chainId does not match proposal.ocapChainId");
146
+ if (decodedTx.from !== action.txFrom) invalidTx("unsignedTxBytesHex tx.from does not match proposal.action.txFrom");
147
+ let txNonce = -1n;
148
+ try {
149
+ txNonce = BigInt(String(decodedTx.nonce ?? ""));
150
+ } catch {
151
+ invalidTx("unsignedTxBytesHex tx.nonce is not a valid integer");
152
+ }
153
+ if (txNonce !== action.frozenNonce) invalidTx("unsignedTxBytesHex tx.nonce does not match proposal.action.frozenNonce");
154
+ const sigList = (0, _ocap_util_lib_get_list_field.getListField)(decodedTx, "signatures");
155
+ for (const s of sigList) if (!isEmptyBytesOrStr(s.signature) || !isEmptyBytesOrStr(s.extra) || !isEmptyBytesOrStr(s.data) || s.delegator) invalidTx("unsignedTxBytesHex tx.signatures entries must omit signature, extra, data, and delegator");
156
+ let fromPk = "";
157
+ try {
158
+ fromPk = (0, _ocap_mcrypto.normalizeUncompressedSecp256k1Pk)((0, _arcblock_did.normalizePublicKeyHex)(decodedTx.pk) || String(decodedTx.pk ?? ""));
159
+ } catch {
160
+ invalidTx("unsignedTxBytesHex tx.pk is not a valid uncompressed secp256k1 public key");
161
+ }
162
+ if (!_ocap_state.rollup.sameAddress((0, _ocap_mcrypto.ethAddressFromUncompressedPk)(fromPk), action.txFrom)) invalidTx("unsignedTxBytesHex tx.pk does not derive to proposal.action.txFrom");
163
+ if ("signerRoster" in action) {
164
+ if (sigList.length !== action.signerRoster.length - 1) invalidTx("unsignedTxBytesHex tx.signatures length does not match proposal signerRoster");
165
+ const rosterByAddr = new Map(action.signerRoster.map((e) => [e.signer, e.pk]));
166
+ if (rosterByAddr.get(action.txFrom) !== fromPk) invalidTx("unsignedTxBytesHex tx.pk does not match txFrom entry in signerRoster");
167
+ const seenSigs = new Set([action.txFrom]);
168
+ for (const s of sigList) {
169
+ let sAddr = "";
170
+ let sPk = "";
171
+ try {
172
+ sAddr = (0, _ocap_mcrypto.checkedNonZeroAddress)(s.signer, "tx.signatures.signer");
173
+ sPk = (0, _ocap_mcrypto.normalizeUncompressedSecp256k1Pk)((0, _arcblock_did.normalizePublicKeyHex)(s.pk) || String(s.pk ?? ""));
174
+ } catch (err) {
175
+ invalidTx(err.message);
176
+ }
177
+ if (s.signer !== sAddr) invalidTx("unsignedTxBytesHex tx.signatures.signer must be EIP-55 checksummed");
178
+ if (seenSigs.has(sAddr) || rosterByAddr.get(sAddr) !== sPk) invalidTx(`unsignedTxBytesHex tx.signatures entry ${sAddr} does not match signerRoster`);
179
+ seenSigs.add(sAddr);
180
+ }
181
+ } else if (sigList.length !== 0) invalidTx("Single-signer OCAP proposal unsignedTxBytesHex must have empty tx.signatures");
182
+ const normItx = normalizeDecodedItx(decodedTx.itx);
183
+ if (normItx.typeUrl !== `fg:t:${action.kind}`) invalidTx(`unsignedTxBytesHex itx.typeUrl (${normItx.typeUrl}) does not match fg:t:${action.kind}`);
184
+ const itx = normItx.value;
185
+ if (itx.rollup !== proposal.ocapBridge) invalidTx("unsignedTxBytesHex itx.rollup does not match proposal.ocapBridge");
186
+ _ocap_state.rollup.assertV1FieldsUnused(itx, "INVALID_ROLLUP_UPDATE");
187
+ if (action.kind === "pause_rollup" || action.kind === "resume_rollup") {
188
+ if (itx.data !== void 0 && itx.data !== null) {
189
+ const d = require_protocols_rollup_bridge_v2.readItxData(itx);
190
+ if (Object.keys(d).some((k) => k !== "reason") || d.reason !== void 0 && d.reason !== action.reason) invalidTx(`unsignedTxBytesHex ${action.kind} itx.data does not match proposal`);
191
+ }
192
+ } else if (action.kind === "close_rollup") {
193
+ if (typeof itx.message !== "string" || itx.message.trim() !== action.reason || itx.token) invalidTx("unsignedTxBytesHex close_rollup message/token does not match proposal");
194
+ const d = require_protocols_rollup_bridge_v2.readItxData(itx);
195
+ if (!Object.keys(d).every((k) => k === "depositCutoffEthBlock" || k === "reason") || String(d.depositCutoffEthBlock ?? "") !== action.depositCutoffEthBlock.toString(10) || d.reason !== void 0 && d.reason !== action.reason) invalidTx("unsignedTxBytesHex close_rollup depositCutoffEthBlock does not match proposal");
196
+ } else if (action.kind === "migrate_rollup") {
197
+ if (itx.type !== action.migrateKind || typeof itx.message !== "string" || itx.message.trim() !== action.reason) invalidTx("unsignedTxBytesHex migrate_rollup type/message does not match proposal");
198
+ if (action.migrateKind === "vault") {
199
+ if (!_ocap_state.rollup.sameAddress(itx.to, action.nextVault) || itx.data !== void 0 && itx.data !== null) invalidTx("unsignedTxBytesHex migrate_rollup(vault) target/data does not match proposal");
200
+ } else {
201
+ if (itx.to !== action.targetBridge) invalidTx("unsignedTxBytesHex migrate_rollup(reserve) to does not match proposal.action.targetBridge");
202
+ const d = require_protocols_rollup_bridge_v2.readItxData(itx);
203
+ if (Object.keys(d).some((k) => k !== "action") || d.action !== action.step) invalidTx("unsignedTxBytesHex migrate_rollup(reserve) step does not match proposal");
204
+ }
205
+ } else if (action.kind === "update_rollup") assertUpdatePatchMatches(require_protocols_rollup_bridge_v2.readItxData(itx), action.patch);
206
+ const fromAcct = await context.statedb.account.get(action.txFrom, context);
207
+ if (!fromAcct) invalidTx(`Proposal txFrom account ${action.txFrom} does not exist on-chain`);
208
+ const currentAcctNonce = BigInt(String(fromAcct.nonce ?? 0));
209
+ if (currentAcctNonce >= action.frozenNonce) invalidTx(`Proposal frozenNonce (${action.frozenNonce.toString(10)}) is already spent on ${action.txFrom} (account.nonce=${currentAcctNonce.toString(10)})`);
210
+ }
211
+
212
+ //#endregion
213
+ exports.verifyOcapProposalTxBinding = verifyOcapProposalTxBinding;
@@ -0,0 +1,7 @@
1
+ import { OcapGovernanceProposal } from "@ocap/mcrypto";
2
+
3
+ //#region src/protocols/rollup/bridge-governance-tx-binding.d.ts
4
+ type Ctx = any;
5
+ declare function verifyOcapProposalTxBinding(context: Ctx, proposal: OcapGovernanceProposal): Promise<void>;
6
+ //#endregion
7
+ export { verifyOcapProposalTxBinding };