From cbf5687e2d3f775a47df30075f18bd6b5e14ef50 Mon Sep 17 00:00:00 2001 From: Kayanski Date: Wed, 8 Nov 2023 11:04:10 +0100 Subject: [PATCH 01/21] Added cw-orch --- Cargo.toml | 5 +++++ src/interface.rs | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 3 +++ src/msg.rs | 2 ++ 4 files changed, 55 insertions(+) create mode 100644 src/interface.rs diff --git a/Cargo.toml b/Cargo.toml index cf6ee56..c9ae77e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,8 @@ overflow-checks = true backtraces = ["cosmwasm-std/backtraces"] # use library feature to disable all instantiate/execute/query exports library = [] +# use interface feature to expose structure for contract orchestration +interface = ["dep:cw-orch"] [package.metadata.scripts] optimize = """docker run --rm -v "$(pwd)":/code \ @@ -52,5 +54,8 @@ schemars = "0.8.15" serde = { version = "1.0.189", default-features = false, features = ["derive"] } thiserror = { version = "1.0.49" } +cw-orch = { version = "0.18.1", optional = true } + [dev-dependencies] cw-multi-test = "0.17.0" +{{project-name}} = {path = ".", features=["interface"]} \ No newline at end of file diff --git a/src/interface.rs b/src/interface.rs new file mode 100644 index 0000000..1710276 --- /dev/null +++ b/src/interface.rs @@ -0,0 +1,45 @@ +use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use cosmwasm_std::Empty; +use cw_orch::{interface, prelude::*}; + +#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)] +pub struct ContractInterface; + +impl Uploadable for ContractInterface { + /// Return the path to the wasm file corresponding to the contract + fn wasm(&self) -> WasmPath { + artifacts_dir_from_workspace!() + .find_wasm_path("{{crate_name}}") + .unwrap() + } + /// Returns a CosmWasm contract wrapper + fn wrapper(&self) -> Box> { + Box::new(ContractWrapper::new_with_empty( + crate::contract::execute, + crate::contract::instantiate, + crate::contract::query, + )) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::msg::{ExecuteMsgFns, QueryMsgFns}; + use cw_orch::anyhow; + + #[test] + fn contract_logic() -> anyhow::Result<()> { + let mock = Mock::new(&Addr::unchecked("sender")); + let contract = ContractInterface::new("project-name", mock); + contract.upload()?; + + contract.instantiate(&InstantiateMsg { count: 7 }, None, None)?; + assert_eq!(contract.get_count()?.count, 7); + + contract.increment()?; + assert_eq!(contract.get_count()?.count, 8); + + Ok(()) + } +} diff --git a/src/lib.rs b/src/lib.rs index 4c7c0ef..7752fc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,3 +6,6 @@ pub mod helpers; pub mod state; pub use crate::error::ContractError; + +#[cfg(feature = "interface")] +pub mod interface; diff --git a/src/msg.rs b/src/msg.rs index adf6ef1..dbe0b69 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -6,6 +6,7 @@ pub struct InstantiateMsg {% raw %}{{% endraw %}{% unless minimal %} {% endunless %}} #[cw_serde] +#[cfg_attr(feature = "interface", derive(cw_orch::ExecuteFns))] pub enum ExecuteMsg {% raw %}{{% endraw %}{% unless minimal %} Increment {}, Reset { count: i32 }, @@ -13,6 +14,7 @@ pub enum ExecuteMsg {% raw %}{{% endraw %}{% unless minimal %} #[cw_serde] #[derive(QueryResponses)] +#[cfg_attr(feature = "interface", derive(cw_orch::QueryFns))] pub enum QueryMsg {% raw %}{{% endraw %}{% unless minimal %} // GetCount returns the current count as a json-encoded number #[returns(GetCountResponse)] From a66a21ac8b03c1a6c7b20f9628b883d2319ca460 Mon Sep 17 00:00:00 2001 From: Kayanski Date: Wed, 8 Nov 2023 11:13:14 +0100 Subject: [PATCH 02/21] Added cw-orch readme section --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6264428..eac4f7f 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ more on how to run tests and develop code. Or go through the [online tutorial](https://docs.cosmwasm.com/) to get a better feel of how to develop. +This template includes [cw-orchestrator](https://docs.rs/cw-orch/latest/cw_orch/) by default. This library allows you to unit-test, integration-test as well as interact with your contracts on-chain using a common intuitive syntax that leverages rust type-safety to assist you throughout your development process. You can find the interface definitions in the [src/interface.rs](src/interface.rs) file. You can also find more information in the [`cw-orch` documentation](https://orchestrator.abstract.money/). + [Publishing](./Publishing.md) contains useful information on how to publish your contract to the world, once you are ready to deploy it on a running blockchain. And [Importing](./Importing.md) contains information about pulling in other contracts or crates From 66f71c5d97ffc8184562df875f0a7d7a02e79c66 Mon Sep 17 00:00:00 2001 From: Kayanski Date: Wed, 8 Nov 2023 11:51:47 +0100 Subject: [PATCH 03/21] Fixed minimal --- src/interface.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/interface.rs b/src/interface.rs index 1710276..e71acc3 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -21,7 +21,7 @@ impl Uploadable for ContractInterface { )) } } - +{% unless minimal %} #[cfg(test)] mod tests { use super::*; @@ -43,3 +43,4 @@ mod tests { Ok(()) } } +{% endunless %} \ No newline at end of file From efb6da196dd4b966e9cef6e0dc9e2f9c81ffe46b Mon Sep 17 00:00:00 2001 From: Kayanski Date: Tue, 9 Jan 2024 10:30:26 +0100 Subject: [PATCH 04/21] Updated cw-orch --- Cargo.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c9ae77e..bc620f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,9 +44,9 @@ optimize = """docker run --rm -v "$(pwd)":/code \ [dependencies] cosmwasm-schema = "1.5.0" cosmwasm-std = { version = "1.5.0", features = [ - "cosmwasm_1_3", - # Enable this if you only deploy to chains that have CosmWasm 1.4 or higher - # "cosmwasm_1_4", + "cosmwasm_1_3", + # Enable this if you only deploy to chains that have CosmWasm 1.4 or higher + # "cosmwasm_1_4", ] } cw-storage-plus = "1.1.0" cw2 = "1.1.1" @@ -54,8 +54,9 @@ schemars = "0.8.15" serde = { version = "1.0.189", default-features = false, features = ["derive"] } thiserror = { version = "1.0.49" } -cw-orch = { version = "0.18.1", optional = true } +cw-orch = { version = "0.19.1", optional = true } [dev-dependencies] + +{{project-name}} = {path = ".", features=["interface"]} cw-multi-test = "0.17.0" -{{project-name}} = {path = ".", features=["interface"]} \ No newline at end of file From ca504bd6aae0afb5a84f972ab4260300f109a43b Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 11 Oct 2024 13:33:50 +0300 Subject: [PATCH 05/21] bump cw-orch --- Cargo.toml | 2 +- src/interface.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f4bed7..100fece 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ schemars = "0.8.16" serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } -cw-orch = { version = "0.19.1", optional = true } +cw-orch = { version = "0.26.0", optional = true } [dev-dependencies] {{project-name}} = { path = ".", features= ["interface"] } diff --git a/src/interface.rs b/src/interface.rs index e71acc3..1b343ec 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -7,13 +7,13 @@ pub struct ContractInterface; impl Uploadable for ContractInterface { /// Return the path to the wasm file corresponding to the contract - fn wasm(&self) -> WasmPath { + fn wasm(info: &ChainInfoOwned) -> WasmPath { artifacts_dir_from_workspace!() .find_wasm_path("{{crate_name}}") .unwrap() } /// Returns a CosmWasm contract wrapper - fn wrapper(&self) -> Box> { + fn wrapper() -> Box> { Box::new(ContractWrapper::new_with_empty( crate::contract::execute, crate::contract::instantiate, @@ -34,7 +34,7 @@ mod tests { let contract = ContractInterface::new("project-name", mock); contract.upload()?; - contract.instantiate(&InstantiateMsg { count: 7 }, None, None)?; + contract.instantiate(&InstantiateMsg { count: 7 }, None, &[])?; assert_eq!(contract.get_count()?.count, 7); contract.increment()?; From 85fd31439282c921ece22f0e6ee6360792c47569 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 11 Oct 2024 14:13:56 +0300 Subject: [PATCH 06/21] move tests --- Cargo.toml | 7 ++- cargo-generate.toml | 1 + src/contract.rs | 14 +++--- src/error.rs | 2 +- src/interface.rs | 6 +-- tests/checksum.rs | 32 ++++++++++++++ tests/integration_tests.rs | 91 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 140 insertions(+), 13 deletions(-) create mode 100644 tests/checksum.rs create mode 100644 tests/integration_tests.rs diff --git a/Cargo.toml b/Cargo.toml index 100fece..2b42244 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ interface = ["dep:cw-orch"] optimize = """docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.15.0 + cosmwasm/optimizer:0.16.0 """ [dependencies] @@ -50,4 +50,7 @@ cw-orch = { version = "0.26.0", optional = true } [dev-dependencies] {{project-name}} = { path = ".", features= ["interface"] } -cw-multi-test = "2.0.0" +{% unless minimal %} + +{% endif %}cw-multi-test = "2.0.0" +cw-orch = { version = "0.26.0", features = ["daemon"] } diff --git a/cargo-generate.toml b/cargo-generate.toml index df31fb8..a92fc62 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -20,4 +20,5 @@ ignore = [ ".gitpod.yml", ".gitpod.Dockerfile", "src/integration_tests.rs", + "tests/", ] diff --git a/src/contract.rs b/src/contract.rs index 82c6521..8e3116e 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -89,7 +89,7 @@ pub mod query { #[cfg(test)] mod tests {% raw %}{{% endraw %}{% unless minimal %} use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; + use cosmwasm_std::testing::{mock_dependencies, mock_env, message_info}; use cosmwasm_std::{coins, from_json}; #[test] @@ -97,7 +97,7 @@ mod tests {% raw %}{{% endraw %}{% unless minimal %} let mut deps = mock_dependencies(); let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(1000, "earth")); + let info = message_info(&deps.api.addr_make("creator"), &coins(1000, "earth")); // we can just call .unwrap() to assert this was a success let res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); @@ -114,11 +114,11 @@ mod tests {% raw %}{{% endraw %}{% unless minimal %} let mut deps = mock_dependencies(); let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(2, "token")); + let info = message_info(&deps.api.addr_make("creator"), &coins(2, "token")); let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); // beneficiary can release it - let info = mock_info("anyone", &coins(2, "token")); + let info = message_info(&deps.api.addr_make("anyone"), &coins(2, "token")); let msg = ExecuteMsg::Increment {}; let _res = execute(deps.as_mut(), mock_env(), info, msg).unwrap(); @@ -133,11 +133,11 @@ mod tests {% raw %}{{% endraw %}{% unless minimal %} let mut deps = mock_dependencies(); let msg = InstantiateMsg { count: 17 }; - let info = mock_info("creator", &coins(2, "token")); + let info = message_info(&deps.api.addr_make("creator"), &coins(2, "token")); let _res = instantiate(deps.as_mut(), mock_env(), info, msg).unwrap(); // beneficiary can release it - let unauth_info = mock_info("anyone", &coins(2, "token")); + let unauth_info = message_info(&deps.api.addr_make("anyone"), &coins(2, "token")); let msg = ExecuteMsg::Reset { count: 5 }; let res = execute(deps.as_mut(), mock_env(), unauth_info, msg); match res { @@ -146,7 +146,7 @@ mod tests {% raw %}{{% endraw %}{% unless minimal %} } // only the original creator can reset the counter - let auth_info = mock_info("creator", &coins(2, "token")); + let auth_info = message_info(&deps.api.addr_make("creator"), &coins(2, "token")); let msg = ExecuteMsg::Reset { count: 5 }; let _res = execute(deps.as_mut(), mock_env(), auth_info, msg).unwrap(); diff --git a/src/error.rs b/src/error.rs index 4a69d8f..19f795a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,7 @@ use cosmwasm_std::StdError; use thiserror::Error; -#[derive(Error, Debug)] +#[derive(Error, Debug, PartialEq)] pub enum ContractError { #[error("{0}")] Std(#[from] StdError), diff --git a/src/interface.rs b/src/interface.rs index 1b343ec..af33358 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -2,12 +2,12 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::Empty; use cw_orch::{interface, prelude::*}; -#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty)] +#[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty, id = "{{project-name}}")] pub struct ContractInterface; impl Uploadable for ContractInterface { /// Return the path to the wasm file corresponding to the contract - fn wasm(info: &ChainInfoOwned) -> WasmPath { + fn wasm(_info: &ChainInfoOwned) -> WasmPath { artifacts_dir_from_workspace!() .find_wasm_path("{{crate_name}}") .unwrap() @@ -31,7 +31,7 @@ mod tests { #[test] fn contract_logic() -> anyhow::Result<()> { let mock = Mock::new(&Addr::unchecked("sender")); - let contract = ContractInterface::new("project-name", mock); + let contract = ContractInterface::new(mock); contract.upload()?; contract.instantiate(&InstantiateMsg { count: 7 }, None, &[])?; diff --git a/tests/checksum.rs b/tests/checksum.rs new file mode 100644 index 0000000..dfbbf2b --- /dev/null +++ b/tests/checksum.rs @@ -0,0 +1,32 @@ +use {{project-name | snake_case}}::interface::ContractInterface; +use cw_orch::{contract::interface_traits::Uploadable, daemon::networks::OSMOSIS_1, mock::Mock}; + +#[test] +fn checksum() { + use std::fs::File; + use std::io::{self, BufRead}; + use std::path::Path; + + let path = Path::new("artifacts/checksums.txt"); + let file = File::open(path).unwrap(); + let lines = io::BufReader::new(file).lines(); + let mut found = false; + + for line in lines.map_while(Result::ok) { + if line.contains("{{project-name | snake_case}}.wasm") { + let parts: Vec<&str> = line.split_whitespace().collect(); + if parts.len() > 1 { + let calculated_hash = ContractInterface::::wasm(&OSMOSIS_1.into()) + .checksum() + .unwrap(); + assert_eq!(parts[0], calculated_hash.to_string()); + found = true; + break; + } + } + } + + if !found { + panic!("Checksum of {{project-name | snake_case}}.wasm not found in checksums.txt"); + } +} diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs new file mode 100644 index 0000000..34be91b --- /dev/null +++ b/tests/integration_tests.rs @@ -0,0 +1,91 @@ +use {{project-name | snake_case}}::{ + msg::{GetCountResponse, InstantiateMsg, QueryMsg}, + ContractError, interface::ContractInterface, +}; +// Use prelude to get all the necessary imports +use cw_orch::prelude::*; +use cw_orch::anyhow; + +use cosmwasm_std::Addr; + +// consts for testing +const USER: &str = "user"; +const ADMIN: &str = "admin"; + +#[test] +fn count() -> anyhow::Result<()> { + // Create a user + let user = Addr::unchecked(USER); + // Create the mock. This will be our chain object throughout + let mock = Mock::new(ADMIN); + + // Set up the contract (Definition below) ↓↓ + let contract = setup(mock.clone())?; + + // Increment the count of the contract + contract + // Set the caller to user + .call_as(&user) + // Call the increment function (auto-generated function provided by ExecuteMsgFns) + .increment()?; + + // Get the count. + use {{project-name | snake_case}}::msg::QueryMsgFns; + let count1 = contract.get_count()?; + + // or query it manually + let count2: GetCountResponse = contract.query(&QueryMsg::GetCount {})?; + assert_eq!(count1.count, count2.count); + + // Or get it manually from the chain + let count3: GetCountResponse = mock.query(&QueryMsg::GetCount {}, &contract.address()?)?; + assert_eq!(count1.count, count3.count); + + // Check the count + assert_eq!(count1.count, 2); + // Reset + use {{project-name | snake_case}}::msg::ExecuteMsgFns; + contract.reset(0)?; + + let count = contract.get_count()?; + assert_eq!(count.count, 0); + + // Check negative case + let exec_res: Result = + contract.call_as(&user).reset(0); + + let expected_err = ContractError::Unauthorized {}; + assert_eq!( + exec_res.unwrap_err().downcast::()?, + expected_err + ); + + Ok(()) +} + +/// Instantiate the contract in any CosmWasm environment +fn setup(chain: Chain) -> anyhow::Result> { + // Construct the interface + let contract = ContractInterface::new(chain.clone()); + let admin = Addr::unchecked(ADMIN); + + // Upload the contract + let upload_resp = contract.upload()?; + + // Get the code-id from the response. + let code_id = upload_resp.uploaded_code_id()?; + // or get it from the interface. + assert_eq!(code_id, contract.code_id()?); + + // Instantiate the contract + let msg = InstantiateMsg { count: 1i32 }; + let init_resp = contract.instantiate(&msg, Some(&admin), &[])?; + + // Get the address from the response + let contract_addr = init_resp.instantiated_contract_address()?; + // or get it from the interface. + assert_eq!(contract_addr, contract.address()?); + + // Return the interface + Ok(contract) +} From da1332b165dd99e7f5f0bfe3033517481d40c754 Mon Sep 17 00:00:00 2001 From: Buckram Date: Fri, 11 Oct 2024 14:19:57 +0300 Subject: [PATCH 07/21] fix autoformat --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2b42244..8c3bbc1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,6 @@ cw-orch = { version = "0.26.0", optional = true } [dev-dependencies] {{project-name}} = { path = ".", features= ["interface"] } {% unless minimal %} - -{% endif %}cw-multi-test = "2.0.0" +cw-multi-test = "2.0.0" cw-orch = { version = "0.26.0", features = ["daemon"] } +{% endunless %} \ No newline at end of file From 8bec9de268ab72b5106a481176354dfc7c1bf6ef Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Fri, 11 Oct 2024 17:15:21 +0200 Subject: [PATCH 08/21] clean up contract and remove default integration tests --- src/contract.rs | 2 +- src/integration_tests.rs | 78 ---------------------- src/lib.rs | 3 +- tests/checksum.rs | 32 --------- tests/{integration_tests.rs => counter.rs} | 5 +- 5 files changed, 5 insertions(+), 115 deletions(-) delete mode 100644 src/integration_tests.rs delete mode 100644 tests/checksum.rs rename tests/{integration_tests.rs => counter.rs} (98%) diff --git a/src/contract.rs b/src/contract.rs index 8e3116e..f480d05 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -89,7 +89,7 @@ pub mod query { #[cfg(test)] mod tests {% raw %}{{% endraw %}{% unless minimal %} use super::*; - use cosmwasm_std::testing::{mock_dependencies, mock_env, message_info}; + use cosmwasm_std::testing::{message_info, mock_dependencies, mock_env}; use cosmwasm_std::{coins, from_json}; #[test] diff --git a/src/integration_tests.rs b/src/integration_tests.rs deleted file mode 100644 index 324f2ec..0000000 --- a/src/integration_tests.rs +++ /dev/null @@ -1,78 +0,0 @@ -#[cfg(test)] -mod tests { - use crate::helpers::CwTemplateContract; - use crate::msg::InstantiateMsg; - use cosmwasm_std::testing::MockApi; - use cosmwasm_std::{Addr, Coin, Empty, Uint128}; - use cw_multi_test::{App, AppBuilder, Contract, ContractWrapper, Executor}; - - pub fn contract_template() -> Box> { - let contract = ContractWrapper::new( - crate::contract::execute, - crate::contract::instantiate, - crate::contract::query, - ); - Box::new(contract) - } - - const USER: &str = "USER"; - const ADMIN: &str = "ADMIN"; - const NATIVE_DENOM: &str = "denom"; - - fn mock_app() -> App { - AppBuilder::new().build(|router, _, storage| { - router - .bank - .init_balance( - storage, - &MockApi::default().addr_make(USER), - vec![Coin { - denom: NATIVE_DENOM.to_string(), - amount: Uint128::new(1), - }], - ) - .unwrap(); - }) - } - - fn proper_instantiate() -> (App, CwTemplateContract) { - let mut app = mock_app(); - let cw_template_id = app.store_code(contract_template()); - - let user = app.api().addr_make(USER); - assert_eq!( - app.wrap().query_balance(user, NATIVE_DENOM).unwrap().amount, - Uint128::new(1) - ); - - let msg = InstantiateMsg { count: 1i32 }; - let cw_template_contract_addr = app - .instantiate_contract( - cw_template_id, - Addr::unchecked(ADMIN), - &msg, - &[], - "test", - None, - ) - .unwrap(); - - let cw_template_contract = CwTemplateContract(cw_template_contract_addr); - - (app, cw_template_contract) - } - - mod count { - use super::*; - use crate::msg::ExecuteMsg; - - #[test] - fn count() { - let (mut app, cw_template_contract) = proper_instantiate(); - - let msg = ExecuteMsg::Increment {}; - let cosmos_msg = cw_template_contract.call(msg).unwrap(); - app.execute(Addr::unchecked(USER), cosmos_msg).unwrap(); - } - } -} diff --git a/src/lib.rs b/src/lib.rs index 7752fc9..567d92a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,7 @@ pub mod contract; mod error; pub mod helpers; -{% unless minimal %}pub mod integration_tests; -{% endunless %}pub mod msg; +pub mod msg; pub mod state; pub use crate::error::ContractError; diff --git a/tests/checksum.rs b/tests/checksum.rs deleted file mode 100644 index dfbbf2b..0000000 --- a/tests/checksum.rs +++ /dev/null @@ -1,32 +0,0 @@ -use {{project-name | snake_case}}::interface::ContractInterface; -use cw_orch::{contract::interface_traits::Uploadable, daemon::networks::OSMOSIS_1, mock::Mock}; - -#[test] -fn checksum() { - use std::fs::File; - use std::io::{self, BufRead}; - use std::path::Path; - - let path = Path::new("artifacts/checksums.txt"); - let file = File::open(path).unwrap(); - let lines = io::BufReader::new(file).lines(); - let mut found = false; - - for line in lines.map_while(Result::ok) { - if line.contains("{{project-name | snake_case}}.wasm") { - let parts: Vec<&str> = line.split_whitespace().collect(); - if parts.len() > 1 { - let calculated_hash = ContractInterface::::wasm(&OSMOSIS_1.into()) - .checksum() - .unwrap(); - assert_eq!(parts[0], calculated_hash.to_string()); - found = true; - break; - } - } - } - - if !found { - panic!("Checksum of {{project-name | snake_case}}.wasm not found in checksums.txt"); - } -} diff --git a/tests/integration_tests.rs b/tests/counter.rs similarity index 98% rename from tests/integration_tests.rs rename to tests/counter.rs index 34be91b..ca2956a 100644 --- a/tests/integration_tests.rs +++ b/tests/counter.rs @@ -1,10 +1,11 @@ use {{project-name | snake_case}}::{ + interface::ContractInterface, msg::{GetCountResponse, InstantiateMsg, QueryMsg}, - ContractError, interface::ContractInterface, + ContractError, }; // Use prelude to get all the necessary imports -use cw_orch::prelude::*; use cw_orch::anyhow; +use cw_orch::prelude::*; use cosmwasm_std::Addr; From ae83b030e5edcc14e02c157ca06c387f7590847c Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Tue, 15 Oct 2024 14:48:19 +0200 Subject: [PATCH 09/21] update readme cargo-generate url --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eac4f7f..85d5888 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ Go to the folder in which you want to place it and run: **Latest** ```sh -cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME +cargo generate --git https://github.com/AbstractSDK/cw-template.git --name PROJECT_NAME ``` For cloning minimal code repo: ```sh -cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME -d minimal=true +cargo generate --git https://github.com/AbstractSDK/cw-template.git --name PROJECT_NAME -d minimal=true ``` You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else) From f30318dbdf7b339c8270dd5f8f1a4a53847ae429 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Tue, 15 Oct 2024 14:48:34 +0200 Subject: [PATCH 10/21] remove interface feature --- Cargo.toml | 5 +---- src/interface.rs | 3 ++- src/lib.rs | 2 +- src/msg.rs | 5 ++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c3bbc1..2a9725f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,8 +23,6 @@ overflow-checks = true [features] # use library feature to disable all instantiate/execute/query exports library = [] -# use interface feature to expose structure for contract orchestration -interface = ["dep:cw-orch"] [package.metadata.scripts] optimize = """docker run --rm -v "$(pwd)":/code \ @@ -46,10 +44,9 @@ schemars = "0.8.16" serde = { version = "1.0.197", default-features = false, features = ["derive"] } thiserror = { version = "1.0.58" } -cw-orch = { version = "0.26.0", optional = true } +cw-orch = { version = "0.26.0" } [dev-dependencies] -{{project-name}} = { path = ".", features= ["interface"] } {% unless minimal %} cw-multi-test = "2.0.0" cw-orch = { version = "0.26.0", features = ["daemon"] } diff --git a/src/interface.rs b/src/interface.rs index af33358..26feb28 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -1,6 +1,7 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; use cosmwasm_std::Empty; -use cw_orch::{interface, prelude::*}; +use cw_orch::interface; +use cw_orch::prelude::*; #[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty, id = "{{project-name}}")] pub struct ContractInterface; diff --git a/src/lib.rs b/src/lib.rs index 567d92a..f523080 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,5 +6,5 @@ pub mod state; pub use crate::error::ContractError; -#[cfg(feature = "interface")] +#[cfg(not(target_arch = "wasm32"))] pub mod interface; diff --git a/src/msg.rs b/src/msg.rs index dbe0b69..eb942ae 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -6,15 +6,14 @@ pub struct InstantiateMsg {% raw %}{{% endraw %}{% unless minimal %} {% endunless %}} #[cw_serde] -#[cfg_attr(feature = "interface", derive(cw_orch::ExecuteFns))] +#[derive(cw_orch::ExecuteFns)] pub enum ExecuteMsg {% raw %}{{% endraw %}{% unless minimal %} Increment {}, Reset { count: i32 }, {% endunless %}} #[cw_serde] -#[derive(QueryResponses)] -#[cfg_attr(feature = "interface", derive(cw_orch::QueryFns))] +#[derive(QueryResponses, cw_orch::QueryFns)] pub enum QueryMsg {% raw %}{{% endraw %}{% unless minimal %} // GetCount returns the current count as a json-encoded number #[returns(GetCountResponse)] From 48585d77522aba26ccf072f076d401c326059adc Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Tue, 15 Oct 2024 15:02:26 +0200 Subject: [PATCH 11/21] add optimize script --- optimize.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 optimize.sh diff --git a/optimize.sh b/optimize.sh new file mode 100755 index 0000000..2f7d208 --- /dev/null +++ b/optimize.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +# Delete all the current wasms first +rm -rf ./artifacts/*.wasm + +if [[ $(arch) == "arm64" ]]; then + image="cosmwasm/optimizer-arm64:0.16.0" +else + image="cosmwasm/optimizer:0.16.0" +fi + +# Optimized builds +docker run --rm -v "$(pwd)":/code \ + --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ + -v "$(dirname "$(pwd)")/integrations":/integrations \ + -v "$(dirname "$(pwd)")/framework":/framework \ + --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ + ${image} \ No newline at end of file From 9fed79ff2ac4afcd06d34f6e485e6f906e29c7d6 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Tue, 15 Oct 2024 15:33:45 +0200 Subject: [PATCH 12/21] update optimize docs --- Cargo.toml | 7 ------- Developing.md | 7 +++++++ README.md | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2a9725f..7a3055e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,6 @@ overflow-checks = true # use library feature to disable all instantiate/execute/query exports library = [] -[package.metadata.scripts] -optimize = """docker run --rm -v "$(pwd)":/code \ - --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ - --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.16.0 -""" - [dependencies] cosmwasm-schema = "2.1.0" cosmwasm-std = { version = "2.1.0", features = [ diff --git a/Developing.md b/Developing.md index 1b3245e..c9ee675 100644 --- a/Developing.md +++ b/Developing.md @@ -70,6 +70,13 @@ To solve both these issues, we have produced `rust-optimizer`, a docker image to produce an extremely small build output in a consistent manner. The suggest way to run it is this: +```sh +chmod +x ./optimize.sh +./optimize.sh +``` + +Which is equivalent to: + ```sh docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ diff --git a/README.md b/README.md index 85d5888..36514f2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ Unless you did that before, run this line now: ```sh cargo install cargo-generate --features vendored-openssl -cargo install cargo-run-script ``` Now, use it to create your new contract. From 1a5bb2a650e123780e6645001fde35f5479a014e Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Wed, 16 Oct 2024 16:10:33 +0200 Subject: [PATCH 13/21] add env-var example --- .env.example | 9 +++++++++ .gitignore | 1 + 2 files changed, 10 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..cbe9f06 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +# Copy this file to .env and fill in the values +# Learn about more env vars: http://orchestrator.abstract.money + +# info, debug, trace (if using env_logger for logging) +RUST_LOG=info + +MAIN_MNEMONIC="" # Necessary if interacting with a daemon on mainnet +TEST_MNEMONIC="" # Necessary if interacting with a daemon on testnet +LOCAL_MNEMONIC="" # Necessary if interacting with a daemon locally diff --git a/.gitignore b/.gitignore index 9095dea..93cd69d 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # IDEs *.iml .idea +.env From cdb60676e31c7464f2ab8d94cc6a779ba4d04441 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Wed, 16 Oct 2024 17:03:20 +0200 Subject: [PATCH 14/21] add deployment bin to template --- .cargo/config.toml | 2 +- Cargo.toml | 10 +++++++- src/bin/deploy.rs | 25 ++++++++++++++++++++ src/interface.rs | 33 +++++++++++--------------- tests/{counter.rs => count.rs} | 43 ++++++---------------------------- 5 files changed, 56 insertions(+), 57 deletions(-) create mode 100644 src/bin/deploy.rs rename tests/{counter.rs => count.rs} (56%) diff --git a/.cargo/config.toml b/.cargo/config.toml index f5659c7..480d79f 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -2,4 +2,4 @@ wasm = "build --release --lib --target wasm32-unknown-unknown" unit-test = "test --lib" schema = "run --bin schema" -integration-test = "test --lib integration_tests" +deploy = "run --bin deploy --features deploy" diff --git a/Cargo.toml b/Cargo.toml index 7a3055e..a414bfc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,9 +20,15 @@ panic = 'abort' incremental = false overflow-checks = true +[[bin]] +name = "deploy" +path = "src/bin/deploy.rs" +required-features = ["deploy"] + [features] # use library feature to disable all instantiate/execute/query exports library = [] +deploy = ["cw-orch/daemon", "dotenv", "env_logger"] [dependencies] cosmwasm-schema = "2.1.0" @@ -39,8 +45,10 @@ thiserror = { version = "1.0.58" } cw-orch = { version = "0.26.0" } +env_logger = { version = "0.11.5", optional = true } +dotenv = { version = "0.15.0", optional = true } + [dev-dependencies] {% unless minimal %} cw-multi-test = "2.0.0" -cw-orch = { version = "0.26.0", features = ["daemon"] } {% endunless %} \ No newline at end of file diff --git a/src/bin/deploy.rs b/src/bin/deploy.rs new file mode 100644 index 0000000..78b0ef5 --- /dev/null +++ b/src/bin/deploy.rs @@ -0,0 +1,25 @@ +use cw_orch::{anyhow, prelude::*}; +use {{project-name | snake_case}}::{ + interface::{{project-name | upper_camel_case}}I, + msg::{ExecuteMsgFns, InstantiateMsg, QueryMsgFns}, +}; + +pub fn main() -> anyhow::Result<()> { + dotenv::dotenv().ok(); // Used to load the `.env` file if any + env_logger::init(); // Used to log contract and chain interactions + + let network = networks::PION_1; + let chain = DaemonBuilder::new(network.clone()).build()?; + + let counter = {{project-name | upper_camel_case}}I::new(chain); + + counter.upload()?; + counter.instantiate(&InstantiateMsg { count: 0 }, None, &[])?; + + counter.increment()?; + + let count = counter.get_count()?; + assert_eq!(count.count, 1); + + Ok(()) +} diff --git a/src/interface.rs b/src/interface.rs index 26feb28..86d7c3f 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -4,9 +4,9 @@ use cw_orch::interface; use cw_orch::prelude::*; #[interface(InstantiateMsg, ExecuteMsg, QueryMsg, Empty, id = "{{project-name}}")] -pub struct ContractInterface; +pub struct {{project-name | upper_camel_case}}I; -impl Uploadable for ContractInterface { +impl Uploadable for {{project-name | upper_camel_case}}I { /// Return the path to the wasm file corresponding to the contract fn wasm(_info: &ChainInfoOwned) -> WasmPath { artifacts_dir_from_workspace!() @@ -22,26 +22,21 @@ impl Uploadable for ContractInterface { )) } } -{% unless minimal %} -#[cfg(test)] -mod tests { - use super::*; - use crate::msg::{ExecuteMsgFns, QueryMsgFns}; - use cw_orch::anyhow; - #[test] - fn contract_logic() -> anyhow::Result<()> { - let mock = Mock::new(&Addr::unchecked("sender")); - let contract = ContractInterface::new(mock); - contract.upload()?; +impl {{project-name | upper_camel_case}}I { + /// Instantiate the contract in any CosmWasm environment + pub fn setup(chain: Chain, admin: Addr) -> cw_orch::anyhow::Result<{{project-name | upper_camel_case}}I> { + // Construct the interface + let contract = {{project-name | upper_camel_case}}I::new(chain.clone()); - contract.instantiate(&InstantiateMsg { count: 7 }, None, &[])?; - assert_eq!(contract.get_count()?.count, 7); + // Upload the contract + contract.upload()?; - contract.increment()?; - assert_eq!(contract.get_count()?.count, 8); + // Instantiate the contract + let msg = InstantiateMsg { count: 1i32 }; + contract.instantiate(&msg, Some(&admin), &[])?; - Ok(()) + // Return the interface + Ok(contract) } } -{% endunless %} \ No newline at end of file diff --git a/tests/counter.rs b/tests/count.rs similarity index 56% rename from tests/counter.rs rename to tests/count.rs index ca2956a..90eac94 100644 --- a/tests/counter.rs +++ b/tests/count.rs @@ -1,27 +1,25 @@ use {{project-name | snake_case}}::{ - interface::ContractInterface, - msg::{GetCountResponse, InstantiateMsg, QueryMsg}, + interface::{{project-name | upper_camel_case}}I, + msg::{GetCountResponse, QueryMsg}, ContractError, }; // Use prelude to get all the necessary imports use cw_orch::anyhow; use cw_orch::prelude::*; -use cosmwasm_std::Addr; - -// consts for testing +// constants for testing const USER: &str = "user"; const ADMIN: &str = "admin"; #[test] fn count() -> anyhow::Result<()> { - // Create a user - let user = Addr::unchecked(USER); // Create the mock. This will be our chain object throughout let mock = Mock::new(ADMIN); - // Set up the contract (Definition below) ↓↓ - let contract = setup(mock.clone())?; + let user = mock.addr_make(USER); + + // Set up the contract + let contract = {{project-name | upper_camel_case}}I::setup(mock.clone(), mock.sender().clone())?; // Increment the count of the contract contract @@ -63,30 +61,3 @@ fn count() -> anyhow::Result<()> { Ok(()) } - -/// Instantiate the contract in any CosmWasm environment -fn setup(chain: Chain) -> anyhow::Result> { - // Construct the interface - let contract = ContractInterface::new(chain.clone()); - let admin = Addr::unchecked(ADMIN); - - // Upload the contract - let upload_resp = contract.upload()?; - - // Get the code-id from the response. - let code_id = upload_resp.uploaded_code_id()?; - // or get it from the interface. - assert_eq!(code_id, contract.code_id()?); - - // Instantiate the contract - let msg = InstantiateMsg { count: 1i32 }; - let init_resp = contract.instantiate(&msg, Some(&admin), &[])?; - - // Get the address from the response - let contract_addr = init_resp.instantiated_contract_address()?; - // or get it from the interface. - assert_eq!(contract_addr, contract.address()?); - - // Return the interface - Ok(contract) -} From bb904dd170e4571371499b93f6292c581464587e Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Wed, 16 Oct 2024 17:03:34 +0200 Subject: [PATCH 15/21] nits --- cargo-generate.toml | 1 - meta/test_generate.sh | 7 ++++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cargo-generate.toml b/cargo-generate.toml index a92fc62..6b9a8b1 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -19,6 +19,5 @@ ignore = [ "Publishing.md", ".gitpod.yml", ".gitpod.Dockerfile", - "src/integration_tests.rs", "tests/", ] diff --git a/meta/test_generate.sh b/meta/test_generate.sh index ea3e14e..2521534 100755 --- a/meta/test_generate.sh +++ b/meta/test_generate.sh @@ -12,7 +12,7 @@ PROJECT_NAME="testgen-local" cd "$TMP_DIR" echo "Generating project from local repository ..." - cargo generate --path "$REPO_ROOT" --name "$PROJECT_NAME" + cargo generate --path "$REPO_ROOT" --name "$PROJECT_NAME" -d minimal=false ( cd "$PROJECT_NAME" @@ -24,8 +24,9 @@ PROJECT_NAME="testgen-local" cargo fmt -- --check # Debug builds first to fail fast - echo "Running unit tests ..." - cargo unit-test + echo "Running tests ..." + cargo test + echo "Creating schema ..." cargo schema From abce256cc4a1d04e080c6d7cf4497f425ed09dc3 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Wed, 16 Oct 2024 17:47:50 +0200 Subject: [PATCH 16/21] update deploy for minimal example --- src/bin/deploy.rs | 10 +++++----- src/interface.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/deploy.rs b/src/bin/deploy.rs index 78b0ef5..03f2f68 100644 --- a/src/bin/deploy.rs +++ b/src/bin/deploy.rs @@ -1,5 +1,5 @@ use cw_orch::{anyhow, prelude::*}; -use {{project-name | snake_case}}::{ +use {{project-name | snake_case}}::{% raw %}{{% endraw %} interface::{{project-name | upper_camel_case}}I, msg::{ExecuteMsgFns, InstantiateMsg, QueryMsgFns}, }; @@ -14,12 +14,12 @@ pub fn main() -> anyhow::Result<()> { let counter = {{project-name | upper_camel_case}}I::new(chain); counter.upload()?; - counter.instantiate(&InstantiateMsg { count: 0 }, None, &[])?; - counter.increment()?; + let msg = InstantiateMsg {% raw %}{{% endraw %}{% unless minimal %} count: 1i32 {% endunless %}}; + counter.instantiate(&msg, None, &[])?;{% unless minimal %} + counter.increment()?; let count = counter.get_count()?; - assert_eq!(count.count, 1); - + assert_eq!(count.count, 1);{% endunless %} Ok(()) } diff --git a/src/interface.rs b/src/interface.rs index 86d7c3f..4c07152 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -33,7 +33,7 @@ impl {{project-name | upper_camel_case}}I { contract.upload()?; // Instantiate the contract - let msg = InstantiateMsg { count: 1i32 }; + let msg = InstantiateMsg {% raw %}{{% endraw %}{% unless minimal %} count: 1i32 {% endunless %}}; contract.instantiate(&msg, Some(&admin), &[])?; // Return the interface From 6f63ccdc988bc99cf730b3b53aef7c14f738b468 Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Wed, 16 Oct 2024 18:32:16 +0200 Subject: [PATCH 17/21] update readme --- Developing.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Developing.md b/Developing.md index c9ee675..393690a 100644 --- a/Developing.md +++ b/Developing.md @@ -109,3 +109,19 @@ The wasm file is compiled deterministically (anyone else running the same docker on the same git commit should get the identical file with the same Sha256 hash). It is also stripped and minimized for upload to a blockchain (we will also gzip it in the uploading process to make it even smaller). + +## Deploying + +Copy `.env.example` to `.env` and fill in the mnemonic that you want to use for deployment. + +```sh +cp .env.example .env +``` + +Then run the deploy script: + +```sh +cargo deploy +``` + +You can change the network to deploy to in the `deploy.rs` file. From 6b2ec85592458dd4c70a46ecbf4f4325d43a1dca Mon Sep 17 00:00:00 2001 From: cyberhoward Date: Thu, 17 Oct 2024 11:13:59 +0200 Subject: [PATCH 18/21] add env file example rename to post-hook --- Developing.md | 8 +------- cargo-generate.toml | 3 +++ post-script.rhai | 1 + 3 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 post-script.rhai diff --git a/Developing.md b/Developing.md index 393690a..6eda44b 100644 --- a/Developing.md +++ b/Developing.md @@ -112,13 +112,7 @@ gzip it in the uploading process to make it even smaller). ## Deploying -Copy `.env.example` to `.env` and fill in the mnemonic that you want to use for deployment. - -```sh -cp .env.example .env -``` - -Then run the deploy script: +Fill in the mnemonic that you want to use for deployment in the `.env` file. Then run the deploy script: ```sh cargo deploy diff --git a/cargo-generate.toml b/cargo-generate.toml index 6b9a8b1..c77d32d 100644 --- a/cargo-generate.toml +++ b/cargo-generate.toml @@ -12,6 +12,9 @@ The minimal template assumes you already know how to write your own logic, and d Would you like to generate the minimal template?""" default = false +[hooks] +post = ["post-script.rhai"] + [conditional.'minimal'] ignore = [ "Developing.md", diff --git a/post-script.rhai b/post-script.rhai new file mode 100644 index 0000000..c8b2c47 --- /dev/null +++ b/post-script.rhai @@ -0,0 +1 @@ +file::rename(".env.example", ".env") From 07ed087791d5167fe0e6cf4ab973667d26029bc6 Mon Sep 17 00:00:00 2001 From: CyberHoward <88450409+CyberHoward@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:10:11 +0200 Subject: [PATCH 19/21] Update Developing.md --- Developing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Developing.md b/Developing.md index 6eda44b..0170a11 100644 --- a/Developing.md +++ b/Developing.md @@ -81,7 +81,7 @@ Which is equivalent to: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer:0.15.0 + cosmwasm/optimizer:0.16.1 ``` Or, If you're on an arm64 machine, you should use a docker image built with arm64. @@ -90,7 +90,7 @@ Or, If you're on an arm64 machine, you should use a docker image built with arm6 docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - cosmwasm/optimizer-arm64:0.15.0 + cosmwasm/optimizer-arm64:0.16.1 ``` We must mount the contract code to `/code`. You can use an absolute path instead From 15ec59ec3ef1a4a3c3af85f7f76d279ebdf0d2ad Mon Sep 17 00:00:00 2001 From: CyberHoward <88450409+CyberHoward@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:10:32 +0200 Subject: [PATCH 20/21] Update optimize.sh --- optimize.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/optimize.sh b/optimize.sh index 2f7d208..d2703f0 100755 --- a/optimize.sh +++ b/optimize.sh @@ -4,9 +4,9 @@ rm -rf ./artifacts/*.wasm if [[ $(arch) == "arm64" ]]; then - image="cosmwasm/optimizer-arm64:0.16.0" + image="cosmwasm/optimizer-arm64:0.16.1" else - image="cosmwasm/optimizer:0.16.0" + image="cosmwasm/optimizer:0.16.1" fi # Optimized builds @@ -15,4 +15,4 @@ docker run --rm -v "$(pwd)":/code \ -v "$(dirname "$(pwd)")/integrations":/integrations \ -v "$(dirname "$(pwd)")/framework":/framework \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ - ${image} \ No newline at end of file + ${image} From f746b08835dd6d04782a2b7ced914655d1f3eb3f Mon Sep 17 00:00:00 2001 From: CyberHoward <88450409+CyberHoward@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:11:44 +0200 Subject: [PATCH 21/21] Update optimize.sh --- optimize.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/optimize.sh b/optimize.sh index d2703f0..b47b67a 100755 --- a/optimize.sh +++ b/optimize.sh @@ -12,7 +12,5 @@ fi # Optimized builds docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ - -v "$(dirname "$(pwd)")/integrations":/integrations \ - -v "$(dirname "$(pwd)")/framework":/framework \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ ${image}