Skip to content
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.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unpublished

- Add methods to set the private key and mnemonic of an existing sender

### Breaking

## 0.25.0
Expand Down
4 changes: 3 additions & 1 deletion cw-orch-daemon/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! This regroups all env variables used by cw-orch-daemon. It allows for easier documentation and env variable management
//! This regroups all env variables used by cw-orch-daemon.
//!
//! It allows for easier documentation and env variable management
//! This is used to import environment variables with safe names (and at a centralized location)
//! To get the env variable parsed value, you can use
//! ```rust,no_run
Expand Down
22 changes: 22 additions & 0 deletions cw-orch-daemon/src/senders/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ impl Wallet {
self.options.clone()
}

/// Replaces the private key that the [CosmosSender] is using with key derived from the provided 24-word mnemonic.
/// If you want more control over the derived private key, use [Self::set_private_key]
pub fn set_mnemonic(&mut self, mnemonic: impl Into<String>) -> Result<(), DaemonError> {
let secp = Secp256k1::new();

let pk = PrivateKey::from_words(
&secp,
&mnemonic.into(),
0,
self.options.hd_index.unwrap_or(0),
self.chain_info.network_info.coin_type,
)?;
self.set_private_key(pk);
Ok(())
}

/// Replaces the private key the sender is using
/// You can use a mnemonic to overwrite the key using [Self::set_mnemonic]
pub fn set_private_key(&mut self, private_key: PrivateKey) {
self.private_key = private_key
}

pub fn set_authz_granter(&mut self, granter: &Addr) {
self.options.authz_granter = Some(granter.to_owned());
}
Expand Down
4 changes: 3 additions & 1 deletion packages/cw-orch-core/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! This regroups all env variables used by cw-orch-daemon. It allows for easier documentation and env variable management
//! This regroups all env variables used by cw-orch-daemon.
//!
//! It allows for easier documentation and env variable management
//! This is used to import environment variables with safe names (and at a centralized location)
//! To get the env variable parsed value, you can use
//! ```rust,no_run
Expand Down