Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make serde dep user side obsolete #422

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions examples/contracts/custom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ mt = ["library", "anyhow", "cw-multi-test"]
[dependencies]
cw1 = { path = "../../interfaces/cw1" }
cw-storage-plus = { workspace = true }
serde = { workspace = true }
sylvia = { path = "../../../sylvia" }
cw-multi-test = { workspace = true, optional = true }
jawoznia marked this conversation as resolved.
Show resolved Hide resolved
anyhow = { workspace = true, optional = true }

[dev-dependencies]
anyhow = { workspace = true }
cw-multi-test = { workspace = true }
sylvia = { path = "../../../sylvia", features = ["mt"] }
1 change: 0 additions & 1 deletion examples/contracts/custom/src/bin/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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,
Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/custom/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cw_storage_plus::Item;
use sylvia::contract;
use sylvia::cw_std::{CosmosMsg, QueryRequest, Response, StdResult};
use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx, SudoCtx};
use sylvia::{contract, schemars};

#[cfg(not(feature = "library"))]
use sylvia::entry_points;
Expand Down
4 changes: 2 additions & 2 deletions examples/contracts/custom/src/multitest/custom_module.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use cw_multi_test::{AppResponse, CosmosRouter, Module};
use cw_storage_plus::Item;
use serde::de::DeserializeOwned;
use std::fmt::Debug;
use sylvia::cw_multi_test::{AppResponse, CosmosRouter, Module};
use sylvia::cw_schema::schemars::JsonSchema;
use sylvia::cw_std::{
to_json_binary, Addr, Api, Binary, BlockInfo, CustomQuery, Empty, Querier, StdError, StdResult,
Storage,
};
use sylvia::serde::de::DeserializeOwned;

use crate::messages::{CountResponse, CounterMsg, CounterQuery};

Expand Down
8 changes: 3 additions & 5 deletions examples/contracts/custom/src/multitest/tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use cw_multi_test::IntoBech32;
use sylvia::cw_multi_test::{BasicAppBuilder, IntoBech32};
use sylvia::multitest::App;

use crate::contract::sv::mt::CodeId;

use super::custom_module::CustomModule;

use crate::contract::sv::mt::CodeId;
use crate::contract::sv::mt::CustomContractProxy;

