diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json b/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json index 9ea6e7bde..bc211ecd8 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json +++ b/contracts/pre-propose/dao-pre-propose-approval-single/schema/dao-pre-propose-approval-single.json @@ -1897,6 +1897,20 @@ }, "additionalProperties": false }, + { + "description": "Returns contract version info.", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Gets the module's configuration.", "type": "object", @@ -2613,6 +2627,40 @@ } } }, + "info": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InfoResponse", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "$ref": "#/definitions/ContractVersion" + } + }, + "additionalProperties": false, + "definitions": { + "ContractVersion": { + "type": "object", + "required": [ + "contract", + "version" + ], + "properties": { + "contract": { + "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", + "type": "string" + }, + "version": { + "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)", + "type": "string" + } + }, + "additionalProperties": false + } + } + }, "proposal_module": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Addr", diff --git a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs index 0705780fc..7b8b109ba 100644 --- a/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approval-single/src/tests.rs @@ -6,6 +6,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor}; use cw_utils::Duration; use dao_interface::state::ProposalModule; use dao_interface::state::{Admin, ModuleInstantiateInfo}; +use dao_interface::proposal::InfoResponse; use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config}; use dao_proposal_single::query::ProposalResponse; use dao_testing::helpers::instantiate_with_cw4_groups_governance; @@ -179,6 +180,15 @@ fn setup_default_test( get_proposal_module(app, pre_propose.clone()) ); assert_eq!(core_addr, get_dao(app, pre_propose.clone())); + assert_eq!( + InfoResponse { + info: ContractVersion { + contract: "crates.io:dao-pre-propose-approval-single".to_string(), + version: env!("CARGO_PKG_VERSION").to_string() + } + }, + get_info(app, pre_propose.clone()) + ); DefaultTestSetup { core_addr, @@ -297,6 +307,12 @@ fn get_dao(app: &App, module: Addr) -> Addr { .unwrap() } +fn get_info(app: &App, module: Addr) -> InfoResponse { + app.wrap() + .query_wasm_smart(module, &QueryMsg::Info {}) + .unwrap() +} + fn get_proposal_module(app: &App, module: Addr) -> Addr { app.wrap() .query_wasm_smart(module, &QueryMsg::ProposalModule {}) diff --git a/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json b/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json index 769cd499d..477b52d77 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json +++ b/contracts/pre-propose/dao-pre-propose-approver/schema/dao-pre-propose-approver.json @@ -712,6 +712,20 @@ }, "additionalProperties": false }, + { + "description": "Returns contract version info.", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Gets the module's configuration.", "type": "object", @@ -1227,6 +1241,40 @@ } } }, + "info": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InfoResponse", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "$ref": "#/definitions/ContractVersion" + } + }, + "additionalProperties": false, + "definitions": { + "ContractVersion": { + "type": "object", + "required": [ + "contract", + "version" + ], + "properties": { + "contract": { + "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", + "type": "string" + }, + "version": { + "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)", + "type": "string" + } + }, + "additionalProperties": false + } + } + }, "proposal_module": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Addr", diff --git a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs index 9cae15ff8..2e62af1da 100644 --- a/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-approver/src/tests.rs @@ -3,6 +3,7 @@ use cw2::ContractVersion; use cw20::Cw20Coin; use cw_denom::UncheckedDenom; use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor}; +use dao_interface::proposal::InfoResponse; use dao_voting::pre_propose::{PreProposeSubmissionPolicy, PreProposeSubmissionPolicyError}; use dps::query::{ProposalListResponse, ProposalResponse}; @@ -300,6 +301,15 @@ fn setup_default_test( approver_core_addr, get_dao(app, pre_propose_approver.clone()) ); + assert_eq!( + InfoResponse { + info: ContractVersion { + contract: "crates.io:dao-pre-propose-approver".to_string(), + version: env!("CARGO_PKG_VERSION").to_string() + } + }, + get_info(app, pre_propose_approver.clone()) + ); DefaultTestSetup { core_addr, @@ -418,6 +428,12 @@ fn get_dao(app: &App, module: Addr) -> Addr { .unwrap() } +fn get_info(app: &App, module: Addr) -> InfoResponse { + app.wrap() + .query_wasm_smart(module, &QueryMsg::Info {}) + .unwrap() +} + fn get_proposal_module(app: &App, module: Addr) -> Addr { app.wrap() .query_wasm_smart(module, &QueryMsg::ProposalModule {}) diff --git a/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json b/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json index a13061598..b4f9a74c2 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json +++ b/contracts/pre-propose/dao-pre-propose-multiple/schema/dao-pre-propose-multiple.json @@ -1842,6 +1842,20 @@ }, "additionalProperties": false }, + { + "description": "Returns contract version info.", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Gets the module's configuration.", "type": "object", @@ -2298,6 +2312,40 @@ } } }, + "info": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InfoResponse", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "$ref": "#/definitions/ContractVersion" + } + }, + "additionalProperties": false, + "definitions": { + "ContractVersion": { + "type": "object", + "required": [ + "contract", + "version" + ], + "properties": { + "contract": { + "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", + "type": "string" + }, + "version": { + "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)", + "type": "string" + } + }, + "additionalProperties": false + } + } + }, "proposal_module": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Addr", diff --git a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs index 48a01a2aa..acb8bc60b 100644 --- a/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-multiple/src/tests.rs @@ -7,6 +7,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor}; use cw_utils::Duration; use dao_interface::state::ProposalModule; use dao_interface::state::{Admin, ModuleInstantiateInfo}; +use dao_interface::proposal::InfoResponse; use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config}; use dao_proposal_multiple as cpm; use dao_testing::helpers::instantiate_with_cw4_groups_governance; @@ -178,6 +179,15 @@ fn setup_default_test( get_proposal_module(app, pre_propose.clone()) ); assert_eq!(core_addr, get_dao(app, pre_propose.clone())); + assert_eq!( + InfoResponse { + info: ContractVersion { + contract: "crates.io:dao-pre-propose-multiple".to_string(), + version: env!("CARGO_PKG_VERSION").to_string() + } + }, + get_info(app, pre_propose.clone()) + ); DefaultTestSetup { core_addr, @@ -350,6 +360,12 @@ fn get_dao(app: &App, module: Addr) -> Addr { .unwrap() } +fn get_info(app: &App, module: Addr) -> InfoResponse { + app.wrap() + .query_wasm_smart(module, &QueryMsg::Info {}) + .unwrap() +} + fn get_proposal_module(app: &App, module: Addr) -> Addr { app.wrap() .query_wasm_smart(module, &QueryMsg::ProposalModule {}) diff --git a/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json b/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json index 507c69ae8..f96180633 100644 --- a/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json +++ b/contracts/pre-propose/dao-pre-propose-single/schema/dao-pre-propose-single.json @@ -1816,6 +1816,20 @@ }, "additionalProperties": false }, + { + "description": "Returns contract version info.", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "description": "Gets the module's configuration.", "type": "object", @@ -2272,6 +2286,40 @@ } } }, + "info": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InfoResponse", + "type": "object", + "required": [ + "info" + ], + "properties": { + "info": { + "$ref": "#/definitions/ContractVersion" + } + }, + "additionalProperties": false, + "definitions": { + "ContractVersion": { + "type": "object", + "required": [ + "contract", + "version" + ], + "properties": { + "contract": { + "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", + "type": "string" + }, + "version": { + "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)", + "type": "string" + } + }, + "additionalProperties": false + } + } + }, "proposal_module": { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Addr", diff --git a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs index f579ad398..6e394728e 100644 --- a/contracts/pre-propose/dao-pre-propose-single/src/tests.rs +++ b/contracts/pre-propose/dao-pre-propose-single/src/tests.rs @@ -6,6 +6,7 @@ use cw_multi_test::{App, BankSudo, Contract, ContractWrapper, Executor}; use cw_utils::Duration; use dao_interface::state::ProposalModule; use dao_interface::state::{Admin, ModuleInstantiateInfo}; +use dao_interface::proposal::InfoResponse; use dao_pre_propose_base::{error::PreProposeError, msg::DepositInfoResponse, state::Config}; use dao_proposal_single as dps; use dao_testing::helpers::instantiate_with_cw4_groups_governance; @@ -176,6 +177,15 @@ fn setup_default_test( get_proposal_module(app, pre_propose.clone()) ); assert_eq!(core_addr, get_dao(app, pre_propose.clone())); + assert_eq!( + InfoResponse { + info: ContractVersion { + contract: "crates.io:dao-pre-propose-single".to_string(), + version: env!("CARGO_PKG_VERSION").to_string() + } + }, + get_info(app, pre_propose.clone()) + ); DefaultTestSetup { core_addr, @@ -325,6 +335,12 @@ fn get_dao(app: &App, module: Addr) -> Addr { .unwrap() } +fn get_info(app: &App, module: Addr) -> InfoResponse { + app.wrap() + .query_wasm_smart(module, &QueryMsg::Info {}) + .unwrap() +} + fn query_hooks(app: &App, module: Addr) -> cw_hooks::HooksResponse { app.wrap() .query_wasm_smart(module, &QueryMsg::ProposalSubmittedHooks {}) diff --git a/packages/dao-pre-propose-base/src/execute.rs b/packages/dao-pre-propose-base/src/execute.rs index 223e08b2d..21bcee3a5 100644 --- a/packages/dao-pre-propose-base/src/execute.rs +++ b/packages/dao-pre-propose-base/src/execute.rs @@ -567,6 +567,9 @@ where to_json_binary(&self.proposal_module.load(deps.storage)?) } QueryMsg::Dao {} => to_json_binary(&self.dao.load(deps.storage)?), + QueryMsg::Info {} => to_json_binary(&dao_interface::proposal::InfoResponse { + info: cw2::get_contract_version(deps.storage)?, + }), QueryMsg::Config {} => to_json_binary(&self.config.load(deps.storage)?), QueryMsg::DepositInfo { proposal_id } => { let (deposit_info, proposer) = self.deposits.load(deps.storage, proposal_id)?; diff --git a/packages/dao-pre-propose-base/src/msg.rs b/packages/dao-pre-propose-base/src/msg.rs index f3391cf71..e795969e9 100644 --- a/packages/dao-pre-propose-base/src/msg.rs +++ b/packages/dao-pre-propose-base/src/msg.rs @@ -1,5 +1,6 @@ use cosmwasm_schema::{cw_serde, schemars::JsonSchema, QueryResponses}; use cw_denom::UncheckedDenom; +use dao_interface::proposal::InfoResponse; use dao_voting::{ deposit::{CheckedDepositInfo, UncheckedDepositInfo}, pre_propose::PreProposeSubmissionPolicy, @@ -118,6 +119,9 @@ where /// with. Returns `Addr`. #[returns(cosmwasm_std::Addr)] Dao {}, + /// Returns contract version info. + #[returns(InfoResponse)] + Info {}, /// Gets the module's configuration. #[returns(crate::state::Config)] Config {},