From 4f88ec14ed91de316a284b58f5c0b533d4f0d48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Tue, 5 Aug 2025 09:56:50 +0300 Subject: [PATCH 1/7] create solana module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/lp_coins.rs | 2 ++ mm2src/coins/solana/mod.rs | 1 + mm2src/coins/solana/solana_coin.rs | 0 3 files changed, 3 insertions(+) create mode 100644 mm2src/coins/solana/mod.rs create mode 100644 mm2src/coins/solana/solana_coin.rs diff --git a/mm2src/coins/lp_coins.rs b/mm2src/coins/lp_coins.rs index 5e1ecb47e7..8f0907c537 100644 --- a/mm2src/coins/lp_coins.rs +++ b/mm2src/coins/lp_coins.rs @@ -301,6 +301,8 @@ use crate::coin_balance::{BalanceObjectOps, HDWalletBalanceObject}; use crate::hd_wallet::{AddrToString, DisplayAddress}; use z_coin::{ZCoin, ZcoinProtocolInfo}; +pub mod solana; + pub type TransactionFut = Box + Send>; pub type TransactionResult = Result; pub type BalanceResult = Result>; diff --git a/mm2src/coins/solana/mod.rs b/mm2src/coins/solana/mod.rs new file mode 100644 index 0000000000..e879f86827 --- /dev/null +++ b/mm2src/coins/solana/mod.rs @@ -0,0 +1 @@ +mod solana_coin; diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs new file mode 100644 index 0000000000..e69de29bb2 From e5bd9a2d0566c4b2448f90d1caa72470cac96563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Wed, 6 Aug 2025 10:05:55 +0300 Subject: [PATCH 2/7] partially add bare structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/solana/mod.rs | 2 + mm2src/coins/solana/solana_coin.rs | 15 ++++ mm2src/coins_activation/src/lib.rs | 1 + .../src/solana_with_assets.rs | 79 +++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 mm2src/coins_activation/src/solana_with_assets.rs diff --git a/mm2src/coins/solana/mod.rs b/mm2src/coins/solana/mod.rs index e879f86827..fecf31dd7c 100644 --- a/mm2src/coins/solana/mod.rs +++ b/mm2src/coins/solana/mod.rs @@ -1 +1,3 @@ mod solana_coin; + +pub use solana_coin::SolanaCoin; diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index e69de29bb2..877f17fd14 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -0,0 +1,15 @@ +use std::ops::Deref; +use std::sync::Arc; + +#[derive(Clone)] +pub struct SolanaCoin(Arc); + +pub struct SolanaCoinFields {} + +impl Deref for SolanaCoin { + type Target = SolanaCoinFields; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} diff --git a/mm2src/coins_activation/src/lib.rs b/mm2src/coins_activation/src/lib.rs index 318305fa17..33dcaa88d9 100644 --- a/mm2src/coins_activation/src/lib.rs +++ b/mm2src/coins_activation/src/lib.rs @@ -15,6 +15,7 @@ mod slp_token_activation; mod standalone_coin; mod tendermint_token_activation; mod tendermint_with_assets_activation; +mod solana_with_assets; mod token; mod utxo_activation; #[cfg(not(target_arch = "wasm32"))] diff --git a/mm2src/coins_activation/src/solana_with_assets.rs b/mm2src/coins_activation/src/solana_with_assets.rs new file mode 100644 index 0000000000..99eeb8885f --- /dev/null +++ b/mm2src/coins_activation/src/solana_with_assets.rs @@ -0,0 +1,79 @@ +use coins::{my_tx_history_v2::TxHistoryStorage, solana::SolanaCoin, MmCoinEnum}; +use mm2_core::mm_ctx::MmArc; +use mm2_err_handle::prelude::MmError; +use mm2_number::BigDecimal; +use rpc_task::RpcTaskHandleShared; + +use crate::{ + context::CoinsActivationContext, + platform_coin_with_tokens::{ + InitPlatformCoinWithTokensTask, InitPlatformCoinWithTokensTaskManagerShared, + PlatformCoinWithTokensActivationOps, TokenAsMmCoinInitializer, + }, +}; + +#[async_trait] +impl PlatformCoinWithTokensActivationOps for SolanaCoin { + type ActivationRequest; + type PlatformProtocolInfo; + type ActivationResult; + type ActivationError; + + type InProgressStatus; + type AwaitingStatus; + type UserAction; + + async fn enable_platform_coin( + ctx: MmArc, + ticker: String, + coin_conf: &Json, + activation_request: Self::ActivationRequest, + protocol_conf: Self::PlatformProtocolInfo, + ) -> Result> { + todo!() + } + + async fn enable_global_nft( + &self, + _activation_request: &Self::ActivationRequest, + ) -> Result, MmError> { + todo!() + } + + fn try_from_mm_coin(coin: MmCoinEnum) -> Option + where + Self: Sized, + { + todo!() + } + + fn token_initializers( + &self, + ) -> Vec>> { + todo!() + } + + async fn get_activation_result( + &self, + _task_handle: Option>>, + activation_request: &Self::ActivationRequest, + _nft_global: &Option, + ) -> Result> { + todo!() + } + + fn start_history_background_fetching( + &self, + ctx: MmArc, + storage: impl TxHistoryStorage, + initial_balance: Option, + ) { + todo!() + } + + fn rpc_task_manager( + activation_ctx: &CoinsActivationContext, + ) -> &InitPlatformCoinWithTokensTaskManagerShared { + todo!() + } +} From 758e4442b2df0317923d5e7bce091c74fa25b70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Wed, 6 Aug 2025 11:13:15 +0300 Subject: [PATCH 3/7] add more infra to solana support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/lp_coins.rs | 8 ++ mm2src/coins/solana/solana_coin.rs | 133 ++++++++++++++++++ .../src/solana_with_assets.rs | 3 +- 3 files changed, 143 insertions(+), 1 deletion(-) diff --git a/mm2src/coins/lp_coins.rs b/mm2src/coins/lp_coins.rs index 8f0907c537..3606a63088 100644 --- a/mm2src/coins/lp_coins.rs +++ b/mm2src/coins/lp_coins.rs @@ -3723,6 +3723,7 @@ pub enum MmCoinEnum { TendermintToken(TendermintToken), #[cfg(not(target_arch = "wasm32"))] LightningCoin(LightningCoin), + Solana(solana::SolanaCoin), #[cfg(feature = "enable-sia")] SiaCoin(SiaCoin), #[cfg(any(test, feature = "for-tests"))] @@ -3791,6 +3792,12 @@ impl From for MmCoinEnum { } } +impl From for MmCoinEnum { + fn from(c: solana::SolanaCoin) -> MmCoinEnum { + MmCoinEnum::Solana(c) + } +} + impl From for MmCoinEnum { fn from(c: ZCoin) -> MmCoinEnum { MmCoinEnum::ZCoin(c) @@ -3820,6 +3827,7 @@ impl Deref for MmCoinEnum { #[cfg(not(target_arch = "wasm32"))] MmCoinEnum::LightningCoin(ref c) => c, MmCoinEnum::ZCoin(ref c) => c, + MmCoinEnum::Solana(ref c) => c, #[cfg(feature = "enable-sia")] MmCoinEnum::SiaCoin(ref c) => c, #[cfg(any(test, feature = "for-tests"))] diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index 877f17fd14..f1604316b8 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -1,6 +1,18 @@ use std::ops::Deref; use std::sync::Arc; +use common::executor::{abortable_queue::WeakSpawner, AbortedError}; +use futures01::Future; +use mm2_core::mm_ctx::MmArc; +use mm2_number::MmNumber; +use rpc::v1::types::Bytes as RpcBytes; +use async_trait::async_trait; + +use crate::{ + DexFee, FeeApproxStage, HistorySyncState, MmCoin, RawTransactionFut, RawTransactionRequest, TradeFee, + TradePreimageResult, TradePreimageValue, ValidateAddressResult, WithdrawFut, WithdrawRequest, +}; + #[derive(Clone)] pub struct SolanaCoin(Arc); @@ -13,3 +25,124 @@ impl Deref for SolanaCoin { &self.0 } } + +#[async_trait] +impl MmCoin for SolanaCoin { + fn is_asset_chain(&self) -> bool { + todo!() + } + + fn wallet_only(&self, ctx: &MmArc) -> bool { + todo!() + } + + fn spawner(&self) -> WeakSpawner { + todo!() + } + + fn withdraw(&self, req: WithdrawRequest) -> WithdrawFut { + todo!() + } + + fn get_raw_transaction(&self, req: RawTransactionRequest) -> RawTransactionFut { + todo!() + } + + fn get_tx_hex_by_hash(&self, tx_hash: Vec) -> RawTransactionFut { + todo!() + } + + fn decimals(&self) -> u8 { + todo!() + } + + fn convert_to_address(&self, from: &str, to_address_format: serde_json::Value) -> Result { + todo!() + } + + fn validate_address(&self, address: &str) -> ValidateAddressResult { + todo!() + } + + fn process_history_loop(&self, ctx: MmArc) -> Box + Send> { + todo!() + } + + fn history_sync_status(&self) -> HistorySyncState { + todo!() + } + + fn get_trade_fee(&self) -> Box + Send> { + todo!() + } + + async fn get_sender_trade_fee( + &self, + value: TradePreimageValue, + _stage: FeeApproxStage, + ) -> TradePreimageResult { + todo!() + } + + fn get_receiver_trade_fee(&self, stage: FeeApproxStage) -> TradePreimageFut { + todo!() + } + + async fn get_fee_to_send_taker_fee( + &self, + dex_fee_amount: DexFee, + _stage: FeeApproxStage, + ) -> TradePreimageResult { + todo!() + } + + fn required_confirmations(&self) -> u64 { + todo!() + } + + fn requires_notarization(&self) -> bool { + todo!() + } + + fn set_required_confirmations(&self, confirmations: u64) { + todo!() + } + + fn set_requires_notarization(&self, requires_nota: bool) { + todo!() + } + + fn swap_contract_address(&self) -> Option { + todo!() + } + + fn fallback_swap_contract(&self) -> Option { + todo!() + } + + fn mature_confirmations(&self) -> Option { + todo!() + } + + fn coin_protocol_info(&self, amount_to_receive: Option) -> Vec { + todo!() + } + + fn is_coin_protocol_supported( + &self, + info: &Option>, + amount_to_send: Option, + locktime: u64, + is_maker: bool, + ) -> bool { + todo!() + } + + fn on_disabled(&self) -> Result<(), AbortedError> { + todo!() + } + + fn on_token_deactivated(&self, ticker: &str) { + todo!() + } +} diff --git a/mm2src/coins_activation/src/solana_with_assets.rs b/mm2src/coins_activation/src/solana_with_assets.rs index 99eeb8885f..c40e9d080c 100644 --- a/mm2src/coins_activation/src/solana_with_assets.rs +++ b/mm2src/coins_activation/src/solana_with_assets.rs @@ -1,3 +1,4 @@ +use async_trait::async_trait; use coins::{my_tx_history_v2::TxHistoryStorage, solana::SolanaCoin, MmCoinEnum}; use mm2_core::mm_ctx::MmArc; use mm2_err_handle::prelude::MmError; @@ -26,7 +27,7 @@ impl PlatformCoinWithTokensActivationOps for SolanaCoin { async fn enable_platform_coin( ctx: MmArc, ticker: String, - coin_conf: &Json, + coin_conf: &serde_json::Value, activation_request: Self::ActivationRequest, protocol_conf: Self::PlatformProtocolInfo, ) -> Result> { From 291acda8d9d7dfa8dca2a856b4c64aefb32df99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Thu, 7 Aug 2025 12:45:12 +0300 Subject: [PATCH 4/7] and more infra for solana MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/solana/solana_coin.rs | 206 ++++++++++++++++++++++++++++- 1 file changed, 202 insertions(+), 4 deletions(-) diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index f1604316b8..7aed5ba5f5 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -4,13 +4,13 @@ use std::sync::Arc; use common::executor::{abortable_queue::WeakSpawner, AbortedError}; use futures01::Future; use mm2_core::mm_ctx::MmArc; -use mm2_number::MmNumber; -use rpc::v1::types::Bytes as RpcBytes; +use mm2_err_handle::prelude::{MmError, MmResult}; +use mm2_number::{BigDecimal, MmNumber}; +use rpc::v1::types::{Bytes as RpcBytes, H264 as RpcH264}; use async_trait::async_trait; use crate::{ - DexFee, FeeApproxStage, HistorySyncState, MmCoin, RawTransactionFut, RawTransactionRequest, TradeFee, - TradePreimageResult, TradePreimageValue, ValidateAddressResult, WithdrawFut, WithdrawRequest, + coin_errors::{AddressFromPubkeyError, MyAddressError, ValidatePaymentResult}, hd_wallet::HDAddressSelector, BalanceFut, CheckIfMyPaymentSentArgs, CoinBalance, ConfirmPaymentInput, DexFee, FeeApproxStage, FoundSwapTxSpend, HistorySyncState, MarketCoinOps, MmCoin, NegotiateSwapContractAddrErr, RawTransactionFut, RawTransactionRequest, RawTransactionResult, RefundPaymentArgs, SearchForSwapTxSpendInput, SendPaymentArgs, SignRawTransactionRequest, SignatureResult, SpendPaymentArgs, SwapOps, TradeFee, TradePreimageFut, TradePreimageResult, TradePreimageValue, TransactionEnum, TransactionResult, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidateFeeArgs, ValidateOtherPubKeyErr, ValidatePaymentInput, VerificationResult, WaitForHTLCTxSpendArgs, WatcherOps, WithdrawFut, WithdrawRequest }; #[derive(Clone)] @@ -146,3 +146,201 @@ impl MmCoin for SolanaCoin { todo!() } } + +#[async_trait] +impl MarketCoinOps for SolanaCoin { + fn ticker(&self) -> &str { + todo!() + } + + fn my_address(&self) -> MmResult { + todo!() + } + + fn address_from_pubkey(&self, pubkey: &RpcH264) -> MmResult { + todo!() + } + + async fn get_public_key(&self) -> Result> { + todo!() + } + + fn sign_message_hash(&self, _message: &str) -> Option<[u8; 32]> { + todo!() + } + + fn sign_message(&self, _message: &str, _address: Option) -> SignatureResult { + todo!() + } + + fn verify_message(&self, _signature: &str, _message: &str, _address: &str) -> VerificationResult { + todo!() + } + + fn my_balance(&self) -> BalanceFut { + todo!() + } + + fn base_coin_balance(&self) -> BalanceFut { + todo!() + } + + fn platform_ticker(&self) -> &str { + todo!() + } + + fn send_raw_tx(&self, tx: &str) -> Box + Send> { + todo!() + } + + fn send_raw_tx_bytes(&self, tx: &[u8]) -> Box + Send> { + todo!() + } + + #[inline(always)] + async fn sign_raw_tx(&self, _args: &SignRawTransactionRequest) -> RawTransactionResult { + todo!() + } + + fn wait_for_confirmations(&self, input: ConfirmPaymentInput) -> Box + Send> { + todo!() + } + + async fn wait_for_htlc_tx_spend(&self, args: WaitForHTLCTxSpendArgs<'_>) -> TransactionResult { + todo!() + } + + fn tx_enum_from_bytes(&self, bytes: &[u8]) -> Result> { + todo!() + } + + fn current_block(&self) -> Box + Send> { + todo!() + } + + fn display_priv_key(&self) -> Result { + todo!() + } + + #[inline] + fn min_tx_amount(&self) -> BigDecimal { + todo!() + } + + #[inline] + fn min_trading_vol(&self) -> MmNumber { + todo!() + } + + #[inline] + fn should_burn_dex_fee(&self) -> bool { + todo!() + } + + fn is_trezor(&self) -> bool { + todo!() + } +} + +#[async_trait] +impl SwapOps for SolanaCoin { + async fn send_taker_fee(&self, dex_fee: DexFee, uuid: &[u8], expire_at: u64) -> TransactionResult { + todo!() + } + + async fn send_maker_payment(&self, maker_payment_args: SendPaymentArgs<'_>) -> TransactionResult { + todo!() + } + + async fn send_taker_payment(&self, taker_payment_args: SendPaymentArgs<'_>) -> TransactionResult { + todo!() + } + + async fn send_maker_spends_taker_payment( + &self, + maker_spends_payment_args: SpendPaymentArgs<'_>, + ) -> TransactionResult { + todo!() + } + + async fn send_taker_spends_maker_payment( + &self, + taker_spends_payment_args: SpendPaymentArgs<'_>, + ) -> TransactionResult { + todo!() + } + + async fn send_taker_refunds_payment(&self, taker_refunds_payment_args: RefundPaymentArgs<'_>) -> TransactionResult { + todo!() + } + + async fn send_maker_refunds_payment(&self, maker_refunds_payment_args: RefundPaymentArgs<'_>) -> TransactionResult { + todo!() + } + + async fn validate_fee(&self, validate_fee_args: ValidateFeeArgs<'_>) -> ValidatePaymentResult<()> { + todo!() + } + + async fn validate_maker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { + todo!() + } + + async fn validate_taker_payment(&self, input: ValidatePaymentInput) -> ValidatePaymentResult<()> { + todo!() + } + + async fn check_if_my_payment_sent( + &self, + if_my_payment_sent_args: CheckIfMyPaymentSentArgs<'_>, + ) -> Result, String> { + todo!() + } + + async fn search_for_swap_tx_spend_my( + &self, + input: SearchForSwapTxSpendInput<'_>, + ) -> Result, String> { + todo!() + } + + async fn search_for_swap_tx_spend_other( + &self, + input: SearchForSwapTxSpendInput<'_>, + ) -> Result, String> { + todo!() + } + + async fn extract_secret( + &self, + secret_hash: &[u8], + spend_tx: &[u8], + watcher_reward: bool, + ) -> Result<[u8; 32], String> { + todo!() + } + + fn negotiate_swap_contract_addr( + &self, + other_side_address: Option<&[u8]>, + ) -> Result, MmError> { + todo!() + } + + #[inline] + fn derive_htlc_key_pair(&self, _swap_unique_data: &[u8]) -> keys::KeyPair { + todo!() + } + + #[inline] + fn derive_htlc_pubkey(&self, _swap_unique_data: &[u8]) -> [u8; 33] { + todo!() + } + + fn validate_other_pubkey(&self, raw_pubkey: &[u8]) -> MmResult<(), ValidateOtherPubKeyErr> { + todo!() + } +} + +#[async_trait] +impl WatcherOps for SolanaCoin {} From e7bb84f37c9411d2f8a83ee9bdbc8ac5ce17489d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Mon, 11 Aug 2025 10:54:08 +0300 Subject: [PATCH 5/7] add place-holder types on solana activation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/solana/mod.rs | 2 + mm2src/coins/solana/solana_coin.rs | 18 ++++- mm2src/coins_activation/src/lib.rs | 2 +- .../src/solana_with_assets.rs | 70 ++++++++++++++++--- 4 files changed, 79 insertions(+), 13 deletions(-) diff --git a/mm2src/coins/solana/mod.rs b/mm2src/coins/solana/mod.rs index fecf31dd7c..a2f19bdbf8 100644 --- a/mm2src/coins/solana/mod.rs +++ b/mm2src/coins/solana/mod.rs @@ -1,3 +1,5 @@ mod solana_coin; pub use solana_coin::SolanaCoin; +pub use solana_coin::SolanaInitError; +pub use solana_coin::SolanaProtocolInfo; diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index 7aed5ba5f5..c5dc59c964 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -1,16 +1,24 @@ use std::ops::Deref; use std::sync::Arc; +use async_trait::async_trait; use common::executor::{abortable_queue::WeakSpawner, AbortedError}; use futures01::Future; use mm2_core::mm_ctx::MmArc; use mm2_err_handle::prelude::{MmError, MmResult}; use mm2_number::{BigDecimal, MmNumber}; use rpc::v1::types::{Bytes as RpcBytes, H264 as RpcH264}; -use async_trait::async_trait; use crate::{ - coin_errors::{AddressFromPubkeyError, MyAddressError, ValidatePaymentResult}, hd_wallet::HDAddressSelector, BalanceFut, CheckIfMyPaymentSentArgs, CoinBalance, ConfirmPaymentInput, DexFee, FeeApproxStage, FoundSwapTxSpend, HistorySyncState, MarketCoinOps, MmCoin, NegotiateSwapContractAddrErr, RawTransactionFut, RawTransactionRequest, RawTransactionResult, RefundPaymentArgs, SearchForSwapTxSpendInput, SendPaymentArgs, SignRawTransactionRequest, SignatureResult, SpendPaymentArgs, SwapOps, TradeFee, TradePreimageFut, TradePreimageResult, TradePreimageValue, TransactionEnum, TransactionResult, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, ValidateFeeArgs, ValidateOtherPubKeyErr, ValidatePaymentInput, VerificationResult, WaitForHTLCTxSpendArgs, WatcherOps, WithdrawFut, WithdrawRequest + coin_errors::{AddressFromPubkeyError, MyAddressError, ValidatePaymentResult}, + hd_wallet::HDAddressSelector, + BalanceFut, CheckIfMyPaymentSentArgs, CoinBalance, ConfirmPaymentInput, DexFee, FeeApproxStage, FoundSwapTxSpend, + HistorySyncState, MarketCoinOps, MmCoin, NegotiateSwapContractAddrErr, RawTransactionFut, RawTransactionRequest, + RawTransactionResult, RefundPaymentArgs, SearchForSwapTxSpendInput, SendPaymentArgs, SignRawTransactionRequest, + SignatureResult, SpendPaymentArgs, SwapOps, TradeFee, TradePreimageFut, TradePreimageResult, TradePreimageValue, + TransactionEnum, TransactionResult, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult, + ValidateFeeArgs, ValidateOtherPubKeyErr, ValidatePaymentInput, VerificationResult, WaitForHTLCTxSpendArgs, + WatcherOps, WithdrawFut, WithdrawRequest, }; #[derive(Clone)] @@ -18,6 +26,9 @@ pub struct SolanaCoin(Arc); pub struct SolanaCoinFields {} +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct SolanaProtocolInfo {} + impl Deref for SolanaCoin { type Target = SolanaCoinFields; @@ -26,6 +37,9 @@ impl Deref for SolanaCoin { } } +#[derive(Clone, Debug)] +pub struct SolanaInitError {} + #[async_trait] impl MmCoin for SolanaCoin { fn is_asset_chain(&self) -> bool { diff --git a/mm2src/coins_activation/src/lib.rs b/mm2src/coins_activation/src/lib.rs index 33dcaa88d9..9a2f5ded14 100644 --- a/mm2src/coins_activation/src/lib.rs +++ b/mm2src/coins_activation/src/lib.rs @@ -12,10 +12,10 @@ mod prelude; #[cfg(feature = "enable-sia")] mod sia_coin_activation; mod slp_token_activation; +mod solana_with_assets; mod standalone_coin; mod tendermint_token_activation; mod tendermint_with_assets_activation; -mod solana_with_assets; mod token; mod utxo_activation; #[cfg(not(target_arch = "wasm32"))] diff --git a/mm2src/coins_activation/src/solana_with_assets.rs b/mm2src/coins_activation/src/solana_with_assets.rs index c40e9d080c..465aeebd2e 100644 --- a/mm2src/coins_activation/src/solana_with_assets.rs +++ b/mm2src/coins_activation/src/solana_with_assets.rs @@ -1,28 +1,78 @@ use async_trait::async_trait; -use coins::{my_tx_history_v2::TxHistoryStorage, solana::SolanaCoin, MmCoinEnum}; +use coins::{ + my_tx_history_v2::TxHistoryStorage, + solana::{SolanaCoin, SolanaInitError, SolanaProtocolInfo}, + CoinProtocol, MmCoinEnum, +}; use mm2_core::mm_ctx::MmArc; use mm2_err_handle::prelude::MmError; use mm2_number::BigDecimal; use rpc_task::RpcTaskHandleShared; +use serde::{Deserialize, Serialize}; use crate::{ context::CoinsActivationContext, platform_coin_with_tokens::{ - InitPlatformCoinWithTokensTask, InitPlatformCoinWithTokensTaskManagerShared, + EnablePlatformCoinWithTokensError, GetPlatformBalance, InitPlatformCoinWithTokensAwaitingStatus, + InitPlatformCoinWithTokensInProgressStatus, InitPlatformCoinWithTokensTask, + InitPlatformCoinWithTokensTaskManagerShared, InitPlatformCoinWithTokensUserAction, PlatformCoinWithTokensActivationOps, TokenAsMmCoinInitializer, }, + prelude::{ActivationRequestInfo, CurrentBlock, TryFromCoinProtocol, TxHistory}, }; +#[derive(Clone, Deserialize)] +pub struct SolanaActivationRequest {} + +impl TxHistory for SolanaActivationRequest { + fn tx_history(&self) -> bool { + todo!() + } +} + +impl ActivationRequestInfo for SolanaActivationRequest { + fn is_hw_policy(&self) -> bool { + todo!() + } +} + +impl TryFromCoinProtocol for SolanaProtocolInfo { + fn try_from_coin_protocol(proto: CoinProtocol) -> Result> { + todo!() + } +} + +#[derive(Clone, Serialize)] +pub struct SolanaActivationResult {} + +impl CurrentBlock for SolanaActivationResult { + fn current_block(&self) -> u64 { + todo!() + } +} + +impl GetPlatformBalance for SolanaActivationResult { + fn get_platform_balance(&self) -> Option { + todo!() + } +} + +impl From for EnablePlatformCoinWithTokensError { + fn from(err: SolanaInitError) -> Self { + todo!() + } +} + #[async_trait] impl PlatformCoinWithTokensActivationOps for SolanaCoin { - type ActivationRequest; - type PlatformProtocolInfo; - type ActivationResult; - type ActivationError; - - type InProgressStatus; - type AwaitingStatus; - type UserAction; + type ActivationRequest = SolanaActivationRequest; + type PlatformProtocolInfo = SolanaProtocolInfo; + type ActivationResult = SolanaActivationResult; + type ActivationError = SolanaInitError; + + type InProgressStatus = InitPlatformCoinWithTokensInProgressStatus; + type AwaitingStatus = InitPlatformCoinWithTokensAwaitingStatus; + type UserAction = InitPlatformCoinWithTokensUserAction; async fn enable_platform_coin( ctx: MmArc, From 203e2c791585d216d3dfbb618e68f2d912ef71d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Mon, 11 Aug 2025 12:29:30 +0300 Subject: [PATCH 6/7] feature gate solana implementation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/Cargo.toml | 1 + mm2src/coins/lp_coins.rs | 8 ++++++-- mm2src/coins/solana/solana_coin.rs | 2 ++ mm2src/coins_activation/Cargo.toml | 1 + mm2src/coins_activation/src/lib.rs | 1 + mm2src/coins_activation/src/solana_with_assets.rs | 2 ++ 6 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mm2src/coins/Cargo.toml b/mm2src/coins/Cargo.toml index 54564746c1..e6a50c43d1 100644 --- a/mm2src/coins/Cargo.toml +++ b/mm2src/coins/Cargo.toml @@ -10,6 +10,7 @@ enable-sia = [ "dep:blake2b_simd", "dep:sia-rust" ] +enable-solana = [] default = [] run-docker-tests = [] for-tests = ["dep:mocktopus"] diff --git a/mm2src/coins/lp_coins.rs b/mm2src/coins/lp_coins.rs index 3606a63088..2c6bdc7836 100644 --- a/mm2src/coins/lp_coins.rs +++ b/mm2src/coins/lp_coins.rs @@ -301,6 +301,7 @@ use crate::coin_balance::{BalanceObjectOps, HDWalletBalanceObject}; use crate::hd_wallet::{AddrToString, DisplayAddress}; use z_coin::{ZCoin, ZcoinProtocolInfo}; +#[cfg(feature = "enable-solana")] pub mod solana; pub type TransactionFut = Box + Send>; @@ -3723,9 +3724,10 @@ pub enum MmCoinEnum { TendermintToken(TendermintToken), #[cfg(not(target_arch = "wasm32"))] LightningCoin(LightningCoin), - Solana(solana::SolanaCoin), #[cfg(feature = "enable-sia")] SiaCoin(SiaCoin), + #[cfg(feature = "enable-solana")] + Solana(solana::SolanaCoin), #[cfg(any(test, feature = "for-tests"))] Test(TestCoin), } @@ -3792,6 +3794,7 @@ impl From for MmCoinEnum { } } +#[cfg(feature = "enable-solana")] impl From for MmCoinEnum { fn from(c: solana::SolanaCoin) -> MmCoinEnum { MmCoinEnum::Solana(c) @@ -3827,9 +3830,10 @@ impl Deref for MmCoinEnum { #[cfg(not(target_arch = "wasm32"))] MmCoinEnum::LightningCoin(ref c) => c, MmCoinEnum::ZCoin(ref c) => c, - MmCoinEnum::Solana(ref c) => c, #[cfg(feature = "enable-sia")] MmCoinEnum::SiaCoin(ref c) => c, + #[cfg(feature = "enable-solana")] + MmCoinEnum::Solana(ref c) => c, #[cfg(any(test, feature = "for-tests"))] MmCoinEnum::Test(ref c) => c, } diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index c5dc59c964..7a55eada8f 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -1,3 +1,5 @@ +#![allow(unused_variables)] + use std::ops::Deref; use std::sync::Arc; diff --git a/mm2src/coins_activation/Cargo.toml b/mm2src/coins_activation/Cargo.toml index dc9b2641f9..261a473444 100644 --- a/mm2src/coins_activation/Cargo.toml +++ b/mm2src/coins_activation/Cargo.toml @@ -8,6 +8,7 @@ doctest = false [features] enable-sia = [] +enable-solana = [] default = [] for-tests = [] diff --git a/mm2src/coins_activation/src/lib.rs b/mm2src/coins_activation/src/lib.rs index 9a2f5ded14..3adaf77327 100644 --- a/mm2src/coins_activation/src/lib.rs +++ b/mm2src/coins_activation/src/lib.rs @@ -12,6 +12,7 @@ mod prelude; #[cfg(feature = "enable-sia")] mod sia_coin_activation; mod slp_token_activation; +#[cfg(feature = "enable-solana")] mod solana_with_assets; mod standalone_coin; mod tendermint_token_activation; diff --git a/mm2src/coins_activation/src/solana_with_assets.rs b/mm2src/coins_activation/src/solana_with_assets.rs index 465aeebd2e..0ff0cd1a51 100644 --- a/mm2src/coins_activation/src/solana_with_assets.rs +++ b/mm2src/coins_activation/src/solana_with_assets.rs @@ -1,3 +1,5 @@ +#![allow(unused_variables)] + use async_trait::async_trait; use coins::{ my_tx_history_v2::TxHistoryStorage, From 42212e9ccf61be2b3b63fab333c3c4021d9a90e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20=C3=96zkan?= Date: Mon, 11 Aug 2025 12:39:40 +0300 Subject: [PATCH 7/7] bless clippy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Onur Özkan --- mm2src/coins/solana/solana_coin.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm2src/coins/solana/solana_coin.rs b/mm2src/coins/solana/solana_coin.rs index 7a55eada8f..ec6fcf598b 100644 --- a/mm2src/coins/solana/solana_coin.rs +++ b/mm2src/coins/solana/solana_coin.rs @@ -60,11 +60,11 @@ impl MmCoin for SolanaCoin { todo!() } - fn get_raw_transaction(&self, req: RawTransactionRequest) -> RawTransactionFut { + fn get_raw_transaction(&self, req: RawTransactionRequest) -> RawTransactionFut<'_> { todo!() } - fn get_tx_hex_by_hash(&self, tx_hash: Vec) -> RawTransactionFut { + fn get_tx_hex_by_hash(&self, tx_hash: Vec) -> RawTransactionFut<'_> { todo!() }