Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(solana-swap): solana swap protocol v1 POC #2091

Merged
merged 24 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
437f200
feat(solana-swap):solana swap protocol v1 POC
r2st Mar 27, 2024
30c96be
lint fixes
r2st Mar 27, 2024
25fc2a2
SolSignature lint fix
r2st Mar 29, 2024
880905a
fixes @shamardy
r2st Apr 1, 2024
911b68f
unwrap fixes
r2st Apr 1, 2024
934242d
lp swap
r2st Apr 2, 2024
4ab3ec9
SolTransaction is stored in TransactionEnum
r2st Apr 2, 2024
09f105f
error message fix
r2st Apr 2, 2024
ac8cc07
error message fix
r2st Apr 2, 2024
53e24bc
lint fix
r2st Apr 2, 2024
eb5d8f4
fix
r2st Apr 3, 2024
1e4bde6
match cases optimized
r2st Apr 3, 2024
79727db
feat(solana-swap): solana swaps poc dev merge
mj-blockydevs Jun 12, 2024
36441d5
feat(solana-swap): solana swaps poc dev merge
mj-blockydevs Jun 12, 2024
2bcd430
feat(solana-swap): solana swaps poc dev merge
mj-blockydevs Jun 12, 2024
0450285
feat(solana-swap): solana swaps poc dev merge cargo fmt
mj-blockydevs Jun 12, 2024
34e0b80
feat(solana-swap-v1): group uses, better function names, public funct…
mj-blockydevs Jun 14, 2024
d4768fe
feat(solana-swap-v1): group uses in tests file
mj-blockydevs Jun 14, 2024
1535e38
feat(solana-swaps-poc): solana 1.9.20 for now
mj-blockydevs Jun 17, 2024
1a33d71
feat(solana-swaps-poc): solana 1.9.20 integration
mj-blockydevs Jun 17, 2024
295f79f
feat(solana-swaps-poc): 1.18.2
mj-blockydevs Jun 18, 2024
515d4ff
feat(solana-swaps-poc): using dev version of the dependency
mj-blockydevs Jun 18, 2024
b6987a1
feat(solana-swaps-poc): rename the param hash to hex
mj-blockydevs Jun 21, 2024
1d07520
feat(solana-swaps-poc): update solana program id - setting the id of …
mj-blockydevs Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ use std::time::Duration;
use std::{fmt, iter};
use utxo_signer::with_key_pair::UtxoSignWithKeyPairError;
use zcash_primitives::transaction::Transaction as ZTransaction;

cfg_native! {
use crate::lightning::LightningCoin;
use crate::lightning::ln_conf::PlatformCoinConfirmationTargets;
Expand Down Expand Up @@ -125,6 +124,29 @@ macro_rules! try_f {
};
}

#[cfg(feature = "enable-solana")]
macro_rules! try_tx_fus_err {
($err: expr) => {
return Box::new(futures01::future::err(crate::TransactionErr::Plain(ERRL!(
"{:?}", $err
))))
};
}

#[cfg(feature = "enable-solana")]
macro_rules! try_tx_fus_opt {
($e: expr, $err: expr) => {
match $e {
Some(ok) => ok,
None => {
return Box::new(futures01::future::err(crate::TransactionErr::Plain(ERRL!(
"{:?}", $err
))))
},
}
};
}

/// `TransactionErr` compatible `try_fus` macro.
macro_rules! try_tx_fus {
($e: expr) => {
Expand Down Expand Up @@ -276,7 +298,7 @@ pub use solana::spl::SplToken;
not(target_os = "android"),
not(target_arch = "wasm32")
))]
pub use solana::{SolanaActivationParams, SolanaCoin, SolanaFeeDetails};
pub use solana::{SolTransaction, SolanaActivationParams, SolanaCoin, SolanaFeeDetails};

pub mod utxo;
use utxo::bch::{bch_coin_with_policy, BchActivationRequest, BchCoin};
Expand Down Expand Up @@ -607,6 +629,8 @@ pub trait Transaction: fmt::Debug + 'static {
pub enum TransactionEnum {
UtxoTx(UtxoTx),
SignedEthTx(SignedEthTx),
#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))]
SolTransaction(SolTransaction),
ZTransaction(ZTransaction),
CosmosTransaction(CosmosTransaction),
#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -615,6 +639,8 @@ pub enum TransactionEnum {

ifrom!(TransactionEnum, UtxoTx);
ifrom!(TransactionEnum, SignedEthTx);
#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))]
ifrom!(TransactionEnum, SolTransaction);
ifrom!(TransactionEnum, ZTransaction);
#[cfg(not(target_arch = "wasm32"))]
ifrom!(TransactionEnum, LightningPayment);
Expand All @@ -638,6 +664,8 @@ impl Deref for TransactionEnum {
TransactionEnum::CosmosTransaction(ref t) => t,
#[cfg(not(target_arch = "wasm32"))]
TransactionEnum::LightningPayment(ref p) => p,
#[cfg(all(feature = "enable-solana", not(target_arch = "wasm32")))]
TransactionEnum::SolTransaction(ref s) => s,
}
}
}
Expand Down Expand Up @@ -4843,7 +4871,7 @@ pub async fn my_tx_history(ctx: MmArc, req: Json) -> Result<Response<Vec<u8>>, S
}

/// `get_trade_fee` rpc implementation.
/// There is some consideration about this rpc:
/// There is some consideration about this rpc:
/// for eth coin this rpc returns max possible trade fee (estimated for maximum possible gas limit for any kind of swap).
/// However for eth coin, as part of fixing this issue https://github.com/KomodoPlatform/komodo-defi-framework/issues/1848,
/// `max_taker_vol' and `trade_preimage` rpc now return more accurate required gas calculations.
Expand Down
Loading
Loading