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

Support Send trait in the SDK #2235

Merged
merged 5 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .changelog/unreleased/SDK/2225-remove-sdk-lifetimes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Removed uses of lifetimes in the SDKs Namada trait and implementation
([\#2225](https://github.com/anoma/namada/pull/2225))
2 changes: 2 additions & 0 deletions .changelog/unreleased/SDK/2235-with-async.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Added Send trait support to the SDK to allow its use in more multithreaded
contexts. ([\#2235](https://github.com/anoma/namada/pull/2235))
74 changes: 43 additions & 31 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ index-set = {git = "https://github.com/heliaxdev/index-set", tag = "v0.8.0", fea
itertools = "0.10.0"
k256 = { version = "0.13.0", default-features = false, features = ["ecdsa", "pkcs8", "precomputed-tables", "serde", "std"]}
lazy_static = "1.4.0"
ledger-namada-rs = { git = "https://github.com/heliaxdev/ledger-namada", rev = "7e861c440de0fdabaf51e30d97f5c8736be348f3" }
ledger-namada-rs = { git = "https://github.com/Zondax/ledger-namada", tag = "v0.0.12" }
ledger-transport-hid = "0.10.0"
libc = "0.2.97"
libloading = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion apps/src/bin/namada-client/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async fn main() -> Result<()> {
CliApi::handle_client_command::<HttpClient, _>(
None,
cli::namada_client_cli()?,
&CliIo,
CliIo,
)
.await
}
2 changes: 1 addition & 1 deletion apps/src/bin/namada-relayer/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ async fn main() -> Result<()> {

let cmd = cli::namada_relayer_cli()?;
// run the CLI
CliApi::handle_relayer_command::<HttpClient>(None, cmd, &CliIo).await
CliApi::handle_relayer_command::<HttpClient>(None, cmd, CliIo).await
}
33 changes: 23 additions & 10 deletions apps/src/lib/bench_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub use namada_sdk::tx::{
TX_WITHDRAW_WASM, VP_USER_WASM, VP_VALIDATOR_WASM,
};
use namada_sdk::wallet::Wallet;
use namada_sdk::NamadaImpl;
use namada_sdk::{Namada, NamadaImpl};
use namada_test_utils::tx_data::TxWriteData;
use rand_core::OsRng;
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -819,11 +819,11 @@ impl Default for BenchShieldedCtx {

impl BenchShieldedCtx {
pub fn generate_masp_tx(
&mut self,
mut self,
amount: Amount,
source: TransferSource,
target: TransferTarget,
) -> Tx {
) -> (Self, Tx) {
let denominated_amount = DenominatedAmount {
amount,
denom: 0.into(),
Expand All @@ -840,12 +840,13 @@ impl BenchShieldedCtx {
&[],
))
.unwrap();
let native_token = self.shell.wl_storage.storage.native_token.clone();
let namada = NamadaImpl::native_new(
&self.shell,
&mut self.wallet,
&mut self.shielded,
&StdIo,
self.shell.wl_storage.storage.native_token.clone(),
self.shell,
self.wallet,
self.shielded,
StdIo,
native_token,
);
let shielded = async_runtime
.block_on(
Expand Down Expand Up @@ -877,7 +878,7 @@ impl BenchShieldedCtx {
)
});

self.shell.generate_tx(
let tx = namada.client().generate_tx(
TX_TRANSFER_WASM,
Transfer {
source: source.effective_address(),
Expand All @@ -890,6 +891,18 @@ impl BenchShieldedCtx {
shielded,
None,
vec![&defaults::albert_keypair()],
)
);
let NamadaImpl {
client,
wallet,
shielded,
..
} = namada;
let ctx = Self {
shielded: shielded.into_inner(),
shell: client,
wallet: wallet.into_inner(),
};
(ctx, tx)
}
}
Loading
Loading