use alloy::{primitives::Address, sol_types::SolStruct};
use serde::{Deserialize, Serialize};
use crate::{
abis::entry_point::EntryPoint::PackedUserOperation,
entry_point::entry_point_08_domain,
user_operation::{UserOperation, UserOperationHash},
};
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[cfg_attr(js, derive(tsify::Tsify))]
#[cfg_attr(js, tsify(into_wasm_abi, from_wasm_abi))]
#[serde(rename_all = "camelCase")]
pub struct SignedUserOperation {
pub user_op: UserOperation,
pub entry_point: Address,
}
impl SignedUserOperation {
#[must_use]
pub fn hash(&self, chain_id: u64) -> UserOperationHash {
UserOperationHash(
PackedUserOperation::from(&self.user_op)
.eip712_signing_hash(&entry_point_08_domain(chain_id)),
)
}
}