├── ci ├── integration-tests │ ├── src │ │ ├── helpers │ │ │ └── mod.rs │ │ ├── lib.rs │ │ └── tests │ │ │ └── mod.rs │ └── .cargo │ │ └── config.toml ├── configs │ ├── cosm-orc │ │ ├── ci.yaml │ │ └── testnet.yaml │ └── test_accounts.json └── bootstrap-env │ └── Cargo.toml ├── contracts ├── voting │ ├── dao-voting-token-staked │ │ ├── src │ │ │ ├── tests │ │ │ │ ├── multitest │ │ │ │ │ └── mod.rs │ │ │ │ ├── test_tube │ │ │ │ │ └── mod.rs │ │ │ │ └── mod.rs │ │ │ └── lib.rs │ │ └── examples │ │ │ └── schema.rs │ ├── dao-voting-cw4 │ │ ├── src │ │ │ ├── state.rs │ │ │ ├── lib.rs │ │ │ ├── msg.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── Cargo.toml │ │ └── README.md │ ├── dao-voting-cw20-staked │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ ├── dao-voting-cw721-roles │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ ├── error.rs │ │ │ └── testing │ │ │ │ ├── instantiate.rs │ │ │ │ ├── execute.rs │ │ │ │ └── mod.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml │ ├── dao-voting-cw721-staked │ │ ├── src │ │ │ ├── lib.rs │ │ │ └── testing │ │ │ │ └── instantiate.rs │ │ └── examples │ │ │ └── schema.rs │ └── dao-voting-onft-staked │ │ ├── src │ │ ├── lib.rs │ │ ├── omniflix.rs │ │ └── error.rs │ │ └── examples │ │ └── schema.rs ├── external │ ├── cw-filter │ │ ├── src │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ ├── state.rs │ │ │ ├── lib.rs │ │ │ ├── error.rs │ │ │ └── decoder.rs │ │ ├── README.md │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ ├── cw-protobuf-registry │ │ ├── src │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── state.rs │ │ ├── proto │ │ │ ├── regen_ecocredit.pb │ │ │ └── string_bool_value.pb │ │ ├── README.md │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ ├── dao-migrator │ │ ├── src │ │ │ ├── utils │ │ │ │ └── mod.rs │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── msg.rs │ │ ├── examples │ │ │ └── schema.rs │ │ └── README.md │ ├── dao-rbam │ │ ├── src │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ └── lib.rs │ │ ├── proto │ │ │ ├── regen_ecocredit.pb │ │ │ └── string_bool_value.pb │ │ └── examples │ │ │ └── schema.rs │ ├── cw-tokenfactory-issuer │ │ ├── tests │ │ │ ├── mod.rs │ │ │ └── cases │ │ │ │ ├── mod.rs │ │ │ │ └── tokenfactory_admin.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── NOTICE │ │ └── src │ │ │ ├── lib.rs │ │ │ ├── hooks.rs │ │ │ └── state.rs │ ├── cw-vesting │ │ ├── src │ │ │ ├── state.rs │ │ │ ├── suite_tests │ │ │ │ └── mod.rs │ │ │ └── lib.rs │ │ └── examples │ │ │ └── schema.rs │ ├── cw-token-swap │ │ ├── src │ │ │ ├── lib.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml │ ├── cw721-roles │ │ ├── src │ │ │ ├── msg.rs │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ ├── btsg-ft-factory │ │ ├── src │ │ │ ├── error.rs │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ ├── msg.rs │ │ │ └── testing │ │ │ │ └── mod.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml │ ├── cw-payroll-factory │ │ ├── examples │ │ │ └── schema.rs │ │ ├── src │ │ │ ├── lib.rs │ │ │ └── error.rs │ │ ├── README.md │ │ └── Cargo.toml │ └── cw-admin-factory │ │ ├── examples │ │ └── schema.rs │ │ ├── src │ │ ├── state.rs │ │ ├── lib.rs │ │ ├── error.rs │ │ └── msg.rs │ │ └── README.md ├── delegation │ └── dao-vote-delegation │ │ ├── src │ │ ├── testing │ │ │ ├── mod.rs │ │ │ └── suite │ │ │ │ └── mod.rs │ │ └── lib.rs │ │ └── examples │ │ └── schema.rs ├── distribution │ ├── dao-rewards-distributor │ │ ├── src │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ └── lib.rs │ │ └── examples │ │ │ └── schema.rs │ └── cw-fund-distributor │ │ ├── src │ │ ├── lib.rs │ │ ├── testing │ │ │ └── mod.rs │ │ ├── error.rs │ │ └── state.rs │ │ ├── examples │ │ └── schema.rs │ │ ├── Cargo.toml │ │ └── README.md ├── pre-propose │ ├── dao-pre-propose-approver │ │ ├── src │ │ │ ├── tests │ │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── state.rs │ │ └── examples │ │ │ └── schema.rs │ ├── dao-pre-propose-single │ │ ├── examples │ │ │ └── schema.rs │ │ └── src │ │ │ └── lib.rs │ ├── dao-pre-propose-multiple │ │ ├── examples │ │ │ └── schema.rs │ │ └── src │ │ │ └── lib.rs │ ├── dao-pre-propose-approval-single │ │ ├── examples │ │ │ └── schema.rs │ │ └── src │ │ │ ├── lib.rs │ │ │ └── state.rs │ └── dao-pre-propose-approval-multiple │ │ ├── examples │ │ └── schema.rs │ │ └── src │ │ ├── lib.rs │ │ └── state.rs ├── test │ ├── dao-test-custom-factory │ │ ├── src │ │ │ ├── lib.rs │ │ │ └── error.rs │ │ ├── README │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ ├── dao-proposal-sudo │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ ├── error.rs │ │ │ └── msg.rs │ │ ├── README │ │ ├── schema │ │ │ ├── instantiate_msg.json │ │ │ ├── query_msg.json │ │ │ ├── dao_response.json │ │ │ ├── admin_response.json │ │ │ └── info_response.json │ │ ├── .gitignore │ │ ├── Cargo.toml │ │ └── examples │ │ │ └── schema.rs │ ├── dao-voting-cw20-balance │ │ ├── README.md │ │ ├── schema │ │ │ ├── execute_msg.json │ │ │ ├── total_power_at_height_response.json │ │ │ ├── voting_power_at_height_response.json │ │ │ └── info_response.json │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ ├── error.rs │ │ │ └── msg.rs │ │ ├── .gitignore │ │ ├── examples │ │ │ └── schema.rs │ │ └── Cargo.toml │ └── dao-proposal-hook-counter │ │ ├── src │ │ ├── lib.rs │ │ ├── error.rs │ │ ├── state.rs │ │ └── msg.rs │ │ ├── README.md │ │ ├── .gitignore │ │ ├── schema │ │ ├── instantiate_msg.json │ │ └── query_msg.json │ │ ├── examples │ │ └── schema.rs │ │ └── Cargo.toml ├── proposal │ ├── dao-proposal-condorcet │ │ ├── gercv.pdf │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ ├── state.rs │ │ │ ├── msg.rs │ │ │ ├── error.rs │ │ │ └── config.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── Cargo.toml │ │ └── README.md │ ├── dao-proposal-multiple │ │ ├── src │ │ │ ├── testing │ │ │ │ └── mod.rs │ │ │ ├── lib.rs │ │ │ └── query.rs │ │ └── examples │ │ │ └── schema.rs │ └── dao-proposal-single │ │ ├── src │ │ ├── testing │ │ │ └── mod.rs │ │ ├── lib.rs │ │ └── query.rs │ │ └── examples │ │ └── schema.rs ├── dao-dao-core │ ├── src │ │ └── lib.rs │ ├── examples │ │ └── schema.rs │ └── Cargo.toml ├── staking │ ├── cw20-stake-external-rewards │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml │ ├── cw20-stake │ │ ├── src │ │ │ ├── lib.rs │ │ │ ├── state.rs │ │ │ └── error.rs │ │ ├── examples │ │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml │ └── cw20-stake-reward-distributor │ │ ├── src │ │ ├── lib.rs │ │ ├── state.rs │ │ ├── error.rs │ │ └── msg.rs │ │ ├── examples │ │ └── schema.rs │ │ ├── README.md │ │ └── Cargo.toml └── README.md ├── packages ├── dao-testing │ ├── src │ │ ├── contracts │ │ │ └── mod.rs │ │ ├── lib.rs │ │ ├── suite │ │ │ └── mod.rs │ │ └── test_tube │ │ │ └── mod.rs │ └── README.md ├── dao-cw721-extensions │ ├── src │ │ └── lib.rs │ ├── README.md │ └── Cargo.toml ├── cw-jsonfilter │ ├── proto │ │ └── string_bool_value.pb │ ├── src │ │ ├── json_ops │ │ │ ├── mod.rs │ │ │ ├── op_existence.rs │ │ │ └── utils.rs │ │ ├── lib.rs │ │ └── decoder.rs │ ├── Cargo.toml │ ├── examples │ │ ├── error_handling.rs │ │ ├── filter.rs │ │ ├── range.rs │ │ ├── array.rs │ │ └── nested_filters.rs │ └── LICENSE-MIT ├── dao-voting │ ├── README.md │ ├── src │ │ ├── lib.rs │ │ ├── error.rs │ │ ├── duration.rs │ │ └── status.rs │ └── Cargo.toml ├── dao-interface │ ├── README.md │ ├── src │ │ ├── lib.rs │ │ ├── nft.rs │ │ ├── proposal.rs │ │ └── helpers.rs │ └── Cargo.toml ├── nft-controllers │ ├── src │ │ └── lib.rs │ ├── README.md │ └── Cargo.toml ├── dao-pre-propose-base │ ├── src │ │ ├── lib.rs │ │ └── helpers.rs │ ├── README.md │ └── Cargo.toml ├── dao-hooks │ ├── src │ │ ├── lib.rs │ │ └── all_hooks.rs │ ├── Cargo.toml │ └── README.md ├── cw-tokenfactory-types │ ├── src │ │ └── lib.rs │ ├── README.md │ └── Cargo.toml ├── cw-hooks │ ├── README.md │ └── Cargo.toml ├── cw-stake-tracker │ ├── Cargo.toml │ └── README.md ├── cw-snapshot-vector-map │ └── Cargo.toml ├── cw-wormhole │ └── Cargo.toml ├── cw-paginate-storage │ ├── Cargo.toml │ └── README.md ├── dao-dao-macros │ ├── README.md │ ├── Cargo.toml │ └── tests │ │ ├── govmod.rs │ │ └── voting.rs └── cw-denom │ ├── Cargo.toml │ └── README.md ├── codecov.yml ├── scripts └── list-exports.mjs ├── .github └── workflows │ ├── audit.yml │ └── codecov.yml ├── .cargo └── config.toml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── LICENSE └── SECURITY.md /ci/integration-tests/src/helpers/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod helper; 2 | 3 | pub mod chain; 4 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-token-staked/src/tests/multitest/mod.rs: -------------------------------------------------------------------------------- 1 | mod tests; 2 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod suite; 2 | pub mod tests; 3 | -------------------------------------------------------------------------------- /contracts/delegation/dao-vote-delegation/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod suite; 2 | pub mod tests; 3 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod suite; 2 | pub mod tests; 3 | -------------------------------------------------------------------------------- /contracts/distribution/dao-rewards-distributor/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod suite; 2 | pub mod tests; 3 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/src/utils/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod query_helpers; 2 | pub mod state_queries; 3 | -------------------------------------------------------------------------------- /contracts/external/dao-rbam/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod regen; 2 | pub mod suite; 3 | pub mod tests; 4 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approver/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod multiple; 2 | pub mod single; 3 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-token-staked/src/tests/test_tube/mod.rs: -------------------------------------------------------------------------------- 1 | mod integration_tests; 2 | mod test_env; 3 | -------------------------------------------------------------------------------- /ci/integration-tests/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | c = "check --tests" 3 | t = "test -- --ignored --test-threads 1" -------------------------------------------------------------------------------- /contracts/external/cw-filter/README.md: -------------------------------------------------------------------------------- 1 | # cw-filter 2 | 3 | Contract that filters messages based on a JSON filter. 4 | -------------------------------------------------------------------------------- /packages/dao-testing/src/contracts/mod.rs: -------------------------------------------------------------------------------- 1 | mod latest; 2 | 3 | pub mod v1; 4 | pub mod v241; 5 | 6 | pub use latest::*; 7 | -------------------------------------------------------------------------------- /contracts/delegation/dao-vote-delegation/src/testing/suite/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod base; 2 | pub mod cw4; 3 | pub mod cw721; 4 | pub mod token; 5 | -------------------------------------------------------------------------------- /packages/dao-cw721-extensions/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod roles; 4 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod helpers; 2 | pub mod setup; 3 | pub mod state_helpers; 4 | pub mod test_migration; 5 | -------------------------------------------------------------------------------- /contracts/test/dao-test-custom-factory/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | mod error; 3 | pub mod msg; 4 | 5 | pub use crate::error::ContractError; 6 | -------------------------------------------------------------------------------- /packages/dao-testing/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm DAO Testing 2 | 3 | This package provides common testing functions and types for testing 4 | DAO modules. 5 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/proto/string_bool_value.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/packages/cw-jsonfilter/proto/string_bool_value.pb -------------------------------------------------------------------------------- /packages/dao-voting/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm DAO Voting 2 | 3 | This package provides types and associated methods for handling voting 4 | in a CosmWasm DAO. 5 | -------------------------------------------------------------------------------- /contracts/external/dao-rbam/proto/regen_ecocredit.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/contracts/external/dao-rbam/proto/regen_ecocredit.pb -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/gercv.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/contracts/proposal/dao-proposal-condorcet/gercv.pdf -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | mod error; 3 | pub mod msg; 4 | pub mod state; 5 | 6 | pub use crate::error::ContractError; 7 | -------------------------------------------------------------------------------- /packages/dao-interface/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm DAO Interface 2 | 3 | This package provides the types and interfaces needed for interacting 4 | with DAO modules. 5 | -------------------------------------------------------------------------------- /contracts/external/dao-rbam/proto/string_bool_value.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/contracts/external/dao-rbam/proto/string_bool_value.pb -------------------------------------------------------------------------------- /ci/integration-tests/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | #[cfg(not(target_arch = "wasm32"))] 4 | mod tests; 5 | 6 | #[cfg(not(target_arch = "wasm32"))] 7 | mod helpers; 8 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/proto/regen_ecocredit.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/contracts/external/cw-protobuf-registry/proto/regen_ecocredit.pb -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/proto/string_bool_value.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DA0-DA0/dao-contracts/HEAD/contracts/external/cw-protobuf-registry/proto/string_bool_value.pb -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-multiple/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod adversarial_tests; 2 | pub mod do_votes; 3 | pub mod execute; 4 | pub mod instantiate; 5 | pub mod queries; 6 | pub mod tests; 7 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/README.md: -------------------------------------------------------------------------------- 1 | # cw balance voting 2 | 3 | A simple voting power module which determines voting power based on 4 | the token balance of specific addresses. 5 | -------------------------------------------------------------------------------- /packages/nft-controllers/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | mod nft_claim; 4 | 5 | pub use nft_claim::{NftClaim, NftClaimError, NftClaims}; 6 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/schema/execute_msg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "ExecuteMsg", 4 | "type": "string", 5 | "enum": [] 6 | } 7 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | pub const ROOT: Item = Item::new("root"); 5 | pub const DAO: Item = Item::new("dao"); 6 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | mod error; 3 | pub mod msg; 4 | pub mod state; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | 9 | pub use crate::error::ContractError; 10 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod contract; 2 | mod error; 3 | pub mod msg; 4 | pub mod state; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | 9 | pub use crate::error::ContractError; 10 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | pub const DAO: Item = Item::new("dao"); 5 | pub const TOKEN: Item = Item::new("token"); 6 | -------------------------------------------------------------------------------- /packages/dao-cw721-extensions/README.md: -------------------------------------------------------------------------------- 1 | # DAO CW721 Extensions: extensions for DAO related NFT contracts 2 | 3 | This implements extensions for cw721 NFT contracts integrating with DAO DAO (for example `cw721-roles`). 4 | -------------------------------------------------------------------------------- /ci/integration-tests/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod cw_core_test; 2 | 3 | pub mod cw20_stake_test; 4 | 5 | pub mod dao_voting_cw721_staked_test; 6 | 7 | pub mod proposal_gas_test; 8 | 9 | pub mod cw_vesting_test; 10 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "ci" 3 | - "packages/dao-dao-macros" 4 | - "packages/dao-testing" 5 | - "test-contracts" 6 | - "**/shim.rs" 7 | - "**/*test*/suite.rs" 8 | - "**/*test*/suite/**/*.rs" 9 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/README.md: -------------------------------------------------------------------------------- 1 | # cw-protobuf-registry 2 | 3 | Protobuf registry that allows registering protobuf files and creating minimal 4 | file descriptor sets needed for decoding protobuf messages. 5 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/tests/mod.rs: -------------------------------------------------------------------------------- 1 | #[cfg(all(feature = "test-tube", feature = "osmosis_tokenfactory"))] 2 | mod cases; 3 | #[cfg(all(feature = "test-tube", feature = "osmosis_tokenfactory"))] 4 | mod test_env; 5 | -------------------------------------------------------------------------------- /scripts/list-exports.mjs: -------------------------------------------------------------------------------- 1 | import fs from 'fs' 2 | 3 | const wasm = fs.readFileSync(process.argv[2]) 4 | const module = await WebAssembly.compile(wasm) 5 | 6 | console.log(WebAssembly.Module.exports(module).map(({name}) => name)) 7 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | /// The address of the protobuf registry, if any. 5 | pub const PROTOBUF_REGISTRY: Item = Item::new("protobuf_registry"); 6 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | pub const GROUP_CONTRACT: Item = Item::new("group_contract"); 5 | pub const DAO: Item = Item::new("dao_address"); 6 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/src/json_ops/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod op_collection; 2 | pub mod op_comparison; 3 | pub mod op_existence; 4 | pub mod op_logical; 5 | pub mod op_transform; 6 | pub mod op_type; 7 | pub mod operator; 8 | pub mod utils; 9 | -------------------------------------------------------------------------------- /ci/configs/cosm-orc/ci.yaml: -------------------------------------------------------------------------------- 1 | chain_cfg: 2 | denom: "ujunox" 3 | prefix: "juno" 4 | chain_id: "testing" 5 | grpc_endpoint: "http://localhost:9090/" 6 | derivation_path: "m/44'/118'/0'/0/0" 7 | gas_price: 0.1 8 | gas_adjustment: 1.5 9 | -------------------------------------------------------------------------------- /contracts/dao-dao-core/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod state; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | 10 | pub use crate::error::ContractError; 11 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-single/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | mod adversarial_tests; 2 | mod do_votes; 3 | mod execute; 4 | mod instantiate; 5 | mod migration_tests; 6 | mod queries; 7 | mod tests; 8 | 9 | pub(crate) const CREATOR_ADDR: &str = "creator"; 10 | -------------------------------------------------------------------------------- /packages/dao-pre-propose-base/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod error; 4 | pub mod execute; 5 | pub mod helpers; 6 | pub mod msg; 7 | pub mod state; 8 | 9 | #[cfg(test)] 10 | mod tests; 11 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/README.md: -------------------------------------------------------------------------------- 1 | # Proposal Hooks Counter 2 | 3 | ## Purely for testing for hooks integration. (DO NOT USE IN MAINNET) 4 | 5 | Contract that integrates with the new proposal hooks 6 | system to test if they work and are reverted correctly. 7 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/README: -------------------------------------------------------------------------------- 1 | # dao-proposal-sudo 2 | 3 | A governance module for the cw-governance contract. Instantiated with 4 | a root address. The root address may indiscriminately cause the module 5 | to execute messages on the DAO. No other user may do this. 6 | -------------------------------------------------------------------------------- /contracts/test/dao-test-custom-factory/README: -------------------------------------------------------------------------------- 1 | # Test Custom Factory contract 2 | Used for testing custom factories with `dao-voting-token-staked` and `dao-voting-cw721-staked`. This also serves an example for how to build custom factory contracts for token or NFT based DAOs. 3 | -------------------------------------------------------------------------------- /contracts/external/cw-vesting/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::Item; 2 | 3 | use crate::vesting::Payment; 4 | 5 | pub const PAYMENT: Payment = Payment::new("vesting", "staked", "validator", "cardinality"); 6 | pub const UNBONDING_DURATION_SECONDS: Item = Item::new("ubs"); 7 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /contracts/external/cw-token-swap/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | pub mod contract; 3 | mod error; 4 | pub mod msg; 5 | pub mod state; 6 | 7 | #[cfg(test)] 8 | mod testing; 9 | 10 | pub use crate::error::ContractError; 11 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | } 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw20-staked/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod testing; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-token-staked/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /packages/dao-hooks/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | mod all_hooks; 4 | pub mod nft_stake; 5 | pub mod proposal; 6 | pub mod stake; 7 | pub mod vote; 8 | 9 | pub use all_hooks::DaoHooks; 10 | pub use cw4::MemberChangedHookMsg; 11 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | pub use crate::error::ContractError; 9 | 10 | #[cfg(test)] 11 | mod tests; 12 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | mod math; 6 | pub mod msg; 7 | pub mod state; 8 | 9 | #[cfg(test)] 10 | mod tests; 11 | 12 | pub use crate::error::ContractError; 13 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-staked/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod testing; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /packages/dao-interface/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod helpers; 4 | pub mod migrate_msg; 5 | pub mod msg; 6 | pub mod nft; 7 | pub mod proposal; 8 | pub mod query; 9 | pub mod state; 10 | pub mod token; 11 | pub mod voting; 12 | -------------------------------------------------------------------------------- /packages/dao-interface/src/nft.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | 3 | use crate::state::ModuleInstantiateCallback; 4 | 5 | #[cw_serde] 6 | pub struct NftFactoryCallback { 7 | pub nft_contract: String, 8 | pub module_instantiate_callback: Option, 9 | } 10 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/src/msg.rs: -------------------------------------------------------------------------------- 1 | use dao_cw721_extensions::roles::{ExecuteExt, MetadataExt, QueryExt}; 2 | 3 | pub type InstantiateMsg = cw721_base::InstantiateMsg; 4 | pub type ExecuteMsg = cw721_base::ExecuteMsg; 5 | pub type QueryMsg = cw721_base::QueryMsg; 6 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::ContractError; 12 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | pub mod decoder; 5 | mod error; 6 | pub mod msg; 7 | pub mod state; 8 | 9 | #[cfg(test)] 10 | mod testing; 11 | 12 | pub use crate::error::ContractError; 13 | -------------------------------------------------------------------------------- /contracts/external/cw-vesting/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_vesting::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw721_roles::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | execute: ExecuteMsg, 8 | query: QueryMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-onft-staked/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | mod omniflix; 7 | pub mod state; 8 | 9 | #[cfg(test)] 10 | mod testing; 11 | 12 | pub use crate::error::ContractError; 13 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod protobuf; 7 | pub mod state; 8 | 9 | #[cfg(test)] 10 | mod testing; 11 | 12 | pub use crate::error::ContractError; 13 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/tests/cases/mod.rs: -------------------------------------------------------------------------------- 1 | mod allowlist; 2 | mod beforesend; 3 | mod burn; 4 | mod contract_owner; 5 | mod denom_metadata; 6 | mod denylist; 7 | mod force_transfer; 8 | mod freeze; 9 | mod instantiate; 10 | mod mint; 11 | mod set_before_send_hook; 12 | mod tokenfactory_admin; 13 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_migrator::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/workflows/audit.yml: -------------------------------------------------------------------------------- 1 | name: Cargo audit 2 | on: 3 | schedule: 4 | - cron: '0 0 * * *' 5 | jobs: 6 | audit: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - uses: actions-rs/audit-check@v1 11 | with: 12 | token: ${{ secrets.GITHUB_TOKEN }} 13 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/schema/instantiate_msg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "InstantiateMsg", 4 | "type": "object", 5 | "required": [ 6 | "root" 7 | ], 8 | "properties": { 9 | "root": { 10 | "type": "string" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/delegation/dao-vote-delegation/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | mod helpers; 6 | mod hooks; 7 | pub mod msg; 8 | pub mod state; 9 | 10 | #[cfg(test)] 11 | mod testing; 12 | 13 | pub use crate::error::ContractError; 14 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("An unknown reply ID was received.")] 10 | UnknownReplyID {}, 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-payroll-factory/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_payroll_factory::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | pub mod types; 8 | pub mod utils; 9 | 10 | #[cfg(test)] 11 | mod testing; 12 | 13 | pub use crate::error::ContractError; 14 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/lib.rs: -------------------------------------------------------------------------------- 1 | mod cell; 2 | pub mod config; 3 | pub mod contract; 4 | mod error; 5 | mod m; 6 | pub mod msg; 7 | pub mod proposal; 8 | pub mod state; 9 | pub mod tally; 10 | 11 | #[cfg(test)] 12 | mod testing; 13 | 14 | pub mod vote; 15 | 16 | pub use crate::error::ContractError; 17 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod bitsong; 4 | pub mod contract; 5 | mod error; 6 | pub mod msg; 7 | pub mod state; 8 | 9 | mod shim; 10 | 11 | pub use crate::error::ContractError; 12 | 13 | #[cfg(test)] 14 | mod testing; 15 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | /target 3 | 4 | # Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) 5 | .cargo-ok 6 | 7 | # Text file backups 8 | **/*.rs.bk 9 | 10 | # macOS 11 | .DS_Store 12 | 13 | # IDEs 14 | *.iml 15 | .idea 16 | -------------------------------------------------------------------------------- /contracts/test/dao-test-custom-factory/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_test_custom_factory::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_cw721_roles::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-onft-staked/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_onft_staked::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod decoder; 2 | pub mod filter; 3 | mod json_ops; 4 | pub mod result; 5 | 6 | #[cfg(test)] 7 | mod test; 8 | 9 | pub use decoder::ProtobufDecoder; 10 | pub use filter::CwJsonFilter; 11 | pub use result::{FilterFailure, FilterFatalError, FilterResult}; 12 | 13 | pub use prost_reflect; 14 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_proposal_condorcet::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-multiple/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod proposal; 7 | pub mod query; 8 | pub mod state; 9 | pub use crate::error::ContractError; 10 | 11 | #[cfg(test)] 12 | pub mod testing; 13 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | /target 3 | 4 | # Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) 5 | .cargo-ok 6 | 7 | # Text file backups 8 | **/*.rs.bk 9 | 10 | # macOS 11 | .DS_Store 12 | 13 | # IDEs 14 | *.iml 15 | .idea 16 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | /target 3 | 4 | # Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327) 5 | .cargo-ok 6 | 7 | # Text file backups 8 | **/*.rs.bk 9 | 10 | # macOS 11 | .DS_Store 12 | 13 | # IDEs 14 | *.iml 15 | .idea 16 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-staked/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_cw721_staked::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::Item; 2 | 3 | use crate::msg::CreatingFanToken; 4 | 5 | /// Temporarily holds data about the fan token being created that's needed in 6 | /// reply so we can mint initial tokens and reset the minter. 7 | pub const CREATING_FAN_TOKEN: Item = Item::new("cft"); 8 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/schema/instantiate_msg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "InstantiateMsg", 4 | "type": "object", 5 | "required": [ 6 | "should_error" 7 | ], 8 | "properties": { 9 | "should_error": { 10 | "type": "boolean" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /contracts/dao-dao-core/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_interface::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/dao-rbam/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_rbam::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw20_stake::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-token-swap/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_token_swap::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_cw4::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/distribution/dao-rewards-distributor/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod helpers; 6 | pub mod hooks; 7 | pub mod msg; 8 | pub mod rewards; 9 | pub mod state; 10 | 11 | #[cfg(test)] 12 | mod testing; 13 | 14 | pub use crate::error::ContractError; 15 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use btsg_ft_factory::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 2 | use cosmwasm_schema::write_api; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_protobuf_registry::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-single/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod proposal; 7 | pub mod query; 8 | 9 | #[cfg(test)] 10 | mod testing; 11 | 12 | pub mod state; 13 | pub mod v1_state; 14 | 15 | pub use crate::error::ContractError; 16 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_admin_factory::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/delegation/dao-vote-delegation/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_vote_delegation::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | /// The account allowed to execute the contract. If None, anyone is allowed. 5 | pub const ADMIN: Item> = Item::new("admin"); 6 | 7 | /// The expected instantiate2 address to validate in the reply. 8 | pub const EXPECT: Item = Item::new("expect"); 9 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw_protobuf_registry::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | 3 | use cw_tokenfactory_issuer::msg::{ExecuteMsg, InstantiateMsg, QueryMsg, SudoMsg}; 4 | 5 | fn main() { 6 | write_api! { 7 | instantiate: InstantiateMsg, 8 | execute: ExecuteMsg, 9 | query: QueryMsg, 10 | sudo: SudoMsg, 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-single/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_pre_propose_single::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-single/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_proposal_single::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/cw-tokenfactory-types/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod msg; 2 | 3 | pub mod cosmos; 4 | pub mod cosmwasm; 5 | pub use osmosis_std::types::osmosis::tokenfactory::v1beta1 as osmosis; 6 | pub mod thorchain; 7 | 8 | // helpers for both osmosis types (osmosis_std crate) and cosmwasm types. it 9 | // needs to be named `shim` because osmosis_std assumes it exists. 10 | mod shim; 11 | -------------------------------------------------------------------------------- /ci/configs/cosm-orc/testnet.yaml: -------------------------------------------------------------------------------- 1 | chain_cfg: 2 | denom: "ujunox" 3 | prefix: "juno" 4 | chain_id: "uni-5" 5 | grpc_endpoint: "http://juno-testnet-grpc.polkachu.com:26090" 6 | derivation_path: "m/44'/118'/0'/0/0" 7 | gas_price: 0.1 8 | gas_adjustment: 1.5 9 | 10 | contract_deploy_info: 11 | cw20_base: 12 | code_id: 229 13 | cw4_group: 14 | code_id: 230 15 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_cw20_staked::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/dao-rbam/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod action; 4 | pub mod contract; 5 | mod error; 6 | pub mod helpers; 7 | pub mod msg; 8 | pub mod role; 9 | pub mod state; 10 | 11 | #[cfg(test)] 12 | pub mod shim; 13 | #[cfg(test)] 14 | mod testing; 15 | 16 | pub use crate::error::ContractError; 17 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-multiple/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_pre_propose_multiple::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-multiple/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_proposal_multiple::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw20-staked/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_cw20_staked::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-token-staked/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_voting_token_staked::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-token-staked/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | // Tests for the crate, using cw-multi-test 2 | // Most coverage lives here 3 | mod multitest; 4 | 5 | // Integration tests using an actual chain binary, requires 6 | // the "test-tube" feature to be enabled 7 | // cargo test --features test-tube 8 | #[cfg(test)] 9 | #[cfg(feature = "test-tube")] 10 | mod test_tube; 11 | -------------------------------------------------------------------------------- /contracts/distribution/dao-rewards-distributor/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_rewards_distributor::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approver/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_pre_propose_approver::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw20_stake_external_rewards::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use cw20_stake_reward_distributor::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-single/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_pre_propose_approval_single::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{OverflowError, StdError}; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error(transparent)] 10 | OverflowError(#[from] OverflowError), 11 | 12 | #[error("Unauthorized")] 13 | Unauthorized {}, 14 | } 15 | -------------------------------------------------------------------------------- /packages/dao-voting/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod approval; 4 | pub mod delegation; 5 | pub mod deposit; 6 | pub mod duration; 7 | pub mod error; 8 | pub mod multiple_choice; 9 | pub mod pre_propose; 10 | pub mod proposal; 11 | pub mod reply; 12 | pub mod status; 13 | pub mod threshold; 14 | pub mod veto; 15 | pub mod voting; 16 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-multiple/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::write_api; 2 | use dao_pre_propose_approval_multiple::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; 3 | 4 | fn main() { 5 | write_api! { 6 | instantiate: InstantiateMsg, 7 | query: QueryMsg, 8 | execute: ExecuteMsg, 9 | migrate: MigrateMsg, 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /contracts/external/cw-payroll-factory/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | // so that consumers don't need a cw_ownable dependency to consume this contract's queries. 12 | pub use cw_ownable::Ownership; 13 | 14 | pub use crate::error::ContractError; 15 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/README.md: -------------------------------------------------------------------------------- 1 | # dao-voting-cw721-roles 2 | 3 | This contract works in conjunction with the [cw721-roles contract](../../external/cw721-roles), and allows for a DAO with non-transferrable roles that can have different weights for voting power. This contract implements the interface needed to be a DAO DAO [voting module](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design#the-voting-module). 4 | -------------------------------------------------------------------------------- /packages/nft-controllers/README.md: -------------------------------------------------------------------------------- 1 | # NFT Controllers 2 | 3 | This is an implementation of cw-plus' 4 | [cw-controllers](https://github.com/CosmWasm/cw-plus/tree/72afcde846b907fac5c0394ce86ed5a59ce47524/packages/controllers) 5 | package for NFTs. It manages claims for our NFT staking contracts: 6 | 7 | - [dao-voting-cw721-staked](../../contracts/voting/dao-voting-cw721-staked) 8 | - [dao-voting-onft-staked](../../contracts/voting/dao-voting-onft-staked) 9 | -------------------------------------------------------------------------------- /contracts/external/cw-vesting/src/suite_tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod suite; 2 | mod tests; 3 | 4 | // Advantage to using a macro for this is that the error trace links 5 | // to the exact line that the error occured, instead of inside of a 6 | // function where the assertion would otherwise happen. 7 | macro_rules! is_error { 8 | ($x:expr, $e:expr) => { 9 | assert!(format!("{:#}", $x.unwrap_err()).contains($e)) 10 | }; 11 | } 12 | pub(crate) use is_error; 13 | -------------------------------------------------------------------------------- /.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [alias] 2 | wasm = "build --release --lib --target wasm32-unknown-unknown" 3 | wasm-debug = "build --lib --target wasm32-unknown-unknown" 4 | all-test = "test --workspace" 5 | unit-test = "test --lib" 6 | integration-test = "test --package integration-tests -- --ignored --test-threads 1 -Z unstable-options --report-time" 7 | test-tube = "test --features test-tube" 8 | schema = "run --example schema" 9 | 10 | [env] 11 | RUSTFLAGS = "-C link-arg=-s" 12 | -------------------------------------------------------------------------------- /packages/cw-hooks/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm DAO Hooks 2 | 3 | This package provides shared hook functionality used for 4 | [dao-hooks](../dao-hooks). 5 | 6 | It deviates from other CosmWasm hook packages in that hooks can be 7 | modified based on their index in the hook list AND based on the 8 | address receiving the hook. This allows dispatching hooks with their 9 | index as the reply ID of a submessage and removing hooks if they fail 10 | to process the hook message. 11 | -------------------------------------------------------------------------------- /packages/cw-tokenfactory-types/README.md: -------------------------------------------------------------------------------- 1 | # cw-tokenfactory-types 2 | 3 | This package supports contracts that depend on varying tokenfactory standards, 4 | which use very similar or identical Cosmos SDK msgs with different type URLs: 5 | 6 | - `/osmosis.tokenfactory...` 7 | - `/cosmwasm.tokenfactory...` 8 | - `/thorchain.denom.v1...` 9 | 10 | Build features: 11 | 12 | - `osmosis_tokenfactory` (default) 13 | - `cosmwasm_tokenfactory` 14 | - `thorchain_tokenfactory` 15 | -------------------------------------------------------------------------------- /packages/dao-voting/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum VotingError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("min_voting_period and max_voting_period must have the same units (height or time)")] 10 | DurationUnitsConflict {}, 11 | 12 | #[error("Min voting period must be less than or equal to max voting period")] 13 | InvalidMinVotingPeriod {}, 14 | } 15 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approver/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | pub mod msg; 5 | pub mod state; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | 10 | // Exporting these means that contracts interacting with this one don't 11 | // need an explicit dependency on the base contract to read queries. 12 | pub use dao_pre_propose_base::msg::DepositInfoResponse; 13 | pub use dao_pre_propose_base::state::Config; 14 | -------------------------------------------------------------------------------- /packages/cw-stake-tracker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-stake-tracker" 3 | authors = ["ekez "] 4 | description = "A package for tracking staked and unbonding tokens in x/staking." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-schema = { workspace = true } 12 | cosmwasm-std = { workspace = true } 13 | cw-wormhole = { workspace = true } 14 | -------------------------------------------------------------------------------- /packages/dao-cw721-extensions/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-cw721-extensions" 3 | authors = ["Jake Hartnell"] 4 | description = "A package for DAO cw721 extensions." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cosmwasm-schema = { workspace = true } 13 | cw-controllers = { workspace = true } 14 | cw4 = { workspace = true } 15 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-multiple/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | pub mod msg; 5 | pub mod state; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | 10 | // Exporting these means that contracts interacting with this one don't 11 | // need an explicit dependency on the base contract to read queries. 12 | pub use dao_pre_propose_base::msg::DepositInfoResponse; 13 | pub use dao_pre_propose_base::state::Config; 14 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-single/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | pub mod msg; 5 | pub mod state; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | 10 | // Exporting these means that contracts interacting with this one don't 11 | // need an explicit dependency on the base contract to read queries. 12 | pub use dao_pre_propose_base::msg::DepositInfoResponse; 13 | pub use dao_pre_propose_base::state::Config; 14 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, Uint128}; 3 | use cw_storage_plus::Item; 4 | 5 | #[cw_serde] 6 | pub struct Config { 7 | pub staking_addr: Addr, 8 | pub reward_rate: Uint128, 9 | pub reward_token: Addr, 10 | } 11 | 12 | // `"config"` key stores v1 configuration. 13 | pub const CONFIG: Item = Item::new("config_v2"); 14 | 15 | pub const LAST_PAYMENT_BLOCK: Item = Item::new("last_payment_block"); 16 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | mod instantiation; 2 | mod proposals; 3 | mod suite; 4 | mod tallying; 5 | 6 | // Advantage to using a macro for this is that the error trace links 7 | // to the exact line that the error occured, instead of inside of a 8 | // function where the assertion would otherwise happen. 9 | macro_rules! is_error { 10 | ($x:expr, $e:expr) => { 11 | assert!(format!("{:#}", $x.unwrap_err()).contains($e)) 12 | }; 13 | } 14 | pub(crate) use is_error; 15 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/README.md: -------------------------------------------------------------------------------- 1 | # CW20 Stake External Rewards 2 | 3 | [![cw20-stake-external-rewards on crates.io](https://img.shields.io/crates/v/cw20-stake-external-rewards.svg?logo=rust)](https://crates.io/crates/cw20-stake-external-rewards) 4 | [![docs.rs](https://img.shields.io/docsrs/cw20-stake-external-rewards?logo=docsdotrs)](https://docs.rs/cw20-stake-external-rewards/latest/cw20_stake_external_rewards/) 5 | 6 | This contract enables staking rewards in terms of non-governance 7 | tokens. 8 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/README.md: -------------------------------------------------------------------------------- 1 | # CW20 Stake 2 | 3 | [![cw20-stake on crates.io](https://img.shields.io/crates/v/cw20-stake.svg?logo=rust)](https://crates.io/crates/cw20-stake) 4 | [![docs.rs](https://img.shields.io/docsrs/cw20-stake?logo=docsdotrs)](https://docs.rs/cw20-stake/latest/cw20_stake/) 5 | 6 | This is a basic implementation of a cw20 staking contract. Staked 7 | tokens can be unbonded with a configurable unbonding period. Staked 8 | balances can be queried at any arbitrary height by external contracts. 9 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Empty; 2 | use cw_multi_test::{Contract, ContractWrapper}; 3 | 4 | mod adversarial_tests; 5 | mod tests; 6 | 7 | pub fn cw_fund_distributor_contract() -> Box> { 8 | let contract = ContractWrapper::new( 9 | crate::contract::execute, 10 | crate::contract::instantiate, 11 | crate::contract::query, 12 | ) 13 | .with_migrate(crate::contract::migrate); 14 | Box::new(contract) 15 | } 16 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | // Integrationg tests using an actual chain binary, requires 12 | // the "test-tube" feature to be enabled 13 | // cargo test --features test-tube 14 | #[cfg(test)] 15 | #[cfg(feature = "test-tube")] 16 | mod integration_tests; 17 | 18 | pub use crate::error::ContractError; 19 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::Addr; 3 | use cw_storage_plus::Item; 4 | 5 | use crate::msg::NftMintMsg; 6 | 7 | #[cw_serde] 8 | pub struct Config { 9 | pub nft_address: Addr, 10 | } 11 | 12 | pub const CONFIG: Item = Item::new("config"); 13 | pub const DAO: Item = Item::new("dao"); 14 | 15 | // Holds initial NFTs messages during instantiation. 16 | pub const INITIAL_NFTS: Item> = Item::new("initial_nfts"); 17 | -------------------------------------------------------------------------------- /packages/cw-snapshot-vector-map/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-snapshot-vector-map" 3 | authors = ["noah "] 4 | description = "A CosmWasm vector map that allows reading the items that existed at any height in the past." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cw-storage-plus = { workspace = true } 13 | serde = { workspace = true } 14 | -------------------------------------------------------------------------------- /packages/cw-wormhole/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-wormhole" 3 | authors = ["ekez "] 4 | description = "A CosmWasm map that allows incrementing and decrementing values from the past." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-schema = { workspace = true } 12 | cosmwasm-std = { workspace = true } 13 | cw-storage-plus = { workspace = true } 14 | serde = { workspace = true } 15 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | mod error; 5 | pub mod msg; 6 | pub mod state; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub use crate::error::RolesContractError as ContractError; 12 | 13 | // So consumers don't need dependencies to interact with this contract. 14 | pub use cw721_base::MinterResponse; 15 | pub use cw_ownable::{Action, Ownership}; 16 | pub use dao_cw721_extensions::roles::{ExecuteExt, MetadataExt, QueryExt}; 17 | -------------------------------------------------------------------------------- /packages/cw-paginate-storage/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-paginate-storage" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "A package for paginating cosmwasm maps." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cw-storage-plus = { workspace = true } 13 | serde = { workspace = true } 14 | 15 | [dev-dependencies] 16 | cw-multi-test = { workspace = true } 17 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/README.md: -------------------------------------------------------------------------------- 1 | # btsg-ft-factory 2 | 3 | Serves as a factory that issues new 4 | [fantokens](https://github.com/bitsongofficial/go-bitsong/tree/main/x/fantoken) 5 | on BitSong and returns their denom for use with the 6 | [dao-voting-token-staked](../../voting/dao-voting-token-staked) voting module 7 | contract. 8 | 9 | Instantiation and execution are permissionless. All DAOs will use the same 10 | factory and execute `Issue` to create new fantokens through `TokenInfo::Factory` 11 | during voting module instantiation. 12 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-multiple/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | 8 | pub use contract::{ExecuteMsg, InstantiateMsg, MigrateMsg, ProposeMessage, QueryMsg}; 9 | 10 | // Exporting these means that contracts interacting with this one don't 11 | // need an explicit dependency on the base contract to read queries. 12 | pub use dao_pre_propose_base::msg::DepositInfoResponse; 13 | pub use dao_pre_propose_base::state::Config; 14 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-single/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | 5 | #[cfg(test)] 6 | mod tests; 7 | 8 | pub use contract::{ExecuteMsg, InstantiateMsg, MigrateMsg, ProposeMessage, QueryMsg}; 9 | 10 | // Exporting these means that contracts interacting with this one don't 11 | // need an explicit dependency on the base contract to read queries. 12 | pub use dao_pre_propose_base::msg::DepositInfoResponse; 13 | pub use dao_pre_propose_base::state::Config; 14 | -------------------------------------------------------------------------------- /packages/cw-hooks/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-hooks" 3 | authors = ["Callum Anderson "] 4 | description = "A package for managing a set of hooks which can be accessed by their index." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | thiserror = { workspace = true } 12 | cosmwasm-std = { workspace = true } 13 | cosmwasm-schema = { workspace = true } 14 | cw-storage-plus = { workspace = true } 15 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/README.md: -------------------------------------------------------------------------------- 1 | # CW20 Stake Reward Distributor 2 | 3 | [![cw20-stake-reward-distributor on crates.io](https://img.shields.io/crates/v/cw20-stake-reward-distributor.svg?logo=rust)](https://crates.io/crates/cw20-stake-reward-distributor) 4 | [![docs.rs](https://img.shields.io/docsrs/cw20-stake-reward-distributor?logo=docsdotrs)](https://docs.rs/cw20-stake-reward-distributor/latest/cw20_stake_reward_distributor/) 5 | 6 | A contract to fund cw20-stake contracts with rewards in terms of the 7 | same tokens being staked. 8 | 9 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::Item; 3 | 4 | use crate::types::{ModulesAddrs, TestState}; 5 | 6 | /// Holds data about the DAO before migration (so we can test against it after migration) 7 | pub const TEST_STATE: Item = Item::new("test_state"); 8 | /// Holds addresses for what we need to query for 9 | pub const MODULES_ADDRS: Item = Item::new("module_addrs"); 10 | /// Hold the core address to be used in reply 11 | pub const CORE_ADDR: Item = Item::new("core_addr"); 12 | -------------------------------------------------------------------------------- /packages/dao-testing/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | #[cfg(not(target_arch = "wasm32"))] 4 | pub mod helpers; 5 | 6 | #[cfg(not(target_arch = "wasm32"))] 7 | pub mod contracts; 8 | 9 | #[cfg(not(target_arch = "wasm32"))] 10 | pub mod tests; 11 | #[cfg(not(target_arch = "wasm32"))] 12 | pub use tests::*; 13 | 14 | #[cfg(not(target_arch = "wasm32"))] 15 | pub mod suite; 16 | #[cfg(not(target_arch = "wasm32"))] 17 | pub use suite::*; 18 | 19 | #[cfg(not(target_arch = "wasm32"))] 20 | pub mod test_tube; 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | .DS_Store 3 | 4 | # Text file backups 5 | **/*.rs.bk 6 | 7 | # Build results 8 | target/ 9 | 10 | # IDEs 11 | .vscode/ 12 | .idea/ 13 | *.iml 14 | **/.editorconfig 15 | 16 | # Auto-gen 17 | .cargo-ok 18 | 19 | # Build artifacts 20 | *.wasm 21 | hash.txt 22 | contracts.txt 23 | artifacts/ 24 | 25 | # code coverage 26 | tarpaulin-report.* 27 | 28 | # integration tests 29 | gas_reports/ 30 | ci/configs/cosm-orc/local.yaml 31 | 32 | contracts/**/Cargo.lock 33 | packages/**/Cargo.lock 34 | debug/**/Cargo.lock 35 | ci/**/Cargo.lock 36 | .aider* 37 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approver/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_storage_plus::{Item, Map}; 3 | 4 | // Stores the address of the pre-propose approval contract 5 | pub const PRE_PROPOSE_APPROVAL_CONTRACT: Item = Item::new("pre_propose_approval_contract"); 6 | // Maps proposal ids to pre-propose ids 7 | pub const PROPOSAL_ID_TO_PRE_PROPOSE_ID: Map = Map::new("proposal_to_pre_propose"); 8 | // Maps pre-propose ids to proposal ids 9 | pub const PRE_PROPOSE_ID_TO_PROPOSAL_ID: Map = Map::new("pre_propose_to_proposal"); 10 | -------------------------------------------------------------------------------- /packages/nft-controllers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "nft-controllers" 3 | authors = ["CypherApe cypherape@protonmail.com", "Noah "] 4 | description = "A package for managing NFT claims." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cosmwasm-schema = { workspace = true } 13 | cw-utils = { workspace = true } 14 | cw-storage-plus = { workspace = true } 15 | thiserror = { workspace = true } 16 | -------------------------------------------------------------------------------- /contracts/README.md: -------------------------------------------------------------------------------- 1 | # DAO Contracts 2 | 3 | - `dao-dao-core` - the core module for DAOs. 4 | - `delegation` - delegation modules. 5 | - `distribution` - token distribution modules. 6 | - `external` - contracts used by DAOs that are not part of a DAO module. 7 | - `pre-propose` - pre-propose modules. 8 | - `proposal` - proposal modules. 9 | - `staking` - cw20 staking functionality and a staking rewards system. 10 | - `voting` - voting modules. 11 | 12 | For a description of each module type, see [our wiki](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design). 13 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::CosmosMsg; 3 | 4 | #[cw_serde] 5 | pub struct InstantiateMsg { 6 | pub root: String, 7 | } 8 | 9 | #[cw_serde] 10 | pub enum ExecuteMsg { 11 | Execute { msgs: Vec }, 12 | } 13 | 14 | #[cw_serde] 15 | #[derive(QueryResponses)] 16 | pub enum QueryMsg { 17 | #[returns(cosmwasm_std::Addr)] 18 | Admin {}, 19 | #[returns(cosmwasm_std::Addr)] 20 | Dao {}, 21 | #[returns(dao_interface::voting::InfoResponse)] 22 | Info {}, 23 | } 24 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use dao_interface::query::SubDao; 3 | 4 | use crate::types::{MigrationParams, V1CodeIds, V2CodeIds}; 5 | 6 | #[cw_serde] 7 | pub struct MigrateV1ToV2 { 8 | pub sub_daos: Vec, 9 | pub migration_params: MigrationParams, 10 | pub v1_code_ids: V1CodeIds, 11 | pub v2_code_ids: V2CodeIds, 12 | } 13 | 14 | pub type InstantiateMsg = MigrateV1ToV2; 15 | 16 | pub type ExecuteMsg = MigrateV1ToV2; 17 | 18 | #[cw_serde] 19 | #[derive(QueryResponses)] 20 | pub enum QueryMsg {} 21 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::Uint128; 3 | use cw_storage_plus::Item; 4 | 5 | #[cw_serde] 6 | pub struct Config { 7 | pub should_error: bool, 8 | } 9 | pub const CONFIG: Item = Item::new("config"); 10 | pub const PROPOSAL_COUNTER: Item = Item::new("proposal_counter"); 11 | pub const STAKE_COUNTER: Item = Item::new("stake_counter"); 12 | pub const STATUS_CHANGED_COUNTER: Item = Item::new("stauts_changed_counter"); 13 | pub const VOTE_COUNTER: Item = Item::new("vote_counter"); 14 | -------------------------------------------------------------------------------- /packages/dao-hooks/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-hooks" 3 | authors = ["ekez ekez@withoutdoing.com", "Jake Hartnell "] 4 | description = "A package for managing DAO vote, proposal, and stake hooks." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cosmwasm-schema = { workspace = true } 13 | cw4 = { workspace = true } 14 | cw-hooks = { workspace = true } 15 | dao-pre-propose-base = { workspace = true } 16 | dao-voting = { workspace = true } 17 | -------------------------------------------------------------------------------- /packages/dao-dao-macros/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm DAO Macros 2 | 3 | This package provides a collection of macros that may be used to 4 | derive DAO module interfaces on message enums. For example, to derive 5 | the voting module interface on an enum: 6 | 7 | ```rust 8 | use cosmwasm_schema::{cw_serde, QueryResponses}; 9 | use dao_dao_macros::{cw20_token_query, voting_module_query}; 10 | use dao_interface::voting::TotalPowerAtHeightResponse; 11 | use dao_interface::voting::VotingPowerAtHeightResponse; 12 | 13 | #[cw20_token_query] 14 | #[voting_module_query] 15 | #[cw_serde] 16 | #[derive(QueryResponses)] 17 | pub enum Query {} 18 | ``` 19 | -------------------------------------------------------------------------------- /packages/dao-testing/src/suite/mod.rs: -------------------------------------------------------------------------------- 1 | mod base; 2 | mod cw20_suite; 3 | mod cw4_suite; 4 | mod cw721_suite; 5 | mod token_suite; 6 | 7 | pub const OWNER: &str = "owner"; 8 | 9 | pub const ADDR0: &str = "addr0"; 10 | pub const ADDR1: &str = "addr1"; 11 | pub const ADDR2: &str = "addr2"; 12 | pub const ADDR3: &str = "addr3"; 13 | pub const ADDR4: &str = "addr4"; 14 | 15 | pub const DENOM: &str = "udenom"; 16 | pub const GOV_DENOM: &str = "ugovtoken"; 17 | 18 | pub use cw_multi_test::Executor; 19 | 20 | pub use base::*; 21 | pub use cw20_suite::*; 22 | pub use cw4_suite::*; 23 | pub use cw721_suite::*; 24 | pub use token_suite::*; 25 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use std::env::current_dir; 2 | use std::fs::create_dir_all; 3 | 4 | use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; 5 | 6 | use dao_proposal_hook_counter::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 7 | 8 | fn main() { 9 | let mut out_dir = current_dir().unwrap(); 10 | out_dir.push("schema"); 11 | create_dir_all(&out_dir).unwrap(); 12 | remove_schemas(&out_dir).unwrap(); 13 | 14 | export_schema(&schema_for!(InstantiateMsg), &out_dir); 15 | export_schema(&schema_for!(ExecuteMsg), &out_dir); 16 | export_schema(&schema_for!(QueryMsg), &out_dir); 17 | } 18 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_utils::ParseReplyError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error("{0}")] 8 | Std(#[from] StdError), 9 | 10 | #[error("Unauthorized")] 11 | Unauthorized {}, 12 | 13 | #[error("{0}")] 14 | ParseReplyError(#[from] ParseReplyError), 15 | 16 | #[error("An unknown reply ID was received.")] 17 | UnknownReplyID {}, 18 | 19 | #[error("Expected contract address {expected} but instantiated {actual}.")] 20 | UnexpectedContractAddress { expected: String, actual: String }, 21 | } 22 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/README.md: -------------------------------------------------------------------------------- 1 | # cw-admin-factory 2 | 3 | [![cw-admin-factory on crates.io](https://img.shields.io/crates/v/cw-admin-factory.svg?logo=rust)](https://crates.io/crates/cw-admin-factory) 4 | [![docs.rs](https://img.shields.io/docsrs/cw-admin-factory?logo=docsdotrs)](https://docs.rs/cw-admin-factory/latest/cw_admin_factory/) 5 | 6 | Serves as a factory that instantiates contracts and sets them as their 7 | own wasm admins. 8 | 9 | Useful for allowing contracts (e.g. DAOs) to migrate themselves. 10 | 11 | Example instantiation flow: 12 | 13 | ![](https://bafkreibqsrdnht5chc5mdzbb6pgiyqfjke3yvukvjrokyefwwbl3k3iwaa.ipfs.nftstorage.link) 14 | 15 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Sunny Aggarwal 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /packages/cw-denom/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-denom" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "A package for validation and handling of cw20 and native Cosmos SDK denominations." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cosmwasm-schema = { workspace = true } 13 | 14 | thiserror = { workspace = true } 15 | cw20 = { workspace = true } 16 | 17 | [dev-dependencies] 18 | cw20-base = { workspace = true } 19 | cw-multi-test = { workspace = true } 20 | dao-testing = { workspace = true } 21 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-jsonfilter" 3 | authors = ["Noah ", "JMARyA "] 4 | description = "Filter and compare JSON objects for CosmWasm" 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | base64 = { workspace = true } 12 | serde = { workspace = true } 13 | serde_json = { workspace = true } 14 | prost-reflect = { workspace = true, features = ["serde"] } 15 | 16 | [dev-dependencies] 17 | cw-protobuf-registry = { workspace = true, features = ["library"] } 18 | prost-types = { workspace = true } 19 | -------------------------------------------------------------------------------- /packages/dao-voting/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-voting" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "Types and methods for CosmWasm DAO voting." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cosmwasm-schema = { workspace = true } 13 | thiserror = { workspace = true } 14 | cw20 = { workspace = true } 15 | dao-interface = { workspace = true } 16 | dao-dao-macros = { workspace = true } 17 | cw-denom = { workspace = true } 18 | cw-utils = { workspace = true } 19 | cw-storage-plus = { workspace = true } 20 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | 12 | #[error("Initial governance token balances must not be empty")] 13 | InitialBalancesError {}, 14 | 15 | #[error("Can not change the contract's token after it has been set")] 16 | DuplicateToken {}, 17 | 18 | #[error("Error instantiating token")] 19 | TokenInstantiateError {}, 20 | 21 | #[error("Got a submessage reply with unknown id: {id}")] 22 | UnknownReplyId { id: u64 }, 23 | } 24 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/examples/error_handling.rs: -------------------------------------------------------------------------------- 1 | use cw_jsonfilter::{CwJsonFilter, FilterResult}; 2 | use serde_json::json; 3 | 4 | fn main() { 5 | let filter = json!({"name": "John", "other": "key"}); 6 | let obj = json!({"name": "John", "age": 30}); 7 | 8 | println!("Applying filter:"); 9 | println!("{filter}"); 10 | println!("To object:"); 11 | println!("{obj}"); 12 | 13 | match CwJsonFilter::check(&filter, &obj) { 14 | FilterResult::Pass => println!("Filter matches the object"), 15 | FilterResult::Fail(err) => println!("Filter does not match the object: {err:?}"), 16 | FilterResult::Fatal(err) => println!("Fatal error: {err:?}"), 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /contracts/external/cw-vesting/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | pub mod contract; 4 | pub mod error; 5 | pub mod msg; 6 | pub mod state; 7 | pub mod vesting; 8 | 9 | pub use crate::error::ContractError; 10 | 11 | // so consumers don't need a cw_ownable dependency to use this contract's queries. 12 | pub use cw_denom::{CheckedDenom, UncheckedDenom}; 13 | pub use cw_ownable::Ownership; 14 | 15 | // so consumers don't need a cw_stake_tracker dependency to use this contract's queries. 16 | pub use cw_stake_tracker::StakeTrackerQuery; 17 | 18 | #[cfg(test)] 19 | mod suite_tests; 20 | #[cfg(test)] 21 | mod tests; 22 | #[cfg(test)] 23 | mod vesting_tests; 24 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/examples/filter.rs: -------------------------------------------------------------------------------- 1 | use cw_jsonfilter::{CwJsonFilter, FilterResult}; 2 | use serde_json::json; 3 | 4 | fn main() { 5 | let filter = json!({"name": "John", "age": 30}); 6 | let obj = json!({"name": "John", "age": 30, "city": "New York"}); 7 | 8 | println!("Applying filter:"); 9 | println!("{filter}"); 10 | println!("To object:"); 11 | println!("{obj}"); 12 | 13 | match CwJsonFilter::check(&filter, &obj) { 14 | FilterResult::Pass => println!("Filter matches the object"), 15 | FilterResult::Fail(err) => println!("Filter does not match the object: {err:?}"), 16 | FilterResult::Fatal(err) => println!("Fatal error: {err:?}"), 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/src/decoder.rs: -------------------------------------------------------------------------------- 1 | use serde_json::Value; 2 | 3 | /// interface for decoding protobuf messages. This allows CwJsonFilter to 4 | /// remain generic while enabling consumers to provide their own decoding logic. 5 | pub trait ProtobufDecoder { 6 | fn decode(&self, message_name: String, value: Vec) -> Result; 7 | } 8 | 9 | /// default decoder used when you don't care about protobuf 10 | #[derive(Clone, Copy, Debug, Default)] 11 | pub struct NoopDecoder; 12 | 13 | impl ProtobufDecoder for NoopDecoder { 14 | fn decode(&self, _message_name: String, _value: Vec) -> Result { 15 | Err("protobuf decoder not provided".to_string()) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/dao-dao-macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-dao-macros" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "A package macros for deriving DAO module interfaces." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | proc-macro = true 12 | 13 | [dependencies] 14 | cosmwasm-schema = { workspace = true } 15 | syn = { workspace = true } 16 | quote = { workspace = true } 17 | proc-macro2 = { workspace = true } 18 | 19 | [dev-dependencies] 20 | dao-interface = { workspace = true } 21 | cw-hooks = { workspace = true } 22 | dao-voting = { workspace = true } 23 | cosmwasm-std = { workspace = true } 24 | -------------------------------------------------------------------------------- /packages/dao-interface/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-interface" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "A package containing interface definitions for DAO DAO DAOs." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [dependencies] 11 | cosmwasm-std = { workspace = true } 12 | cw-storage-plus = { workspace = true } 13 | cosmwasm-schema = { workspace = true } 14 | cw2 = { workspace = true } 15 | cw20 = { workspace = true } 16 | cw721 = { workspace = true } 17 | cw-utils = { workspace = true } 18 | osmosis-std = { workspace = true } 19 | 20 | [dev-dependencies] 21 | cosmwasm-schema = { workspace = true } 22 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-staked/src/testing/instantiate.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_multi_test::{App, Executor}; 3 | use dao_testing::contracts::cw721_base_contract; 4 | 5 | pub fn instantiate_cw721_base(app: &mut App, sender: &str, minter: &str) -> Addr { 6 | let cw721_id = app.store_code(cw721_base_contract()); 7 | 8 | app.instantiate_contract( 9 | cw721_id, 10 | Addr::unchecked(sender), 11 | &cw721_base::InstantiateMsg { 12 | name: "bad kids".to_string(), 13 | symbol: "bad kids".to_string(), 14 | minter: minter.to_string(), 15 | }, 16 | &[], 17 | "cw721_base".to_string(), 18 | None, 19 | ) 20 | .unwrap() 21 | } 22 | -------------------------------------------------------------------------------- /packages/cw-denom/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm Denom 2 | 3 | This is a simple package for validating cw20 and Cosmos SDK native 4 | denominations. It proves the types, `UncheckedDenom` and 5 | `CheckedDenom`. `UncheckedDenom` may be used in CosmWasm contract 6 | messages and checked via the `into_checked` method. 7 | 8 | To validate native denominations, this package uses the [same 9 | rules](https://github.com/cosmos/cosmos-sdk/blob/7728516abfab950dc7a9120caad4870f1f962df5/types/coin.go#L865-L867) as the SDK. 10 | 11 | To validate cw20 denominations this package ensures that the 12 | specified address is valid, that the specified address is a 13 | CosmWasm contract, and that the specified address responds 14 | correctly to cw20 `TokenInfo` queries. 15 | -------------------------------------------------------------------------------- /packages/dao-testing/src/test_tube/mod.rs: -------------------------------------------------------------------------------- 1 | // Integrationg tests using an actual chain binary, requires 2 | // the "test-tube" feature to be enabled 3 | // cargo test --features test-tube 4 | 5 | #[cfg(feature = "test-tube")] 6 | pub mod cw_admin_factory; 7 | 8 | #[cfg(feature = "test-tube")] 9 | pub mod cw_tokenfactory_issuer; 10 | 11 | #[cfg(feature = "test-tube")] 12 | pub mod cw4_group; 13 | 14 | #[cfg(feature = "test-tube")] 15 | pub mod cw721_base; 16 | 17 | #[cfg(feature = "test-tube")] 18 | pub mod dao_dao_core; 19 | 20 | #[cfg(feature = "test-tube")] 21 | pub mod dao_proposal_single; 22 | 23 | #[cfg(feature = "test-tube")] 24 | pub mod dao_test_custom_factory; 25 | 26 | #[cfg(feature = "test-tube")] 27 | pub mod dao_voting_cw4; 28 | -------------------------------------------------------------------------------- /packages/dao-dao-macros/tests/govmod.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | 3 | use dao_dao_macros::proposal_module_query; 4 | 5 | #[proposal_module_query] 6 | #[allow(dead_code)] 7 | #[cw_serde] 8 | #[derive(QueryResponses)] 9 | enum Test { 10 | #[returns(String)] 11 | Foo, 12 | #[returns(String)] 13 | Bar(u64), 14 | #[returns(String)] 15 | Baz { waldo: u64 }, 16 | } 17 | 18 | #[test] 19 | fn proposal_module_query_derive() { 20 | let test = Test::Dao {}; 21 | 22 | // If this compiles we have won. 23 | match test { 24 | Test::Foo | Test::Bar(_) | Test::Baz { .. } | Test::Dao {} => "yay", 25 | Test::Info {} => "yay", 26 | Test::NextProposalId {} => "yay", 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error(transparent)] 7 | Std(#[from] StdError), 8 | 9 | #[error("Error instantiating cw721-roles contract")] 10 | NftInstantiateError {}, 11 | 12 | #[error("This contract only supports queries")] 13 | NoExecute {}, 14 | 15 | #[error("New cw721-roles contract must be instantiated with at least one NFT")] 16 | NoInitialNfts {}, 17 | 18 | #[error("Only the owner of this contract may execute this message")] 19 | NotOwner {}, 20 | 21 | #[error("Got a submessage reply with unknown id: {id}")] 22 | UnknownReplyId { id: u64 }, 23 | } 24 | -------------------------------------------------------------------------------- /packages/dao-pre-propose-base/README.md: -------------------------------------------------------------------------------- 1 | # Pre-Propose Base 2 | 3 | This provides a base package that may be used to implement [pre-propose 4 | modules](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design#pre-propose-modules). 5 | It is modeled after the 6 | [cw721-base](https://github.com/CosmWasm/cw-nfts/tree/27ffdc6c24c2d173be6c677d04bec1420191184d/contracts/cw721-base) 7 | contract for implementing NFT contracts. 8 | 9 | See the [pre-propose-single](../../contracts/pre-propose/dao-pre-propose-single) 10 | contract for an example of using this package to implement a proposal 11 | module with deposits. 12 | 13 | Our wiki has more info on [pre-propose module design](https://github.com/DA0-DA0/dao-contracts/wiki/Pre-propose-module-design). 14 | -------------------------------------------------------------------------------- /contracts/external/cw-payroll-factory/README.md: -------------------------------------------------------------------------------- 1 | # cw-payroll-factory 2 | 3 | [![cw-payroll-factory on crates.io](https://img.shields.io/crates/v/cw-payroll-factory.svg?logo=rust)](https://crates.io/crates/cw-payroll-factory) 4 | [![docs.rs](https://img.shields.io/docsrs/cw-payroll-factory?logo=docsdotrs)](https://docs.rs/cw-payroll-factory/latest/cw_payroll_factory/) 5 | 6 | Serves as a factory that instantiates [cw-vesting](../cw-vesting) contracts and stores them in an indexed maps for easy querying by recipient or the instantiator (i.e. give me all of my vesting payment contracts or give me all of a DAO's vesting payment contracts). 7 | 8 | An optional `owner` can be specified when instantiating `cw-payroll-factory` that limits contract instantiation to a single account. 9 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw20-staked/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Binary}; 2 | use cw_storage_plus::Item; 3 | use cw_utils::Duration; 4 | use dao_voting::threshold::ActiveThreshold; 5 | 6 | pub const ACTIVE_THRESHOLD: Item = Item::new("active_threshold"); 7 | pub const TOKEN: Item = Item::new("token"); 8 | pub const DAO: Item = Item::new("dao"); 9 | pub const STAKING_CONTRACT: Item = Item::new("staking_contract"); 10 | pub const STAKING_CONTRACT_UNSTAKING_DURATION: Item> = 11 | Item::new("staking_contract_unstaking_duration"); 12 | pub const STAKING_CONTRACT_CODE_ID: Item = Item::new("staking_contract_code_id"); 13 | pub const STAKING_CONTRACT_SALT: Item = Item::new("staking_contract_salt"); 14 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_controllers::Hooks; 3 | use cw_storage_plus::{SnapshotItem, SnapshotMap, Strategy}; 4 | 5 | // Hooks to contracts that will receive staking and unstaking messages. 6 | pub const HOOKS: Hooks = Hooks::new("hooks"); 7 | 8 | /// A historic snapshot of total weight over time 9 | pub const TOTAL: SnapshotItem = SnapshotItem::new( 10 | "total", 11 | "total__checkpoints", 12 | "total__changelog", 13 | Strategy::EveryBlock, 14 | ); 15 | 16 | /// A historic list of members and total voting weights 17 | pub const MEMBERS: SnapshotMap<&Addr, u64> = SnapshotMap::new( 18 | "members", 19 | "members__checkpoints", 20 | "members__changelog", 21 | Strategy::EveryBlock, 22 | ); 23 | -------------------------------------------------------------------------------- /packages/cw-stake-tracker/README.md: -------------------------------------------------------------------------------- 1 | # Stake Tracker 2 | 3 | This is a CosmWasm package for tracking the staked balance of a smart 4 | contract. 5 | 6 | The `StakeTracker` type here exposes a couple methods with the `on_` 7 | prefix. These should be called whenever the contract performs an 8 | action with x/staking. For example, when the contract delegates 9 | tokens, it should call the `on_delegate` method to register that. Not 10 | calling the method will cause the package to incorrectly track staked 11 | values. 12 | 13 | See 14 | [`cw-vesting`](https://github.com/DA0-DA0/dao-contracts/blob/main/contracts/external/cw-vesting/SECURITY.md#slashing) 15 | for an example of integrating this package into a smart contract and a 16 | discussion of how to handle slash events. 17 | 18 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error(transparent)] 7 | Std(#[from] StdError), 8 | 9 | #[error(transparent)] 10 | Ownership(#[from] cw_ownable::OwnershipError), 11 | 12 | #[error("Invalid Cw20")] 13 | InvalidCw20 {}, 14 | 15 | #[error("Invalid Staking Contract")] 16 | InvalidStakingContract {}, 17 | 18 | #[error("Zero eligible rewards")] 19 | ZeroRewards {}, 20 | 21 | #[error("Rewards have already been distributed for this block")] 22 | RewardsDistributedForBlock {}, 23 | 24 | #[error("can not migrate. current version is up to date")] 25 | AlreadyMigrated {}, 26 | } 27 | -------------------------------------------------------------------------------- /contracts/external/cw-token-swap/README.md: -------------------------------------------------------------------------------- 1 | # cw-token-swap 2 | 3 | [![cw-token-swap on crates.io](https://img.shields.io/crates/v/cw-token-swap.svg?logo=rust)](https://crates.io/crates/cw-token-swap) 4 | [![docs.rs](https://img.shields.io/docsrs/cw-token-swap?logo=docsdotrs)](https://docs.rs/cw-token-swap/latest/cw_token_swap/) 5 | 6 | This is an escrow token swap contract for swapping between native and 7 | cw20 tokens. The contract is instantiated with two counterparties and 8 | their promised funds. Promised funds may either be native tokens or 9 | cw20 tokens. Upon both counterparties providing the promised funds the 10 | transaction is completed and both sides receive their tokens. 11 | 12 | At any time before the other counterparty has provided funds a 13 | counterparty may withdraw their funds. 14 | 15 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{OverflowError, StdError}; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | 12 | #[error("Zero voting power")] 13 | ZeroVotingPower {}, 14 | 15 | #[error("Zero funds")] 16 | ZeroFunds {}, 17 | 18 | #[error("Cannot claim funds during the funding period")] 19 | ClaimDuringFundingPeriod {}, 20 | 21 | #[error("Cannot fund the contract during the claim period")] 22 | FundDuringClaimingPeriod {}, 23 | 24 | #[error("List of specified tokens to claim is empty")] 25 | EmptyClaim {}, 26 | 27 | #[error("{0}")] 28 | OverflowErr(#[from] OverflowError), 29 | } 30 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, StdResult, Storage}; 2 | use cw_storage_plus::{Item, Map}; 3 | 4 | use crate::{config::Config, proposal::Proposal, tally::Tally, vote::Vote}; 5 | 6 | pub(crate) const DAO: Item = Item::new("dao"); 7 | pub(crate) const CONFIG: Item = Item::new("config"); 8 | 9 | pub(crate) const TALLY: Map = Map::new("tallys"); 10 | pub(crate) const PROPOSAL: Map = Map::new("proposals"); 11 | pub(crate) const VOTE: Map<(u32, Addr), Vote> = Map::new("votes"); 12 | 13 | pub(crate) fn next_proposal_id(storage: &dyn Storage) -> StdResult { 14 | PROPOSAL 15 | .keys(storage, None, None, cosmwasm_std::Order::Descending) 16 | .next() 17 | .transpose() 18 | .map(|id| id.unwrap_or(0) + 1) 19 | } 20 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/testing/instantiate.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_multi_test::{App, Executor}; 3 | use dao_testing::contracts::cw721_roles_contract; 4 | 5 | pub fn instantiate_cw721_roles(app: &mut App, sender: &str, minter: &str) -> (Addr, u64) { 6 | let cw721_id = app.store_code(cw721_roles_contract()); 7 | 8 | let cw721_addr = app 9 | .instantiate_contract( 10 | cw721_id, 11 | Addr::unchecked(sender), 12 | &cw721_base::InstantiateMsg { 13 | name: "bad kids".to_string(), 14 | symbol: "bad kids".to_string(), 15 | minter: minter.to_string(), 16 | }, 17 | &[], 18 | "cw721_roles".to_string(), 19 | None, 20 | ) 21 | .unwrap(); 22 | 23 | (cw721_addr, cw721_id) 24 | } 25 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))] 2 | 3 | /// The smart contract itself, including the execute, instantiate, query, migrate 4 | /// and reply entry points 5 | pub mod contract; 6 | /// Private error module, ContractError is re-exported in the public interface 7 | mod error; 8 | /// Contract methods that can be executed and alter state 9 | pub mod execute; 10 | /// Helper functions used for validation and checks 11 | pub mod helpers; 12 | /// Contract hooks 13 | pub mod hooks; 14 | /// Contract messages describing the API of the contract as well as responses 15 | /// from contract queries 16 | pub mod msg; 17 | /// Contract queries 18 | pub mod queries; 19 | /// The contract state 20 | pub mod state; 21 | 22 | /// Error messages used in this contract 23 | pub use crate::error::ContractError; 24 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of conduct 2 | 3 | Be kind to one another. 4 | 5 | > Good walkers leave no track. 6 | > Good counters don’t use their fingers. 7 | > The best door’s unlocked and unopened. 8 | > The best knot’s not in a rope and can’t be untied. 9 | > 10 | > So wise souls are good at caring for people, 11 | > never turning their back on anyone. 12 | > They’re good at looking after things, 13 | > never turning their back on anything. 14 | > There’s a light hidden here. 15 | > 16 | > Good people teach people who aren’t good yet; 17 | > the less good are the makings of the good. 18 | > Anyone who doesn’t respect a teacher 19 | > or cherish a student 20 | > may be clever, but has gone astray. 21 | > There’s a deep mystery here. 22 | 23 | - [Tao Te Ching (Ursula Le Guin transaltion)](https://github.com/lovingawareness/tao-te-ching/blob/master/Ursula%20K%20Le%20Guin.md) 24 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{OverflowError, StdError}; 2 | use thiserror::Error; 3 | 4 | #[derive(Debug, Error, PartialEq)] 5 | pub enum RolesContractError { 6 | #[error(transparent)] 7 | Std(#[from] StdError), 8 | 9 | #[error(transparent)] 10 | Base(#[from] cw721_base::ContractError), 11 | 12 | #[error(transparent)] 13 | HookError(#[from] cw_controllers::HookError), 14 | 15 | #[error("{0}")] 16 | OverflowErr(#[from] OverflowError), 17 | 18 | #[error(transparent)] 19 | Ownable(#[from] cw_ownable::OwnershipError), 20 | 21 | #[error("Cannot burn NFT, member weight would be negative")] 22 | CannotBurn {}, 23 | 24 | #[error("Would result in negative value")] 25 | NegativeValue {}, 26 | 27 | #[error("The submitted weight is equal to the previous value, no change will occur")] 28 | NoWeightChange {}, 29 | } 30 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::{CosmosMsg, Empty}; 3 | 4 | use dao_dao_macros::proposal_module_query; 5 | 6 | use crate::config::UncheckedConfig; 7 | 8 | pub type InstantiateMsg = UncheckedConfig; 9 | 10 | #[cw_serde] 11 | pub struct Choice { 12 | pub msgs: Vec>, 13 | } 14 | 15 | #[cw_serde] 16 | pub enum ExecuteMsg { 17 | Propose { choices: Vec }, 18 | Vote { proposal_id: u32, vote: Vec }, 19 | Execute { proposal_id: u32 }, 20 | Close { proposal_id: u32 }, 21 | SetConfig(UncheckedConfig), 22 | } 23 | 24 | #[proposal_module_query] 25 | #[cw_serde] 26 | #[derive(QueryResponses)] 27 | pub enum QueryMsg { 28 | #[returns(crate::proposal::ProposalResponse)] 29 | Proposal { id: u32 }, 30 | #[returns(crate::config::Config)] 31 | Config {}, 32 | } 33 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/testing/execute.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::Addr; 2 | use cw_multi_test::{App, AppResponse, Executor}; 3 | use dao_cw721_extensions::roles::{ExecuteExt, MetadataExt}; 4 | 5 | use anyhow::Result as AnyResult; 6 | 7 | pub fn mint_nft( 8 | app: &mut App, 9 | cw721: &Addr, 10 | sender: &str, 11 | receiver: &str, 12 | token_id: &str, 13 | ) -> AnyResult { 14 | app.execute_contract( 15 | Addr::unchecked(sender), 16 | cw721.clone(), 17 | &cw721_base::ExecuteMsg::::Mint { 18 | token_id: token_id.to_string(), 19 | owner: receiver.to_string(), 20 | token_uri: None, 21 | extension: MetadataExt { 22 | role: Some("admin".to_string()), 23 | weight: 1, 24 | }, 25 | }, 26 | &[], 27 | ) 28 | } 29 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::Uint128; 3 | use dao_hooks::{proposal::ProposalHookMsg, stake::StakeChangedHookMsg, vote::VoteHookMsg}; 4 | 5 | #[cw_serde] 6 | pub struct InstantiateMsg { 7 | pub should_error: bool, // Debug flag to test when hooks fail over 8 | } 9 | 10 | #[cw_serde] 11 | pub enum ExecuteMsg { 12 | ProposalHook(ProposalHookMsg), 13 | StakeChangeHook(StakeChangedHookMsg), 14 | VoteHook(VoteHookMsg), 15 | } 16 | 17 | #[cw_serde] 18 | #[derive(QueryResponses)] 19 | pub enum QueryMsg { 20 | #[returns(Uint128)] 21 | StakeCounter {}, 22 | #[returns(u64)] 23 | VoteCounter {}, 24 | #[returns(u64)] 25 | ProposalCounter {}, 26 | #[returns(u64)] 27 | StatusChangedCounter {}, 28 | } 29 | 30 | #[cw_serde] 31 | pub struct CountResponse { 32 | pub count: u64, 33 | } 34 | -------------------------------------------------------------------------------- /packages/dao-hooks/README.md: -------------------------------------------------------------------------------- 1 | # DAO Hooks 2 | This package provides an interface for managing and dispatching proposal, 3 | staking, and voting related hooks. 4 | 5 | ### NFT Stake Hooks 6 | Staking hooks are fired when NFTs are staked or unstaked in a DAO. 7 | 8 | ### Proposal Hooks 9 | There are two types of proposal hooks: 10 | - **New Proposal Hook:** fired when a new proposal is created. 11 | - **Proposal Staus Changed Hook:** fired when a proposal's status changes. 12 | 13 | Our wiki contains more info on [Proposal Hooks](https://github.com/DA0-DA0/dao-contracts/wiki/Proposal-Hooks-Interactions). 14 | 15 | ### Stake Hooks 16 | Staking hooks are fired when tokens are staked or unstaked in a DAO. 17 | 18 | ### Vote Hooks 19 | Vote hooks are fired when new votes are cast. 20 | 21 | You can read more about vote hooks in our [wiki](https://github.com/DA0-DA0/dao-contracts/wiki/Proposal-Hooks-Interactions). 22 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_utils::ParseReplyError; 3 | use thiserror::Error; 4 | 5 | pub use cw_ownable::OwnershipError; 6 | pub use cw_utils::PaymentError; 7 | 8 | #[derive(Error, Debug, PartialEq)] 9 | pub enum ContractError { 10 | #[error("{0}")] 11 | Std(#[from] StdError), 12 | 13 | #[error(transparent)] 14 | Payment(#[from] PaymentError), 15 | 16 | #[error(transparent)] 17 | Ownership(#[from] OwnershipError), 18 | 19 | #[error(transparent)] 20 | ParseReply(#[from] ParseReplyError), 21 | 22 | #[error("Unauthorized")] 23 | Unauthorized {}, 24 | 25 | #[error("JSON serialization error: {err}")] 26 | JsonSerialization { err: String }, 27 | 28 | #[error("Unknown reply ID: {id}")] 29 | UnknownReplyID { id: u64 }, 30 | 31 | #[error("Missing protobuf registry")] 32 | MissingProtobufRegistry {}, 33 | } 34 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::Binary; 3 | use dao_dao_macros::voting_module_query; 4 | 5 | #[cw_serde] 6 | pub enum GroupContract { 7 | Existing { 8 | address: String, 9 | }, 10 | New { 11 | cw4_group_code_id: u64, 12 | /// Optionally instantiate the cw4 group via instantiate2 using this 13 | /// salt. 14 | cw4_group_salt: Option, 15 | initial_members: Vec, 16 | }, 17 | } 18 | 19 | #[cw_serde] 20 | pub struct InstantiateMsg { 21 | pub group_contract: GroupContract, 22 | } 23 | 24 | #[cw_serde] 25 | pub enum ExecuteMsg {} 26 | 27 | #[voting_module_query] 28 | #[cw_serde] 29 | #[derive(QueryResponses)] 30 | pub enum QueryMsg { 31 | #[returns(cosmwasm_std::Addr)] 32 | GroupContract {}, 33 | } 34 | 35 | #[cw_serde] 36 | pub struct MigrateMsg {} 37 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/schema/query_msg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "QueryMsg", 4 | "oneOf": [ 5 | { 6 | "type": "object", 7 | "required": [ 8 | "admin" 9 | ], 10 | "properties": { 11 | "admin": { 12 | "type": "object" 13 | } 14 | }, 15 | "additionalProperties": false 16 | }, 17 | { 18 | "type": "object", 19 | "required": [ 20 | "dao" 21 | ], 22 | "properties": { 23 | "dao": { 24 | "type": "object" 25 | } 26 | }, 27 | "additionalProperties": false 28 | }, 29 | { 30 | "type": "object", 31 | "required": [ 32 | "info" 33 | ], 34 | "properties": { 35 | "info": { 36 | "type": "object" 37 | } 38 | }, 39 | "additionalProperties": false 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /packages/dao-voting/src/duration.rs: -------------------------------------------------------------------------------- 1 | use cw_utils::Duration; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq, Eq)] 5 | pub enum UnstakingDurationError { 6 | #[error("Invalid unstaking duration, unstaking duration cannot be 0")] 7 | InvalidUnstakingDuration {}, 8 | } 9 | 10 | pub fn validate_duration(duration: Option) -> Result<(), UnstakingDurationError> { 11 | if let Some(unstaking_duration) = duration { 12 | match unstaking_duration { 13 | Duration::Height(height) => { 14 | if height == 0 { 15 | return Err(UnstakingDurationError::InvalidUnstakingDuration {}); 16 | } 17 | } 18 | Duration::Time(time) => { 19 | if time == 0 { 20 | return Err(UnstakingDurationError::InvalidUnstakingDuration {}); 21 | } 22 | } 23 | } 24 | } 25 | Ok(()) 26 | } 27 | -------------------------------------------------------------------------------- /ci/bootstrap-env/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bootstrap-env" 3 | version = "0.2.0" 4 | edition = { workspace = true } 5 | repository = { workspace = true } 6 | 7 | [target.'cfg(not(target_arch = "wasm32"))'.dependencies] 8 | cosm-orc = { workspace = true } 9 | cw20 = { workspace = true } 10 | cw-utils = { workspace = true } 11 | cosmwasm-std = { workspace = true, features = ["ibc3"] } 12 | cw-admin-factory = { workspace = true } 13 | dao-dao-core = { workspace = true } 14 | cw20-stake = { workspace = true } 15 | dao-voting-cw20-staked = { workspace = true } 16 | dao-proposal-single = { workspace = true } 17 | dao-pre-propose-single = { workspace = true } 18 | dao-interface = { workspace = true } 19 | dao-voting = { workspace = true } 20 | 21 | anyhow = { workspace = true } 22 | env_logger = { workspace = true } 23 | serde = { workspace = true, default-features = false, features = ["derive"] } 24 | serde_json = { workspace = true } 25 | serde_yaml = { workspace = true } 26 | -------------------------------------------------------------------------------- /contracts/external/cw-payroll-factory/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{StdError, Uint128}; 2 | use cw_ownable::OwnershipError; 3 | use cw_utils::{ParseReplyError, PaymentError}; 4 | use thiserror::Error; 5 | 6 | #[derive(Error, Debug, PartialEq)] 7 | pub enum ContractError { 8 | #[error("{0}")] 9 | Std(#[from] StdError), 10 | 11 | #[error(transparent)] 12 | Ownable(#[from] OwnershipError), 13 | 14 | #[error("{0}")] 15 | PaymentError(#[from] PaymentError), 16 | 17 | #[error("Unauthorized")] 18 | Unauthorized {}, 19 | 20 | #[error("{0}")] 21 | ParseReplyError(#[from] ParseReplyError), 22 | 23 | #[error("Got a submessage reply with unknown id: {id}")] 24 | UnknownReplyId { id: u64 }, 25 | 26 | #[error("reentered factory during payroll instantiation")] 27 | Reentrancy, 28 | 29 | #[error("vesting contract vests ({expected}) tokens, funded with ({sent})")] 30 | WrongFundAmount { sent: Uint128, expected: Uint128 }, 31 | } 32 | -------------------------------------------------------------------------------- /contracts/test/dao-test-custom-factory/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use cw_utils::{ParseReplyError, PaymentError}; 3 | use dao_voting::threshold::ActiveThresholdError; 4 | use thiserror::Error; 5 | 6 | #[derive(Error, Debug)] 7 | pub enum ContractError { 8 | #[error("{0}")] 9 | Std(#[from] StdError), 10 | 11 | #[error(transparent)] 12 | ActiveThresholdError(#[from] ActiveThresholdError), 13 | 14 | #[error(transparent)] 15 | ParseReplyError(#[from] ParseReplyError), 16 | 17 | #[error(transparent)] 18 | PaymentError(#[from] PaymentError), 19 | 20 | #[error("New NFT contract must be instantiated with at least one NFT")] 21 | NoInitialNfts {}, 22 | 23 | #[error("Unauthorized")] 24 | Unauthorized {}, 25 | 26 | #[error("Got a submessage reply with unknown id: {id}")] 27 | UnknownReplyId { id: u64 }, 28 | 29 | #[error("Factory message must serialize to WasmMsg::Execute")] 30 | UnsupportedFactoryMsg {}, 31 | } 32 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use std::env::current_dir; 2 | use std::fs::create_dir_all; 3 | 4 | use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; 5 | 6 | use dao_interface::voting::{ 7 | InfoResponse, TotalPowerAtHeightResponse, VotingPowerAtHeightResponse, 8 | }; 9 | use dao_voting_cw20_balance::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 10 | 11 | fn main() { 12 | let mut out_dir = current_dir().unwrap(); 13 | out_dir.push("schema"); 14 | create_dir_all(&out_dir).unwrap(); 15 | remove_schemas(&out_dir).unwrap(); 16 | 17 | export_schema(&schema_for!(InstantiateMsg), &out_dir); 18 | export_schema(&schema_for!(ExecuteMsg), &out_dir); 19 | export_schema(&schema_for!(QueryMsg), &out_dir); 20 | 21 | export_schema(&schema_for!(InfoResponse), &out_dir); 22 | export_schema(&schema_for!(TotalPowerAtHeightResponse), &out_dir); 23 | export_schema(&schema_for!(VotingPowerAtHeightResponse), &out_dir); 24 | } 25 | -------------------------------------------------------------------------------- /packages/dao-hooks/src/all_hooks.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cw4::MemberChangedHookMsg; 3 | 4 | use crate::nft_stake::NftStakeChangedHookMsg; 5 | use crate::proposal::{PreProposeHookMsg, ProposalHookMsg}; 6 | use crate::stake::StakeChangedHookMsg; 7 | use crate::vote::VoteHookMsg; 8 | 9 | /// An enum representing all possible DAO hooks. 10 | #[cw_serde] 11 | pub enum DaoHooks { 12 | /// Called when a member is added or removed 13 | /// to a cw4-groups or cw721-roles contract. 14 | MemberChangedHook(MemberChangedHookMsg), 15 | /// Called when NFTs are staked or unstaked. 16 | NftStakeChangeHook(NftStakeChangedHookMsg), 17 | /// Pre-propose hooks 18 | PreProposeHook(PreProposeHookMsg), 19 | /// Called when a proposal status changes. 20 | ProposalHook(ProposalHookMsg), 21 | /// Called when tokens are staked or unstaked. 22 | StakeChangeHook(StakeChangedHookMsg), 23 | /// Called when a vote is cast. 24 | VoteHook(VoteHookMsg), 25 | } 26 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/src/hooks.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Coin, DepsMut, Response}; 2 | 3 | use crate::error::ContractError; 4 | use crate::helpers::{check_is_not_denied, check_is_not_frozen}; 5 | 6 | /// The before send hook is called before every token transfer on chains that 7 | /// support MsgSetBeforeSendHook. 8 | /// 9 | /// It is called by the bank module. 10 | pub fn beforesend_hook( 11 | deps: DepsMut, 12 | from: String, 13 | to: String, 14 | coin: Coin, 15 | ) -> Result { 16 | // Assert that denom of this contract is not frozen 17 | // If it is frozen, check whether either 'from' or 'to' address is allowed 18 | check_is_not_frozen(deps.as_ref(), &from, &to, &coin.denom)?; 19 | 20 | // Assert that neither 'from' or 'to' address is denylist 21 | check_is_not_denied(deps.as_ref(), from)?; 22 | check_is_not_denied(deps.as_ref(), to)?; 23 | 24 | Ok(Response::new().add_attribute("action", "before_send")) 25 | } 26 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-proposal-sudo" 3 | authors = ["ekez "] 4 | description = "A proposal module that allows direct execution without voting." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | thiserror = { workspace = true } 25 | dao-dao-macros = { workspace = true } 26 | dao-interface = { workspace = true } 27 | 28 | [dev-dependencies] 29 | cw-multi-test = { workspace = true } 30 | -------------------------------------------------------------------------------- /contracts/external/cw-token-swap/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{StdError, Uint128}; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | 12 | #[error("Counterparties must have different addresses")] 13 | NonDistinctCounterparties {}, 14 | 15 | #[error("Can not provide funds more than once")] 16 | AlreadyProvided {}, 17 | 18 | #[error("Escrow funds have already been sent")] 19 | Complete {}, 20 | 21 | #[error("Must provide funds before withdrawing")] 22 | NoProvision {}, 23 | 24 | #[error("Can not create an escrow for zero tokens")] 25 | ZeroTokens {}, 26 | 27 | #[error("Provided funds do not match promised funds")] 28 | InvalidFunds {}, 29 | 30 | #[error("Invalid amount. Expected ({expected}), got ({actual})")] 31 | InvalidAmount { expected: Uint128, actual: Uint128 }, 32 | } 33 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-single/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, StdResult, Storage}; 2 | use cw_storage_plus::{Item, Map}; 3 | 4 | use dao_voting::{approval::ApprovalProposal, proposal::SingleChoiceProposeMsg}; 5 | 6 | pub type Proposal = ApprovalProposal; 7 | 8 | pub const APPROVER: Item = Item::new("approver"); 9 | pub const PENDING_PROPOSALS: Map = Map::new("pending_proposals"); 10 | pub const COMPLETED_PROPOSALS: Map = Map::new("completed_proposals"); 11 | pub const CREATED_PROPOSAL_TO_COMPLETED_PROPOSAL: Map = 12 | Map::new("created_to_completed_proposal"); 13 | 14 | /// Used internally to track the current approval_id. 15 | const CURRENT_ID: Item = Item::new("current_id"); 16 | 17 | pub(crate) fn advance_approval_id(store: &mut dyn Storage) -> StdResult { 18 | let id: u64 = CURRENT_ID.may_load(store)?.unwrap_or_default() + 1; 19 | CURRENT_ID.save(store, &id)?; 20 | Ok(id) 21 | } 22 | -------------------------------------------------------------------------------- /contracts/pre-propose/dao-pre-propose-approval-multiple/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, StdResult, Storage}; 2 | use cw_storage_plus::{Item, Map}; 3 | 4 | use dao_voting::{approval::ApprovalProposal, proposal::MultipleChoiceProposeMsg}; 5 | 6 | pub type Proposal = ApprovalProposal; 7 | 8 | pub const APPROVER: Item = Item::new("approver"); 9 | pub const PENDING_PROPOSALS: Map = Map::new("pending_proposals"); 10 | pub const COMPLETED_PROPOSALS: Map = Map::new("completed_proposals"); 11 | pub const CREATED_PROPOSAL_TO_COMPLETED_PROPOSAL: Map = 12 | Map::new("created_to_completed_proposal"); 13 | 14 | /// Used internally to track the current approval_id. 15 | const CURRENT_ID: Item = Item::new("current_id"); 16 | 17 | pub(crate) fn advance_approval_id(store: &mut dyn Storage) -> StdResult { 18 | let id: u64 = CURRENT_ID.may_load(store)?.unwrap_or_default() + 1; 19 | CURRENT_ID.save(store, &id)?; 20 | Ok(id) 21 | } 22 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/src/json_ops/op_existence.rs: -------------------------------------------------------------------------------- 1 | use crate::{json_ops::operator::OperatorContext, CwJsonFilter, FilterResult, ProtobufDecoder}; 2 | 3 | impl CwJsonFilter { 4 | pub fn handle_exists_op(&self, op_ctx: OperatorContext) -> FilterResult { 5 | match op_ctx.operator_arg { 6 | serde_json::Value::Bool(exists) => FilterResult::from_bool( 7 | *exists == op_ctx.value.is_some(), 8 | op_ctx.operator, 9 | match op_ctx.value.is_some() { 10 | true => "value exists", 11 | false => "value does not exist", 12 | }, 13 | op_ctx.filter_path, 14 | op_ctx.obj_path, 15 | ), 16 | _ => FilterResult::fatal_invalid_filter( 17 | format!("{} arg must be a boolean", op_ctx.operator), 18 | op_ctx.filter_path, 19 | op_ctx.obj_path, 20 | ), 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, Uint128, Uint256}; 3 | use cw20::Denom; 4 | 5 | use cw_storage_plus::{Item, Map}; 6 | 7 | #[cw_serde] 8 | pub struct Config { 9 | pub staking_contract: Addr, 10 | pub reward_token: Denom, 11 | } 12 | 13 | // `"config"` key stores v1 configuration. 14 | pub const CONFIG: Item = Item::new("config_v2"); 15 | 16 | #[cw_serde] 17 | pub struct RewardConfig { 18 | pub period_finish: u64, 19 | pub reward_rate: Uint128, 20 | pub reward_duration: u64, 21 | } 22 | pub const REWARD_CONFIG: Item = Item::new("reward_config"); 23 | 24 | pub const REWARD_PER_TOKEN: Item = Item::new("reward_per_token"); 25 | 26 | pub const LAST_UPDATE_BLOCK: Item = Item::new("last_update_block"); 27 | 28 | pub const PENDING_REWARDS: Map = Map::new("pending_rewards"); 29 | 30 | pub const USER_REWARD_PER_TOKEN: Map = Map::new("user_reward_per_token"); 31 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/schema/query_msg.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "QueryMsg", 4 | "oneOf": [ 5 | { 6 | "type": "object", 7 | "required": [ 8 | "vote_counter" 9 | ], 10 | "properties": { 11 | "vote_counter": { 12 | "type": "object" 13 | } 14 | }, 15 | "additionalProperties": false 16 | }, 17 | { 18 | "type": "object", 19 | "required": [ 20 | "proposal_counter" 21 | ], 22 | "properties": { 23 | "proposal_counter": { 24 | "type": "object" 25 | } 26 | }, 27 | "additionalProperties": false 28 | }, 29 | { 30 | "type": "object", 31 | "required": [ 32 | "status_changed_counter" 33 | ], 34 | "properties": { 35 | "status_changed_counter": { 36 | "type": "object" 37 | } 38 | }, 39 | "additionalProperties": false 40 | } 41 | ] 42 | } 43 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/schema/dao_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "DaoResponse", 4 | "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", 5 | "type": "string" 6 | } 7 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/schema/admin_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "AdminResponse", 4 | "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", 5 | "type": "string" 6 | } 7 | -------------------------------------------------------------------------------- /packages/dao-pre-propose-base/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Deps, StdResult}; 2 | 3 | /// validate addresses and add to and/or remove from an existing list of 4 | /// addresses, removing any duplicates. mutates the original list. 5 | pub fn add_and_remove_addresses( 6 | deps: Deps, 7 | list: &mut Vec, 8 | add: Option>, 9 | remove: Option>, 10 | ) -> StdResult<()> { 11 | if let Some(add) = add { 12 | let mut addrs = add 13 | .iter() 14 | .map(|addr| deps.api.addr_validate(addr)) 15 | .collect::>>()?; 16 | 17 | list.append(&mut addrs); 18 | list.sort(); 19 | list.dedup(); 20 | } 21 | 22 | if let Some(remove) = remove { 23 | let addrs = remove 24 | .iter() 25 | .map(|addr| deps.api.addr_validate(addr)) 26 | .collect::>>()?; 27 | 28 | list.retain(|a| !addrs.contains(a)); 29 | } 30 | 31 | Ok(()) 32 | } 33 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | 12 | #[error("Can not change the contract's token after it has been set")] 13 | DuplicateGroupContract {}, 14 | 15 | #[error("Cannot instantiate a group contract with duplicate initial members")] 16 | DuplicateMembers {}, 17 | 18 | #[error("Error occured whilst instantiating group contract")] 19 | GroupContractInstantiateError {}, 20 | 21 | #[error("Contract only supports queries")] 22 | NoExecute {}, 23 | 24 | #[error("Cannot instantiate or use a group contract with no initial members")] 25 | NoMembers {}, 26 | 27 | #[error("Got a submessage reply with unknown id: {id}")] 28 | UnknownReplyId { id: u64 }, 29 | 30 | #[error("Total weight of the CW4 contract cannot be zero")] 31 | ZeroTotalWeight {}, 32 | } 33 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error(transparent)] 7 | Std(#[from] StdError), 8 | #[error(transparent)] 9 | Ownable(#[from] cw_ownable::OwnershipError), 10 | #[error(transparent)] 11 | Cw20Error(#[from] cw20_base::ContractError), 12 | #[error("Staking change hook sender is not staking contract")] 13 | InvalidHookSender {}, 14 | #[error("No rewards claimable")] 15 | NoRewardsClaimable {}, 16 | #[error("Reward period not finished")] 17 | RewardPeriodNotFinished {}, 18 | #[error("Invalid funds")] 19 | InvalidFunds {}, 20 | #[error("Invalid Cw20")] 21 | InvalidCw20 {}, 22 | #[error("Reward rate less then one per block")] 23 | RewardRateLessThenOnePerBlock {}, 24 | #[error("Reward duration can not be zero")] 25 | ZeroRewardDuration {}, 26 | #[error("can not migrate. current version is up to date")] 27 | AlreadyMigrated {}, 28 | } 29 | -------------------------------------------------------------------------------- /packages/cw-tokenfactory-types/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-tokenfactory-types" 3 | authors = ["Noah Saso "] 4 | description = "A package for the handling of various tokenfactory types." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [features] 11 | default = ["osmosis_tokenfactory"] 12 | # use the /osmosis.tokenfactory... msg types 13 | osmosis_tokenfactory = [] 14 | # use the /cosmwasm.tokenfactory... msg types 15 | cosmwasm_tokenfactory = [] 16 | # use the /thorchain.denom.v1... msg types 17 | thorchain_tokenfactory = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | dao-interface = { workspace = true } 23 | osmosis-std = { workspace = true } 24 | osmosis-std-derive = { workspace = true } 25 | prost = { workspace = true } 26 | prost-types = { workspace = true } 27 | schemars = { workspace = true } 28 | serde = { workspace = true } 29 | serde-cw-value = { workspace = true } 30 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright 2025 JMARyA 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/src/json_ops/utils.rs: -------------------------------------------------------------------------------- 1 | use base64::{ 2 | alphabet, 3 | engine::{DecodePaddingMode, GeneralPurpose, GeneralPurposeConfig}, 4 | }; 5 | 6 | // Helper to reduce path allocations 7 | #[inline] 8 | pub fn append_path(base: &str, segment: &str) -> String { 9 | let mut path = String::with_capacity(base.len() + segment.len() + 1); 10 | path.push_str(base); 11 | path.push('.'); 12 | path.push_str(segment); 13 | path 14 | } 15 | 16 | #[inline] 17 | pub fn append_array_path(base: &str, index: usize) -> String { 18 | let mut path = String::with_capacity(base.len() + 10); // reasonable for most indices 19 | path.push_str(base); 20 | path.push('['); 21 | path.push_str(&index.to_string()); 22 | path.push(']'); 23 | path 24 | } 25 | 26 | /// Base64 decoding engine 27 | pub const BASE64_ENGINE: GeneralPurpose = GeneralPurpose::new( 28 | &alphabet::STANDARD, 29 | GeneralPurposeConfig::new() 30 | .with_decode_allow_trailing_bits(true) 31 | .with_decode_padding_mode(DecodePaddingMode::Indifferent), 32 | ); 33 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | 3 | use cosmwasm_std::Binary; 4 | use cw20::Cw20Coin; 5 | use cw20_base::msg::InstantiateMarketingInfo; 6 | 7 | use dao_dao_macros::{cw20_token_query, voting_module_query}; 8 | 9 | #[cw_serde] 10 | #[allow(clippy::large_enum_variant)] 11 | pub enum TokenInfo { 12 | Existing { 13 | address: String, 14 | }, 15 | New { 16 | code_id: u64, 17 | /// Optionally instantiate the token via instantiate2 using this salt. 18 | salt: Option, 19 | label: String, 20 | 21 | name: String, 22 | symbol: String, 23 | decimals: u8, 24 | initial_balances: Vec, 25 | marketing: Option, 26 | }, 27 | } 28 | 29 | #[cw_serde] 30 | pub struct InstantiateMsg { 31 | pub token_info: TokenInfo, 32 | } 33 | 34 | #[cw_serde] 35 | pub enum ExecuteMsg {} 36 | 37 | #[cw20_token_query] 38 | #[voting_module_query] 39 | #[cw_serde] 40 | #[derive(QueryResponses)] 41 | pub enum QueryMsg {} 42 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/examples/schema.rs: -------------------------------------------------------------------------------- 1 | use std::env::current_dir; 2 | use std::fs::create_dir_all; 3 | 4 | use cosmwasm_schema::{export_schema, export_schema_with_title, remove_schemas, schema_for}; 5 | use cosmwasm_std::Addr; 6 | use dao_interface::voting::InfoResponse; 7 | use dao_proposal_sudo::msg::{ExecuteMsg, InstantiateMsg, QueryMsg}; 8 | 9 | fn main() { 10 | let mut out_dir = current_dir().unwrap(); 11 | out_dir.push("schema"); 12 | create_dir_all(&out_dir).unwrap(); 13 | remove_schemas(&out_dir).unwrap(); 14 | 15 | export_schema(&schema_for!(InstantiateMsg), &out_dir); 16 | export_schema(&schema_for!(ExecuteMsg), &out_dir); 17 | export_schema(&schema_for!(QueryMsg), &out_dir); 18 | 19 | export_schema(&schema_for!(InfoResponse), &out_dir); 20 | 21 | // Auto TS code generation expects the query return type as QueryNameResponse 22 | // Here we map query resonses to the correct name 23 | export_schema_with_title(&schema_for!(Addr), &out_dir, "DaoResponse"); 24 | export_schema_with_title(&schema_for!(Addr), &out_dir, "AdminResponse"); 25 | } 26 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/schema/total_power_at_height_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "TotalPowerAtHeightResponse", 4 | "type": "object", 5 | "required": [ 6 | "height", 7 | "power" 8 | ], 9 | "properties": { 10 | "height": { 11 | "type": "integer", 12 | "format": "uint64", 13 | "minimum": 0.0 14 | }, 15 | "power": { 16 | "$ref": "#/definitions/Uint128" 17 | } 18 | }, 19 | "definitions": { 20 | "Uint128": { 21 | "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", 22 | "type": "string" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/schema/voting_power_at_height_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "VotingPowerAtHeightResponse", 4 | "type": "object", 5 | "required": [ 6 | "height", 7 | "power" 8 | ], 9 | "properties": { 10 | "height": { 11 | "type": "integer", 12 | "format": "uint64", 13 | "minimum": 0.0 14 | }, 15 | "power": { 16 | "$ref": "#/definitions/Uint128" 17 | } 18 | }, 19 | "definitions": { 20 | "Uint128": { 21 | "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", 22 | "type": "string" 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/dao-interface/src/proposal.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cw2::ContractVersion; 3 | 4 | #[cw_serde] 5 | pub struct InfoResponse { 6 | pub info: ContractVersion, 7 | } 8 | 9 | #[cw_serde] 10 | #[derive(QueryResponses)] 11 | pub enum Query { 12 | /// Returns the address of the DAO this module belongs to 13 | #[returns(::cosmwasm_std::Addr)] 14 | Dao {}, 15 | /// Returns contract version info 16 | #[returns(InfoResponse)] 17 | Info {}, 18 | /// Returns the proposal ID that will be assigned to the 19 | /// next proposal created. 20 | #[returns(::std::primitive::u64)] 21 | NextProposalId {}, 22 | } 23 | 24 | mod tests { 25 | /// Make sure the enum has all of the fields we expect. This will 26 | /// fail to compile if not. 27 | #[test] 28 | fn test_macro_expansion() { 29 | use super::Query; 30 | 31 | let query = Query::Info {}; 32 | 33 | match query { 34 | Query::Dao {} => (), 35 | Query::Info {} => (), 36 | Query::NextProposalId {} => (), 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-onft-staked/src/omniflix.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{CosmosMsg, Deps, StdError, StdResult}; 2 | use omniflix_std::types::omniflix::onft::v1beta1::{MsgTransferOnft, OnftQuerier}; 3 | 4 | pub fn query_onft_owner(deps: Deps, denom_id: &str, token_id: &str) -> StdResult { 5 | let res = OnftQuerier::new(&deps.querier).onft(denom_id.to_string(), token_id.to_string())?; 6 | let owner = res 7 | .onft 8 | .ok_or(StdError::generic_err("ONFT not found"))? 9 | .owner; 10 | 11 | Ok(owner) 12 | } 13 | 14 | pub fn query_onft_supply(deps: Deps, id: &str) -> StdResult { 15 | let res = OnftQuerier::new(&deps.querier).supply(id.to_string(), "".to_string())?; 16 | Ok(res.amount) 17 | } 18 | 19 | pub fn get_onft_transfer_msg( 20 | denom_id: &str, 21 | token_id: &str, 22 | sender: &str, 23 | recipient: &str, 24 | ) -> CosmosMsg { 25 | MsgTransferOnft { 26 | denom_id: denom_id.to_string(), 27 | id: token_id.to_string(), 28 | sender: sender.to_string(), 29 | recipient: recipient.to_string(), 30 | } 31 | .into() 32 | } 33 | -------------------------------------------------------------------------------- /contracts/external/cw-token-swap/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-token-swap" 3 | authors = ["ekez "] 4 | description = "A CosmWasm contract for swapping native and cw20 assets." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # For more explicit tests, `cargo test --features=backtraces`. 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # Use library feature to disable all instantiate/execute/query exports. 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw-utils = { workspace = true } 24 | cw2 = { workspace = true } 25 | cw20 = { workspace = true } 26 | thiserror = { workspace = true } 27 | 28 | [dev-dependencies] 29 | cw-token-swap = { workspace = true } 30 | cosmwasm-schema = { workspace = true } 31 | cw-multi-test = { workspace = true } 32 | cw20-base = { workspace = true } 33 | dao-testing = { workspace = true } 34 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-voting-cw20-balance" 3 | authors = ["ekez "] 4 | description = "A DAO DAO test contract." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | cw20 = { workspace = true } 25 | cw-utils = { workspace = true } 26 | thiserror = { workspace = true } 27 | dao-dao-macros = { workspace = true } 28 | dao-interface = { workspace = true } 29 | cw20-base = { workspace = true, features = ["library"] } 30 | 31 | [dev-dependencies] 32 | cw-multi-test = { workspace = true } 33 | dao-testing = { workspace = true } 34 | -------------------------------------------------------------------------------- /packages/dao-pre-propose-base/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-pre-propose-base" 3 | authors = ["ekez ekez@withoutdoing.com"] 4 | description = "A package for implementing pre-propose modules." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query WASM exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw2 = { workspace = true } 23 | cw-denom = { workspace = true } 24 | cw-storage-plus = { workspace = true } 25 | cw-utils = { workspace = true } 26 | cw-hooks = { workspace = true } 27 | dao-interface = { workspace = true } 28 | dao-voting = { workspace = true } 29 | serde = { workspace = true } 30 | thiserror = { workspace = true } 31 | semver = { workspace = true } 32 | 33 | [dev-dependencies] 34 | cw-multi-test = { workspace = true } 35 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::{Addr, Uint128}; 3 | use dao_interface::token::InitialBalance; 4 | 5 | #[cw_serde] 6 | pub struct InstantiateMsg {} 7 | 8 | #[cw_serde] 9 | pub enum ExecuteMsg { 10 | /// Issues a new fantoken. 11 | Issue(NewFanToken), 12 | } 13 | 14 | #[cw_serde] 15 | pub struct CreatingFanToken { 16 | /// Fan token info. 17 | pub token: NewFanToken, 18 | /// DAO address. 19 | pub dao: Addr, 20 | } 21 | 22 | #[cw_serde] 23 | pub struct NewFanToken { 24 | /// Fan token symbol. 25 | pub symbol: String, 26 | /// Fan token name. 27 | pub name: String, 28 | /// Fan token max supply. 29 | pub max_supply: Uint128, 30 | /// Fan token URI. 31 | pub uri: String, 32 | /// The initial balances to set for the token, cannot be empty. 33 | pub initial_balances: Vec, 34 | /// Optional balance to mint for the DAO. 35 | pub initial_dao_balance: Option, 36 | } 37 | 38 | #[cw_serde] 39 | #[derive(QueryResponses)] 40 | pub enum QueryMsg {} 41 | 42 | #[cw_serde] 43 | pub struct MigrateMsg {} 44 | -------------------------------------------------------------------------------- /packages/cw-paginate-storage/README.md: -------------------------------------------------------------------------------- 1 | # CosmWasm Map Pagination 2 | 3 | This package provides generic convienence methods for paginating keys 4 | and values in a CosmWasm `Map` or `SnapshotMap`. If you use these 5 | methods to paginate the maps in your contract you may [make larry0x 6 | happy](https://twitter.com/larry0x/status/1530537243709939719). 7 | 8 | ## Example 9 | 10 | Given a map like: 11 | 12 | ```rust 13 | use cw_storage_plus::Map; 14 | 15 | pub const ITEMS: Map = Map::new("items"); 16 | ``` 17 | 18 | You can use this package to write a query to list it's contents like: 19 | 20 | ```rust 21 | use cosmwasm_std::{Deps, Binary, to_json_binary, StdResult}; 22 | use cw_storage_plus::Map; 23 | use cw_paginate_storage::paginate_map; 24 | 25 | pub const ITEMS: Map = Map::new("items"); 26 | 27 | pub fn query_list_items( 28 | deps: Deps, 29 | start_after: Option, 30 | limit: Option, 31 | ) -> StdResult { 32 | to_json_binary(&paginate_map( 33 | deps, 34 | &ITEMS, 35 | start_after, 36 | limit, 37 | cosmwasm_std::Order::Descending, 38 | )?) 39 | } 40 | ``` 41 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/examples/range.rs: -------------------------------------------------------------------------------- 1 | use cw_jsonfilter::{CwJsonFilter, FilterResult}; 2 | use serde_json::{json, Value}; 3 | 4 | fn main() { 5 | let filter = json!({"age": { "$range": [18, 30] }}); 6 | // same as: 7 | // let filter = json!({"$and": [{"age": {"$gte": 18}}, {"age": {"$lte": 30}}]}); 8 | 9 | let obj1 = json!({"name": "John Doe", "age": 25}); 10 | let obj2 = json!({"name": "Alice Smith", "age": 35}); 11 | let obj3 = json!({"name": "Bob Brown", "age": 20}); 12 | 13 | println!("Filter:"); 14 | println!("{filter}"); 15 | println!("Objects:"); 16 | println!("Object 1: {obj1}"); 17 | println!("Object 2: {obj2}"); 18 | println!("Object 3: {obj3}"); 19 | 20 | match_objects(&filter, &obj1); 21 | match_objects(&filter, &obj2); 22 | match_objects(&filter, &obj3); 23 | } 24 | 25 | fn match_objects(filter: &Value, obj: &Value) { 26 | match CwJsonFilter::check(filter, obj) { 27 | FilterResult::Pass => println!("Filter matches the object"), 28 | FilterResult::Fail(err) => println!("Filter does not match the object: {err:?}"), 29 | FilterResult::Fatal(err) => println!("Fatal error: {err:?}"), 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-voting-cw4" 3 | authors = ["Callum Anderson "] 4 | description = "A DAO DAO voting module based on cw4 membership." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cw-storage-plus = { workspace = true } 22 | cw2 = { workspace = true } 23 | cw-utils = { workspace = true } 24 | cosmwasm-schema = { workspace = true } 25 | thiserror = { workspace = true } 26 | dao-dao-macros = { workspace = true } 27 | dao-interface = { workspace = true } 28 | cw4 = { workspace = true } 29 | cw4-group = { workspace = true, features = ["library"] } 30 | 31 | [dev-dependencies] 32 | dao-voting-cw4 = { workspace = true } 33 | cw-multi-test = { workspace = true } 34 | dao-testing = { workspace = true } 35 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-voting-cw721-roles" 3 | authors = ["Jake Hartnell"] 4 | description = "A DAO DAO voting module based on non-transferrable cw721 tokens." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | backtraces = ["cosmwasm-std/backtraces"] 15 | library = [] 16 | 17 | [dependencies] 18 | cosmwasm-std = { workspace = true } 19 | cosmwasm-schema = { workspace = true } 20 | cw-storage-plus = { workspace = true } 21 | dao-cw721-extensions = { workspace = true } 22 | dao-dao-macros = { workspace = true } 23 | dao-interface = { workspace = true } 24 | cw721-base = { workspace = true, features = ["library"] } 25 | cw-ownable = { workspace = true } 26 | cw721 = { workspace = true } 27 | cw-utils = { workspace = true } 28 | cw2 = { workspace = true } 29 | cw4 = { workspace = true } 30 | thiserror = { workspace = true } 31 | 32 | [dev-dependencies] 33 | cw-multi-test = { workspace = true } 34 | cw721-roles = { workspace = true } 35 | anyhow = { workspace = true } 36 | dao-testing = { workspace = true } 37 | -------------------------------------------------------------------------------- /packages/dao-dao-macros/tests/voting.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | 3 | use dao_dao_macros::voting_module_query; 4 | 5 | /// enum for testing. Important that this derives things / has other 6 | /// attributes so we can be sure we aren't messing with other macros 7 | /// with ours. 8 | #[voting_module_query] 9 | #[allow(dead_code)] 10 | #[cw_serde] 11 | #[derive(QueryResponses)] 12 | enum Test { 13 | #[returns(String)] 14 | Foo, 15 | #[returns(String)] 16 | Bar(u64), 17 | #[returns(String)] 18 | Baz { waldo: u64 }, 19 | } 20 | 21 | #[test] 22 | fn voting_module_query_derive() { 23 | let _test = Test::VotingPowerAtHeight { 24 | address: "foo".to_string(), 25 | height: Some(10), 26 | }; 27 | 28 | let test = Test::TotalPowerAtHeight { height: Some(10) }; 29 | 30 | // If this compiles we have won. 31 | match test { 32 | Test::Foo 33 | | Test::Bar(_) 34 | | Test::Baz { .. } 35 | | Test::TotalPowerAtHeight { height: _ } 36 | | Test::VotingPowerAtHeight { 37 | height: _, 38 | address: _, 39 | } 40 | | Test::Info {} => "yay", 41 | Test::Dao {} => "yay", 42 | }; 43 | } 44 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-sudo/schema/info_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "InfoResponse", 4 | "type": "object", 5 | "required": [ 6 | "info" 7 | ], 8 | "properties": { 9 | "info": { 10 | "$ref": "#/definitions/ContractVersion" 11 | } 12 | }, 13 | "definitions": { 14 | "ContractVersion": { 15 | "type": "object", 16 | "required": [ 17 | "contract", 18 | "version" 19 | ], 20 | "properties": { 21 | "contract": { 22 | "description": "contract is the crate name of the implementing contract, eg. `crate:cw20-base` we will use other prefixes for other languages, and their standard global namespacing", 23 | "type": "string" 24 | }, 25 | "version": { 26 | "description": "version is any string that this implementation knows. It may be simple counter \"1\", \"2\". or semantic version on release tags \"v0.7.0\", or some custom feature flag list. the only code that needs to understand the version parsing is code that knows how to migrate from the given contract (and is tied to it's implementation somehow)", 27 | "type": "string" 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/src/decoder.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, QuerierWrapper}; 2 | use cw_jsonfilter::ProtobufDecoder; 3 | use serde_json::Value; 4 | 5 | /// ProtobufDecoder implementing helper type that wraps around a 6 | /// cw querier and the registry address to enable cw-protobuf-registry 7 | /// decoding queries. 8 | pub struct WasmQuerierProtobufDecoder<'a> { 9 | querier: QuerierWrapper<'a>, 10 | registry_address: Addr, 11 | } 12 | 13 | impl<'a> WasmQuerierProtobufDecoder<'a> { 14 | pub fn new(querier: QuerierWrapper<'a>, registry_address: Addr) -> Self { 15 | Self { 16 | querier, 17 | registry_address, 18 | } 19 | } 20 | } 21 | 22 | impl ProtobufDecoder for WasmQuerierProtobufDecoder<'_> { 23 | fn decode(&self, message_name: String, value: Vec) -> Result { 24 | self.querier 25 | .query_wasm_smart::( 26 | &self.registry_address, 27 | &cw_protobuf_registry::msg::QueryMsg::Decode { 28 | message_name, 29 | value, 30 | }, 31 | ) 32 | .map(|r| r.value) 33 | .map_err(|e| e.to_string()) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use dao_voting::{error::VotingError, reply::error::TagError, threshold::ThresholdError}; 3 | use thiserror::Error; 4 | 5 | use crate::vote::VoteError; 6 | 7 | #[derive(Error, Debug)] 8 | pub enum ContractError { 9 | #[error(transparent)] 10 | Std(#[from] StdError), 11 | #[error(transparent)] 12 | InvalidVote(#[from] VoteError), 13 | #[error(transparent)] 14 | Threshold(#[from] ThresholdError), 15 | #[error(transparent)] 16 | Voting(#[from] VotingError), 17 | #[error(transparent)] 18 | Tag(#[from] TagError), 19 | 20 | #[error("non-zero voting power required to perform this action")] 21 | ZeroVotingPower {}, 22 | 23 | #[error("only proposals that are in the passed state may be executed")] 24 | Unexecutable {}, 25 | 26 | #[error("only rejected proposals may be closed")] 27 | Unclosable {}, 28 | 29 | #[error("only the DAO my perform this action")] 30 | NotDao {}, 31 | 32 | #[error("already voted")] 33 | Voted {}, 34 | 35 | #[error("only non-expired proposals may be voted on")] 36 | Expired {}, 37 | 38 | #[error("must specify at least one choice for proposal")] 39 | ZeroChoices {}, 40 | } 41 | -------------------------------------------------------------------------------- /contracts/test/dao-voting-cw20-balance/schema/info_response.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://json-schema.org/draft-07/schema#", 3 | "title": "InfoResponse", 4 | "type": "object", 5 | "required": [ 6 | "info" 7 | ], 8 | "properties": { 9 | "info": { 10 | "$ref": "#/definitions/ContractVersion" 11 | } 12 | }, 13 | "definitions": { 14 | "ContractVersion": { 15 | "type": "object", 16 | "required": [ 17 | "contract", 18 | "version" 19 | ], 20 | "properties": { 21 | "contract": { 22 | "description": "contract is the crate name of the implementing contract, eg. `crate:cw20-base` we will use other prefixes for other languages, and their standard global namespacing", 23 | "type": "string" 24 | }, 25 | "version": { 26 | "description": "version is any string that this implementation knows. It may be simple counter \"1\", \"2\". or semantic version on release tags \"v0.7.0\", or some custom feature flag list. the only code that needs to understand the version parsing is code that knows how to migrate from the given contract (and is tied to it's implementation somehow)", 27 | "type": "string" 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/examples/array.rs: -------------------------------------------------------------------------------- 1 | use cw_jsonfilter::{CwJsonFilter, FilterResult}; 2 | use serde_json::{json, Value}; 3 | 4 | fn main() { 5 | let filter = 6 | json!({"$or": [{"tags": {"$contains": "programming"}},{"tags": {"$contains": "rust"}}]}); 7 | 8 | let obj1 = json!({"name": "John Doe", "tags": ["rust", "programming", "development"]}); 9 | let obj2 = json!({"name": "Alice Smith", "tags": ["web", "development", "javascript"]}); 10 | let obj3 = json!({"name": "Bob Brown", "tags": ["python", "programming", "machine learning"]}); 11 | 12 | println!("Filter:"); 13 | println!("{filter}"); 14 | println!("Objects:"); 15 | println!("Object 1: {obj1}"); 16 | println!("Object 2: {obj2}"); 17 | println!("Object 3: {obj3}"); 18 | 19 | match_objects(&filter, &obj1); 20 | match_objects(&filter, &obj2); 21 | match_objects(&filter, &obj3); 22 | } 23 | 24 | fn match_objects(filter: &Value, obj: &Value) { 25 | match CwJsonFilter::check(filter, obj) { 26 | FilterResult::Pass => println!("Filter matches the object"), 27 | FilterResult::Fail(err) => println!("Filter does not match the object: {err:?}"), 28 | FilterResult::Fatal(err) => println!("Fatal error: {err:?}"), 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw20-staked/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-voting-cw20-staked" 3 | authors = ["Callum Anderson "] 4 | description = "A DAO DAO voting module based on staked cw20 tokens." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw-utils = { workspace = true } 24 | cw2 = { workspace = true } 25 | cw20 = { workspace = true } 26 | cw20-base = { workspace = true, features = ["library"] } 27 | cw20-stake = { workspace = true, features = ["library"] } 28 | thiserror = { workspace = true } 29 | dao-dao-macros = { workspace = true } 30 | dao-interface = { workspace = true } 31 | dao-voting = { workspace = true } 32 | 33 | [dev-dependencies] 34 | cw-multi-test = { workspace = true } 35 | dao-testing = { workspace = true } 36 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/tests/cases/tokenfactory_admin.rs: -------------------------------------------------------------------------------- 1 | use cw_tokenfactory_issuer::ContractError; 2 | use osmosis_test_tube::Account; 3 | 4 | use crate::test_env::{TestEnv, TokenfactoryIssuer}; 5 | 6 | #[test] 7 | fn transfer_token_factory_admin_by_contract_owner_should_pass() { 8 | let env = TestEnv::default(); 9 | let owner = &env.test_accs[0]; 10 | let new_admin = &env.test_accs[1]; 11 | let denom = env.cw_tokenfactory_issuer.query_denom().unwrap().denom; 12 | 13 | env.cw_tokenfactory_issuer 14 | .update_tokenfactory_admin(&new_admin.address(), owner) 15 | .unwrap(); 16 | 17 | assert_eq!(new_admin.address(), env.token_admin(&denom)); 18 | } 19 | 20 | #[test] 21 | fn transfer_token_factory_admin_by_non_contract_owner_should_fail() { 22 | let env = TestEnv::default(); 23 | let non_owner = &env.test_accs[1]; 24 | let someone_else = &env.test_accs[1]; 25 | 26 | let err = env 27 | .cw_tokenfactory_issuer 28 | .update_tokenfactory_admin(&someone_else.address(), non_owner) 29 | .unwrap_err(); 30 | 31 | assert_eq!( 32 | err, 33 | TokenfactoryIssuer::execute_error(ContractError::Ownership( 34 | cw_ownable::OwnershipError::NotOwner 35 | )) 36 | ) 37 | } 38 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, Uint128}; 2 | use cw_storage_plus::{Item, Map}; 3 | use cw_utils::Expiration; 4 | 5 | /// block height for distribution snapshot 6 | pub const DISTRIBUTION_HEIGHT: Item = Item::new("distribution_height"); 7 | /// period during which the contract can be funded 8 | /// exclusive of the expiration block 9 | pub const FUNDING_PERIOD_EXPIRATION: Item = Item::new("funding_period"); 10 | /// voting contract to determine the voting power 11 | pub const VOTING_CONTRACT: Item = Item::new("voting_contract"); 12 | /// total voting power at the distribution height 13 | pub const TOTAL_POWER: Item = Item::new("total_power"); 14 | 15 | /// maps token address to the amount being distributed 16 | pub const CW20_BALANCES: Map = Map::new("cw20_balances"); 17 | pub const NATIVE_BALANCES: Map = Map::new("native_balances"); 18 | 19 | /// maps (ADDRESS, TOKEN_ADDRESS) to amounts 20 | /// that have been claimed by the address 21 | pub const CW20_CLAIMS: Map<(Addr, Addr), Uint128> = Map::new("cw20_claims"); 22 | /// maps (ADDRESS, NATIVE_DENOM) to amounts 23 | /// that have been claimed by the address 24 | pub const NATIVE_CLAIMS: Map<(Addr, String), Uint128> = Map::new("native_claims"); 25 | -------------------------------------------------------------------------------- /contracts/external/cw-payroll-factory/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-payroll-factory" 3 | authors = ["Jake Hartnell"] 4 | description = "A CosmWasm factory contract for instantiating a payroll contract." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-denom = { workspace = true } 23 | cw-ownable = { workspace = true } 24 | cw-storage-plus = { workspace = true } 25 | cw2 = { workspace = true } 26 | cw20 = { workspace = true } 27 | thiserror = { workspace = true } 28 | cw-vesting = { workspace = true, features = ["library"] } 29 | cw-utils = { workspace = true } 30 | 31 | [dev-dependencies] 32 | cw-payroll-factory = { workspace = true } 33 | cw-multi-test = { workspace = true } 34 | cw20-base = { workspace = true, features = ["library"] } 35 | dao-testing = { workspace = true } 36 | wynd-utils = { workspace = true } 37 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/src/config.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cw_utils::Duration; 3 | use dao_voting::{ 4 | threshold::{validate_quorum, PercentageThreshold}, 5 | voting::validate_voting_period, 6 | }; 7 | 8 | use crate::ContractError; 9 | 10 | #[cw_serde] 11 | pub struct UncheckedConfig { 12 | pub quorum: PercentageThreshold, 13 | pub voting_period: Duration, 14 | pub min_voting_period: Option, 15 | pub close_proposals_on_execution_failure: bool, 16 | } 17 | 18 | #[cw_serde] 19 | pub(crate) struct Config { 20 | pub quorum: PercentageThreshold, 21 | pub voting_period: Duration, 22 | pub min_voting_period: Option, 23 | pub close_proposals_on_execution_failure: bool, 24 | } 25 | 26 | impl UncheckedConfig { 27 | pub(crate) fn into_checked(self) -> Result { 28 | validate_quorum(&self.quorum)?; 29 | let (min_voting_period, voting_period) = 30 | validate_voting_period(self.min_voting_period, self.voting_period)?; 31 | Ok(Config { 32 | quorum: self.quorum, 33 | close_proposals_on_execution_failure: self.close_proposals_on_execution_failure, 34 | voting_period, 35 | min_voting_period, 36 | }) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, Uint128}; 3 | use cw_controllers::Claims; 4 | use cw_hooks::Hooks; 5 | use cw_storage_plus::{Item, SnapshotItem, SnapshotMap, Strategy}; 6 | use cw_utils::Duration; 7 | 8 | #[cw_serde] 9 | pub struct Config { 10 | pub token_address: Addr, 11 | pub unstaking_duration: Option, 12 | } 13 | 14 | // `"config"` key stores v1 configuration. 15 | pub const CONFIG: Item = Item::new("config_v2"); 16 | 17 | pub const STAKED_BALANCES: SnapshotMap<&Addr, Uint128> = SnapshotMap::new( 18 | "staked_balances", 19 | "staked_balance__checkpoints", 20 | "staked_balance__changelog", 21 | Strategy::EveryBlock, 22 | ); 23 | 24 | pub const STAKED_TOTAL: SnapshotItem = SnapshotItem::new( 25 | "total_staked", 26 | "total_staked__checkpoints", 27 | "total_staked__changelog", 28 | Strategy::EveryBlock, 29 | ); 30 | 31 | /// The maximum number of claims that may be outstanding. 32 | pub const MAX_CLAIMS: u64 = 100; 33 | 34 | pub const CLAIMS: Claims = Claims::new("claims"); 35 | 36 | pub const BALANCE: Item = Item::new("balance"); 37 | 38 | // Hooks to contracts that will receive staking and unstaking messages 39 | pub const HOOKS: Hooks = Hooks::new("hooks"); 40 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw20-stake-reward-distributor" 3 | edition = "2018" 4 | authors = [ 5 | "Vernon Johnson , ekez ", 6 | ] 7 | description = "Distributes cw20 staking rewards." 8 | license = { workspace = true } 9 | repository = { workspace = true } 10 | version = { workspace = true } 11 | 12 | 13 | [lib] 14 | crate-type = ["cdylib", "rlib"] 15 | 16 | [features] 17 | # for more explicit tests, cargo test --features=backtraces 18 | backtraces = ["cosmwasm-std/backtraces"] 19 | # use library feature to disable all instantiate/execute/query exports 20 | library = [] 21 | 22 | [dependencies] 23 | cosmwasm-std = { workspace = true } 24 | cosmwasm-schema = { workspace = true } 25 | cw-storage-plus = { workspace = true } 26 | cw2 = { workspace = true } 27 | cw20 = { workspace = true } 28 | cw-utils = { workspace = true } 29 | cw20-base = { workspace = true, features = ["library"] } 30 | cw20-stake = { workspace = true, features = ["library"] } 31 | thiserror = { workspace = true } 32 | cw-ownable = { workspace = true } 33 | cw20-stake-reward-distributor-v1 = { workspace = true, features = ["library"] } 34 | 35 | [dev-dependencies] 36 | cw20-stake-reward-distributor = { workspace = true } 37 | cw-multi-test = { workspace = true } 38 | dao-testing = { workspace = true } 39 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-fund-distributor" 3 | authors = ["bekauz "] 4 | description = "A CosmWasm contract for distributing funds to DAO members based on voting power." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-schema = { workspace = true } 21 | cosmwasm-std = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | cw20 = { workspace = true } 25 | thiserror = { workspace = true } 26 | cw-utils = { workspace = true } 27 | dao-voting-cw20-staked = { workspace = true } 28 | cw20-stake = { workspace = true, features = ["library"] } 29 | dao-interface = { workspace = true } 30 | cw-paginate-storage = { workspace = true } 31 | 32 | [dev-dependencies] 33 | dao-dao-core = { workspace = true, features = ["library"] } 34 | dao-testing = { workspace = true } 35 | cw-multi-test = { workspace = true } 36 | cw20-base = { workspace = true, features = ["library"] } 37 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name ="dao-proposal-condorcet" 3 | authors = ["ekez "] 4 | description = "A DAO DAO proposal module with ranked-choice, Condorcet voting." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | cw-utils = { workspace = true } 25 | dao-voting = { workspace = true } 26 | dao-dao-macros = { workspace = true } 27 | dao-interface = { workspace = true } 28 | thiserror = { workspace = true } 29 | 30 | [dev-dependencies] 31 | cosmwasm-schema = { workspace = true } 32 | cw-multi-test = { workspace = true } 33 | dao-dao-core = { workspace = true, features = ["library"] } 34 | dao-testing = { workspace = true } 35 | dao-voting-cw4 = { workspace = true } 36 | cw4-group = { workspace = true } 37 | cw4 = { workspace = true } 38 | anyhow = { workspace = true } 39 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-reward-distributor/src/msg.rs: -------------------------------------------------------------------------------- 1 | use crate::state::Config; 2 | use cosmwasm_schema::{cw_serde, QueryResponses}; 3 | use cosmwasm_std::Uint128; 4 | 5 | use cw_ownable::cw_ownable_execute; 6 | 7 | // so that consumers don't need a cw_ownable dependency to consume 8 | // this contract's queries. 9 | pub use cw_ownable::Ownership; 10 | 11 | #[cw_serde] 12 | pub struct InstantiateMsg { 13 | pub owner: String, 14 | pub staking_addr: String, 15 | pub reward_rate: Uint128, 16 | pub reward_token: String, 17 | } 18 | 19 | #[cw_ownable_execute] 20 | #[cw_serde] 21 | pub enum ExecuteMsg { 22 | UpdateConfig { 23 | staking_addr: String, 24 | reward_rate: Uint128, 25 | reward_token: String, 26 | }, 27 | Distribute {}, 28 | Withdraw {}, 29 | } 30 | 31 | #[cw_serde] 32 | #[derive(QueryResponses)] 33 | pub enum QueryMsg { 34 | #[returns(InfoResponse)] 35 | Info {}, 36 | 37 | #[returns(::cw_ownable::Ownership<::cosmwasm_std::Addr>)] 38 | Ownership {}, 39 | } 40 | 41 | #[cw_serde] 42 | pub struct InfoResponse { 43 | pub config: Config, 44 | pub last_payment_block: u64, 45 | pub balance: Uint128, 46 | } 47 | 48 | #[cw_serde] 49 | pub enum MigrateMsg { 50 | /// Updates the contract from v1 -> v2. Version two implements a 51 | /// two step ownership transfer. 52 | FromV1 {}, 53 | } 54 | -------------------------------------------------------------------------------- /contracts/test/dao-proposal-hook-counter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-proposal-hook-counter" 3 | authors = ["Callum Anderson "] 4 | description = "A DAO DAO test contract for counting proposal hook calls." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | thiserror = { workspace = true } 25 | dao-hooks = { workspace = true } 26 | 27 | [dev-dependencies] 28 | cw-hooks = { workspace = true } 29 | cw20 = { workspace = true } 30 | dao-voting-cw20-balance = { workspace = true } 31 | cw20-base = { workspace = true } 32 | cw-utils = { workspace = true } 33 | dao-voting = { workspace = true } 34 | dao-interface = { workspace = true } 35 | dao-dao-core = { workspace = true } 36 | dao-proposal-single = { workspace = true } 37 | cw-multi-test = { workspace = true } 38 | dao-testing = { workspace = true } 39 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw4/README.md: -------------------------------------------------------------------------------- 1 | # CW4 Group Voting 2 | 3 | [![dao-voting-cw4 on crates.io](https://img.shields.io/crates/v/dao-voting-cw4.svg?logo=rust)](https://crates.io/crates/dao-voting-cw4) 4 | [![docs.rs](https://img.shields.io/docsrs/dao-voting-cw4?logo=docsdotrs)](https://docs.rs/dao-voting-cw4/latest/dao_voting_cw4/) 5 | 6 | A simple voting power module which determines voting power based on 7 | the weight of a user in a cw4-group contract. This allocates voting 8 | power in the same way that one would expect a multisig to. 9 | 10 | This contract implements the interface needed to be a DAO 11 | DAO [voting 12 | module](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design#the-voting-module). 13 | For more information about how these modules fit together see 14 | [this](https://github.com/DA0-DA0/dao-contracts/wiki/DAO-DAO-Contracts-Design) 15 | wiki page. 16 | 17 | ## Receiving updates 18 | 19 | This contract does not make subqueries to the cw4-group contract to 20 | get an addresses voting power. Instead, it listens for 21 | `MemberChangedHook` messages from said contract and caches voting 22 | power locally. 23 | 24 | As the DAO is the admin of the underlying cw4-group contract it is 25 | important that the DAO does not remove this contract from that 26 | contract's list of hook receivers. Doing so will cause this contract 27 | to stop receiving voting power updates. 28 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake-external-rewards/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw20-stake-external-rewards" 3 | authors = ["Ben2x4 ", "ekez "] 4 | edition = "2018" 5 | description = "Distributes staking rewards." 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | backtraces = ["cosmwasm-std/backtraces"] 15 | # use library feature to disable all instantiate/execute/query exports 16 | library = [] 17 | 18 | [dependencies] 19 | cosmwasm-std = { workspace = true } 20 | cosmwasm-schema = { workspace = true } 21 | cw-storage-plus = { workspace = true } 22 | cw-controllers = { workspace = true } 23 | cw20 = { workspace = true } 24 | cw-utils = { workspace = true } 25 | cw20-base = { workspace = true, features = ["library"] } 26 | cw2 = { workspace = true } 27 | thiserror = { workspace = true } 28 | cw20-stake = { workspace = true, features = ["library"] } 29 | cw-ownable = { workspace = true } 30 | dao-hooks = { workspace = true } 31 | 32 | cw20-stake-external-rewards-v1 = { workspace = true } 33 | cw20-013 = { package = "cw20", version = "0.13" } 34 | 35 | [dev-dependencies] 36 | cw20-stake-external-rewards = { workspace = true } 37 | cw-multi-test = { workspace = true } 38 | anyhow = { workspace = true } 39 | dao-testing = { workspace = true } 40 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::{Addr, StdError}; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug, PartialEq)] 5 | pub enum ContractError { 6 | #[error(transparent)] 7 | Std(#[from] StdError), 8 | 9 | #[error(transparent)] 10 | Cw20Error(#[from] cw20_base::ContractError), 11 | 12 | #[error(transparent)] 13 | Ownership(#[from] cw_ownable::OwnershipError), 14 | 15 | #[error(transparent)] 16 | HookError(#[from] cw_hooks::HookError), 17 | 18 | #[error(transparent)] 19 | UnstakingDurationError(#[from] dao_voting::duration::UnstakingDurationError), 20 | 21 | #[error("can not migrate. current version is up to date")] 22 | AlreadyMigrated {}, 23 | 24 | #[error("Unstaking this amount violates the invariant: (cw20 total_supply <= 2^128)")] 25 | Cw20InvaraintViolation {}, 26 | 27 | #[error("Can not unstake more than has been staked")] 28 | ImpossibleUnstake {}, 29 | 30 | #[error("Provided cw20 errored in response to TokenInfo query")] 31 | InvalidCw20 {}, 32 | 33 | #[error("Invalid token")] 34 | InvalidToken { received: Addr, expected: Addr }, 35 | 36 | #[error("Nothing to claim")] 37 | NothingToClaim {}, 38 | 39 | #[error("Nothing to unstake")] 40 | NothingStaked {}, 41 | 42 | #[error("Too many outstanding claims. Claim some tokens before unstaking more.")] 43 | TooManyClaims {}, 44 | } 45 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw20-staked/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use thiserror::Error; 3 | 4 | #[derive(Error, Debug)] 5 | pub enum ContractError { 6 | #[error("{0}")] 7 | Std(#[from] StdError), 8 | 9 | #[error("Unauthorized")] 10 | Unauthorized {}, 11 | 12 | #[error("Initial governance token balances must not be empty")] 13 | InitialBalancesError {}, 14 | 15 | #[error("Can not change the contract's token after it has been set")] 16 | DuplicateToken {}, 17 | 18 | #[error("Error instantiating token")] 19 | TokenInstantiateError {}, 20 | 21 | #[error("Error instantiating staking contract")] 22 | StakingInstantiateError {}, 23 | 24 | #[error("Got a submessage reply with unknown id: {id}")] 25 | UnknownReplyId { id: u64 }, 26 | 27 | #[error("Staking contract token address does not match provided token address")] 28 | StakingContractMismatch {}, 29 | 30 | #[error("Can not change the contract's staking contract after it has been set")] 31 | DuplicateStakingContract {}, 32 | 33 | #[error("Active threshold percentage must be greater than 0 and less than 1")] 34 | InvalidActivePercentage {}, 35 | 36 | #[error("Active threshold count must be greater than zero")] 37 | ZeroActiveCount {}, 38 | 39 | #[error("Absolute count threshold cannot be greater than the total token supply")] 40 | InvalidAbsoluteCount {}, 41 | } 42 | -------------------------------------------------------------------------------- /contracts/dao-dao-core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-dao-core" 3 | authors = ["ekez "] 4 | description = "A DAO DAO core module." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true, features = ["ibc3"] } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | cw-utils = { workspace = true } 25 | cw20 = { workspace = true } 26 | cw721 = { workspace = true } 27 | thiserror = { workspace = true } 28 | dao-interface = { workspace = true } 29 | dao-dao-macros = { workspace = true } 30 | cw-paginate-storage = { workspace = true } 31 | cw-core-v1 = { workspace = true, features = ["library"] } 32 | 33 | [dev-dependencies] 34 | dao-dao-core = { workspace = true } 35 | cw-multi-test = { workspace = true } 36 | cw20-base = { workspace = true } 37 | cw721-base = { workspace = true } 38 | dao-proposal-sudo = { workspace = true } 39 | dao-testing = { workspace = true } 40 | dao-voting-cw20-balance = { workspace = true } 41 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-protobuf-registry" 3 | authors = ["Noah Saso "] 4 | description = "A protobuf registry that handles decoding protobuf messages." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | dao-interface = { workspace = true } 24 | thiserror = { workspace = true } 25 | cw-utils = { workspace = true } 26 | cw-ownable = { workspace = true } 27 | schemars = { workspace = true } 28 | serde = { workspace = true } 29 | serde_json = { workspace = true } 30 | cw2 = { workspace = true } 31 | prost = { workspace = true } 32 | prost-reflect = { workspace = true, features = ["serde"] } 33 | prost-types = { workspace = true } 34 | base64 = { workspace = true } 35 | 36 | [dev-dependencies] 37 | cw-multi-test = { workspace = true } 38 | cw-protobuf-registry = { workspace = true } 39 | dao-testing = { workspace = true } 40 | -------------------------------------------------------------------------------- /contracts/staking/cw20-stake/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw20-stake" 3 | authors = ["Ben2x4 "] 4 | description = "CW20 token that can be staked and staked balance can be queried at any height" 5 | edition = "2018" 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | backtraces = ["cosmwasm-std/backtraces"] 15 | # use library feature to disable all instantiate/execute/query exports 16 | library = [] 17 | 18 | [dependencies] 19 | cosmwasm-std = { workspace = true } 20 | cosmwasm-schema = { workspace = true } 21 | cw-storage-plus = { workspace = true } 22 | cw-controllers = { workspace = true } 23 | cw-hooks = { workspace = true } 24 | cw20 = { workspace = true } 25 | cw-utils = { workspace = true } 26 | cw20-base = { workspace = true, features = ["library"] } 27 | cw2 = { workspace = true } 28 | thiserror = { workspace = true } 29 | cw-paginate-storage = { workspace = true } 30 | cw-ownable = { workspace = true } 31 | dao-hooks = { workspace = true } 32 | dao-voting = { workspace = true } 33 | 34 | cw20-stake-v1 = { workspace = true, features = ["library"] } 35 | cw-utils-v1 = { workspace = true } 36 | 37 | [dev-dependencies] 38 | cw20-stake = { workspace = true } 39 | cw-multi-test = { workspace = true } 40 | anyhow = { workspace = true } 41 | dao-testing = { workspace = true } 42 | -------------------------------------------------------------------------------- /contracts/external/cw721-roles/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw721-roles" 3 | authors = ["Jake Hartnell"] 4 | description = "Non-transferable CW721 NFT contract that incorporates voting weights and on-chain roles." 5 | version = { workspace = true } 6 | edition = { workspace = true } 7 | repository = { workspace = true } 8 | license = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-schema = { workspace = true } 21 | cosmwasm-std = { workspace = true } 22 | cw-controllers = { workspace = true } 23 | cw-ownable = { workspace = true } 24 | cw-storage-plus = { workspace = true } 25 | cw-utils = { workspace = true } 26 | cw2 = { workspace = true } 27 | cw4 = { workspace = true } 28 | cw721 = { workspace = true } 29 | cw721-base = { workspace = true, features = ["library"] } 30 | dao-cw721-extensions = { workspace = true } 31 | serde = { workspace = true } 32 | thiserror = { workspace = true } 33 | 34 | [dev-dependencies] 35 | cw-multi-test = { workspace = true } 36 | dao-testing = { workspace = true } 37 | dao-voting-cw721-staked = { workspace = true } 38 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-multiple/src/query.rs: -------------------------------------------------------------------------------- 1 | use crate::{proposal::MultipleChoiceProposal, state::Config}; 2 | use cosmwasm_schema::cw_serde; 3 | use cosmwasm_std::{Addr, Uint128}; 4 | 5 | use dao_voting::multiple_choice::MultipleChoiceVote; 6 | 7 | #[cw_serde] 8 | pub struct ProposalListResponse { 9 | pub proposals: Vec, 10 | } 11 | 12 | /// Information about a proposal returned by proposal queries. 13 | #[cw_serde] 14 | pub struct ProposalResponse { 15 | pub id: u64, 16 | pub proposal: MultipleChoiceProposal, 17 | } 18 | 19 | /// Information about a vote that was cast. 20 | #[cw_serde] 21 | pub struct VoteInfo { 22 | /// The address that voted. 23 | pub voter: Addr, 24 | /// Position on the vote. 25 | pub vote: MultipleChoiceVote, 26 | /// The voting power behind the vote. 27 | pub power: Uint128, 28 | /// The individual voting power behind the vote (excluding delegation). 29 | pub individual_power: Uint128, 30 | /// The rationale behind the vote. 31 | pub rationale: Option, 32 | } 33 | 34 | #[cw_serde] 35 | pub struct VoteResponse { 36 | pub vote: Option, 37 | } 38 | 39 | #[cw_serde] 40 | pub struct VoteListResponse { 41 | pub votes: Vec, 42 | } 43 | 44 | #[cw_serde] 45 | pub struct VoterResponse { 46 | pub weight: Option, 47 | } 48 | 49 | #[cw_serde] 50 | pub struct ConfigResponse { 51 | pub config: Config, 52 | } 53 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-single/src/query.rs: -------------------------------------------------------------------------------- 1 | use crate::proposal::SingleChoiceProposal; 2 | use cosmwasm_schema::cw_serde; 3 | use cosmwasm_std::{Addr, Uint128}; 4 | use dao_voting::voting::Vote; 5 | 6 | /// Information about a proposal returned by proposal queries. 7 | #[cw_serde] 8 | pub struct ProposalResponse { 9 | /// The ID of the proposal being returned. 10 | pub id: u64, 11 | pub proposal: SingleChoiceProposal, 12 | } 13 | 14 | /// Information about a vote that was cast. 15 | #[cw_serde] 16 | pub struct VoteInfo { 17 | /// The address that voted. 18 | pub voter: Addr, 19 | /// Position on the vote. 20 | pub vote: Vote, 21 | /// The voting power behind the vote. 22 | pub power: Uint128, 23 | /// The individual voting power behind the vote (excluding delegation). 24 | pub individual_power: Uint128, 25 | /// Address-specified rationale for the vote. 26 | pub rationale: Option, 27 | } 28 | 29 | /// Information about a vote. 30 | #[cw_serde] 31 | pub struct VoteResponse { 32 | /// None if no such vote, Some otherwise. 33 | pub vote: Option, 34 | } 35 | 36 | /// Information about the votes for a proposal. 37 | #[cw_serde] 38 | pub struct VoteListResponse { 39 | pub votes: Vec, 40 | } 41 | 42 | /// A list of proposals returned by `ListProposals` and 43 | /// `ReverseProposals`. 44 | #[cw_serde] 45 | pub struct ProposalListResponse { 46 | pub proposals: Vec, 47 | } 48 | -------------------------------------------------------------------------------- /contracts/external/cw-filter/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cw-filter" 3 | authors = ["Noah Saso "] 4 | description = "A contract that filters messages based on a JSON filter." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true, features = ["cosmwasm_1_2"] } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw-jsonfilter = { workspace = true } 24 | dao-interface = { workspace = true } 25 | thiserror = { workspace = true } 26 | cw-utils = { workspace = true } 27 | cw-ownable = { workspace = true } 28 | schemars = { workspace = true } 29 | serde = { workspace = true } 30 | serde_json = { workspace = true } 31 | cw2 = { workspace = true } 32 | cw-protobuf-registry = { workspace = true, features = ["library"] } 33 | 34 | [dev-dependencies] 35 | cw-filter = { workspace = true, features = ["library"] } 36 | cw-multi-test = { workspace = true } 37 | dao-testing = { workspace = true } 38 | prost = { workspace = true } 39 | prost-reflect = { workspace = true, features = ["serde"] } 40 | prost-types = { workspace = true } 41 | -------------------------------------------------------------------------------- /.github/workflows/codecov.yml: -------------------------------------------------------------------------------- 1 | # From: https://github.com/codecov/example-rust/blob/main/.github/workflows/rust.yml 2 | name: Coverage 3 | 4 | on: 5 | - push 6 | 7 | env: 8 | CARGO_TERM_COLOR: always 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Free Disk Space (Ubuntu) 17 | uses: jlumbroso/free-disk-space@main 18 | with: 19 | tool-cache: false 20 | android: true 21 | dotnet: true 22 | haskell: true 23 | large-packages: false 24 | docker-images: true 25 | swap-storage: true 26 | - uses: actions-rs/toolchain@v1 27 | with: 28 | toolchain: stable 29 | override: true 30 | components: llvm-tools-preview 31 | - name: cargo install cargo-llvm-cov 32 | run: cargo install cargo-llvm-cov 33 | - name: cargo llvm-cov 34 | run: cargo llvm-cov --workspace --lcov --output-path lcov.info 35 | - name: Codecov 36 | # You may pin to the exact commit or the version. 37 | # uses: codecov/codecov-action@81cd2dc8148241f03f5839d295e000b8f761e378 38 | uses: codecov/codecov-action@v3 39 | with: 40 | # Repository upload token - get it from codecov.io. 41 | token: ${{ secrets.CODECOV_TOKEN }} 42 | # Specify whether the Codecov output should be verbose 43 | verbose: true 44 | fail_ci_if_error: true 45 | -------------------------------------------------------------------------------- /ci/configs/test_accounts.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "user1", 4 | "address": "juno10j9gpw9t4jsz47qgnkvl5n3zlm2fz72k67rxsg", 5 | "mnemonic": "siren window salt bullet cream letter huge satoshi fade shiver permit offer happy immense wage fitness goose usual aim hammer clap about super trend" 6 | }, 7 | { 8 | "name": "user2", 9 | "address": "juno1v9xynggs6vnrv2x5ufxdj398u2ghc5n9ya57ea", 10 | "mnemonic": "devote vast fashion hat flat ensure earth abandon gesture erode member few common lonely sword rapid police fury another surround dragon purse swear patch" 11 | }, 12 | { 13 | "name": "user3", 14 | "address": "juno1965jgwxjp39sz2urty8r2khjdyy8dgt78kzfj6", 15 | "mnemonic": "vessel utility occur solid post dry now blush federal bonus fiscal differ mesh puppy sock cloud diagram fence silk shield bless spring ordinary banana" 16 | }, 17 | { 18 | "name": "user4", 19 | "address": "juno1zn6psr8ngkagj3wmt0830y97s2uae6eazgnnsa", 20 | "mnemonic": "finger attitude bargain drop nephew hunt try spring link swamp submit devote forget canvas whisper almost typical photo evoke width penalty start frost strategy" 21 | }, 22 | { 23 | "name": "user5", 24 | "address": "juno1d64uqyvwzsr6wz5aw9p8rt08jya78xpjdxxaa5", 25 | "mnemonic": "record regular they cupboard someone mutual marble evil swamp bread expire pioneer casual pitch help road hard survey unfold false decrease material bargain youth" 26 | } 27 | ] -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "btsg-ft-factory" 3 | authors = ["noah "] 4 | description = "A CosmWasm factory contract for issuing fantokens on BitSong." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | # for more explicit tests, cargo test --features=backtraces 15 | backtraces = ["cosmwasm-std/backtraces"] 16 | # use library feature to disable all instantiate/execute/query exports 17 | library = [] 18 | 19 | [dependencies] 20 | cosmwasm-std = { workspace = true } 21 | cosmwasm-schema = { workspace = true } 22 | cw-storage-plus = { workspace = true } 23 | cw2 = { workspace = true } 24 | dao-interface = { workspace = true } 25 | osmosis-std-derive = { workspace = true } 26 | prost = { workspace = true } 27 | prost-types = { workspace = true } 28 | schemars = { workspace = true } 29 | serde = { workspace = true } 30 | thiserror = { workspace = true } 31 | 32 | [dev-dependencies] 33 | anyhow = { workspace = true } 34 | cosmwasm-schema = { workspace = true } 35 | cw-multi-test = { workspace = true } 36 | cw-utils = { workspace = true } 37 | dao-dao-core = { workspace = true, features = ["library"] } 38 | dao-proposal-single = { workspace = true, features = ["library"] } 39 | dao-testing = { workspace = true } 40 | dao-voting-token-staked = { workspace = true, features = ["library"] } 41 | dao-voting = { workspace = true } 42 | -------------------------------------------------------------------------------- /contracts/distribution/cw-fund-distributor/README.md: -------------------------------------------------------------------------------- 1 | # cw-fund-distributor 2 | 3 | This contract is meant to facilitate fund distribution 4 | proportional to the amount of voting power members have 5 | at a given block height. 6 | 7 | Possible use cases may involve: 8 | 9 | - Dissolving a DAO and distributing its treasury to members prior to shutting down 10 | - Distributing funds among DAO members 11 | - Funding subDAOs 12 | 13 | > **WARNING:** THIS CONTRACT IS NOT AUDITED AND IS _EXPERIMENTAL_. USE AT YOUR 14 | > OWN RISK. 15 | 16 | ## Funding Period 17 | 18 | Contract is instantiated with a `funding_period` - a time duration that should suffice 19 | to move the funds to be distributed into the distributor contract. 20 | 21 | Funding the contract can only happen during this period. 22 | No claims can happen during this period. 23 | 24 | ## Claiming/Distribution Period 25 | 26 | After the `funding_period` expires, the funds held by distributor contract become 27 | available for claims. 28 | 29 | Funding the contract is no longer possible at this point. 30 | 31 | ## Fund redistribution 32 | 33 | Considering it is more than likely that not every user would claim its allocation, 34 | it is possible to redistribute the unclaimed funds. 35 | 36 | Only the `cw_admin` can call the method. 37 | 38 | The redistribution method finds all the claims that have been performed 39 | and subtracts the amounts from the initially funded balance. The respective 40 | allocation ratios for each DAO member remain the same; any previous claims 41 | are cleared. 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 DAO DAO 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the 13 | distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived 17 | from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /contracts/external/btsg-ft-factory/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | mod app; 2 | mod bitsong_stargate; 3 | mod tests; 4 | 5 | use app::BitsongApp; 6 | use cosmwasm_std::Addr; 7 | use cw_multi_test::Executor; 8 | use dao_testing::contracts::{btsg_ft_factory_contract, dao_voting_token_staked_contract}; 9 | 10 | use crate::msg::InstantiateMsg; 11 | 12 | /// Address used to stake stuff. 13 | pub(crate) const STAKER: &str = "staker"; 14 | 15 | pub(crate) struct CommonTest { 16 | app: BitsongApp, 17 | module_id: u64, 18 | factory: Addr, 19 | } 20 | 21 | pub(crate) fn setup_test() -> CommonTest { 22 | let mut app = BitsongApp::new(); 23 | let factory_id = app.store_code(btsg_ft_factory_contract()); 24 | let module_id = app.store_code(dao_voting_token_staked_contract()); 25 | 26 | let factory = app 27 | .instantiate_contract( 28 | factory_id, 29 | Addr::unchecked("anyone"), 30 | &InstantiateMsg {}, 31 | &[], 32 | "bitsong_fantoken_factory", 33 | None, 34 | ) 35 | .unwrap(); 36 | 37 | CommonTest { 38 | app, 39 | module_id, 40 | factory, 41 | } 42 | } 43 | 44 | // Advantage to using a macro for this is that the error trace links 45 | // to the exact line that the error occured, instead of inside of a 46 | // function where the assertion would otherwise happen. 47 | macro_rules! is_error { 48 | ($x:expr => $e:tt) => { 49 | assert!(format!("{:#}", $x.unwrap_err()).contains($e)) 50 | }; 51 | } 52 | 53 | pub(crate) use is_error; 54 | -------------------------------------------------------------------------------- /contracts/test/dao-test-custom-factory/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "dao-test-custom-factory" 3 | authors = ["Jake Hartnell"] 4 | description = "A test contract for testing factory patterns in dao-voting-token-staked and dao-voting-cw721-staked." 5 | edition = { workspace = true } 6 | license = { workspace = true } 7 | repository = { workspace = true } 8 | version = { workspace = true } 9 | 10 | [lib] 11 | crate-type = ["cdylib", "rlib"] 12 | 13 | [features] 14 | default = ["osmosis_tokenfactory"] 15 | # for more explicit tests, cargo test --features=backtraces 16 | backtraces = ["cosmwasm-std/backtraces"] 17 | # use library feature to disable all instantiate/execute/query exports 18 | library = [] 19 | # different tokenfactory cosmos sdk module standards. enable corresponding 20 | # standard in types library 21 | osmosis_tokenfactory = ["cw-tokenfactory-issuer/osmosis_tokenfactory"] 22 | 23 | [dependencies] 24 | cosmwasm-std = { workspace = true } 25 | cosmwasm-schema = { workspace = true } 26 | cw2 = { workspace = true } 27 | cw721 = { workspace = true } 28 | cw721-base = { workspace = true, features = ["library"] } 29 | cw-ownable = { workspace = true } 30 | cw-storage-plus = { workspace = true } 31 | cw-utils = { workspace = true } 32 | thiserror = { workspace = true } 33 | dao-dao-macros = { workspace = true } 34 | dao-interface = { workspace = true } 35 | dao-voting = { workspace = true } 36 | cw-tokenfactory-issuer = { workspace = true, default-features = false, features = [ 37 | "library", 38 | ] } 39 | 40 | [dev-dependencies] 41 | cw-multi-test = { workspace = true } 42 | -------------------------------------------------------------------------------- /contracts/external/cw-tokenfactory-issuer/src/state.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cosmwasm_std::{Addr, Uint128}; 3 | use cw_storage_plus::{Item, Map}; 4 | 5 | /// Holds the Token Factory denom managed by this contract 6 | pub const DENOM: Item = Item::new("denom"); 7 | 8 | /// Denylist addresses prevented from transferring tokens 9 | pub const DENYLIST: Map<&Addr, bool> = Map::new("denylist"); 10 | 11 | /// Addresses allowed to transfer tokens even if the token is frozen 12 | pub const ALLOWLIST: Map<&Addr, bool> = Map::new("allowlist"); 13 | 14 | /// Whether or not features that require MsgBeforeSendHook are enabled 15 | /// Many Token Factory chains do not yet support MsgBeforeSendHook 16 | #[cw_serde] 17 | pub struct BeforeSendHookInfo { 18 | /// Whether or not features in this contract that require MsgBeforeSendHook are enabled. 19 | pub advanced_features_enabled: bool, 20 | /// The address of the contract that implements the BeforeSendHook interface. 21 | /// Most often this will be the cw_tokenfactory_issuer contract itself. 22 | pub hook_contract_address: Option, 23 | } 24 | pub const BEFORE_SEND_HOOK_INFO: Item = Item::new("hook_features_enabled"); 25 | 26 | /// Whether or not token transfers are frozen 27 | pub const IS_FROZEN: Item = Item::new("is_frozen"); 28 | 29 | /// Allowances for burning 30 | pub const BURNER_ALLOWANCES: Map<&Addr, Uint128> = Map::new("burner_allowances"); 31 | 32 | /// Allowances for minting 33 | pub const MINTER_ALLOWANCES: Map<&Addr, Uint128> = Map::new("minter_allowances"); 34 | -------------------------------------------------------------------------------- /packages/cw-jsonfilter/examples/nested_filters.rs: -------------------------------------------------------------------------------- 1 | use cw_jsonfilter::{CwJsonFilter, FilterResult}; 2 | use serde_json::{json, Value}; 3 | 4 | fn main() { 5 | // Filter can be as complex as you want 6 | let filter = json!({ 7 | "$and": [ 8 | {"$or": [ 9 | {"age": {"$gte": 18}}, 10 | {"is_student": true} 11 | ]}, 12 | {"$not": { 13 | "$or": [ 14 | {"city": "New York"}, 15 | {"city": "Los Angeles"} 16 | ] 17 | }} 18 | ] 19 | }); 20 | 21 | let obj1 = json!({"age": 25, "is_student": false, "city": "Chicago"}); 22 | let obj2 = json!({"age": 16, "is_student": true, "city": "Miami"}); 23 | let obj3 = json!({"age": 30, "is_student": false, "city": "New York"}); 24 | 25 | println!("Filter:"); 26 | println!("{filter}"); 27 | println!("Objects:"); 28 | println!("Object 1: {obj1}"); 29 | println!("Object 2: {obj2}"); 30 | println!("Object 3: {obj3}"); 31 | 32 | // Matching objects against the filter 33 | match_objects(&filter, &obj1); 34 | match_objects(&filter, &obj2); 35 | match_objects(&filter, &obj3); 36 | } 37 | 38 | fn match_objects(filter: &Value, obj: &Value) { 39 | match CwJsonFilter::check(filter, obj) { 40 | FilterResult::Pass => println!("Filter matches the object"), 41 | FilterResult::Fail(err) => println!("Filter does not match the object: {err:?}"), 42 | FilterResult::Fatal(err) => println!("Fatal error: {err:?}"), 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/dao-interface/src/helpers.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | 3 | #[cw_serde] 4 | pub enum Update { 5 | Set(T), 6 | Clear, 7 | } 8 | 9 | /// An update type that allows partial updates of optional fields. 10 | #[cw_serde] 11 | #[serde(transparent)] 12 | pub struct OptionalUpdate(pub Option>); 13 | 14 | impl OptionalUpdate { 15 | /// Updates the value if it exists, otherwise does nothing. 16 | pub fn maybe_update(self, update: impl FnOnce(Option)) { 17 | match self.0 { 18 | Some(Update::Set(value)) => update(Some(value)), 19 | Some(Update::Clear) => update(None), 20 | None => (), 21 | } 22 | } 23 | 24 | /// Updates the value if it exists, otherwise does nothing, requiring the 25 | /// update action to return a result. 26 | pub fn maybe_update_result( 27 | self, 28 | update: impl FnOnce(Option) -> Result<(), E>, 29 | ) -> Result<(), E> { 30 | self.maybe_update_result_with_value(update, ()) 31 | } 32 | 33 | /// Updates the value if it exists, otherwise does nothing, requiring the 34 | /// update action to return a result with a value. 35 | pub fn maybe_update_result_with_value( 36 | self, 37 | update: impl FnOnce(Option) -> Result, 38 | default: R, 39 | ) -> Result { 40 | match self.0 { 41 | Some(Update::Set(value)) => update(Some(value)), 42 | Some(Update::Clear) => update(None), 43 | None => Ok(default), 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-cw721-roles/src/testing/mod.rs: -------------------------------------------------------------------------------- 1 | mod execute; 2 | mod instantiate; 3 | mod queries; 4 | mod tests; 5 | 6 | use cosmwasm_std::Addr; 7 | use cw_multi_test::{App, Executor}; 8 | use dao_testing::contracts::dao_voting_cw721_roles_contract; 9 | 10 | use crate::msg::{InstantiateMsg, NftContract, NftMintMsg}; 11 | 12 | use self::instantiate::instantiate_cw721_roles; 13 | 14 | /// Address used as the owner, instantiator, and minter. 15 | pub(crate) const CREATOR_ADDR: &str = "creator"; 16 | 17 | pub(crate) struct CommonTest { 18 | app: App, 19 | module_addr: Addr, 20 | } 21 | 22 | pub(crate) fn setup_test(initial_nfts: Vec) -> CommonTest { 23 | let mut app = App::default(); 24 | let module_id = app.store_code(dao_voting_cw721_roles_contract()); 25 | 26 | let (_, cw721_id) = instantiate_cw721_roles(&mut app, CREATOR_ADDR, CREATOR_ADDR); 27 | let module_addr = app 28 | .instantiate_contract( 29 | module_id, 30 | Addr::unchecked(CREATOR_ADDR), 31 | &InstantiateMsg { 32 | nft_contract: NftContract::New { 33 | code_id: cw721_id, 34 | label: "cw721-roles".to_string(), 35 | name: "Job Titles".to_string(), 36 | symbol: "TITLES".to_string(), 37 | initial_nfts, 38 | salt: None, 39 | }, 40 | }, 41 | &[], 42 | "cw721_voting", 43 | None, 44 | ) 45 | .unwrap(); 46 | 47 | CommonTest { app, module_addr } 48 | } 49 | -------------------------------------------------------------------------------- /contracts/voting/dao-voting-onft-staked/src/error.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_std::StdError; 2 | use dao_voting::threshold::ActiveThresholdError; 3 | use thiserror::Error; 4 | 5 | #[derive(Error, Debug, PartialEq)] 6 | pub enum ContractError { 7 | #[error(transparent)] 8 | Std(#[from] StdError), 9 | 10 | #[error(transparent)] 11 | ActiveThresholdError(#[from] ActiveThresholdError), 12 | 13 | #[error(transparent)] 14 | HookError(#[from] cw_hooks::HookError), 15 | 16 | #[error(transparent)] 17 | UnstakingDurationError(#[from] dao_voting::duration::UnstakingDurationError), 18 | 19 | #[error(transparent)] 20 | NftClaimError(#[from] nft_controllers::NftClaimError), 21 | 22 | #[error("Nothing to claim")] 23 | NothingToClaim {}, 24 | 25 | #[error("Only an NFT's owner can prepare it to be staked")] 26 | OnlyOwnerCanPrepareStake {}, 27 | 28 | #[error("NFTs must be prepared and transferred before they can be staked")] 29 | StakeMustBePrepared {}, 30 | 31 | #[error("Recipient must be set when the DAO is cancelling a stake that was not prepared")] 32 | NoRecipient {}, 33 | 34 | #[error("Only the owner or preparer can cancel a prepared stake")] 35 | NotPreparerNorOwner {}, 36 | 37 | #[error("Can not unstake that which you have not staked (unstaking {token_id})")] 38 | NotStaked { token_id: String }, 39 | 40 | #[error("Unauthorized")] 41 | Unauthorized {}, 42 | 43 | #[error("Got a submessage reply with unknown id: {id}")] 44 | UnknownReplyId { id: u64 }, 45 | 46 | #[error("Can't unstake zero NFTs.")] 47 | ZeroUnstake {}, 48 | } 49 | -------------------------------------------------------------------------------- /packages/dao-voting/src/status.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::cw_serde; 2 | use cw_utils::Expiration; 3 | 4 | #[cw_serde] 5 | #[derive(Copy)] 6 | pub enum Status { 7 | /// The proposal is open for voting. 8 | Open, 9 | /// The proposal has been rejected. 10 | Rejected, 11 | /// The proposal has been passed but has not been executed. 12 | Passed, 13 | /// The proposal has been passed and executed. 14 | Executed, 15 | /// The proposal has failed or expired and has been closed. A 16 | /// proposal deposit refund has been issued if applicable. 17 | Closed, 18 | /// The proposal's execution failed. 19 | ExecutionFailed, 20 | /// The proposal is timelocked. Only the configured vetoer 21 | /// can execute or veto until the timelock expires. 22 | VetoTimelock { expiration: Expiration }, 23 | /// The proposal has been vetoed. 24 | Vetoed, 25 | } 26 | 27 | impl std::fmt::Display for Status { 28 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 29 | match self { 30 | Status::Open => write!(f, "open"), 31 | Status::Rejected => write!(f, "rejected"), 32 | Status::Passed => write!(f, "passed"), 33 | Status::Executed => write!(f, "executed"), 34 | Status::Closed => write!(f, "closed"), 35 | Status::ExecutionFailed => write!(f, "execution_failed"), 36 | Status::VetoTimelock { expiration } => { 37 | write!(f, "veto_timelock_until_{expiration:?}") 38 | } 39 | Status::Vetoed => write!(f, "vetoed"), 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | If you find a security vulnerability in our contracts it's a very big 2 | deal and we'd like to work with you to get it fixed. To keep the DAOs 3 | that use DAO DAO safe, we ask that you don't mention it publicly and 4 | get in touch with one of us. 5 | 6 | For Discord, please DM: 7 | 8 | - ekez#9732 (PST, often up late so may be good for Eastern European and Asian time zone mornings) 9 | - elsehow#3115 (PST, more avaliable than ekez in PST mornings) 10 | - Callum#5521 (UTC) 11 | 12 | DM as many of us as you need to get a response. You can join our 13 | Discord via [this link](https://discord.com/invite/sAaGuyW3D2). 14 | 15 | If you're concerned about Discord's phone number requirements feel 16 | free to email a report to ekez at `ekez@withoutdoing.com`. That email 17 | uses [gsuite](https://workspace.google.com/); if you're worried about 18 | Google you can use this public key: 19 | 20 | ``` 21 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCvCEX7GpPmUji7jR5XMDJOOSVQM2ne7nJB8OfE1xqEPBruOin1g3t9mLdQmVUkARHOW2lCup4UUeO1F/wAbfSk/CrpxHM7ErtD1FEzbOv/wBUWpsvne6dGfXw/zPQplUJ7Lk04Iln4WAgfxTuXEgJnXf/HRHovWaTWX+Eo3Br2vWQqcUc99Cy1Rvf8QTHT/UgDnqRcx67Yq1ndHAXBhNWcXGysgL4qyt79Q3rB+TR3yPugCBBMxvzEljFGCUc7P4jI+sXVFNzrghLOVwaGGfVDS66FFzEY0Hg/odfK4NdCSjGgHwU8y9oRjkgZFzhsdLp94pkLIAX143+UOribLlrOGSr/1OtJA4aIfenJZVE2vt/A4HPKtlBP6X6figOS+QWgVwGY4tzoeEH6oqCjniF5EgtB741PDzMlnpFcrkrdAeM6WqBkxeyf5tEebahsMEI3ZNkMjKVpBCJfe6Ms4yFA815MVKsBPHWWaJ4XhvhnbinENcFU3rBflOvSsjx0MaxkLb2+Ve1NiEZ3Zj82Nycf1cWtOp0n5LCjEtfCYvzfIy6BXoqAC97gAKf++13t/+3ECJCIPcoXKFWMiXfjSt/GiQwhbmAGWNX+pbpqWMd7QeqT1cQzvAdrvFnOmFe8/wymovYeEaM0Qv7w1gbPYat9eCbBN6IGqX/aJiSCokYl3Q== 22 | ``` 23 | -------------------------------------------------------------------------------- /contracts/external/cw-admin-factory/src/msg.rs: -------------------------------------------------------------------------------- 1 | use cosmwasm_schema::{cw_serde, QueryResponses}; 2 | use cosmwasm_std::{Addr, Binary}; 3 | 4 | #[cw_serde] 5 | pub struct InstantiateMsg { 6 | /// The account allowed to execute this contract. If no admin, anyone can 7 | /// execute it. 8 | pub admin: Option, 9 | } 10 | 11 | #[cw_serde] 12 | pub enum ExecuteMsg { 13 | /// Instantiates the target contract with the provided instantiate message, 14 | /// code ID, and label and updates the contract's admin to be itself. 15 | InstantiateContractWithSelfAdmin { 16 | instantiate_msg: Binary, 17 | code_id: u64, 18 | label: String, 19 | }, 20 | /// Instantiates the target contract with the provided instantiate message, 21 | /// code ID, label, and salt, via instantiate2 to give a predictable 22 | /// address, and updates the contract's admin to be itself. 23 | Instantiate2ContractWithSelfAdmin { 24 | instantiate_msg: Binary, 25 | code_id: u64, 26 | label: String, 27 | salt: Binary, 28 | /// Optionally specify the expected address and fail if it doesn't match 29 | /// the instantiated contract. This makes it easy for a consumer to 30 | /// validate that they are using the correct address elsewhere. 31 | expect: Option, 32 | }, 33 | } 34 | 35 | #[cw_serde] 36 | #[derive(QueryResponses)] 37 | pub enum QueryMsg { 38 | #[returns(AdminResponse)] 39 | Admin {}, 40 | } 41 | 42 | #[cw_serde] 43 | pub struct MigrateMsg {} 44 | 45 | #[cw_serde] 46 | pub struct AdminResponse { 47 | pub admin: Option, 48 | } 49 | -------------------------------------------------------------------------------- /contracts/proposal/dao-proposal-condorcet/README.md: -------------------------------------------------------------------------------- 1 | # dao-proposal-condorcet 2 | 3 | [![dao-proposal-condorcet on crates.io](https://img.shields.io/crates/v/dao-proposal-condorcet.svg?logo=rust)](https://crates.io/crates/dao-proposal-condorcet) 4 | [![docs.rs](https://img.shields.io/docsrs/dao-proposal-condorcet?logo=docsdotrs)](https://docs.rs/dao-proposal-condorcet/latest/dao_proposal_condorcet/) 5 | 6 | This is a DAO DAO proposal module which implements The Condorcet 7 | Method. 8 | 9 | https://www.princeton.edu/~cuff/voting/theory.html 10 | 11 | This module lacks many basic features. For example, proposals and 12 | choices do not have human readable names and descriptions. For this 13 | first version, the goal is to build a correct, secure, and gas 14 | efficent voting system that may be audited, not to build a proposal 15 | module that is ready for use with humans and a frontend. 16 | 17 | To this end, this module differs from `dao-proposal-single` and 18 | `dao-proposal-multiple` in that it does not: 19 | 20 | 1. support revoting, 21 | 2. integrate with pre-propose modules, nor 22 | 3. support proposal and vote hooks 23 | 24 | The ranked choice voting system used is described in detail 25 | [here](./gercv.pdf). This contract will make no sense unless you read 26 | that PDF first as there is a fair bit of math. 27 | 28 | > what works reliably 29 | > is to know the raw silk, 30 | > hold the uncut wood. 31 | > Need little, 32 | > want less. 33 | > Forget the rules. 34 | > Be untroubled. 35 | 36 | - [Tao Te Ching (Ursula Le Guin transaltion)](https://github.com/lovingawareness/tao-te-ching/blob/master/Ursula%20K%20Le%20Guin.md) 37 | 38 | -------------------------------------------------------------------------------- /contracts/external/cw-protobuf-registry/src/state.rs: -------------------------------------------------------------------------------- 1 | use cw_storage_plus::{Index, IndexList, IndexedMap, Map, MultiIndex}; 2 | 3 | /// Map protobuf file name -> raw protobuf file descriptor proto data. 4 | pub const FILES: Map> = Map::new("files"); 5 | 6 | /// Map protobuf message descriptor name -> protobuf file name that contains it. 7 | /// Secondary index on file_name to look up/iterate by file. This supports the 8 | /// following queries: 9 | /// - get a specific protobuf message by name (map lookup) 10 | /// - list all protobuf messages (range query) 11 | /// - list all protobuf messages in a specific file (secondary index range 12 | /// query) 13 | pub const MESSAGES: IndexedMap> = IndexedMap::new( 14 | "messages", 15 | MessagesIndexes { 16 | file_name: MultiIndex::new( 17 | |_pk, file_name| file_name.clone(), 18 | "messages", 19 | "messages__file_name", 20 | ), 21 | }, 22 | ); 23 | 24 | /// Secondary index for protobuf descriptors to look up/iterate by file name. 25 | pub struct MessagesIndexes<'a> { 26 | pub file_name: MultiIndex<'a, String, String, String>, 27 | } 28 | impl IndexList for MessagesIndexes<'_> { 29 | fn get_indexes(&self) -> Box> + '_> { 30 | let v: Vec<&dyn Index> = vec![&self.file_name]; 31 | Box::new(v.into_iter()) 32 | } 33 | } 34 | 35 | /// Map message name -> file descriptor set that contains the exact files with 36 | /// the exact messages/enums needed to decode the message. 37 | pub const PREPARED: Map> = Map::new("prepared"); 38 | -------------------------------------------------------------------------------- /contracts/external/dao-migrator/README.md: -------------------------------------------------------------------------------- 1 | # dao-migrator 2 | 3 | [![dao-migrator on crates.io](https://img.shields.io/crates/v/dao-migrator.svg?logo=rust)](https://crates.io/crates/dao-migrator) 4 | [![docs.rs](https://img.shields.io/docsrs/dao-migrator?logo=docsdotrs)](https://docs.rs/dao-migrator/latest/dao_migrator/) 5 | 6 | Here is the [discussion](https://github.com/DA0-DA0/dao-contracts/discussions/607). 7 | 8 | A migrator module for a DAO DAO DAO which handles migration for DAO modules 9 | and test it went successfully. 10 | 11 | DAO core migration is handled by a proposal, which adds this module and do 12 | init callback to do migration on all regsitered modules. 13 | If custom module is found, this TX fails and migration is cancelled, custom 14 | module requires a custom migration to be done by the DAO. 15 | 16 | # General idea 17 | 18 | 1. Proposal is made to migrate DAO core to V2, which also adds this module to the DAO. 19 | 2. On init of this contract, a callback is fired to do the migration. 20 | 3. Then we check to make sure the DAO doesn't have custom modules. 21 | 4. We query the state before migration 22 | 5. We do the migration 23 | 6. We query the new state and test it to make sure everything is correct. 24 | 7. In any case where 1 migration fails, we fail the whole TX. 25 | 26 | # Important notes 27 | 28 | - custom modules cannot reliably be migrated by this contract, 29 | because of that we fail the process to avoid any unwanted results. 30 | 31 | - If any module migration fails we fail the whole thing, 32 | this is to make sure that we either have a fully working V2, 33 | or we do nothing and make sure the DAO is operational at any time. 34 | --------------------------------------------------------------------------------