use cw1::sv::mt::Cw1Proxy;
Expand All @@ -14,7 +12,7 @@ use sylvia::cw_std::CosmosMsg;
fn test_custom() {
let owner = "owner".into_bech32();

let mt_app = cw_multi_test::BasicAppBuilder::new_custom()
let mt_app = BasicAppBuilder::new_custom()
.with_custom(CustomModule::default())
.build(|router, _, storage| {
router.custom.save_counter(storage, 0).unwrap();
Expand Down
7 changes: 2 additions & 5 deletions examples/contracts/cw1-subkeys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,21 @@ crate-type = ["cdylib", "rlib"]

[features]
library = []
mt = ["library", "cw-multi-test", "anyhow"]
mt = ["library", "anyhow", "sylvia/mt"]

[dependencies]
anyhow = { workspace = true, optional = true }
cw-multi-test = { workspace = true, optional = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
cw1 = { path = "../../interfaces/cw1" }
whitelist = { path = "../../interfaces/whitelist" }
cw1-whitelist = { path = "../cw1-whitelist", features = ["library"] }
cw2 = { workspace = true }
serde = { workspace = true }
sylvia = { path = "../../../sylvia" }
thiserror = { workspace = true }

[dev-dependencies]
anyhow = { workspace = true }
cw-multi-test = { workspace = true }
sylvia = { path = "../../../sylvia", features = ["mt"] }
cw1-whitelist = { path = "../cw1-whitelist", features = ["library", "mt"] }
cw1-whitelist = { path = "../cw1-whitelist", features = ["mt"] }
cw1 = { path = "../../interfaces/cw1", features = ["mt"] }
1 change: 0 additions & 1 deletion examples/contracts/cw1-subkeys/src/bin/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use cw1_subkeys::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMs
use sylvia::cw_schema::write_api;
use sylvia::cw_std::Empty;

#[cfg(not(tarpaulin_include))]
fn main() {
write_api! {
crate_name: sylvia::cw_schema,
Expand Down
8 changes: 5 additions & 3 deletions examples/contracts/cw1-subkeys/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ use cw1_whitelist::contract::Cw1WhitelistContract;
use cw2::set_contract_version;
use cw_storage_plus::{Bound, Map};
use cw_utils::Expiration;
use sylvia::contract;
use sylvia::cw_std::{
ensure, ensure_ne, Addr, BankMsg, Coin, CosmosMsg, Deps, DistributionMsg, Empty, Env, Order,
Response, StakingMsg, StdResult,
ensure, ensure_ne, Addr, BankMsg, Coin, CosmosMsg, Deps, DistributionMsg, Env, Order, Response,
StakingMsg, StdResult,
};
use sylvia::types::{CustomMsg, CustomQuery, ExecCtx, InstantiateCtx, QueryCtx};
use sylvia::{contract, schemars};

#[cfg(not(feature = "library"))]
use sylvia::cw_std::Empty;
#[cfg(not(feature = "library"))]
use sylvia::entry_points;

Expand Down
2 changes: 1 addition & 1 deletion examples/contracts/cw1-subkeys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod contract;
mod cw1;
pub mod error;
#[cfg(any(test, feature = "tests"))]
#[cfg(test)]
pub mod multitest;
pub mod responses;
pub mod state;
Expand Down
6 changes: 3 additions & 3 deletions examples/contracts/cw1-subkeys/src/multitest/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cw2::{query_contract_info, ContractVersion};
use cw_multi_test::IntoBech32;
use cw_utils::{Expiration, NativeBalance};
use sylvia::cw_multi_test::IntoBech32;
use sylvia::cw_std::{coin, coins, Addr};
use sylvia::multitest::App;

Expand Down Expand Up @@ -59,7 +59,7 @@ fn get_contract_version_works() {
}

mod allowance {
use cw_multi_test::next_block;
use sylvia::cw_multi_test::next_block;

use crate::responses::AllowanceInfo;
use crate::state::Allowance;
Expand Down Expand Up @@ -425,7 +425,7 @@ mod cw1_execute {
let admin = "admin".into_bech32();
let non_admin = Addr::unchecked("non_admin");

let app = cw_multi_test::App::new(|router, _api, storage| {
let app = sylvia::cw_multi_test::App::new(|router, _api, storage| {
router
.bank
.init_balance(storage, &admin, coins(2345, ATOM))
Expand Down
8 changes: 6 additions & 2 deletions examples/contracts/cw1-subkeys/src/responses.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use crate::state::Permissions;
use cw_utils::{Expiration, NativeBalance};
use serde::{Deserialize, Serialize};
use sylvia::cw_schema::schemars::JsonSchema;
use sylvia::cw_std::Addr;
use sylvia::schemars;
use sylvia::serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug, Default)]
#[serde(crate = "sylvia::serde")]
pub struct AllAllowancesResponse {
pub allowances: Vec<AllowanceInfo>,
}
Expand All @@ -24,6 +25,7 @@ impl AllAllowancesResponse {
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(crate = "sylvia::serde")]
pub struct AllowanceInfo {
pub spender: Addr,
pub balance: NativeBalance,
Expand Down Expand Up @@ -74,17 +76,19 @@ impl AllowanceInfo {
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug, Default)]
#[serde(crate = "sylvia::serde")]
pub struct AllPermissionsResponse {
pub permissions: Vec<PermissionsInfo>,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
#[serde(crate = "sylvia::serde")]
pub struct PermissionsInfo {
pub spender: Addr,
pub permissions: Permissions,
}

#[cfg(any(test, feature = "test-utils"))]
#[cfg(any(test, feature = "mt"))]
impl PermissionsInfo {
/// Utility function providing some ordering to be used with `slice::sort_by`.
///
Expand Down
4 changes: 3 additions & 1 deletion examples/contracts/cw1-subkeys/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::fmt;

use cw_utils::{Expiration, NativeBalance};
use serde::{Deserialize, Serialize};
use sylvia::schemars;
use sylvia::serde::{Deserialize, Serialize};

// Permissions struct defines users message execution permissions.
// Could have implemented permissions for each cosmos module(StakingPermissions, GovPermissions etc...)
Expand All @@ -11,6 +11,7 @@ use sylvia::schemars;
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, schemars::JsonSchema, Default, Copy,
)]
#[serde(crate = "sylvia::serde")]
pub struct Permissions {
pub delegate: bool,
pub redelegate: bool,
Expand All @@ -29,6 +30,7 @@ impl fmt::Display for Permissions {
}

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, schemars::JsonSchema, Default)]
#[serde(crate = "sylvia::serde")]
pub struct Allowance {
pub balance: NativeBalance,
pub expires: Expiration,
Expand Down
Loading
Loading