o2-tools 0.3.20-rc

Reusable tooling for trade account and order book contract interactions on Fuel
Documentation
//! 1:1 conversions from the trade-account contract bindings into the
//! structurally identical trial-trade-account bindings.
//!
//! Both sets of types are generated by `abigen!` from the same underlying Sway
//! schema (`std::crypto::signature::Signature`, `std::low_level_call::CallParams`,
//! `contract_schema::trade_account::CallContractArg`), so every enum variant and
//! struct field maps directly and the conversions are total.

use crate::{
    trade_account_deploy,
    trial_trade_account_deploy,
};

impl From<trade_account_deploy::CallParams> for trial_trade_account_deploy::CallParams {
    fn from(value: trade_account_deploy::CallParams) -> Self {
        Self {
            coins: value.coins,
            asset_id: value.asset_id,
            gas: value.gas,
        }
    }
}

impl From<trade_account_deploy::CallContractArg>
    for trial_trade_account_deploy::CallContractArg
{
    fn from(value: trade_account_deploy::CallContractArg) -> Self {
        Self {
            contract_id: value.contract_id,
            function_selector: value.function_selector,
            call_params: value.call_params.into(),
            call_data: value.call_data,
        }
    }
}

impl From<trade_account_deploy::Secp256k1> for trial_trade_account_deploy::Secp256k1 {
    fn from(value: trade_account_deploy::Secp256k1) -> Self {
        Self { bits: value.bits }
    }
}

impl From<trade_account_deploy::Secp256r1> for trial_trade_account_deploy::Secp256r1 {
    fn from(value: trade_account_deploy::Secp256r1) -> Self {
        Self { bits: value.bits }
    }
}

impl From<trade_account_deploy::Ed25519> for trial_trade_account_deploy::Ed25519 {
    fn from(value: trade_account_deploy::Ed25519) -> Self {
        Self { bits: value.bits }
    }
}

impl From<trade_account_deploy::Signature> for trial_trade_account_deploy::Signature {
    fn from(value: trade_account_deploy::Signature) -> Self {
        match value {
            trade_account_deploy::Signature::Secp256k1(signature) => {
                Self::Secp256k1(signature.into())
            }
            trade_account_deploy::Signature::Secp256r1(signature) => {
                Self::Secp256r1(signature.into())
            }
            trade_account_deploy::Signature::Ed25519(signature) => {
                Self::Ed25519(signature.into())
            }
        }
    }
}