diff --git a/src/state/participant.rs b/src/state/participant.rs index 07e9a85..a335d94 100644 --- a/src/state/participant.rs +++ b/src/state/participant.rs @@ -40,15 +40,10 @@ impl Participant { } } -#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug, Default)] pub enum AcceptanceStatus { Accepted, + #[default] Pending, Denied, -} - -impl Default for AcceptanceStatus { - fn default() -> Self { - AcceptanceStatus::Pending - } } \ No newline at end of file diff --git a/src/state/pool.rs b/src/state/pool.rs index 4a7ad46..bfafc3b 100644 --- a/src/state/pool.rs +++ b/src/state/pool.rs @@ -47,13 +47,13 @@ impl Pool { bump: u8 ) -> Result { if name.as_bytes().len() > Self::MAX_NAME_LEN { - return Err(StockpileError::DefaultError.into()); + return Err(StockpileError::DefaultError); } let current = Clock::get().unwrap(); let timestamp = current.unix_timestamp as u64; if timestamp > start { - return Err(StockpileError::DefaultError.into()); + return Err(StockpileError::DefaultError); } Ok(Self { @@ -74,7 +74,7 @@ impl Pool { let current = Clock::get().unwrap(); let timestamp = current.unix_timestamp as u64; if timestamp > self.end { - return Err(StockpileError::DefaultError.into()); + return Err(StockpileError::DefaultError); } if timestamp > self.start { @@ -82,39 +82,29 @@ impl Pool { } match self.pool_state { - PoolState::PendingStart => Err(StockpileError::DefaultError.into()), + PoolState::PendingStart => Err(StockpileError::DefaultError), PoolState::Active => Ok(()), - PoolState::Distributed => Err(StockpileError::DefaultError.into()), + PoolState::Distributed => Err(StockpileError::DefaultError), } } } -#[derive(BorshDeserialize, BorshSerialize, Clone, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, Debug, Default)] pub enum PoolState { + #[default] PendingStart, Active, Distributed, } -impl Default for PoolState { - fn default() -> Self { - PoolState::PendingStart - } -} - -#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug, Default)] pub enum PoolAccess { Open, + #[default] Manual, TokenGated(TokenGateInfo), } -impl Default for PoolAccess { - fn default() -> Self { - PoolAccess::Manual - } -} - #[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug)] pub struct TokenGateInfo { pub mint: Pubkey, @@ -126,19 +116,14 @@ pub struct TokenGateInfo { // 2. Civic - Runs a Civic Gateway check on the user & requires them to have a pass // 3. Relayer - Requires signing by specified keys (usually via an API endpoint) // 4. Custom - Add a serialized ix, and perform the check via your own on-chain program. -#[derive(BorshDeserialize, BorshSerialize, Clone, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, Debug, Default)] pub enum SybilStrategy { + #[default] None, Relayer(Vec), Custom(CustomStrategy) } -impl Default for SybilStrategy { - fn default() -> Self { - SybilStrategy::None - } -} - #[derive(BorshDeserialize, BorshSerialize, Clone, Debug)] pub struct CustomStrategy { pub program_id: Pubkey, diff --git a/src/state/pool_result.rs b/src/state/pool_result.rs index 79b7610..9a6a0d5 100644 --- a/src/state/pool_result.rs +++ b/src/state/pool_result.rs @@ -49,21 +49,16 @@ impl PoolResult { + 4 // Enum (Singleton) + 1 // u8 + 128; // Padding - - return size + + size } } -#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, PartialEq, Debug, Default)] pub enum ResultState { + #[default] NotStarted, // Calculations have not begun yet Pending, // Calculations are in progress, but not all participants & tables have been accounted Confirmed, // Participant calculations are confirmed, final proportions are pending Completed // All calculations completed -} - -impl Default for ResultState { - fn default() -> Self { - ResultState::NotStarted - } } \ No newline at end of file diff --git a/src/state/vault.rs b/src/state/vault.rs index 278352d..581c86d 100644 --- a/src/state/vault.rs +++ b/src/state/vault.rs @@ -30,7 +30,7 @@ impl Vault { bump: u8 ) -> Result { if name.as_bytes().len() > Self::MAX_NAME_LEN { - return Err(StockpileError::DefaultError.into()); + return Err(StockpileError::DefaultError); } Ok(Self { @@ -44,22 +44,17 @@ impl Vault { pub fn is_active(&mut self) -> Result<(), StockpileError> { match self.vault_state { - VaultState::Closed => Err(StockpileError::DefaultError.into()), + VaultState::Closed => Err(StockpileError::DefaultError), VaultState::Active => Ok(()), - VaultState::Deactivated => Err(StockpileError::DefaultError.into()), + VaultState::Deactivated => Err(StockpileError::DefaultError), } } } -#[derive(BorshDeserialize, BorshSerialize, Clone, Debug)] +#[derive(BorshDeserialize, BorshSerialize, Clone, Debug, Default)] pub enum VaultState { + #[default] Active, Deactivated, Closed, -} - -impl Default for VaultState { - fn default() -> Self { - VaultState::Active - } } \ No newline at end of file diff --git a/src/state/vote_table.rs b/src/state/vote_table.rs index c763533..7c5ff90 100644 --- a/src/state/vote_table.rs +++ b/src/state/vote_table.rs @@ -95,18 +95,13 @@ impl VoteTable { } } -#[derive(BorshSerialize, BorshDeserialize, Debug, Clone, PartialEq)] +#[derive(BorshSerialize, BorshDeserialize, Debug, Clone, PartialEq, Default)] pub enum VoteStatus { + #[default] Valid, Invalid } -impl Default for VoteStatus { - fn default() -> Self { - VoteStatus::Valid - } -} - #[derive(BorshDeserialize, BorshSerialize, Debug, Clone)] pub struct VoteTicket { pub voter: Pubkey,