Skip to content

Commit 20a4612

Browse files
authored
Release/0.23 (#416)
* Changed versions * Version updates * Version * Description * Better makefile * Added starship update * Added Clone * version * Added remove state in trait * Added remove * Added ibctxanalyssis to check ibc return * Updated docs and starship
1 parent 1e5e4fa commit 20a4612

File tree

33 files changed

+169
-66
lines changed

33 files changed

+169
-66
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cw-orchestrator Changelog
22

3-
## Unreleased
3+
## 0.23.0
44

55
- Added a test to make sure the derive macros stay compatible with new cw-orch versions
66
- Changed the derive macros import from cw_orch to cw_orch_core. This allows changing the cw-orch API without breaking the derive macros.
@@ -19,6 +19,7 @@
1919
- Writing to a file happens when all Daemon's that use same file dropped instead of hot writes
2020
- `force_write` added to the `DaemonState` to allow force write of the state
2121
- Added `event_attr_values` to get all the attribute values corresponding to a key
22+
- Added `remove_{address,code_id}` functions to be able to erase an entry in state. Involves core, mock, daemon, osmosis-test-tube, clone-testing
2223
- Added `state` to DaemonBuilder to be able to share state between daemons
2324

2425
### Breaking

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,29 @@ anyhow = "1.0"
3535
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
3636
tokio = { version = "1.4", features = ["full"] }
3737

38-
cw-orch = { path = "./cw-orch", version = "0.22.0" }
39-
cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.22.0" }
40-
cw-orch-core = { path = "packages/cw-orch-core", version = "1.0.0" }
38+
cw-orch = { path = "./cw-orch", version = "0.23.0" }
39+
cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.23.2" }
40+
cw-orch-core = { path = "packages/cw-orch-core", version = "1.1.1" }
4141
cw-orch-traits = { path = "packages/cw-orch-traits", version = "0.22.0" }
4242
cw-orch-mock = { path = "packages/cw-orch-mock", version = "0.22.0" }
4343
cw-orch-networks = { path = "packages/cw-orch-networks", version = "0.22.0" }
4444

4545
# Macros
4646
cw-orch-contract-derive = { path = "packages/macros/cw-orch-contract-derive", version = "0.21.0" }
47-
cw-orch-fns-derive = { path = "packages/macros/cw-orch-fns-derive", version = "0.20.0" }
47+
cw-orch-fns-derive = { path = "packages/macros/cw-orch-fns-derive", version = "0.21.0" }
4848

4949
# Extensions
5050
cw-orch-osmosis-test-tube = { version = "0.1.0", path = "packages/cw-orch-osmosis-test-tube" }
5151

5252
# Interchain
53-
cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.2.0" }
54-
cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.2.0" }
55-
cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.2.0" }
56-
cw-orch-starship = { path = "packages/interchain/starship", version = "0.2.0" }
53+
cw-orch-interchain = { path = "cw-orch-interchain", version = "0.2.0" }
54+
cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.3.0" }
55+
cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.3.2" }
56+
cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.3.1" }
57+
cw-orch-starship = { path = "packages/interchain/starship", version = "0.3.0" }
5758

5859
#Clone Testing
59-
cw-orch-clone-testing = { version = "0.4.1", path = "packages/clone-testing" }
60+
cw-orch-clone-testing = { version = "0.5.0", path = "packages/clone-testing" }
6061

6162

6263
thiserror = { version = "1.0.21" }

cw-orch-daemon/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-daemon"
3-
version = "0.22.2"
3+
version = "0.23.3"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
license = { workspace = true }

cw-orch-daemon/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub enum DaemonError {
124124
Instantiate2Error(#[from] Instantiate2AddressError),
125125
#[error("Error opening file {0},err: ({1})")]
126126
OpenFile(String, String),
127-
#[error("State file {0} already locked, use another state file or clone daemon which holds the lock")]
127+
#[error("State file {0} already locked, use another state file, clone daemon which holds the lock, or use `state` method of Builder")]
128128
StateAlreadyLocked(String),
129129
}
130130

cw-orch-daemon/src/state.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,25 @@ impl DaemonState {
192192
Ok(())
193193
}
194194

195+
/// Remove a stateful value using the chainId and networkId
196+
pub fn remove(&mut self, key: &str, contract_id: &str) -> Result<(), DaemonError> {
197+
let json_file_state = match &mut self.json_state {
198+
DaemonStateFile::ReadOnly { path } => {
199+
return Err(DaemonError::StateReadOnly(path.clone()))
200+
}
201+
DaemonStateFile::FullAccess { json_file_state } => json_file_state,
202+
};
203+
204+
let mut json_file_lock = json_file_state.lock().unwrap();
205+
let val = json_file_lock.get_mut(
206+
&self.chain_data.network_info.chain_name,
207+
&self.chain_data.chain_id,
208+
);
209+
val[key][contract_id] = Value::Null;
210+
211+
Ok(())
212+
}
213+
195214
/// Forcefully write current json to a file
196215
pub fn force_write(&mut self) -> Result<(), DaemonError> {
197216
let json_file_state = match &mut self.json_state {
@@ -247,6 +266,11 @@ impl StateInterface for DaemonState {
247266
.unwrap();
248267
}
249268

269+
fn remove_address(&mut self, contract_id: &str) {
270+
let deployment_id = self.deployment_id.clone();
271+
self.remove(&deployment_id, contract_id).unwrap();
272+
}
273+
250274
/// Get the locally-saved version of the contract's version on this network
251275
fn get_code_id(&self, contract_id: &str) -> Result<u64, CwEnvError> {
252276
let value = self
@@ -262,6 +286,9 @@ impl StateInterface for DaemonState {
262286
fn set_code_id(&mut self, contract_id: &str, code_id: u64) {
263287
self.set("code_ids", contract_id, code_id).unwrap();
264288
}
289+
fn remove_code_id(&mut self, contract_id: &str) {
290+
self.remove("code_ids", contract_id).unwrap();
291+
}
265292

266293
/// Get all addresses for deployment id from state file
267294
fn get_all_addresses(&self) -> Result<HashMap<String, Addr>, CwEnvError> {

cw-orch-interchain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-interchain"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
license = { workspace = true }

cw-orch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch"
3-
version = "0.22.3"
3+
version = "0.23.0"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
license = { workspace = true }

cw-orch/src/prelude.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,3 @@ pub use cw_orch_traits::*;
6868

6969
#[cfg(feature = "snapshot-testing")]
7070
pub use crate::take_storage_snapshot;
71-
72-
#[cfg(feature = "interchain")]
73-
/// Everything that concerns interchain capabilities
74-
pub mod interchain {
75-
pub use cw_orch_interchain_core::{IbcQueryHandler, InterchainEnv};
76-
pub use cw_orch_interchain_daemon::{
77-
ChannelCreationValidator, ChannelCreator, DaemonInterchainEnv,
78-
};
79-
pub use cw_orch_interchain_mock::{MockBech32InterchainEnv, MockInterchainEnv};
80-
pub use cw_orch_starship::Starship;
81-
}
82-
#[cfg(feature = "interchain")]
83-
pub use interchain::*;

docs/src/integrations/daemon.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ This simple script actually hides another parameter which is the `LOCAL_MNEMONIC
2121
>
2222
> Under the hood, the `DaemonBuilder` struct creates a `tokio::Runtime`. Be careful because this builder is not usable in an `async` function. In such function, you can use <a href="https://docs.rs/cw-orch/latest/cw_orch/daemon/struct.DaemonAsync.html" target="_blank">`DaemonAsync`</a>
2323
24+
<div class="warning">
25+
26+
When using multiple Daemons with the same state file, you should re-use a single Daemon State to avoid conflicts and panics:
27+
28+
```rust,ignore
29+
let daemon1 = Daemon::builder()
30+
.chain(OSMOSIS_1)
31+
.build()?;
32+
// If you don't use the `state` method here, this will fail with:
33+
// State file <file-name> already locked, use another state file, clone daemon which holds the lock, or use `state` method of Builder
34+
let daemon2 = Daemon::builder()
35+
.chain(JUNO_1)
36+
.state(daemon1.state())
37+
.build()?;
38+
```
39+
40+
41+
</div>
42+
43+
44+
2445
## Interacting with contracts
2546

2647
You can then use the resulting `Daemon` variable to interact with your [contracts](../contracts/index.md):

packages/clone-testing/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-clone-testing"
3-
version = "0.4.1"
3+
version = "0.5.1"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

packages/clone-testing/src/core.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,8 @@ mod test {
454454
use cw_orch_core::environment::QueryHandler;
455455
use cw_orch_daemon::networks::JUNO_1;
456456
use cw_orch_mock::cw_multi_test::{Contract as MockContract, ContractWrapper};
457-
use serde::Serialize;
458457
use speculoos::prelude::*;
459458

460-
#[derive(Debug, Serialize)]
461-
struct MigrateMsg {}
462459
pub struct MockCw20;
463460

464461
fn execute(

packages/clone-testing/src/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ impl StateInterface for MockState {
5151
.insert(contract_id.to_string(), address.to_owned());
5252
}
5353

54+
fn remove_address(&mut self, contract_id: &str) {
55+
self.addresses.remove(contract_id);
56+
}
57+
5458
/// Get the locally-saved version of the contract's version on this network
5559
fn get_code_id(&self, contract_id: &str) -> Result<u64, CwEnvError> {
5660
self.code_ids
@@ -66,6 +70,10 @@ impl StateInterface for MockState {
6670
self.code_ids.insert(contract_id.to_string(), code_id);
6771
}
6872

73+
fn remove_code_id(&mut self, contract_id: &str) {
74+
self.code_ids.remove(contract_id);
75+
}
76+
6977
fn get_all_addresses(&self) -> Result<HashMap<String, Addr>, CwEnvError> {
7078
let mock_addresses = self.addresses.clone();
7179
let daemon_addresses = self.daemon_state.get_all_addresses().unwrap_or_default();

packages/cw-orch-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-core"
3-
version = "1.0.0"
3+
version = "1.1.1"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
license = { workspace = true }

packages/cw-orch-core/src/contract/contract_instance.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ impl<Chain: ChainState> Contract<Chain> {
7171
self.chain.state().set_address(&self.id, address)
7272
}
7373

74+
/// Remove state address for contract
75+
pub fn remove_address(&self) {
76+
self.chain.state().remove_address(&self.id)
77+
}
78+
7479
/// Returns state code_id for contract
7580
pub fn code_id(&self) -> Result<u64, CwEnvError> {
7681
let state_code_id = self.chain.state().get_code_id(&self.id);
@@ -83,6 +88,10 @@ impl<Chain: ChainState> Contract<Chain> {
8388
pub fn set_code_id(&self, code_id: u64) {
8489
self.chain.state().set_code_id(&self.id, code_id)
8590
}
91+
/// Remove state code_id for contract
92+
pub fn remove_code_id(&self) {
93+
self.chain.state().remove_code_id(&self.id)
94+
}
8695
}
8796

8897
/// Expose chain and state function to call them on the contract

packages/cw-orch-core/src/contract/interface_traits.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ pub trait ContractInstance<Chain: ChainState> {
4747
Contract::set_address(self.as_instance(), address)
4848
}
4949

50+
/// Removes the address for the contract
51+
fn remove_address(&self) {
52+
Contract::remove_address(self.as_instance())
53+
}
54+
5055
/// Sets a default address for the contract. If the contract already has an address registered in the state, this won't be used.
5156
/// This is mostly used to ship address with a cw-orch package.
5257
fn set_default_address(&mut self, address: &Addr) {
@@ -59,6 +64,11 @@ pub trait ContractInstance<Chain: ChainState> {
5964
Contract::set_code_id(self.as_instance(), code_id)
6065
}
6166

67+
/// Removes the code_id for the contract
68+
fn remove_code_id(&self) {
69+
Contract::remove_code_id(self.as_instance())
70+
}
71+
6272
/// Sets a default address for the contract. If the contract already has an address registered in the state, this won't be used.
6373
/// This is mostly used to ship address with a cw-orch package.
6474
fn set_default_code_id(&mut self, code_id: u64) {

packages/cw-orch-core/src/environment/state.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,24 @@ pub trait StateInterface: Clone {
2121
/// Set the address of a contract using the specified contract id.
2222
fn set_address(&mut self, contract_id: &str, address: &Addr);
2323

24+
/// Removes the address of a contract using the specified contract id.
25+
fn remove_address(&mut self, _contract_id: &str) {
26+
// Using default impl to avoid breaking changes
27+
unimplemented!()
28+
}
29+
2430
/// Get the code id for a contract with the specified contract id.
2531
fn get_code_id(&self, contract_id: &str) -> Result<u64, CwEnvError>;
2632

2733
/// Set the code id for a contract with the specified contract id.
2834
fn set_code_id(&mut self, contract_id: &str, code_id: u64);
2935

36+
/// Removes the code id for a contract with the specified contract id.
37+
fn remove_code_id(&mut self, _contract_id: &str) {
38+
// Using default impl to avoid breaking changes
39+
unimplemented!()
40+
}
41+
3042
/// Get all addresses related to this deployment.
3143
fn get_all_addresses(&self) -> Result<HashMap<String, Addr>, CwEnvError>;
3244

@@ -58,6 +70,14 @@ impl<S: StateInterface> StateInterface for Rc<RefCell<S>> {
5870
fn get_all_code_ids(&self) -> Result<HashMap<String, u64>, CwEnvError> {
5971
(**self).borrow().get_all_code_ids()
6072
}
73+
74+
fn remove_address(&mut self, contract_id: &str) {
75+
(**self).borrow_mut().remove_address(contract_id)
76+
}
77+
78+
fn remove_code_id(&mut self, contract_id: &str) {
79+
(**self).borrow_mut().remove_code_id(contract_id)
80+
}
6181
}
6282

6383
impl<S: StateInterface> StateInterface for Rc<S> {

packages/cw-orch-mock/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-mock"
3-
version = "0.22.2"
3+
version = "0.22.4"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

packages/cw-orch-mock/src/core.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,13 @@ mod test {
255255
};
256256
use cw_multi_test::ContractWrapper;
257257
use cw_orch_core::environment::{BankQuerier, DefaultQueriers, QueryHandler};
258-
use serde::Serialize;
259258
use speculoos::prelude::*;
260259

261260
use crate::core::*;
262261

263262
const SENDER: &str = "cosmos123";
264263
const BALANCE_ADDR: &str = "cosmos456";
265264

266-
#[derive(Debug, Serialize)]
267-
struct MigrateMsg {}
268-
269265
fn execute(
270266
_deps: DepsMut,
271267
_env: Env,

packages/cw-orch-mock/src/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ impl StateInterface for MockState {
6161
.insert(contract_id.to_string(), address.to_owned());
6262
}
6363

64+
fn remove_address(&mut self, contract_id: &str) {
65+
self.addresses.remove(contract_id);
66+
}
67+
6468
/// Get the locally-saved version of the contract's version on this network
6569
fn get_code_id(&self, contract_id: &str) -> Result<u64, CwEnvError> {
6670
self.code_ids
@@ -74,6 +78,10 @@ impl StateInterface for MockState {
7478
self.code_ids.insert(contract_id.to_string(), code_id);
7579
}
7680

81+
fn remove_code_id(&mut self, contract_id: &str) {
82+
self.code_ids.remove(contract_id);
83+
}
84+
7785
fn get_all_addresses(&self) -> Result<HashMap<String, Addr>, CwEnvError> {
7886
Ok(self.addresses.clone())
7987
}

packages/cw-orch-networks/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-networks"
3-
version = "0.22.0"
3+
version = "0.22.1"
44
authors = { workspace = true }
55
edition = { workspace = true }
66
license = { workspace = true }

packages/cw-orch-osmosis-test-tube/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "cw-orch-osmosis-test-tube"
3-
version = "0.1.0"
3+
version = "0.1.1"
4+
description = "Cw-orch environment adapter for osmosis-test-tube"
45
authors.workspace = true
56
edition.workspace = true
67
license.workspace = true

packages/interchain/interchain-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cw-orch-interchain-core"
3-
version = "0.2.0"
3+
version = "0.3.2"
44
authors.workspace = true
55
edition.workspace = true
66
license.workspace = true

0 commit comments

Comments
 (0)