ccnext_abi_encoding/abi/
mod.rs

1use super::common::{AbiEncodeResult, EncodingVersion};
2
3use alloy::rpc::types::{Transaction, TransactionReceipt};
4use thiserror::Error;
5
6mod v1;
7
8#[derive(Debug, Error)]
9pub enum EncodeError {
10    #[error("Custom error: {0}")]
11    Custom(String),
12}
13
14/// Encodes a given ethereum transaction and its receipt into ABI format
15/// according to the specified encoding version.
16///
17/// This function assumes that both the transaction and receipt comply with the ethereum specifications
18/// as defined in the `alloy` crate.
19pub fn abi_encode(
20    tx: Transaction,
21    rx: TransactionReceipt,
22    version: EncodingVersion,
23) -> Result<AbiEncodeResult, Box<dyn std::error::Error>> {
24    match version {
25        EncodingVersion::V1 => v1::abi_encode(tx, rx),
26    }
27}