You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use {
anchor_lang::prelude::*,
crate::{state::*, utils::*},
anchor_spl::*,
std::mem::size_of
};
pub fn handler(ctx: Context<InitializePool>) -> Result <()> {
check_token_program(ctx.accounts.token_program.key());
// initialize pool state
let pool_state = &mut ctx.accounts.pool_state;
pool_state.bump = ctx.bumps.pool_state;
pool_state.amount = 0;
pool_state.vault_bump = ctx.bumps.token_vault;
pool_state.vault_auth_bump = ctx.bumps.pool_authority;
pool_state.token_mint = ctx.accounts.token_mint.key();
pool_state.staking_token_mint = ctx.accounts.staking_token_mint.key();
pool_state.vault_authority = ctx.accounts.pool_authority.key();
msg!("Staking pool created!");
Ok(())
}
#[derive(Accounts)]
pub struct InitializePool<'info> {
/// CHECK: PDA, auth over all token vaults
#[account(
seeds = [VAULT_AUTH_SEED.as_bytes()],
bump
)]
pub pool_authority: UncheckedAccount<'info>,
// pool state account
#[account(
init,
seeds = [token_mint.key().as_ref(), STAKE_POOL_STATE_SEED.as_bytes()],
bump,
payer = payer,
space = 8 + size_of::<PoolState>()
)]
pub pool_state: Account<'info, PoolState>,
// Mint of token
#[account(
mint::token_program = token_program,
mint::authority = payer
)]
pub token_mint: InterfaceAccount<'info, token_interface::Mint>,
// pool token account for Token Mint
#[account(
init,
token::mint = token_mint,
token::authority = pool_authority,
token::token_program = token_program,
// use token_mint, pool auth, and constant as seeds for token a vault
seeds = [token_mint.key().as_ref(), pool_authority.key().as_ref(), VAULT_SEED.as_bytes()],
bump,
payer = payer,
)]
pub token_vault: InterfaceAccount<'info, token_interface::TokenAccount>,
// Mint of staking token
#[account(
mut,
mint::token_program = token_program
)]
pub staking_token_mint: InterfaceAccount<'info, token_interface::Mint>,
// payer, will pay for creation of pool vault
#[account(mut)]
pub payer: Signer<'info>,
pub token_program: Interface<'info, token_interface::TokenInterface>,
pub system_program: Program<'info, System>,
pub rent: Sysvar<'info, Rent>
}
error[E0599]: no function or associated item named `create_type` found for struct `anchor_spl::token_interface::Mint` in the current scope
--> programs/token22-staking-latest/src/instructions/init_pool.rs:26:10
|
26 | #[derive(Accounts)]
| ^^^^^^^^ function or associated item not found in `Mint`
|
= note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `anchor_spl::token_interface::Mint: Discriminator` is not satisfied
--> programs/token22-staking-latest/src/instructions/init_pool.rs:48:45
|
48 | pub token_mint: InterfaceAccount<'info, token_interface::Mint>,
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Discriminator` is not implemented for `anchor_spl::token_interface::Mint`
|
= help: the following other types implement trait `Discriminator`:
InitPool
InitStakeEntry
StakeEntry
__idl::IdlAccount
anchor_lang::ProgramData
anchor_lang::idl::IdlAccount
instruction::Stake
instruction::Unstake
state::PoolState
error[E0599]: no function or associated item named `insert_types` found for struct `anchor_spl::token_interface::Mint` in the current scope
--> programs/token22-staking-latest/src/instructions/init_pool.rs:26:10
|
26 | #[derive(Accounts)]
| ^^^^^^^^ function or associated item not found in `Mint`
|
= note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0599]: no function or associated item named `create_type` found for struct `anchor_spl::token_interface::TokenAccount` in the current scope
--> programs/token22-staking-latest/src/instructions/init_pool.rs:26:10
|
26 | #[derive(Accounts)]
| ^^^^^^^^ function or associated item not found in `TokenAccount`
|
= note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `anchor_spl::token_interface::TokenAccount: Discriminator` is not satisfied
--> programs/token22-staking-latest/src/instructions/init_pool.rs:60:46
|
60 | pub token_vault: InterfaceAccount<'info, token_interface::TokenAccount>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Discriminator` is not implemented for `anchor_spl::token_interface::TokenAccount`
|
= help: the following other types implement trait `Discriminator`:
InitPool
InitStakeEntry
StakeEntry
__idl::IdlAccount
anchor_lang::ProgramData
anchor_lang::idl::IdlAccount
instruction::Stake
instruction::Unstake
state::PoolState
error[E0599]: no function or associated item named `insert_types` found for struct `anchor_spl::token_interface::TokenAccount` in the current scope
--> programs/token22-staking-latest/src/instructions/init_pool.rs:26:10
|
26 | #[derive(Accounts)]
| ^^^^^^^^ function or associated item not found in `TokenAccount`
|
= note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `anchor_spl::token_interface::Mint: Discriminator` is not satisfied
--> programs/token22-staking-latest/src/instructions/init_pool.rs:66:53
|
66 | pub staking_token_mint: InterfaceAccount<'info, token_interface::Mint>,
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Discriminator` is not implemented for `anchor_spl::token_interface::Mint`
|
= help: the following other types implement trait `Discriminator`:
InitPool
InitStakeEntry
StakeEntry
__idl::IdlAccount
anchor_lang::ProgramData
anchor_lang::idl::IdlAccount
instruction::Stake
instruction::Unstake
state::PoolState
warning: unused variable: `stake_amount`
--> programs/token22-staking-latest/src/instructions/stake.rs:10:37
|
10 | pub fn handler(ctx: Context<Stake>, stake_amount: u64) -> Result <()> {
| ^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_stake_amount`
|
= note: `#[warn(unused_variables)]` on by default
Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
warning: `token22-staking-latest` (lib test) generated 5 warnings
error: could not compile `token22-staking-latest` (lib test) due to 7 previous errors; 5 warnings emitted
Error: Building IDL failed
token22-staking-latest/programs/token22-staking-latest/src/instructions/init_pool.rs:
The text was updated successfully, but these errors were encountered: