From 05aae9dbb3003fe6a35495da99300c808de8da55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wo=C5=BAniak?= Date: Fri, 23 Aug 2024 18:06:21 +0200 Subject: [PATCH] feat: Make cosmwasm_schema deps obsolete --- examples/Cargo.lock | 16 --------------- examples/Cargo.toml | 1 - examples/contracts/custom/Cargo.toml | 1 - examples/contracts/custom/src/bin/schema.rs | 3 ++- examples/contracts/custom/src/messages.rs | 8 ++++---- .../custom/src/multitest/custom_module.rs | 2 +- examples/contracts/cw1-subkeys/Cargo.toml | 1 - .../contracts/cw1-subkeys/src/bin/schema.rs | 3 ++- .../contracts/cw1-subkeys/src/responses.rs | 4 ++-- examples/contracts/cw1-whitelist/Cargo.toml | 1 - .../contracts/cw1-whitelist/src/bin/schema.rs | 3 ++- examples/contracts/cw20-base/Cargo.toml | 1 - .../contracts/cw20-base/src/bin/schema.rs | 3 ++- examples/contracts/cw20-base/src/contract.rs | 10 +++++----- .../cw20-base/src/multitest/receiver.rs | 2 +- examples/contracts/cw20-base/src/responses.rs | 14 ++++++------- .../entry-points-overriding/Cargo.toml | 1 - .../entry-points-overriding/src/bin/schema.rs | 3 ++- .../entry-points-overriding/src/messages.rs | 10 +++++----- .../contracts/generic_contract/Cargo.toml | 1 - .../generic_contract/src/bin/schema.rs | 3 ++- .../generic_contract/src/contract.rs | 4 ++-- .../generic_iface_on_contract/Cargo.toml | 1 - .../src/bin/schema.rs | 3 ++- .../generic_iface_on_contract/src/contract.rs | 4 ++-- .../contracts/generics_forwarded/Cargo.toml | 1 - .../generics_forwarded/src/bin/schema.rs | 3 ++- .../generics_forwarded/src/contract.rs | 4 ++-- .../contracts/generics_forwarded/src/cw1.rs | 2 +- .../interfaces/custom-and-generic/Cargo.toml | 1 - .../interfaces/custom-and-generic/src/lib.rs | 6 +++--- examples/interfaces/cw1/Cargo.toml | 1 - .../interfaces/cw20-allowances/Cargo.toml | 1 - .../interfaces/cw20-allowances/src/lib.rs | 2 +- .../cw20-allowances/src/responses.rs | 20 +++++++++++-------- examples/interfaces/cw20-marketing/Cargo.toml | 1 - examples/interfaces/cw20-marketing/src/lib.rs | 8 ++++---- .../cw20-marketing/src/responses.rs | 6 +++--- examples/interfaces/cw20-minting/Cargo.toml | 1 - examples/interfaces/cw20-minting/src/lib.rs | 2 +- .../interfaces/cw20-minting/src/responses.rs | 4 ++-- examples/interfaces/cw4/Cargo.toml | 1 - examples/interfaces/cw4/src/lib.rs | 2 +- examples/interfaces/cw4/src/responses.rs | 14 ++++++------- examples/interfaces/generic/Cargo.toml | 1 - examples/interfaces/generic/src/lib.rs | 4 ++-- examples/interfaces/whitelist/Cargo.toml | 1 - examples/interfaces/whitelist/src/lib.rs | 2 +- .../src/contract/communication/enum_msg.rs | 9 ++------- sylvia-derive/src/types/msg_type.rs | 6 ++++++ 50 files changed, 93 insertions(+), 113 deletions(-) diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 61aec0b8..8015bf4f 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -406,7 +406,6 @@ name = "custom" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "cw-storage-plus", "cw1", @@ -419,7 +418,6 @@ name = "custom-and-generic" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -474,7 +472,6 @@ name = "cw1" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -485,7 +482,6 @@ name = "cw1-subkeys" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "cw-storage-plus", "cw-utils", @@ -504,7 +500,6 @@ version = "0.5.0" dependencies = [ "anyhow", "assert_matches", - "cosmwasm-schema", "cw-multi-test", "cw-storage-plus", "cw1", @@ -535,7 +530,6 @@ name = "cw20-allowances" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "cw-utils", "serde", @@ -548,7 +542,6 @@ version = "0.5.0" dependencies = [ "anyhow", "assert_matches", - "cosmwasm-schema", "cw-multi-test", "cw-storage-plus", "cw-utils", @@ -567,7 +560,6 @@ name = "cw20-marketing" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -578,7 +570,6 @@ name = "cw20-minting" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -589,7 +580,6 @@ name = "cw4" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -721,7 +711,6 @@ name = "entry-points-overriding" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "cw-storage-plus", "cw-utils", @@ -756,7 +745,6 @@ name = "generic" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", @@ -778,7 +766,6 @@ name = "generic_contract" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "custom-and-generic", "cw-multi-test", "cw-storage-plus", @@ -794,7 +781,6 @@ name = "generic_iface_on_contract" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "custom-and-generic", "cw-multi-test", "cw-storage-plus", @@ -810,7 +796,6 @@ name = "generics_forwarded" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "custom-and-generic", "cw-multi-test", "cw-storage-plus", @@ -1462,7 +1447,6 @@ name = "whitelist" version = "0.5.0" dependencies = [ "anyhow", - "cosmwasm-schema", "cw-multi-test", "serde", "sylvia", diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 32a1b06c..5f5c119f 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -28,7 +28,6 @@ edition = "2021" [workspace.dependencies] anyhow = "1.0.86" -cosmwasm-schema = "2.1.3" cw-multi-test = "2.1.1" cw-storage-plus = "2.0.0" cw-utils = "2.0.0" diff --git a/examples/contracts/custom/Cargo.toml b/examples/contracts/custom/Cargo.toml index e51e7d61..288e1f82 100644 --- a/examples/contracts/custom/Cargo.toml +++ b/examples/contracts/custom/Cargo.toml @@ -18,7 +18,6 @@ mt = ["library", "anyhow", "cw-multi-test"] [dependencies] cw1 = { path = "../../interfaces/cw1" } -cosmwasm-schema = { workspace = true } cw-storage-plus = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/contracts/custom/src/bin/schema.rs b/examples/contracts/custom/src/bin/schema.rs index 554d313c..5b43e0c3 100644 --- a/examples/contracts/custom/src/bin/schema.rs +++ b/examples/contracts/custom/src/bin/schema.rs @@ -1,10 +1,11 @@ -use cosmwasm_schema::write_api; +use sylvia::cw_schema::write_api; use custom::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/custom/src/messages.rs b/examples/contracts/custom/src/messages.rs index 30076f85..852bb052 100644 --- a/examples/contracts/custom/src/messages.rs +++ b/examples/contracts/custom/src/messages.rs @@ -1,17 +1,17 @@ -use cosmwasm_schema::cw_serde; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{CustomMsg, CustomQuery}; -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct CountResponse { pub count: u64, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum CounterMsg { Increment {}, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum CounterQuery { Count {}, } diff --git a/examples/contracts/custom/src/multitest/custom_module.rs b/examples/contracts/custom/src/multitest/custom_module.rs index 86c5aef2..12c82aad 100644 --- a/examples/contracts/custom/src/multitest/custom_module.rs +++ b/examples/contracts/custom/src/multitest/custom_module.rs @@ -1,8 +1,8 @@ -use cosmwasm_schema::schemars::JsonSchema; use cw_multi_test::{AppResponse, CosmosRouter, Module}; use cw_storage_plus::Item; use serde::de::DeserializeOwned; use std::fmt::Debug; +use sylvia::cw_schema::schemars::JsonSchema; use sylvia::cw_std::{ to_json_binary, Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, StdError, StdResult, Storage, diff --git a/examples/contracts/cw1-subkeys/Cargo.toml b/examples/contracts/cw1-subkeys/Cargo.toml index 6e03b0c3..9dfc4904 100644 --- a/examples/contracts/cw1-subkeys/Cargo.toml +++ b/examples/contracts/cw1-subkeys/Cargo.toml @@ -12,7 +12,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } diff --git a/examples/contracts/cw1-subkeys/src/bin/schema.rs b/examples/contracts/cw1-subkeys/src/bin/schema.rs index 700b6c07..089ffed3 100644 --- a/examples/contracts/cw1-subkeys/src/bin/schema.rs +++ b/examples/contracts/cw1-subkeys/src/bin/schema.rs @@ -1,10 +1,11 @@ -use cosmwasm_schema::write_api; use cw1_subkeys::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use sylvia::cw_schema::write_api; use sylvia::cw_std::Empty; #[cfg(not(tarpaulin_include))] fn main() { write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/cw1-subkeys/src/responses.rs b/examples/contracts/cw1-subkeys/src/responses.rs index 69e4cfd8..ae0773a1 100644 --- a/examples/contracts/cw1-subkeys/src/responses.rs +++ b/examples/contracts/cw1-subkeys/src/responses.rs @@ -1,7 +1,7 @@ use crate::state::Permissions; -use cosmwasm_schema::schemars::JsonSchema; use cw_utils::{Expiration, NativeBalance}; use serde::{Deserialize, Serialize}; +use sylvia::cw_schema::schemars::JsonSchema; use sylvia::cw_std::Addr; use sylvia::schemars; @@ -43,7 +43,7 @@ impl AllowanceInfo { /// ``` /// # use cw_utils::{Expiration, NativeBalance}; /// # use cw1_subkeys::msg::AllowanceInfo; - /// # use cosmwasm_schema::{cw_serde, QueryResponses}; + /// # use sylvia::cw_schema::{cw_serde, QueryResponses}; /// # use sylvia::cw_std::coin; /// /// let mut allows = vec![Allowance { diff --git a/examples/contracts/cw1-whitelist/Cargo.toml b/examples/contracts/cw1-whitelist/Cargo.toml index a4422d09..756f8aed 100644 --- a/examples/contracts/cw1-whitelist/Cargo.toml +++ b/examples/contracts/cw1-whitelist/Cargo.toml @@ -16,7 +16,6 @@ library = [] mt = ["sylvia/mt", "library", "cw-multi-test", "anyhow"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } cw1 = { path = "../../interfaces/cw1" } diff --git a/examples/contracts/cw1-whitelist/src/bin/schema.rs b/examples/contracts/cw1-whitelist/src/bin/schema.rs index 952678d6..7276fb9e 100644 --- a/examples/contracts/cw1-whitelist/src/bin/schema.rs +++ b/examples/contracts/cw1-whitelist/src/bin/schema.rs @@ -1,10 +1,11 @@ -use cosmwasm_schema::write_api; use cw1_whitelist::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use sylvia::cw_schema::write_api; use sylvia::cw_std::Empty; #[cfg(not(tarpaulin_include))] fn main() { write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/cw20-base/Cargo.toml b/examples/contracts/cw20-base/Cargo.toml index 2e2ea2c4..89757820 100644 --- a/examples/contracts/cw20-base/Cargo.toml +++ b/examples/contracts/cw20-base/Cargo.toml @@ -17,7 +17,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } diff --git a/examples/contracts/cw20-base/src/bin/schema.rs b/examples/contracts/cw20-base/src/bin/schema.rs index 7d9ee6a5..f2addffb 100644 --- a/examples/contracts/cw20-base/src/bin/schema.rs +++ b/examples/contracts/cw20-base/src/bin/schema.rs @@ -1,10 +1,11 @@ -use cosmwasm_schema::write_api; use cw20_base::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use sylvia::cw_schema::write_api; use sylvia::cw_std::Empty; #[cfg(not(tarpaulin_include))] fn main() { write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/cw20-base/src/contract.rs b/examples/contracts/cw20-base/src/contract.rs index 5abf5ec2..2d382d3d 100644 --- a/examples/contracts/cw20-base/src/contract.rs +++ b/examples/contracts/cw20-base/src/contract.rs @@ -1,13 +1,13 @@ use crate::error::ContractError; use crate::responses::{BalanceResponse, Cw20Coin, Cw20ReceiveMsg, TokenInfoResponse}; use crate::validation::{validate_accounts, validate_msg, verify_logo}; -use cosmwasm_schema::cw_serde; use cw2::{ensure_from_older_version, set_contract_version}; use cw20_allowances::responses::AllowanceResponse; use cw20_marketing::responses::{LogoInfo, MarketingInfoResponse}; use cw20_marketing::Logo; use cw20_minting::responses::MinterResponse; use cw_storage_plus::{Item, Map}; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{ ensure, Addr, Binary, BlockInfo, DepsMut, Empty, Order, Response, StdError, StdResult, Storage, Uint128, @@ -22,7 +22,7 @@ use sylvia::entry_points; const CONTRACT_NAME: &str = "crates.io:cw20-base"; const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct TokenInfo { pub name: String, pub symbol: String, @@ -37,14 +37,14 @@ impl TokenInfo { } } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct MinterData { pub minter: Addr, /// cap is how many more tokens can be issued by the minter pub cap: Option, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct InstantiateMarketingInfo { pub project: Option, pub description: Option, @@ -52,7 +52,7 @@ pub struct InstantiateMarketingInfo { pub logo: Option, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct InstantiateMsgData { pub name: String, pub symbol: String, diff --git a/examples/contracts/cw20-base/src/multitest/receiver.rs b/examples/contracts/cw20-base/src/multitest/receiver.rs index bdcb0aee..40ad75d9 100644 --- a/examples/contracts/cw20-base/src/multitest/receiver.rs +++ b/examples/contracts/cw20-base/src/multitest/receiver.rs @@ -1,6 +1,6 @@ use sylvia::cw_std::{Binary, Response, StdError, Uint128}; +use sylvia::interface; use sylvia::types::ExecCtx; -use sylvia::{interface, schemars}; #[interface] #[sv::custom(msg=sylvia::cw_std::Empty, query=sylvia::cw_std::Empty)] diff --git a/examples/contracts/cw20-base/src/responses.rs b/examples/contracts/cw20-base/src/responses.rs index 2e759d6c..f10e1887 100644 --- a/examples/contracts/cw20-base/src/responses.rs +++ b/examples/contracts/cw20-base/src/responses.rs @@ -1,9 +1,9 @@ -use cosmwasm_schema::cw_serde; use std::fmt; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{to_json_binary, Addr, Binary, CosmosMsg, StdResult, Uint128, WasmMsg}; /// Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a ExecuteMsg -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct Cw20ReceiveMsg { pub sender: String, pub amount: Uint128, @@ -30,12 +30,12 @@ impl Cw20ReceiveMsg { } // This is just a helper to properly serialize the above message -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] enum ReceiverExecuteMsg { Receive(Cw20ReceiveMsg), } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct Cw20Coin { pub address: String, pub amount: Uint128, @@ -53,7 +53,7 @@ impl fmt::Display for Cw20Coin { } } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct Cw20CoinVerified { pub address: Addr, pub amount: Uint128, @@ -71,12 +71,12 @@ impl fmt::Display for Cw20CoinVerified { } } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct BalanceResponse { pub balance: Uint128, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct TokenInfoResponse { pub name: String, pub symbol: String, diff --git a/examples/contracts/entry-points-overriding/Cargo.toml b/examples/contracts/entry-points-overriding/Cargo.toml index 3b996d93..198aed62 100644 --- a/examples/contracts/entry-points-overriding/Cargo.toml +++ b/examples/contracts/entry-points-overriding/Cargo.toml @@ -17,7 +17,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } diff --git a/examples/contracts/entry-points-overriding/src/bin/schema.rs b/examples/contracts/entry-points-overriding/src/bin/schema.rs index 2275f114..a80362a8 100644 --- a/examples/contracts/entry-points-overriding/src/bin/schema.rs +++ b/examples/contracts/entry-points-overriding/src/bin/schema.rs @@ -1,4 +1,4 @@ -use cosmwasm_schema::write_api; +use sylvia::cw_schema::write_api; use entry_points_overriding::contract::sv::{ContractQueryMsg, InstantiateMsg}; use entry_points_overriding::messages::{CustomExecMsg, SudoMsg}; @@ -6,6 +6,7 @@ use entry_points_overriding::messages::{CustomExecMsg, SudoMsg}; #[cfg(not(tarpaulin_include))] fn main() { write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: CustomExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/entry-points-overriding/src/messages.rs b/examples/contracts/entry-points-overriding/src/messages.rs index 34fa206e..0d85f435 100644 --- a/examples/contracts/entry-points-overriding/src/messages.rs +++ b/examples/contracts/entry-points-overriding/src/messages.rs @@ -1,21 +1,21 @@ -use cosmwasm_schema::cw_serde; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{DepsMut, Env, MessageInfo, Response, StdError, StdResult}; use sylvia::types::ExecCtx; use crate::contract::sv::ContractExecMsg; use crate::contract::CounterContract; -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct CountResponse { pub count: u32, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum SudoMsg { SetCountToThree {}, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum UserExecMsg { IncreaseByOne {}, } @@ -29,7 +29,7 @@ pub fn increase_by_one(ctx: ExecCtx) -> StdResult { Ok(Response::new()) } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum CustomExecMsg { ContractExec(ContractExecMsg), CustomExec(UserExecMsg), diff --git a/examples/contracts/generic_contract/Cargo.toml b/examples/contracts/generic_contract/Cargo.toml index 053f8692..208703dc 100644 --- a/examples/contracts/generic_contract/Cargo.toml +++ b/examples/contracts/generic_contract/Cargo.toml @@ -17,7 +17,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } diff --git a/examples/contracts/generic_contract/src/bin/schema.rs b/examples/contracts/generic_contract/src/bin/schema.rs index 6cd3cfdc..552e5a84 100644 --- a/examples/contracts/generic_contract/src/bin/schema.rs +++ b/examples/contracts/generic_contract/src/bin/schema.rs @@ -1,4 +1,4 @@ -use cosmwasm_schema::write_api; +use sylvia::cw_schema::write_api; #[cfg(not(tarpaulin_include))] fn main() { @@ -6,6 +6,7 @@ fn main() { use generic_contract::contract::SvCustomMsg; write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/generic_contract/src/contract.rs b/examples/contracts/generic_contract/src/contract.rs index 132c4e10..fee30001 100644 --- a/examples/contracts/generic_contract/src/contract.rs +++ b/examples/contracts/generic_contract/src/contract.rs @@ -7,11 +7,11 @@ use sylvia::{contract, schemars}; #[cfg(not(feature = "library"))] use sylvia::entry_points; -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomMsg; impl sylvia::cw_std::CustomMsg for SvCustomMsg {} -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomQuery; impl sylvia::cw_std::CustomQuery for SvCustomQuery {} diff --git a/examples/contracts/generic_iface_on_contract/Cargo.toml b/examples/contracts/generic_iface_on_contract/Cargo.toml index 4cc7dafc..d4ebe964 100644 --- a/examples/contracts/generic_iface_on_contract/Cargo.toml +++ b/examples/contracts/generic_iface_on_contract/Cargo.toml @@ -17,7 +17,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } 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 03983dc6..be80142c 100644 --- a/examples/contracts/generic_iface_on_contract/src/bin/schema.rs +++ b/examples/contracts/generic_iface_on_contract/src/bin/schema.rs @@ -1,4 +1,4 @@ -use cosmwasm_schema::write_api; +use sylvia::cw_schema::write_api; #[cfg(not(tarpaulin_include))] fn main() { @@ -7,6 +7,7 @@ fn main() { }; write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, execute: ContractExecMsg, query: ContractQueryMsg, diff --git a/examples/contracts/generic_iface_on_contract/src/contract.rs b/examples/contracts/generic_iface_on_contract/src/contract.rs index a9788d0b..c6bd839f 100644 --- a/examples/contracts/generic_iface_on_contract/src/contract.rs +++ b/examples/contracts/generic_iface_on_contract/src/contract.rs @@ -7,11 +7,11 @@ use sylvia::entry_points; pub struct NonGenericContract; -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomMsg; impl sylvia::cw_std::CustomMsg for SvCustomMsg {} -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomQuery; impl sylvia::cw_std::CustomQuery for SvCustomQuery {} diff --git a/examples/contracts/generics_forwarded/Cargo.toml b/examples/contracts/generics_forwarded/Cargo.toml index 8ec6cb18..858d84c4 100644 --- a/examples/contracts/generics_forwarded/Cargo.toml +++ b/examples/contracts/generics_forwarded/Cargo.toml @@ -17,7 +17,6 @@ mt = ["library", "cw-multi-test", "anyhow"] [dependencies] anyhow = { workspace = true, optional = true } -cosmwasm-schema = { workspace = true } cw-multi-test = { workspace = true, optional = true } cw-storage-plus = { workspace = true } cw-utils = { workspace = true } diff --git a/examples/contracts/generics_forwarded/src/bin/schema.rs b/examples/contracts/generics_forwarded/src/bin/schema.rs index deec2b7b..41e80bc3 100644 --- a/examples/contracts/generics_forwarded/src/bin/schema.rs +++ b/examples/contracts/generics_forwarded/src/bin/schema.rs @@ -1,4 +1,4 @@ -use cosmwasm_schema::write_api; +use sylvia::cw_schema::write_api; #[cfg(not(tarpaulin_include))] fn main() { @@ -6,6 +6,7 @@ fn main() { use generics_forwarded::contract::{SvCustomMsg, SvCustomQuery}; write_api! { + crate_name: sylvia::cw_schema, instantiate: InstantiateMsg, // We should rethink this. We generate messages generic over types used in the methods. // To do so we however have to merge generics from the contract and interfaces methods. diff --git a/examples/contracts/generics_forwarded/src/contract.rs b/examples/contracts/generics_forwarded/src/contract.rs index 54b2b6ea..758be894 100644 --- a/examples/contracts/generics_forwarded/src/contract.rs +++ b/examples/contracts/generics_forwarded/src/contract.rs @@ -7,11 +7,11 @@ use sylvia::types::{ }; use sylvia::{contract, schemars}; -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomMsg; impl sylvia::cw_std::CustomMsg for SvCustomMsg {} -#[cosmwasm_schema::cw_serde] +#[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomQuery; impl sylvia::cw_std::CustomQuery for SvCustomQuery {} diff --git a/examples/contracts/generics_forwarded/src/cw1.rs b/examples/contracts/generics_forwarded/src/cw1.rs index 401d0463..5db5ce3b 100644 --- a/examples/contracts/generics_forwarded/src/cw1.rs +++ b/examples/contracts/generics_forwarded/src/cw1.rs @@ -1,7 +1,7 @@ -use cosmwasm_schema::schemars::JsonSchema; use cw1::{CanExecuteResp, Cw1}; use serde::de::DeserializeOwned; use serde::Deserialize; +use sylvia::cw_schema::schemars::JsonSchema; use sylvia::cw_std::{CosmosMsg, CustomMsg, Empty, Response, StdResult}; use sylvia::types::{CustomQuery, ExecCtx, QueryCtx}; diff --git a/examples/interfaces/custom-and-generic/Cargo.toml b/examples/interfaces/custom-and-generic/Cargo.toml index 0c64cdc0..edeca40d 100644 --- a/examples/interfaces/custom-and-generic/Cargo.toml +++ b/examples/interfaces/custom-and-generic/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/custom-and-generic/src/lib.rs b/examples/interfaces/custom-and-generic/src/lib.rs index a9eb9eba..5eece85f 100644 --- a/examples/interfaces/custom-and-generic/src/lib.rs +++ b/examples/interfaces/custom-and-generic/src/lib.rs @@ -1,7 +1,7 @@ use sylvia::cw_std::{CosmosMsg, Response, StdError}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx, SudoCtx}; -use sylvia::{interface, schemars}; #[interface] pub trait CustomAndGeneric { @@ -77,10 +77,10 @@ mod tests { use crate::sv::Querier; - #[cosmwasm_schema::cw_serde] + #[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomMsg; impl sylvia::cw_std::CustomMsg for SvCustomMsg {} - #[cosmwasm_schema::cw_serde] + #[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomQuery; impl sylvia::cw_std::CustomQuery for SvCustomQuery {} diff --git a/examples/interfaces/cw1/Cargo.toml b/examples/interfaces/cw1/Cargo.toml index 62c5abf3..647b05c3 100644 --- a/examples/interfaces/cw1/Cargo.toml +++ b/examples/interfaces/cw1/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/cw20-allowances/Cargo.toml b/examples/interfaces/cw20-allowances/Cargo.toml index fdedb391..5e0cdb05 100644 --- a/examples/interfaces/cw20-allowances/Cargo.toml +++ b/examples/interfaces/cw20-allowances/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } cw-utils = { workspace = true } diff --git a/examples/interfaces/cw20-allowances/src/lib.rs b/examples/interfaces/cw20-allowances/src/lib.rs index ff2f28dd..16095921 100644 --- a/examples/interfaces/cw20-allowances/src/lib.rs +++ b/examples/interfaces/cw20-allowances/src/lib.rs @@ -5,8 +5,8 @@ use responses::{ AllAccountsResponse, AllAllowancesResponse, AllSpenderAllowancesResponse, AllowanceResponse, }; use sylvia::cw_std::{Binary, Response, StdError, StdResult, Uint128}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; -use sylvia::{interface, schemars}; #[interface] pub trait Cw20Allowances { diff --git a/examples/interfaces/cw20-allowances/src/responses.rs b/examples/interfaces/cw20-allowances/src/responses.rs index 34e8cded..7d908c0f 100644 --- a/examples/interfaces/cw20-allowances/src/responses.rs +++ b/examples/interfaces/cw20-allowances/src/responses.rs @@ -1,40 +1,44 @@ -use cosmwasm_schema::cw_serde; use cw_utils::Expiration; use serde::{Deserialize, Serialize}; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::Uint128; -use sylvia::schemars; +use sylvia::schemars::JsonSchema; -#[derive(Serialize, Deserialize, Clone, PartialEq, schemars::JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[schemars(crate = "sylvia::cw_schema::schemars")] pub struct AllowanceResponse { pub allowance: Uint128, pub expires: Expiration, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct AllowanceInfo { pub spender: String, pub allowance: Uint128, pub expires: Expiration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, schemars::JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[schemars(crate = "sylvia::cw_schema::schemars")] pub struct AllAllowancesResponse { pub allowances: Vec, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct SpenderAllowanceInfo { pub owner: String, pub allowance: Uint128, pub expires: Expiration, } -#[derive(Serialize, Deserialize, Clone, PartialEq, schemars::JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)] +#[schemars(crate = "sylvia::cw_schema::schemars")] pub struct AllSpenderAllowancesResponse { pub allowances: Vec, } -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, schemars::JsonSchema, Debug, Default)] +#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)] +#[schemars(crate = "sylvia::cw_schema::schemars")] pub struct AllAccountsResponse { pub accounts: Vec, } diff --git a/examples/interfaces/cw20-marketing/Cargo.toml b/examples/interfaces/cw20-marketing/Cargo.toml index 76f80da6..5ab3ee5d 100644 --- a/examples/interfaces/cw20-marketing/Cargo.toml +++ b/examples/interfaces/cw20-marketing/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/cw20-marketing/src/lib.rs b/examples/interfaces/cw20-marketing/src/lib.rs index 04189022..81f0500f 100644 --- a/examples/interfaces/cw20-marketing/src/lib.rs +++ b/examples/interfaces/cw20-marketing/src/lib.rs @@ -1,13 +1,13 @@ pub mod responses; -use cosmwasm_schema::cw_serde; use responses::{DownloadLogoResponse, MarketingInfoResponse}; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{Binary, Response, StdError, StdResult}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; -use sylvia::{interface, schemars}; /// This is used for uploading logo data, or setting it in InstantiateData -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum Logo { /// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. Url(String), @@ -17,7 +17,7 @@ pub enum Logo { /// This is used to store the logo on the blockchain in an accepted format. /// Enforce maximum size of 5KB on all variants. -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum EmbeddedLogo { /// Store the Logo as an SVG file. The content must conform to the spec /// at https://en.wikipedia.org/wiki/Scalable_Vector_Graphics diff --git a/examples/interfaces/cw20-marketing/src/responses.rs b/examples/interfaces/cw20-marketing/src/responses.rs index f3319304..6cccde26 100644 --- a/examples/interfaces/cw20-marketing/src/responses.rs +++ b/examples/interfaces/cw20-marketing/src/responses.rs @@ -1,11 +1,11 @@ -use cosmwasm_schema::cw_serde; use serde::{Deserialize, Serialize}; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::{Addr, Binary}; use sylvia::schemars; /// This is used to display logo info, provide a link or inform there is one /// that can be downloaded from the blockchain itself -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub enum LogoInfo { /// A reference to an externally hosted logo. Must be a valid HTTP or HTTPS URL. Url(String), @@ -27,7 +27,7 @@ pub struct MarketingInfoResponse { /// When we download an embedded logo, we get this response type. /// We expect a SPA to be able to accept this info and display it. -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct DownloadLogoResponse { pub mime_type: String, pub data: Binary, diff --git a/examples/interfaces/cw20-minting/Cargo.toml b/examples/interfaces/cw20-minting/Cargo.toml index 6af6214e..2266968a 100644 --- a/examples/interfaces/cw20-minting/Cargo.toml +++ b/examples/interfaces/cw20-minting/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/cw20-minting/src/lib.rs b/examples/interfaces/cw20-minting/src/lib.rs index 0b1a4195..9bfe86e3 100644 --- a/examples/interfaces/cw20-minting/src/lib.rs +++ b/examples/interfaces/cw20-minting/src/lib.rs @@ -2,8 +2,8 @@ pub mod responses; use responses::MinterResponse; use sylvia::cw_std::{Response, StdError, StdResult, Uint128}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; -use sylvia::{interface, schemars}; #[interface] pub trait Cw20Minting { diff --git a/examples/interfaces/cw20-minting/src/responses.rs b/examples/interfaces/cw20-minting/src/responses.rs index 7dbe3e5c..a156f850 100644 --- a/examples/interfaces/cw20-minting/src/responses.rs +++ b/examples/interfaces/cw20-minting/src/responses.rs @@ -1,7 +1,7 @@ -use cosmwasm_schema::cw_serde; +use sylvia::cw_schema::cw_serde; use sylvia::cw_std::Uint128; -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct MinterResponse { pub minter: String, /// cap is a hard cap on total supply that can be achieved by minting. diff --git a/examples/interfaces/cw4/Cargo.toml b/examples/interfaces/cw4/Cargo.toml index bd71a508..7419584a 100644 --- a/examples/interfaces/cw4/Cargo.toml +++ b/examples/interfaces/cw4/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/cw4/src/lib.rs b/examples/interfaces/cw4/src/lib.rs index 22eb0468..1194ed65 100644 --- a/examples/interfaces/cw4/src/lib.rs +++ b/examples/interfaces/cw4/src/lib.rs @@ -4,8 +4,8 @@ use responses::{ AdminResponse, HooksResponse, MemberListResponse, MemberResponse, TotalWeightResponse, }; use sylvia::cw_std::{Response, StdError}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; -use sylvia::{interface, schemars}; #[interface] pub trait Cw4 { diff --git a/examples/interfaces/cw4/src/responses.rs b/examples/interfaces/cw4/src/responses.rs index f5797e8b..8796c1c3 100644 --- a/examples/interfaces/cw4/src/responses.rs +++ b/examples/interfaces/cw4/src/responses.rs @@ -1,6 +1,6 @@ -use cosmwasm_schema::cw_serde; +use sylvia::cw_schema::cw_serde; -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct AdminResponse { pub admin: Option, } @@ -8,28 +8,28 @@ pub struct AdminResponse { /// A group member has a weight associated with them. /// This may all be equal, or may have meaning in the app that /// makes use of the group (eg. voting power) -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct Member { pub addr: String, pub weight: u64, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct MemberListResponse { pub members: Vec, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct MemberResponse { pub weight: Option, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct TotalWeightResponse { pub weight: u64, } -#[cw_serde] +#[cw_serde(crate = "sylvia::cw_schema")] pub struct HooksResponse { pub hooks: Vec, } diff --git a/examples/interfaces/generic/Cargo.toml b/examples/interfaces/generic/Cargo.toml index 8cd1f362..f5518f90 100644 --- a/examples/interfaces/generic/Cargo.toml +++ b/examples/interfaces/generic/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/generic/src/lib.rs b/examples/interfaces/generic/src/lib.rs index ed450f11..c836ca0d 100644 --- a/examples/interfaces/generic/src/lib.rs +++ b/examples/interfaces/generic/src/lib.rs @@ -1,7 +1,7 @@ use sylvia::cw_std::{CosmosMsg, Response, StdError}; +use sylvia::interface; use sylvia::types::{CustomMsg, ExecCtx, QueryCtx, SudoCtx}; -use sylvia::{interface, schemars}; #[interface] #[sv::custom(msg=sylvia::cw_std::Empty, query=sylvia::cw_std::Empty)] @@ -76,7 +76,7 @@ mod tests { use crate::sv::Querier; - #[cosmwasm_schema::cw_serde] + #[sylvia::cw_schema::cw_serde(crate = "sylvia::cw_schema")] pub struct SvCustomMsg; impl sylvia::cw_std::CustomMsg for SvCustomMsg {} diff --git a/examples/interfaces/whitelist/Cargo.toml b/examples/interfaces/whitelist/Cargo.toml index 50bf6f80..e0ef891f 100644 --- a/examples/interfaces/whitelist/Cargo.toml +++ b/examples/interfaces/whitelist/Cargo.toml @@ -12,7 +12,6 @@ homepage = "https://cosmwasm.com" mt = ["sylvia/mt"] [dependencies] -cosmwasm-schema = { workspace = true } serde = { workspace = true } sylvia = { path = "../../../sylvia" } diff --git a/examples/interfaces/whitelist/src/lib.rs b/examples/interfaces/whitelist/src/lib.rs index ab2cb8d6..472a433b 100644 --- a/examples/interfaces/whitelist/src/lib.rs +++ b/examples/interfaces/whitelist/src/lib.rs @@ -1,7 +1,7 @@ use responses::AdminListResponse; use sylvia::cw_std::{Response, StdError, StdResult}; +use sylvia::interface; use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, QueryCtx}; -use sylvia::{interface, schemars}; pub mod responses; diff --git a/sylvia-derive/src/contract/communication/enum_msg.rs b/sylvia-derive/src/contract/communication/enum_msg.rs index ad3ffa8e..5042a736 100644 --- a/sylvia-derive/src/contract/communication/enum_msg.rs +++ b/sylvia-derive/src/contract/communication/enum_msg.rs @@ -76,12 +76,7 @@ impl<'a> EnumMessage<'a> { let ctx_type = msg_ty.emit_ctx_type(&custom.query_or_default()); let ret_type = msg_ty.emit_result_type(&custom.msg_or_default(), &error.error); - - let derive_query = match msg_ty { - MsgType::Query => quote! { #sylvia ::cw_schema::QueryResponses }, - _ => quote! {}, - }; - + let derive_call = msg_ty.emit_derive_call(); let ep_name = msg_ty.emit_ep_name(); let messages_fn_name = Ident::new(&format!("{}_messages", ep_name), contract.span()); @@ -96,7 +91,7 @@ impl<'a> EnumMessage<'a> { quote! { #[allow(clippy::derive_partial_eq_without_eq)] - #[derive(#sylvia ::serde::Serialize, #sylvia ::serde::Deserialize, Clone, Debug, PartialEq, #sylvia ::schemars::JsonSchema, #derive_query )] + #derive_call #( #[ #msg_attrs_to_forward ] )* #[serde(rename_all="snake_case")] pub enum #enum_name #bracketed_used_generics { diff --git a/sylvia-derive/src/types/msg_type.rs b/sylvia-derive/src/types/msg_type.rs index a2c0d49e..157f5d9a 100644 --- a/sylvia-derive/src/types/msg_type.rs +++ b/sylvia-derive/src/types/msg_type.rs @@ -155,12 +155,18 @@ impl MsgType { pub fn emit_derive_call(&self) -> TokenStream { let sylvia = crate_module(); + let cw_schema = quote! { #sylvia:: cw_schema }.to_string(); + let schemars = quote! { #sylvia:: cw_schema::schemars }.to_string(); + match self { MsgType::Query => quote! { #[derive(#sylvia ::serde::Serialize, #sylvia ::serde::Deserialize, Clone, Debug, PartialEq, #sylvia ::schemars::JsonSchema, #sylvia:: cw_schema::QueryResponses)] + #[schemars(crate = #schemars )] + #[query_responses(crate = #cw_schema )] }, _ => quote! { #[derive(#sylvia ::serde::Serialize, #sylvia ::serde::Deserialize, Clone, Debug, PartialEq, #sylvia ::schemars::JsonSchema)] + #[schemars(crate = #schemars )] }, } }