From 4544f749420432edf77f91f1fcdd997fdc31f57d Mon Sep 17 00:00:00 2001 From: Majira Date: Mon, 8 Jun 2026 04:41:43 +0200 Subject: [PATCH] fix: address review feedback for #22 --- src/chain/connector.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/chain/connector.rs b/src/chain/connector.rs index 72c56dc..8ab50d0 100644 --- a/src/chain/connector.rs +++ b/src/chain/connector.rs @@ -92,3 +92,32 @@ impl ChainConnector { &self.provider } } + + +// chain/solana.rs +pub struct Chain { + connection: sol::client::Connection, +} + +impl Chain { + pub fn new(connection: impl 'static + Clone) -> Self { + Self { connection } + } + + pub fn balance(&self, token_id: &str) -> Result<(), String> { + let result = self.connection.get_balance(token_id); + Ok(result.map(|res| res)) + } + + pub fn transfer(&self, from: &str, to: &str, amount: u64) -> Result<(), String> { + if let Some(res) = self.connection.transfer(from.to_string(), to.to_string(), amount) { + Ok(format!("Transfer of {} to {} with result {}", amount, to, res)) + } else { + Err(String::from("No balance found")) + } + } + + pub fn get_chain_id(&self) -> String { + "Solana".to_string() + } +} \ No newline at end of file