Add check for mutability of init payer (#1271)
This commit is contained in:
parent
1164ebdcfc
commit
83121c26eb
|
@ -11,6 +11,10 @@ incremented for features.
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Breaking
|
||||||
|
|
||||||
|
* lang: Enforce that the payer for an init-ed account be marked `mut` ([#1271](https://github.com/project-serum/anchor/pull/1271)).
|
||||||
|
|
||||||
## [0.21.0] - 2022-02-07
|
## [0.21.0] - 2022-02-07
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
|
@ -303,7 +303,7 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "avm"
|
name = "avm"
|
||||||
version = "0.20.1"
|
version = "0.21.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
|
|
@ -39,55 +39,85 @@ pub fn parse(strct: &syn::ItemStruct) -> ParseResult<AccountsStruct> {
|
||||||
|
|
||||||
fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> {
|
fn constraints_cross_checks(fields: &[AccountField]) -> ParseResult<()> {
|
||||||
// INIT
|
// INIT
|
||||||
let init_field = fields.iter().find(|f| {
|
let init_fields: Vec<&Field> = fields
|
||||||
if let AccountField::Field(field) = f {
|
.iter()
|
||||||
field.constraints.init.is_some()
|
.filter_map(|f| match f {
|
||||||
} else {
|
AccountField::Field(field) if field.constraints.init.is_some() => Some(field),
|
||||||
false
|
_ => None,
|
||||||
}
|
})
|
||||||
});
|
.collect();
|
||||||
if let Some(init_field) = init_field {
|
|
||||||
|
if !init_fields.is_empty() {
|
||||||
// init needs system program.
|
// init needs system program.
|
||||||
if fields.iter().all(|f| f.ident() != "system_program") {
|
if fields.iter().all(|f| f.ident() != "system_program") {
|
||||||
return Err(ParseError::new(
|
return Err(ParseError::new(
|
||||||
init_field.ident().span(),
|
init_fields[0].ident.span(),
|
||||||
"the init constraint requires \
|
"the init constraint requires \
|
||||||
the system_program field to exist in the account \
|
the system_program field to exist in the account \
|
||||||
validation struct. Use the program type to add \
|
validation struct. Use the program type to add \
|
||||||
the system_program field to your validation struct.",
|
the system_program field to your validation struct.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if let AccountField::Field(field) = init_field {
|
|
||||||
let kind = &field.constraints.init.as_ref().unwrap().kind;
|
let kind = &init_fields[0].constraints.init.as_ref().unwrap().kind;
|
||||||
// init token/a_token/mint needs token program.
|
// init token/a_token/mint needs token program.
|
||||||
match kind {
|
match kind {
|
||||||
InitKind::Program { .. } => (),
|
InitKind::Program { .. } => (),
|
||||||
InitKind::Token { .. }
|
InitKind::Token { .. } | InitKind::AssociatedToken { .. } | InitKind::Mint { .. } => {
|
||||||
| InitKind::AssociatedToken { .. }
|
if fields.iter().all(|f| f.ident() != "token_program") {
|
||||||
| InitKind::Mint { .. } => {
|
return Err(ParseError::new(
|
||||||
if fields.iter().all(|f| f.ident() != "token_program") {
|
init_fields[0].ident.span(),
|
||||||
return Err(ParseError::new(
|
"the init constraint requires \
|
||||||
init_field.ident().span(),
|
|
||||||
"the init constraint requires \
|
|
||||||
the token_program field to exist in the account \
|
the token_program field to exist in the account \
|
||||||
validation struct. Use the program type to add \
|
validation struct. Use the program type to add \
|
||||||
the token_program field to your validation struct.",
|
the token_program field to your validation struct.",
|
||||||
));
|
));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// a_token needs associated token program.
|
}
|
||||||
if let InitKind::AssociatedToken { .. } = kind {
|
// a_token needs associated token program.
|
||||||
if fields
|
if let InitKind::AssociatedToken { .. } = kind {
|
||||||
.iter()
|
if fields
|
||||||
.all(|f| f.ident() != "associated_token_program")
|
.iter()
|
||||||
{
|
.all(|f| f.ident() != "associated_token_program")
|
||||||
return Err(ParseError::new(
|
{
|
||||||
init_field.ident().span(),
|
return Err(ParseError::new(
|
||||||
"the init constraint requires \
|
init_fields[0].ident.span(),
|
||||||
|
"the init constraint requires \
|
||||||
the associated_token_program field to exist in the account \
|
the associated_token_program field to exist in the account \
|
||||||
validation struct. Use the program type to add \
|
validation struct. Use the program type to add \
|
||||||
the associated_token_program field to your validation struct.",
|
the associated_token_program field to your validation struct.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for field in init_fields {
|
||||||
|
// Get payer for init-ed account
|
||||||
|
let associated_payer_name = match field.constraints.init.clone().unwrap().payer.unwrap()
|
||||||
|
{
|
||||||
|
// composite payer, check not supported
|
||||||
|
Expr::Field(_) => continue,
|
||||||
|
field_name => field_name.to_token_stream().to_string(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check payer is mutable
|
||||||
|
let associated_payer_field = fields.iter().find_map(|f| match f {
|
||||||
|
AccountField::Field(field) if *f.ident() == associated_payer_name => Some(field),
|
||||||
|
_ => None,
|
||||||
|
});
|
||||||
|
match associated_payer_field {
|
||||||
|
Some(associated_payer_field) => {
|
||||||
|
if !associated_payer_field.constraints.is_mutable() {
|
||||||
|
return Err(ParseError::new(
|
||||||
|
field.ident.span(),
|
||||||
|
"the payer specified for an init constraint must be mutable.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
return Err(ParseError::new(
|
||||||
|
field.ident.span(),
|
||||||
|
"the payer specified does not exist.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 09c911a53fd710d7d56972089c64de19d54ecf37
|
Subproject commit 2bfe49bdac2333d0e413a1e452c0ab7b502266fa
|
|
@ -130,8 +130,7 @@ pub struct CashCheck<'info> {
|
||||||
check_signer: AccountInfo<'info>,
|
check_signer: AccountInfo<'info>,
|
||||||
#[account(mut, has_one = owner)]
|
#[account(mut, has_one = owner)]
|
||||||
to: Account<'info, TokenAccount>,
|
to: Account<'info, TokenAccount>,
|
||||||
#[account(signer)]
|
owner: Signer<'info>,
|
||||||
owner: AccountInfo<'info>,
|
|
||||||
token_program: AccountInfo<'info>,
|
token_program: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,8 +147,7 @@ pub struct CancelCheck<'info> {
|
||||||
check_signer: AccountInfo<'info>,
|
check_signer: AccountInfo<'info>,
|
||||||
#[account(mut, has_one = owner)]
|
#[account(mut, has_one = owner)]
|
||||||
from: Account<'info, TokenAccount>,
|
from: Account<'info, TokenAccount>,
|
||||||
#[account(signer)]
|
owner: Signer<'info>,
|
||||||
owner: AccountInfo<'info>,
|
|
||||||
token_program: AccountInfo<'info>,
|
token_program: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -362,6 +362,7 @@ pub struct CreateOfficer<'info> {
|
||||||
token::authority = officer,
|
token::authority = officer,
|
||||||
)]
|
)]
|
||||||
treasury: Box<Account<'info, TokenAccount>>,
|
treasury: Box<Account<'info, TokenAccount>>,
|
||||||
|
#[account(mut)]
|
||||||
authority: Signer<'info>,
|
authority: Signer<'info>,
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
not(feature = "test"),
|
not(feature = "test"),
|
||||||
|
@ -393,6 +394,7 @@ pub struct AuthorizeMarket<'info> {
|
||||||
bump,
|
bump,
|
||||||
)]
|
)]
|
||||||
market_auth: Account<'info, MarketAuth>,
|
market_auth: Account<'info, MarketAuth>,
|
||||||
|
#[account(mut)]
|
||||||
payer: Signer<'info>,
|
payer: Signer<'info>,
|
||||||
// Not read or written to so not validated.
|
// Not read or written to so not validated.
|
||||||
market: UncheckedAccount<'info>,
|
market: UncheckedAccount<'info>,
|
||||||
|
|
|
@ -49,8 +49,8 @@ pub struct CreateUser<'info> {
|
||||||
space = 320,
|
space = 320,
|
||||||
)]
|
)]
|
||||||
user: Account<'info, User>,
|
user: Account<'info, User>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
authority: AccountInfo<'info>,
|
authority: Signer<'info>,
|
||||||
system_program: AccountInfo<'info>,
|
system_program: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,7 @@ pub struct SendMessage<'info> {
|
||||||
has_one = authority,
|
has_one = authority,
|
||||||
)]
|
)]
|
||||||
user: Account<'info, User>,
|
user: Account<'info, User>,
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
chat_room: Loader<'info, ChatRoom>,
|
chat_room: Loader<'info, ChatRoom>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,8 +60,7 @@ pub struct HasOneError<'info> {
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct SignerError<'info> {
|
pub struct SignerError<'info> {
|
||||||
#[account(signer)]
|
my_account: Signer<'info>,
|
||||||
my_account: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[account]
|
#[account]
|
||||||
|
|
|
@ -108,7 +108,7 @@ describe("errors", () => {
|
||||||
assert.ok(false);
|
assert.ok(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errMsg =
|
const errMsg =
|
||||||
"Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x7d2";
|
"Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xbc2";
|
||||||
assert.equal(err.toString(), errMsg);
|
assert.equal(err.toString(), errMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -102,8 +102,8 @@ pub mod escrow {
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
#[instruction(initializer_amount: u64)]
|
#[instruction(initializer_amount: u64)]
|
||||||
pub struct InitializeEscrow<'info> {
|
pub struct InitializeEscrow<'info> {
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub initializer: AccountInfo<'info>,
|
pub initializer: Signer<'info>,
|
||||||
#[account(
|
#[account(
|
||||||
mut,
|
mut,
|
||||||
constraint = initializer_deposit_token_account.amount >= initializer_amount
|
constraint = initializer_deposit_token_account.amount >= initializer_amount
|
||||||
|
@ -181,7 +181,7 @@ impl<'info> From<&mut InitializeEscrow<'info>>
|
||||||
.initializer_deposit_token_account
|
.initializer_deposit_token_account
|
||||||
.to_account_info()
|
.to_account_info()
|
||||||
.clone(),
|
.clone(),
|
||||||
current_authority: accounts.initializer.clone(),
|
current_authority: accounts.initializer.to_account_info().clone(),
|
||||||
};
|
};
|
||||||
let cpi_program = accounts.token_program.to_account_info();
|
let cpi_program = accounts.token_program.to_account_info();
|
||||||
CpiContext::new(cpi_program, cpi_accounts)
|
CpiContext::new(cpi_program, cpi_accounts)
|
||||||
|
|
|
@ -250,8 +250,7 @@ pub struct Withdraw<'info> {
|
||||||
// Vesting.
|
// Vesting.
|
||||||
#[account(mut, has_one = beneficiary, has_one = vault)]
|
#[account(mut, has_one = beneficiary, has_one = vault)]
|
||||||
vesting: Account<'info, Vesting>,
|
vesting: Account<'info, Vesting>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
vault: Account<'info, TokenAccount>,
|
vault: Account<'info, TokenAccount>,
|
||||||
#[account(
|
#[account(
|
||||||
|
@ -281,8 +280,7 @@ pub struct WhitelistDeposit<'info> {
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct WhitelistTransfer<'info> {
|
pub struct WhitelistTransfer<'info> {
|
||||||
lockup: ProgramState<'info, Lockup>,
|
lockup: ProgramState<'info, Lockup>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
whitelisted_program: AccountInfo<'info>,
|
whitelisted_program: AccountInfo<'info>,
|
||||||
|
|
||||||
// Whitelist interface.
|
// Whitelist interface.
|
||||||
|
|
|
@ -596,8 +596,7 @@ impl<'info> Initialize<'info> {
|
||||||
pub struct UpdateRegistrar<'info> {
|
pub struct UpdateRegistrar<'info> {
|
||||||
#[account(mut, has_one = authority)]
|
#[account(mut, has_one = authority)]
|
||||||
registrar: Account<'info, Registrar>,
|
registrar: Account<'info, Registrar>,
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -607,8 +606,7 @@ pub struct CreateMember<'info> {
|
||||||
// Member.
|
// Member.
|
||||||
#[account(zero)]
|
#[account(zero)]
|
||||||
member: Box<Account<'info, Member>>,
|
member: Box<Account<'info, Member>>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(
|
#[account(
|
||||||
"&balances.spt.owner == member_signer.key",
|
"&balances.spt.owner == member_signer.key",
|
||||||
"balances.spt.mint == registrar.pool_mint",
|
"balances.spt.mint == registrar.pool_mint",
|
||||||
|
@ -672,8 +670,7 @@ pub struct Ctor<'info> {
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct SetLockupProgram<'info> {
|
pub struct SetLockupProgram<'info> {
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -691,8 +688,7 @@ pub struct IsRealized<'info> {
|
||||||
pub struct UpdateMember<'info> {
|
pub struct UpdateMember<'info> {
|
||||||
#[account(mut, has_one = beneficiary)]
|
#[account(mut, has_one = beneficiary)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -700,8 +696,7 @@ pub struct Deposit<'info> {
|
||||||
// Member.
|
// Member.
|
||||||
#[account(has_one = beneficiary)]
|
#[account(has_one = beneficiary)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
|
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
|
||||||
vault: Account<'info, TokenAccount>,
|
vault: Account<'info, TokenAccount>,
|
||||||
// Depositor.
|
// Depositor.
|
||||||
|
@ -726,8 +721,7 @@ pub struct DepositLocked<'info> {
|
||||||
vesting_vault: AccountInfo<'info>,
|
vesting_vault: AccountInfo<'info>,
|
||||||
// Note: no need to verify the depositor_authority since the SPL program
|
// Note: no need to verify the depositor_authority since the SPL program
|
||||||
// will fail the transaction if it's not correct.
|
// will fail the transaction if it's not correct.
|
||||||
#[account(signer)]
|
pub depositor_authority: Signer<'info>,
|
||||||
depositor_authority: AccountInfo<'info>,
|
|
||||||
#[account(constraint = token_program.key == &token::ID)]
|
#[account(constraint = token_program.key == &token::ID)]
|
||||||
token_program: AccountInfo<'info>,
|
token_program: AccountInfo<'info>,
|
||||||
#[account(
|
#[account(
|
||||||
|
@ -746,8 +740,7 @@ pub struct DepositLocked<'info> {
|
||||||
registrar: Box<Account<'info, Registrar>>,
|
registrar: Box<Account<'info, Registrar>>,
|
||||||
#[account(has_one = registrar, has_one = beneficiary)]
|
#[account(has_one = registrar, has_one = beneficiary)]
|
||||||
member: Box<Account<'info, Member>>,
|
member: Box<Account<'info, Member>>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -762,8 +755,7 @@ pub struct Stake<'info> {
|
||||||
// Member.
|
// Member.
|
||||||
#[account(mut, has_one = beneficiary, has_one = registrar)]
|
#[account(mut, has_one = beneficiary, has_one = registrar)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
||||||
balances: BalanceSandboxAccounts<'info>,
|
balances: BalanceSandboxAccounts<'info>,
|
||||||
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
||||||
|
@ -801,8 +793,7 @@ pub struct StartUnstake<'info> {
|
||||||
pending_withdrawal: Account<'info, PendingWithdrawal>,
|
pending_withdrawal: Account<'info, PendingWithdrawal>,
|
||||||
#[account(has_one = beneficiary, has_one = registrar)]
|
#[account(has_one = beneficiary, has_one = registrar)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
||||||
balances: BalanceSandboxAccounts<'info>,
|
balances: BalanceSandboxAccounts<'info>,
|
||||||
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
||||||
|
@ -827,8 +818,7 @@ pub struct EndUnstake<'info> {
|
||||||
|
|
||||||
#[account(has_one = registrar, has_one = beneficiary)]
|
#[account(has_one = registrar, has_one = beneficiary)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(mut, has_one = registrar, has_one = member, constraint = !pending_withdrawal.burned)]
|
#[account(mut, has_one = registrar, has_one = member, constraint = !pending_withdrawal.burned)]
|
||||||
pending_withdrawal: Account<'info, PendingWithdrawal>,
|
pending_withdrawal: Account<'info, PendingWithdrawal>,
|
||||||
|
|
||||||
|
@ -859,8 +849,7 @@ pub struct Withdraw<'info> {
|
||||||
// Member.
|
// Member.
|
||||||
#[account(has_one = registrar, has_one = beneficiary)]
|
#[account(has_one = registrar, has_one = beneficiary)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
|
#[account(mut, constraint = vault.to_account_info().key == &member.balances.vault)]
|
||||||
vault: Account<'info, TokenAccount>,
|
vault: Account<'info, TokenAccount>,
|
||||||
#[account(
|
#[account(
|
||||||
|
@ -886,8 +875,7 @@ pub struct WithdrawLocked<'info> {
|
||||||
vesting: Box<Account<'info, Vesting>>,
|
vesting: Box<Account<'info, Vesting>>,
|
||||||
#[account(mut, constraint = vesting_vault.key == &vesting.vault)]
|
#[account(mut, constraint = vesting_vault.key == &vesting.vault)]
|
||||||
vesting_vault: AccountInfo<'info>,
|
vesting_vault: AccountInfo<'info>,
|
||||||
#[account(signer)]
|
vesting_signer: Signer<'info>,
|
||||||
vesting_signer: AccountInfo<'info>,
|
|
||||||
#[account(constraint = token_program.key == &token::ID)]
|
#[account(constraint = token_program.key == &token::ID)]
|
||||||
token_program: AccountInfo<'info>,
|
token_program: AccountInfo<'info>,
|
||||||
#[account(
|
#[account(
|
||||||
|
@ -906,8 +894,7 @@ pub struct WithdrawLocked<'info> {
|
||||||
registrar: Box<Account<'info, Registrar>>,
|
registrar: Box<Account<'info, Registrar>>,
|
||||||
#[account(has_one = registrar, has_one = beneficiary)]
|
#[account(has_one = registrar, has_one = beneficiary)]
|
||||||
member: Box<Account<'info, Member>>,
|
member: Box<Account<'info, Member>>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -977,8 +964,7 @@ pub struct ClaimRewardCommon<'info> {
|
||||||
// Member.
|
// Member.
|
||||||
#[account(mut, has_one = registrar, has_one = beneficiary)]
|
#[account(mut, has_one = registrar, has_one = beneficiary)]
|
||||||
member: Account<'info, Member>,
|
member: Account<'info, Member>,
|
||||||
#[account(signer)]
|
beneficiary: Signer<'info>,
|
||||||
beneficiary: AccountInfo<'info>,
|
|
||||||
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
#[account(constraint = BalanceSandbox::from(&balances) == member.balances)]
|
||||||
balances: BalanceSandboxAccounts<'info>,
|
balances: BalanceSandboxAccounts<'info>,
|
||||||
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
#[account(constraint = BalanceSandbox::from(&balances_locked) == member.balances_locked)]
|
||||||
|
@ -1014,8 +1000,7 @@ pub struct ExpireReward<'info> {
|
||||||
)]
|
)]
|
||||||
vendor_signer: AccountInfo<'info>,
|
vendor_signer: AccountInfo<'info>,
|
||||||
// Receiver.
|
// Receiver.
|
||||||
#[account(signer)]
|
expiry_receiver: Signer<'info>,
|
||||||
expiry_receiver: AccountInfo<'info>,
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
expiry_receiver_token: AccountInfo<'info>,
|
expiry_receiver_token: AccountInfo<'info>,
|
||||||
// Misc.
|
// Misc.
|
||||||
|
@ -1263,7 +1248,7 @@ impl<'a, 'b, 'c, 'info> From<&mut DepositLocked<'info>>
|
||||||
let cpi_accounts = Transfer {
|
let cpi_accounts = Transfer {
|
||||||
from: accounts.vesting_vault.clone(),
|
from: accounts.vesting_vault.clone(),
|
||||||
to: accounts.member_vault.to_account_info(),
|
to: accounts.member_vault.to_account_info(),
|
||||||
authority: accounts.depositor_authority.clone(),
|
authority: accounts.depositor_authority.to_account_info().clone(),
|
||||||
};
|
};
|
||||||
let cpi_program = accounts.token_program.clone();
|
let cpi_program = accounts.token_program.clone();
|
||||||
CpiContext::new(cpi_program, cpi_accounts)
|
CpiContext::new(cpi_program, cpi_accounts)
|
||||||
|
|
|
@ -27,10 +27,11 @@ pub struct TestTokenSeedsInit<'info> {
|
||||||
token::authority = authority,
|
token::authority = authority,
|
||||||
)]
|
)]
|
||||||
pub my_pda: Account<'info, TokenAccount>,
|
pub my_pda: Account<'info, TokenAccount>,
|
||||||
|
#[account(mut)]
|
||||||
pub authority: AccountInfo<'info>,
|
pub authority: AccountInfo<'info>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub token_program: AccountInfo<'info>,
|
pub token_program: Program<'info, Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -43,6 +44,7 @@ pub struct TestInitAssociatedToken<'info> {
|
||||||
)]
|
)]
|
||||||
pub token: Account<'info, TokenAccount>,
|
pub token: Account<'info, TokenAccount>,
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
|
@ -82,9 +84,10 @@ pub struct TestPdaInit<'info> {
|
||||||
payer = my_payer,
|
payer = my_payer,
|
||||||
)]
|
)]
|
||||||
pub my_pda: Account<'info, DataU16>,
|
pub my_pda: Account<'info, DataU16>,
|
||||||
pub my_payer: AccountInfo<'info>,
|
#[account(mut)]
|
||||||
|
pub my_payer: Signer<'info>,
|
||||||
pub foo: AccountInfo<'info>,
|
pub foo: AccountInfo<'info>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -96,8 +99,9 @@ pub struct TestPdaInitZeroCopy<'info> {
|
||||||
payer = my_payer,
|
payer = my_payer,
|
||||||
)]
|
)]
|
||||||
pub my_pda: Loader<'info, DataZeroCopy>,
|
pub my_pda: Loader<'info, DataZeroCopy>,
|
||||||
pub my_payer: AccountInfo<'info>,
|
#[account(mut)]
|
||||||
pub system_program: AccountInfo<'info>,
|
pub my_payer: Signer<'info>,
|
||||||
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -189,29 +193,29 @@ pub struct TestI8<'info> {
|
||||||
pub struct TestInit<'info> {
|
pub struct TestInit<'info> {
|
||||||
#[account(init, payer = payer)]
|
#[account(init, payer = payer)]
|
||||||
pub data: Account<'info, DataI8>,
|
pub data: Account<'info, DataI8>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct TestInitZeroCopy<'info> {
|
pub struct TestInitZeroCopy<'info> {
|
||||||
#[account(init, payer = payer, space = 8 + size_of::<DataZeroCopy>())]
|
#[account(init, payer = payer, space = 8 + size_of::<DataZeroCopy>())]
|
||||||
pub data: Loader<'info, DataZeroCopy>,
|
pub data: Loader<'info, DataZeroCopy>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct TestInitMint<'info> {
|
pub struct TestInitMint<'info> {
|
||||||
#[account(init, mint::decimals = 6, mint::authority = payer, mint::freeze_authority = payer, payer = payer)]
|
#[account(init, mint::decimals = 6, mint::authority = payer, mint::freeze_authority = payer, payer = payer)]
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
pub token_program: AccountInfo<'info>,
|
pub token_program: Program<'info, Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -219,11 +223,11 @@ pub struct TestInitToken<'info> {
|
||||||
#[account(init, token::mint = mint, token::authority = payer, payer = payer)]
|
#[account(init, token::mint = mint, token::authority = payer, payer = payer)]
|
||||||
pub token: Account<'info, TokenAccount>,
|
pub token: Account<'info, TokenAccount>,
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
pub token_program: AccountInfo<'info>,
|
pub token_program: Program<'info, Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -238,6 +242,7 @@ pub struct TestCompositePayer<'info> {
|
||||||
pub struct TestFetchAll<'info> {
|
pub struct TestFetchAll<'info> {
|
||||||
#[account(init, payer = authority)]
|
#[account(init, payer = authority)]
|
||||||
pub data: Account<'info, DataWithFilter>,
|
pub data: Account<'info, DataWithFilter>,
|
||||||
|
#[account(mut)]
|
||||||
pub authority: Signer<'info>,
|
pub authority: Signer<'info>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
@ -246,6 +251,7 @@ pub struct TestFetchAll<'info> {
|
||||||
pub struct TestInitWithEmptySeeds<'info> {
|
pub struct TestInitWithEmptySeeds<'info> {
|
||||||
#[account(init, seeds = [], bump, payer = authority, space = 8 + size_of::<Data>())]
|
#[account(init, seeds = [], bump, payer = authority, space = 8 + size_of::<Data>())]
|
||||||
pub pda: Account<'info, Data>,
|
pub pda: Account<'info, Data>,
|
||||||
|
#[account(mut)]
|
||||||
pub authority: Signer<'info>,
|
pub authority: Signer<'info>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
@ -260,6 +266,7 @@ pub struct TestEmptySeedsConstraint<'info> {
|
||||||
pub struct InitWithSpace<'info> {
|
pub struct InitWithSpace<'info> {
|
||||||
#[account(init, payer = payer)]
|
#[account(init, payer = payer)]
|
||||||
pub data: Account<'info, DataU16>,
|
pub data: Account<'info, DataU16>,
|
||||||
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
@ -268,6 +275,7 @@ pub struct InitWithSpace<'info> {
|
||||||
pub struct TestInitIfNeeded<'info> {
|
pub struct TestInitIfNeeded<'info> {
|
||||||
#[account(init_if_needed, payer = payer, space = 500)]
|
#[account(init_if_needed, payer = payer, space = 500)]
|
||||||
pub data: Account<'info, DataU16>,
|
pub data: Account<'info, DataU16>,
|
||||||
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
@ -276,6 +284,7 @@ pub struct TestInitIfNeeded<'info> {
|
||||||
pub struct TestInitIfNeededChecksOwner<'info> {
|
pub struct TestInitIfNeededChecksOwner<'info> {
|
||||||
#[account(init_if_needed, payer = payer, space = 100, owner = *owner.key, seeds = [b"hello"], bump)]
|
#[account(init_if_needed, payer = payer, space = 100, owner = *owner.key, seeds = [b"hello"], bump)]
|
||||||
pub data: UncheckedAccount<'info>,
|
pub data: UncheckedAccount<'info>,
|
||||||
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
pub owner: AccountInfo<'info>,
|
pub owner: AccountInfo<'info>,
|
||||||
|
@ -296,11 +305,11 @@ pub struct TestInitIfNeededChecksSeeds<'info> {
|
||||||
pub struct TestInitMintIfNeeded<'info> {
|
pub struct TestInitMintIfNeeded<'info> {
|
||||||
#[account(init_if_needed, mint::decimals = decimals, mint::authority = mint_authority, mint::freeze_authority = freeze_authority, payer = payer)]
|
#[account(init_if_needed, mint::decimals = decimals, mint::authority = mint_authority, mint::freeze_authority = freeze_authority, payer = payer)]
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
pub token_program: AccountInfo<'info>,
|
pub token_program: Program<'info, Token>,
|
||||||
pub mint_authority: AccountInfo<'info>,
|
pub mint_authority: AccountInfo<'info>,
|
||||||
pub freeze_authority: AccountInfo<'info>,
|
pub freeze_authority: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
@ -310,11 +319,11 @@ pub struct TestInitTokenIfNeeded<'info> {
|
||||||
#[account(init_if_needed, token::mint = mint, token::authority = authority, payer = payer)]
|
#[account(init_if_needed, token::mint = mint, token::authority = authority, payer = payer)]
|
||||||
pub token: Account<'info, TokenAccount>,
|
pub token: Account<'info, TokenAccount>,
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
pub payer: AccountInfo<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: AccountInfo<'info>,
|
pub system_program: Program<'info, System>,
|
||||||
pub token_program: AccountInfo<'info>,
|
pub token_program: Program<'info, Token>,
|
||||||
pub authority: AccountInfo<'info>,
|
pub authority: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,6 +337,7 @@ pub struct TestInitAssociatedTokenIfNeeded<'info> {
|
||||||
)]
|
)]
|
||||||
pub token: Account<'info, TokenAccount>,
|
pub token: Account<'info, TokenAccount>,
|
||||||
pub mint: Account<'info, Mint>,
|
pub mint: Account<'info, Mint>,
|
||||||
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
pub rent: Sysvar<'info, Rent>,
|
pub rent: Sysvar<'info, Rent>,
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
|
|
|
@ -177,8 +177,7 @@ pub struct CreateTransaction<'info> {
|
||||||
#[account(zero)]
|
#[account(zero)]
|
||||||
transaction: ProgramAccount<'info, Transaction>,
|
transaction: ProgramAccount<'info, Transaction>,
|
||||||
// One of the owners. Checked in the handler.
|
// One of the owners. Checked in the handler.
|
||||||
#[account(signer)]
|
proposer: Signer<'info>,
|
||||||
proposer: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -187,8 +186,7 @@ pub struct Approve<'info> {
|
||||||
#[account(mut, has_one = multisig)]
|
#[account(mut, has_one = multisig)]
|
||||||
transaction: ProgramAccount<'info, Transaction>,
|
transaction: ProgramAccount<'info, Transaction>,
|
||||||
// One of the multisig owners. Checked in the handler.
|
// One of the multisig owners. Checked in the handler.
|
||||||
#[account(signer)]
|
owner: Signer<'info>,
|
||||||
owner: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
|
|
@ -64,14 +64,12 @@ pub struct Status<'info> {
|
||||||
pub struct Initializedashboard<'info> {
|
pub struct Initializedashboard<'info> {
|
||||||
#[account(zero)]
|
#[account(zero)]
|
||||||
dashboard: Account<'info, Dashboard>,
|
dashboard: Account<'info, Dashboard>,
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct Initialize<'info> {
|
pub struct Initialize<'info> {
|
||||||
#[account(signer)]
|
player_x: Signer<'info>,
|
||||||
player_x: AccountInfo<'info>,
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
dashboard: Account<'info, Dashboard>,
|
dashboard: Account<'info, Dashboard>,
|
||||||
#[account(zero)]
|
#[account(zero)]
|
||||||
|
@ -80,16 +78,14 @@ pub struct Initialize<'info> {
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct Playerjoin<'info> {
|
pub struct Playerjoin<'info> {
|
||||||
#[account(signer)]
|
player_o: Signer<'info>,
|
||||||
player_o: AccountInfo<'info>,
|
|
||||||
#[account(mut, constraint = game.game_state != 0 && game.player_x != Pubkey::default())]
|
#[account(mut, constraint = game.game_state != 0 && game.player_x != Pubkey::default())]
|
||||||
game: Account<'info, Game>,
|
game: Account<'info, Game>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct Playermove<'info> {
|
pub struct Playermove<'info> {
|
||||||
#[account(signer)]
|
player: Signer<'info>,
|
||||||
player: AccountInfo<'info>,
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
game: Account<'info, Game>,
|
game: Account<'info, Game>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,24 +64,21 @@ pub mod zero_copy {
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct SetEvent<'info> {
|
pub struct SetEvent<'info> {
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct CreateFoo<'info> {
|
pub struct CreateFoo<'info> {
|
||||||
#[account(zero)]
|
#[account(zero)]
|
||||||
foo: AccountLoader<'info, Foo>,
|
foo: AccountLoader<'info, Foo>,
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct UpdateFoo<'info> {
|
pub struct UpdateFoo<'info> {
|
||||||
#[account(mut, has_one = authority)]
|
#[account(mut, has_one = authority)]
|
||||||
foo: AccountLoader<'info, Foo>,
|
foo: AccountLoader<'info, Foo>,
|
||||||
#[account(signer)]
|
authority: Signer<'info>,
|
||||||
authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -91,8 +88,7 @@ pub struct UpdateFooSecond<'info> {
|
||||||
constraint = &foo.load()?.get_second_authority() == second_authority.key,
|
constraint = &foo.load()?.get_second_authority() == second_authority.key,
|
||||||
)]
|
)]
|
||||||
foo: AccountLoader<'info, Foo>,
|
foo: AccountLoader<'info, Foo>,
|
||||||
#[account(signer)]
|
second_authority: Signer<'info>,
|
||||||
second_authority: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
|
@ -104,8 +100,8 @@ pub struct CreateBar<'info> {
|
||||||
payer = authority, owner = *program_id
|
payer = authority, owner = *program_id
|
||||||
)]
|
)]
|
||||||
bar: AccountLoader<'info, Bar>,
|
bar: AccountLoader<'info, Bar>,
|
||||||
#[account(signer)]
|
#[account(mut)]
|
||||||
authority: AccountInfo<'info>,
|
authority: Signer<'info>,
|
||||||
foo: AccountLoader<'info, Foo>,
|
foo: AccountLoader<'info, Foo>,
|
||||||
system_program: AccountInfo<'info>,
|
system_program: AccountInfo<'info>,
|
||||||
}
|
}
|
||||||
|
@ -118,8 +114,7 @@ pub struct UpdateBar<'info> {
|
||||||
bump,
|
bump,
|
||||||
)]
|
)]
|
||||||
pub bar: AccountLoader<'info, Bar>,
|
pub bar: AccountLoader<'info, Bar>,
|
||||||
#[account(signer)]
|
pub authority: Signer<'info>,
|
||||||
pub authority: AccountInfo<'info>,
|
|
||||||
pub foo: AccountLoader<'info, Foo>,
|
pub foo: AccountLoader<'info, Foo>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +128,7 @@ pub struct CreateLargeAccount<'info> {
|
||||||
pub struct UpdateLargeAccount<'info> {
|
pub struct UpdateLargeAccount<'info> {
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
event_q: AccountLoader<'info, EventQ>,
|
event_q: AccountLoader<'info, EventQ>,
|
||||||
#[account(signer)]
|
from: Signer<'info>,
|
||||||
from: AccountInfo<'info>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[account(zero_copy)]
|
#[account(zero_copy)]
|
||||||
|
|
Loading…
Reference in New Issue