Skip to content

Commit

Permalink
wasm upload fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Buckram123 committed Oct 8, 2024
1 parent 991293f commit ecca95d
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions cw-orch-cli/src/commands/action/cosmwasm/store/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{commands::action::CosmosContext, types::keys::seed_phrase_for_id};

use color_eyre::eyre::Context;
use cw_orch::{daemon::TxSender, prelude::*};
use cw_orch::prelude::*;

#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
#[interactive_clap(input_context = CosmosContext)]
Expand All @@ -28,39 +27,17 @@ impl StoreWasmOutput {
scope:&<StoreContractCommands as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope,
) -> color_eyre::eyre::Result<Self> {
let chain = previous_context.chain;
let wasm_byte_code = std::fs::read(&scope.wasm_path).wrap_err(format!(
"Failed to open or read the file: {}",
scope.wasm_path.0.display()
))?;
let wasm_path = WasmPath::new(&scope.wasm_path)?;

let seed = seed_phrase_for_id(&scope.signer)?;
let daemon = chain.daemon(seed)?;

let upload_msg = cosmrs::cosmwasm::MsgStoreCode {
sender: daemon.sender().account_id(),
wasm_byte_code,
instantiate_permission: None,
};
let resp = daemon
.rt_handle
.block_on(daemon.sender().commit_tx(vec![upload_msg], None))?;
.block_on(daemon.sender().upload_wasm(wasm_path))?;
let code_id = resp.uploaded_code_id().unwrap();
println!("code_id: {code_id}");

Ok(StoreWasmOutput)
}
}

// TODO: the dream here to use Uploadable instead
// fn uploadable_from_path(wasm_path: WasmPath) -> impl Uploadable {
// struct Placeholder {
// wasm_path: WasmPath,
// }
// impl Uploadable for Placeholder {
// fn wasm(_chain: &ChainInfoOwned) -> WasmPath {
// // having &self.wasm_path instead would solve the issue
// wasm_path
// }
// }
// Placeholder { wasm_path }
// }

0 comments on commit ecca95d

Please sign in to comment.