From b8e34e380de4928d3fd7a4675ab97ab1e33c36d9 Mon Sep 17 00:00:00 2001 From: Bao Date: Tue, 27 Dec 2022 16:57:42 -0800 Subject: [PATCH] refactor to policy_module_irrevocable --- .../cwd-proposal-delegate/src/contract.rs | 10 ++++++---- .../cwd-proposal-delegate/src/state.rs | 2 +- .../cwd-proposal-delegate/src/testing/tests.rs | 18 +++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/contracts/proposal/cwd-proposal-delegate/src/contract.rs b/contracts/proposal/cwd-proposal-delegate/src/contract.rs index 7bd71c21b..9ea552776 100644 --- a/contracts/proposal/cwd-proposal-delegate/src/contract.rs +++ b/contracts/proposal/cwd-proposal-delegate/src/contract.rs @@ -52,7 +52,8 @@ pub fn execute( policy_irrevocable, policy_preserve_on_failure, } => { - let policy_irrevocable = policy_irrevocable.unwrap_or(DEFAULT_POLICY_IRREVOCABLE); + let policy_module_irrevocable = + policy_irrevocable.unwrap_or(DEFAULT_POLICY_IRREVOCABLE); let policy_preserve_on_failure = policy_preserve_on_failure.unwrap_or(DEFAULT_POLICY_PRESERVE_ON_FAILURE); let delegate = deps.api.addr_validate(&delegate)?; @@ -64,7 +65,7 @@ pub fn execute( delegate, msgs, expiration, - policy_irrevocable, + policy_module_irrevocable, policy_preserve_on_failure, }, ) @@ -158,9 +159,10 @@ pub fn execute_remove_delegation( } // If delegation is irrevocable, return Error let Delegation { - policy_irrevocable, .. + policy_module_irrevocable, + .. } = DELEGATIONS.load(deps.storage, delegation_id)?; - if policy_irrevocable { + if policy_module_irrevocable { return Err(ContractError::DelegationIrrevocable {}); } // Else remove the delegation diff --git a/contracts/proposal/cwd-proposal-delegate/src/state.rs b/contracts/proposal/cwd-proposal-delegate/src/state.rs index e0ba93217..36f90fea6 100644 --- a/contracts/proposal/cwd-proposal-delegate/src/state.rs +++ b/contracts/proposal/cwd-proposal-delegate/src/state.rs @@ -14,7 +14,7 @@ pub struct Delegation { pub msgs: Vec>, pub expiration: Option, - pub policy_irrevocable: bool, + pub policy_module_irrevocable: bool, pub policy_preserve_on_failure: bool, } diff --git a/contracts/proposal/cwd-proposal-delegate/src/testing/tests.rs b/contracts/proposal/cwd-proposal-delegate/src/testing/tests.rs index 26b680158..260959882 100644 --- a/contracts/proposal/cwd-proposal-delegate/src/testing/tests.rs +++ b/contracts/proposal/cwd-proposal-delegate/src/testing/tests.rs @@ -40,7 +40,7 @@ fn test_unauthorized_delegation() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: true, }, ) @@ -58,7 +58,7 @@ fn test_unauthorized_delegation() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, ) @@ -93,7 +93,7 @@ fn test_execute_authorization() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, ) @@ -145,7 +145,7 @@ fn test_execute_authorization() { delegate: Addr::unchecked("dest_addr_2"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, ) @@ -211,7 +211,7 @@ fn test_execute_on_failure_policy() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, ) @@ -241,7 +241,7 @@ fn test_execute_on_failure_policy() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: true, }, ) @@ -306,7 +306,7 @@ fn test_execute_on_expired() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: Some(Expiration::AtHeight(10)), - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, ) @@ -358,7 +358,7 @@ fn test_revocable_policy() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: true, // Make it irrevocable + policy_module_irrevocable: true, // Make it irrevocable policy_preserve_on_failure: false, }, ) @@ -381,7 +381,7 @@ fn test_revocable_policy() { delegate: Addr::unchecked("dest_addr"), msgs: Vec::new(), expiration: None, - policy_irrevocable: false, + policy_module_irrevocable: false, policy_preserve_on_failure: false, }, )