From d4c94cab52351900b22e1bf6697fe8e4c64a9047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Mon, 22 Jul 2024 15:13:33 +0200 Subject: [PATCH] feat: Remove support for `, custom(msg=.. ,query=..)` in entry_points macro --- .../contracts/cw1-subkeys/src/contract.rs | 10 +++---- examples/contracts/cw1-subkeys/src/cw1.rs | 2 +- .../contracts/cw1-subkeys/src/whitelist.rs | 2 +- .../contracts/cw1-whitelist/src/contract.rs | 6 ++--- examples/contracts/cw1-whitelist/src/cw1.rs | 2 +- .../contracts/cw1-whitelist/src/whitelist.rs | 2 +- .../contracts/cw20-base/src/allowances.rs | 2 +- examples/contracts/cw20-base/src/contract.rs | 10 +++---- examples/contracts/cw20-base/src/marketing.rs | 2 +- examples/contracts/cw20-base/src/minting.rs | 2 +- .../generics_forwarded/src/contract.rs | 2 +- sylvia-derive/src/message.rs | 20 +++++++------- sylvia-derive/src/parser/entry_point.rs | 26 ++----------------- sylvia/src/types.rs | 3 --- sylvia/tests/api.rs | 2 ++ sylvia/tests/custom_msg.rs | 3 ++- sylvia/tests/custom_query.rs | 3 ++- sylvia/tests/entry_points.rs | 3 ++- sylvia/tests/executor.rs | 13 +++++----- sylvia/tests/interface_impl.rs | 3 ++- sylvia/tests/multitest.rs | 2 ++ sylvia/tests/querier.rs | 19 +++++++------- sylvia/tests/query_returns.rs | 3 ++- sylvia/tests/remote.rs | 22 +++++++--------- sylvia/tests/replies.rs | 3 ++- 25 files changed, 76 insertions(+), 91 deletions(-) diff --git a/examples/contracts/cw1-subkeys/src/contract.rs b/examples/contracts/cw1-subkeys/src/contract.rs index 131c887d..f25192c3 100644 --- a/examples/contracts/cw1-subkeys/src/contract.rs +++ b/examples/contracts/cw1-subkeys/src/contract.rs @@ -25,10 +25,10 @@ pub const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); const MAX_LIMIT: u32 = 30; const DEFAULT_LIMIT: u32 = 10; -pub struct Cw1SubkeysContract<'a> { - pub(crate) whitelist: Cw1WhitelistContract<'a>, - pub(crate) permissions: Map<&'a Addr, Permissions>, - pub(crate) allowances: Map<&'a Addr, Allowance>, +pub struct Cw1SubkeysContract { + pub(crate) whitelist: Cw1WhitelistContract, + pub(crate) permissions: Map<&'static Addr, Permissions>, + pub(crate) allowances: Map<&'static Addr, Allowance>, } #[cfg_attr(not(feature = "library"), entry_points)] @@ -36,7 +36,7 @@ pub struct Cw1SubkeysContract<'a> { #[sv::error(ContractError)] #[sv::messages(cw1 as Cw1)] #[sv::messages(whitelist as Whitelist)] -impl<'abcd> Cw1SubkeysContract<'abcd> { +impl Cw1SubkeysContract { pub const fn new() -> Self { Self { whitelist: Cw1WhitelistContract::new(), diff --git a/examples/contracts/cw1-subkeys/src/cw1.rs b/examples/contracts/cw1-subkeys/src/cw1.rs index d8a1b065..a349deb6 100644 --- a/examples/contracts/cw1-subkeys/src/cw1.rs +++ b/examples/contracts/cw1-subkeys/src/cw1.rs @@ -5,7 +5,7 @@ use sylvia::types::{ExecCtx, QueryCtx}; use crate::contract::Cw1SubkeysContract; use crate::error::ContractError; -impl Cw1 for Cw1SubkeysContract<'_> { +impl Cw1 for Cw1SubkeysContract { type Error = ContractError; fn execute( diff --git a/examples/contracts/cw1-subkeys/src/whitelist.rs b/examples/contracts/cw1-subkeys/src/whitelist.rs index 7a67b93c..0817282d 100644 --- a/examples/contracts/cw1-subkeys/src/whitelist.rs +++ b/examples/contracts/cw1-subkeys/src/whitelist.rs @@ -6,7 +6,7 @@ use whitelist::Whitelist; use crate::contract::Cw1SubkeysContract; use crate::error::ContractError; -impl Whitelist for Cw1SubkeysContract<'_> { +impl Whitelist for Cw1SubkeysContract { type Error = ContractError; fn freeze(&self, ctx: ExecCtx) -> Result { diff --git a/examples/contracts/cw1-whitelist/src/contract.rs b/examples/contracts/cw1-whitelist/src/contract.rs index 123e8991..8797c0da 100644 --- a/examples/contracts/cw1-whitelist/src/contract.rs +++ b/examples/contracts/cw1-whitelist/src/contract.rs @@ -12,8 +12,8 @@ use sylvia::entry_points; const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME"); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -pub struct Cw1WhitelistContract<'a> { - pub(crate) admins: Map<&'a Addr, Empty>, +pub struct Cw1WhitelistContract { + pub(crate) admins: Map<&'static Addr, Empty>, pub(crate) mutable: Item, } @@ -22,7 +22,7 @@ pub struct Cw1WhitelistContract<'a> { #[sv::error(ContractError)] #[sv::messages(cw1 as Cw1)] #[sv::messages(whitelist as Whitelist)] -impl<'a> Cw1WhitelistContract<'a> { +impl Cw1WhitelistContract { pub const fn new() -> Self { Self { admins: Map::new("admins"), diff --git a/examples/contracts/cw1-whitelist/src/cw1.rs b/examples/contracts/cw1-whitelist/src/cw1.rs index 4dd3b551..0c94b658 100644 --- a/examples/contracts/cw1-whitelist/src/cw1.rs +++ b/examples/contracts/cw1-whitelist/src/cw1.rs @@ -5,7 +5,7 @@ use sylvia::types::{ExecCtx, QueryCtx}; use crate::contract::Cw1WhitelistContract; use crate::error::ContractError; -impl Cw1 for Cw1WhitelistContract<'_> { +impl Cw1 for Cw1WhitelistContract { type Error = ContractError; fn execute(&self, ctx: ExecCtx, msgs: Vec) -> Result { diff --git a/examples/contracts/cw1-whitelist/src/whitelist.rs b/examples/contracts/cw1-whitelist/src/whitelist.rs index d96f5495..0d9d2240 100644 --- a/examples/contracts/cw1-whitelist/src/whitelist.rs +++ b/examples/contracts/cw1-whitelist/src/whitelist.rs @@ -6,7 +6,7 @@ use whitelist::Whitelist; use crate::contract::Cw1WhitelistContract; use crate::error::ContractError; -impl Whitelist for Cw1WhitelistContract<'_> { +impl Whitelist for Cw1WhitelistContract { type Error = ContractError; fn freeze(&self, ctx: ExecCtx) -> Result { diff --git a/examples/contracts/cw20-base/src/allowances.rs b/examples/contracts/cw20-base/src/allowances.rs index 15ac5f8c..deb2d4db 100644 --- a/examples/contracts/cw20-base/src/allowances.rs +++ b/examples/contracts/cw20-base/src/allowances.rs @@ -16,7 +16,7 @@ use crate::responses::Cw20ReceiveMsg; const MAX_LIMIT: u32 = 30; const DEFAULT_LIMIT: u32 = 10; -impl Cw20Allowances for Cw20Base<'_> { +impl Cw20Allowances for Cw20Base { type Error = ContractError; /// Allows spender to access an additional amount tokens from the owner's (env.sender) account. diff --git a/examples/contracts/cw20-base/src/contract.rs b/examples/contracts/cw20-base/src/contract.rs index c594fe26..35d57f93 100644 --- a/examples/contracts/cw20-base/src/contract.rs +++ b/examples/contracts/cw20-base/src/contract.rs @@ -62,14 +62,14 @@ pub struct InstantiateMsgData { pub marketing: Option, } -pub struct Cw20Base<'a> { +pub struct Cw20Base { pub(crate) token_info: Item, pub(crate) marketing_info: Item, pub(crate) logo: Item, - pub(crate) balances: Map<&'a Addr, Uint128>, - pub(crate) allowances: Map<(&'a Addr, &'a Addr), AllowanceResponse>, + pub(crate) balances: Map<&'static Addr, Uint128>, + pub(crate) allowances: Map<(&'static Addr, &'static Addr), AllowanceResponse>, // TODO: After https://github.com/CosmWasm/cw-plus/issues/670 is implemented, replace this with a `MultiIndex` over `ALLOWANCES` - pub(crate) allowances_spender: Map<(&'a Addr, &'a Addr), AllowanceResponse>, + pub(crate) allowances_spender: Map<(&'static Addr, &'static Addr), AllowanceResponse>, } #[cfg_attr(not(feature = "library"), entry_points)] @@ -78,7 +78,7 @@ pub struct Cw20Base<'a> { #[sv::messages(cw20_allowances as Allowances)] #[sv::messages(cw20_marketing as Marketing)] #[sv::messages(cw20_minting as Minting)] -impl<'abcd> Cw20Base<'abcd> { +impl Cw20Base { pub const fn new() -> Self { Self { token_info: Item::new("token_info"), diff --git a/examples/contracts/cw20-base/src/marketing.rs b/examples/contracts/cw20-base/src/marketing.rs index 845c1c22..ed95836c 100644 --- a/examples/contracts/cw20-base/src/marketing.rs +++ b/examples/contracts/cw20-base/src/marketing.rs @@ -6,7 +6,7 @@ use cw20_marketing::responses::{DownloadLogoResponse, LogoInfo, MarketingInfoRes use cw20_marketing::{Cw20Marketing, EmbeddedLogo, Logo}; use sylvia::types::{ExecCtx, QueryCtx}; -impl Cw20Marketing for Cw20Base<'_> { +impl Cw20Marketing for Cw20Base { type Error = ContractError; fn update_marketing( diff --git a/examples/contracts/cw20-base/src/minting.rs b/examples/contracts/cw20-base/src/minting.rs index f13585cc..a6e4e416 100644 --- a/examples/contracts/cw20-base/src/minting.rs +++ b/examples/contracts/cw20-base/src/minting.rs @@ -5,7 +5,7 @@ use cw20_minting::responses::MinterResponse; use cw20_minting::Cw20Minting; use sylvia::types::{ExecCtx, QueryCtx}; -impl Cw20Minting for Cw20Base<'_> { +impl Cw20Minting for Cw20Base { type Error = ContractError; fn mint( diff --git a/examples/contracts/generics_forwarded/src/contract.rs b/examples/contracts/generics_forwarded/src/contract.rs index 945ff615..f6ac52dc 100644 --- a/examples/contracts/generics_forwarded/src/contract.rs +++ b/examples/contracts/generics_forwarded/src/contract.rs @@ -50,7 +50,7 @@ pub struct GenericsForwardedContract< )>, } -#[cfg_attr(not(feature = "library"), sylvia::entry_points(generics, custom(msg=SvCustomMsg, query=SvCustomQuery)))] +#[cfg_attr(not(feature = "library"), sylvia::entry_points(generics))] #[contract] #[sv::error(ContractError)] #[sv::messages(generic as Generic: custom(msg, query))] diff --git a/sylvia-derive/src/message.rs b/sylvia-derive/src/message.rs index d1c505b5..1259887e 100644 --- a/sylvia-derive/src/message.rs +++ b/sylvia-derive/src/message.rs @@ -1296,7 +1296,6 @@ pub struct EntryPoints<'a> { source: &'a ItemImpl, name: Type, error: Type, - custom: Custom, override_entry_points: Vec, generics: Vec<&'a GenericParam>, where_clause: &'a Option, @@ -1313,13 +1312,11 @@ impl<'a> EntryPoints<'a> { let generics: Vec<_> = source.generics.params.iter().collect(); let where_clause = &source.generics.where_clause; - let custom = parsed_attrs.custom_attr.unwrap_or_default(); Self { source, name, error, - custom, override_entry_points, generics, where_clause, @@ -1332,7 +1329,6 @@ impl<'a> EntryPoints<'a> { source, name, error, - custom, override_entry_points, generics, where_clause, @@ -1340,13 +1336,17 @@ impl<'a> EntryPoints<'a> { } = self; let sylvia = crate_module(); - let custom = match &attrs.custom { - Some(custom) => custom, - None => custom, - }; + let bracketed_generics = attrs + .generics + .as_ref() + .map(|generics| match generics.is_empty() { + true => quote! {}, + false => quote! { < #generics > }, + }) + .unwrap_or(quote! {}); - let custom_msg = custom.msg_or_default(); - let custom_query = custom.query_or_default(); + let custom_msg = parse_quote! { < #name #bracketed_generics as #sylvia ::types::ContractApi > :: CustomMsg }; + let custom_query = parse_quote! { < #name #bracketed_generics as #sylvia ::types::ContractApi > :: CustomQuery }; let instantiate_variants = MsgVariants::new( source.as_variants(), diff --git a/sylvia-derive/src/parser/entry_point.rs b/sylvia-derive/src/parser/entry_point.rs index 8c32b561..231bb0b5 100644 --- a/sylvia-derive/src/parser/entry_point.rs +++ b/sylvia-derive/src/parser/entry_point.rs @@ -1,9 +1,8 @@ -use syn::parse::{Error, Nothing, Parse, ParseStream, Parser}; +use syn::parse::{Error, Nothing, Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; -use syn::{parenthesized, GenericArgument, Path, Result, Token}; +use syn::{GenericArgument, Path, Result, Token}; -use super::attributes::custom::Custom; use super::extract_generics_from_path; /// Parsed arguments for `entry_points` macro @@ -11,8 +10,6 @@ use super::extract_generics_from_path; pub struct EntryPointArgs { /// Types used in place of contracts generics. pub generics: Option>, - /// Concrete custom msg/query used in place of contracts generic ones. - pub custom: Option, } impl Parse for EntryPointArgs { @@ -30,25 +27,6 @@ impl Parse for EntryPointArgs { _ => return Err(Error::new(generics.span(), "Expected `generics`.")), }; - let comma: Option = input.parse().ok(); - if comma.is_none() { - return Ok(entry_points_args); - } - - let custom: Option = input.parse().ok(); - match custom { - Some(custom) - if custom.get_ident().map(|custom| custom.to_string()) - == Some("custom".to_owned()) => - { - let content; - parenthesized!(content in input); - entry_points_args.custom = Some(Custom::parse.parse2(content.parse()?)?); - } - Some(attr) => return Err(Error::new(attr.span(), "Expected `custom`.")), - _ => (), - }; - let _: Nothing = input.parse()?; Ok(entry_points_args) diff --git a/sylvia/src/types.rs b/sylvia/src/types.rs index 19afb3b8..c4f7ec1c 100644 --- a/sylvia/src/types.rs +++ b/sylvia/src/types.rs @@ -572,7 +572,6 @@ pub trait InterfaceApi { /// Api trait for easier access to generated types and messages. pub trait ContractApi { - // Messages type Instantiate; type Query; type Exec; @@ -581,10 +580,8 @@ pub trait ContractApi { type ContractSudo; type Migrate; type Sudo; - // Communication type Querier<'querier>; type Remote<'remote>; - // Customs type CustomMsg: CustomMsg; type CustomQuery: CustomQuery; } diff --git a/sylvia/tests/api.rs b/sylvia/tests/api.rs index b8f2d568..5e441515 100644 --- a/sylvia/tests/api.rs +++ b/sylvia/tests/api.rs @@ -7,9 +7,11 @@ use sylvia::types::{ use sylvia_derive::contract; pub struct SomeContract { + #[allow(clippy::complexity)] _phantom: PhantomData<(Instantiate, Query, Exec, Migrate, Sudo, Ret, CMsg, CQuery)>, } +#[allow(dead_code)] #[contract] #[sv::custom(msg=CMsg, query=CQuery)] impl diff --git a/sylvia/tests/custom_msg.rs b/sylvia/tests/custom_msg.rs index dffc02d7..3d00c61d 100644 --- a/sylvia/tests/custom_msg.rs +++ b/sylvia/tests/custom_msg.rs @@ -1,8 +1,8 @@ use cosmwasm_std::{CustomMsg, Response, StdResult}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; +use sylvia::{contract, entry_points}; #[derive(Clone, PartialEq, Serialize, Deserialize, Debug, JsonSchema)] pub struct MyMsg; @@ -201,6 +201,7 @@ mod impl_associated_interface { } } +#[entry_points] #[contract] #[sv::messages(some_interface)] #[sv::messages(other_interface: custom(msg))] diff --git a/sylvia/tests/custom_query.rs b/sylvia/tests/custom_query.rs index 8d9113bc..53a9b20a 100644 --- a/sylvia/tests/custom_query.rs +++ b/sylvia/tests/custom_query.rs @@ -1,7 +1,7 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{CustomQuery, Response, StdResult}; -use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; +use sylvia::{contract, entry_points}; #[cw_serde] pub struct MyQuery; @@ -206,6 +206,7 @@ mod impl_default_query_interface { } } +#[entry_points] #[contract] #[sv::messages(some_interface)] #[sv::messages(associated_type_interface)] diff --git a/sylvia/tests/entry_points.rs b/sylvia/tests/entry_points.rs index c65a26b2..27332b0f 100644 --- a/sylvia/tests/entry_points.rs +++ b/sylvia/tests/entry_points.rs @@ -135,8 +135,8 @@ pub mod entry_points { mod contract { use cosmwasm_std::{Response, StdError, StdResult}; use cw_storage_plus::Item; - use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; + use sylvia::{contract, entry_points}; use crate::CountResponse; @@ -146,6 +146,7 @@ mod contract { pub(crate) migrates: Item, } + #[entry_points] #[contract] #[sv::override_entry_point(sudo=crate::entry_points::sudo(crate::sudo::SudoWrapperMsg))] #[sv::override_entry_point(migrate=crate::entry_points::migrate(crate::migrate::MigrateMsg))] diff --git a/sylvia/tests/executor.rs b/sylvia/tests/executor.rs index fa7687ad..712bdc7c 100644 --- a/sylvia/tests/executor.rs +++ b/sylvia/tests/executor.rs @@ -4,8 +4,8 @@ use cosmwasm_std::{Addr, Response, StdResult}; use cw_storage_plus::Item; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use sylvia::contract; use sylvia::types::InstantiateCtx; +use sylvia::{contract, entry_points}; #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct CountResponse { @@ -38,7 +38,7 @@ use counter::Counter; use sv::Executor as ContractExecutor; use sylvia::types::{ExecCtx, QueryCtx}; -impl Counter for CounterContract<'_> { +impl Counter for CounterContract { type Error = StdError; fn count(&self, ctx: QueryCtx) -> StdResult { @@ -56,15 +56,16 @@ impl Counter for CounterContract<'_> { } } -pub struct CounterContract<'a> { +pub struct CounterContract { pub count: Item, - pub remote_contract: Item>>, - pub remote_interface: Item>>, + pub remote_contract: Item>, + pub remote_interface: Item>>, } +#[entry_points] #[contract] #[sv::messages(counter)] -impl<'a> CounterContract<'a> { +impl CounterContract { #[allow(clippy::new_without_default)] pub fn new() -> Self { Self { diff --git a/sylvia/tests/interface_impl.rs b/sylvia/tests/interface_impl.rs index 6bd6615d..88d5427c 100644 --- a/sylvia/tests/interface_impl.rs +++ b/sylvia/tests/interface_impl.rs @@ -1,6 +1,6 @@ use cosmwasm_std::{Response, StdError, StdResult}; -use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx, SudoCtx}; +use sylvia::{contract, entry_points}; mod interface1 { use cosmwasm_std::{Response, StdError, StdResult}; @@ -46,6 +46,7 @@ mod interface2 { pub struct Contract; +#[entry_points] #[contract] #[sv::messages(interface1)] #[sv::messages(interface2)] diff --git a/sylvia/tests/multitest.rs b/sylvia/tests/multitest.rs index f20a8c2b..166067ea 100644 --- a/sylvia/tests/multitest.rs +++ b/sylvia/tests/multitest.rs @@ -3,6 +3,7 @@ use cosmwasm_std::{CodeInfoResponse, Empty, Response, StdResult}; use cw_multi_test::IntoBech32; use std::marker::PhantomData; +use sylvia::entry_points; use sylvia::multitest::App; use sylvia::types::InstantiateCtx; use sylvia_derive::contract; @@ -11,6 +12,7 @@ pub struct SomeContract { _phantom: PhantomData, } +#[entry_points(generics)] #[contract] impl SomeContract where diff --git a/sylvia/tests/querier.rs b/sylvia/tests/querier.rs index fe39632d..cd48971a 100644 --- a/sylvia/tests/querier.rs +++ b/sylvia/tests/querier.rs @@ -4,8 +4,8 @@ use cosmwasm_std::{Addr, Response, StdResult}; use cw_storage_plus::Item; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use sylvia::contract; use sylvia::types::InstantiateCtx; +use sylvia::{contract, entry_points}; #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] pub struct CountResponse { @@ -45,7 +45,7 @@ pub mod impl_counter { use cosmwasm_std::{Response, StdError, StdResult}; use sylvia::types::{ExecCtx, QueryCtx}; - impl Counter for super::CounterContract<'_> { + impl Counter for super::CounterContract { type Error = StdError; fn count(&self, ctx: QueryCtx) -> StdResult { @@ -88,14 +88,15 @@ pub mod impl_counter { } } -pub struct CounterContract<'a> { +pub struct CounterContract { pub count: Item, - pub remote: Item>>, + pub remote: Item>, } +#[entry_points] #[contract] #[sv::messages(counter)] -impl<'asdf> CounterContract<'asdf> { +impl CounterContract { #[allow(clippy::new_without_default)] pub fn new() -> Self { Self { @@ -130,19 +131,19 @@ mod tests { let remote_addr = Addr::unchecked("remote"); // Remote generation - let remote = sylvia::types::Remote::>::new(remote_addr.clone()); + let remote = sylvia::types::Remote::::new(remote_addr.clone()); let _: sylvia::types::BoundQuerier<_, _> = remote.querier(&querier_wrapper); - let remote = sylvia::types::Remote::>::new(remote_addr.clone()); + let remote = sylvia::types::Remote::::new(remote_addr.clone()); let _: sylvia::types::BoundQuerier<_, _> = remote.querier(&querier_wrapper); // Querier generation - let _ = sylvia::types::BoundQuerier::<_, super::CounterContract<'_>>::borrowed( + let _ = sylvia::types::BoundQuerier::<_, super::CounterContract>::borrowed( &remote_addr, &querier_wrapper, ); let querier = sylvia::types::BoundQuerier::borrowed(&remote_addr, &querier_wrapper); - let _ = sylvia::types::BoundQuerier::<_, super::CounterContract<'_>>::from(&querier); + let _ = sylvia::types::BoundQuerier::<_, super::CounterContract>::from(&querier); } #[test] diff --git a/sylvia/tests/query_returns.rs b/sylvia/tests/query_returns.rs index adbdc856..85430598 100644 --- a/sylvia/tests/query_returns.rs +++ b/sylvia/tests/query_returns.rs @@ -2,8 +2,8 @@ use cosmwasm_std::{Response, StdError, StdResult}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use sylvia::contract; use sylvia::types::{InstantiateCtx, QueryCtx}; +use sylvia::{contract, entry_points}; use thiserror::Error; #[derive(Error, Debug, PartialEq)] @@ -36,6 +36,7 @@ pub mod msg { pub struct SomeContract {} +#[entry_points] #[contract] #[sv::error(ContractError)] impl SomeContract { diff --git a/sylvia/tests/remote.rs b/sylvia/tests/remote.rs index 96b94d4d..2da8e309 100644 --- a/sylvia/tests/remote.rs +++ b/sylvia/tests/remote.rs @@ -159,14 +159,14 @@ pub mod unsigned_contract { // Making sure `Remote` can be stored in `#[cw_serde]` types #[cw_serde] #[allow(dead_code)] -pub struct ContractStorage<'a, Contract> { - remote: Remote<'a, Contract>, +pub struct ContractStorage { + remote: Remote<'static, Contract>, } #[derive(Serialize, Deserialize)] -pub struct InterfaceStorage<'a, CounterT> { +pub struct InterfaceStorage { interface_remote: Remote< - 'a, + 'static, dyn counter::Counter< Error = StdError, ExecC = ExampleMsg, @@ -176,7 +176,7 @@ pub struct InterfaceStorage<'a, CounterT> { >, } -impl InterfaceStorage<'_, CounterT> +impl InterfaceStorage where CounterT: Serialize + DeserializeOwned, { @@ -193,22 +193,20 @@ pub mod manager { use schemars::JsonSchema; use serde::de::DeserializeOwned; use serde::Serialize; - use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx}; + use sylvia::{contract, entry_points}; use crate::counter::sv::{Executor, Querier}; use crate::{ExampleMsg, ExampleQuery, InterfaceStorage}; - pub struct ManagerContract<'a, CounterT> { - remote_counter: Item>, + pub struct ManagerContract { + remote_counter: Item>, } + #[entry_points(generics)] #[contract] - // Due to how `cw_multi_test::App` is constructed to test two contracts they have - // to use the same custom types. - // Not sure if this limits testing of some real life scenarios. #[sv::custom(msg=ExampleMsg, query=ExampleQuery)] - impl<'a, CounterT> ManagerContract<'a, CounterT> + impl ManagerContract where CounterT: Serialize + DeserializeOwned + std::fmt::Debug + JsonSchema + 'static, { diff --git a/sylvia/tests/replies.rs b/sylvia/tests/replies.rs index 89bc92d8..663b255f 100644 --- a/sylvia/tests/replies.rs +++ b/sylvia/tests/replies.rs @@ -5,13 +5,14 @@ use sylvia::cw_std::{from_json, Reply, SubMsgResponse, SubMsgResult}; #[allow(dead_code)] mod noop_contract { - use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx}; + use sylvia::{contract, entry_points}; use sylvia::cw_std::{Response, StdResult}; pub struct NoopContract; + #[entry_points] #[contract] impl NoopContract { pub const fn new() -> Self {