Skip to content

Commit

Permalink
move shutdown notice in lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Giannis Chatziveroglou committed Jul 21, 2023
1 parent f14998f commit 72d38e2
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 42 deletions.
49 changes: 33 additions & 16 deletions programs/cardinal-rewards-center/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::errors::ErrorCode;
pub mod stake_pool;
pub use stake_pool::*;
pub mod stake_entry;
Expand Down Expand Up @@ -26,8 +27,10 @@ pub mod cardinal_rewards_center {
use super::*;

//// stake_pool ////
pub fn init_pool(ctx: Context<InitPoolCtx>, ix: InitPoolIx) -> Result<()> {
stake_pool::init_pool::handler(ctx, ix)
pub fn init_pool(_ctx: Context<InitPoolCtx>, _ix: InitPoolIx) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 32 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:32:9 | 32 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default = help: remove `return`
// stake_pool::init_pool::handler(ctx, ix)
}
pub fn update_pool(ctx: Context<UpdatePoolCtx>, ix: UpdatePoolIx) -> Result<()> {
stake_pool::update_pool::handler(ctx, ix)
Expand All @@ -37,8 +40,10 @@ pub mod cardinal_rewards_center {
}

//// stake_entry ////
pub fn init_entry(ctx: Context<InitEntryCtx>, user: Pubkey) -> Result<()> {
stake_entry::init_entry::handler(ctx, user)
pub fn init_entry(_ctx: Context<InitEntryCtx>, _user: Pubkey) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 45 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:45:9 | 45 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_entry::init_pool::handler(ctx, user)
}
pub fn update_total_stake_seconds(ctx: Context<UpdateTotalStakeSecondsCtx>) -> Result<()> {
stake_entry::update_total_stake_seconds::handler(ctx)
Expand All @@ -65,21 +70,27 @@ pub mod cardinal_rewards_center {
stake_entry::close_stake_entry::handler(ctx)
}
//// stake_entry::editions ////
pub fn stake_edition<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, StakeEditionCtx<'info>>, amount: u64) -> Result<()> {
stake_entry::editions::stake_edition::handler(ctx, amount)
pub fn stake_edition<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeEditionCtx<'info>>, _amount: u64) -> Result<()> {

Check warning on line 73 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining

warning: the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining --> programs/cardinal-rewards-center/src/lib.rs:73:5 | 73 | pub fn stake_edition<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeEditionCtx<'info>>, _amount: u64) -> Result<()... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 73 - pub fn stake_edition<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeEditionCtx<'info>>, _amount: u64) -> Result<()> { 73 + pub fn stake_edition<'info>(_ctx: Context<'_, '_, '_, 'info, StakeEditionCtx<'info>>, _amount: u64) -> Result<()> { |
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 75 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:75:9 | 75 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_entry::editions::stake_edition::handler(ctx, amount)
}
pub fn unstake_edition<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeEditionCtx<'info>>) -> Result<()> {

Check warning on line 78 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining

warning: the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining --> programs/cardinal-rewards-center/src/lib.rs:78:5 | 78 | pub fn unstake_edition<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeEditionCtx<'info>>) -> Result<()... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 78 - pub fn unstake_edition<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeEditionCtx<'info>>) -> Result<()> { 78 + pub fn unstake_edition<'info>(ctx: Context<'_, '_, '_, 'info, UnstakeEditionCtx<'info>>) -> Result<()> { |
stake_entry::editions::unstake_edition::handler(ctx)
}
//// stake_entry::ccs ////
pub fn stake_ccs<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, StakeCCSCtx<'info>>, amount: u64) -> Result<()> {
stake_entry::ccs::stake_ccs::handler(ctx, amount)
pub fn stake_ccs<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeCCSCtx<'info>>, _amount: u64) -> Result<()> {

Check warning on line 82 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining

warning: the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining --> programs/cardinal-rewards-center/src/lib.rs:82:5 | 82 | pub fn stake_ccs<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeCCSCtx<'info>>, _amount: u64) -> Result<()... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 82 - pub fn stake_ccs<'key, 'accounts, 'remaining, 'info>(_ctx: Context<'key, 'accounts, 'remaining, 'info, StakeCCSCtx<'info>>, _amount: u64) -> Result<()> { 82 + pub fn stake_ccs<'info>(_ctx: Context<'_, '_, '_, 'info, StakeCCSCtx<'info>>, _amount: u64) -> Result<()> { |
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 84 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:84:9 | 84 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_entry::ccs::stake_ccs::handler(ctx, amount)
}
pub fn unstake_ccs<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeCCSCtx<'info>>) -> Result<()> {

Check warning on line 87 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining

warning: the following explicit lifetimes could be elided: 'key, 'accounts, 'remaining --> programs/cardinal-rewards-center/src/lib.rs:87:5 | 87 | pub fn unstake_ccs<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeCCSCtx<'info>>) -> Result<()... | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 87 - pub fn unstake_ccs<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts, 'remaining, 'info, UnstakeCCSCtx<'info>>) -> Result<()> { 87 + pub fn unstake_ccs<'info>(ctx: Context<'_, '_, '_, 'info, UnstakeCCSCtx<'info>>) -> Result<()> { |
stake_entry::ccs::unstake_ccs::handler(ctx)
}
pub fn stake_pnft(ctx: Context<StakePNFTCtx>) -> Result<()> {
stake_entry::pnfts::stake_pnft::handler(ctx)
pub fn stake_pnft(_ctx: Context<StakePNFTCtx>) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 92 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:92:9 | 92 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_entry::pnfts::stake_pnft::handler(ctx)
}

