Repository: CosmWasm/sylvia (rust)

Issue:
Consider better structure of generated code
Right now, generated code is bloated into the namespace where macros are used. There are also strange limitations on naming of the modules for traits, which creates a place for mistakes.

I would prefer to isolate things a bit. All generated things should go to `sv` module (so if we `#[contract]`, it would have things generated as `sv::ExecMsg`, `sv::QueryMsg`, etc). This way, rules about how to avoid naming collisions would be easy: single contract/interface call per module, but we eventually want the module to be named however the user wants to. Additionally "if you want to use sylvia, do not create `sv` modules yourself).

Additionally, I want to rename all tests-related generated modules to `mt` - we want to keep them short to be easy to type around. 

Pull request description:
feat: Wrap contract types in `sv` module
close #114 

Patch:
diff --git a/examples/contracts/custom/src/bin/schema.rs b/examples/contracts/custom/src/bin/schema.rs
index a60261b..554d313 100644
--- a/examples/contracts/custom/src/bin/schema.rs
+++ b/examples/contracts/custom/src/bin/schema.rs
@@ -1,6 +1,6 @@
 use cosmwasm_schema::write_api;
 
-use custom::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+use custom::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
diff --git a/examples/contracts/cw1-subkeys/src/bin/schema.rs b/examples/contracts/cw1-subkeys/src/bin/schema.rs
index b07cdba..c512923 100644
--- a/examples/contracts/cw1-subkeys/src/bin/schema.rs
+++ b/examples/contracts/cw1-subkeys/src/bin/schema.rs
@@ -1,6 +1,6 @@
 use cosmwasm_schema::write_api;
 
-use cw1_subkeys::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+use cw1_subkeys::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
diff --git a/examples/contracts/cw1-whitelist/src/bin/schema.rs b/examples/contracts/cw1-whitelist/src/bin/schema.rs
index fa957ed..3096b12 100644
--- a/examples/contracts/cw1-whitelist/src/bin/schema.rs
+++ b/examples/contracts/cw1-whitelist/src/bin/schema.rs
@@ -1,6 +1,6 @@
 use cosmwasm_schema::write_api;
 
