Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: minor issues NTRN-402 #43

Merged
merged 13 commits into from
Mar 18, 2023
16 changes: 8 additions & 8 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
e8b52fab268f7bb5538b4b81e284a89eee824e4b9f9430eb147f64601bea3363 credits_vault.wasm
e02c0faf19a093d4f304b5aae55c34a38b4dd5fcd153bf6060b4962d29fd7d49 credits_vault.wasm
e1f198ec554470bd05f4081cf2309035a1369152b147bdc2ca2fad7120364641 cw4_group.wasm
187c5a1e98b14384bf2e1bbbfddde4214f7e10e00dd5369c68f4dc3363a8a7bf cw4_voting.wasm
6fc1a396d4763097b7b260a083e1c7f9de8d92b1a020c18cceee29f055d72df2 cwd_core.wasm
676a948ace3832aaca1ffcb0809525bd8545437425eb22b39a640c4731b17e3f cwd_core.wasm
c7ddd8a95dc3d1912249f12e7b036d9daeaac07af1e2c77ebe92a97aaab125b8 cwd_pre_propose_multiple.wasm
047169a6e4e4b6fc5b2f7550376b2f1648554c54837f7631afa07fc3c6c34ce8 cwd_pre_propose_overrule.wasm
35be8f8ebecfd8893eded5d63148fd1f68733a525f8f7a42f8b70c11bbaf60fb cwd_pre_propose_single.wasm
77c2d5ef5199a936905920e53c8435b9bf89e919c4552a679813902ecc3b1d77 cwd_proposal_multiple.wasm
994330de9edb83f32e1364f9d65ddcc37669bd2d22071220bad2028a93b82d5e cwd_proposal_multiple.wasm
64d3e3dc1db548307654dd585f1bad1d3dc00d2758d2b71d988a71333bcea3c6 cwd_proposal_single.wasm
8f86441f544654e6012cf4e56670c0ddbd2275c80aba64c923fe349889e0ed43 cwd_subdao_core.wasm
bdddd6ea8f7dc36e1b73d97c7caf20f59a3f2e3544a307098fbd02d838f260bd cwd_subdao_pre_propose_overrule.wasm
e98782b00d3a36f85dfe899025848beae3b330deefb818204d6251e431417f1a cwd_subdao_pre_propose_single.wasm
be0fb8de87fad3da5f4fee52b27dbcef6426af56692401945873b2b0894779cc cwd_subdao_proposal_single.wasm
aed528b20c9d432414858d0a825e945365145b3d375cb174fd7a8ba4f7234693 cwd_subdao_timelock_single.wasm
a6a0f619d52fc90ab59e15358f7a5b2a34e570e31cdbf6881037198bc877c2ab lockdrop_vault.wasm
9bbd1d908adc2e3d50ae3f3d74073a4d39c437c6b389fed2163eff3bf238ee28 neutron_distribution.wasm
73c102d902e11e0eb070d53282e5e04656dc3a549defec596b36cbb3571e0f31 lockdrop_vault.wasm
543678b0a2147d095dfe9076aad23b263422d321c98d61c969745b5c393968c0 neutron_distribution.wasm
8c58519e5a278fbce1c912a5832cab7e29768b69f05c2338e2a10d584c517c5a neutron_reserve.wasm
f4be156137da8588bf7215fa62a8bddb5d9cc31415c524716ebc1b53bd0448a8 neutron_treasury.wasm
566cdb60a51e9ad83bc2bf69492f1fdd72931784dcc2648811adaa87d5565586 neutron_vault.wasm
97a95c2ddae372f8d119cb188c1066bd3baccb7b37eae8cd704fe3ef19fbfd05 neutron_voting_registry.wasm
e95ae0040e7cf295e483440715f57cf468c3b9badd0bb3ccd0103bacc5a46bdc neutron_treasury.wasm
0704e6094cc92cbd8bf08eeaa52f17df944e6f73e6c27b79b636a90987cbcbf5 neutron_vault.wasm
9d079e8b6b3032b4f1d17a0345b583fe3274dcfb293219c3305d44720e326ade neutron_voting_registry.wasm
16 changes: 8 additions & 8 deletions artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
d328a563a7125e5c1bd8d31004eacfea2417467efc040aac2ecc981040f566a6 target/wasm32-unknown-unknown/release/cwd_pre_propose_overrule.wasm
9045a14917b5fe2aae20e8778bdb315ddee88dcd3f38e6d86fd2e1e820e585d0 target/wasm32-unknown-unknown/release/cwd_pre_propose_single.wasm
1ae934f9b3e188a4d7096f4f9231edfad84a482a33a66e90b5d0ce124065c062 target/wasm32-unknown-unknown/release/cwd_subdao_pre_propose_single.wasm
91be9e3bbb44c0abfafc1602887348ac67c41511c6f2cbbca26e945e7125b159 target/wasm32-unknown-unknown/release/neutron_distribution.wasm
2243d1d288ebc8c8110a95ea69226ba9012ffd79cad637147c6e9aa5a27c7942 target/wasm32-unknown-unknown/release/neutron_treasury.wasm
d328a563a7125e5c1bd8d31004eacfea2417467efc040aac2ecc981040f566a6 target/wasm32-unknown-unknown/release/cwd_pre_propose_overrule.wasm
98d530814928c28813685bdd634d33c6d10bde7d8d3d14054dd28c18ecc082c7 target/wasm32-unknown-unknown/release/cwd_core.wasm
182595fe1ffd93701b14c6f04d5ac40af1f43aabcfbdb7144b63d609a87154d0 target/wasm32-unknown-unknown/release/cwd_subdao_core.wasm
5f5de39421089a6edc7f6e8bbcfe90aa57115e6257d8f3e2c4ee9f026a8acf0e target/wasm32-unknown-unknown/release/cwd_subdao_proposal_single.wasm
2cbd1aeb99f73a7089fbcb94140096585c4db4611fb342a6e9843989feee1fd2 target/wasm32-unknown-unknown/release/cwd_subdao_timelock_single.wasm
958d16502995b3793d757debf31462925a83d2a7ff64a9085cb039cdc647c6a6 target/wasm32-unknown-unknown/release/neutron_reserve.wasm
78764327dccf528394eb79786bb75d8737687dfff33ea8e0497a71276a7ee926 target/wasm32-unknown-unknown/release/cwd_proposal_multiple.wasm
fc79389148ad4653d8a9da2926c683d297b0c7ddce8bf2a865c70e0897cdb176 target/wasm32-unknown-unknown/release/cwd_proposal_single.wasm
d433ee1fb4e4776d6099018f1ed0fae7ac965b519a2a7cd73d13eddeba32fa19 target/wasm32-unknown-unknown/release/lockdrop_vault.wasm
1ad122156a805c1f22ea37baf521605b5bedd761b22973bf69192de331e30bd2 target/wasm32-unknown-unknown/release/neutron_vault.wasm
55eabfcd6370e5774f67dc9517fcf6361f73bb53f17f129987cf4929227edd5b target/wasm32-unknown-unknown/release/neutron_voting_registry.wasm
98389aad0f011b85b7092660c807d8a80c5a96f68321f17eb0cf12feed478106 target/wasm32-unknown-unknown/release/credits_vault.wasm
fc8b096f3c222d03feb30db06781bc48b0047ef413a578d5051652009d4b2654 target/wasm32-unknown-unknown/release/credits_vault.wasm
e77eedef6c4bccd4f5a9d01d51384438b28698c69ac62bb04e721e01a6d53e77 target/wasm32-unknown-unknown/release/cwd_core.wasm
310bcf72e4189d76ab60a95624693f4be2a413715c5d1a938b270b4e14f9813d target/wasm32-unknown-unknown/release/cwd_proposal_multiple.wasm
5ca97769fa8c3d0e39d70518725f4671b24f20e2699eeab4b26bd6b130aebce1 target/wasm32-unknown-unknown/release/lockdrop_vault.wasm
541982d8d8e00ce380fc6d48bd7c4c631ae4160bedde61c62bd84c317c2177f2 target/wasm32-unknown-unknown/release/neutron_distribution.wasm
beeaf6a9cb0c9904515fe8be03a810df9b5348d47dc5d2e04a4ad9ad4dbad17f target/wasm32-unknown-unknown/release/neutron_treasury.wasm
015b3a9c3f570ee7ce3a01f7453b6658497565c9a438091a209f391f82659a8d target/wasm32-unknown-unknown/release/neutron_vault.wasm
8a9e58c14a85c76b3ab2ad62ca5001c7cbc52a75cc7b3a80ba8d604864e5cc0c target/wasm32-unknown-unknown/release/neutron_voting_registry.wasm
Binary file modified artifacts/credits_vault.wasm
Binary file not shown.
Binary file modified artifacts/cwd_core.wasm
Binary file not shown.
Binary file modified artifacts/cwd_proposal_multiple.wasm
Binary file not shown.
Binary file modified artifacts/lockdrop_vault.wasm
Binary file not shown.
Binary file modified artifacts/neutron_distribution.wasm
Binary file not shown.
Binary file modified artifacts/neutron_treasury.wasm
Binary file not shown.
Binary file modified artifacts/neutron_vault.wasm
Binary file not shown.
Binary file modified artifacts/neutron_voting_registry.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub(crate) fn instantiate_with_native_bonded_balances_governance(
let vault_intantiate = neutron_vault::msg::InstantiateMsg {
name: "Test vault".to_string(),
description: "based neutron vault".to_string(),
owner: None,
owner: Admin::CoreModule {},
manager: None,
denom: "ujuno".to_string(),
};
Expand Down Expand Up @@ -125,7 +125,7 @@ pub(crate) fn instantiate_with_native_bonded_balances_governance(
voting_registry_module_instantiate_info: ModuleInstantiateInfo {
code_id: voting_registry_id,
msg: to_binary(&neutron_voting_registry::msg::InstantiateMsg {
owner: Some(Admin::CoreModule {}),
owner: Admin::CoreModule {},
manager: None,
voting_vaults: vec![vault_addr.to_string()],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub(crate) fn instantiate_with_native_bonded_balances_governance(
let vault_intantiate = neutron_vault::msg::InstantiateMsg {
name: "Test vault".to_string(),
description: "based neutron vault".to_string(),
owner: None,
owner: Admin::CoreModule {},
manager: None,
denom: "ujuno".to_string(),
};
Expand Down Expand Up @@ -128,7 +128,7 @@ pub(crate) fn instantiate_with_native_bonded_balances_governance(
voting_registry_module_instantiate_info: ModuleInstantiateInfo {
code_id: voting_registry_id,
msg: to_binary(&neutron_voting_registry::msg::InstantiateMsg {
owner: Some(Admin::CoreModule {}),
owner: Admin::CoreModule {},
manager: None,
voting_vaults: vec![vault_addr.to_string()],
})
Expand Down
55 changes: 5 additions & 50 deletions contracts/dao/voting/credits-vault/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"properties": {
"update_config": {
"type": "object",
"required": [
"owner"
],
"properties": {
"credits_contract_address": {
"type": [
Expand All @@ -30,60 +33,12 @@
]
},
"owner": {
"anyOf": [
{
"$ref": "#/definitions/Admin"
},
{
"type": "null"
}
]
"type": "string"
}
}
}
},
"additionalProperties": false
}
],
"definitions": {
"Admin": {
"description": "Information about the CosmWasm level admin of a contract. Used in conjunction with `ModuleInstantiateInfo` to instantiate modules.",
"oneOf": [
{
"description": "Set the admin to a specified address.",
"type": "object",
"required": [
"address"
],
"properties": {
"address": {
"type": "object",
"required": [
"addr"
],
"properties": {
"addr": {
"type": "string"
}
}
}
},
"additionalProperties": false
},
{
"description": "Sets the admin as the core module address.",
"type": "object",
"required": [
"core_module"
],
"properties": {
"core_module": {
"type": "object"
}
},
"additionalProperties": false
}
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "object",
"required": [
"credits_contract_address",
"description"
"description",
"owner"
],
"properties": {
"credits_contract_address": {
Expand All @@ -24,14 +25,7 @@
]
},
"owner": {
"anyOf": [
{
"$ref": "#/definitions/Addr"
},
{
"type": "null"
}
]
"$ref": "#/definitions/Addr"
}
},
"definitions": {
Expand Down
12 changes: 3 additions & 9 deletions contracts/dao/voting/credits-vault/schema/instantiate_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"type": "object",
"required": [
"credits_contract_address",
"description"
"description",
"owner"
],
"properties": {
"credits_contract_address": {
Expand All @@ -20,14 +21,7 @@
]
},
"owner": {
"anyOf": [
{
"$ref": "#/definitions/Admin"
},
{
"type": "null"
}
]
"$ref": "#/definitions/Admin"
}
},
"definitions": {
Expand Down
44 changes: 10 additions & 34 deletions contracts/dao/voting/credits-vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,10 @@ pub fn instantiate(
) -> Result<Response, ContractError> {
set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;

let owner = msg
.owner
.as_ref()
.map(|owner| match owner {
Admin::Address { addr } => deps.api.addr_validate(addr),
Admin::CoreModule {} => Ok(info.sender.clone()),
})
.transpose()?;

let owner = match msg.owner {
Admin::Address { addr } => deps.api.addr_validate(addr.as_str())?,
Admin::CoreModule {} => info.sender.clone(),
};
let manager = msg
.manager
.map(|manager| deps.api.addr_validate(&manager))
Expand All @@ -51,13 +46,7 @@ pub fn instantiate(
.add_attribute("action", "instantiate")
.add_attribute("description", config.description)
.add_attribute("credits_contract_address", config.credits_contract_address)
.add_attribute(
"owner",
config
.owner
.map(|a| a.to_string())
.unwrap_or_else(|| "None".to_string()),
)
.add_attribute("owner", config.owner)
.add_attribute(
"manager",
config
Expand Down Expand Up @@ -95,32 +84,25 @@ pub fn execute_update_config(
deps: DepsMut,
info: MessageInfo,
new_credits_contract_address: Option<String>,
new_owner: Option<Admin>,
new_owner: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you change Admin to String?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

long story short: so it's simpler and common

simpler: because it's anyway eventually stored as Addr in the contract's cfg. just look a bit below at how this value was handled and how it's now handled. Admin struct is very complicated to be passed, just look at the changes here: https://github.com/neutron-org/neutron/pull/166/files. if we pass Admin::CoreModule, it simply sets the owner to the sender, so why don't allow sending the simple sender address?

common: another reason is that we have the owner field as String in all other contracts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i prefer to trust you!

new_manager: Option<String>,
new_description: Option<String>,
) -> Result<Response, ContractError> {
let mut config: Config = CONFIG.load(deps.storage)?;
if Some(info.sender.clone()) != config.owner && Some(info.sender.clone()) != config.manager {
if info.sender != config.owner && Some(info.sender.clone()) != config.manager {
return Err(ContractError::Unauthorized {});
}

let new_credits_contract_address = new_credits_contract_address
.map(|new_credits_contract_address| deps.api.addr_validate(&new_credits_contract_address))
.transpose()?;

let new_owner = new_owner
.as_ref()
.map(|owner| match owner {
Admin::Address { addr } => deps.api.addr_validate(addr),
Admin::CoreModule {} => Ok(info.sender.clone()),
})
.transpose()?;

let new_owner = deps.api.addr_validate(&new_owner)?;
let new_manager = new_manager
.map(|new_manager| deps.api.addr_validate(&new_manager))
.transpose()?;

if Some(info.sender) != config.owner && new_owner != config.owner {
if info.sender != config.owner && new_owner != config.owner {
return Err(ContractError::OnlyOwnerCanChangeOwner {});
};

Expand All @@ -138,13 +120,7 @@ pub fn execute_update_config(
.add_attribute("action", "update_config")
.add_attribute("description", config.description)
.add_attribute("credits_contract_address", config.credits_contract_address)
.add_attribute(
"owner",
config
.owner
.map(|a| a.to_string())
.unwrap_or_else(|| "None".to_string()),
)
.add_attribute("owner", config.owner)
.add_attribute(
"manager",
config
Expand Down
4 changes: 2 additions & 2 deletions contracts/dao/voting/credits-vault/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct InstantiateMsg {
// Description contains information that characterizes the vault.
pub description: String,
// Owner can update all configs including changing the owner. This will generally be a DAO.
pub owner: Option<Admin>,
pub owner: Admin,
// Manager can update all configs except changing the owner. This will generally be an operations multisig for a DAO.
pub manager: Option<String>,
}
Expand All @@ -20,7 +20,7 @@ pub struct InstantiateMsg {
pub enum ExecuteMsg {
UpdateConfig {
credits_contract_address: Option<String>,
owner: Option<Admin>,
owner: String,
manager: Option<String>,
description: Option<String>,
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/dao/voting/credits-vault/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
pub struct Config {
pub credits_contract_address: Addr,
pub description: String,
pub owner: Option<Addr>,
pub owner: Addr,
pub manager: Option<Addr>,
}

Expand Down
Loading