1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! Cosmwasm smart contract orchestration and gas profiling tool
//!
//! Store, instantiate, execute, and query [Cosmwasm] smart contracts against a configured [Cosmos] based chain.
//! Optionally, profile gas usage of the smart contract operations.
//!
//! Potential uses:
//! * Integration tests
//! * Deployments / Bootstrapping environments
//! * Gas profiling
//!
//! [cosmwasm]: https://github.com/CosmWasm/cosmwasm
//! [Cosmos]: https://github.com/cosmos/cosmos-sdk
//!
//!
//! # Quick Start
//!
//! ```no_run
//! # use std::error::Error;
//! # use cosm_orc::{
//! # config::cfg::Config,
//! # orchestrator::cosm_orc::{CosmOrc, WasmMsg},
//! # };
//! # use cosm_orc::config::key::SigningKey;
//! # use cosm_orc::config::key::Key;
//! # use cw20_base::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
//! # fn main() -> Result<(), Box<dyn Error>> {
//! // juno_local.yaml has the cw20_base code_id already stored
//! // If the smart contract has not been stored on the chain yet use: `cosm_orc::store_contracts()`
//! let mut cosm_orc = CosmOrc::new(Config::from_yaml("./example-configs/juno_local.yaml")?)?;
//!
//! let key = SigningKey {
//! name: "validator".to_string(),
//! key: Key::Mnemonic("word1 word2 ...".to_string()),
//! };
//!
//! let msgs: Vec<WasmMsg<InstantiateMsg, ExecuteMsg, QueryMsg>> = vec![
//! WasmMsg::InstantiateMsg(InstantiateMsg {
//! name: "Meme Token".to_string(),
//! symbol: "MEME".to_string(),
//! decimals: 6,
//! initial_balances: vec![],
//! mint: None,
//! marketing: None,
//! }),
//! WasmMsg::QueryMsg(QueryMsg::TokenInfo {}),
//! ];
//!
//! cosm_orc.process_msgs("cw20_base", "meme_token_test", &msgs, &key)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Store Contracts
//!
//! If `config.yaml` doesn't have the pre-stored contract code ids, you can call `store_contracts()`:
//!
//! ```no_run
//! # use std::error::Error;
//! # use cosm_orc::{
//! # config::cfg::Config,
//! # orchestrator::cosm_orc::{CosmOrc, WasmMsg},
//! # };
//! # use cosm_orc::config::key::SigningKey;
//! # use cosm_orc::config::key::Key;
//! # use cw20_base::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
//! # fn main() -> Result<(), Box<dyn Error>> {
//! let mut cosm_orc = CosmOrc::new(Config::from_yaml("./example-configs/juno_local.yaml")?)?;
//!
//! let key = SigningKey {
//! name: "validator".to_string(),
//! key: Key::Mnemonic("word1 word2 ...".to_string()),
//! };
//!
//! // `./artifacts` is a directory that contains the rust optimized wasm files.
//! //
//! // NOTE: currently cosm-orc is expecting a wasm filed called: `cw20_base.wasm`
//! // to be in `/artifacts`, since `cw20_base` is used as the contract name in process_msgs() call below
//! cosm_orc.store_contracts("./artifacts", &key)?;
//!
//! let msgs: Vec<WasmMsg<InstantiateMsg, ExecuteMsg, QueryMsg>> = vec![
//! WasmMsg::InstantiateMsg(InstantiateMsg {
//! name: "Meme Token".to_string(),
//! symbol: "MEME".to_string(),
//! decimals: 6,
//! initial_balances: vec![],
//! mint: None,
//! marketing: None,
//! }),
//! WasmMsg::QueryMsg(QueryMsg::TokenInfo {}),
//! ];
//!
//! cosm_orc.process_msgs("cw20_base", "meme_token_test", &msgs, &key)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Gas Profiling
//!
//! ```no_run
//! # use std::error::Error;
//! # use cosm_orc::{
//! # config::cfg::Config,
//! # orchestrator::cosm_orc::{CosmOrc, WasmMsg},
//! # profilers::gas_profiler::GasProfiler,
//! # };
//! # use cosm_orc::config::key::SigningKey;
//! # use cosm_orc::config::key::Key;
//! # use cw20_base::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
//! # fn main() -> Result<(), Box<dyn Error>> {
//! let mut cosm_orc =
//! CosmOrc::new(Config::from_yaml("config.yaml")?)?.add_profiler(Box::new(GasProfiler::new()));
//!
//! let key = SigningKey {
//! name: "validator".to_string(),
//! key: Key::Mnemonic("word1 word2 ...".to_string()),
//! };
//!
//! // `./artifacts` is a directory that contains the rust optimized wasm files.
//! //
//! // NOTE: currently cosm-orc is expecting a wasm filed called: `cw20_base.wasm`
//! // to be in `/artifacts`, since `cw20_base` is used as the contract name in process_msgs() call below
//! cosm_orc.store_contracts("./artifacts", &key)?;
//!
//! let msgs: Vec<WasmMsg<InstantiateMsg, ExecuteMsg, QueryMsg>> = vec![
//! WasmMsg::InstantiateMsg(InstantiateMsg {
//! name: "Meme Token".to_string(),
//! symbol: "MEME".to_string(),
//! decimals: 6,
//! initial_balances: vec![],
//! mint: None,
//! marketing: None,
//! }),
//! WasmMsg::QueryMsg(QueryMsg::TokenInfo {}),
//! ];
//!
//! cosm_orc.process_msgs("cw20_base", "meme_token_test", &msgs, &key)?;
//! let reports = cosm_orc.profiler_reports()?;
//! # Ok(())
//! # }
//! ```
//!