trident-sdk 0.2.0

End-user SDK for Trident deposits and cross-chain spends
Documentation
use alloy_primitives::keccak256;
use alloy_sol_types::SolValue;

use crate::TridentClientError;
use crate::evm::abi::SpendIntent;
use crate::proto::v1;

/// Computes the canonical spend-spec hash from a proto spend intent.
///
/// This hash identifies the spend specification itself and excludes fields that
/// do not belong to the spec identity, such as signatures and attestation
/// wrapper data.
pub(crate) fn compute_spend_spec_hash(
    intent: v1::SpendIntent,
) -> Result<[u8; 32], TridentClientError> {
    let abi_intent: SpendIntent = intent
        .try_into()
        .map_err(TridentClientError::ProtoConversion)?;
    Ok(keccak256(abi_intent.spec.abi_encode()).into())
}