diff --git a/projects/DAPIO/chain-integration/chain-integration/integration.rs b/projects/DAPIO/chain-integration/chain-integration/integration.rs deleted file mode 100644 index f209980f7..000000000 --- a/projects/DAPIO/chain-integration/chain-integration/integration.rs +++ /dev/null @@ -1,104 +0,0 @@ -// Chain integration implementation - -use tokio::prelude::*; -use serde::{Serialize, Deserialize}; - -// Chain integration configuration -#[derive(Debug, Serialize, Deserialize)] -struct ChainIntegrationConfig { - pi_network_config: PiNetworkConfig, - ethereum_config: EthereumConfig, - binance_smart_chain_config: BinanceSmartChainConfig, - polkadot_config: PolkadotConfig, -} - -// Chain integration implementation -struct ChainIntegration { - pi_network: PiNetwork, - ethereum: Ethereum, - binance_smart_chain: BinanceSmartChain, - polkadot: Polkadot, -} - -impl ChainIntegration { - async fn new(config: ChainIntegrationConfig) -> Result { - let pi_network = PiNetwork::new(config.pi_network_config).await?; - let ethereum = Ethereum::new(config.ethereum_config).await?; - let binance_smart_chain = BinanceSmartChain::new(config.binance_smart_chain_config).await?; - let polkadot = Polkadot::new(config.polkadot_config).await?; - Ok(Self { - pi_network, - ethereum, - binance_smart_chain, - polkadot, - }) - } - - async fn get_block_numbers(&self) -> Result, String> { - let mut block_numbers = Vec::new(); - block_numbers.push(self.pi_network.get_block_number().await?); - block_numbers.push(self.ethereum.get_block_number().await?); - block_numbers.push(self.binance_smart_chain.get_block_number().await?); - block_numbers.push(self.polkadot.get_block_number().await?); - Ok(block_numbers) - } - - async fn send_transactions(&self, txs: Vec) -> Result, String> { - let mut tx_hashes = Vec::new(); - for tx in txs { - tx_hashes.push(self.pi_network.send_transaction(&tx).await?); - tx_hashes.push(self.ethereum.send_transaction(&tx).await?); - tx_hashes.push(self.binance_smart_chain.send_transaction(&tx).await?); - tx_hashes.push(self.polkadot.send_transaction(&tx).await?); - } - Ok(tx_hashes) - } -} - -// Example usage -#[tokio::main] -async fn main() { - let config = ChainIntegrationConfig { - pi_network_config: PiNetworkConfig { - node_url: "https://pi-network-node.com".to_string(), - api_key: "YOUR_API_KEY".to_string(), - api_secret: "YOUR_API_SECRET".to_string(), - }, - ethereum_config: EthereumConfig { - node_url: "https://ethereum-node.com".to_string(), - api_key: "YOUR_API_KEY".to_string(), - api_secret: "YOUR_API_SECRET".to_string(), - }, - binance_smart_chain_config: BinanceSmartChainConfig { - node_url: "https://binance-smart-chain-node.com".to_string(), - api_key: "YOUR_API_KEY".to_string(), - api_secret: "YOUR_API_SECRET".to_string(), - }, - polkadot_config: PolkadotConfig { - node_url: "https://polkadot-node.com".to_string(), - api_key: "YOUR_API_KEY".to_string(), - api_secret: "YOUR_API_SECRET".to_string(), - }, - }; - let chain_integration = ChainIntegration::new(config).await.unwrap(); - let block_numbers = chain_integration.get_block_numbers().await.unwrap(); - println!("Block numbers: {:?}", block_numbers); - let txs = vec![ - Transaction { - from: "0x1234567890abcdef".to_string(), - to: "0xfedcba9876543210".to_string(), - value: 100, - gas: 20000, - gas_price: 20, - }, - Transaction { - from: "0xfedcba9876543210".to_string(), - to: "0x1234567890abcdef".to_string(), - value: 50, - gas: 15000, - gas_price: 15, - }, - ]; - let tx_hashes = chain_integration.send_transactions(txs).await.unwrap(); - println!("Transaction hashes: {:?}", tx_hashes); -}