From 280ee80b7d08cb560cb2fa3521713c43b9c5acd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Thu, 31 Oct 2024 13:18:06 +0100 Subject: [PATCH] feat: Create ctx module for context types --- examples/contracts/custom/src/contract.rs | 2 + examples/contracts/custom/src/cw1.rs | 2 + .../contracts/cw1-subkeys/src/contract.rs | 2 + examples/contracts/cw1-subkeys/src/cw1.rs | 2 + .../contracts/cw1-subkeys/src/whitelist.rs | 2 + .../contracts/cw1-whitelist/src/contract.rs | 2 + 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 | 2 + examples/contracts/cw20-base/src/marketing.rs | 2 + examples/contracts/cw20-base/src/minting.rs | 2 + .../cw20-base/src/multitest/receiver.rs | 2 + .../src/multitest/receiver_contract.rs | 2 + .../entry-points-overriding/src/contract.rs | 2 + .../entry-points-overriding/src/messages.rs | 2 + .../generic_contract/src/contract.rs | 5 +- .../src/custom_and_generic.rs | 2 + .../contracts/generic_contract/src/cw1.rs | 2 + .../contracts/generic_contract/src/generic.rs | 2 + .../generic_iface_on_contract/src/contract.rs | 2 + .../src/custom_and_generic.rs | 2 + .../generic_iface_on_contract/src/cw1.rs | 2 + .../generic_iface_on_contract/src/generic.rs | 2 + .../generics_forwarded/src/contract.rs | 5 +- .../src/custom_and_generic.rs | 2 + .../contracts/generics_forwarded/src/cw1.rs | 2 + .../generics_forwarded/src/generic.rs | 2 + .../interfaces/custom-and-generic/src/lib.rs | 2 + examples/interfaces/cw1/src/lib.rs | 2 + .../interfaces/cw20-allowances/src/lib.rs | 2 + examples/interfaces/cw20-marketing/src/lib.rs | 2 + examples/interfaces/cw20-minting/src/lib.rs | 2 + examples/interfaces/cw4/src/lib.rs | 2 + examples/interfaces/generic/src/lib.rs | 2 + examples/interfaces/whitelist/src/lib.rs | 2 + sylvia-derive/src/lib.rs | 6 +- sylvia/examples/basic.rs | 2 + sylvia/src/ctx.rs | 131 ++++++++++++++++++ sylvia/src/lib.rs | 42 +----- sylvia/src/types.rs | 24 +++- sylvia/tests/api.rs | 2 + sylvia/tests/custom_msg.rs | 2 + sylvia/tests/custom_query.rs | 2 + sylvia/tests/dispatching.rs | 2 + sylvia/tests/entry_points.rs | 2 + sylvia/tests/executor.rs | 1 + sylvia/tests/interface_impl.rs | 2 + sylvia/tests/legacy_replies.rs | 2 + sylvia/tests/multitest.rs | 1 + sylvia/tests/querier.rs | 1 + sylvia/tests/query_returns.rs | 2 + sylvia/tests/remote.rs | 2 + sylvia/tests/reply_data.rs | 5 +- sylvia/tests/reply_dispatch.rs | 5 +- sylvia/tests/reply_generation.rs | 5 +- .../attr_forwarding/invalid_sv_attr.rs | 4 +- .../attr_forwarding/invalid_sv_attr.stderr | 2 +- .../ui/attributes/custom/invalid_custom.rs | 2 +- .../ui/attributes/features/invalid_params.rs | 2 +- .../ui/attributes/messages/invalid_custom.rs | 2 +- .../attributes/messages/unexpected_token.rs | 2 +- .../msg/overlapping_reply_handlers.rs | 2 +- sylvia/tests/ui/macros/entry_points.rs | 2 +- sylvia/tests/ui/method_signature/reply.rs | 2 +- .../tests/ui/missing_method/instantiation.rs | 1 + .../ui/missing_method/instantiation.stderr | 4 +- .../tests/ui/missing_method/msgs_misused.rs | 5 +- .../ui/missing_method/msgs_misused.stderr | 12 +- sylvia/tests/ui/missing_method/new.rs | 2 +- .../ui/missing_method/new_has_parameters.rs | 2 +- 71 files changed, 286 insertions(+), 79 deletions(-) create mode 100644 sylvia/src/ctx.rs diff --git a/examples/contracts/custom/src/contract.rs b/examples/contracts/custom/src/contract.rs index b5bbc667..293c94a6 100644 --- a/examples/contracts/custom/src/contract.rs +++ b/examples/contracts/custom/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw_storage_plus::Item; use sylvia::contract; use sylvia::cw_std::{CosmosMsg, QueryRequest, Response, StdResult}; diff --git a/examples/contracts/custom/src/cw1.rs b/examples/contracts/custom/src/cw1.rs index a2817a5c..c109f9d2 100644 --- a/examples/contracts/custom/src/cw1.rs +++ b/examples/contracts/custom/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_std::{CosmosMsg, Empty, Response, StdError, StdResult}; use sylvia::types::{ExecCtx, QueryCtx}; diff --git a/examples/contracts/cw1-subkeys/src/contract.rs b/examples/contracts/cw1-subkeys/src/contract.rs index 8b525591..80ea013b 100644 --- a/examples/contracts/cw1-subkeys/src/contract.rs +++ b/examples/contracts/cw1-subkeys/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1_whitelist::contract::Cw1WhitelistContract; use cw2::set_contract_version; use cw_storage_plus::{Bound, Map}; diff --git a/examples/contracts/cw1-subkeys/src/cw1.rs b/examples/contracts/cw1-subkeys/src/cw1.rs index 9b1879b4..d7c8a958 100644 --- a/examples/contracts/cw1-subkeys/src/cw1.rs +++ b/examples/contracts/cw1-subkeys/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_std::{ensure, Addr, CosmosMsg, Response, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; diff --git a/examples/contracts/cw1-subkeys/src/whitelist.rs b/examples/contracts/cw1-subkeys/src/whitelist.rs index bbd1fb0f..d10af0cc 100644 --- a/examples/contracts/cw1-subkeys/src/whitelist.rs +++ b/examples/contracts/cw1-subkeys/src/whitelist.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{Response, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; use whitelist::responses::AdminListResponse; diff --git a/examples/contracts/cw1-whitelist/src/contract.rs b/examples/contracts/cw1-whitelist/src/contract.rs index 531b2029..966e2bd2 100644 --- a/examples/contracts/cw1-whitelist/src/contract.rs +++ b/examples/contracts/cw1-whitelist/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::error::ContractError; use cw2::set_contract_version; use cw_storage_plus::{Item, Map}; diff --git a/examples/contracts/cw1-whitelist/src/cw1.rs b/examples/contracts/cw1-whitelist/src/cw1.rs index 84030602..a85e5e33 100644 --- a/examples/contracts/cw1-whitelist/src/cw1.rs +++ b/examples/contracts/cw1-whitelist/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_std::{Addr, CosmosMsg, Response, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; diff --git a/examples/contracts/cw1-whitelist/src/whitelist.rs b/examples/contracts/cw1-whitelist/src/whitelist.rs index e292d1e8..134513f4 100644 --- a/examples/contracts/cw1-whitelist/src/whitelist.rs +++ b/examples/contracts/cw1-whitelist/src/whitelist.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{Empty, Order, Response, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; use whitelist::responses::AdminListResponse; diff --git a/examples/contracts/cw20-base/src/allowances.rs b/examples/contracts/cw20-base/src/allowances.rs index bd9af057..205fa5f2 100644 --- a/examples/contracts/cw20-base/src/allowances.rs +++ b/examples/contracts/cw20-base/src/allowances.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw20_allowances::responses::{ AllAccountsResponse, AllAllowancesResponse, AllSpenderAllowancesResponse, AllowanceInfo, AllowanceResponse, SpenderAllowanceInfo, diff --git a/examples/contracts/cw20-base/src/contract.rs b/examples/contracts/cw20-base/src/contract.rs index 97d88a28..d9f1d1ba 100644 --- a/examples/contracts/cw20-base/src/contract.rs +++ b/examples/contracts/cw20-base/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::error::ContractError; use crate::responses::{BalanceResponse, Cw20Coin, Cw20ReceiveMsg, TokenInfoResponse}; use crate::validation::{validate_accounts, validate_msg, verify_logo}; diff --git a/examples/contracts/cw20-base/src/marketing.rs b/examples/contracts/cw20-base/src/marketing.rs index 45259358..d69c224b 100644 --- a/examples/contracts/cw20-base/src/marketing.rs +++ b/examples/contracts/cw20-base/src/marketing.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::contract::Cw20Base; use crate::error::ContractError; use crate::validation::verify_logo; diff --git a/examples/contracts/cw20-base/src/minting.rs b/examples/contracts/cw20-base/src/minting.rs index d7d6a382..34f6b4f0 100644 --- a/examples/contracts/cw20-base/src/minting.rs +++ b/examples/contracts/cw20-base/src/minting.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::contract::{Cw20Base, MinterData}; use crate::error::ContractError; use cw20_minting::responses::MinterResponse; diff --git a/examples/contracts/cw20-base/src/multitest/receiver.rs b/examples/contracts/cw20-base/src/multitest/receiver.rs index 40ad75d9..af9d814e 100644 --- a/examples/contracts/cw20-base/src/multitest/receiver.rs +++ b/examples/contracts/cw20-base/src/multitest/receiver.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{Binary, Response, StdError, Uint128}; use sylvia::interface; use sylvia::types::ExecCtx; diff --git a/examples/contracts/cw20-base/src/multitest/receiver_contract.rs b/examples/contracts/cw20-base/src/multitest/receiver_contract.rs index 643bc62a..9701b21d 100644 --- a/examples/contracts/cw20-base/src/multitest/receiver_contract.rs +++ b/examples/contracts/cw20-base/src/multitest/receiver_contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::contract; use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/examples/contracts/entry-points-overriding/src/contract.rs b/examples/contracts/entry-points-overriding/src/contract.rs index 6d4a7b1e..e4bf5f46 100644 --- a/examples/contracts/entry-points-overriding/src/contract.rs +++ b/examples/contracts/entry-points-overriding/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw_storage_plus::Item; use sylvia::contract; use sylvia::cw_std::{Response, StdError, StdResult}; diff --git a/examples/contracts/entry-points-overriding/src/messages.rs b/examples/contracts/entry-points-overriding/src/messages.rs index 0d85f435..3c572b9f 100644 --- a/examples/contracts/entry-points-overriding/src/messages.rs +++ b/examples/contracts/entry-points-overriding/src/messages.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{DepsMut, Env, MessageInfo, Response, StdError, StdResult}; use sylvia::types::ExecCtx; diff --git a/examples/contracts/generic_contract/src/contract.rs b/examples/contracts/generic_contract/src/contract.rs index ed6904e4..898a0851 100644 --- a/examples/contracts/generic_contract/src/contract.rs +++ b/examples/contracts/generic_contract/src/contract.rs @@ -1,8 +1,9 @@ +#![allow(deprecated)] + use cw_storage_plus::Item; use sylvia::contract; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Binary, Response, StdResult, SubMsgResult}; -#[allow(deprecated)] -use sylvia::replies::ReplyCtx; use sylvia::serde::Deserialize; use sylvia::types::{CustomMsg, ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; diff --git a/examples/contracts/generic_contract/src/custom_and_generic.rs b/examples/contracts/generic_contract/src/custom_and_generic.rs index ad1d06c4..81ac40ea 100644 --- a/examples/contracts/generic_contract/src/custom_and_generic.rs +++ b/examples/contracts/generic_contract/src/custom_and_generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use custom_and_generic::CustomAndGeneric; use sylvia::cw_std::{CosmosMsg, Response, StdError, StdResult}; use sylvia::types::{ExecCtx, QueryCtx, SudoCtx}; diff --git a/examples/contracts/generic_contract/src/cw1.rs b/examples/contracts/generic_contract/src/cw1.rs index 9d51212c..904fea34 100644 --- a/examples/contracts/generic_contract/src/cw1.rs +++ b/examples/contracts/generic_contract/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::contract::GenericContract; use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_std::{CosmosMsg, Empty, Response, StdError, StdResult}; diff --git a/examples/contracts/generic_contract/src/generic.rs b/examples/contracts/generic_contract/src/generic.rs index 1a7a3969..18bc6aec 100644 --- a/examples/contracts/generic_contract/src/generic.rs +++ b/examples/contracts/generic_contract/src/generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use generic::Generic; use sylvia::cw_std::{CosmosMsg, Response, StdError, StdResult}; use sylvia::serde::Deserialize; diff --git a/examples/contracts/generic_iface_on_contract/src/contract.rs b/examples/contracts/generic_iface_on_contract/src/contract.rs index 8440a492..2540b319 100644 --- a/examples/contracts/generic_iface_on_contract/src/contract.rs +++ b/examples/contracts/generic_iface_on_contract/src/contract.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::contract; use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/examples/contracts/generic_iface_on_contract/src/custom_and_generic.rs b/examples/contracts/generic_iface_on_contract/src/custom_and_generic.rs index 11dcb6cf..bb461953 100644 --- a/examples/contracts/generic_iface_on_contract/src/custom_and_generic.rs +++ b/examples/contracts/generic_iface_on_contract/src/custom_and_generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::contract::{SvCustomMsg, SvCustomQuery}; use custom_and_generic::CustomAndGeneric; use sylvia::cw_std::{CosmosMsg, Response, StdError, StdResult}; diff --git a/examples/contracts/generic_iface_on_contract/src/cw1.rs b/examples/contracts/generic_iface_on_contract/src/cw1.rs index 303e00a1..6779703c 100644 --- a/examples/contracts/generic_iface_on_contract/src/cw1.rs +++ b/examples/contracts/generic_iface_on_contract/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_std::{CosmosMsg, Empty, Response, StdError, StdResult}; use sylvia::types::{ExecCtx, QueryCtx}; diff --git a/examples/contracts/generic_iface_on_contract/src/generic.rs b/examples/contracts/generic_iface_on_contract/src/generic.rs index 00163613..035c2211 100644 --- a/examples/contracts/generic_iface_on_contract/src/generic.rs +++ b/examples/contracts/generic_iface_on_contract/src/generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use generic::Generic; use sylvia::cw_std::{CosmosMsg, Response, StdError, StdResult}; use sylvia::types::{ExecCtx, QueryCtx, SudoCtx}; diff --git a/examples/contracts/generics_forwarded/src/contract.rs b/examples/contracts/generics_forwarded/src/contract.rs index 2db264b4..9ce2b49f 100644 --- a/examples/contracts/generics_forwarded/src/contract.rs +++ b/examples/contracts/generics_forwarded/src/contract.rs @@ -1,11 +1,10 @@ -#![allow(clippy::type_complexity)] +#![allow(clippy::type_complexity, deprecated)] use crate::error::ContractError; use cw_storage_plus::Item; use sylvia::contract; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Binary, Response, SubMsgResult}; -#[allow(deprecated)] -use sylvia::replies::ReplyCtx; use sylvia::serde::Deserialize; use sylvia::types::{ CustomMsg, CustomQuery, ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx, diff --git a/examples/contracts/generics_forwarded/src/custom_and_generic.rs b/examples/contracts/generics_forwarded/src/custom_and_generic.rs index d7931682..82966470 100644 --- a/examples/contracts/generics_forwarded/src/custom_and_generic.rs +++ b/examples/contracts/generics_forwarded/src/custom_and_generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use custom_and_generic::CustomAndGeneric; use sylvia::cw_std::{CosmosMsg, Response}; use sylvia::serde::Deserialize; diff --git a/examples/contracts/generics_forwarded/src/cw1.rs b/examples/contracts/generics_forwarded/src/cw1.rs index 86ea3712..a7d56a29 100644 --- a/examples/contracts/generics_forwarded/src/cw1.rs +++ b/examples/contracts/generics_forwarded/src/cw1.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw1::{CanExecuteResp, Cw1}; use sylvia::cw_schema::schemars::JsonSchema; use sylvia::cw_std::{CosmosMsg, CustomMsg, Empty, Response, StdResult}; diff --git a/examples/contracts/generics_forwarded/src/generic.rs b/examples/contracts/generics_forwarded/src/generic.rs index 553aa61f..ee20c8d3 100644 --- a/examples/contracts/generics_forwarded/src/generic.rs +++ b/examples/contracts/generics_forwarded/src/generic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use generic::Generic; use sylvia::cw_std::{CosmosMsg, Response}; use sylvia::serde::Deserialize; diff --git a/examples/interfaces/custom-and-generic/src/lib.rs b/examples/interfaces/custom-and-generic/src/lib.rs index 5eece85f..02766680 100644 --- a/examples/interfaces/custom-and-generic/src/lib.rs +++ b/examples/interfaces/custom-and-generic/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{CosmosMsg, Response, StdError}; use sylvia::interface; diff --git a/examples/interfaces/cw1/src/lib.rs b/examples/interfaces/cw1/src/lib.rs index 97d85d65..c3e423c2 100644 --- a/examples/interfaces/cw1/src/lib.rs +++ b/examples/interfaces/cw1/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{CosmosMsg, Response, StdError, StdResult}; use sylvia::serde::{Deserialize, Serialize}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; diff --git a/examples/interfaces/cw20-allowances/src/lib.rs b/examples/interfaces/cw20-allowances/src/lib.rs index 16095921..e9b7ea2f 100644 --- a/examples/interfaces/cw20-allowances/src/lib.rs +++ b/examples/interfaces/cw20-allowances/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + pub mod responses; use cw_utils::Expiration; diff --git a/examples/interfaces/cw20-marketing/src/lib.rs b/examples/interfaces/cw20-marketing/src/lib.rs index 81f0500f..ae97ca18 100644 --- a/examples/interfaces/cw20-marketing/src/lib.rs +++ b/examples/interfaces/cw20-marketing/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + pub mod responses; use responses::{DownloadLogoResponse, MarketingInfoResponse}; diff --git a/examples/interfaces/cw20-minting/src/lib.rs b/examples/interfaces/cw20-minting/src/lib.rs index 9bfe86e3..061f9267 100644 --- a/examples/interfaces/cw20-minting/src/lib.rs +++ b/examples/interfaces/cw20-minting/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + pub mod responses; use responses::MinterResponse; diff --git a/examples/interfaces/cw4/src/lib.rs b/examples/interfaces/cw4/src/lib.rs index 1194ed65..1f8e081a 100644 --- a/examples/interfaces/cw4/src/lib.rs +++ b/examples/interfaces/cw4/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + pub mod responses; use responses::{ diff --git a/examples/interfaces/generic/src/lib.rs b/examples/interfaces/generic/src/lib.rs index c836ca0d..094fda50 100644 --- a/examples/interfaces/generic/src/lib.rs +++ b/examples/interfaces/generic/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{CosmosMsg, Response, StdError}; use sylvia::interface; diff --git a/examples/interfaces/whitelist/src/lib.rs b/examples/interfaces/whitelist/src/lib.rs index 472a433b..7c389808 100644 --- a/examples/interfaces/whitelist/src/lib.rs +++ b/examples/interfaces/whitelist/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use responses::AdminListResponse; use sylvia::cw_std::{Response, StdError, StdResult}; use sylvia::interface; diff --git a/sylvia-derive/src/lib.rs b/sylvia-derive/src/lib.rs index af8aca13..348545f8 100644 --- a/sylvia-derive/src/lib.rs +++ b/sylvia-derive/src/lib.rs @@ -264,7 +264,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// ## Example usage /// ```rust /// # use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; -/// # use sylvia::replies::ReplyCtx; +/// # use sylvia::ctx::ReplyCtx; /// # use sylvia::cw_std::{Binary, Response, StdError, SubMsgResult}; /// # use cw_storage_plus::Item; /// # use thiserror::Error; @@ -328,7 +328,7 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// /// ```rust /// # use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; -/// # use sylvia::replies::ReplyCtx; +/// # use sylvia::ctx::ReplyCtx; /// # use sylvia::cw_std::{Binary, Response, StdError, SubMsgResult}; /// # use cw_storage_plus::Item; /// # use thiserror::Error; @@ -673,7 +673,7 @@ fn contract_impl(attr: TokenStream2, item: TokenStream2) -> TokenStream2 { /// ## Example usage /// ```rust /// # use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; -/// # use sylvia::replies::ReplyCtx; +/// # use sylvia::ctx::ReplyCtx; /// # use sylvia::cw_std::{Binary, Reply, Response, StdResult, SubMsgResult}; /// # /// pub struct SvContract; diff --git a/sylvia/examples/basic.rs b/sylvia/examples/basic.rs index 9ccd252d..27920188 100644 --- a/sylvia/examples/basic.rs +++ b/sylvia/examples/basic.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use anyhow::Error; use cosmwasm_std::{Addr, Response}; use cw_storage_plus::{Item, Map}; diff --git a/sylvia/src/ctx.rs b/sylvia/src/ctx.rs new file mode 100644 index 00000000..113aa255 --- /dev/null +++ b/sylvia/src/ctx.rs @@ -0,0 +1,131 @@ +use cosmwasm_std::{Deps, DepsMut, Empty, Env, Event, MessageInfo, MsgResponse}; + +/// Represantation of `reply` context received in entry point. +#[non_exhaustive] +pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: DepsMut<'a, C>, + pub env: Env, + pub gas_used: u64, + pub events: Vec, + pub msg_responses: Vec, +} + +/// Represantation of `migrate` context received in entry point. +#[non_exhaustive] +pub struct MigrateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: DepsMut<'a, C>, + pub env: Env, +} + +/// Represantation of `execute` context received in entry point. +#[non_exhaustive] +pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: DepsMut<'a, C>, + pub env: Env, + pub info: MessageInfo, +} + +/// Represantation of `instantiate` context received in entry point. +#[non_exhaustive] +pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: DepsMut<'a, C>, + pub env: Env, + pub info: MessageInfo, +} + +/// Represantation of `query` context received in entry point. +#[non_exhaustive] +pub struct QueryCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: Deps<'a, C>, + pub env: Env, +} + +/// Represantation of `sudo` context received in entry point. +#[non_exhaustive] +pub struct SudoCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { + pub deps: DepsMut<'a, C>, + pub env: Env, +} + +impl ExecCtx<'_, C> { + pub fn branch(&'_ mut self) -> ExecCtx<'_, C> { + ExecCtx { + deps: self.deps.branch(), + env: self.env.clone(), + info: self.info.clone(), + } + } +} + +impl InstantiateCtx<'_, C> { + pub fn branch(&'_ mut self) -> InstantiateCtx<'_, C> { + InstantiateCtx { + deps: self.deps.branch(), + env: self.env.clone(), + info: self.info.clone(), + } + } +} + +impl SudoCtx<'_, C> { + pub fn branch(&'_ mut self) -> SudoCtx<'_, C> { + SudoCtx { + deps: self.deps.branch(), + env: self.env.clone(), + } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for MigrateCtx<'a, C> { + fn from((deps, env): (DepsMut<'a, C>, Env)) -> Self { + Self { deps, env } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> + From<(DepsMut<'a, C>, Env, u64, Vec, Vec)> for ReplyCtx<'a, C> +{ + fn from( + (deps, env, gas_used, events, msg_responses): ( + DepsMut<'a, C>, + Env, + u64, + Vec, + Vec, + ), + ) -> Self { + Self { + deps, + env, + gas_used, + events, + msg_responses, + } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, MessageInfo)> for ExecCtx<'a, C> { + fn from((deps, env, info): (DepsMut<'a, C>, Env, MessageInfo)) -> Self { + Self { deps, env, info } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env, MessageInfo)> + for InstantiateCtx<'a, C> +{ + fn from((deps, env, info): (DepsMut<'a, C>, Env, MessageInfo)) -> Self { + Self { deps, env, info } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> From<(Deps<'a, C>, Env)> for QueryCtx<'a, C> { + fn from((deps, env): (Deps<'a, C>, Env)) -> Self { + Self { deps, env } + } +} + +impl<'a, C: cosmwasm_std::CustomQuery> From<(DepsMut<'a, C>, Env)> for SudoCtx<'a, C> { + fn from((deps, env): (DepsMut<'a, C>, Env)) -> Self { + Self { deps, env } + } +} diff --git a/sylvia/src/lib.rs b/sylvia/src/lib.rs index 71ed418b..4b0a1ea8 100644 --- a/sylvia/src/lib.rs +++ b/sylvia/src/lib.rs @@ -4,6 +4,7 @@ //! Most of implementation lies in `sylvia-derive` crate which is reexported here pub mod builder; +pub mod ctx; pub mod into_response; #[cfg_attr(docsrs, doc(cfg(feature = "mt")))] #[cfg(feature = "mt")] @@ -28,44 +29,3 @@ pub use { cosmwasm_schema as cw_schema, cosmwasm_std as cw_std, schemars, serde, serde_cw_value as serde_value, serde_json_wasm as serde_json, }; - -pub mod replies { - use cosmwasm_std::{DepsMut, Empty, Env, Event, MsgResponse}; - - /// Represantation of `reply` context received in entry point. - #[deprecated( - since = "1.3.0", - note = "This type is added temporarily to not break existing API. Since `2.0.0` it will replace the `sylvia::types::ReplyCtx` type." - )] - #[non_exhaustive] - pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { - pub deps: DepsMut<'a, C>, - pub env: Env, - pub gas_used: u64, - pub events: Vec, - pub msg_responses: Vec, - } - - #[allow(deprecated)] - impl<'a, C: cosmwasm_std::CustomQuery> - From<(DepsMut<'a, C>, Env, u64, Vec, Vec)> for ReplyCtx<'a, C> - { - fn from( - (deps, env, gas_used, events, msg_responses): ( - DepsMut<'a, C>, - Env, - u64, - Vec, - Vec, - ), - ) -> Self { - Self { - deps, - env, - gas_used, - events, - msg_responses, - } - } - } -} diff --git a/sylvia/src/types.rs b/sylvia/src/types.rs index 9ab660bc..5247c4e2 100644 --- a/sylvia/src/types.rs +++ b/sylvia/src/types.rs @@ -1,4 +1,5 @@ //! Module providing utilities to build and use sylvia contracts. +#![allow(deprecated)] use cosmwasm_std::{Binary, Coin, Deps, DepsMut, Empty, Env, MessageInfo, WasmMsg}; use derivative::Derivative; @@ -462,7 +463,8 @@ impl<'a, Contract: ?Sized> AsRef for Remote<'a, Contract> { #[non_exhaustive] #[deprecated( since = "1.3.0", - note = "This type will be replaced with `sylvia::replies::ReplyCtx` in 2.0.0." + note = "This type will be replaced with `sylvia::ctx::ReplyCtx` in 2.0.0.\n + You can use `sylvia::ctx::ReplyCtx` before the 2.0.0 release by using `#[sv::features(replies)]` attribute." )] pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, @@ -471,6 +473,10 @@ pub struct ReplyCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { /// Represantation of `migrate` context received in entry point. #[non_exhaustive] +#[deprecated( + since = "1.3.0", + note = "This type will be replaced with `sylvia::ctx::MigrateCtx` in 2.0.0." +)] pub struct MigrateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -478,6 +484,10 @@ pub struct MigrateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { /// Represantation of `execute` context received in entry point. #[non_exhaustive] +#[deprecated( + since = "1.3.0", + note = "This type will be replaced with `sylvia::ctx::ExecCtx` in 2.0.0." +)] pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -486,6 +496,10 @@ pub struct ExecCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { /// Represantation of `instantiate` context received in entry point. #[non_exhaustive] +#[deprecated( + since = "1.3.0", + note = "This type will be replaced with `sylvia::ctx::InstantiateCtx` in 2.0.0." +)] pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, @@ -494,6 +508,10 @@ pub struct InstantiateCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { /// Represantation of `query` context received in entry point. #[non_exhaustive] +#[deprecated( + since = "1.3.0", + note = "This type will be replaced with `sylvia::ctx::QueryCtx` in 2.0.0." +)] pub struct QueryCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: Deps<'a, C>, pub env: Env, @@ -501,6 +519,10 @@ pub struct QueryCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { /// Represantation of `sudo` context received in entry point. #[non_exhaustive] +#[deprecated( + since = "1.3.0", + note = "This type will be replaced with `sylvia::ctx::SudoCtx` in 2.0.0." +)] pub struct SudoCtx<'a, C: cosmwasm_std::CustomQuery = Empty> { pub deps: DepsMut<'a, C>, pub env: Env, diff --git a/sylvia/tests/api.rs b/sylvia/tests/api.rs index 903f24e7..63e8c6f9 100644 --- a/sylvia/tests/api.rs +++ b/sylvia/tests/api.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use std::marker::PhantomData; use sylvia::cw_std::{Response, StdResult}; diff --git a/sylvia/tests/custom_msg.rs b/sylvia/tests/custom_msg.rs index d553ba39..e36b74b9 100644 --- a/sylvia/tests/custom_msg.rs +++ b/sylvia/tests/custom_msg.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use sylvia::cw_std::{CustomMsg, Response, StdResult}; diff --git a/sylvia/tests/custom_query.rs b/sylvia/tests/custom_query.rs index 1eaf7afe..913b411b 100644 --- a/sylvia/tests/custom_query.rs +++ b/sylvia/tests/custom_query.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cosmwasm_schema::cw_serde; use sylvia::cw_std::{CustomQuery, Response, StdResult}; use sylvia::types::{ExecCtx, InstantiateCtx, MigrateCtx, QueryCtx, SudoCtx}; diff --git a/sylvia/tests/dispatching.rs b/sylvia/tests/dispatching.rs index 985fab96..df0400d5 100644 --- a/sylvia/tests/dispatching.rs +++ b/sylvia/tests/dispatching.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cw_multi_test::IntoAddr; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; diff --git a/sylvia/tests/entry_points.rs b/sylvia/tests/entry_points.rs index f3657e39..17685ca6 100644 --- a/sylvia/tests/entry_points.rs +++ b/sylvia/tests/entry_points.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use contract::sv::ContractExecMsg; use cosmwasm_schema::cw_serde; diff --git a/sylvia/tests/executor.rs b/sylvia/tests/executor.rs index 88495c51..77e3d6cd 100644 --- a/sylvia/tests/executor.rs +++ b/sylvia/tests/executor.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] #![cfg(feature = "mt")] use cw_storage_plus::Item; diff --git a/sylvia/tests/interface_impl.rs b/sylvia/tests/interface_impl.rs index aa45a827..75cdb62d 100644 --- a/sylvia/tests/interface_impl.rs +++ b/sylvia/tests/interface_impl.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{Empty, Response, StdError, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, InstantiateCtx, QueryCtx, SudoCtx}; use sylvia::{contract, entry_points}; diff --git a/sylvia/tests/legacy_replies.rs b/sylvia/tests/legacy_replies.rs index 8f42d3f8..54751182 100644 --- a/sylvia/tests/legacy_replies.rs +++ b/sylvia/tests/legacy_replies.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + #[cfg(all(test, feature = "mt"))] use cw_multi_test::IntoBech32; use sylvia::cw_std::testing::{mock_dependencies, mock_env}; diff --git a/sylvia/tests/multitest.rs b/sylvia/tests/multitest.rs index 5146e8ad..6296699c 100644 --- a/sylvia/tests/multitest.rs +++ b/sylvia/tests/multitest.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] #![cfg(feature = "mt")] use cw_multi_test::IntoBech32; diff --git a/sylvia/tests/querier.rs b/sylvia/tests/querier.rs index 78ce4133..10674042 100644 --- a/sylvia/tests/querier.rs +++ b/sylvia/tests/querier.rs @@ -1,3 +1,4 @@ +#![allow(deprecated)] #![cfg(feature = "mt")] use cw_storage_plus::Item; diff --git a/sylvia/tests/query_returns.rs b/sylvia/tests/query_returns.rs index 6cfd5e1b..30837dde 100644 --- a/sylvia/tests/query_returns.rs +++ b/sylvia/tests/query_returns.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use sylvia::cw_std::{Response, StdError, StdResult}; use schemars::JsonSchema; diff --git a/sylvia/tests/remote.rs b/sylvia/tests/remote.rs index f7468e66..83673e9e 100644 --- a/sylvia/tests/remote.rs +++ b/sylvia/tests/remote.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cosmwasm_schema::cw_serde; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; diff --git a/sylvia/tests/reply_data.rs b/sylvia/tests/reply_data.rs index be04b108..26905754 100644 --- a/sylvia/tests/reply_data.rs +++ b/sylvia/tests/reply_data.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cosmwasm_schema::cw_serde; use cosmwasm_std::to_json_binary; use cw_storage_plus::Item; @@ -5,9 +7,8 @@ use cw_utils::{MsgInstantiateContractResponse, ParseReplyError}; use noop_contract::sv::{Executor, NoopContractInstantiateBuilder}; use sv::SubMsgMethods; use sylvia::builder::instantiate::InstantiateBuilder; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Addr, Binary, Response, StdError, SubMsg}; -#[allow(deprecated)] -use sylvia::replies::ReplyCtx; use sylvia::types::{ExecCtx, InstantiateCtx, Remote}; use sylvia::{contract, entry_points}; use thiserror::Error; diff --git a/sylvia/tests/reply_dispatch.rs b/sylvia/tests/reply_dispatch.rs index 52a8f38c..d9704fb6 100644 --- a/sylvia/tests/reply_dispatch.rs +++ b/sylvia/tests/reply_dispatch.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use cosmwasm_schema::cw_serde; use cosmwasm_std::{to_json_binary, BankMsg, CosmosMsg, Empty, SubMsgResult}; use cw_storage_plus::Item; @@ -7,9 +9,8 @@ use sv::{ SubMsgMethods, ALWAYS_REPLY_ID, ERROR_REPLY_ID, REMOTE_INSTANTIATED_REPLY_ID, SUCCESS_REPLY_ID, }; use sylvia::builder::instantiate::InstantiateBuilder; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Addr, Binary, Response, StdError, SubMsg}; -#[allow(deprecated)] -use sylvia::replies::ReplyCtx; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, InstantiateCtx, QueryCtx, Remote}; use sylvia::{contract, entry_points}; use thiserror::Error; diff --git a/sylvia/tests/reply_generation.rs b/sylvia/tests/reply_generation.rs index 4fdfaccd..a2a26edc 100644 --- a/sylvia/tests/reply_generation.rs +++ b/sylvia/tests/reply_generation.rs @@ -1,8 +1,9 @@ +#![allow(deprecated)] + use cosmwasm_std::{Binary, SubMsgResult}; use itertools::Itertools; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Response, StdResult}; -#[allow(deprecated)] -use sylvia::replies::ReplyCtx; use sylvia::types::InstantiateCtx; use sylvia::{contract, entry_points}; diff --git a/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.rs b/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.rs index 34db2616..fe6f1d91 100644 --- a/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.rs +++ b/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.rs @@ -1,11 +1,11 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::{ExecCtx, InstantiateCtx}; pub struct Contract; #[sylvia::contract] -#[sv::msg_attr(exec,)] +#[sv::msg_attr(exec)] #[sv::msg_attr(random_msg, PartialOrd)] #[sv::msg_attr(exec PartialOrd)] #[sv::msg_attr(PartialOrd)] diff --git a/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.stderr b/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.stderr index 6dda7303..9fd27b6b 100644 --- a/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.stderr +++ b/sylvia/tests/ui/attributes/attr_forwarding/invalid_sv_attr.stderr @@ -1,7 +1,7 @@ error: Expected attribute of the form: `#[sv::msg_attr(msg_type, attribute_to_forward)]` --> tests/ui/attributes/attr_forwarding/invalid_sv_attr.rs:8:16 | -8 | #[sv::msg_attr(exec,)] +8 | #[sv::msg_attr(exec)] | ^^^^ error: Invalid message type, expected one of: `exec`, `query`, `instantiate`, `migrate`, `reply` or `sudo`. diff --git a/sylvia/tests/ui/attributes/custom/invalid_custom.rs b/sylvia/tests/ui/attributes/custom/invalid_custom.rs index 0d33699b..4e208355 100644 --- a/sylvia/tests/ui/attributes/custom/invalid_custom.rs +++ b/sylvia/tests/ui/attributes/custom/invalid_custom.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/sylvia/tests/ui/attributes/features/invalid_params.rs b/sylvia/tests/ui/attributes/features/invalid_params.rs index a2c08e2f..b79d726f 100644 --- a/sylvia/tests/ui/attributes/features/invalid_params.rs +++ b/sylvia/tests/ui/attributes/features/invalid_params.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::contract; use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/sylvia/tests/ui/attributes/messages/invalid_custom.rs b/sylvia/tests/ui/attributes/messages/invalid_custom.rs index 5c4703a1..1fa88882 100644 --- a/sylvia/tests/ui/attributes/messages/invalid_custom.rs +++ b/sylvia/tests/ui/attributes/messages/invalid_custom.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/sylvia/tests/ui/attributes/messages/unexpected_token.rs b/sylvia/tests/ui/attributes/messages/unexpected_token.rs index 7d5cbad8..2f2c48db 100644 --- a/sylvia/tests/ui/attributes/messages/unexpected_token.rs +++ b/sylvia/tests/ui/attributes/messages/unexpected_token.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Empty, Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs b/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs index 4a2b5a35..c74c4e23 100644 --- a/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs +++ b/sylvia/tests/ui/attributes/msg/overlapping_reply_handlers.rs @@ -1,8 +1,8 @@ #![allow(unused_imports, deprecated)] use sylvia::contract; +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Reply, Response, StdResult}; -use sylvia::replies::ReplyCtx; use sylvia::types::InstantiateCtx; pub struct Contract; diff --git a/sylvia/tests/ui/macros/entry_points.rs b/sylvia/tests/ui/macros/entry_points.rs index 84a1e9a3..510b13e7 100644 --- a/sylvia/tests/ui/macros/entry_points.rs +++ b/sylvia/tests/ui/macros/entry_points.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::{CustomMsg, CustomQuery, InstantiateCtx}; diff --git a/sylvia/tests/ui/method_signature/reply.rs b/sylvia/tests/ui/method_signature/reply.rs index 16084744..35e8fa3b 100644 --- a/sylvia/tests/ui/method_signature/reply.rs +++ b/sylvia/tests/ui/method_signature/reply.rs @@ -1,6 +1,6 @@ #![allow(unused_imports, deprecated)] +use sylvia::ctx::ReplyCtx; use sylvia::cw_std::{Binary, Response, StdResult}; -use sylvia::replies::ReplyCtx; use sylvia::types::InstantiateCtx; pub mod mismatched_params { diff --git a/sylvia/tests/ui/missing_method/instantiation.rs b/sylvia/tests/ui/missing_method/instantiation.rs index 12aff85e..1a7f9561 100644 --- a/sylvia/tests/ui/missing_method/instantiation.rs +++ b/sylvia/tests/ui/missing_method/instantiation.rs @@ -1,3 +1,4 @@ +#![allow(unused_imports, deprecated)] pub struct Contract {} #[sylvia::contract] diff --git a/sylvia/tests/ui/missing_method/instantiation.stderr b/sylvia/tests/ui/missing_method/instantiation.stderr index 77352b93..a20e8a43 100644 --- a/sylvia/tests/ui/missing_method/instantiation.stderr +++ b/sylvia/tests/ui/missing_method/instantiation.stderr @@ -2,7 +2,7 @@ error: Missing instantiation message. = note: `sylvia::contract` requires exactly one method marked with `#[sv::msg(instantiation)]` attribute. - --> tests/ui/missing_method/instantiation.rs:4:1 + --> tests/ui/missing_method/instantiation.rs:5:1 | -4 | impl Contract { +5 | impl Contract { | ^^^^ diff --git a/sylvia/tests/ui/missing_method/msgs_misused.rs b/sylvia/tests/ui/missing_method/msgs_misused.rs index 11572ceb..45935bc6 100644 --- a/sylvia/tests/ui/missing_method/msgs_misused.rs +++ b/sylvia/tests/ui/missing_method/msgs_misused.rs @@ -1,12 +1,11 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; pub struct Contract; - mod interface { - use sylvia::cw_std::{Response, StdResult, StdError}; + use sylvia::cw_std::{Response, StdError, StdResult}; use sylvia::types::{InstantiateCtx, MigrateCtx}; #[sylvia::interface] diff --git a/sylvia/tests/ui/missing_method/msgs_misused.stderr b/sylvia/tests/ui/missing_method/msgs_misused.stderr index 0099269c..709aabe3 100644 --- a/sylvia/tests/ui/missing_method/msgs_misused.stderr +++ b/sylvia/tests/ui/missing_method/msgs_misused.stderr @@ -2,25 +2,25 @@ error: The message attribute `instantiate` is not supported in interfaces. = note: Contracts need to implement `instantiate` method within their `impl` block. - --> tests/ui/missing_method/msgs_misused.rs:17:12 + --> tests/ui/missing_method/msgs_misused.rs:16:12 | -17 | fn instantiate(&self, ctx: InstantiateCtx) -> StdResult; +16 | fn instantiate(&self, ctx: InstantiateCtx) -> StdResult; | ^^^^^^^^^^^ error: The message attribute `migrate` is not supported in interfaces = note: Contracts need to implement `migrate` method within their `impl` block. - --> tests/ui/missing_method/msgs_misused.rs:20:12 + --> tests/ui/missing_method/msgs_misused.rs:19:12 | -20 | fn migrate(&self, ctx: MigrateCtx) -> StdResult; +19 | fn migrate(&self, ctx: MigrateCtx) -> StdResult; | ^^^^^^^ error: More than one instantiation or migration message = note: Instantiation/Migration message previously defined here - --> tests/ui/missing_method/msgs_misused.rs:31:12 + --> tests/ui/missing_method/msgs_misused.rs:30:12 | -31 | pub fn instantiate(&self, ctx: InstantiateCtx) -> StdResult { +30 | pub fn instantiate(&self, ctx: InstantiateCtx) -> StdResult { | ^^^^^^^^^^^ diff --git a/sylvia/tests/ui/missing_method/new.rs b/sylvia/tests/ui/missing_method/new.rs index 2b21c26c..e7afe089 100644 --- a/sylvia/tests/ui/missing_method/new.rs +++ b/sylvia/tests/ui/missing_method/new.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx; diff --git a/sylvia/tests/ui/missing_method/new_has_parameters.rs b/sylvia/tests/ui/missing_method/new_has_parameters.rs index 43368f76..e56e4427 100644 --- a/sylvia/tests/ui/missing_method/new_has_parameters.rs +++ b/sylvia/tests/ui/missing_method/new_has_parameters.rs @@ -1,4 +1,4 @@ -#![allow(unused_imports)] +#![allow(unused_imports, deprecated)] use sylvia::cw_std::{Response, StdResult}; use sylvia::types::InstantiateCtx;