-use cw1_whitelist::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+use cw1_whitelist::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
diff --git a/examples/contracts/cw1-whitelist/src/contract.rs b/examples/contracts/cw1-whitelist/src/contract.rs
index 9f5ae73..2bf302a 100644
--- a/examples/contracts/cw1-whitelist/src/contract.rs
+++ b/examples/contracts/cw1-whitelist/src/contract.rs
@@ -290,7 +290,7 @@ mod tests {
     mod msgs {
         use cosmwasm_std::{from_binary, from_slice, to_binary, BankMsg};
 
-        use crate::contract::{ContractExecMsg, ContractQueryMsg};
+        use crate::contract::sv::{ContractExecMsg, ContractQueryMsg};
 
         #[test]
         fn freeze() {
diff --git a/examples/contracts/cw20-base/src/bin/schema.rs b/examples/contracts/cw20-base/src/bin/schema.rs
index 3482c2f..ee47c95 100644
--- a/examples/contracts/cw20-base/src/bin/schema.rs
+++ b/examples/contracts/cw20-base/src/bin/schema.rs
@@ -1,6 +1,6 @@
 use cosmwasm_schema::write_api;
 
-use cw20_base::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+use cw20_base::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
diff --git a/examples/contracts/entry-points-overriding/src/bin/schema.rs b/examples/contracts/entry-points-overriding/src/bin/schema.rs
index 0c9fdd4..6d5bd4e 100644
--- a/examples/contracts/entry-points-overriding/src/bin/schema.rs
+++ b/examples/contracts/entry-points-overriding/src/bin/schema.rs
@@ -1,6 +1,6 @@
 use cosmwasm_schema::write_api;
 
-use entry_points_overriding::contract::{ContractQueryMsg, InstantiateMsg};
+use entry_points_overriding::contract::sv::{ContractQueryMsg, InstantiateMsg};
 use entry_points_overriding::messages::CustomExecMsg;
 use entry_points_overriding::messages::SudoMsg;
 
diff --git a/examples/contracts/entry-points-overriding/src/messages.rs b/examples/contracts/entry-points-overriding/src/messages.rs
index c032e2b..56b372b 100644
--- a/examples/contracts/entry-points-overriding/src/messages.rs
+++ b/examples/contracts/entry-points-overriding/src/messages.rs
@@ -2,7 +2,8 @@ use cosmwasm_schema::cw_serde;
 use cosmwasm_std::{DepsMut, Env, MessageInfo, Response, StdError, StdResult};
 use sylvia::types::ExecCtx;
 
-use crate::contract::{ContractExecMsg, CounterContract};
+use crate::contract::sv::ContractExecMsg;
+use crate::contract::CounterContract;
 
 #[cw_serde]
 pub struct CountResponse {
diff --git a/examples/contracts/generic_contract/src/bin/schema.rs b/examples/contracts/generic_contract/src/bin/schema.rs
index f84d1bb..db8d754 100644
--- a/examples/contracts/generic_contract/src/bin/schema.rs
+++ b/examples/contracts/generic_contract/src/bin/schema.rs
@@ -2,7 +2,7 @@ use cosmwasm_schema::write_api;
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
-    use generic_contract::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+    use generic_contract::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
     use sylvia::types::SvCustomMsg;
 
     write_api! {
diff --git a/examples/contracts/generic_contract/src/contract.rs b/examples/contracts/generic_contract/src/contract.rs
index e253e06..4fffc93 100644
--- a/examples/contracts/generic_contract/src/contract.rs
+++ b/examples/contracts/generic_contract/src/contract.rs
@@ -79,7 +79,7 @@ where
 
 #[cfg(test)]
 mod tests {
-    use super::multitest_utils::CodeId;
+    use super::sv::multitest_utils::CodeId;
     use sylvia::multitest::App;
     use sylvia::types::SvCustomMsg;
 
diff --git a/examples/contracts/generic_contract/src/custom_and_generic.rs b/examples/contracts/generic_contract/src/custom_and_generic.rs
index 47a1929..d1ce0b1 100644
--- a/examples/contracts/generic_contract/src/custom_and_generic.rs
+++ b/examples/contracts/generic_contract/src/custom_and_generic.rs
@@ -40,7 +40,7 @@ impl<InstantiateParam, ExecParam, QueryParam, MigrateParam, RetType>
 #[cfg(test)]
 mod tests {
     use super::sv::test_utils::CustomAndGeneric;
-    use crate::contract::multitest_utils::CodeId;
+    use crate::contract::sv::multitest_utils::CodeId;
     use sylvia::{multitest::App, types::SvCustomMsg};
 
     #[test]
diff --git a/examples/contracts/generic_contract/src/cw1.rs b/examples/contracts/generic_contract/src/cw1.rs
index 8113c60..4c5c125 100644
--- a/examples/contracts/generic_contract/src/cw1.rs
+++ b/examples/contracts/generic_contract/src/cw1.rs
@@ -36,7 +36,7 @@ impl<InstantiateParam, ExecParam, QueryParam, MigrateParam, RetType> Cw1
 #[cfg(test)]
 mod tests {
     use super::sv::test_utils::Cw1;
-    use crate::contract::multitest_utils::CodeId;
+    use crate::contract::sv::multitest_utils::CodeId;
     use cosmwasm_std::{CosmosMsg, Empty};
     use sylvia::{multitest::App, types::SvCustomMsg};
 
diff --git a/examples/contracts/generic_contract/src/generic.rs b/examples/contracts/generic_contract/src/generic.rs
index d7b32c2..8504c8a 100644
--- a/examples/contracts/generic_contract/src/generic.rs
+++ b/examples/contracts/generic_contract/src/generic.rs
@@ -44,7 +44,7 @@ impl<InstantiateParam, ExecParam, QueryParam, MigrateParam, RetType>
 #[cfg(test)]
 mod tests {
     use super::sv::test_utils::Generic;
-    use crate::contract::multitest_utils::CodeId;
+    use crate::contract::sv::multitest_utils::CodeId;
     use cosmwasm_std::CosmosMsg;
     use sylvia::multitest::App;
     use sylvia::types::SvCustomMsg;
diff --git a/examples/contracts/generic_iface_on_contract/src/bin/schema.rs b/examples/contracts/generic_iface_on_contract/src/bin/schema.rs
index 8a7c48e..03983dc 100644
--- a/examples/contracts/generic_iface_on_contract/src/bin/schema.rs
+++ b/examples/contracts/generic_iface_on_contract/src/bin/schema.rs
@@ -2,7 +2,9 @@ use cosmwasm_schema::write_api;
 
 #[cfg(not(tarpaulin_include))]
 fn main() {
-    use generic_iface_on_contract::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg};
+    use generic_iface_on_contract::contract::sv::{
+        ContractExecMsg, ContractQueryMsg, InstantiateMsg,
+    };
 
     write_api! {
         instantiate: InstantiateMsg,
diff --git a/examples/contracts/generic_iface_on_contract/src/contract.rs b/examples/contracts/generic_iface_on_contract/src/contract.rs
index 2d0adc4..0a94398 100644
--- a/examples/contracts/generic_iface_on_contract/src/contract.rs
+++ b/examples/contracts/generic_iface_on_contract/src/contract.rs
@@ -35,7 +35,7 @@ mod tests {
     fn mt_helpers() {
         let _ = NonGenericContract::new();
         let app = App::<cw_multi_test::BasicApp<SvCustomMsg>>::custom(|_, _, _| {});
-        let code_id = super::multitest_utils::CodeId::store_code(&app);
+        let code_id = super::sv::multitest_utils::CodeId::store_code(&app);
 
         let owner = "owner";
 
diff --git a/sylvia-derive/src/input.rs b/sylvia-derive/src/input.rs
index 11afc04..edd55cb 100644
--- a/sylvia-derive/src/input.rs
+++ b/sylvia-derive/src/input.rs
@@ -207,15 +207,19 @@ impl<'a> ImplInput<'a> {
         #[cfg(not(tarpaulin_include))]
         {
             quote! {
-                #messages
+                pub mod sv {
+                    use super::*;
 
-                #multitest_helpers
+                    #messages
 
-                #remote
+                    #multitest_helpers
 
-                #querier
+                    #remote
+
+                    #querier
 
-                #(#querier_from_impl)*
+                    #(#querier_from_impl)*
+                }
             }
         }
     }
diff --git a/sylvia-derive/src/message.rs b/sylvia-derive/src/message.rs
index 9c29910..141d114 100644
--- a/sylvia-derive/src/message.rs
+++ b/sylvia-derive/src/message.rs
@@ -978,8 +978,8 @@ where
             .map(|module| quote! { #module ::sv::Querier })
             .unwrap_or_else(|| quote! { sv::Querier });
         let bound_querier = contract_module
-            .map(|module| quote! { #module ::BoundQuerier})
-            .unwrap_or_else(|| quote! { BoundQuerier });
+            .map(|module| quote! { #module ::sv::BoundQuerier})
+            .unwrap_or_else(|| quote! { sv::BoundQuerier });
 
         let querier = if !used_generics.is_empty() {
             quote! { #querier < #(#used_generics,)* > }
@@ -1044,7 +1044,7 @@ where
             #[#sylvia ::cw_std::entry_point]
             pub fn #ep_name (
                 #params ,
-                msg: #msg_name #bracketed_generics,
+                msg: sv:: #msg_name #bracketed_generics,
             ) -> Result<#resp_type, #error> {
                 msg.dispatch(&#name ::new() , ( #values )).map_err(Into::into)
             }


Test patch:
diff --git a/examples/contracts/custom/src/multitest/tests.rs b/examples/contracts/custom/src/multitest/tests.rs
index 5bb9286..606444c 100644
--- a/examples/contracts/custom/src/multitest/tests.rs
+++ b/examples/contracts/custom/src/multitest/tests.rs
@@ -1,6 +1,6 @@
 use sylvia::multitest::App;
 
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 
 use super::custom_module::{CustomApp, CustomModule};
 
diff --git a/examples/contracts/cw1-subkeys/src/multitest/tests.rs b/examples/contracts/cw1-subkeys/src/multitest/tests.rs
index 71cc20d..a92fe84 100644
--- a/examples/contracts/cw1-subkeys/src/multitest/tests.rs
+++ b/examples/contracts/cw1-subkeys/src/multitest/tests.rs
@@ -3,7 +3,7 @@ use cw2::{query_contract_info, ContractVersion};
 use cw_utils::{Expiration, NativeBalance};
 use sylvia::multitest::App;
 
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 use crate::contract::{CONTRACT_NAME, CONTRACT_VERSION};
 
 const ATOM: &str = "atom";
diff --git a/examples/contracts/cw1-whitelist/src/multitest.rs b/examples/contracts/cw1-whitelist/src/multitest.rs
index 812f982..a91713d 100644
--- a/examples/contracts/cw1-whitelist/src/multitest.rs
+++ b/examples/contracts/cw1-whitelist/src/multitest.rs
@@ -3,7 +3,7 @@ mod test {
     use cosmwasm_std::{to_binary, WasmMsg};
     use whitelist::responses::AdminListResponse;
 
-    use crate::contract::multitest_utils::CodeId;
+    use crate::contract::sv::multitest_utils::CodeId;
     use crate::cw1::sv::test_utils::Cw1;
     use crate::error::ContractError;
     use crate::whitelist::sv::test_utils::Whitelist;
diff --git a/examples/contracts/cw20-base/src/multitest/allowances_tests.rs b/examples/contracts/cw20-base/src/multitest/allowances_tests.rs
index 22c2735..29fdf0a 100644
--- a/examples/contracts/cw20-base/src/multitest/allowances_tests.rs
+++ b/examples/contracts/cw20-base/src/multitest/allowances_tests.rs
@@ -8,10 +8,10 @@ use cw_utils::Expiration;
 use sylvia::multitest::App;
 
 use crate::allowances::sv::test_utils::Cw20Allowances;
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 use crate::contract::InstantiateMsgData;
 use crate::error::ContractError;
-use crate::multitest::receiver_contract::multitest_utils::CodeId as ReceiverCodeId;
+use crate::multitest::receiver_contract::sv::multitest_utils::CodeId as ReceiverCodeId;
 use crate::responses::Cw20Coin;
 
 #[test]
diff --git a/examples/contracts/cw20-base/src/multitest/base_tests.rs b/examples/contracts/cw20-base/src/multitest/base_tests.rs
index 7fdd382..f97a169 100644
--- a/examples/contracts/cw20-base/src/multitest/base_tests.rs
+++ b/examples/contracts/cw20-base/src/multitest/base_tests.rs
@@ -4,10 +4,10 @@ use cw_utils::Expiration;
 use sylvia::multitest::App;
 
 use crate::allowances::sv::test_utils::Cw20Allowances;
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 use crate::contract::InstantiateMsgData;
 use crate::error::ContractError;
-use crate::multitest::receiver_contract::multitest_utils::CodeId as ReceiverCodeId;
+use crate::multitest::receiver_contract::sv::multitest_utils::CodeId as ReceiverCodeId;
 use crate::responses::{BalanceResponse, Cw20Coin, TokenInfoResponse};
 
 #[test]
diff --git a/examples/contracts/cw20-base/src/multitest/marketing_tests.rs b/examples/contracts/cw20-base/src/multitest/marketing_tests.rs
index d8da5c1..c5e2235 100644
--- a/examples/contracts/cw20-base/src/multitest/marketing_tests.rs
+++ b/examples/contracts/cw20-base/src/multitest/marketing_tests.rs
@@ -3,7 +3,7 @@ use cw20_marketing::responses::{DownloadLogoResponse, LogoInfo, MarketingInfoRes
 use cw20_marketing::{EmbeddedLogo, Logo};
 use sylvia::multitest::App;
 
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 use crate::contract::{InstantiateMarketingInfo, InstantiateMsgData};
 use crate::error::ContractError;
 use crate::marketing::sv::test_utils::Cw20Marketing;
diff --git a/examples/contracts/cw20-base/src/multitest/minting_tests.rs b/examples/contracts/cw20-base/src/multitest/minting_tests.rs
index 72bdad0..50418d8 100644
--- a/examples/contracts/cw20-base/src/multitest/minting_tests.rs
+++ b/examples/contracts/cw20-base/src/multitest/minting_tests.rs
@@ -2,7 +2,7 @@ use cosmwasm_std::{StdError, Uint128};
 use cw20_minting::responses::MinterResponse;
 use sylvia::multitest::App;
 
-use crate::contract::multitest_utils::CodeId;
+use crate::contract::sv::multitest_utils::CodeId;
 use crate::contract::InstantiateMsgData;
 use crate::error::ContractError;
 use crate::minting::sv::test_utils::Cw20Minting;
diff --git a/examples/contracts/entry-points-overriding/src/multitest.rs b/examples/contracts/entry-points-overriding/src/multitest.rs
index d822451..9efda4e 100644
--- a/examples/contracts/entry-points-overriding/src/multitest.rs
+++ b/examples/contracts/entry-points-overriding/src/multitest.rs
@@ -1,9 +1,8 @@
 #[cfg(test)]
 mod test {
-    use crate::{
-        contract::{multitest_utils::CodeId, ContractExecMsg, ExecMsg},
-        messages::{CustomExecMsg, SudoMsg, UserExecMsg},
-    };
+    use crate::contract::sv::multitest_utils::CodeId;
+    use crate::contract::sv::{ContractExecMsg, ExecMsg};
+    use crate::messages::{CustomExecMsg, SudoMsg, UserExecMsg};
     use cosmwasm_std::Addr;
     use cw_multi_test::Executor;
     use sylvia::multitest::App;
diff --git a/sylvia/tests/custom_msg.rs b/sylvia/tests/custom_msg.rs
index da9aad5..55e6693 100644
--- a/sylvia/tests/custom_msg.rs
+++ b/sylvia/tests/custom_msg.rs
@@ -223,7 +223,7 @@ mod tests {
     fn test_custom() {
         let _ = MyContract::new();
         let app = App::<cw_multi_test::BasicApp<MyMsg>>::custom(|_, _, _| {});
-        let code_id = crate::multitest_utils::CodeId::store_code(&app);
+        let code_id = crate::sv::multitest_utils::CodeId::store_code(&app);
 
         let owner = "owner";
 
diff --git a/sylvia/tests/custom_query.rs b/sylvia/tests/custom_query.rs
index bf0a7cf..00c33d3 100644
--- a/sylvia/tests/custom_query.rs
+++ b/sylvia/tests/custom_query.rs
@@ -254,7 +254,7 @@ mod tests {
     fn test_custom() {
         let _ = MyContract::new();
         let app = App::<cw_multi_test::BasicApp<Empty, MyQuery>>::custom(|_, _, _| {});
-        let code_id = crate::multitest_utils::CodeId::store_code(&app);
+        let code_id = crate::sv::multitest_utils::CodeId::store_code(&app);
 
         let owner = "owner";
 
diff --git a/sylvia/tests/dispatching.rs b/sylvia/tests/dispatching.rs
index 8a1a35b..155354c 100644
--- a/sylvia/tests/dispatching.rs
+++ b/sylvia/tests/dispatching.rs
@@ -1,12 +1,20 @@
 use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info};
-use cosmwasm_std::{from_binary, Addr, Decimal, Response, StdError, StdResult};
-use interface::Interface;
+use cosmwasm_std::{from_binary, Addr, Decimal, Response};
 use schemars::JsonSchema;
 use serde::{Deserialize, Serialize};
-use std::cell::RefCell;
-use std::collections::HashMap;
-use sylvia::contract;
-use sylvia::types::{ExecCtx, QueryCtx};
+
+use crate::contract::Contract;
+
+#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub struct EmptyQueryResponse {}
+
+#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub struct QueryResponse {
+    coef: Decimal,
+    desc: String,
+}
 
 mod interface {
     use cosmwasm_std::{Addr, Decimal, Response, StdError};
@@ -40,77 +48,83 @@ mod interface {
     }
 }
 
-#[derive(Default)]
-pub struct Contract {
-    execs: RefCell<u64>,
-    queries: RefCell<u64>,
+mod impl_interface {
+    use cosmwasm_std::{Addr, Decimal, Response, StdError};
+    use sylvia::types::{ExecCtx, QueryCtx};
 
-    data: RefCell<HashMap<Addr, QueryResponse>>,
-}
+    use crate::{EmptyQueryResponse, QueryResponse};
 
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub struct EmptyQueryResponse {}
+    #[sylvia::contract(module = crate::contract)]
+    #[messages(crate::interface as Interface)]
+    impl crate::interface::Interface for crate::contract::Contract {
+        type Error = StdError;
 
-#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub struct QueryResponse {
-    coef: Decimal,
-    desc: String,
-}
-
-#[contract]
-#[messages(interface as Interface)]
-impl Interface for Contract {
-    type Error = StdError;
+        #[msg(exec)]
+        fn no_args_execution(&self, _: ExecCtx) -> Result<Response, StdError> {
+            *self.execs.borrow_mut() += 1;
+            Ok(Response::new())
+        }
 
-    #[msg(exec)]
-    fn no_args_execution(&self, _: ExecCtx) -> Result<Response, StdError> {
-        *self.execs.borrow_mut() += 1;
-        Ok(Response::new())
-    }
+        #[msg(exec)]
+        fn argumented_execution(
+            &self,
+            _: ExecCtx,
+            addr: Addr,
+            coef: Decimal,
+            desc: String,
+        ) -> Result<Response, Self::Error> {
+            *self.execs.borrow_mut() += 1;
 
-    #[msg(exec)]
-    fn argumented_execution(
-        &self,
-        _: ExecCtx,
-        addr: Addr,
-        coef: Decimal,
-        desc: String,
-    ) -> Result<Response, Self::Error> {
-        *self.execs.borrow_mut() += 1;
-
-        self.data
-            .borrow_mut()
-            .insert(addr, QueryResponse { coef, desc });
-        Ok(Response::new())
-    }
+            self.data
+                .borrow_mut()
+                .insert(addr, QueryResponse { coef, desc });
+            Ok(Response::new())
+        }
 
-    #[msg(query)]
-    fn no_args_query(&self, _: QueryCtx) -> Result<EmptyQueryResponse, StdError> {
-        *self.queries.borrow_mut() += 1;
-        Ok(dbg!(EmptyQueryResponse {}))
-    }
+        #[msg(query)]
+        fn no_args_query(&self, _: QueryCtx) -> Result<EmptyQueryResponse, StdError> {
+            *self.queries.borrow_mut() += 1;
+            Ok(dbg!(EmptyQueryResponse {}))
+        }
 
-    #[msg(query)]
-    fn argumented_query(&self, _: QueryCtx, user: Addr) -> Result<QueryResponse, Self::Error> {
-        *self.queries.borrow_mut() += 1;
-        Ok(self.data.borrow().get(&user).unwrap().clone())
+        #[msg(query)]
+        fn argumented_query(&self, _: QueryCtx, user: Addr) -> Result<QueryResponse, Self::Error> {
+            *self.queries.borrow_mut() += 1;
+            Ok(self.data.borrow().get(&user).unwrap().clone())
+        }
     }
 }
 
-#[allow(dead_code)]
-#[cfg(not(tarpaulin_include))]
-#[contract]
-#[messages(interface as Interface)]
-impl Contract {
-    fn new() -> Self {
-        Self::default()
+mod contract {
+    use std::{cell::RefCell, collections::HashMap};
+
+    use cosmwasm_std::{Addr, Response, StdResult};
+    use sylvia::types::ExecCtx;
+    use sylvia_derive::contract;
+
+    use crate::QueryResponse;
+
+    #[derive(Default)]
+    pub struct Contract {
+        pub(crate) execs: RefCell<u64>,
+        pub(crate) queries: RefCell<u64>,
+
+        pub(crate) data: RefCell<HashMap<Addr, QueryResponse>>,
     }
 
-    #[msg(instantiate)]
-    fn instanciate(&self, _: ExecCtx) -> StdResult<Response> {
-        Ok(Response::new())
+    #[allow(dead_code)]
+    #[cfg(not(tarpaulin_include))]
+    #[contract]
+    #[messages(crate::interface as Interface)]
+    impl Contract {
+        fn new() -> Self {
+            Self::default()
+        }
+
+        #[msg(instantiate)]
+        fn instanciate(&self, _: ExecCtx) -> StdResult<Response> {
+            Ok(Response::new())
+        }
     }
 }
 
diff --git a/sylvia/tests/entry_points.rs b/sylvia/tests/entry_points.rs
index d7bbb2e..951dfee 100644
--- a/sylvia/tests/entry_points.rs
+++ b/sylvia/tests/entry_points.rs
@@ -1,4 +1,4 @@
-use contract::ContractExecMsg;
+use contract::sv::ContractExecMsg;
 use cosmwasm_schema::cw_serde;
 use cosmwasm_std::Coin;
 use cw_storage_plus::Item;
@@ -145,8 +145,8 @@ mod tests {
     use cw_multi_test::Executor;
     use sylvia::multitest::App;
 
-    use crate::contract::multitest_utils::CodeId;
-    use crate::contract::{ContractExecMsg, ExecMsg};
+    use crate::contract::sv::multitest_utils::CodeId;
+    use crate::contract::sv::{ContractExecMsg, ExecMsg};
     use crate::exec::{CustomExecMsg, UserExecMsg};
     use crate::SudoMsg;
 
diff --git a/sylvia/tests/messages_generation.rs b/sylvia/tests/messages_generation.rs
index 023c71a..6fe0b94 100644
--- a/sylvia/tests/messages_generation.rs
+++ b/sylvia/tests/messages_generation.rs
@@ -137,28 +137,28 @@ fn interface_messages_constructible() {
 
 #[test]
 fn contract_messages_constructible() {
-    let no_args_exec = contract::ExecMsg::NoArgsExecution {};
-    let _argumented_exec = contract::ExecMsg::ArgumentedExecution {
+    let no_args_exec = contract::sv::ExecMsg::NoArgsExecution {};
+    let _argumented_exec = contract::sv::ExecMsg::ArgumentedExecution {
         _addr: Addr::unchecked("owner"),
         _coef: Decimal::percent(10),
         _desc: "Some description".to_owned(),
     };
-    let no_args_query = contract::QueryMsg::NoArgsQuery {};
-    let _argumented_query = contract::QueryMsg::ArgumentedQuery {
+    let no_args_query = contract::sv::QueryMsg::NoArgsQuery {};
+    let _argumented_query = contract::sv::QueryMsg::ArgumentedQuery {
         _user: Addr::unchecked("owner"),
     };
-    let _ = contract::InstantiateMsg {};
-    let _ = contract::MigrateMsg {};
+    let _ = contract::sv::InstantiateMsg {};
+    let _ = contract::sv::MigrateMsg {};
 
     // Ensure no extra variants are generated
     match no_args_exec {
-        contract::ExecMsg::NoArgsExecution {} => (),
-        contract::ExecMsg::ArgumentedExecution { .. } => (),
+        contract::sv::ExecMsg::NoArgsExecution {} => (),
+        contract::sv::ExecMsg::ArgumentedExecution { .. } => (),
     }
 
     match no_args_query {
-        contract::QueryMsg::NoArgsQuery {} => (),
-        contract::QueryMsg::ArgumentedQuery { .. } => (),
+        contract::sv::QueryMsg::NoArgsQuery {} => (),
+        contract::sv::QueryMsg::ArgumentedQuery { .. } => (),
     }
 }
 
diff --git a/sylvia/tests/querier.rs b/sylvia/tests/querier.rs
index 8720d79..9a78ed3 100644
--- a/sylvia/tests/querier.rs
+++ b/sylvia/tests/querier.rs
@@ -79,7 +79,7 @@ pub mod impl_counter {
         fn decrease_by_count(&self, ctx: ExecCtx) -> StdResult<Response> {
             let remote = self.remote.load(ctx.deps.storage)?;
             let other_count =
-                crate::counter::sv::BoundQuerier::borrowed(&remote.0, &ctx.deps.querier)
+                crate::counter::sv::BoundQuerier::borrowed(remote.as_ref(), &ctx.deps.querier)
                     .count()?
                     .count;
             self.count.update(ctx.deps.storage, |count| {
@@ -94,7 +94,7 @@ pub mod impl_counter {
 
 pub struct CounterContract<'a> {
     pub count: Item<'static, u64>,
-    pub remote: Item<'static, Remote<'a>>,
+    pub remote: Item<'static, sv::Remote<'a>>,
 }
 
 #[contract]
@@ -112,7 +112,7 @@ impl CounterContract<'_> {
     fn instantiate(&self, ctx: InstantiateCtx, remote_addr: Addr) -> StdResult<Response> {
         self.count.save(ctx.deps.storage, &0)?;
         self.remote
-            .save(ctx.deps.storage, &Remote::new(remote_addr))?;
+            .save(ctx.deps.storage, &sv::Remote::new(remote_addr))?;
         Ok(Response::new())
     }
 }
@@ -125,7 +125,7 @@ mod tests {
     use sylvia::multitest::App;
 
     use crate::impl_counter::sv::test_utils::Counter;
-    use crate::multitest_utils::CodeId;
+    use crate::sv::multitest_utils::CodeId;
 
     #[test]
     fn querier_generation() {
@@ -136,12 +136,12 @@ mod tests {
         // Remote generation
         let remote = super::counter::sv::Remote::new(remote_addr.clone());
         let _: super::counter::sv::BoundQuerier<_> = remote.querier(&querier_wrapper);
-        let remote = super::Remote::new(remote_addr.clone());
-        let _: super::BoundQuerier<_> = remote.querier(&querier_wrapper);
+        let remote = super::sv::Remote::new(remote_addr.clone());
+        let _: super::sv::BoundQuerier<_> = remote.querier(&querier_wrapper);
 
         // Querier generation
         let _ = super::counter::sv::BoundQuerier::borrowed(&remote_addr, &querier_wrapper);
-        let querier = super::BoundQuerier::borrowed(&remote_addr, &querier_wrapper);
+        let querier = super::sv::BoundQuerier::borrowed(&remote_addr, &querier_wrapper);
 
         let _ = super::counter::sv::BoundQuerier::from(&querier);
     }
diff --git a/sylvia/tests/query_returns.rs b/sylvia/tests/query_returns.rs
index 9bd63ce..b85dd6a 100644
--- a/sylvia/tests/query_returns.rs
+++ b/sylvia/tests/query_returns.rs
@@ -69,7 +69,7 @@ mod tests {
 
     #[test]
     fn generate_contract_query() {
-        let _ = QueryMsg::ContractQuery {
+        let _ = sv::QueryMsg::ContractQuery {
             _name: "some_name".to_owned(),
         };
     }
diff --git a/sylvia/tests/remote.rs b/sylvia/tests/remote.rs
index 0628e1a..4c93708 100644
--- a/sylvia/tests/remote.rs
+++ b/sylvia/tests/remote.rs
@@ -37,7 +37,7 @@ impl SomeContract {
 #[cw_serde]
 #[allow(dead_code)]
 struct CustomStorage {
-    remote: crate::Remote<'static>,
+    remote: crate::sv::Remote<'static>,
 }
 
 #[cfg(test)]
@@ -54,9 +54,9 @@ mod tests {
         let _ = some_interface::sv::Remote::borrowed(&addr);
 
         // contract
-        let new_remote = crate::Remote::new(Addr::unchecked("some_contract"));
+        let new_remote = crate::sv::Remote::new(Addr::unchecked("some_contract"));
         let addr = Addr::unchecked("some_contract");
-        let borrowed_remote = crate::Remote::borrowed(&addr);
+        let borrowed_remote = crate::sv::Remote::borrowed(&addr);
         assert_eq!(&Addr::unchecked("some_contract"), borrowed_remote.as_ref());
 
         let _ = some_interface::sv::Remote::from(&borrowed_remote);
diff --git a/sylvia/tests/replies.rs b/sylvia/tests/replies.rs
index a7bf502..979db3c 100644
--- a/sylvia/tests/replies.rs
+++ b/sylvia/tests/replies.rs
@@ -55,7 +55,7 @@ mod reply_contract {
 
         #[msg(exec)]
         fn poke(&self, _ctx: ExecCtx, noop: String) -> StdResult<Response> {
-            let msg = noop_contract::ExecMsg::Noop {};
+            let msg = noop_contract::sv::ExecMsg::Noop {};
             let msg = WasmMsg::Execute {
                 contract_addr: noop,
                 msg: to_binary(&msg)?,
@@ -93,16 +93,16 @@ fn entry_point_generation() {
     assert_eq!(data, "data");
 }
 
-#[cfg(feature = "mt")]
+#[cfg(all(test, feature = "mt"))]
 #[test]
 fn mt_helper_generation() {
     let app = sylvia::multitest::App::default();
     let owner = "owner";
 
-    let noop_contract_code = noop_contract::multitest_utils::CodeId::store_code(&app);
+    let noop_contract_code = noop_contract::sv::multitest_utils::CodeId::store_code(&app);
     let noop_contract = noop_contract_code.instantiate().call(owner).unwrap();
 
-    let reply_contract_code = reply_contract::multitest_utils::CodeId::store_code(&app);
+    let reply_contract_code = reply_contract::sv::multitest_utils::CodeId::store_code(&app);
     let reply_contract = reply_contract_code.instantiate().call(owner).unwrap();
 
     let resp = reply_contract