Skip to content

Commit

Permalink
[1.0.rc-1] Operators Removal (#318)
Browse files Browse the repository at this point in the history
* removed operators from contracts

* linting
  • Loading branch information
joemonem authored Mar 14, 2024
1 parent 65c0e09 commit 1f70a51
Show file tree
Hide file tree
Showing 52 changed files with 93 additions and 214 deletions.
2 changes: 1 addition & 1 deletion contracts/app/andromeda-app-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "app-contract".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address.clone(),
owner: msg.owner.clone(),
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/data-storage/andromeda-primitive/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "primitive".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
29 changes: 17 additions & 12 deletions contracts/ecosystem/andromeda-vault/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@ use andromeda_ecosystem::vault::{
DepositMsg, ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, StrategyAddressResponse,
StrategyType, BALANCES, STRATEGY_CONTRACT_ADDRESSES,
};
use andromeda_std::ado_base::ownership::ContractOwnerResponse;
use andromeda_std::ado_contract::ADOContract;

use andromeda_std::amp::{AndrAddr, Recipient};

use andromeda_std::common::context::ExecuteContext;
use andromeda_std::{
ado_base::withdraw::{Withdrawal, WithdrawalType},
ado_base::{
operators::IsOperatorResponse, AndromedaMsg, AndromedaQuery,
InstantiateMsg as BaseInstantiateMsg,
},
ado_base::{AndromedaMsg, AndromedaQuery, InstantiateMsg as BaseInstantiateMsg},
error::{from_semver, ContractError},
};

Expand Down Expand Up @@ -46,7 +44,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "vault".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

owner: msg.owner,
kernel_address: msg.kernel_address,
},
Expand Down Expand Up @@ -356,14 +354,21 @@ fn execute_update_strategy(
// strategy_addr.clone(),
// &deps.querier,
// )?;
let strategy_is_operator: IsOperatorResponse = deps.querier.query_wasm_smart(
strategy_addr.clone(),
&QueryMsg::IsOperator {
address: env.contract.address.to_string(),
},
)?;

// Replaced operator with owner check
// let strategy_is_operator: IsOperatorResponse = deps.querier.query_wasm_smart(
// strategy_addr.clone(),
// &QueryMsg::IsOperator {
// address: env.contract.address.to_string(),
// },
// )?;

let strategy_owner: ContractOwnerResponse = deps
.querier
.query_wasm_smart(strategy_addr.clone(), &QueryMsg::Owner {})?;

ensure!(
strategy_is_operator.is_operator,
strategy_owner.owner == env.contract.address,
ContractError::NotAssignedOperator {
msg: Some("Vault contract is not an operator for the given address".to_string()),
}
Expand Down
10 changes: 5 additions & 5 deletions contracts/ecosystem/andromeda-vault/src/testing/mock_querier.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use andromeda_std::ado_base::ownership::ContractOwnerResponse;
//use andromeda_ecosystem::anchor_earn::PositionResponse;
use andromeda_std::testing::mock_querier::MockAndromedaQuerier;
use andromeda_std::{
ado_base::{operators::IsOperatorResponse, AndromedaQuery, InstantiateMsg},
ado_base::{AndromedaQuery, InstantiateMsg},
ado_contract::ADOContract,
amp::Recipient,
testing::mock_querier::MOCK_KERNEL_CONTRACT,
Expand Down Expand Up @@ -48,7 +49,6 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "vault".to_string(),
ado_version: "test".to_string(),
operators: None,
kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down Expand Up @@ -98,9 +98,9 @@ impl WasmMockQuerier {
};
SystemResult::Ok(ContractResult::Ok(to_binary(&msg_response).unwrap()))
}
AndromedaQuery::IsOperator { address } => {
let msg_response = IsOperatorResponse {
is_operator: address == MOCK_VAULT_CONTRACT,
AndromedaQuery::Owner {} => {
let msg_response = ContractOwnerResponse {
owner: MOCK_VAULT_CONTRACT.to_owned(),
};
SystemResult::Ok(ContractResult::Ok(to_binary(&msg_response).unwrap()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "andromeda-cross-chain-swap".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "splitter".to_string(),
ado_version: "test".to_string(),
operators: None,

kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "rate-limiting-withdrawals".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "splitter".to_string(),
ado_version: "test".to_string(),
operators: None,

kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/finance/andromeda-splitter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "splitter".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "splitter".to_string(),
ado_version: "test".to_string(),
operators: None,

kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/finance/andromeda-timelock/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "timelock".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "splitter".to_string(),
ado_version: "test".to_string(),
operators: None,

kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down
2 changes: 1 addition & 1 deletion contracts/finance/andromeda-vesting/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "vesting".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn mock_dependencies_custom(
InstantiateMsg {
ado_type: "lockdrop".to_string(),
ado_version: "test".to_string(),
operators: None,

kernel_address: MOCK_KERNEL_CONTRACT.to_string(),
owner: None,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn instantiate(
BaseInstantiateMsg {
ado_type: "weighted-distribution-splitter".to_string(),
ado_version: CONTRACT_VERSION.to_string(),
operators: None,

kernel_address: msg.kernel_address,
owner: msg.owner,
},
Expand Down
Loading

0 comments on commit 1f70a51

Please sign in to comment.