Skip to content

Commit

Permalink
Ywallet integration wip
Browse files Browse the repository at this point in the history
  • Loading branch information
hhanh00 committed Sep 16, 2024
1 parent a0a7387 commit 47b25d2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dart-warp
17 changes: 10 additions & 7 deletions warp-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ pub fn c_export(_attr: TokenStream, item: TokenStream) -> TokenStream {
let ident = &param.ident;
let name = ident.to_string();
match name.as_str() {
"coin" => {
continue;
}
"network" => {
has_network = true;
continue;
Expand Down Expand Up @@ -216,35 +219,35 @@ pub fn c_export(_attr: TokenStream, item: TokenStream) -> TokenStream {

let network = if has_network {
quote! {
let network = &coin.network.clone();
let network = &coin_def.network.clone();
}
} else {
quote! {}
};
let url = if has_url {
quote! {
let url = coin.url.clone();
let url = coin_def.config.lwd_url.clone().unwrap();
}
} else {
quote! {}
};
let connection = if has_connection {
if mut_connection {
quote! {
let mut connection = coin.connection()?;
let mut connection = coin_def.connection()?;
let connection: &mut rusqlite::Connection = &mut connection;
}
} else {
quote! {
let connection = &coin.connection()?;
let connection = &coin_def.connection()?;
}
}
} else {
quote! {}
};
let client = if has_client {
quote! {
let mut client = coin.connect_lwd().await?;
let mut client = coin_def.connect_lwd().await?;
let client = &mut client;
}
} else {
Expand Down Expand Up @@ -272,7 +275,7 @@ pub fn c_export(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[tokio::main]
pub async extern "C" fn #wrapper(coin: u8, #(#wrapped_fnargs),*) -> CResult<#c_result_type> {
let res = async {
let coin = {
let coin_def = {
let c = COINS[coin as usize].lock();
c.clone()
};
Expand All @@ -294,7 +297,7 @@ pub fn c_export(_attr: TokenStream, item: TokenStream) -> TokenStream {
#[no_mangle]
pub extern "C" fn #wrapper(coin: u8, #(#wrapped_fnargs),*) -> CResult<#c_result_type> {
let res = || {
let coin = {
let coin_def = {
let c = COINS[coin as usize].lock();
c.clone()
};
Expand Down

0 comments on commit 47b25d2

Please sign in to comment.