CRC: revert needless return changes for clarity

Signed-off-by: Jacinta Ferrant <jacinta@trustmachines.co>
This commit is contained in:
Jacinta Ferrant
2023-10-03 15:11:40 -07:00
committed by Joey Yandle
parent fd0cdc3e00
commit 5be4534eaf
3 changed files with 62 additions and 41 deletions

View File

@@ -119,6 +119,7 @@ pub fn pox_lock_v1(
}
/// Handle special cases when calling into the PoX v1 contract
#[allow(clippy::needless_return)]
pub fn handle_contract_call(
global_context: &mut GlobalContext,
_sender_opt: Option<&PrincipalData>,
@@ -171,18 +172,20 @@ pub fn handle_contract_call(
}),
));
}
Ok(())
return Ok(());
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(LockingError::PoxAlreadyLocked) => {
// the caller tried to lock tokens into both pox-1 and pox-2
Err(ClarityError::Runtime(
return Err(ClarityError::Runtime(
RuntimeErrorType::PoxAlreadyLocked,
None,
))
));
}
Err(e) => {
panic!(

View File

@@ -272,6 +272,7 @@ fn pox_lock_v2(
}
/// Handle responses from stack-stx and delegate-stack-stx -- functions that *lock up* STX
#[allow(clippy::needless_return)]
fn handle_stack_lockup_pox_v2(
global_context: &mut GlobalContext,
function_name: &str,
@@ -310,18 +311,20 @@ fn handle_stack_lockup_pox_v2(
locked_address: stacker,
contract_identifier: boot_code_id("pox-2", global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(LockingError::PoxAlreadyLocked) => {
// the caller tried to lock tokens into both pox-1 and pox-2
Err(ClarityError::Runtime(
return Err(ClarityError::Runtime(
RuntimeErrorType::PoxAlreadyLocked,
None,
))
));
}
Err(e) => {
panic!(
@@ -334,6 +337,7 @@ fn handle_stack_lockup_pox_v2(
/// Handle responses from stack-extend and delegate-stack-extend -- functions that *extend
/// already-locked* STX.
#[allow(clippy::needless_return)]
fn handle_stack_lockup_extension_pox_v2(
global_context: &mut GlobalContext,
function_name: &str,
@@ -375,12 +379,14 @@ fn handle_stack_lockup_extension_pox_v2(
locked_address: stacker,
contract_identifier: boot_code_id("pox-2", global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(e) => {
// Error results *other* than a DefunctPoxContract panic, because
// those errors should have been caught by the PoX contract before
@@ -395,6 +401,7 @@ fn handle_stack_lockup_extension_pox_v2(
/// Handle responses from stack-increase and delegate-stack-increase -- functions that *increase
/// already-locked* STX amounts.
#[allow(clippy::needless_return)]
fn handle_stack_lockup_increase_pox_v2(
global_context: &mut GlobalContext,
function_name: &str,
@@ -435,12 +442,14 @@ fn handle_stack_lockup_increase_pox_v2(
contract_identifier: boot_code_id("pox-2", global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(e) => {
// Error results *other* than a DefunctPoxContract panic, because
// those errors should have been caught by the PoX contract before

View File

@@ -153,6 +153,7 @@ pub fn pox_lock_increase_v3(
/////////////// PoX-3 //////////////////////////////////////////
/// Handle responses from stack-stx and delegate-stack-stx in pox-3 -- functions that *lock up* STX
#[allow(clippy::needless_return)]
fn handle_stack_lockup_pox_v3(
global_context: &mut GlobalContext,
function_name: &str,
@@ -193,18 +194,20 @@ fn handle_stack_lockup_pox_v3(
locked_address: stacker,
contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(LockingError::PoxAlreadyLocked) => {
// the caller tried to lock tokens into multiple pox contracts
Err(ClarityError::Runtime(
return Err(ClarityError::Runtime(
RuntimeErrorType::PoxAlreadyLocked,
None,
))
));
}
Err(e) => {
panic!(
@@ -217,6 +220,7 @@ fn handle_stack_lockup_pox_v3(
/// Handle responses from stack-extend and delegate-stack-extend in pox-3 -- functions that *extend
/// already-locked* STX.
#[allow(clippy::needless_return)]
fn handle_stack_lockup_extension_pox_v3(
global_context: &mut GlobalContext,
function_name: &str,
@@ -258,12 +262,14 @@ fn handle_stack_lockup_extension_pox_v3(
locked_address: stacker,
contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(e) => {
// Error results *other* than a DefunctPoxContract panic, because
// those errors should have been caught by the PoX contract before
@@ -278,6 +284,7 @@ fn handle_stack_lockup_extension_pox_v3(
/// Handle responses from stack-increase and delegate-stack-increase in PoX-3 -- functions
/// that *increase already-locked* STX amounts.
#[allow(clippy::needless_return)]
fn handle_stack_lockup_increase_pox_v3(
global_context: &mut GlobalContext,
function_name: &str,
@@ -317,12 +324,14 @@ fn handle_stack_lockup_increase_pox_v3(
contract_identifier: boot_code_id(POX_3_NAME, global_context.mainnet),
}));
Ok(Some(event))
return Ok(Some(event));
}
Err(LockingError::DefunctPoxContract) => {
return Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
));
}
Err(LockingError::DefunctPoxContract) => Err(ClarityError::Runtime(
RuntimeErrorType::DefunctPoxContract,
None,
)),
Err(e) => {
// Error results *other* than a DefunctPoxContract panic, because
// those errors should have been caught by the PoX contract before