Encode an immutable effect receipt and verify its derived ID.
(receipt: &EffectReceipt)
| 141 | |
| 142 | /// Encode an immutable effect receipt and verify its derived ID. |
| 143 | pub fn encode_effect_receipt(receipt: &EffectReceipt) -> Result<Vec<u8>, OperationCodecError> { |
| 144 | let bytes = encode_effect_receipt_payload(receipt.payload())?; |
| 145 | let actual = EffectReceiptId::from_canonical_bytes(&bytes); |
| 146 | if actual != receipt.id() { |
| 147 | return Err(OperationCodecError::new(format!( |
| 148 | "effect receipt ID mismatch: stored {}, computed {}", |
| 149 | receipt.id(), |
| 150 | actual |
| 151 | ))); |
| 152 | } |
| 153 | Ok(bytes) |
| 154 | } |
| 155 | |
| 156 | pub(crate) fn encode_effect_receipt_payload( |
| 157 | payload: &EffectReceiptPayload, |