use crate::Result;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TonConnectConfig {
pub manifest_url: String,
pub wallet_list_url: Option<String>,
}
impl TonConnectConfig {
pub fn new(manifest_url: String) -> Self {
TonConnectConfig {
manifest_url,
wallet_list_url: None,
}
}
pub fn with_wallet_list(mut self, url: String) -> Self {
self.wallet_list_url = Some(url);
self
}
}
pub struct TonConnector {
config: TonConnectConfig,
}
impl TonConnector {
pub fn new(config: TonConnectConfig) -> Self {
TonConnector { config }
}
pub fn generate_connection_url(&self) -> Result<String> {
todo!("Connection URL generation not yet implemented")
}
pub fn generate_qr_code(&self) -> Result<Vec<u8>> {
todo!("QR code generation not yet implemented")
}
pub async fn create_session(&self) -> Result<super::session::WalletSession> {
todo!("Session creation not yet implemented")
}
pub async fn request_address(&self) -> Result<String> {
todo!("Address request not yet implemented")
}
pub async fn send_transaction(&self, _destination: &str, _amount: u64) -> Result<String> {
todo!("Transaction sending not yet implemented")
}
pub async fn validate_manifest(&self) -> Result<bool> {
todo!("Manifest validation not yet implemented")
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TransactionParams {
pub destination: String,
pub amount: u64,
pub message: Option<String>,
}
impl TransactionParams {
pub fn new(destination: String, amount: u64) -> Self {
TransactionParams {
destination,
amount,
message: None,
}
}
pub fn with_message(mut self, message: String) -> Self {
self.message = Some(message);
self
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_ton_connect_config() {
let config = TonConnectConfig::new("https://example.com/manifest.json".to_string());
assert_eq!(config.manifest_url, "https://example.com/manifest.json");
}
#[test]
fn test_transaction_params() {
let params = TransactionParams::new("addr1".to_string(), 1000);
assert_eq!(params.amount, 1000);
}
}