use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::Coin;
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct OutboundBatchRequest {
pub destination_chain_type: u32,
pub destination_chain_id: String,
pub contract_calls: Vec<ContractCall>,
pub relayer_fee: Coin,
pub outgoing_tx_fee: Coin,
pub is_atomic: bool,
pub exp_timestamp: u64,
}
impl OutboundBatchRequest {
pub fn new(
destination_chain_type: u32,
destination_chain_id: impl Into<String>,
contract_calls: Vec<ContractCall>,
relayer_fee: Coin,
outgoing_tx_fee: Coin,
is_atomic: bool,
exp_timestamp: u64,
) -> Self {
OutboundBatchRequest {
destination_chain_type,
destination_chain_id: destination_chain_id.into(),
contract_calls,
relayer_fee,
outgoing_tx_fee,
is_atomic,
exp_timestamp,
}
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct ContractCall {
pub destination_contract_address: Vec<u8>,
pub payload: Vec<u8>,
}
impl ContractCall {
pub fn new(
destination_contract_address: impl Into<Vec<u8>>,
payload: impl Into<Vec<u8>>,
) -> Self {
ContractCall {
destination_contract_address: destination_contract_address.into(),
payload: payload.into(),
}
}
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub enum ChainType {
ChainTypeEvm,
ChainTypeCosmos,
ChainTypePolkadot,
ChainTypeSolano,
ChainTypeNear,
}
impl ChainType {
pub fn get_chain_code(&self) -> u32 {
match self {
ChainType::ChainTypeEvm => 0,
ChainType::ChainTypeCosmos => 1,
ChainType::ChainTypePolkadot => 2,
ChainType::ChainTypeSolano => 3,
ChainType::ChainTypeNear => 4,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct OutboundBatchResponses {
pub outbound_batch_responses: Vec<OutboundBatchResponse>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct OutboundBatchResponse {
pub outbound_batch_nonce: u64,
}