Skip to content

Commit

Permalink
feat: Wrap contract types in sv module
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Oct 25, 2023
1 parent ba0fe74 commit 8f840c3
Show file tree
Hide file tree
Showing 33 changed files with 150 additions and 130 deletions.
2 changes: 1 addition & 1 deletion examples/contracts/custom/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/custom/src/multitest/tests.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-subkeys/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-subkeys/src/multitest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-whitelist/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-whitelist/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-whitelist/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw20-base/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/cw20-base/src/multitest/base_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
3 changes: 2 additions & 1 deletion examples/contracts/entry-points-overriding/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions examples/contracts/entry-points-overriding/src/multitest.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/generic_contract/src/bin/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/generic_contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/generic_contract/src/cw1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/generic_contract/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
14 changes: 9 additions & 5 deletions sylvia-derive/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)*
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions sylvia-derive/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,)* > }
Expand Down Expand Up @@ -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,

Check warning on line 1047 in sylvia-derive/src/message.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/message.rs#L1047

Added line #L1047 was not covered by tests
) -> Result<#resp_type, #error> {
msg.dispatch(&#name ::new() , ( #values )).map_err(Into::into)
}
Expand Down
2 changes: 1 addition & 1 deletion sylvia/tests/custom_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion sylvia/tests/custom_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Loading

0 comments on commit 8f840c3

Please sign in to comment.