use anyhow::Result;
use serde::{Deserialize, Serialize};
pub trait BlockChainOps {
fn generate_keypair() -> (String, String)
where
Self: Sized;
fn create_address(&mut self) -> Result<String>;
fn address(&self) -> Result<String>;
fn public_key(&self) -> Result<[u8; 32]>;
fn private_key(&self) -> Result<Vec<u8>>;
fn sign(&self, text: &str) -> Result<String>;
fn verify(&self, text: &str, sig_b64: &str) -> Result<bool>;
fn send_payment(&self, to: &str, payment_amount: f64) -> Result<()>;
fn account_balance(&self) -> Result<Option<f64>>;
fn account_balance_at(&self, account: &str) -> Result<f64>;
fn wait_for_confirmation(&self, tx_id: &str, timeout: u64) -> Result<()>;
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ConfirmedTxn {
pub confirmed_round: u64,
pub note: Option<Vec<u8>>,
}
pub trait TransactionQueryOps {
fn confirmed_transaction(&self, tx_id: &str) -> Result<Option<ConfirmedTxn>>;
fn find_transaction_by_note(&self, note: &[u8]) -> Result<Option<ConfirmedTxn>>;
fn find_transaction_by_note_prefix(&self, prefix: &[u8]) -> Result<Option<ConfirmedTxn>>;
fn find_transactions_by_note_prefix(&self, prefix: &[u8]) -> Result<Vec<ConfirmedTxn>>;
fn find_transaction_by_note_and_sender(
&self,
note: &[u8],
sender: &str,
) -> Result<Option<ConfirmedTxn>>;
fn find_transaction_by_note_prefix_and_sender(
&self,
prefix: &[u8],
sender: &str,
) -> Result<Option<ConfirmedTxn>>;
fn find_transactions_by_note_prefix_and_sender(
&self,
prefix: &[u8],
sender: &str,
) -> Result<Vec<ConfirmedTxn>>;
}
pub trait AssetOps {
fn send_asset(&self, asset_id: u64, amount: u64, to: &str) -> Result<()>;
fn asset_holding(&self, account: &str, asset_id: u64) -> Result<u64>;
}