From 3b45e161c82f68106c51c6dc5df91b9031b7225e Mon Sep 17 00:00:00 2001 From: Augustus Chang Date: Thu, 17 Oct 2024 16:34:46 -0400 Subject: [PATCH] fix op struct encoding --- contracts/src/mcms.cairo | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contracts/src/mcms.cairo b/contracts/src/mcms.cairo index 1b4e7dc71..f795914a3 100644 --- a/contracts/src/mcms.cairo +++ b/contracts/src/mcms.cairo @@ -121,11 +121,18 @@ fn hash_pair(a: u256, b: u256) -> u256 { fn hash_op(op: Op) -> u256 { let mut encoded_leaf: Bytes = BytesTrait::new_empty() .encode(MANY_CHAIN_MULTI_SIG_DOMAIN_SEPARATOR_OP) + .encode(0x40) // dynamic byte offset of the op struct .encode(op.chain_id) .encode(op.multisig) .encode(op.nonce) .encode(op.to) - .encode(op.selector); + .encode(op.selector) + // dynamic byte offset of data array (relative to beginning of op struct) + // (note: domain seperator not part of the op struct) + .encode(0xc0) + // length prefix + .encode(op.data.len()); + // encode the data field by looping through let mut i = 0; while i < op.data.len() {