Skip to content

Commit

Permalink
native SOL
Browse files Browse the repository at this point in the history
  • Loading branch information
doradelta committed Nov 20, 2024
1 parent e0f3dce commit 127f972
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 101 deletions.
61 changes: 49 additions & 12 deletions user/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions user/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ rand = "0.8.5"
solana-client = "1.8.3"
serde = { version = "1.0", features = ["derive"] }
clap = "4.5.20"
spl-token = { version = "3.2.0", default-features = false, features = ["no-entrypoint"] }
spl-associated-token-account = { version = "3.0.2", default-features = false, features = ["no-entrypoint"] }
bridge-escrow = { git = "https://github.com/ComposableFi/emulated-light-client.git", branch = "upgrade" }
solana-ibc = { git = "https://github.com/ComposableFi/emulated-light-client.git", branch = "fast-bridge", features = ["cpi"] }
Expand Down
18 changes: 9 additions & 9 deletions user/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::Pubkey;
use clap::{Arg, ArgMatches, Command};
use std::str::FromStr;
use crate::Pubkey;

pub fn parse_cli() -> ArgMatches {
Command::new("Mantis SDK Intent CLI")
Expand Down Expand Up @@ -50,23 +50,23 @@ pub fn common_args() -> Vec<Arg> {
vec![
Arg::new("amount_in")
.required(true)
.value_parser(clap::value_parser!(u64))
.value_parser(clap::value_parser!(u64))
.help("Amount in tokens"),
Arg::new("token_in")
.required(true)
.value_parser(clap::value_parser!(String))
.help("Token input address"),
Arg::new("token_out")
.required(true)
.value_parser(clap::value_parser!(String))
.value_parser(clap::value_parser!(String))
.help("Token output address"),
Arg::new("amount_out")
.required(true)
.value_parser(clap::value_parser!(String))
.value_parser(clap::value_parser!(String))
.help("Amount out in tokens"),
Arg::new("timeout")
.required(true)
.value_parser(clap::value_parser!(u64))
.value_parser(clap::value_parser!(u64))
.help("Timeout duration in seconds"),
]
}
Expand All @@ -90,18 +90,18 @@ fn common_args_ethereum() -> Vec<Arg> {
.help("Token input address"),
Arg::new("amount_in")
.required(true)
.value_parser(clap::value_parser!(u64))
.value_parser(clap::value_parser!(u64))
.help("Amount in tokens"),
Arg::new("token_out")
.required(true)
.help("Token output address"),
Arg::new("amount_out")
.required(true)
.value_parser(clap::value_parser!(u64))
.value_parser(clap::value_parser!(u64))
.help("Amount out in tokens"),
Arg::new("timeout")
.required(true)
.value_parser(clap::value_parser!(u64))
.value_parser(clap::value_parser!(u64))
.help("Timeout duration in seconds"),
]
}
Expand All @@ -115,4 +115,4 @@ fn cross_domain_args_ethereum() -> Vec<Arg> {
.help("Destination user address"),
);
args
}
}
27 changes: 15 additions & 12 deletions user/src/ethereum.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::env;
use ethers::prelude::*;
use ethers::providers::{Http, Provider};
use std::str::FromStr;
use std::sync::Arc;
use crate::env;

abigen!(
Escrow,
Expand Down Expand Up @@ -58,7 +58,7 @@ pub async fn escrow_and_store_intent_ethereum(
single_domain: bool,
timeout: U256,
) -> Result<TransactionReceipt, Box<dyn std::error::Error>> {
let contract_address = "0x64E78873057769a5fd9A2278E6820666ec7e87f9"; // Escrow Contract
let contract_address = "0x393D402F48F0F468030082b5410a58cA2231FD34"; // Escrow Contract
let private_key = env::var("ETHEREUM_PKEY").expect("ETHEREUM_PKEY must be set");
let rpc_url = env::var("ETHEREUM_RPC").expect("ETHEREUM_RPC must be set");

Expand All @@ -79,24 +79,27 @@ pub async fn escrow_and_store_intent_ethereum(
}

let intent = (
token_in, // token_in passed as parameter
amount_in, // amount_in passed as parameter
src_user, // src_user passed as parameter
token_out, // token_out passed as parameter
amount_out, // amount_out passed as parameter
dst_user, // dst_user determined based on single/cross domain
"".to_string(), // winner_solver (currently empty, can be passed as needed)
timeout, // timeout passed as parameter
token_in, // token_in passed as parameter
amount_in, // amount_in passed as parameter
src_user, // src_user passed as parameter
token_out, // token_out passed as parameter
amount_out, // amount_out passed as parameter
dst_user, // dst_user determined based on single/cross domain
"".to_string(), // winner_solver (currently empty, can be passed as needed)
timeout, // timeout passed as parameter
);

let value = if single_domain {
U256::zero()
let mut value = U256::zero();
if token_in == H160::from_str("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE").unwrap() {
value = amount_in;
}
value
} else {
let mut value = U256::from_dec_str("12100000000000000").unwrap();
if token_in == H160::from_str("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE").unwrap() {
value += amount_in;
}

value
};

Expand Down
Loading

0 comments on commit 127f972

Please sign in to comment.