Просмотр исходного кода

contract/money: Fix typos in some of the error enums.

parazyd 3 лет назад
Родитель
Сommit
6df3990e8a

+ 3 - 3
src/contract/consensus/src/entrypoint/unstake_v1.rs

@@ -131,7 +131,7 @@ pub(crate) fn consensus_unstake_process_instruction_v1(
     let next_call_idx = call_idx + 1;
     if next_call_idx >= calls.len() as u32 {
         msg!("[ConsensusUnstakeV1] Error: next_call_idx out of bounds");
-        return Err(MoneyError::SpendHookOutOfBounds.into())
+        return Err(MoneyError::CallIdxOutOfBounds.into())
     }
 
     let next = &calls[next_call_idx as usize];
@@ -143,14 +143,14 @@ pub(crate) fn consensus_unstake_process_instruction_v1(
     // Verify next call corresponds to Money::UnstakeV1 (0x07)
     if next.data[0] != 0x07 {
         msg!("[ConsensusUnstakeV1] Error: Next call function mismatch");
-        return Err(MoneyError::NextCallFunctionMissmatch.into())
+        return Err(MoneyError::NextCallFunctionMismatch.into())
     }
 
     // Verify next call StakeInput is the same as this calls input
     let next_params: MoneyUnstakeParamsV1 = deserialize(&next.data[1..])?;
     if input != &next_params.input {
         msg!("[ConsensusUnstakeV1] Error: Next call input mismatch");
-        return Err(MoneyError::NextCallInputMissmatch.into())
+        return Err(MoneyError::NextCallInputMismatch.into())
     }
 
     // At this point the state transition has passed, so we create a state update

+ 3 - 3
src/contract/money/src/entrypoint/stake_v1.rs

@@ -133,7 +133,7 @@ pub(crate) fn money_stake_process_instruction_v1(
     let next_call_idx = call_idx + 1;
     if next_call_idx >= calls.len() as u32 {
         msg!("[MoneyStakeV1] Error: next_call_idx out of bounds");
-        return Err(MoneyError::SpendHookOutOfBounds.into())
+        return Err(MoneyError::CallIdxOutOfBounds.into())
     }
 
     // Verify next call corresponds to Consensus::StakeV1 (0x01)
@@ -145,14 +145,14 @@ pub(crate) fn money_stake_process_instruction_v1(
 
     if next.data[0] != 0x01 {
         msg!("[MoneyStakeV1] Error: Next call function mismatch");
-        return Err(MoneyError::NextCallFunctionMissmatch.into())
+        return Err(MoneyError::NextCallFunctionMismatch.into())
     }
 
     // Verify next call ConsensusInput is the same as this calls input
     let next_params: ConsensusStakeParamsV1 = deserialize(&next.data[1..])?;
     if input != &next_params.input {
         msg!("[MoneyStakeV1] Error: Next call input mismatch");
-        return Err(MoneyError::NextCallInputMissmatch.into())
+        return Err(MoneyError::NextCallInputMismatch.into())
     }
 
     // At this point the state transition has passed, so we create a state update

+ 1 - 1
src/contract/money/src/entrypoint/transfer_v1.rs

@@ -197,7 +197,7 @@ pub(crate) fn money_transfer_process_instruction_v1(
             let next_call_idx = call_idx + 1;
             if next_call_idx >= calls.len() as u32 {
                 msg!("[TransferV1] Error: next_call_idx out of bounds (input {})", i);
-                return Err(MoneyError::SpendHookOutOfBounds.into())
+                return Err(MoneyError::CallIdxOutOfBounds.into())
             }
 
             let next = &calls[next_call_idx as usize];

+ 4 - 4
src/contract/money/src/entrypoint/unstake_v1.rs

@@ -132,7 +132,7 @@ pub(crate) fn money_unstake_process_instruction_v1(
     // Check previous call is consensus contract
     if call_idx == 0 {
         msg!("[MoneyUnstakeV1] Error: previous_call_idx will be out of bounds");
-        return Err(MoneyError::SpendHookOutOfBounds.into())
+        return Err(MoneyError::CallIdxOutOfBounds.into())
     }
 
     let previous_call_idx = call_idx - 1;
@@ -145,7 +145,7 @@ pub(crate) fn money_unstake_process_instruction_v1(
     // Verify previous call corresponds to Consensus::UnstakeV1 (0x04)
     if previous.data[0] != 0x04 {
         msg!("[MoneyUnstakeV1] Error: Previous call function mismatch");
-        return Err(MoneyError::PreviousCallFunctionMissmatch.into())
+        return Err(MoneyError::PreviousCallFunctionMismatch.into())
     }
 
     // Verify previous call input is the same as this calls StakeInput
@@ -153,7 +153,7 @@ pub(crate) fn money_unstake_process_instruction_v1(
     let previous_input = &previous_params.input;
     if previous_input != input {
         msg!("[MoneyUnstakeV1] Error: Previous call input mismatch");
-        return Err(MoneyError::PreviousCallInputMissmatch.into())
+        return Err(MoneyError::PreviousCallInputMismatch.into())
     }
 
     // If next spend hook is set, check its correctness
@@ -161,7 +161,7 @@ pub(crate) fn money_unstake_process_instruction_v1(
         let next_call_idx = call_idx + 1;
         if next_call_idx >= calls.len() as u32 {
             msg!("[MoneyUnstakeV1] Error: next_call_idx out of bounds");
-            return Err(MoneyError::SpendHookOutOfBounds.into())
+            return Err(MoneyError::CallIdxOutOfBounds.into())
         }
 
         let next = &calls[next_call_idx as usize];

+ 11 - 11
src/contract/money/src/error.rs

@@ -43,8 +43,8 @@ pub enum MoneyError {
     #[error("Duplicate nullifier found")]
     DuplicateNullifier,
 
-    #[error("Spend hook out of bounds")]
-    SpendHookOutOfBounds,
+    #[error("Call index out of bounds")]
+    CallIdxOutOfBounds,
 
     #[error("Spend hook mismatch")]
     SpendHookMismatch,
@@ -101,16 +101,16 @@ pub enum MoneyError {
     UnstakePreviousCallNotConsensusContract,
 
     #[error("Next call function mismatch")]
-    NextCallFunctionMissmatch,
+    NextCallFunctionMismatch,
 
     #[error("Next call input mismatch")]
-    NextCallInputMissmatch,
+    NextCallInputMismatch,
 
     #[error("Previous call function mismatch")]
-    PreviousCallFunctionMissmatch,
+    PreviousCallFunctionMismatch,
 
     #[error("Previous call input mismatch")]
-    PreviousCallInputMissmatch,
+    PreviousCallInputMismatch,
 
     #[error("Call is not executed on genesis slot")]
     GenesisCallNonGenesisSlot,
@@ -126,7 +126,7 @@ impl From<MoneyError> for ContractError {
             MoneyError::TransferClearInputUnauthorised => Self::Custom(5),
             MoneyError::TransferMerkleRootNotFound => Self::Custom(6),
             MoneyError::DuplicateNullifier => Self::Custom(7),
-            MoneyError::SpendHookOutOfBounds => Self::Custom(8),
+            MoneyError::CallIdxOutOfBounds => Self::Custom(8),
             MoneyError::SpendHookMismatch => Self::Custom(9),
             MoneyError::DuplicateCoin => Self::Custom(10),
             MoneyError::ValueMismatch => Self::Custom(11),
@@ -145,10 +145,10 @@ impl From<MoneyError> for ContractError {
             MoneyError::UnstakeSpendHookNotConsensusContract => Self::Custom(24),
             MoneyError::UnstakeNextCallNotMoneyContract => Self::Custom(25),
             MoneyError::UnstakePreviousCallNotConsensusContract => Self::Custom(26),
-            MoneyError::NextCallFunctionMissmatch => Self::Custom(27),
-            MoneyError::NextCallInputMissmatch => Self::Custom(28),
-            MoneyError::PreviousCallFunctionMissmatch => Self::Custom(29),
-            MoneyError::PreviousCallInputMissmatch => Self::Custom(30),
+            MoneyError::NextCallFunctionMismatch => Self::Custom(27),
+            MoneyError::NextCallInputMismatch => Self::Custom(28),
+            MoneyError::PreviousCallFunctionMismatch => Self::Custom(29),
+            MoneyError::PreviousCallInputMismatch => Self::Custom(30),
             MoneyError::GenesisCallNonGenesisSlot => Self::Custom(31),
         }
     }