diff --git a/Cargo.lock b/Cargo.lock index 3db6fb7..b3fe8ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,6 +13,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "anyhow" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519" + [[package]] name = "base16ct" version = "0.2.0" @@ -37,6 +43,12 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" +[[package]] +name = "bech32" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d" + [[package]] name = "block-buffer" version = "0.9.0" @@ -57,9 +69,9 @@ dependencies = [ [[package]] name = "bnum" -version = "0.8.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9008b6bb9fc80b5277f2fe481c09e828743d9151203e804583eb4c9e15b31d" +checksum = "56953345e39537a3e18bdaeba4cb0c58a78c1f61f361dc0fa7c5c7340ae87c5f" [[package]] name = "byteorder" @@ -67,6 +79,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + [[package]] name = "cfg-if" version = "1.0.0" @@ -96,12 +114,11 @@ dependencies = [ [[package]] name = "cosmwasm-crypto" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8bb3c77c3b7ce472056968c745eb501c440fbc07be5004eba02782c35bfbbe3" +checksum = "d8b08e6670ab9e13a1a8a9cfad8fdad48bf0aaf88a6e81f39f2d9b2fc79b1890" dependencies = [ "digest 0.10.7", - "ecdsa", "ed25519-zebra", "k256", "rand_core 0.6.4", @@ -110,18 +127,18 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea73e9162e6efde00018d55ed0061e93a108b5d6ec4548b4f8ce3c706249687" +checksum = "b8b0918fc1a24b2ee08142c8d99d03f4c8e6d74244bdb304dbb29c0dab8e77e9" dependencies = [ "syn 1.0.109", ] [[package]] name = "cosmwasm-schema" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df41ea55f2946b6b43579659eec048cc2f66e8c8e2e3652fc5e5e476f673856" +checksum = "26dbdb5800ca67f2f2f938d67db59a7c5434af133c3e508779a4df7a9b5d533b" dependencies = [ "cosmwasm-schema-derive", "schemars", @@ -132,9 +149,9 @@ dependencies = [ [[package]] name = "cosmwasm-schema-derive" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43609e92ce1b9368aa951b334dd354a2d0dd4d484931a5f83ae10e12a26c8ba9" +checksum = "d8ee47cf29f7688ebfa6ade8ddabcf51fc153f1157a3b46f5b4b1ce7a0316fdf" dependencies = [ "proc-macro2", "quote", @@ -143,12 +160,12 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.0" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04d6864742e3a7662d024b51a94ea81c9af21db6faea2f9a6d2232bb97c6e53e" +checksum = "88191bd0d4743613eb7a2f086acb0838404cb531bf658382effafc7ba91e8320" dependencies = [ "base64", - "bech32", + "bech32 0.9.1", "bnum", "cosmwasm-crypto", "cosmwasm-derive", @@ -207,11 +224,31 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cw-multi-test" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e403ad6ec62c8bcbcb75f7f4940712d0142b6103310da2a9375252b942358caa" +dependencies = [ + "anyhow", + "bech32 0.11.0", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "derivative", + "itertools", + "prost", + "schemars", + "serde", + "sha2 0.10.8", + "thiserror", +] + [[package]] name = "cw-storage-plus" -version = "1.2.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5ff29294ee99373e2cd5fd21786a3c0ced99a52fec2ca347d565489c61b723c" +checksum = "f13360e9007f51998d42b1bc6b7fa0141f74feae61ed5fd1e5b0a89eec7b5de1" dependencies = [ "cosmwasm-std", "schemars", @@ -219,15 +256,16 @@ dependencies = [ ] [[package]] -name = "cw-sylvia-template" -version = "0.1.0" +name = "cw-utils" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07dfee7f12f802431a856984a32bce1cb7da1e6c006b5409e3981035ce562dec" dependencies = [ "cosmwasm-schema", "cosmwasm-std", - "cw-storage-plus", "schemars", "serde", - "sylvia", + "thiserror", ] [[package]] @@ -307,6 +345,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "either" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" + [[package]] name = "elliptic-curve" version = "0.13.8" @@ -421,6 +465,15 @@ dependencies = [ "hashbrown 0.14.3", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.10" @@ -429,9 +482,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "k256" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -538,13 +591,36 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.74" +version = "1.0.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" +checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba" dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.60", +] + [[package]] name = "quote" version = "1.0.35" @@ -625,9 +701,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.194" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" +checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" dependencies = [ "serde_derive", ] @@ -643,22 +719,22 @@ dependencies = [ [[package]] name = "serde-json-wasm" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16a62a1fad1e1828b24acac8f2b468971dade7b8c3c2e672bcadefefb1f8c137" +checksum = "f05da0d153dd4595bdffd5099dc0e9ce425b205ee648eb93437ff7302af8c9a5" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.194" +version = "1.0.198" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" +checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.60", ] [[package]] @@ -741,12 +817,15 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "sylvia" -version = "0.7.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f358d505f46900e55154f028f18811961ebb58f7a92954ec03086ffb2b26cf51" +checksum = "f1b4ce088d9f8ed96dcd28941ffac196f1ef6fecd35a894595522c30ea7e6eaf" dependencies = [ + "anyhow", "cosmwasm-schema", "cosmwasm-std", + "cw-multi-test", + "derivative", "konst", "schemars", "serde", @@ -757,16 +836,17 @@ dependencies = [ [[package]] name = "sylvia-derive" -version = "0.7.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bed182fb775d756fdfe7e87174a4e43f1c446c8f9aff1de38a2165dd04b7d805" +checksum = "3d1aa1afb2d49749efefffbba3a44981dcff66d62519e8581b24ef4b37d05129" dependencies = [ "convert_case", + "itertools", "proc-macro-crate", "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -782,33 +862,45 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.46" +version = "2.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" +checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "template" +version = "0.1.0" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "schemars", + "serde", + "sylvia", +] + [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", - "syn 2.0.46", + "syn 2.0.60", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 68e444c..d8f129c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,23 +4,19 @@ authors = ["{{authors}}"] version = "0.1.0" edition = "2021" - [features] library = [] - [lib] crate-type = ["cdylib", "rlib"] - [dependencies] -cosmwasm-std = { version = "1", features = ["staking"] } -sylvia = "0.7" -serde = "1.0.180" # required by sylvia's macro expansions -schemars = "0.8" # required by sylvia's macro expansions -cosmwasm-schema = "1.3" -cw-storage-plus = "1.2" - +cosmwasm-std = { version = "2.0.2", features = ["staking"] } +sylvia = "1.0.2" +serde = "1.0.198" # required by sylvia's macro expansions +schemars = "0.8" # required by sylvia's macro expansions +cosmwasm-schema = "2.0.2" +cw-storage-plus = "2.0.0" [dev-dependencies] -sylvia = { version = "0.7.0", features = ["mt"] } +sylvia = { version = "1.0.2", features = ["mt"] } diff --git a/src/bin/schema.rs b/src/bin/schema.rs index d6c0b26..7de16cc 100644 --- a/src/bin/schema.rs +++ b/src/bin/schema.rs @@ -1,6 +1,6 @@ use cosmwasm_schema::write_api; -use {{crate_name}}::contract::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; +use {{crate_name}}::contract::sv::{ContractExecMsg, ContractQueryMsg, InstantiateMsg}; #[cfg(not(tarpaulin_include))] fn main() { diff --git a/src/contract.rs b/src/contract.rs index f7f1f2c..0635247 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -2,29 +2,29 @@ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Response, StdResult}; use cw_storage_plus::Item; -use sylvia::{contract, entry_points}; +use sylvia::contract; use sylvia::types::{ExecCtx, InstantiateCtx, QueryCtx}; pub struct CounterContract { - pub count: Item<'static, u64>, + pub count: Item, } -#[cfg_attr(not(feature = "library"), entry_points)] +#[cfg_attr(not(feature = "library"), sylvia::entry_points)] #[contract] impl CounterContract { - pub fn new() -> Self { + pub const fn new() -> Self { Self { count: Item::new("count"), } } - #[msg(instantiate)] + #[sv::msg(instantiate)] fn instantiate(&self, ctx: InstantiateCtx) -> StdResult { self.count.save(ctx.deps.storage, &0)?; Ok(Response::new()) } - #[msg(exec)] + #[sv::msg(exec)] fn increment(&self, ctx: ExecCtx) -> StdResult { self.count .update(ctx.deps.storage, |count| -> StdResult { @@ -33,7 +33,7 @@ impl CounterContract { Ok(Response::new()) } - #[msg(query)] + #[sv::msg(query)] fn count(&self, ctx: QueryCtx) -> StdResult { let count = self.count.load(ctx.deps.storage)?; Ok(CountResponse { count }) @@ -56,7 +56,6 @@ mod tests { // For more complex tests (particularly involving cross-contract calls), you // may want to check out `cw-multi-test`: // https://github.com/CosmWasm/cw-multi-test - #[test] fn init() { let contract = CounterContract::new(); diff --git a/src/multitest/mod.rs b/src/multitest/mod.rs index 9a6bfca..ef62d0a 100644 --- a/src/multitest/mod.rs +++ b/src/multitest/mod.rs @@ -1,17 +1,18 @@ +use sylvia::cw_multi_test::IntoAddr; use sylvia::multitest::App; -use crate::contract::multitest_utils::CodeId; +use crate::contract::sv::mt::{CodeId, CounterContractProxy}; #[test] fn instantiate() { let app = App::default(); let code_id = CodeId::store_code(&app); - let owner = "owner"; + let owner = "owner".into_addr(); - let contract = code_id.instantiate().call(owner).unwrap(); + let contract = code_id.instantiate().call(&owner).unwrap(); - contract.increment().call(owner).unwrap(); + contract.increment().call(&owner).unwrap(); let count = contract.count().unwrap().count; assert_eq!(count, 1);