#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2018::*;
#[macro_use]
extern crate std;
use anchor_lang::{prelude::*, solana_program::system_program};
pub static ID: anchor_lang::solana_program::pubkey::Pubkey =
anchor_lang::solana_program::pubkey::Pubkey::new_from_array([
216u8, 55u8, 200u8, 93u8, 189u8, 81u8, 94u8, 109u8, 14u8, 249u8, 244u8, 106u8, 68u8, 214u8,
222u8, 190u8, 9u8, 25u8, 199u8, 75u8, 79u8, 230u8, 94u8, 137u8, 51u8, 187u8, 193u8, 48u8,
87u8, 222u8, 175u8, 163u8,
]);
pub fn check_id(id: &anchor_lang::solana_program::pubkey::Pubkey) -> bool {
id == &ID
}
pub fn id() -> anchor_lang::solana_program::pubkey::Pubkey {
ID
}
use turnstile::*;
pub mod program {
use super::*;
pub struct Turnstile;
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for Turnstile {
#[inline]
fn clone(&self) -> Turnstile {
match *self {
Turnstile => Turnstile,
}
}
}
impl anchor_lang::AccountDeserialize for Turnstile {
fn try_deserialize(
buf: &mut &[u8],
) -> std::result::Result<Self, anchor_lang::solana_program::program_error::ProgramError>
{
Turnstile::try_deserialize_unchecked(buf)
}
fn try_deserialize_unchecked(
_buf: &mut &[u8],
) -> std::result::Result<Self, anchor_lang::solana_program::program_error::ProgramError>
{
Ok(Turnstile)
}
}
impl anchor_lang::Id for Turnstile {
fn id() -> Pubkey {
ID
}
}
}
fn dispatch(program_id: &Pubkey, accounts: &[AccountInfo], data: &[u8]) -> ProgramResult {
let mut ix_data: &[u8] = data;
let sighash: [u8; 8] = {
let mut sighash: [u8; 8] = [0; 8];
sighash.copy_from_slice(&ix_data[..8]);
ix_data = &ix_data[8..];
sighash
};
if true {
if sighash == anchor_lang::idl::IDL_IX_TAG.to_le_bytes() {
return __private::__idl::__idl_dispatch(program_id, accounts, &ix_data);
}
}
match sighash {
[175, 175, 109, 31, 13, 152, 155, 237] => {
__private::__global::initialize(program_id, accounts, ix_data)
}
[35, 147, 18, 114, 196, 95, 215, 250] => {
__private::__global::coin(program_id, accounts, ix_data)
}
[143, 34, 101, 78, 188, 184, 199, 63] => {
__private::__global::push(program_id, accounts, ix_data)
}
_ => Err(anchor_lang::__private::ErrorCode::InstructionFallbackNotFound.into()),
}
}
mod __private {
use super::*;
pub mod __idl {
use super::*;
#[inline(never)]
#[cfg(not(feature = "no-idl"))]
pub fn __idl_dispatch(
program_id: &Pubkey,
accounts: &[AccountInfo],
idl_ix_data: &[u8],
) -> ProgramResult {
let mut accounts = accounts;
let mut data: &[u8] = idl_ix_data;
let ix = anchor_lang::idl::IdlInstruction::deserialize(&mut data)
.map_err(|_| anchor_lang::__private::ErrorCode::InstructionDidNotDeserialize)?;
match ix {
anchor_lang::idl::IdlInstruction::Create { data_len } => {
let mut accounts = anchor_lang::idl::IdlCreateAccounts::try_accounts(
program_id,
&mut accounts,
&[],
)?;
__idl_create_account(program_id, &mut accounts, data_len)?;
accounts.exit(program_id)?;
}
anchor_lang::idl::IdlInstruction::CreateBuffer => {
let mut accounts = anchor_lang::idl::IdlCreateBuffer::try_accounts(
program_id,
&mut accounts,
&[],
)?;
__idl_create_buffer(program_id, &mut accounts)?;
accounts.exit(program_id)?;
}
anchor_lang::idl::IdlInstruction::Write { data } => {
let mut accounts = anchor_lang::idl::IdlAccounts::try_accounts(
program_id,
&mut accounts,
&[],
)?;
__idl_write(program_id, &mut accounts, data)?;
accounts.exit(program_id)?;
}
anchor_lang::idl::IdlInstruction::SetAuthority { new_authority } => {
let mut accounts = anchor_lang::idl::IdlAccounts::try_accounts(
program_id,
&mut accounts,
&[],
)?;
__idl_set_authority(program_id, &mut accounts, new_authority)?;
accounts.exit(program_id)?;
}
anchor_lang::idl::IdlInstruction::SetBuffer => {
let mut accounts = anchor_lang::idl::IdlSetBuffer::try_accounts(
program_id,
&mut accounts,
&[],
)?;
__idl_set_buffer(program_id, &mut accounts)?;
accounts.exit(program_id)?;
}
}
Ok(())
}
#[inline(never)]
pub fn __idl_create_account(
program_id: &Pubkey,
accounts: &mut anchor_lang::idl::IdlCreateAccounts,
data_len: u64,
) -> ProgramResult {
if program_id != accounts.program.key {
return Err(anchor_lang::__private::ErrorCode::IdlInstructionInvalidProgram.into());
}
let from = accounts.from.key;
let (base, nonce) = Pubkey::find_program_address(&[], program_id);
let seed = anchor_lang::idl::IdlAccount::seed();
let owner = accounts.program.key;
let to = Pubkey::create_with_seed(&base, seed, owner).unwrap();
let space = 8 + 32 + 4 + data_len as usize;
let rent = Rent::get()?;
let lamports = rent.minimum_balance(space);
let seeds = &[&[nonce][..]];
let ix = anchor_lang::solana_program::system_instruction::create_account_with_seed(
from,
&to,
&base,
seed,
lamports,
space as u64,
owner,
);
anchor_lang::solana_program::program::invoke_signed(
&ix,
&[
accounts.from.clone(),
accounts.to.clone(),
accounts.base.clone(),
accounts.system_program.clone(),
],
&[seeds],
)?;
let mut idl_account = {
let mut account_data = accounts.to.try_borrow_data()?;
let mut account_data_slice: &[u8] = &account_data;
anchor_lang::idl::IdlAccount::try_deserialize_unchecked(&mut account_data_slice)?
};
idl_account.authority = *accounts.from.key;
let mut data = accounts.to.try_borrow_mut_data()?;
let dst: &mut [u8] = &mut data;
let mut cursor = std::io::Cursor::new(dst);
idl_account.try_serialize(&mut cursor)?;
Ok(())
}
#[inline(never)]
pub fn __idl_create_buffer(
program_id: &Pubkey,
accounts: &mut anchor_lang::idl::IdlCreateBuffer,
) -> ProgramResult {
let mut buffer = &mut accounts.buffer;
buffer.authority = *accounts.authority.key;
Ok(())
}
#[inline(never)]
pub fn __idl_write(
program_id: &Pubkey,
accounts: &mut anchor_lang::idl::IdlAccounts,
idl_data: Vec<u8>,
) -> ProgramResult {
let mut idl = &mut accounts.idl;
idl.data.extend(idl_data);
Ok(())
}
#[inline(never)]
pub fn __idl_set_authority(
program_id: &Pubkey,
accounts: &mut anchor_lang::idl::IdlAccounts,
new_authority: Pubkey,
) -> ProgramResult {
accounts.idl.authority = new_authority;
Ok(())
}
#[inline(never)]
pub fn __idl_set_buffer(
program_id: &Pubkey,
accounts: &mut anchor_lang::idl::IdlSetBuffer,
) -> ProgramResult {
accounts.idl.data = accounts.buffer.data.clone();
Ok(())
}
}
pub mod __state {
use super::*;
}
pub mod __interface {
use super::*;
}
pub mod __global {
use super::*;
#[inline(never)]
pub fn initialize(
program_id: &Pubkey,
accounts: &[AccountInfo],
ix_data: &[u8],
) -> ProgramResult {
let ix = instruction::Initialize::deserialize(&mut &ix_data[..])
.map_err(|_| anchor_lang::__private::ErrorCode::InstructionDidNotDeserialize)?;
let instruction::Initialize = ix;
let mut remaining_accounts: &[AccountInfo] = accounts;
let mut accounts =
Initialize::try_accounts(program_id, &mut remaining_accounts, ix_data)?;
turnstile::initialize(Context::new(program_id, &mut accounts, remaining_accounts))?;
accounts.exit(program_id)
}
#[inline(never)]
pub fn coin(
program_id: &Pubkey,
accounts: &[AccountInfo],
ix_data: &[u8],
) -> ProgramResult {
let ix = instruction::Coin::deserialize(&mut &ix_data[..])
.map_err(|_| anchor_lang::__private::ErrorCode::InstructionDidNotDeserialize)?;
let instruction::Coin { dummy_arg } = ix;
let mut remaining_accounts: &[AccountInfo] = accounts;
let mut accounts =
UpdateState::try_accounts(program_id, &mut remaining_accounts, ix_data)?;
turnstile::coin(
Context::new(program_id, &mut accounts, remaining_accounts),
dummy_arg,
)?;
accounts.exit(program_id)
}
#[inline(never)]
pub fn push(
program_id: &Pubkey,
accounts: &[AccountInfo],
ix_data: &[u8],
) -> ProgramResult {
let ix = instruction::Push::deserialize(&mut &ix_data[..])
.map_err(|_| anchor_lang::__private::ErrorCode::InstructionDidNotDeserialize)?;
let instruction::Push = ix;
let mut remaining_accounts: &[AccountInfo] = accounts;
let mut accounts =
UpdateState::try_accounts(program_id, &mut remaining_accounts, ix_data)?;
turnstile::push(Context::new(program_id, &mut accounts, remaining_accounts))?;
accounts.exit(program_id)
}
}
}
pub mod turnstile {
use super::*;
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
let state = &mut ctx.accounts.state;
state.locked = true;
state.res = false;
Ok(())
}
#[allow(unused_variables)]
pub fn coin(ctx: Context<UpdateState>, dummy_arg: String) -> ProgramResult {
let state = &mut ctx.accounts.state;
state.locked = false;
Ok(())
}
pub fn push(ctx: Context<UpdateState>) -> ProgramResult {
let state = &mut ctx.accounts.state;
if state.locked {
state.res = false;
} else {
state.locked = true;
state.res = true;
}
Ok(())
}
}
pub mod instruction {
use super::*;
pub mod state {
use super::*;
}
pub struct Initialize;
impl borsh::ser::BorshSerialize for Initialize {
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
Ok(())
}
}
impl borsh::de::BorshDeserialize for Initialize {
fn deserialize(
buf: &mut &[u8],
) -> ::core::result::Result<Self, borsh::maybestd::io::Error> {
Ok(Self {})
}
}
impl anchor_lang::InstructionData for Initialize {
fn data(&self) -> Vec<u8> {
let mut d = [175, 175, 109, 31, 13, 152, 155, 237].to_vec();
d.append(&mut self.try_to_vec().expect("Should always serialize"));
d
}
}
pub struct Coin {
pub dummy_arg: String,
}
impl borsh::ser::BorshSerialize for Coin
where
String: borsh::ser::BorshSerialize,
{
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
borsh::BorshSerialize::serialize(&self.dummy_arg, writer)?;
Ok(())
}
}
impl borsh::de::BorshDeserialize for Coin
where
String: borsh::BorshDeserialize,
{
fn deserialize(
buf: &mut &[u8],
) -> ::core::result::Result<Self, borsh::maybestd::io::Error> {
Ok(Self {
dummy_arg: borsh::BorshDeserialize::deserialize(buf)?,
})
}
}
impl anchor_lang::InstructionData for Coin {
fn data(&self) -> Vec<u8> {
let mut d = [35, 147, 18, 114, 196, 95, 215, 250].to_vec();
d.append(&mut self.try_to_vec().expect("Should always serialize"));
d
}
}
pub struct Push;
impl borsh::ser::BorshSerialize for Push {
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
Ok(())
}
}
impl borsh::de::BorshDeserialize for Push {
fn deserialize(
buf: &mut &[u8],
) -> ::core::result::Result<Self, borsh::maybestd::io::Error> {
Ok(Self {})
}
}
impl anchor_lang::InstructionData for Push {
fn data(&self) -> Vec<u8> {
let mut d = [143, 34, 101, 78, 188, 184, 199, 63].to_vec();
d.append(&mut self.try_to_vec().expect("Should always serialize"));
d
}
}
}
pub mod accounts {
pub use crate::__client_accounts_update_state::*;
pub use crate::__client_accounts_initialize::*;
}
pub struct Initialize<'info> {
# [account (init , payer = user , space = 8 + 2)]
pub state: Account<'info, State>,
#[account(signer)]
pub user: AccountInfo<'info>,
# [account (address = system_program :: ID)]
pub system_program: AccountInfo<'info>,
}
#[automatically_derived]
impl<'info> anchor_lang::Accounts<'info> for Initialize<'info>
where
'info: 'info,
{
#[inline(never)]
fn try_accounts(
program_id: &anchor_lang::solana_program::pubkey::Pubkey,
accounts: &mut &[anchor_lang::solana_program::account_info::AccountInfo<'info>],
ix_data: &[u8],
) -> std::result::Result<Self, anchor_lang::solana_program::program_error::ProgramError> {
let state = &accounts[0];
*accounts = &accounts[1..];
let user: AccountInfo = anchor_lang::Accounts::try_accounts(program_id, accounts, ix_data)?;
let system_program: AccountInfo =
anchor_lang::Accounts::try_accounts(program_id, accounts, ix_data)?;
let __anchor_rent = Rent::get()?;
let state = {
if !false
|| state.to_account_info().owner == &anchor_lang::solana_program::system_program::ID
{
let space = 8 + 2;
let payer = user.to_account_info();
let __current_lamports = state.to_account_info().lamports();
if __current_lamports == 0 {
let lamports = __anchor_rent.minimum_balance(space);
anchor_lang::solana_program::program::invoke_signed(
&anchor_lang::solana_program::system_instruction::create_account(
payer.to_account_info().key,
state.to_account_info().key,
lamports,
space as u64,
program_id,
),
&[
payer.to_account_info(),
state.to_account_info(),
system_program.to_account_info(),
],
&[],
)?;
} else {
let required_lamports = __anchor_rent
.minimum_balance(space)
.max(1)
.saturating_sub(__current_lamports);
if required_lamports > 0 {
anchor_lang::solana_program::program::invoke(
&anchor_lang::solana_program::system_instruction::transfer(
payer.to_account_info().key,
state.to_account_info().key,
required_lamports,
),
&[
payer.to_account_info(),
state.to_account_info(),
system_program.to_account_info(),
],
)?;
}
anchor_lang::solana_program::program::invoke_signed(
&anchor_lang::solana_program::system_instruction::allocate(
state.to_account_info().key,
space as u64,
),
&[state.to_account_info(), system_program.to_account_info()],
&[],
)?;
anchor_lang::solana_program::program::invoke_signed(
&anchor_lang::solana_program::system_instruction::assign(
state.to_account_info().key,
program_id,
),
&[state.to_account_info(), system_program.to_account_info()],
&[],
)?;
}
}
let pa: anchor_lang::Account<State> = anchor_lang::Account::try_from_unchecked(&state)?;
pa
};
if !state.to_account_info().is_writable {
return Err(anchor_lang::__private::ErrorCode::ConstraintMut.into());
}
if !state.to_account_info().is_signer {
return Err(anchor_lang::__private::ErrorCode::ConstraintSigner.into());
}
if !__anchor_rent.is_exempt(
state.to_account_info().lamports(),
state.to_account_info().try_data_len()?,
) {
return Err(anchor_lang::__private::ErrorCode::ConstraintRentExempt.into());
}
if !user.is_signer {
return Err(anchor_lang::__private::ErrorCode::ConstraintSigner.into());
}
if system_program.to_account_info().key != &system_program::ID {
return Err(anchor_lang::__private::ErrorCode::ConstraintAddress.into());
}
Ok(Initialize {
state,
user,
system_program,
})
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountInfos<'info> for Initialize<'info>
where
'info: 'info,
{
fn to_account_infos(
&self,
) -> Vec<anchor_lang::solana_program::account_info::AccountInfo<'info>> {
let mut account_infos = ::alloc::vec::Vec::new();
account_infos.extend(self.state.to_account_infos());
account_infos.extend(self.user.to_account_infos());
account_infos.extend(self.system_program.to_account_infos());
account_infos
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountMetas for Initialize<'info> {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.extend(self.state.to_account_metas(Some(true)));
account_metas.extend(self.user.to_account_metas(Some(true)));
account_metas.extend(self.system_program.to_account_metas(None));
account_metas
}
}
#[automatically_derived]
impl<'info> anchor_lang::AccountsExit<'info> for Initialize<'info>
where
'info: 'info,
{
fn exit(
&self,
program_id: &anchor_lang::solana_program::pubkey::Pubkey,
) -> anchor_lang::solana_program::entrypoint::ProgramResult {
anchor_lang::AccountsExit::exit(&self.state, program_id)?;
Ok(())
}
}
pub(crate) mod __client_accounts_initialize {
use super::*;
use anchor_lang::prelude::borsh;
pub struct Initialize {
pub state: anchor_lang::solana_program::pubkey::Pubkey,
pub user: anchor_lang::solana_program::pubkey::Pubkey,
pub system_program: anchor_lang::solana_program::pubkey::Pubkey,
}
impl borsh::ser::BorshSerialize for Initialize
where
anchor_lang::solana_program::pubkey::Pubkey: borsh::ser::BorshSerialize,
anchor_lang::solana_program::pubkey::Pubkey: borsh::ser::BorshSerialize,
anchor_lang::solana_program::pubkey::Pubkey: borsh::ser::BorshSerialize,
{
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
borsh::BorshSerialize::serialize(&self.state, writer)?;
borsh::BorshSerialize::serialize(&self.user, writer)?;
borsh::BorshSerialize::serialize(&self.system_program, writer)?;
Ok(())
}
}
#[automatically_derived]
impl anchor_lang::ToAccountMetas for Initialize {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.push(anchor_lang::solana_program::instruction::AccountMeta::new(
self.state, true,
));
account_metas.push(
anchor_lang::solana_program::instruction::AccountMeta::new_readonly(
self.user, true,
),
);
account_metas.push(
anchor_lang::solana_program::instruction::AccountMeta::new_readonly(
self.system_program,
false,
),
);
account_metas
}
}
}
pub(crate) mod __cpi_client_accounts_initialize {
use super::*;
pub struct Initialize<'info> {
pub state: anchor_lang::solana_program::account_info::AccountInfo<'info>,
pub user: anchor_lang::solana_program::account_info::AccountInfo<'info>,
pub system_program: anchor_lang::solana_program::account_info::AccountInfo<'info>,
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountMetas for Initialize<'info> {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.push(anchor_lang::solana_program::instruction::AccountMeta::new(
anchor_lang::Key::key(&self.state),
true,
));
account_metas.push(
anchor_lang::solana_program::instruction::AccountMeta::new_readonly(
anchor_lang::Key::key(&self.user),
true,
),
);
account_metas.push(
anchor_lang::solana_program::instruction::AccountMeta::new_readonly(
anchor_lang::Key::key(&self.system_program),
false,
),
);
account_metas
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountInfos<'info> for Initialize<'info> {
fn to_account_infos(
&self,
) -> Vec<anchor_lang::solana_program::account_info::AccountInfo<'info>> {
let mut account_infos = ::alloc::vec::Vec::new();
account_infos.push(anchor_lang::ToAccountInfo::to_account_info(&self.state));
account_infos.push(anchor_lang::ToAccountInfo::to_account_info(&self.user));
account_infos.push(anchor_lang::ToAccountInfo::to_account_info(
&self.system_program,
));
account_infos
}
}
}
pub struct UpdateState<'info> {
#[account(mut)]
pub state: Account<'info, State>,
}
#[automatically_derived]
impl<'info> anchor_lang::Accounts<'info> for UpdateState<'info>
where
'info: 'info,
{
#[inline(never)]
fn try_accounts(
program_id: &anchor_lang::solana_program::pubkey::Pubkey,
accounts: &mut &[anchor_lang::solana_program::account_info::AccountInfo<'info>],
ix_data: &[u8],
) -> std::result::Result<Self, anchor_lang::solana_program::program_error::ProgramError> {
let state: anchor_lang::Account<State> =
anchor_lang::Accounts::try_accounts(program_id, accounts, ix_data)?;
if !state.to_account_info().is_writable {
return Err(anchor_lang::__private::ErrorCode::ConstraintMut.into());
}
Ok(UpdateState { state })
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountInfos<'info> for UpdateState<'info>
where
'info: 'info,
{
fn to_account_infos(
&self,
) -> Vec<anchor_lang::solana_program::account_info::AccountInfo<'info>> {
let mut account_infos = ::alloc::vec::Vec::new();
account_infos.extend(self.state.to_account_infos());
account_infos
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountMetas for UpdateState<'info> {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.extend(self.state.to_account_metas(None));
account_metas
}
}
#[automatically_derived]
impl<'info> anchor_lang::AccountsExit<'info> for UpdateState<'info>
where
'info: 'info,
{
fn exit(
&self,
program_id: &anchor_lang::solana_program::pubkey::Pubkey,
) -> anchor_lang::solana_program::entrypoint::ProgramResult {
anchor_lang::AccountsExit::exit(&self.state, program_id)?;
Ok(())
}
}
pub(crate) mod __client_accounts_update_state {
use super::*;
use anchor_lang::prelude::borsh;
pub struct UpdateState {
pub state: anchor_lang::solana_program::pubkey::Pubkey,
}
impl borsh::ser::BorshSerialize for UpdateState
where
anchor_lang::solana_program::pubkey::Pubkey: borsh::ser::BorshSerialize,
{
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
borsh::BorshSerialize::serialize(&self.state, writer)?;
Ok(())
}
}
#[automatically_derived]
impl anchor_lang::ToAccountMetas for UpdateState {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.push(anchor_lang::solana_program::instruction::AccountMeta::new(
self.state, false,
));
account_metas
}
}
}
pub(crate) mod __cpi_client_accounts_update_state {
use super::*;
pub struct UpdateState<'info> {
pub state: anchor_lang::solana_program::account_info::AccountInfo<'info>,
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountMetas for UpdateState<'info> {
fn to_account_metas(
&self,
is_signer: Option<bool>,
) -> Vec<anchor_lang::solana_program::instruction::AccountMeta> {
let mut account_metas = ::alloc::vec::Vec::new();
account_metas.push(anchor_lang::solana_program::instruction::AccountMeta::new(
anchor_lang::Key::key(&self.state),
false,
));
account_metas
}
}
#[automatically_derived]
impl<'info> anchor_lang::ToAccountInfos<'info> for UpdateState<'info> {
fn to_account_infos(
&self,
) -> Vec<anchor_lang::solana_program::account_info::AccountInfo<'info>> {
let mut account_infos = ::alloc::vec::Vec::new();
account_infos.push(anchor_lang::ToAccountInfo::to_account_info(&self.state));
account_infos
}
}
}
pub struct State {
pub locked: bool,
pub res: bool,
}
impl borsh::ser::BorshSerialize for State
where
bool: borsh::ser::BorshSerialize,
bool: borsh::ser::BorshSerialize,
{
fn serialize<W: borsh::maybestd::io::Write>(
&self,
writer: &mut W,
) -> ::core::result::Result<(), borsh::maybestd::io::Error> {
borsh::BorshSerialize::serialize(&self.locked, writer)?;
borsh::BorshSerialize::serialize(&self.res, writer)?;
Ok(())
}
}
impl borsh::de::BorshDeserialize for State
where
bool: borsh::BorshDeserialize,
bool: borsh::BorshDeserialize,
{
fn deserialize(buf: &mut &[u8]) -> ::core::result::Result<Self, borsh::maybestd::io::Error> {
Ok(Self {
locked: borsh::BorshDeserialize::deserialize(buf)?,
res: borsh::BorshDeserialize::deserialize(buf)?,
})
}
}
#[automatically_derived]
#[allow(unused_qualifications)]
impl ::core::clone::Clone for State {
#[inline]
fn clone(&self) -> State {
match *self {
State {
locked: ref __self_0_0,
res: ref __self_0_1,
} => State {
locked: ::core::clone::Clone::clone(&(*__self_0_0)),
res: ::core::clone::Clone::clone(&(*__self_0_1)),
},
}
}
}
#[automatically_derived]
impl anchor_lang::AccountSerialize for State {
fn try_serialize<W: std::io::Write>(
&self,
writer: &mut W,
) -> std::result::Result<(), ProgramError> {
writer
.write_all(&[216, 146, 107, 94, 104, 75, 182, 177])
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotSerialize)?;
AnchorSerialize::serialize(self, writer)
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotSerialize)?;
Ok(())
}
}
#[automatically_derived]
impl anchor_lang::AccountDeserialize for State {
fn try_deserialize(buf: &mut &[u8]) -> std::result::Result<Self, ProgramError> {
if buf.len() < [216, 146, 107, 94, 104, 75, 182, 177].len() {
return Err(anchor_lang::__private::ErrorCode::AccountDiscriminatorNotFound.into());
}
let given_disc = &buf[..8];
if &[216, 146, 107, 94, 104, 75, 182, 177] != given_disc {
return Err(anchor_lang::__private::ErrorCode::AccountDiscriminatorMismatch.into());
}
Self::try_deserialize_unchecked(buf)
}
fn try_deserialize_unchecked(buf: &mut &[u8]) -> std::result::Result<Self, ProgramError> {
let mut data: &[u8] = &buf[8..];
AnchorDeserialize::deserialize(&mut data)
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotDeserialize.into())
}
}
#[automatically_derived]
impl anchor_lang::Discriminator for State {
fn discriminator() -> [u8; 8] {
[216, 146, 107, 94, 104, 75, 182, 177]
}
}
#[automatically_derived]
impl anchor_lang::Owner for State {
fn owner() -> Pubkey {
crate::ID
}
}