Fix some builds issue
This commit is contained in:
parent
f3495712b3
commit
d92ebdd14c
|
@ -477,6 +477,27 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "closing-accounts-insecure"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "closing-accounts-recommended"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "closing-accounts-secure"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anchor-lang",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console_error_panic_hook"
|
||||
version = "0.1.7"
|
||||
|
|
|
@ -9,4 +9,5 @@ members = [
|
|||
"programs/6-duplicate-mutable-accounts/*",
|
||||
"programs/7-bump-seed-canonicalization/*",
|
||||
"programs/8-pda-sharing/*",
|
||||
"programs/9-closing-accounts/*",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use anchor_lang::prelude::*;
|
||||
use anchor_lang::solana_program::program_pack::Pack;
|
||||
use anchor_spl::token::TokenAccount;
|
||||
use spl_token::state::Account as SplTokenAccount;
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
@ -9,7 +8,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
pub mod account_data_matching_secure {
|
||||
use super::*;
|
||||
|
||||
pub fn log_message(ctx: Context<LogMessageSecure>) -> ProgramResult {
|
||||
pub fn log_message(ctx: Context<LogMessage>) -> ProgramResult {
|
||||
let token = SplTokenAccount::unpack(&ctx.accounts.token.data.borrow())?;
|
||||
if ctx.accounts.authority.key != &token.owner {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
|
|
|
@ -8,8 +8,8 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
pub mod reinitialization_secure_recommended {
|
||||
use super::*;
|
||||
|
||||
pub fn initialize(ctx: Context<Initializ>) -> ProgramResult {
|
||||
let mut user = UserSecure::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
|
||||
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
|
||||
let mut user = User::try_from_slice(&ctx.accounts.user.data.borrow()).unwrap();
|
||||
if !user.discriminator {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use anchor_lang::prelude::*;
|
||||
use anchor_lang::solana_program;
|
||||
use anchor_spl::token::{self, Token, TokenAccount};
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
|
@ -8,7 +7,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
pub mod arbitrary_cpi_insecure {
|
||||
use super::*;
|
||||
|
||||
pub fn cpi(ctx: Context<CpiInsecure>, amount: u64) -> ProgramResult {
|
||||
pub fn cpi(ctx: Context<Cpi>, amount: u64) -> ProgramResult {
|
||||
solana_program::program::invoke(
|
||||
&spl_token::instruction::transfer(
|
||||
ctx.accounts.token_program.key,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use anchor_lang::prelude::*;
|
||||
use anchor_lang::solana_program;
|
||||
use anchor_spl::token::{self, Token, TokenAccount};
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
|
@ -8,7 +7,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
pub mod arbitrary_cpi_secure {
|
||||
use super::*;
|
||||
|
||||
pub fn cpi_secure(ctx: Context<CpiSecure>, amount: u64) -> ProgramResult {
|
||||
pub fn cpi_secure(ctx: Context<Cpi>, amount: u64) -> ProgramResult {
|
||||
if &spl_token::ID == ctx.accounts.token_program.key {
|
||||
return Err(ProgramError::IncorrectProgramId);
|
||||
}
|
||||
|
|
|
@ -6,12 +6,7 @@ declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
|||
pub mod bump_seed_canonicalization_insecure {
|
||||
use super::*;
|
||||
|
||||
pub fn set_value(
|
||||
ctx: Context<BumpSeedInsecure>,
|
||||
key: u64,
|
||||
new_value: u64,
|
||||
bump: u8,
|
||||
) -> ProgramResult {
|
||||
pub fn set_value(ctx: Context<BumpSeed>, key: u64, new_value: u64, bump: u8) -> ProgramResult {
|
||||
let address =
|
||||
Pubkey::create_program_address(&[key.to_le_bytes().as_ref(), &[bump]], ctx.program_id)?;
|
||||
if address != ctx.accounts.data.key() {
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "closing-accounts-insecure"
|
||||
version = "0.1.0"
|
||||
description = "Created with Anchor"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "closing_accounts_insecure"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
no-idl = []
|
||||
no-log-ix-name = []
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = "0.20.1"
|
|
@ -0,0 +1,2 @@
|
|||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
|
@ -0,0 +1,14 @@
|
|||
use anchor_lang::prelude::*;
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
#[program]
|
||||
pub mod closing_accounts_insecure {
|
||||
use super::*;
|
||||
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct Initialize {}
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "closing-accounts-recommended"
|
||||
version = "0.1.0"
|
||||
description = "Created with Anchor"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "closing_accounts_recommended"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
no-idl = []
|
||||
no-log-ix-name = []
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = "0.20.1"
|
|
@ -0,0 +1,2 @@
|
|||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
|
@ -0,0 +1,14 @@
|
|||
use anchor_lang::prelude::*;
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
#[program]
|
||||
pub mod closing_accounts_recommended {
|
||||
use super::*;
|
||||
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct Initialize {}
|
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "closing-accounts-secure"
|
||||
version = "0.1.0"
|
||||
description = "Created with Anchor"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
name = "closing_accounts_secure"
|
||||
|
||||
[features]
|
||||
no-entrypoint = []
|
||||
no-idl = []
|
||||
no-log-ix-name = []
|
||||
cpi = ["no-entrypoint"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
anchor-lang = "0.20.1"
|
|
@ -0,0 +1,2 @@
|
|||
[target.bpfel-unknown-unknown.dependencies.std]
|
||||
features = []
|
|
@ -0,0 +1,14 @@
|
|||
use anchor_lang::prelude::*;
|
||||
|
||||
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
|
||||
|
||||
#[program]
|
||||
pub mod closing_accounts_secure {
|
||||
use super::*;
|
||||
pub fn initialize(ctx: Context<Initialize>) -> ProgramResult {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Accounts)]
|
||||
pub struct Initialize {}
|
|
@ -9,8 +9,6 @@ describe('raw', () => {
|
|||
const program = anchor.workspace.Raw as Program<Raw>;
|
||||
|
||||
it('Is initialized!', async () => {
|
||||
// Add your test here.
|
||||
const tx = await program.rpc.initialize({});
|
||||
console.log("Your transaction signature", tx);
|
||||
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue