diff --git a/Cargo.lock b/Cargo.lock index 104454f..1aa7ace 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -690,21 +690,11 @@ dependencies = [ "secret-cosmwasm-std", ] -[[package]] -name = "cw-address-like" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451a4691083a88a3c0630a8a88799e9d4cd6679b7ce8ff22b8da2873ff31d380" -dependencies = [ - "cosmwasm-std 1.5.0", -] - [[package]] name = "cw-admin-factory" version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", - "cw20-base 1.1.2", "dao-dao-core", "dao-interface", "secret-cosmwasm-std", @@ -745,7 +735,7 @@ dependencies = [ "cw-utils 0.13.4", "cw2 0.13.4", "cw20 0.13.4", - "cw721 0.13.4", + "cw721", "schemars", "serde", "thiserror", @@ -800,67 +790,22 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-multi-test" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e2c2f2c0877b839c5cad85e67811074e854a50c1ff3085eb8290b1c27809c" -dependencies = [ - "anyhow", - "cosmwasm-std 1.5.0", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "derivative", - "itertools 0.11.0", - "prost 0.12.3", - "schemars", - "serde", - "sha2 0.10.8", - "thiserror", -] - [[package]] name = "cw-ownable" version = "0.5.1" dependencies = [ "cosmwasm-schema 1.1.11", - "cw-address-like 1.0.4", - "cw-ownable-derive 0.5.1", + "cw-address-like", + "cw-ownable-derive", "secret-cosmwasm-std", "secret-storage-plus", "secret-utils", "thiserror", ] -[[package]] -name = "cw-ownable" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093dfb4520c48b5848274dd88ea99e280a04bc08729603341c7fb0d758c74321" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-address-like 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cw-ownable-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "thiserror", -] - -[[package]] -name = "cw-ownable-derive" -version = "0.5.1" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "cw-ownable-derive" version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d3bf2e0f341bb6cc100d7d441d31cf713fbd3ce0c511f91e79f14b40a889af" dependencies = [ "proc-macro2", "quote", @@ -910,17 +855,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw-storage-plus" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b6f91c0b94481a3e9ef1ceb183c37d00764f8751e39b45fc09f4d9b970d469" -dependencies = [ - "cosmwasm-std 1.5.0", - "schemars", - "serde", -] - [[package]] name = "cw-storage-plus" version = "1.2.0" @@ -944,21 +878,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw-utils" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6a84c6c1c0acc3616398eba50783934bd6c964bad6974241eaee3460c8f5b26" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw2 0.16.0", - "schemars", - "semver", - "serde", - "thiserror", -] - [[package]] name = "cw-utils" version = "1.0.3" @@ -996,19 +915,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw2" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91398113b806f4d2a8d5f8d05684704a20ffd5968bf87e3473e1973710b884ad" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-storage-plus 0.16.0", - "schemars", - "serde", -] - [[package]] name = "cw2" version = "1.1.2" @@ -1065,23 +971,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cw20-base" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ad79e86ea3707229bf78df94e08732e8f713207b4a77b2699755596725e7d9" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-storage-plus 1.2.0", - "cw2 1.1.2", - "cw20 1.1.2", - "schemars", - "semver", - "serde", - "thiserror", -] - [[package]] name = "cw20-stake" version = "0.2.6" @@ -1095,7 +984,7 @@ dependencies = [ "cw-utils 0.13.4", "cw2 0.13.4", "cw20 0.13.4", - "cw20-base 0.13.4", + "cw20-base", "schemars", "serde", "thiserror", @@ -1156,68 +1045,6 @@ dependencies = [ "serde", ] -[[package]] -name = "cw721" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a1ea6e6277bdd6dfc043a9b1380697fe29d6e24b072597439523658d21d791" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-utils 0.16.0", - "schemars", - "serde", -] - -[[package]] -name = "cw721" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c4d286625ccadc957fe480dd3bdc54ada19e0e6b5b9325379db3130569e914" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-utils 1.0.3", - "schemars", - "serde", -] - -[[package]] -name = "cw721-base" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77518e27431d43214cff4cdfbd788a7508f68d9b1f32389e6fce513e7eaccbef" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-storage-plus 0.16.0", - "cw-utils 0.16.0", - "cw2 0.16.0", - "cw721 0.16.0", - "schemars", - "serde", - "thiserror", -] - -[[package]] -name = "cw721-base" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da518d9f68bfda7d972cbaca2e8fcf04651d0edc3de72b04ae2bcd9289c81614" -dependencies = [ - "cosmwasm-schema 1.5.0", - "cosmwasm-std 1.5.0", - "cw-ownable 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cw-storage-plus 1.2.0", - "cw-utils 1.0.3", - "cw2 1.1.2", - "cw721 0.18.0", - "cw721-base 0.16.0", - "schemars", - "serde", - "thiserror", -] - [[package]] name = "dao-dao-core" version = "2.4.0" @@ -1225,8 +1052,6 @@ dependencies = [ "cosmwasm-schema 1.1.11", "cw-core", "cw-paginate-storage 2.4.0", - "cw20-base 1.1.2", - "cw721-base 0.18.0", "dao-dao-macros", "dao-interface", "schemars", @@ -1293,9 +1118,6 @@ dependencies = [ "cw-denom", "cw-hooks", "cw-paginate-storage 2.4.0", - "cw-utils 1.0.3", - "cw20 1.1.2", - "cw20-base 1.1.2", "cw4-group", "dao-dao-core", "dao-hooks", @@ -1310,6 +1132,7 @@ dependencies = [ "secret-multi-test", "secret-storage-plus", "secret-toolkit", + "secret-utils", "thiserror", ] @@ -1319,8 +1142,6 @@ version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", "cw-denom", - "cw20 1.1.2", - "cw20-base 1.1.2", "cw4-group", "dao-dao-core", "dao-hooks", @@ -1365,8 +1186,6 @@ version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", "cw-denom", - "cw20 1.1.2", - "cw20-base 1.1.2", "cw4-group", "dao-dao-core", "dao-hooks", @@ -1389,10 +1208,6 @@ dependencies = [ "cosmwasm-schema 1.1.11", "cw-denom", "cw-hooks", - "cw-multi-test", - "cw-utils 1.0.3", - "cw20 1.1.2", - "cw20-base 1.1.2", "cw4-group", "dao-interface", "dao-pre-propose-base", @@ -1400,6 +1215,8 @@ dependencies = [ "dao-voting 2.4.0", "secret-cosmwasm-std", "secret-cw2", + "secret-multi-test", + "secret-utils", ] [[package]] @@ -1435,12 +1252,9 @@ dependencies = [ "cosmwasm-schema 1.1.11", "cw-denom", "cw-hooks", - "cw20 1.1.2", - "cw20-base 1.1.2", "cw3", "cw4", "cw4-group", - "cw721-base 0.18.0", "dao-dao-macros", "dao-hooks", "dao-interface", @@ -1571,8 +1385,7 @@ name = "dao-voting-snip20-staked" version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", - "cw-ownable 0.5.1", - "cw20-base 1.1.2", + "cw-ownable", "dao-dao-macros", "dao-interface", "dao-voting 2.4.0", @@ -1597,7 +1410,7 @@ version = "2.4.0" dependencies = [ "anyhow", "cosmwasm-schema 1.1.11", - "cw-ownable 0.5.1", + "cw-ownable", "cw-paginate-storage 2.4.0", "cw4", "dao-dao-macros", @@ -1625,8 +1438,6 @@ dependencies = [ "cosmwasm-schema 1.1.11", "cw-hooks", "cw-paginate-storage 2.4.0", - "cw721 0.18.0", - "cw721-base 0.18.0", "dao-dao-macros", "dao-hooks", "dao-interface", @@ -1654,7 +1465,7 @@ dependencies = [ "cosmos-sdk-proto", "cosmwasm-schema 1.1.11", "cw-hooks", - "cw-ownable 0.5.1", + "cw-ownable", "cw-paginate-storage 2.4.0", "dao-dao-macros", "dao-hooks", @@ -3123,10 +2934,9 @@ dependencies = [ "bincode", "cosmwasm-schema 1.1.11", "cw-hooks", - "cw-ownable 0.5.1", + "cw-ownable", "cw-paginate-storage 2.4.0", "cw-utils 0.13.4", - "cw20 1.1.2", "cw20-stake", "dao-hooks", "dao-voting 2.4.0", @@ -3154,9 +2964,8 @@ version = "2.4.0" dependencies = [ "anyhow", "cosmwasm-schema 1.1.11", - "cw-ownable 0.5.1", + "cw-ownable", "cw20 0.13.4", - "cw20 1.1.2", "dao-hooks", "schemars", "secret-cosmwasm-std", @@ -3178,9 +2987,7 @@ name = "snip20-stake-reward-distributor" version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", - "cw-ownable 0.5.1", - "cw20 1.1.2", - "cw20-base 1.1.2", + "cw-ownable", "schemars", "secret-cosmwasm-std", "secret-cw-controllers", @@ -3202,7 +3009,7 @@ version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", "secret-cosmwasm-std", - "secret-storage-plus", + "secret-toolkit", "secret-utils", "thiserror", ] @@ -3228,7 +3035,7 @@ name = "snip721-roles" version = "2.4.0" dependencies = [ "cosmwasm-schema 1.1.11", - "cw-ownable 0.5.1", + "cw-ownable", "cw4", "dao-snip721-extensions", "dao-voting-snip721-staked", @@ -3278,7 +3085,7 @@ dependencies = [ "cw-utils 0.13.4", "cw2 0.13.4", "cw20 0.13.4", - "cw20-base 0.13.4", + "cw20-base", "cw20-stake", "schemars", "serde", @@ -3297,7 +3104,7 @@ dependencies = [ "cw-utils 0.13.4", "cw2 0.13.4", "cw20 0.13.4", - "cw20-base 0.13.4", + "cw20-base", "cw20-stake", "schemars", "serde", diff --git a/Cargo.toml b/Cargo.toml index 06c3f3d..224956e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,25 +35,16 @@ incremental = false overflow-checks = true [workspace.dependencies] -anyhow = { version = "1.0" } -assert_matches = "1.5" -cosm-orc = { version = "4.0" } -cosm-tome = "0.2" -# cosmwasm-schema = { version = "1.1.11", git = "https://github.com/scrtlabs/cosmwasm" } -cw-controllers = "1.1" -cw-multi-test = "0.18" -cw-storage-plus = { version = "1.1" } -cw-utils = "1.0" -cw2 = "1.1" -cw20 = "1.1" -cw20-base = "1.1" -cw3 = "1.1" -cw4 = { path = "./packages/cw4-1.1.2/" } -cw4-group = { path = "./packages/cw4-group-1.1.2/" } -cw721 = "0.18" -cw721-base = "0.18" -env_logger = "0.10" -once_cell = "1.18" +anyhow = { version = "1.0",default-features = false } +assert_matches = {version = "1.5",default-features = false} +cosm-orc = { version = "4.0",default-features = false } +cosm-tome = {version = "0.2",default-features = false} +cw3 = {version = "1.1",default-features = false} +cw4 = { path = "./packages/cw4-1.1.2/" ,default-features = false} +cw4-group = { path = "./packages/cw4-group-1.1.2/" ,default-features = false} +env_logger = {version = "0.10",default-features = false} +once_cell = {version = "1.18",default-features = false} + # osmosis-std = { path = "./packages/osmosis-std-0.21.0/" } # osmosis-std-derive = { path = "./packages/osmosis-std-derive-0.20.1/" } # osmosis-test-tube = { path = "./packages/osmosis-test-tube-20.1.2/" } @@ -61,86 +52,82 @@ once_cell = "1.18" # osmosis-std = "0.22.0" # osmosis-std-derive = "0.20.1" # osmosis-test-tube = "22.1.0" -proc-macro2 = "1.0" -prost = { version = "0.12.3", features = ["prost-derive"] } +proc-macro2 = {version = "1.0",default-features = false} +prost = { version = "0.12.3", features = ["prost-derive"] ,default-features = false} prost-types = { version = "0.12.3", default-features = false } -quote = "1.0" -rand = "0.8" -# schemars = "0.8" -# serde = { version = "1.0", default-features = false, features = ["derive"] } -serde-cw-value = "0.7" -serde_json = "1.0" -serde_yaml = "0.9" -sg-multi-test = "3.1.0" -sg-std = "3.1.0" -sg721 = "3.1.0" -sg721-base = "3.1.0" -syn = { version = "1.0", features = ["derive"] } -test-context = "0.1" -# thiserror = { version = "1.0" } -wynd-utils = {path = "./packages/wynd-utils-0.4.1/"} -bincode = "1.3.3" +quote = {version = "1.0",default-features = false} +rand = {version = "0.8",default-features = false} +serde-cw-value = {version = "0.7",default-features = false} +serde_json = {version = "1.0",default-features = false} +serde_yaml = {version = "0.9",default-features = false} +sg-multi-test = {version = "3.1.0",default-features = false} +sg-std = {version = "3.1.0",default-features = false} +sg721 = {version = "3.1.0",default-features = false} +sg721-base = {version = "3.1.0",default-features = false} +syn = { version = "1.0", features = ["derive"],default-features = false } +test-context = {version = "0.1",default-features = false} +wynd-utils = {path = "./packages/wynd-utils-0.4.1/",default-features = false} +bincode = {version="1.3.3",default-features = false} # One commit ahead of version 0.3.0. Allows initialization with an # optional owner. -cw-ownable = { path = "./packages/cw-ownable-0.5.1/" } -# cw-ownable = "0.5" +cw-ownable = { path = "./packages/cw-ownable-0.5.1/",default-features = false } -cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.4.0" } -cw-denom = { path = "./packages/cw-denom", version = "2.4.0" } -cw-hooks = { path = "./packages/cw-hooks", version = "2.4.0" } -cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.0" } +cw-admin-factory = { path = "./contracts/external/cw-admin-factory", version = "2.4.0" ,default-features = false} +cw-denom = { path = "./packages/cw-denom", version = "2.4.0",default-features = false } +cw-hooks = { path = "./packages/cw-hooks", version = "2.4.0",default-features = false } +cw-paginate-storage = { path = "./packages/cw-paginate-storage", version = "2.4.0",default-features = false } cw-payroll-factory = { path = "./contracts/external/cw-payroll-factory", version = "2.4.0" } -cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.0" } +cw-stake-tracker = { path = "./packages/cw-stake-tracker", version = "2.4.0",default-features = false } # cw-tokenfactory-issuer = { path = "./contracts/external/cw-tokenfactory-issuer", version = "2.4.0" } # cw-tokenfactory-types = { path = "./packages/cw-tokenfactory-types", version = "2.4.0", default-features = false } -cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.0" } -cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.0" } -snip20-stake = { path = "./contracts/staking/snip20-stake", version = "2.4.0" } -snip721-controllers = { path = "./packages/snip721-controllers", version = "2.4.0" } -snip721-roles = { path = "./contracts/external/snip721-roles", version = "2.4.0" } -dao-snip721-extensions = { path = "./packages/dao-snip721-extensions", version = "2.4.0" } -dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.4.0" } -dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.4.0" } -dao-hooks = { path = "./packages/dao-hooks", version = "2.4.0" } -dao-interface = { path = "./packages/dao-interface", version = "2.4.0" } -dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.4.0" } -dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.4.0" } -dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.4.0" } -dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.4.0" } -dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.4.0" } -dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.4.0" } +cw-vesting = { path = "./contracts/external/cw-vesting", version = "2.4.0",default-features = false } +cw-wormhole = { path = "./packages/cw-wormhole", version = "2.4.0",default-features = false } +snip20-stake = { path = "./contracts/staking/snip20-stake", version = "2.4.0",default-features = false } +snip721-controllers = { path = "./packages/snip721-controllers", version = "2.4.0",default-features = false } +snip721-roles = { path = "./contracts/external/snip721-roles", version = "2.4.0",default-features = false } +dao-snip721-extensions = { path = "./packages/dao-snip721-extensions", version = "2.4.0",default-features = false } +dao-dao-core = { path = "./contracts/dao-dao-core", version = "2.4.0",default-features = false } +dao-dao-macros = { path = "./packages/dao-dao-macros", version = "2.4.0",default-features = false } +dao-hooks = { path = "./packages/dao-hooks", version = "2.4.0" ,default-features = false} +dao-interface = { path = "./packages/dao-interface", version = "2.4.0",default-features = false } +dao-pre-propose-approval-single = { path = "./contracts/pre-propose/dao-pre-propose-approval-single", version = "2.4.0",default-features = false } +dao-pre-propose-approver = { path = "./contracts/pre-propose/dao-pre-propose-approver", version = "2.4.0" ,default-features = false} +dao-pre-propose-base = { path = "./packages/dao-pre-propose-base", version = "2.4.0",default-features = false } +dao-pre-propose-multiple = { path = "./contracts/pre-propose/dao-pre-propose-multiple", version = "2.4.0" ,default-features = false} +dao-pre-propose-single = { path = "./contracts/pre-propose/dao-pre-propose-single", version = "2.4.0" ,default-features = false} +dao-proposal-condorcet = { path = "./contracts/proposal/dao-proposal-condorcet", version = "2.4.0",default-features = false } # dao-proposal-hook-counter = { path = "./contracts/test/dao-proposal-hook-counter", version = "2.4.0" } -dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.4.0" } -dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.4.0" } +dao-proposal-multiple = { path = "./contracts/proposal/dao-proposal-multiple", version = "2.4.0",default-features = false } +dao-proposal-single = { path = "./contracts/proposal/dao-proposal-single", version = "2.4.0",default-features = false } # dao-proposal-sudo = { path = "./contracts/test/dao-proposal-sudo", version = "2.4.0" } # dao-test-custom-factory = { path = "./contracts/test/dao-test-custom-factory", version = "2.4.0" } # dao-testing = { path = "./packages/dao-testing", version = "2.4.0" } -dao-voting = { path = "./packages/dao-voting", version = "2.4.0" } +dao-voting = { path = "./packages/dao-voting", version = "2.4.0",default-features = false } # dao-voting-snip20-balance = { path = "./contracts/test/dao-voting-snip20-balance", version = "2.4.0" } -dao-voting-snip20-staked = { path = "./contracts/voting/dao-voting-snip20-staked", version = "2.4.0" } -dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.4.0" } -dao-voting-snip721-roles = { path = "./contracts/voting/dao-voting-snip721-roles", version = "2.4.0" } -dao-voting-snip721-staked = { path = "./contracts/voting/dao-voting-snip721-staked", version = "2.4.0" } -dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.4.0" } +dao-voting-snip20-staked = { path = "./contracts/voting/dao-voting-snip20-staked", version = "2.4.0",default-features = false } +dao-voting-cw4 = { path = "./contracts/voting/dao-voting-cw4", version = "2.4.0",default-features = false } +dao-voting-snip721-roles = { path = "./contracts/voting/dao-voting-snip721-roles", version = "2.4.0" ,default-features = false} +dao-voting-snip721-staked = { path = "./contracts/voting/dao-voting-snip721-staked", version = "2.4.0",default-features = false } +dao-voting-token-staked = { path = "./contracts/voting/dao-voting-token-staked", version = "2.4.0",default-features = false } # v1 dependencies. used for state migrations. -cw-core-v1 = { package = "cw-core", version = "0.1.0" } -cw-proposal-single-v1 = { package = "cw-proposal-single", version = "0.1.0" } -cw-utils-v1 = { package = "cw-utils", version = "0.13" } -cw20-stake-external-rewards-v1 = { package = "stake-cw20-external-rewards", version = "0.2.6" } -cw20-stake-reward-distributor-v1 = { package = "stake-cw20-reward-distributor", version = "0.1.0" } -cw20-stake-v1 = { package = "cw20-stake", version = "0.2.6" } -cw20-staked-balance-voting-v1 = { package = "cw20-staked-balance-voting", version = "0.1.0" } -cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0" } -stake-cw20-v03 = { package = "stake-cw20", version = "0.2.6" } -voting-v1 = { package = "dao-voting", version = "0.1.0" } +cw-core-v1 = { package = "cw-core", version = "0.1.0" ,default-features = false} +cw-proposal-single-v1 = { package = "cw-proposal-single", version = "0.1.0",default-features = false } +cw-utils-v1 = { package = "cw-utils", version = "0.13",default-features = false } +cw20-stake-external-rewards-v1 = { package = "stake-cw20-external-rewards", version = "0.2.6",default-features = false } +cw20-stake-reward-distributor-v1 = { package = "stake-cw20-reward-distributor", version = "0.1.0",default-features = false } +cw20-stake-v1 = { package = "cw20-stake", version = "0.2.6",default-features = false } +cw20-staked-balance-voting-v1 = { package = "cw20-staked-balance-voting", version = "0.1.0",default-features = false } +cw4-voting-v1 = { package = "cw4-voting", version = "0.1.0",default-features = false } +stake-cw20-v03 = { package = "stake-cw20", version = "0.2.6",default-features = false } +voting-v1 = { package = "dao-voting", version = "0.1.0" ,default-features = false} # cosmwasm-storage = { version = "1.1.11", package = "secret-cosmwasm-storage", default-features = false } -secret-utils = { path = "./packages/utils/" } +secret-utils = { path = "./packages/utils/",default-features = false } # cosmwasm-std = { version = "1.1.11", package = "secret-cosmwasm-std", default-features = false } secret-toolkit = { version = "0.10.0", default-features = false, features = [ "utils", @@ -151,22 +138,22 @@ secret-toolkit = { version = "0.10.0", default-features = false, features = [ "snip20", "snip721", ] } -secret-storage-plus = { path = "./packages/storage-plus/" } -secret-cw-controllers = { path = "./packages/controllers/" } -secret-cw2 = { path = "./packages/cw2/" } -secret-multi-test = { path = "./packages/multi-test/" } +secret-storage-plus = { path = "./packages/storage-plus/" ,default-features = false} +secret-cw-controllers = { path = "./packages/controllers/",default-features = false } +secret-cw2 = { path = "./packages/cw2/",default-features = false } +secret-multi-test = { path = "./packages/multi-test/",default-features = false } cosmwasm-std = { package = "secret-cosmwasm-std", version = "1.1.11", features = [ "stargate", "staking", "ibc3", "random", -] } -cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "1.1.11" } -schemars = "0.8.12" +],default-features = false } +cosmwasm-storage = { package = "secret-cosmwasm-storage", version = "1.1.11",default-features = false } +schemars = {version = "0.8.12",default-features = false} serde = { version = "1.0.158", default-features = false, features = ["derive"] } -thiserror = { version = "1.0.21" } -cosmwasm-schema = { git = "https://github.com/scrtlabs/cosmwasm/", branch = "secret" } -snip20-reference-impl = { path = "./contracts/external/snip20-reference-impl/" } -snip721-reference-impl = { path = "./contracts/external/snip721-reference-impl/" } +thiserror = { version = "1.0.21" ,default-features = false} +cosmwasm-schema = { git = "https://github.com/scrtlabs/cosmwasm/", branch = "secret",default-features = false } +snip20-reference-impl = { path = "./contracts/external/snip20-reference-impl/",default-features = false } +snip721-reference-impl = { path = "./contracts/external/snip721-reference-impl/" ,default-features = false} cosmos-sdk-proto = { version = "0.20.0", default-features = false } diff --git a/contracts/dao-dao-core/Cargo.toml b/contracts/dao-dao-core/Cargo.toml index 576d1f1..08f9b0c 100644 --- a/contracts/dao-dao-core/Cargo.toml +++ b/contracts/dao-dao-core/Cargo.toml @@ -37,7 +37,5 @@ secret-cw-controllers = { workspace = true } [dev-dependencies] secret-multi-test = { workspace = true, features = ["stargate"] } -cw20-base = { workspace = true } -cw721-base = { workspace = true } # dao-proposal-sudo = { workspace = true } # dao-voting-snip20-balance = { workspace = true } diff --git a/contracts/external/cw-admin-factory/Cargo.toml b/contracts/external/cw-admin-factory/Cargo.toml index 2fca8c9..9eed0ef 100644 --- a/contracts/external/cw-admin-factory/Cargo.toml +++ b/contracts/external/cw-admin-factory/Cargo.toml @@ -31,4 +31,3 @@ cosmwasm-schema = { workspace = true } secret-multi-test = { workspace = true } dao-dao-core = { workspace = true, features = ["library"] } dao-interface = { workspace = true } -cw20-base = { workspace = true, features = ["library"] } diff --git a/contracts/external/cw-admin-factory/src/contract.rs b/contracts/external/cw-admin-factory/src/contract.rs index ace436d..5bf85ce 100644 --- a/contracts/external/cw-admin-factory/src/contract.rs +++ b/contracts/external/cw-admin-factory/src/contract.rs @@ -1,7 +1,8 @@ #[cfg(not(feature = "library"))] use cosmwasm_std::entry_point; use cosmwasm_std::{ - Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg, WasmMsg,SubMsgResult + Binary, Deps, DepsMut, Env, MessageInfo, Reply, Response, StdError, StdResult, SubMsg, + SubMsgResult, WasmMsg, }; use dao_interface::state::ModuleInstantiateInfo; use secret_cw2::set_contract_version; diff --git a/contracts/external/cw-vesting/src/lib.rs b/contracts/external/cw-vesting/src/lib.rs index a940276..1df2235 100644 --- a/contracts/external/cw-vesting/src/lib.rs +++ b/contracts/external/cw-vesting/src/lib.rs @@ -15,9 +15,9 @@ pub use cw_ownable::Ownership; // so consumers don't need a cw_stake_tracker dependency to use this contract's queries. pub use cw_stake_tracker::StakeTrackerQuery; -#[cfg(test)] -mod suite_tests; -#[cfg(test)] -mod tests; -#[cfg(test)] -mod vesting_tests; +// #[cfg(test)] +// mod suite_tests; +// #[cfg(test)] +// mod tests; +// #[cfg(test)] +// mod vesting_tests; diff --git a/contracts/external/snip20-reference-impl/src/contract.rs b/contracts/external/snip20-reference-impl/src/contract.rs index 0f6b7e5..7d83c8b 100644 --- a/contracts/external/snip20-reference-impl/src/contract.rs +++ b/contracts/external/snip20-reference-impl/src/contract.rs @@ -2903,9 +2903,12 @@ mod tests { height: 12_345, time: Timestamp::from_seconds(1_571_797_420), chain_id: "cosmos-testnet-14002".to_string(), - random:None, + random: None, }, - transaction: Some(TransactionInfo { index: 3, hash:"hash".to_string() }), + transaction: Some(TransactionInfo { + index: 3, + hash: "hash".to_string(), + }), contract: ContractInfo { address: Addr::unchecked(MOCK_CONTRACT_ADDR.to_string()), code_hash: "".to_string(), diff --git a/contracts/external/snip20-reference-impl/src/msg.rs b/contracts/external/snip20-reference-impl/src/msg.rs index 022d224..be1844f 100644 --- a/contracts/external/snip20-reference-impl/src/msg.rs +++ b/contracts/external/snip20-reference-impl/src/msg.rs @@ -10,13 +10,13 @@ use cosmwasm_std::{Addr, Api, Binary, StdError, StdResult, Uint128}; use secret_toolkit::permit::Permit; #[cfg_attr(test, derive(Eq, PartialEq))] -#[derive(Serialize, Deserialize,Debug, Clone, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)] pub struct InitialBalance { pub address: String, pub amount: Uint128, } -#[derive(Serialize, Deserialize,Debug,Clone, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)] pub struct InstantiateMsg { pub name: String, pub admin: Option, diff --git a/contracts/external/snip721-reference-impl/src/contract.rs b/contracts/external/snip721-reference-impl/src/contract.rs index bdb2eae..b4e86b2 100644 --- a/contracts/external/snip721-reference-impl/src/contract.rs +++ b/contracts/external/snip721-reference-impl/src/contract.rs @@ -16,7 +16,6 @@ use secret_toolkit::{ viewing_key::{ViewingKey, ViewingKeyStore}, }; -use crate::{inventory::{Inventory, InventoryIter}, msg::ContractInfo}; use crate::mint_run::{SerialNumber, StoredMintRunInfo}; use crate::msg::{ AccessLevel, BatchNftDossierElement, Burn, ContractStatus, Cw721Approval, Cw721OwnerOfResponse, @@ -38,6 +37,10 @@ use crate::{ expiration::Expiration, msg::{InstantiateResponse, Minters, NftInfo, NumTokens, OwnerOf}, }; +use crate::{ + inventory::{Inventory, InventoryIter}, + msg::ContractInfo, +}; /// pad handle responses and log attributes to blocks of 256 bytes to prevent leaking info based on /// response size diff --git a/contracts/external/snip721-roles/src/contract.rs b/contracts/external/snip721-roles/src/contract.rs index ef6ed16..1d42916 100644 --- a/contracts/external/snip721-roles/src/contract.rs +++ b/contracts/external/snip721-roles/src/contract.rs @@ -354,11 +354,9 @@ pub fn execute_burn( Snip721QueryAnswer::OwnerOf { owner, .. } => { owner_addr = owner; } - _ => () + _ => (), } - - // Get the weight of the token let nft_info_res: Snip721QueryAnswer = deps.querier.query_wasm_smart( snip721_info.code_hash.clone(), @@ -367,12 +365,12 @@ pub fn execute_burn( token_id: token_id.clone(), }, )?; - let mut extension_res = None ; + let mut extension_res = None; match nft_info_res { - Snip721QueryAnswer::NftInfo { extension , .. } => { + Snip721QueryAnswer::NftInfo { extension, .. } => { extension_res = extension; } - _ => () + _ => (), } let mut total = Uint64::from(TotalStore::load(deps.storage)); @@ -595,14 +593,17 @@ pub fn execute_update_token_role( }, ) .map_err(|_| ContractError::NftDoesNotExist {})?; - let mut extension_res = None ; + let mut extension_res = None; let mut token_uri_res = Some(String::new()); match token_res { - Snip721QueryAnswer::NftInfo { extension , token_uri } => { + Snip721QueryAnswer::NftInfo { + extension, + token_uri, + } => { extension_res = extension; token_uri_res = token_uri; } - _ => () + _ => (), } // Update role with new value @@ -627,11 +628,7 @@ pub fn execute_update_token_role( youtube_url: Some(extension_res.clone().unwrap().youtube_url.unwrap()), media: Some(extension_res.clone().unwrap().media.unwrap()), protected_attributes: Some( - extension_res - .clone() - .unwrap() - .protected_attributes - .unwrap(), + extension_res.clone().unwrap().protected_attributes.unwrap(), ), token_subtype: Some(extension_res.clone().unwrap().token_subtype.unwrap()), role: role.clone(), @@ -672,13 +669,13 @@ pub fn execute_update_token_uri( ) .map_err(|_| ContractError::NftDoesNotExist {})?; - let mut extension_res = None ; - match token_res { - Snip721QueryAnswer::NftInfo { extension , .. } => { - extension_res = extension; - } - _ => () + let mut extension_res = None; + match token_res { + Snip721QueryAnswer::NftInfo { extension, .. } => { + extension_res = extension; } + _ => (), + } // Update role with new value let exec_msg = WasmMsg::Execute { @@ -702,11 +699,7 @@ pub fn execute_update_token_uri( youtube_url: Some(extension_res.clone().unwrap().youtube_url.unwrap()), media: Some(extension_res.clone().unwrap().media.unwrap()), protected_attributes: Some( - extension_res - .clone() - .unwrap() - .protected_attributes - .unwrap(), + extension_res.clone().unwrap().protected_attributes.unwrap(), ), token_subtype: Some(extension_res.clone().unwrap().token_subtype.unwrap()), role: Some(extension_res.clone().unwrap().role.unwrap()), @@ -747,15 +740,18 @@ pub fn execute_update_token_weight( ) .map_err(|_| ContractError::NftDoesNotExist {})?; - let mut extension_res = None ; - let mut token_uri_res = Some(String::new()); - match token_res { - Snip721QueryAnswer::NftInfo { extension , token_uri } => { - extension_res = extension; - token_uri_res = token_uri; - } - _ => () + let mut extension_res = None; + let mut token_uri_res = Some(String::new()); + match token_res { + Snip721QueryAnswer::NftInfo { + extension, + token_uri, + } => { + extension_res = extension; + token_uri_res = token_uri; } + _ => (), + } // Lookup the owner of the NFT let owner_res: Snip721QueryAnswer = deps.querier.query_wasm_smart( @@ -773,7 +769,7 @@ pub fn execute_update_token_weight( Snip721QueryAnswer::OwnerOf { owner, .. } => { owner_addr = owner; } - _ => () + _ => (), } let mut total = Uint64::from(TotalStore::load(deps.storage)); @@ -905,11 +901,7 @@ pub fn execute_update_token_weight( youtube_url: Some(extension_res.clone().unwrap().youtube_url.unwrap()), media: Some(extension_res.clone().unwrap().media.unwrap()), protected_attributes: Some( - extension_res - .clone() - .unwrap() - .protected_attributes - .unwrap(), + extension_res.clone().unwrap().protected_attributes.unwrap(), ), token_subtype: Some(extension_res.clone().unwrap().token_subtype.unwrap()), role: Some(extension_res.unwrap().role.unwrap()), @@ -987,7 +979,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { QueryMsg::GetNftContractInfo {} => to_binary(&get_info(deps)?), _ => { let snip721_info = SNIP721_INFO.load(deps.storage)?; - let res:Snip721QueryAnswer = deps.querier.query_wasm_smart( + let res: Snip721QueryAnswer = deps.querier.query_wasm_smart( snip721_info.code_hash.clone(), snip721_info.contract_address.to_string().clone(), &msg, diff --git a/contracts/external/snip721-roles/src/error.rs b/contracts/external/snip721-roles/src/error.rs index 068a804..4e82049 100644 --- a/contracts/external/snip721-roles/src/error.rs +++ b/contracts/external/snip721-roles/src/error.rs @@ -1,5 +1,6 @@ use cosmwasm_std::{OverflowError, StdError}; use thiserror::Error; +use cw_ownable::OwnershipError; #[derive(Debug, Error, PartialEq)] pub enum RolesContractError { @@ -19,7 +20,7 @@ pub enum RolesContractError { OverflowErr(#[from] OverflowError), #[error(transparent)] - Ownable(#[from] cw_ownable::OwnershipError), + Ownable(#[from]OwnershipError), #[error("Cannot burn NFT, member weight would be negative")] CannotBurn {}, diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/Cargo.toml b/contracts/pre-propose/dao-pre-propose-approval-single/Cargo.toml index 1c68847..864ee0c 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/Cargo.toml +++ b/contracts/pre-propose/dao-pre-propose-approval-single/Cargo.toml @@ -32,10 +32,8 @@ cw-hooks ={ workspace = true } [dev-dependencies] cw-denom = { workspace = true } secret-multi-test = { workspace = true } -cw-utils = { workspace = true } +secret-utils = { workspace = true } cw4-group = { workspace = true } -cw20 = { workspace = true } -cw20-base = { workspace = true } dao-dao-core = { workspace = true } dao-hooks = { workspace = true } # dao-testing = { workspace = true } diff --git a/contracts/pre-propose/dao-pre-propose-approver/Cargo.toml b/contracts/pre-propose/dao-pre-propose-approver/Cargo.toml index ba16e52..4b9e2de 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/Cargo.toml +++ b/contracts/pre-propose/dao-pre-propose-approver/Cargo.toml @@ -33,8 +33,6 @@ cw-denom = { workspace = true } secret-multi-test = { workspace = true } secret-utils = { workspace = true } cw4-group = { workspace = true } -cw20 = { workspace = true } -cw20-base = { workspace = true } dao-dao-core = { workspace = true } dao-hooks = { workspace = true } dao-proposal-single = { workspace = true, features = ["library"] } diff --git a/contracts/pre-propose/dao-pre-propose-multiple/Cargo.toml b/contracts/pre-propose/dao-pre-propose-multiple/Cargo.toml index d33ae92..b88985d 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/Cargo.toml +++ b/contracts/pre-propose/dao-pre-propose-multiple/Cargo.toml @@ -27,8 +27,6 @@ dao-voting = { workspace = true } secret-multi-test = { workspace = true } secret-utils = { workspace = true } cw4-group = { workspace = true } -cw20 = { workspace = true } -cw20-base = { workspace = true } dao-voting-snip20-staked = { workspace = true } dao-proposal-multiple = { workspace = true } dao-dao-core = { workspace = true } diff --git a/contracts/pre-propose/dao-pre-propose-single/Cargo.toml b/contracts/pre-propose/dao-pre-propose-single/Cargo.toml index 8bda404..667759b 100644 --- a/contracts/pre-propose/dao-pre-propose-single/Cargo.toml +++ b/contracts/pre-propose/dao-pre-propose-single/Cargo.toml @@ -24,11 +24,9 @@ dao-voting = { workspace = true } secret-cw2 = { workspace = true } [dev-dependencies] -cw-multi-test = { workspace = true } -cw-utils = { workspace = true } +secret-multi-test = { workspace = true } +secret-utils = { workspace = true } cw4-group = { workspace = true } -cw20 = { workspace = true } -cw20-base = { workspace = true } cw-denom = { workspace = true } dao-interface = { workspace = true } # dao-testing = { workspace = true } diff --git a/contracts/proposal/dao-proposal-multiple/Cargo.toml b/contracts/proposal/dao-proposal-multiple/Cargo.toml index 797fb32..7e16dda 100644 --- a/contracts/proposal/dao-proposal-multiple/Cargo.toml +++ b/contracts/proposal/dao-proposal-multiple/Cargo.toml @@ -30,7 +30,6 @@ cosmwasm-schema = { workspace = true } secret-storage-plus = { workspace = true } secret-utils = { workspace = true } secret-cw2 = { workspace = true } -cw20 = { workspace = true } cw3 = { workspace = true } thiserror = { workspace = true } dao-dao-macros = { workspace = true } @@ -57,8 +56,6 @@ dao-voting-snip721-staked = { workspace = true } cw-denom = { workspace = true } # dao-testing = { workspace = true } snip20-stake = { workspace = true } -cw20-base = { workspace = true } -cw721-base = { workspace = true } cw4 = { workspace = true } cw4-group = { workspace = true } rand = { workspace = true } diff --git a/contracts/proposal/dao-proposal-multiple/src/contract.rs b/contracts/proposal/dao-proposal-multiple/src/contract.rs index f195a94..254ee55 100644 --- a/contracts/proposal/dao-proposal-multiple/src/contract.rs +++ b/contracts/proposal/dao-proposal-multiple/src/contract.rs @@ -410,10 +410,9 @@ pub fn execute_vote( return Err(ContractError::NotRegistered {}); } - let ballot = BALLOTS.get(deps.storage, &(proposal_id, info.sender.clone())); match ballot { - Some(current_ballot) => { + Some(current_ballot) => { if prop.allow_revoting { if current_ballot.vote == vote { // Don't allow casting the same vote more than @@ -422,37 +421,35 @@ pub fn execute_vote( return Err(ContractError::AlreadyCast {}); } prop.votes - .remove_vote(current_ballot.vote, current_ballot.power)?; + .remove_vote(current_ballot.vote, current_ballot.power)?; BALLOTS.insert( - deps.storage, - &(proposal_id, info.sender.clone()), - &Ballot { - power: vote_power, - vote, - // Roll over the previous rationale. If - // you're changing your vote, you've also - // likely changed your thinking. - rationale: rationale.clone(), - }, - )?; + deps.storage, + &(proposal_id, info.sender.clone()), + &Ballot { + power: vote_power, + vote, + // Roll over the previous rationale. If + // you're changing your vote, you've also + // likely changed your thinking. + rationale: rationale.clone(), + }, + )?; } else { return Err(ContractError::AlreadyVoted {}); } } None => { - - BALLOTS.insert( - deps.storage, - &(proposal_id, info.sender.clone()), - &Ballot { - power: vote_power, - vote, - rationale: rationale.clone(), - }, - )?; - + BALLOTS.insert( + deps.storage, + &(proposal_id, info.sender.clone()), + &Ballot { + power: vote_power, + vote, + rationale: rationale.clone(), + }, + )?; + } } -} let old_status = prop.status; @@ -620,8 +617,8 @@ pub fn execute_close( proposal_id: u64, ) -> Result, ContractError> { let mut prop = PROPOSALS - .get(deps.storage, &proposal_id) - .ok_or(ContractError::NoSuchProposal { id: proposal_id })?; + .get(deps.storage, &proposal_id) + .ok_or(ContractError::NoSuchProposal { id: proposal_id })?; prop.update_status(&env.block)?; if prop.status != Status::Rejected { @@ -741,7 +738,6 @@ pub fn execute_update_rationale( proposal_id: u64, rationale: Option, ) -> Result { - let ballot = BALLOTS.get(deps.storage, &(proposal_id, info.sender.clone())); if ballot.clone().is_some() { ballot.clone().unwrap().rationale = rationale.clone(); diff --git a/contracts/proposal/dao-proposal-single/src/contract.rs b/contracts/proposal/dao-proposal-single/src/contract.rs index e7c0f76..73dcaed 100644 --- a/contracts/proposal/dao-proposal-single/src/contract.rs +++ b/contracts/proposal/dao-proposal-single/src/contract.rs @@ -531,7 +531,7 @@ pub fn execute_vote( let ballot = BALLOTS.get(deps.storage, &(proposal_id, info.sender.clone())); match ballot { - Some(current_ballot) => { + Some(current_ballot) => { if prop.allow_revoting { if current_ballot.vote == vote { // Don't allow casting the same vote more than @@ -540,37 +540,35 @@ pub fn execute_vote( return Err(ContractError::AlreadyCast {}); } prop.votes - .remove_vote(current_ballot.vote, current_ballot.power); + .remove_vote(current_ballot.vote, current_ballot.power); BALLOTS.insert( - deps.storage, - &(proposal_id, info.sender.clone()), - &Ballot { - power: vote_power, - vote, - // Roll over the previous rationale. If - // you're changing your vote, you've also - // likely changed your thinking. - rationale: rationale.clone(), - }, - )?; + deps.storage, + &(proposal_id, info.sender.clone()), + &Ballot { + power: vote_power, + vote, + // Roll over the previous rationale. If + // you're changing your vote, you've also + // likely changed your thinking. + rationale: rationale.clone(), + }, + )?; } else { return Err(ContractError::AlreadyVoted {}); } } None => { - - BALLOTS.insert( - deps.storage, - &(proposal_id, info.sender.clone()), - &Ballot { - power: vote_power, - vote, - rationale: rationale.clone(), - }, - )?; - + BALLOTS.insert( + deps.storage, + &(proposal_id, info.sender.clone()), + &Ballot { + power: vote_power, + vote, + rationale: rationale.clone(), + }, + )?; + } } -} let old_status = prop.status; @@ -613,7 +611,6 @@ pub fn execute_update_rationale( proposal_id: u64, rationale: Option, ) -> Result { - let ballot = BALLOTS.get(deps.storage, &(proposal_id, info.sender.clone())); if ballot.clone().is_some() { ballot.clone().unwrap().rationale = rationale.clone(); @@ -643,8 +640,8 @@ pub fn execute_close( proposal_id: u64, ) -> Result { let mut prop = PROPOSALS - .get(deps.storage, &proposal_id) - .ok_or(ContractError::NoSuchProposal { id: proposal_id })?; + .get(deps.storage, &proposal_id) + .ok_or(ContractError::NoSuchProposal { id: proposal_id })?; // Update status to ensure that proposals which were open and have // expired are moved to "rejected." diff --git a/contracts/staking/snip20-stake-external-rewards/Cargo.toml b/contracts/staking/snip20-stake-external-rewards/Cargo.toml index 2555767..a1ace53 100644 --- a/contracts/staking/snip20-stake-external-rewards/Cargo.toml +++ b/contracts/staking/snip20-stake-external-rewards/Cargo.toml @@ -21,7 +21,6 @@ cosmwasm-schema = { workspace = true } cosmwasm-storage = { workspace = true } secret-storage-plus = { workspace = true } secret-cw-controllers = { workspace = true } -cw20 = { workspace = true } secret-utils = { workspace = true } secret-cw2 = { workspace = true } thiserror = { workspace = true } diff --git a/contracts/staking/snip20-stake-reward-distributor/Cargo.toml b/contracts/staking/snip20-stake-reward-distributor/Cargo.toml index 598991c..d8f3ab7 100644 --- a/contracts/staking/snip20-stake-reward-distributor/Cargo.toml +++ b/contracts/staking/snip20-stake-reward-distributor/Cargo.toml @@ -21,8 +21,6 @@ library = [] cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } serde={workspace=true} -cw20 = { workspace = true } -cw20-base = { workspace = true, features = ["library"] } snip20-stake = { workspace = true, features = ["library"]} thiserror = { workspace = true } cw-ownable = { workspace = true } diff --git a/contracts/staking/snip20-stake-reward-distributor/src/contract.rs b/contracts/staking/snip20-stake-reward-distributor/src/contract.rs index f89d2d5..efa71b7 100644 --- a/contracts/staking/snip20-stake-reward-distributor/src/contract.rs +++ b/contracts/staking/snip20-stake-reward-distributor/src/contract.rs @@ -220,7 +220,7 @@ fn get_distribution_msg(deps: Deps, env: &Env) -> Result { - balance=amount; + balance = amount; } _ => (), } @@ -277,7 +277,7 @@ pub fn execute_withdraw( let mut balance = Uint128::zero(); match balance_info { QueryAnswer::Balance { amount } => { - balance=amount; + balance = amount; } _ => (), } @@ -342,7 +342,7 @@ fn query_info(deps: Deps, env: Env) -> StdResult { let mut balance = Uint128::zero(); match balance_info { QueryAnswer::Balance { amount } => { - balance=amount; + balance = amount; } _ => (), } diff --git a/contracts/staking/snip20-stake/Cargo.toml b/contracts/staking/snip20-stake/Cargo.toml index c40ab62..f0f50a4 100644 --- a/contracts/staking/snip20-stake/Cargo.toml +++ b/contracts/staking/snip20-stake/Cargo.toml @@ -26,7 +26,6 @@ cw-paginate-storage = { workspace = true } cw-ownable = { workspace = true } dao-hooks = { workspace = true } dao-voting = { workspace = true } -cw20 ={ workspace = true } cw20-stake-v1 = { workspace = true, features = ["library"] } cw-utils-v1 = { workspace = true } diff --git a/contracts/voting/dao-voting-snip20-staked/Cargo.toml b/contracts/voting/dao-voting-snip20-staked/Cargo.toml index 54e821a..afa88f8 100644 --- a/contracts/voting/dao-voting-snip20-staked/Cargo.toml +++ b/contracts/voting/dao-voting-snip20-staked/Cargo.toml @@ -32,7 +32,6 @@ thiserror = { workspace = true } dao-dao-macros = { workspace = true } dao-interface = { workspace = true } dao-voting = { workspace = true } -cw20-base={workspace=true} cw-ownable={workspace=true} secret-cw-controllers={ workspace=true } diff --git a/contracts/voting/dao-voting-snip721-roles/examples/schema.rs b/contracts/voting/dao-voting-snip721-roles/examples/schema.rs index 0e391c5..f89dd48 100644 --- a/contracts/voting/dao-voting-snip721-roles/examples/schema.rs +++ b/contracts/voting/dao-voting-snip721-roles/examples/schema.rs @@ -1,5 +1,5 @@ use cosmwasm_schema::write_api; -use dao_voting_cw721_roles::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; +use dao_voting_snip721_roles::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; fn main() { write_api! { diff --git a/contracts/voting/dao-voting-snip721-staked/Cargo.toml b/contracts/voting/dao-voting-snip721-staked/Cargo.toml index 7c0a120..aeb5bd5 100644 --- a/contracts/voting/dao-voting-snip721-staked/Cargo.toml +++ b/contracts/voting/dao-voting-snip721-staked/Cargo.toml @@ -28,8 +28,6 @@ cosmwasm-schema = { workspace = true } secret-storage-plus = { workspace = true } secret-cw-controllers = { workspace = true } cw-hooks = { workspace = true } -cw721 = { workspace = true } -cw721-base = { workspace = true, features = ["library"] } snip721-controllers = { workspace = true } cw-paginate-storage = { workspace = true } secret-utils = { workspace = true } diff --git a/contracts/voting/dao-voting-snip721-staked/src/state.rs b/contracts/voting/dao-voting-snip721-staked/src/state.rs index dc0e8f2..100e397 100644 --- a/contracts/voting/dao-voting-snip721-staked/src/state.rs +++ b/contracts/voting/dao-voting-snip721-staked/src/state.rs @@ -151,7 +151,7 @@ impl StakedNftsTotalStore { /// The maximum number of claims that may be outstanding. pub const MAX_CLAIMS: u64 = 70; -pub const NFT_CLAIMS: NftClaims = NftClaims::new("nft_claims"); +pub const NFT_CLAIMS: NftClaims = NftClaims::new(b"nft_claims"); // Hooks to contracts that will receive staking and unstaking // messages. diff --git a/contracts/voting/dao-voting-token-staked/src/contract.rs b/contracts/voting/dao-voting-token-staked/src/contract.rs index a69ce98..ac59404 100644 --- a/contracts/voting/dao-voting-token-staked/src/contract.rs +++ b/contracts/voting/dao-voting-token-staked/src/contract.rs @@ -3,9 +3,8 @@ use cosmwasm_std::entry_point; use cosmos_sdk_proto::cosmos::bank; use cosmwasm_std::{ - coins, to_binary, to_vec, BankMsg, Binary, ContractResult, CosmosMsg, Deps, - DepsMut, Empty, Env, MessageInfo, QueryRequest, Response, StdError, StdResult, - SystemResult, Uint128, Uint256, + coins, to_binary, to_vec, BankMsg, Binary, ContractResult, CosmosMsg, Deps, DepsMut, Empty, + Env, MessageInfo, QueryRequest, Response, StdError, StdResult, SystemResult, Uint128, Uint256, }; use cw_hooks::HookItem; // use cw_tokenfactory_issuer::msg::{ @@ -115,65 +114,63 @@ pub fn instantiate( .add_attribute("token", "existing_token") .add_attribute("denom", denom) .set_data(to_binary(&(env.contract.address, env.contract.code_hash))?)) - } - - // TokenInfo::New(ref token) => { - // let NewTokenInfo { - // subdenom, - // token_issuer_code_id, - // token_issuer_code_hash, - // .. - // } = token; - - // // Save new token info for use in reply - // TOKEN_INSTANTIATION_INFO.save(deps.storage, &msg.token_info)?; - - // // Instantiate cw-token-factory-issuer contract - // // DAO (sender) is set as contract admin - // let msg = IssuerInstantiateMsg::NewToken { - // subdenom: subdenom.to_string(), - // }; - // let issuer_instantiate_msg = SubMsg::reply_on_success( - // msg.to_cosmos_msg( - // Some(info.sender.to_string()), - // env.contract.address.to_string(), - // token_issuer_code_id.clone(), - // token_issuer_code_hash.clone(), - // None, - // )?, - // INSTANTIATE_TOKEN_FACTORY_ISSUER_REPLY_ID, - // ); - - // Ok(Response::new() - // .add_attribute("action", "instantiate") - // .add_attribute("token", "new_token") - // .add_submessage(issuer_instantiate_msg)) - // } - // TokenInfo::Factory(binary) => match from_binary(&binary)? { - // WasmMsg::Execute { - // msg, - // contract_addr, - // code_hash, - // funds, - // } => { - // // Call factory contract. Use only a trusted factory contract, - // // as this is a critical security component and valdiation of - // // setup will happen in the factory. - // Ok(Response::new() - // .add_attribute("action", "intantiate") - // .add_attribute("token", "custom_factory") - // .add_submessage(SubMsg::reply_on_success( - // WasmMsg::Execute { - // contract_addr, - // code_hash, - // msg, - // funds, - // }, - // FACTORY_EXECUTE_REPLY_ID, - // ))) - // } - // _ => Err(ContractError::UnsupportedFactoryMsg {}), - // }, + } // TokenInfo::New(ref token) => { + // let NewTokenInfo { + // subdenom, + // token_issuer_code_id, + // token_issuer_code_hash, + // .. + // } = token; + + // // Save new token info for use in reply + // TOKEN_INSTANTIATION_INFO.save(deps.storage, &msg.token_info)?; + + // // Instantiate cw-token-factory-issuer contract + // // DAO (sender) is set as contract admin + // let msg = IssuerInstantiateMsg::NewToken { + // subdenom: subdenom.to_string(), + // }; + // let issuer_instantiate_msg = SubMsg::reply_on_success( + // msg.to_cosmos_msg( + // Some(info.sender.to_string()), + // env.contract.address.to_string(), + // token_issuer_code_id.clone(), + // token_issuer_code_hash.clone(), + // None, + // )?, + // INSTANTIATE_TOKEN_FACTORY_ISSUER_REPLY_ID, + // ); + + // Ok(Response::new() + // .add_attribute("action", "instantiate") + // .add_attribute("token", "new_token") + // .add_submessage(issuer_instantiate_msg)) + // } + // TokenInfo::Factory(binary) => match from_binary(&binary)? { + // WasmMsg::Execute { + // msg, + // contract_addr, + // code_hash, + // funds, + // } => { + // // Call factory contract. Use only a trusted factory contract, + // // as this is a critical security component and valdiation of + // // setup will happen in the factory. + // Ok(Response::new() + // .add_attribute("action", "intantiate") + // .add_attribute("token", "custom_factory") + // .add_submessage(SubMsg::reply_on_success( + // WasmMsg::Execute { + // contract_addr, + // code_hash, + // msg, + // funds, + // }, + // FACTORY_EXECUTE_REPLY_ID, + // ))) + // } + // _ => Err(ContractError::UnsupportedFactoryMsg {}), + // }, } } diff --git a/contracts/voting/dao-voting-token-staked/src/msg.rs b/contracts/voting/dao-voting-token-staked/src/msg.rs index 435972d..25ced72 100644 --- a/contracts/voting/dao-voting-token-staked/src/msg.rs +++ b/contracts/voting/dao-voting-token-staked/src/msg.rs @@ -16,7 +16,6 @@ pub enum TokenInfo { /// Token factory denom denom: String, }, - // NOTE* There is right now no way to create new token so will be using existing token // Creates a new Token Factory token via the issue contract with the DAO automatically diff --git a/packages/controllers/src/hooks.rs b/packages/controllers/src/hooks.rs index 658fdf4..91ff624 100644 --- a/packages/controllers/src/hooks.rs +++ b/packages/controllers/src/hooks.rs @@ -33,10 +33,9 @@ pub enum HookError { HookNotRegistered {}, } - #[cw_serde] pub struct HookItem { - pub addr : Addr, + pub addr: Addr, pub code_hash: String, } // store all hook addresses in one item. We cannot have many of them before the contract becomes unusable anyway. @@ -47,7 +46,11 @@ impl<'a> Hooks<'a> { Hooks(Item::new(storage_key)) } - pub fn add_hook(&self, storage: &mut dyn Storage, hook_item: HookItem) -> Result<(), HookError> { + pub fn add_hook( + &self, + storage: &mut dyn Storage, + hook_item: HookItem, + ) -> Result<(), HookError> { let mut hooks = self.0.may_load(storage)?.unwrap_or_default(); if !hooks.iter().any(|h| h == &hook_item) { hooks.push(hook_item); @@ -57,7 +60,11 @@ impl<'a> Hooks<'a> { Ok(self.0.save(storage, &hooks)?) } - pub fn remove_hook(&self, storage: &mut dyn Storage, hook_item: HookItem) -> Result<(), HookError> { + pub fn remove_hook( + &self, + storage: &mut dyn Storage, + hook_item: HookItem, + ) -> Result<(), HookError> { let mut hooks = self.0.load(storage)?; if let Some(p) = hooks.iter().position(|x| x == &hook_item) { hooks.remove(p); @@ -86,13 +93,19 @@ impl<'a> Hooks<'a> { deps: DepsMut, info: MessageInfo, addr: Addr, - code_hash: String + code_hash: String, ) -> Result, HookError> where C: Clone + fmt::Debug + PartialEq + JsonSchema, { admin.assert_admin(deps.as_ref(), &info.sender)?; - self.add_hook(deps.storage, HookItem { addr:addr.clone(), code_hash:code_hash.clone()})?; + self.add_hook( + deps.storage, + HookItem { + addr: addr.clone(), + code_hash: code_hash.clone(), + }, + )?; let attributes = vec![ attr("action", "add_hook"), @@ -108,13 +121,19 @@ impl<'a> Hooks<'a> { deps: DepsMut, info: MessageInfo, addr: Addr, - code_hash: String + code_hash: String, ) -> Result, HookError> where C: Clone + fmt::Debug + PartialEq + JsonSchema, { admin.assert_admin(deps.as_ref(), &info.sender)?; - self.remove_hook(deps.storage, HookItem { addr:addr.clone(), code_hash:code_hash.clone()})?; + self.remove_hook( + deps.storage, + HookItem { + addr: addr.clone(), + code_hash: code_hash.clone(), + }, + )?; let attributes = vec![ attr("action", "remove_hook"), diff --git a/packages/controllers/src/replies.rs b/packages/controllers/src/replies.rs index 41277a6..55499d3 100644 --- a/packages/controllers/src/replies.rs +++ b/packages/controllers/src/replies.rs @@ -25,9 +25,9 @@ pub enum ReplyEvent { Snip20ModuleInstantiate { code_hash: String }, Snip20ModuleCreateViewingKey {}, FailedPreProposeModuleHook {}, - FailedVoteHook{ idx: u64}, - FailedProposalHook { idx: u64}, - FailedProposalExecution {proposal_id : u64}, + FailedVoteHook { idx: u64 }, + FailedProposalHook { idx: u64 }, + FailedProposalExecution { proposal_id: u64 }, } // store all hook addresses in one item. We cannot have many of them before the contract becomes unusable anyway. pub struct ReplyIds<'a> { @@ -35,8 +35,6 @@ pub struct ReplyIds<'a> { curr_id: Item<'a, u64>, } - - impl<'a> ReplyIds<'a> { pub const fn new(namespace: &'a [u8], count_namespace: &'a [u8]) -> Self { ReplyIds { diff --git a/packages/cw-denom/src/lib.rs b/packages/cw-denom/src/lib.rs index 1b56915..1b6fb13 100644 --- a/packages/cw-denom/src/lib.rs +++ b/packages/cw-denom/src/lib.rs @@ -39,7 +39,7 @@ pub enum CheckedDenom { /// A native (bank module) asset. Native(String), /// A cw20 asset. - Cw20(Addr,String), + Cw20(Addr, String), } /// A denom that has not been checked to confirm it points to a valid @@ -49,7 +49,7 @@ pub enum UncheckedDenom { /// A native (bank module) asset. Native(String), /// A cw20 asset. - Cw20(String,String), + Cw20(String, String), } impl UncheckedDenom { @@ -65,7 +65,7 @@ impl UncheckedDenom { pub fn into_checked(self, deps: Deps) -> Result { match self { Self::Native(denom) => validate_native_denom(denom), - Self::Cw20(addr,code_hash) => { + Self::Cw20(addr, code_hash) => { let addr = deps.api.addr_validate(&addr)?; let _info: secret_toolkit::snip20::TokenInfoResponse = deps .querier @@ -75,7 +75,7 @@ impl UncheckedDenom { &secret_toolkit::snip20::QueryMsg::TokenInfo {}, ) .map_err(|err| DenomError::InvalidCw20 { err })?; - Ok(CheckedDenom::Cw20(addr,code_hash)) + Ok(CheckedDenom::Cw20(addr, code_hash)) } } } @@ -97,7 +97,7 @@ impl CheckedDenom { pub fn is_cw20(&self, cw20: &Addr) -> bool { match self { CheckedDenom::Native(_) => false, - CheckedDenom::Cw20(a,_) => a == cw20, + CheckedDenom::Cw20(a, _) => a == cw20, } } @@ -129,7 +129,7 @@ impl CheckedDenom { ) -> StdResult { match self { CheckedDenom::Native(denom) => Ok(querier.query_balance(who, denom)?.amount), - CheckedDenom::Cw20(address,code_hash) => { + CheckedDenom::Cw20(address, code_hash) => { let balance: secret_toolkit::snip20::Balance = querier.query_wasm_smart( code_hash, address, @@ -146,11 +146,7 @@ impl CheckedDenom { /// Gets a `CosmosMsg` that, when executed, will transfer AMOUNT /// tokens to WHO. AMOUNT being zero will cause the message /// execution to fail. - pub fn get_transfer_to_message( - &self, - who: &Addr, - amount: Uint128, - ) -> StdResult { + pub fn get_transfer_to_message(&self, who: &Addr, amount: Uint128) -> StdResult { Ok(match self { CheckedDenom::Native(denom) => BankMsg::Send { to_address: who.to_string(), @@ -160,9 +156,9 @@ impl CheckedDenom { }], } .into(), - CheckedDenom::Cw20(address,code_hash) => WasmMsg::Execute { + CheckedDenom::Cw20(address, code_hash) => WasmMsg::Execute { contract_addr: address.to_string(), - code_hash:code_hash.to_string(), + code_hash: code_hash.to_string(), msg: to_binary(&secret_toolkit::snip20::HandleMsg::Transfer { recipient: who.to_string(), amount, @@ -208,7 +204,7 @@ impl fmt::Display for CheckedDenom { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Native(inner) => write!(f, "{inner}"), - Self::Cw20(inner,_) => write!(f, "{inner}"), + Self::Cw20(inner, _) => write!(f, "{inner}"), } } } @@ -225,7 +221,6 @@ mod tests { const CW20_ADDR: &str = "cw20"; const CW20_CODE_HASH: &str = "CODE_HASH"; - fn token_info_mock_querier(works: bool) -> impl Fn(&WasmQuery) -> QuerierResult { move |query: &WasmQuery| -> QuerierResult { match query { @@ -263,12 +258,13 @@ mod tests { let mut deps = mock_dependencies(); deps.querier = querier; - let unchecked = UncheckedDenom::Cw20(CW20_ADDR.to_string(),CW20_CODE_HASH.to_string()); - let checked = unchecked - .into_checked(deps.as_ref()) - .unwrap(); + let unchecked = UncheckedDenom::Cw20(CW20_ADDR.to_string(), CW20_CODE_HASH.to_string()); + let checked = unchecked.into_checked(deps.as_ref()).unwrap(); - assert_eq!(checked, CheckedDenom::Cw20(Addr::unchecked(CW20_ADDR),CW20_CODE_HASH.to_string())) + assert_eq!( + checked, + CheckedDenom::Cw20(Addr::unchecked(CW20_ADDR), CW20_CODE_HASH.to_string()) + ) } #[test] @@ -279,10 +275,8 @@ mod tests { let mut deps = mock_dependencies(); deps.querier = querier; - let unchecked = UncheckedDenom::Cw20(CW20_ADDR.to_string(),CW20_CODE_HASH.to_string()); - let err = unchecked - .into_checked(deps.as_ref()) - .unwrap_err(); + let unchecked = UncheckedDenom::Cw20(CW20_ADDR.to_string(), CW20_CODE_HASH.to_string()); + let err = unchecked.into_checked(deps.as_ref()).unwrap_err(); assert_eq!( err, DenomError::InvalidCw20 { @@ -301,10 +295,11 @@ mod tests { let mut deps = mock_dependencies(); deps.querier = querier; - let unchecked = UncheckedDenom::Cw20("HasCapitalsSoShouldNotValidate".to_string(),"HasCapitalsSoShouldNotValidate".to_string()); - let err = unchecked - .into_checked(deps.as_ref()) - .unwrap_err(); + let unchecked = UncheckedDenom::Cw20( + "HasCapitalsSoShouldNotValidate".to_string(), + "HasCapitalsSoShouldNotValidate".to_string(), + ); + let err = unchecked.into_checked(deps.as_ref()).unwrap_err(); assert_eq!( err, DenomError::Std(StdError::GenericErr { @@ -384,7 +379,7 @@ mod tests { fn test_display() { let denom = CheckedDenom::Native("hello".to_string()); assert_eq!(denom.to_string(), "hello".to_string()); - let denom = CheckedDenom::Cw20(Addr::unchecked("hello"),"CODE_HASH".to_string()); + let denom = CheckedDenom::Cw20(Addr::unchecked("hello"), "CODE_HASH".to_string()); assert_eq!(denom.to_string(), "hello".to_string()); } } diff --git a/packages/cw-hooks/src/lib.rs b/packages/cw-hooks/src/lib.rs index 477fcdb..bbe7bc6 100644 --- a/packages/cw-hooks/src/lib.rs +++ b/packages/cw-hooks/src/lib.rs @@ -3,10 +3,10 @@ use cosmwasm_schema::cw_serde; use thiserror::Error; -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; use cosmwasm_std::{Addr, CustomQuery, Deps, StdError, StdResult, Storage, SubMsg}; +use schemars::JsonSchema; use secret_storage_plus::Item; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] @@ -28,19 +28,22 @@ pub enum HookError { #[cw_serde] pub struct HookItem { - pub addr : Addr, + pub addr: Addr, pub code_hash: String, } // store all hook addresses in one item. We cannot have many of them before the contract becomes unusable anyway. pub struct Hooks<'a>(Item<'a, Vec>); - impl<'a> Hooks<'a> { pub const fn new(storage_key: &'a str) -> Self { Hooks(Item::new(storage_key)) } - pub fn add_hook(&self, storage: &mut dyn Storage, hook_item: HookItem) -> Result<(), HookError> { + pub fn add_hook( + &self, + storage: &mut dyn Storage, + hook_item: HookItem, + ) -> Result<(), HookError> { let mut hooks = self.0.may_load(storage)?.unwrap_or_default(); if !hooks.iter().any(|h| h == &hook_item) { hooks.push(hook_item); @@ -50,7 +53,11 @@ impl<'a> Hooks<'a> { Ok(self.0.save(storage, &hooks)?) } - pub fn remove_hook(&self, storage: &mut dyn Storage, hook_item: HookItem) -> Result<(), HookError> { + pub fn remove_hook( + &self, + storage: &mut dyn Storage, + hook_item: HookItem, + ) -> Result<(), HookError> { let mut hooks = self.0.load(storage)?; if let Some(p) = hooks.iter().position(|h| h == &hook_item) { hooks.remove(p); @@ -144,8 +151,24 @@ mod tests { .unwrap(); assert_eq!(msgs, vec![]); - hooks.add_hook(storage, HookItem { addr: addr!("ekez"), code_hash: "def".to_string() }).unwrap(); - hooks.add_hook(storage, HookItem { addr: addr!("meow"), code_hash: "abc".to_string() }).unwrap(); + hooks + .add_hook( + storage, + HookItem { + addr: addr!("ekez"), + code_hash: "def".to_string(), + }, + ) + .unwrap(); + hooks + .add_hook( + storage, + HookItem { + addr: addr!("meow"), + code_hash: "abc".to_string(), + }, + ) + .unwrap(); assert_eq!(hooks.hook_count(storage).unwrap(), 2); @@ -200,10 +223,24 @@ mod tests { // Query hooks returns all hooks added let HooksResponse { hooks: the_hooks } = hooks.query_hooks(deps.as_ref()).unwrap(); - assert_eq!(the_hooks, vec![HookItem { addr: addr!("meow"), code_hash: "abc".to_string() }]); + assert_eq!( + the_hooks, + vec![HookItem { + addr: addr!("meow"), + code_hash: "abc".to_string() + }] + ); // Remove last hook - hooks.remove_hook(&mut deps.storage, HookItem { addr: addr!("meow"), code_hash: "abc".to_string() }).unwrap(); + hooks + .remove_hook( + &mut deps.storage, + HookItem { + addr: addr!("meow"), + code_hash: "abc".to_string(), + }, + ) + .unwrap(); // Query hooks returns empty vector if no hooks added let HooksResponse { hooks: the_hooks } = hooks.query_hooks(deps.as_ref()).unwrap(); diff --git a/packages/cw-ownable-0.5.1/src/lib.rs b/packages/cw-ownable-0.5.1/src/lib.rs index 44c28b0..d57b743 100644 --- a/packages/cw-ownable-0.5.1/src/lib.rs +++ b/packages/cw-ownable-0.5.1/src/lib.rs @@ -1,8 +1,8 @@ use std::fmt::Display; use cosmwasm_schema::cw_serde; -use cw_address_like::AddressLike; use cosmwasm_std::{Addr, Api, Attribute, BlockInfo, DepsMut, StdError, StdResult, Storage}; +use cw_address_like::AddressLike; use secret_storage_plus::Item; // re-export the proc macros and the Expiration class diff --git a/packages/cw-paginate-storage/src/lib.rs b/packages/cw-paginate-storage/src/lib.rs index fd663e6..9b32d66 100644 --- a/packages/cw-paginate-storage/src/lib.rs +++ b/packages/cw-paginate-storage/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] -use cosmwasm_std::{Deps, StdResult,StdError}; +use cosmwasm_std::{Deps, StdError, StdResult}; use secret_toolkit::storage::{ keymap::{KeyItemIter, KeyIter}, Keymap, @@ -38,7 +38,6 @@ impl From for i32 { } } - /// Generic function for paginating a list of (K, V) pairs in a /// CosmWasm Map. pub fn paginate_map( @@ -55,7 +54,6 @@ where .flatten() .collect(); - Ok(items) } @@ -201,7 +199,7 @@ where // &map, // Some("1".to_string()), // None, - + // ) // .unwrap(); // assert_eq!(items, vec!["2"]); diff --git a/packages/cw-wormhole/src/lib.rs b/packages/cw-wormhole/src/lib.rs index feb5d3c..c23f8e3 100644 --- a/packages/cw-wormhole/src/lib.rs +++ b/packages/cw-wormhole/src/lib.rs @@ -78,18 +78,16 @@ impl<'n, K, V> Wormhole<'n, K, V> { impl<'n, K, V> Wormhole<'n, K, V> where - // 1. keys in the map can be cloned - K: Serialize + DeserializeOwned + Clone+PartialEq, - // 1.1. values in the map can be serialized and deserialized - V: serde::de::DeserializeOwned + serde::Serialize + Default + Clone + // 1. keys in the map can be cloned + K: Serialize + DeserializeOwned + Clone + PartialEq, + // 1.1. values in the map can be serialized and deserialized + V: serde::de::DeserializeOwned + serde::Serialize + Default + Clone, { /// Loads the value at a key at the specified time. If the key has /// no value at that time, returns `None`. Returns `Some(value)` /// otherwise. pub fn load(&self, storage: &dyn Storage, k: K, t: u64) -> StdResult> { - Ok(self - .snapshots() - .get(storage, &(k, t))) + Ok(self.snapshots().get(storage, &(k, t))) } /// Increments the value of key `k` at time `t` by amount `i`. @@ -100,13 +98,13 @@ where self.update(storage, k, t, &mut |v, _| v + i.clone()) } - /// Decrements the value of key `k` at time `t` by amount `i`. - pub fn decrement(&self, storage: &mut dyn Storage, k: K, t: u64, i: V) -> StdResult - where - V: Sub, - { - self.update(storage, k, t, &mut |v, _| v - i.clone()) - } + /// Decrements the value of key `k` at time `t` by amount `i`. + pub fn decrement(&self, storage: &mut dyn Storage, k: K, t: u64, i: V) -> StdResult + where + V: Sub, + { + self.update(storage, k, t, &mut |v, _| v - i.clone()) + } /// Gets the snapshot map with a namespace with a lifetime equal /// to the lifetime of `&'a self`. @@ -129,24 +127,29 @@ where t: u64, update: &mut dyn FnMut(V, u64) -> V, ) -> StdResult { - // Update the value at t. - let prev = self.load(storage, k.clone(), t)?.unwrap_or_default(); - let updated = update(prev, t); - self.snapshots().insert(storage, &(k.clone(), t), &updated)?; - - // Update all values where t' > t. - let all_entries: Vec<_> = self.snapshots().iter(storage)?.collect::>>()?; - - for ((key, time), value) in all_entries { - if key == k && time > t { - let updated_value = update(value.clone(), time); - self.snapshots().insert(storage, &(key, time), &updated_value)?; - } - } - - Ok(updated) - } - + // Update the value at t. + let prev = self.load(storage, k.clone(), t)?.unwrap_or_default(); + let updated = update(prev, t); + self.snapshots() + .insert(storage, &(k.clone(), t), &updated)?; + + // Update all values where t' > t. + let all_entries: Vec<_> = self + .snapshots() + .iter(storage)? + .collect::>>()?; + + for ((key, time), value) in all_entries { + if key == k && time > t { + let updated_value = update(value.clone(), time); + self.snapshots() + .insert(storage, &(key, time), &updated_value)?; + } + } + + Ok(updated) + } + /// Updates a single key `k` at time `t` without performing an /// update on values of `(k, t')` where `t' > t`. /// @@ -205,4 +208,4 @@ where } #[cfg(test)] -mod tests; \ No newline at end of file +mod tests; diff --git a/packages/cw-wormhole/src/tests.rs b/packages/cw-wormhole/src/tests.rs index 8d1f186..f8244ef 100644 --- a/packages/cw-wormhole/src/tests.rs +++ b/packages/cw-wormhole/src/tests.rs @@ -56,9 +56,6 @@ // // Calls to update should visit values in ascending order in terms of // // time. - - - // // #[test] // // fn test_update_visits_in_ascending_order() { // // let storage = &mut mock_dependencies().storage; @@ -112,4 +109,4 @@ // // // values. // // let v = w.load(storage, (), 4).unwrap().unwrap(); // // assert_eq!(v, 10); -// // } \ No newline at end of file +// // } diff --git a/packages/cw4-group-1.1.2/src/tests.rs b/packages/cw4-group-1.1.2/src/tests.rs index 83b3d4c..fcfcf51 100644 --- a/packages/cw4-group-1.1.2/src/tests.rs +++ b/packages/cw4-group-1.1.2/src/tests.rs @@ -6,9 +6,9 @@ use secret_cw_controllers::{AdminError, HookError, HookItem}; use crate::contract::{ execute, instantiate, query_list_members, query_member, query_total_weight, update_members, }; +use crate::error::ContractError; use crate::msg::{ExecuteMsg, InstantiateMsg}; use crate::state::{ADMIN, HOOKS}; -use crate::error::ContractError; const INIT_ADMIN: &str = "juan"; const USER1: &str = "somebody"; @@ -284,9 +284,8 @@ fn add_remove_hooks() { let contract2 = String::from("hook2"); let contract2_code_hash = String::from("shshsh"); - let add_msg = ExecuteMsg::AddHook { - hook:HookItem{ + hook: HookItem { addr: Addr::unchecked(contract1.clone()), code_hash: contract1_code_hash.clone(), }, @@ -313,14 +312,17 @@ fn add_remove_hooks() { ) .unwrap(); let hooks = HOOKS.query_hooks(deps.as_ref()).unwrap(); - assert_eq!(hooks.hooks, vec![HookItem{ - addr: Addr::unchecked(contract1.clone()), - code_hash: contract1_code_hash.clone() - }]); + assert_eq!( + hooks.hooks, + vec![HookItem { + addr: Addr::unchecked(contract1.clone()), + code_hash: contract1_code_hash.clone() + }] + ); // cannot remove a non-registered contract let remove_msg = ExecuteMsg::RemoveHook { - hook:HookItem{ + hook: HookItem { addr: Addr::unchecked(contract2.clone()), code_hash: contract2_code_hash.clone(), }, @@ -330,40 +332,51 @@ fn add_remove_hooks() { // add second contract let add_msg2 = ExecuteMsg::AddHook { - hook:HookItem{ + hook: HookItem { addr: Addr::unchecked(contract2.clone()), code_hash: contract2_code_hash.clone(), }, }; let _ = execute(deps.as_mut(), mock_env(), admin_info.clone(), add_msg2).unwrap(); let hooks = HOOKS.query_hooks(deps.as_ref()).unwrap(); - assert_eq!(hooks.hooks, vec![HookItem{ - addr: Addr::unchecked(contract1.clone()), - code_hash: contract1_code_hash.clone() - }, HookItem{ - addr:Addr::unchecked(contract2.clone()), - code_hash : contract2_code_hash.clone() - }]); + assert_eq!( + hooks.hooks, + vec![ + HookItem { + addr: Addr::unchecked(contract1.clone()), + code_hash: contract1_code_hash.clone() + }, + HookItem { + addr: Addr::unchecked(contract2.clone()), + code_hash: contract2_code_hash.clone() + } + ] + ); // cannot re-add an existing contract let err = execute(deps.as_mut(), mock_env(), admin_info.clone(), add_msg).unwrap_err(); assert_eq!(err, HookError::HookAlreadyRegistered {}.into()); // non-admin cannot remove - let remove_msg = ExecuteMsg::RemoveHook { hook:HookItem{ - addr: Addr::unchecked(contract1.clone()), - code_hash: contract1_code_hash.clone(), - },}; + let remove_msg = ExecuteMsg::RemoveHook { + hook: HookItem { + addr: Addr::unchecked(contract1.clone()), + code_hash: contract1_code_hash.clone(), + }, + }; let err = execute(deps.as_mut(), mock_env(), user_info, remove_msg.clone()).unwrap_err(); assert_eq!(err, HookError::Admin(AdminError::NotAdmin {}).into()); // remove the original let _ = execute(deps.as_mut(), mock_env(), admin_info, remove_msg).unwrap(); let hooks = HOOKS.query_hooks(deps.as_ref()).unwrap(); - assert_eq!(hooks.hooks, vec![ HookItem{ - addr:Addr::unchecked(contract2.clone()), - code_hash : contract2_code_hash.clone() - }]); + assert_eq!( + hooks.hooks, + vec![HookItem { + addr: Addr::unchecked(contract2.clone()), + code_hash: contract2_code_hash.clone() + }] + ); } #[test] @@ -383,13 +396,13 @@ fn hooks_fire() { // register 2 hooks let admin_info = mock_info(INIT_ADMIN, &[]); let add_msg = ExecuteMsg::AddHook { - hook:HookItem{ + hook: HookItem { addr: Addr::unchecked(contract1.clone()), code_hash: contract1_code_hash.clone(), }, }; let add_msg2 = ExecuteMsg::AddHook { - hook:HookItem{ + hook: HookItem { addr: Addr::unchecked(contract2.clone()), code_hash: contract2_code_hash.clone(), }, diff --git a/packages/dao-dao-macros/src/lib.rs b/packages/dao-dao-macros/src/lib.rs index ede2f53..9fc9a54 100644 --- a/packages/dao-dao-macros/src/lib.rs +++ b/packages/dao-dao-macros/src/lib.rs @@ -123,7 +123,7 @@ pub fn voting_module_query(metadata: TokenStream, input: TokenStream) -> TokenSt let vp = dao_interface_path("voting::VotingPowerAtHeightResponse"); let tp = dao_interface_path("voting::TotalPowerAtHeightResponse"); let ci = dao_interface_path("state::AnyContractInfo"); - + merge_variants( metadata, input, diff --git a/packages/dao-hooks/src/all_hooks.rs b/packages/dao-hooks/src/all_hooks.rs index 85e75f1..946d56a 100644 --- a/packages/dao-hooks/src/all_hooks.rs +++ b/packages/dao-hooks/src/all_hooks.rs @@ -4,8 +4,8 @@ use crate::nft_stake::NftStakeChangedHookMsg; use crate::proposal::{PreProposeHookMsg, ProposalHookMsg}; use crate::stake::StakeChangedHookMsg; use crate::vote::VoteHookMsg; -use serde::{Deserialize, Serialize}; use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; /// An enum representing all possible DAO hooks. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] diff --git a/packages/dao-hooks/src/nft_stake.rs b/packages/dao-hooks/src/nft_stake.rs index 419e43e..0611731 100644 --- a/packages/dao-hooks/src/nft_stake.rs +++ b/packages/dao-hooks/src/nft_stake.rs @@ -1,7 +1,7 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; -use cw_hooks::Hooks; use cosmwasm_std::{to_binary, Addr, StdResult, Storage, SubMsg, WasmMsg}; +use cw_hooks::Hooks; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; /// An enum representing NFT staking hooks. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -25,7 +25,7 @@ pub fn stake_nft_hook_msgs( hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.into_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; @@ -48,7 +48,7 @@ pub fn unstake_nft_hook_msgs( hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.into_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; diff --git a/packages/dao-hooks/src/proposal.rs b/packages/dao-hooks/src/proposal.rs index fcb4a73..526b092 100644 --- a/packages/dao-hooks/src/proposal.rs +++ b/packages/dao-hooks/src/proposal.rs @@ -1,12 +1,12 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; +use cosmwasm_std::{to_binary, Empty, StdResult, Storage, SubMsg, WasmMsg}; use cw_hooks::Hooks; use dao_voting::{ pre_propose::ProposalCreationPolicy, reply::{failed_pre_propose_module_hook_id, mask_proposal_hook_index}, status::Status, }; -use cosmwasm_std::{to_binary, Empty, StdResult, Storage, SubMsg, WasmMsg}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; /// An enum representing proposal hook messages. /// Either a new propsoal hook, fired when a new proposal is created, @@ -45,7 +45,7 @@ pub fn new_proposal_hooks( let messages = hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.to_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; @@ -83,7 +83,7 @@ pub fn proposal_status_changed_hooks( let messages = hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.to_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; @@ -109,7 +109,7 @@ pub fn proposal_completed_hooks( let mut hooks: Vec = vec![]; match proposal_creation_policy { ProposalCreationPolicy::Anyone {} => (), - ProposalCreationPolicy::Module { addr,code_hash } => { + ProposalCreationPolicy::Module { addr, code_hash } => { let msg = to_binary(&PreProposeHookMsg::ProposalCompletedHook { proposal_id, new_status, diff --git a/packages/dao-hooks/src/stake.rs b/packages/dao-hooks/src/stake.rs index 04a8744..a8c8fa6 100644 --- a/packages/dao-hooks/src/stake.rs +++ b/packages/dao-hooks/src/stake.rs @@ -1,7 +1,7 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; -use cw_hooks::Hooks; use cosmwasm_std::{to_binary, Addr, StdResult, Storage, SubMsg, Uint128, WasmMsg}; +use cw_hooks::Hooks; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; /// An enum representing staking hooks. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -25,7 +25,7 @@ pub fn stake_hook_msgs( hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.to_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; @@ -47,7 +47,7 @@ pub fn unstake_hook_msgs( hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.to_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; diff --git a/packages/dao-hooks/src/vote.rs b/packages/dao-hooks/src/vote.rs index 913bfca..8cf6855 100644 --- a/packages/dao-hooks/src/vote.rs +++ b/packages/dao-hooks/src/vote.rs @@ -1,8 +1,8 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; +use cosmwasm_std::{to_binary, StdResult, Storage, SubMsg, WasmMsg}; use cw_hooks::Hooks; use dao_voting::reply::mask_vote_hook_index; -use cosmwasm_std::{to_binary, StdResult, Storage, SubMsg, WasmMsg}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; /// An enum representing vote hooks, fired when new votes are cast. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -34,7 +34,7 @@ pub fn new_vote_hooks( hooks.prepare_hooks(storage, |hook_item| { let execute = WasmMsg::Execute { contract_addr: hook_item.addr.to_string(), - code_hash:hook_item.code_hash.clone(), + code_hash: hook_item.code_hash.clone(), msg: msg.clone(), funds: vec![], }; diff --git a/packages/dao-interface/src/migrate_msg.rs b/packages/dao-interface/src/migrate_msg.rs index 5de93fe..a49923d 100644 --- a/packages/dao-interface/src/migrate_msg.rs +++ b/packages/dao-interface/src/migrate_msg.rs @@ -1,10 +1,10 @@ //! types used for migrating modules of the DAO with migrating core //! copyo of the types from dao-migrator contract. -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; use crate::query::SubDao; use crate::state::ModuleInstantiateInfo; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] @@ -14,8 +14,8 @@ pub struct MigrateParams { } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")]pub struct MigrateV1ToV2 { - +#[serde(rename_all = "snake_case")] +pub struct MigrateV1ToV2 { pub sub_daos: Vec, pub migration_params: MigrationModuleParams, pub v1_code_ids: V1CodeIds, diff --git a/packages/dao-interface/src/msg.rs b/packages/dao-interface/src/msg.rs index 8698535..4160d90 100644 --- a/packages/dao-interface/src/msg.rs +++ b/packages/dao-interface/src/msg.rs @@ -1,11 +1,11 @@ -use cosmwasm_schema:: QueryResponses; +use crate::state::Config; +use crate::{migrate_msg::MigrateParams, query::SubDao, state::ModuleInstantiateInfo}; +use cosmwasm_schema::QueryResponses; use cosmwasm_std::{Addr, Binary, CosmosMsg, Empty, Uint128}; use schemars::JsonSchema; use secret_toolkit::utils::HandleCallback; use secret_utils::Duration; use serde::{Deserialize, Serialize}; -use crate::state::Config; -use crate::{migrate_msg::MigrateParams, query::SubDao, state::ModuleInstantiateInfo}; /// Information about an item to be stored in the items list. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -58,7 +58,6 @@ pub struct InstantiateMsg { pub snip721_code_hash: String, } - /// Snip20ReceiveMsg should be de/serialized under `Receive()` variant in a HandleMsg #[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] @@ -182,7 +181,7 @@ pub enum ExecuteMsg { } impl HandleCallback for ExecuteMsg { - const BLOCK_SIZE: usize=256; + const BLOCK_SIZE: usize = 256; } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] @@ -283,7 +282,6 @@ pub enum QueryMsg { /// Returns the total voting power at a given block height. #[returns(crate::voting::TotalPowerAtHeightResponse)] TotalPowerAtHeight { height: Option }, - } #[allow(clippy::large_enum_variant)] diff --git a/packages/dao-interface/src/nft.rs b/packages/dao-interface/src/nft.rs index 7c98fe1..1427753 100644 --- a/packages/dao-interface/src/nft.rs +++ b/packages/dao-interface/src/nft.rs @@ -1,6 +1,6 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; use crate::state::ModuleInstantiateCallback; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/dao-interface/src/proposal.rs b/packages/dao-interface/src/proposal.rs index 687e6b4..bb2112e 100644 --- a/packages/dao-interface/src/proposal.rs +++ b/packages/dao-interface/src/proposal.rs @@ -1,7 +1,7 @@ -use cosmwasm_schema:: QueryResponses; +use cosmwasm_schema::QueryResponses; +use schemars::JsonSchema; use secret_cw2::ContractVersion; use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] diff --git a/packages/dao-interface/src/query.rs b/packages/dao-interface/src/query.rs index 9ff3b64..5afd3f9 100644 --- a/packages/dao-interface/src/query.rs +++ b/packages/dao-interface/src/query.rs @@ -1,10 +1,10 @@ -use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; use cosmwasm_std::{Addr, Uint128}; +use schemars::JsonSchema; use secret_cw2::ContractVersion; use secret_utils::Expiration; +use serde::{Deserialize, Serialize}; -use crate::state::{Config, ProposalModule,VotingModuleInfo}; +use crate::state::{Config, ProposalModule, VotingModuleInfo}; /// Relevant state for the governance module. Returned by the /// `DumpState` query. @@ -38,7 +38,6 @@ pub enum PauseInfoResponse { Unpaused {}, } - /// Returned by the `GetItem` query. #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] @@ -84,8 +83,8 @@ pub struct DaoURIResponse { } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")]pub struct ProposalModuleCountResponse { - +#[serde(rename_all = "snake_case")] +pub struct ProposalModuleCountResponse { /// The number of active proposal modules. pub active_proposal_module_count: u32, /// The total number of proposal modules. diff --git a/packages/dao-interface/src/voting.rs b/packages/dao-interface/src/voting.rs index b9d6bcb..072b5a1 100644 --- a/packages/dao-interface/src/voting.rs +++ b/packages/dao-interface/src/voting.rs @@ -1,8 +1,8 @@ -use cosmwasm_schema:: QueryResponses; +use cosmwasm_schema::QueryResponses; use cosmwasm_std::Uint128; +use schemars::JsonSchema; use secret_cw2::ContractVersion; use serde::{Deserialize, Serialize}; -use schemars::JsonSchema; #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] @@ -18,7 +18,7 @@ pub enum Query { #[returns(VotingPowerAtHeightResponse)] VotingPowerAtHeight { address: ::std::string::String, - key : ::std::string::String, + key: ::std::string::String, height: ::std::option::Option<::std::primitive::u64>, }, /// Returns the total voting power at a given block heigh. @@ -64,13 +64,13 @@ pub struct InfoResponse { } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")]pub struct IsActiveResponse { - +#[serde(rename_all = "snake_case")] +pub struct IsActiveResponse { pub active: bool, } #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] -#[serde(rename_all = "snake_case")]pub struct DenomResponse { - +#[serde(rename_all = "snake_case")] +pub struct DenomResponse { pub denom: String, } diff --git a/packages/dao-pre-propose-base/src/error.rs b/packages/dao-pre-propose-base/src/error.rs index 31cf7a0..46a0e9a 100644 --- a/packages/dao-pre-propose-base/src/error.rs +++ b/packages/dao-pre-propose-base/src/error.rs @@ -1,5 +1,5 @@ -use cw_denom::DenomError; use cosmwasm_std::StdError; +use cw_denom::DenomError; use secret_utils::ParseReplyError; use thiserror::Error; diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index bc124ec..1ff9b44 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -7,8 +7,8 @@ use cw_hooks::HookItem; use secret_cw2::set_contract_version; use cw_denom::UncheckedDenom; -use dao_interface::voting::{Query as CwCoreQuery, VotingPowerAtHeightResponse}; use dao_interface::state::AnyContractInfo; +use dao_interface::voting::{Query as CwCoreQuery, VotingPowerAtHeightResponse}; use dao_voting::{ deposit::{DepositRefundPolicy, UncheckedDepositInfo}, status::Status, @@ -43,7 +43,13 @@ where // making limited assumptions here. The only way to associate // a deposit module with a proposal module is for the proposal // module to instantiate it. - self.proposal_module.save(deps.storage, &AnyContractInfo { addr: info.sender.clone(), code_hash: msg.proposal_module_code_hash.clone() })?; + self.proposal_module.save( + deps.storage, + &AnyContractInfo { + addr: info.sender.clone(), + code_hash: msg.proposal_module_code_hash.clone(), + }, + )?; // Query the proposal module for its DAO. let dao_info: AnyContractInfo = deps.querier.query_wasm_smart( @@ -57,7 +63,11 @@ where let deposit_info = msg .deposit_info .map(|info| { - info.into_checked(deps.as_ref(), dao_info.addr.clone(), dao_info.code_hash.clone()) + info.into_checked( + deps.as_ref(), + dao_info.addr.clone(), + dao_info.code_hash.clone(), + ) }) .transpose()?; @@ -87,7 +97,7 @@ where msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::Propose {key, msg } => self.execute_propose(deps, env, info,key, msg), + ExecuteMsg::Propose { key, msg } => self.execute_propose(deps, env, info, key, msg), ExecuteMsg::UpdateConfig { deposit_info, open_proposal_submission, @@ -97,11 +107,11 @@ where ExecuteMsg::Withdraw { denom, key } => { self.execute_withdraw(deps.as_ref(), env, info, denom, key) } - ExecuteMsg::AddProposalSubmittedHook { address,code_hash } => { - self.execute_add_proposal_submitted_hook(deps, info, address,code_hash) + ExecuteMsg::AddProposalSubmittedHook { address, code_hash } => { + self.execute_add_proposal_submitted_hook(deps, info, address, code_hash) } - ExecuteMsg::RemoveProposalSubmittedHook { address,code_hash } => { - self.execute_remove_proposal_submitted_hook(deps, info, address,code_hash) + ExecuteMsg::RemoveProposalSubmittedHook { address, code_hash } => { + self.execute_remove_proposal_submitted_hook(deps, info, address, code_hash) } ExecuteMsg::ProposalCompletedHook { proposal_id, @@ -126,20 +136,13 @@ where key: String, msg: ProposalMessage, ) -> Result { - self.check_can_submit( - deps.as_ref(), - info.sender.clone(), - key, - )?; + self.check_can_submit(deps.as_ref(), info.sender.clone(), key)?; let config = self.config.load(deps.storage)?; let deposit_messages = if let Some(ref deposit_info) = config.deposit_info { deposit_info.check_native_deposit_paid(&info)?; - deposit_info.get_take_deposit_messages( - &info.sender, - &env.contract.address.clone(), - )? + deposit_info.get_take_deposit_messages(&info.sender, &env.contract.address.clone())? } else { vec![] }; @@ -166,17 +169,17 @@ where funds: vec![], }; - let hooks_msgs = self - .proposal_submitted_hooks - .prepare_hooks(deps.storage, |hook_item| { - let execute = WasmMsg::Execute { - contract_addr: hook_item.addr.into_string(), - code_hash: hook_item.code_hash.clone(), - msg: to_binary(&msg)?, - funds: vec![], - }; - Ok(SubMsg::new(execute)) - })?; + let hooks_msgs = + self.proposal_submitted_hooks + .prepare_hooks(deps.storage, |hook_item| { + let execute = WasmMsg::Execute { + contract_addr: hook_item.addr.into_string(), + code_hash: hook_item.code_hash.clone(), + msg: to_binary(&msg)?, + funds: vec![], + }; + Ok(SubMsg::new(execute)) + })?; Ok(Response::default() .add_attribute("method", "execute_propose") @@ -241,18 +244,12 @@ where match denom { None => Err(PreProposeError::NoWithdrawalDenom {}), Some(denom) => { - let balance = denom.query_balance( - &deps.querier, - &env.contract.address, - key, - )?; + let balance = denom.query_balance(&deps.querier, &env.contract.address, key)?; if balance.is_zero() { Err(PreProposeError::NothingToWithdraw {}) } else { - let withdraw_message = denom.get_transfer_to_message( - &dao.addr.clone(), - balance, - )?; + let withdraw_message = + denom.get_transfer_to_message(&dao.addr.clone(), balance)?; Ok(Response::default() .add_message(withdraw_message) .add_attribute("method", "withdraw") @@ -269,7 +266,7 @@ where deps: DepsMut, info: MessageInfo, address: String, - code_hash: String + code_hash: String, ) -> Result { let dao = self.dao.load(deps.storage)?; if info.sender != dao.addr.clone() { @@ -277,10 +274,8 @@ where } let addr = deps.api.addr_validate(&address)?; - self.proposal_submitted_hooks.add_hook(deps.storage, HookItem{ - addr, - code_hash, - })?; + self.proposal_submitted_hooks + .add_hook(deps.storage, HookItem { addr, code_hash })?; Ok(Response::default()) } @@ -290,7 +285,7 @@ where deps: DepsMut, info: MessageInfo, address: String, - code_hash: String + code_hash: String, ) -> Result { let dao = self.dao.load(deps.storage)?; if info.sender != dao.addr.clone() { @@ -302,10 +297,7 @@ where // Remove the hook self.proposal_submitted_hooks - .remove_hook(deps.storage, HookItem{ - addr, - code_hash, - })?; + .remove_hook(deps.storage, HookItem { addr, code_hash })?; Ok(Response::default()) } @@ -352,13 +344,11 @@ where }; if should_refund_to_proposer { - deposit_info - .get_return_deposit_message(&proposer)? + deposit_info.get_return_deposit_message(&proposer)? } else { // If the proposer doesn't get the deposit, the DAO does. let dao = self.dao.load(deps.storage)?; - deposit_info - .get_return_deposit_message(&dao.addr.clone())? + deposit_info.get_return_deposit_message(&dao.addr.clone())? } } else { // No deposit info for this proposal. Nothing to do. @@ -386,7 +376,7 @@ where &self, deps: Deps, who: Addr, - key: String + key: String, ) -> Result<(), PreProposeError> { let config = self.config.load(deps.storage)?; diff --git a/packages/dao-pre-propose-base/src/msg.rs b/packages/dao-pre-propose-base/src/msg.rs index 6224fab..9285b4b 100644 --- a/packages/dao-pre-propose-base/src/msg.rs +++ b/packages/dao-pre-propose-base/src/msg.rs @@ -26,9 +26,7 @@ pub struct InstantiateMsg { pub enum ExecuteMsg { /// Creates a new proposal in the pre-propose module. MSG will be /// serialized and used as the proposal creation message. - Propose { key: String, - msg: ProposalMessage - }, + Propose { key: String, msg: ProposalMessage }, /// Updates the configuration of this module. This will completely /// override the existing configuration. This new configuration @@ -78,10 +76,10 @@ pub enum ExecuteMsg { /// Adds a proposal submitted hook. Fires when a new proposal is submitted /// to the pre-propose contract. Only the DAO may call this method. - AddProposalSubmittedHook { address: String,code_hash: String }, + AddProposalSubmittedHook { address: String, code_hash: String }, /// Removes a proposal submitted hook. Only the DAO may call this method. - RemoveProposalSubmittedHook { address: String ,code_hash: String}, + RemoveProposalSubmittedHook { address: String, code_hash: String }, /// Handles proposal hook fired by the associated proposal /// module when a proposal is completed (ie executed or rejected). diff --git a/packages/dao-snip721-extensions/src/roles.rs b/packages/dao-snip721-extensions/src/roles.rs index 5d799ed..a12feda 100644 --- a/packages/dao-snip721-extensions/src/roles.rs +++ b/packages/dao-snip721-extensions/src/roles.rs @@ -14,9 +14,9 @@ pub struct MetadataExt { pub enum ExecuteExt { /// Add a new hook to be informed of all membership changes. /// Must be called by Admin - AddHook { addr: String ,code_hash: String}, + AddHook { addr: String, code_hash: String }, /// Remove a hook. Must be called by Admin - RemoveHook { addr: String,code_hash: String }, + RemoveHook { addr: String, code_hash: String }, /// Update the token_uri for a particular NFT. Must be called by minter / admin UpdateTokenUri { token_id: String, @@ -72,7 +72,6 @@ pub enum QueryExt { permit: Permit, query: QueryWithPermit, }, - } impl QueryExt { @@ -101,9 +100,10 @@ pub struct ViewingKeyError { #[derive(QueryResponses)] pub enum QueryWithPermit { #[returns(dao_interface::voting::VotingPowerAtHeightResponse)] - Member { addr: String, - at_height: Option,}, + Member { + addr: String, + at_height: Option, + }, } - impl CustomMsg for QueryExt {} diff --git a/packages/dao-voting/src/deposit.rs b/packages/dao-voting/src/deposit.rs index 90045b1..f1d8dbe 100644 --- a/packages/dao-voting/src/deposit.rs +++ b/packages/dao-voting/src/deposit.rs @@ -70,7 +70,6 @@ pub struct UncheckedDepositInfo { pub refund_policy: DepositRefundPolicy, } - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] pub enum DepositRefundPolicy { @@ -157,7 +156,8 @@ impl UncheckedDepositInfo { // returned a valid token. Conversion of the unchecked // denom into a checked one will do a `TokenInfo {}` // query. - UncheckedDenom::Cw20(token.addr.into_string(),token.code_hash).into_checked(deps) + UncheckedDenom::Cw20(token.addr.into_string(), token.code_hash) + .into_checked(deps) } } } @@ -205,7 +205,7 @@ impl CheckedDepositInfo { ) -> StdResult> { let take_deposit_msg: Vec = if let Self { amount, - denom: CheckedDenom::Cw20(address,token_code_hash), + denom: CheckedDenom::Cw20(address, token_code_hash), .. } = self { @@ -224,7 +224,7 @@ impl CheckedDepositInfo { memo: None, padding: None, })?, - code_hash:token_code_hash.clone(), + code_hash: token_code_hash.clone(), } .into()] } @@ -236,17 +236,12 @@ impl CheckedDepositInfo { Ok(take_deposit_msg) } - pub fn get_return_deposit_message( - &self, - depositor: &Addr, - ) -> StdResult> { + pub fn get_return_deposit_message(&self, depositor: &Addr) -> StdResult> { // Should get caught in `into_checked()`, but to be pedantic. if self.amount.is_zero() { return Ok(vec![]); } - let message = self - .denom - .get_transfer_to_message(depositor, self.amount)?; + let message = self.denom.get_transfer_to_message(depositor, self.amount)?; Ok(vec![message]) } } diff --git a/packages/dao-voting/src/pre_propose.rs b/packages/dao-voting/src/pre_propose.rs index 7c3d382..47be852 100644 --- a/packages/dao-voting/src/pre_propose.rs +++ b/packages/dao-voting/src/pre_propose.rs @@ -1,14 +1,12 @@ //! Types related to the pre-propose module. Motivation: //! . - -use dao_interface::state::ModuleInstantiateInfo; use cosmwasm_std::{Addr, Empty, StdResult, Storage, SubMsg}; +use dao_interface::state::ModuleInstantiateInfo; use schemars::JsonSchema; use secret_cw_controllers::{ReplyEvent, ReplyIds}; use serde::{Deserialize, Serialize}; - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] pub enum PreProposeInfo { @@ -19,7 +17,6 @@ pub enum PreProposeInfo { ModuleMayPropose { info: ModuleInstantiateInfo }, } - #[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)] #[serde(rename_all = "snake_case")] pub enum ProposalCreationPolicy { @@ -28,7 +25,7 @@ pub enum ProposalCreationPolicy { /// Only ADDR may create proposals. It is expected that ADDR is a /// pre-propose module, though we only require that it is a valid /// address. - Module { addr: Addr, code_hash:String }, + Module { addr: Addr, code_hash: String }, } impl ProposalCreationPolicy { @@ -37,7 +34,7 @@ impl ProposalCreationPolicy { pub fn is_permitted(&self, creator: &Addr) -> bool { match self { Self::Anyone {} => true, - Self::Module { addr,code_hash:_ } => creator == addr, + Self::Module { addr, code_hash: _ } => creator == addr, } } } @@ -47,23 +44,28 @@ impl PreProposeInfo { self, store: &mut dyn Storage, dao: Addr, - reply_id : ReplyIds, + reply_id: ReplyIds, ) -> StdResult<(ProposalCreationPolicy, Vec>)> { Ok(match self { Self::AnyoneMayPropose {} => (ProposalCreationPolicy::Anyone {}, vec![]), Self::ModuleMayPropose { info } => { - let reply_id = reply_id.add_event(store,ReplyEvent::PreProposalModuleInstantiate { code_hash: info.clone().code_hash }); + let reply_id = reply_id.add_event( + store, + ReplyEvent::PreProposalModuleInstantiate { + code_hash: info.clone().code_hash, + }, + ); ( - // Anyone can propose will be set until instantiation succeeds, then - // `ModuleMayPropose` will be set. This ensures that we fail open - // upon instantiation failure. - ProposalCreationPolicy::Anyone {}, - vec![SubMsg::reply_on_success( - info.to_cosmos_msg(dao), - reply_id.unwrap(), - )], - ) - }, + // Anyone can propose will be set until instantiation succeeds, then + // `ModuleMayPropose` will be set. This ensures that we fail open + // upon instantiation failure. + ProposalCreationPolicy::Anyone {}, + vec![SubMsg::reply_on_success( + info.to_cosmos_msg(dao), + reply_id.unwrap(), + )], + ) + } }) } } diff --git a/packages/dao-voting/src/threshold.rs b/packages/dao-voting/src/threshold.rs index a9790ad..3a8e93a 100644 --- a/packages/dao-voting/src/threshold.rs +++ b/packages/dao-voting/src/threshold.rs @@ -1,7 +1,6 @@ use cosmwasm_std::{Decimal, Uint128}; -use serde::{Serialize,Deserialize}; use schemars::JsonSchema; - +use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/packages/dao-voting/src/voting.rs b/packages/dao-voting/src/voting.rs index e81b10e..6bb40bf 100644 --- a/packages/dao-voting/src/voting.rs +++ b/packages/dao-voting/src/voting.rs @@ -1,5 +1,5 @@ -use dao_interface::voting; use cosmwasm_std::{Addr, Decimal, Deps, StdResult, Uint128, Uint256}; +use dao_interface::voting; use schemars::JsonSchema; use secret_utils::Duration; use serde::{Deserialize, Serialize}; diff --git a/packages/snip721-controllers/Cargo.toml b/packages/snip721-controllers/Cargo.toml index 460abce..8684595 100644 --- a/packages/snip721-controllers/Cargo.toml +++ b/packages/snip721-controllers/Cargo.toml @@ -11,5 +11,5 @@ version = { workspace = true } cosmwasm-std = { workspace = true } cosmwasm-schema = { workspace = true } secret-utils = { workspace = true } -secret-storage-plus = { workspace = true } +secret-toolkit = { workspace = true } thiserror = { workspace = true } diff --git a/packages/snip721-controllers/src/nft_claim.rs b/packages/snip721-controllers/src/nft_claim.rs index 3c5122f..ceaa743 100644 --- a/packages/snip721-controllers/src/nft_claim.rs +++ b/packages/snip721-controllers/src/nft_claim.rs @@ -1,6 +1,7 @@ + use cosmwasm_schema::cw_serde; -use cosmwasm_std::{Addr, BlockInfo, CustomQuery, Deps, StdResult, Storage}; -use secret_storage_plus::Map; +use cosmwasm_std::{Addr, BlockInfo, CustomQuery, Deps, StdError, StdResult, Storage}; +use secret_toolkit::storage::Keymap; use secret_utils::Expiration; #[cw_serde] @@ -9,6 +10,7 @@ pub struct NftClaimsResponse { } #[cw_serde] +#[derive(Default)] pub struct NftClaim { pub token_id: String, pub release_at: Expiration, @@ -23,11 +25,11 @@ impl NftClaim { } } -pub struct NftClaims<'a>(Map<'a, &'a Addr, Vec>); +pub struct NftClaims<'a>(Keymap<'a, Addr, Vec>); impl<'a> NftClaims<'a> { - pub const fn new(storage_key: &'a str) -> Self { - NftClaims(Map::new(storage_key)) + pub const fn new(storage_key: &'a [u8]) -> Self { + NftClaims(Keymap::new(storage_key)) } /// Creates a number of NFT claims simeltaniously for a given @@ -46,17 +48,44 @@ impl<'a> NftClaims<'a> { token_ids: Vec, release_at: Expiration, ) -> StdResult<()> { - self.0.update(storage, addr, |old| -> StdResult<_> { - Ok(old - .unwrap_or_default() - .into_iter() - .chain(token_ids.into_iter().map(|token_id| NftClaim { - token_id, - release_at, - })) - .collect::>()) - })?; + // self.0.update(storage, addr, |old| -> StdResult<_> { + // Ok(old + // .unwrap_or_default() + // .into_iter() + // .chain(token_ids.into_iter().map(|token_id| NftClaim { + // token_id, + // release_at, + // })) + // .collect::>()) + // })?; + // Ok(()) + + let new_claims: Vec = { + let mut old_claims = self.0.get(storage, addr).unwrap_or_default(); + // Check for deduplication and if the token_ids are already in claims + let mut seen = std::collections::HashSet::new(); + for token_id in &token_ids { + if !seen.insert(token_id) { + return Err(StdError::generic_err("Duplicate token IDs are not allowed")); + } + if old_claims.iter().any(|c| c.token_id == *token_id) { + return Err(StdError::generic_err("Token ID is already in claims queue")); + } + } + // Create new NFT claims + old_claims.extend(token_ids.into_iter().map(|token_id| NftClaim { + token_id, + release_at, + })); + old_claims + }; + + // Insert the updated claims back into the storage + self.0.insert(storage, addr, &new_claims)?; + Ok(()) + + } /// This iterates over all mature claims for the address, and removes them, up to an optional cap. @@ -67,21 +96,49 @@ impl<'a> NftClaims<'a> { addr: &Addr, block: &BlockInfo, ) -> StdResult> { + // let mut to_send = vec![]; + // self.0.update(storage, addr, |nft_claims| -> StdResult<_> { + // let (_send, waiting): (Vec<_>, _) = + // nft_claims.unwrap_or_default().into_iter().partition(|c| { + // // if mature and we can pay fully, then include in _send + // if c.release_at.is_expired(block) { + // to_send.push(c.token_id.clone()); + // true + // } else { + // // not to send, leave in waiting and save again + // false + // } + // }); + // Ok(waiting) + // })?; + // Ok(to_send) + let mut to_send = vec![]; - self.0.update(storage, addr, |nft_claims| -> StdResult<_> { - let (_send, waiting): (Vec<_>, _) = - nft_claims.unwrap_or_default().into_iter().partition(|c| { + + // Retrieve the current value associated with the address key + let mut nft_claims = self.0.get(storage, addr); + + // Update the value if it exists, or initialize it to default otherwise + let _ = match nft_claims.take() { + Some(claims) => { + let (send, waiting): (Vec<_>, _) = claims.into_iter().partition(|c| { // if mature and we can pay fully, then include in _send if c.release_at.is_expired(block) { to_send.push(c.token_id.clone()); true } else { - // not to send, leave in waiting and save again + // not to send, leave in waiting false } }); - Ok(waiting) - })?; + // Save the updated value + self.0.insert(storage, addr, &waiting)?; + send + } + None => vec![], // No claims found for the address + }; + + // Return the tokens to be sent Ok(to_send) } @@ -90,7 +147,7 @@ impl<'a> NftClaims<'a> { deps: Deps, address: &Addr, ) -> StdResult { - let nft_claims = self.0.may_load(deps.storage, address)?.unwrap_or_default(); + let nft_claims = self.0.get(deps.storage, address).unwrap_or_default(); Ok(NftClaimsResponse { nft_claims }) } } diff --git a/packages/storage-plus/benches/main.rs b/packages/storage-plus/benches/main.rs index 3e40cd6..c79348f 100644 --- a/packages/storage-plus/benches/main.rs +++ b/packages/storage-plus/benches/main.rs @@ -6,7 +6,7 @@ use rand::Rng; use std::mem; use std::time::Duration; -use secret_storage_plus::{CwIntKey}; +use secret_storage_plus::CwIntKey; fn bench_signed_int_key(c: &mut Criterion) { let mut group = c.benchmark_group("Signed int keys"); diff --git a/packages/storage-plus/src/helpers.rs b/packages/storage-plus/src/helpers.rs index d321cd0..708757b 100644 --- a/packages/storage-plus/src/helpers.rs +++ b/packages/storage-plus/src/helpers.rs @@ -10,8 +10,8 @@ use std::any::type_name; use crate::{keys::Key, Serde}; use cosmwasm_std::{ - to_vec, Addr, Binary, ContractResult, CustomQuery, QuerierWrapper, QueryRequest, - StdError, StdResult, SystemResult, WasmQuery, + to_vec, Addr, Binary, ContractResult, CustomQuery, QuerierWrapper, QueryRequest, StdError, + StdResult, SystemResult, WasmQuery, }; /// may_deserialize parses json bytes from storage (Option), returning Ok(None) if no data present @@ -28,7 +28,9 @@ pub(crate) fn may_deserialize( } /// must_deserialize parses json bytes from storage (Option), returning NotFound error if no data present -pub(crate) fn must_deserialize(value: &Option>) -> StdResult { +pub(crate) fn must_deserialize( + value: &Option>, +) -> StdResult { match value { Some(vec) => Ok(Ser::deserialize(vec)?), None => Err(StdError::not_found(type_name::())), diff --git a/packages/storage-plus/src/item.rs b/packages/storage-plus/src/item.rs index 4af9bee..45f285f 100644 --- a/packages/storage-plus/src/item.rs +++ b/packages/storage-plus/src/item.rs @@ -2,17 +2,19 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::marker::PhantomData; -use cosmwasm_std::{ - Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage, WasmQuery, -}; +use cosmwasm_std::{Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage, WasmQuery}; -use crate::{helpers::{may_deserialize, must_deserialize}, Serde, Json}; +use crate::{ + helpers::{may_deserialize, must_deserialize}, + Json, Serde, +}; /// Item stores one typed item at the given key. /// This is an analog of Singleton. /// It functions the same way as Path does but doesn't use a Vec and thus has a const fn constructor. pub struct Item<'a, T, Ser = Json> - where Ser: Serde, +where + Ser: Serde, { // this is full key - no need to length-prefix it, we only store one item storage_key: &'a [u8], @@ -107,10 +109,7 @@ mod test { use crate::Bincode2; use super::*; - use cosmwasm_std::{ - to_vec, - testing::MockStorage - }; + use cosmwasm_std::{testing::MockStorage, to_vec}; use rstest::*; use rstest_reuse::{self, *}; use serde::{Deserialize, Serialize}; @@ -131,12 +130,10 @@ mod test { #[rstest] #[case(CONFIG)] #[case(B_CONFIG)] - fn serialization(#[case] config: Item) { } + fn serialization(#[case] config: Item) {} #[apply(serialization)] - fn save_and_load( - #[case] config: Item, - ) { + fn save_and_load(#[case] config: Item) { let mut store = MockStorage::new(); assert!(config.load(&store).is_err()); @@ -152,9 +149,7 @@ mod test { } #[apply(serialization)] - fn remove_works( - #[case] config: Item, - ) { + fn remove_works(#[case] config: Item) { let mut store = MockStorage::new(); // store data @@ -210,9 +205,7 @@ mod test { } #[apply(serialization)] - fn update_success( - #[case] config: Item, - ) { + fn update_success(#[case] config: Item) { let mut store = MockStorage::new(); let cfg = Config { @@ -234,9 +227,7 @@ mod test { } #[apply(serialization)] - fn update_can_change_variable_from_outer_scope( - #[case] config: Item, - ) { + fn update_can_change_variable_from_outer_scope(#[case] config: Item) { let mut store = MockStorage::new(); let cfg = Config { owner: "admin".to_string(), @@ -256,9 +247,7 @@ mod test { } #[apply(serialization)] - fn update_does_not_change_data_on_error( - #[case] config: Item, - ) { + fn update_does_not_change_data_on_error(#[case] config: Item) { let mut store = MockStorage::new(); let cfg = Config { @@ -282,9 +271,7 @@ mod test { } #[apply(serialization)] - fn update_supports_custom_errors( - #[case] config: Item - ) { + fn update_supports_custom_errors(#[case] config: Item) { #[derive(Debug)] enum MyError { Std(StdError), @@ -326,9 +313,7 @@ mod test { } #[apply(serialization)] - fn readme_works( - #[case] config: Item - ) -> StdResult<()> { + fn readme_works(#[case] config: Item) -> StdResult<()> { let mut store = MockStorage::new(); // may_load returns Option, so None if data is missing diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index 78375fe..ebf9aa1 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -2,7 +2,6 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::marker::PhantomData; -use crate::{Serde, Json}; #[cfg(feature = "iterator")] use crate::bound::{Bound, PrefixBound}; #[cfg(feature = "iterator")] @@ -16,6 +15,7 @@ use crate::keys::{Key, PrimaryKey}; use crate::path::Path; #[cfg(feature = "iterator")] use crate::prefix::{namespaced_prefix_range, Prefix}; +use crate::{Json, Serde}; use cosmwasm_std::{from_slice, Addr, CustomQuery, QuerierWrapper, StdError, StdResult, Storage}; #[derive(Debug, Clone)] @@ -28,7 +28,8 @@ pub struct Map<'a, K, T, Ser = Json> { } impl<'a, K, T, Ser> Map<'a, K, T, Ser> - where Ser: Serde, +where + Ser: Serde, { pub const fn new(namespace: &'a str) -> Self { Map { @@ -282,9 +283,9 @@ mod test { #[cfg(feature = "iterator")] use crate::bound::Bounder; - use crate::{int_key::CwIntKey, Bincode2}; #[cfg(feature = "iterator")] use crate::IntKeyOld; + use crate::{int_key::CwIntKey, Bincode2}; #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] struct Data { @@ -308,9 +309,9 @@ mod test { const TRIPLE: Map<(&[u8], u8, &str), u64> = Map::new("triple"); const B_TRIPLE: Map<(&[u8], u8, &str), u64, Bincode2> = Map::new("triple"); - type Key<'a> = &'a[u8]; - type AKey<'a> = (&'a[u8], &'a[u8]); - type TKey<'a> = (&'a[u8], u8, &'a str); + type Key<'a> = &'a [u8]; + type AKey<'a> = (&'a [u8], &'a [u8]); + type TKey<'a> = (&'a [u8], u8, &'a str); #[template] #[rstest] @@ -320,7 +321,8 @@ mod test { #[case] people: Map, #[case] allowance: Map, #[case] triple: Map, - ) {} + ) { + } #[apply(serialization_3)] fn create_path( @@ -360,7 +362,7 @@ mod test { } #[rstest] - fn save_and_load(#[values(PEOPLE, B_PEOPLE)] people: Map ) { + fn save_and_load(#[values(PEOPLE, B_PEOPLE)] people: Map) { let mut store = MockStorage::new(); // save and load on one key @@ -1161,7 +1163,9 @@ mod test { } #[rstest] - fn readme_works(#[values(PEOPLE, B_PEOPLE)] people: Map) -> StdResult<()> { + fn readme_works( + #[values(PEOPLE, B_PEOPLE)] people: Map, + ) -> StdResult<()> { let mut store = MockStorage::new(); let data = Data { name: "John".to_string(), @@ -1214,7 +1218,9 @@ mod test { } #[rstest] - fn readme_works_composite_keys(#[values(ALLOWANCE, B_ALLOWANCE)] allowance: Map) -> StdResult<()> { + fn readme_works_composite_keys( + #[values(ALLOWANCE, B_ALLOWANCE)] allowance: Map, + ) -> StdResult<()> { let mut store = MockStorage::new(); // save and load on a composite key @@ -1239,9 +1245,10 @@ mod test { } #[rstest] - fn readme_works_with_path(#[values(PEOPLE, B_PEOPLE)] people: Map, - #[values(ALLOWANCE, B_ALLOWANCE)] allowance: Map -) -> StdResult<()> { + fn readme_works_with_path( + #[values(PEOPLE, B_PEOPLE)] people: Map, + #[values(ALLOWANCE, B_ALLOWANCE)] allowance: Map, + ) -> StdResult<()> { let mut store = MockStorage::new(); let data = Data { name: "John".to_string(), diff --git a/packages/storage-plus/src/path.rs b/packages/storage-plus/src/path.rs index 0db6780..dcdbc13 100644 --- a/packages/storage-plus/src/path.rs +++ b/packages/storage-plus/src/path.rs @@ -2,9 +2,9 @@ use serde::de::DeserializeOwned; use serde::Serialize; use std::marker::PhantomData; -use crate::{Json, Serde}; use crate::helpers::{may_deserialize, must_deserialize, nested_namespaces_with_key}; use crate::keys::Key; +use crate::{Json, Serde}; use cosmwasm_std::{StdError, StdResult, Storage}; use std::ops::Deref; @@ -24,7 +24,7 @@ where impl Deref for Path where T: Serialize + DeserializeOwned, - Ser: Serde + Ser: Serde, { type Target = [u8]; diff --git a/packages/storage-plus/src/serialization/bincode2.rs b/packages/storage-plus/src/serialization/bincode2.rs index bda5365..e9d292f 100644 --- a/packages/storage-plus/src/serialization/bincode2.rs +++ b/packages/storage-plus/src/serialization/bincode2.rs @@ -1,7 +1,7 @@ -use std::any::type_name; -use serde::{de::DeserializeOwned, Serialize}; -use cosmwasm_std::{StdError, StdResult}; use crate::Serde; +use cosmwasm_std::{StdError, StdResult}; +use serde::{de::DeserializeOwned, Serialize}; +use std::any::type_name; /// Use bincode2 for serialization. #[derive(Copy, Clone, Debug)] diff --git a/packages/storage-plus/src/traits.rs b/packages/storage-plus/src/traits.rs index f120126..3e6539a 100644 --- a/packages/storage-plus/src/traits.rs +++ b/packages/storage-plus/src/traits.rs @@ -1,6 +1,6 @@ +use crate::{Item, Json, Map, PrimaryKey, Serde}; use cosmwasm_std::{StdError, StdResult, Storage}; use serde::{de::DeserializeOwned, Serialize}; -use crate::{Item, Json, Map, PrimaryKey, Serde}; pub trait NaiveItemStorage: Serialize + DeserializeOwned where