algonaut_algod 0.5.0

API endpoint for algod operations.
Documentation
/*
 * Algod REST API.
 *
 * API endpoint for algod operations.
 *
 * The version of the OpenAPI document: 0.0.1
 * Contact: contact@algorand.com
 * Generated by: https://openapi-generator.tech
 */

use algonaut_crypto::{HashDigest, deserialize_hash};
use algonaut_transaction::builder::TransactionParams;

/// TransactionParams200Response : TransactionParams contains the parameters that help a client construct a new transaction.

#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
pub struct TransactionParams200Response {
    /// ConsensusVersion indicates the consensus protocol version as of LastRound.
    #[serde(rename = "consensus-version")]
    pub consensus_version: String,
    /// Fee is the suggested transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol.
    #[serde(rename = "fee")]
    pub fee: u64,
    /// GenesisHash is the hash of the genesis block.
    #[serde(rename = "genesis-hash", deserialize_with = "deserialize_hash")]
    pub genesis_hash: HashDigest,
    /// GenesisID is an ID listed in the genesis block.
    #[serde(rename = "genesis-id")]
    pub genesis_id: String,
    /// LastRound indicates the last round seen
    #[serde(rename = "last-round")]
    pub last_round: u64,
    /// The minimum transaction fee (not per byte) required for the txn to validate for the current network protocol.
    #[serde(rename = "min-fee")]
    pub min_fee: u64,
}

impl TransactionParams200Response {
    /// TransactionParams contains the parameters that help a client construct a new transaction.
    pub fn new(
        consensus_version: String,
        fee: u64,
        genesis_hash: HashDigest,
        genesis_id: String,
        last_round: u64,
        min_fee: u64,
    ) -> TransactionParams200Response {
        TransactionParams200Response {
            consensus_version,
            fee,
            genesis_hash,
            genesis_id,
            last_round,
            min_fee,
        }
    }
}

impl TransactionParams for TransactionParams200Response {
    fn last_round(&self) -> u64 {
        self.last_round
    }

    fn min_fee(&self) -> u64 {
        self.min_fee
    }

    fn genesis_hash(&self) -> HashDigest {
        self.genesis_hash
    }

    fn genesis_id(&self) -> &String {
        &self.genesis_id
    }
}