pub fn unstake_pnft(ctx: Context<UnstakePNFTCtx>) -> Result<()> {
Expand All @@ -95,14 +106,18 @@ pub mod cardinal_rewards_center {
}

//// stake_booster ////
pub fn init_stake_booster(ctx: Context<InitStakeBoosterCtx>, ix: InitStakeBoosterIx) -> Result<()> {
stake_booster::init_stake_booster::handler(ctx, ix)
pub fn init_stake_booster(_ctx: Context<InitStakeBoosterCtx>, _ix: InitStakeBoosterIx) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 111 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:111:9 | 111 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_booster::init_stake_booster::handler(ctx, ix)
}
pub fn update_stake_booster(ctx: Context<UpdateStakeBoosterCtx>, ix: UpdateStakeBoosterIx) -> Result<()> {
stake_booster::update_stake_booster::handler(ctx, ix)
}
pub fn boost_stake_entry(ctx: Context<BoostStakeEntryCtx>, ix: BoostStakeEntryIx) -> Result<()> {
stake_booster::boost_stake_entry::handler(ctx, ix)
pub fn boost_stake_entry(_ctx: Context<BoostStakeEntryCtx>, _ix: BoostStakeEntryIx) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 119 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:119:9 | 119 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// stake_booster::boost_stake_entry::handler(ctx, ix)
}
pub fn close_stake_booster(ctx: Context<CloseStakeBoosterCtx>) -> Result<()> {
stake_booster::close_stake_booster::handler(ctx)
Expand Down Expand Up @@ -136,8 +151,10 @@ pub mod cardinal_rewards_center {

//// reward_distribution ////
//// reward_distribution::reward_distributor ////
pub fn init_reward_distributor(ctx: Context<InitRewardDistributorCtx>, ix: InitRewardDistributorIx) -> Result<()> {
reward_distribution::reward_distributor::init_reward_distributor::handler(ctx, ix)
pub fn init_reward_distributor(_ctx: Context<InitRewardDistributorCtx>, _ix: InitRewardDistributorIx) -> Result<()> {
// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));

Check warning on line 156 in programs/cardinal-rewards-center/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> programs/cardinal-rewards-center/src/lib.rs:156:9 | 156 | return Err(error!(ErrorCode::ProtocolsShutdown)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = help: remove `return`
// reward_distribution::reward_distributor::init_reward_distributor::handler(ctx, ix)
}
pub fn update_reward_distributor(ctx: Context<UpdateRewardDistributorCtx>, ix: UpdateRewardDistributorIx) -> Result<()> {
reward_distribution::reward_distributor::update_reward_distributor::handler(ctx, ix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,5 @@ pub fn handler(ctx: Context<InitRewardDistributorCtx>, ix: InitRewardDistributor

assert_payment_info(ctx.accounts.stake_pool.key(), Action::ClaimRewards, ix.claim_rewards_payment_info)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,5 @@ pub fn handler(ctx: Context<BoostStakeEntryCtx>, ix: BoostStakeEntryIx) -> Resul
)?;
handle_payment_info(ctx.accounts.stake_booster.boost_action_payment_info, remaining_accounts)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,5 @@ pub fn handler(ctx: Context<InitStakeBoosterCtx>, ix: InitStakeBoosterIx) -> Res
stake_booster.start_time_seconds = ix.start_time_seconds;
stake_booster.boost_action_payment_info = ix.boost_action_payment_info;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,5 @@ pub fn handler<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts,
stake_pool.total_staked = stake_pool.total_staked.checked_add(1).expect("Add error");
stake_entry_fill_zeros(stake_entry)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,5 @@ pub fn handler<'key, 'accounts, 'remaining, 'info>(ctx: Context<'key, 'accounts,
stake_pool.total_staked = stake_pool.total_staked.checked_add(1).expect("Add error");
stake_entry_fill_zeros(stake_entry)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::authorization::mint_is_allowed;
use crate::errors::ErrorCode;
use crate::stake_seed;
use crate::StakeEntry;
use crate::StakePool;
Expand Down Expand Up @@ -43,7 +42,5 @@ pub fn handler(ctx: Context<InitEntryCtx>, _user: Pubkey) -> Result<()> {
let remaining_accounts = &mut ctx.remaining_accounts.iter();
mint_is_allowed(stake_pool, &ctx.accounts.stake_mint_metadata, ctx.accounts.stake_mint.key(), remaining_accounts)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,5 @@ pub fn handler(ctx: Context<StakePNFTCtx>) -> Result<()> {
&[&user_escrow_seeds.iter().map(|s| s.as_slice()).collect::<Vec<&[u8]>>()],
)?;

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}
5 changes: 1 addition & 4 deletions programs/cardinal-rewards-center/src/stake_pool/init_pool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::assert_payment_info;
use crate::errors::ErrorCode;
use crate::utils::resize_account;
use crate::Action;
use crate::StakePool;
Expand Down Expand Up @@ -73,7 +72,5 @@ pub fn handler(ctx: Context<InitPoolCtx>, ix: InitPoolIx) -> Result<()> {

stake_pool.set_inner(new_stake_pool);

// shutdown
return Err(error!(ErrorCode::ProtocolsShutdown));
// Ok(())
Ok(())
}

0 comments on commit 72d38e2

Please sign in to comment.