Skip to content

Commit

Permalink
rename: consistent account infos in token program (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicfromnewyoke authored Nov 18, 2024
1 parent d854c65 commit 6c44ab7
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions programs/token/src/instructions/approve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{write_bytes, UNINIT_BYTE};
/// 2. `[SIGNER]` The source account owner.
pub struct Approve<'a> {
/// Source Account.
pub token: &'a AccountInfo,
pub source: &'a AccountInfo,
/// Delegate Account
pub delegate: &'a AccountInfo,
/// Source Owner Account
Expand All @@ -35,7 +35,7 @@ impl<'a> Approve<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// Account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.source.key()),
AccountMeta::readonly(self.delegate.key()),
AccountMeta::readonly_signer(self.authority.key()),
];
Expand All @@ -58,7 +58,7 @@ impl<'a> Approve<'a> {

invoke_signed(
&instruction,
&[self.token, self.delegate, self.authority],
&[self.source, self.delegate, self.authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/approve_checked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{write_bytes, UNINIT_BYTE};
/// 3. `[SIGNER]` The source account owner.
pub struct ApproveChecked<'a> {
/// Source Account.
pub token: &'a AccountInfo,
pub source: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Delegate Account.
Expand All @@ -40,7 +40,7 @@ impl<'a> ApproveChecked<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// Account metadata
let account_metas: [AccountMeta; 4] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.source.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly(self.delegate.key()),
AccountMeta::readonly_signer(self.authority.key()),
Expand All @@ -67,7 +67,7 @@ impl<'a> ApproveChecked<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.delegate, self.authority],
&[self.source, self.mint, self.delegate, self.authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{write_bytes, UNINIT_BYTE};
/// 2. `[SIGNER]` The account's owner/delegate.
pub struct Burn<'a> {
/// Source of the Burn Account
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account
pub mint: &'a AccountInfo,
/// Owner of the Token Account
Expand All @@ -35,7 +35,7 @@ impl<'a> Burn<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// Account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::writable(self.mint.key()),
AccountMeta::readonly_signer(self.authority.key()),
];
Expand All @@ -58,7 +58,7 @@ impl<'a> Burn<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.authority],
&[self.account, self.mint, self.authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/burn_checked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use pinocchio::{
/// 2. `[SIGNER]` The account's owner/delegate.
pub struct BurnChecked<'a> {
/// Source of the Burn Account
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account
pub mint: &'a AccountInfo,
/// Owner of the Token Account
Expand All @@ -36,7 +36,7 @@ impl<'a> BurnChecked<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// Account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::writable(self.mint.key()),
AccountMeta::readonly_signer(self.authority.key()),
];
Expand All @@ -62,7 +62,7 @@ impl<'a> BurnChecked<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.authority],
&[self.account, self.mint, self.authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/freeze_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use pinocchio::{
/// 2. `[SIGNER]` The mint freeze authority.
pub struct FreezeAccount<'a> {
/// Token Account to freeze.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Mint Freeze Authority Account
Expand All @@ -29,7 +29,7 @@ impl<'a> FreezeAccount<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly_signer(self.freeze_authority.key()),
];
Expand All @@ -42,7 +42,7 @@ impl<'a> FreezeAccount<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.freeze_authority],
&[self.account, self.mint, self.freeze_authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/initialize_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use pinocchio::{
/// 3. `[]` Rent sysvar
pub struct InitializeAccount<'a> {
/// New Account.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Owner of the new Account.
Expand All @@ -32,7 +32,7 @@ impl<'a> InitializeAccount<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 4] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly(self.owner.key()),
AccountMeta::readonly(self.rent_sysvar.key()),
Expand All @@ -46,7 +46,7 @@ impl<'a> InitializeAccount<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.owner, self.rent_sysvar],
&[self.account, self.mint, self.owner, self.rent_sysvar],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/initialize_account_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{write_bytes, UNINIT_BYTE};
/// 3. `[]` Rent sysvar
pub struct InitializeAccount2<'a> {
/// New Account.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Rent Sysvar Account
Expand All @@ -36,7 +36,7 @@ impl<'a> InitializeAccount2<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly(self.rent_sysvar.key()),
];
Expand All @@ -59,7 +59,7 @@ impl<'a> InitializeAccount2<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.rent_sysvar],
&[self.account, self.mint, self.rent_sysvar],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/initialize_account_3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{write_bytes, UNINIT_BYTE};
/// 1. `[]` The mint this account will be associated with.
pub struct InitializeAccount3<'a> {
/// New Account.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Owner of the new Account.
Expand All @@ -33,7 +33,7 @@ impl<'a> InitializeAccount3<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 2] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
];

Expand All @@ -53,6 +53,6 @@ impl<'a> InitializeAccount3<'a> {
data: unsafe { from_raw_parts(instruction_data.as_ptr() as _, 33) },
};

invoke_signed(&instruction, &[self.token, self.mint], signers)
invoke_signed(&instruction, &[self.account, self.mint], signers)
}
}
6 changes: 3 additions & 3 deletions programs/token/src/instructions/mint_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct MintTo<'a> {
/// Mint Account.
pub mint: &'a AccountInfo,
/// Token Account.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Authority
pub mint_authority: &'a AccountInfo,
/// Amount
Expand All @@ -37,7 +37,7 @@ impl<'a> MintTo<'a> {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.mint.key()),
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly_signer(self.mint_authority.key()),
];

Expand All @@ -59,7 +59,7 @@ impl<'a> MintTo<'a> {

invoke_signed(
&instruction,
&[self.mint, self.token, self.mint_authority],
&[self.mint, self.account, self.mint_authority],
signers,
)
}
Expand Down
6 changes: 3 additions & 3 deletions programs/token/src/instructions/mint_to_checked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct MintToChecked<'a> {
/// Mint Account.
pub mint: &'a AccountInfo,
/// Token Account.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Authority
pub mint_authority: &'a AccountInfo,
/// Amount
Expand All @@ -39,7 +39,7 @@ impl<'a> MintToChecked<'a> {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.mint.key()),
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly_signer(self.mint_authority.key()),
];

Expand All @@ -64,7 +64,7 @@ impl<'a> MintToChecked<'a> {

invoke_signed(
&instruction,
&[self.mint, self.token, self.mint_authority],
&[self.mint, self.account, self.mint_authority],
signers,
)
}
Expand Down
10 changes: 5 additions & 5 deletions programs/token/src/instructions/revoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use pinocchio::{
/// 0. `[WRITE]` The source account.
/// 1. `[SIGNER]` The source account owner.
pub struct Revoke<'a> {
/// New Account.
pub token: &'a AccountInfo,
/// Mint Account.
/// Source Account.
pub source: &'a AccountInfo,
/// Source Owner Account.
pub authority: &'a AccountInfo,
}

Expand All @@ -26,7 +26,7 @@ impl<'a> Revoke<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 2] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.source.key()),
AccountMeta::readonly_signer(self.authority.key()),
];

Expand All @@ -36,6 +36,6 @@ impl<'a> Revoke<'a> {
data: &[5],
};

invoke_signed(&instruction, &[self.token, self.authority], signers)
invoke_signed(&instruction, &[self.source, self.authority], signers)
}
}
6 changes: 3 additions & 3 deletions programs/token/src/instructions/thaw_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use pinocchio::{
/// 2. `[SIGNER]` The mint freeze authority.
pub struct ThawAccount<'a> {
/// Token Account to thaw.
pub token: &'a AccountInfo,
pub account: &'a AccountInfo,
/// Mint Account.
pub mint: &'a AccountInfo,
/// Mint Freeze Authority Account
Expand All @@ -29,7 +29,7 @@ impl<'a> ThawAccount<'a> {
pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
// account metadata
let account_metas: [AccountMeta; 3] = [
AccountMeta::writable(self.token.key()),
AccountMeta::writable(self.account.key()),
AccountMeta::readonly(self.mint.key()),
AccountMeta::readonly_signer(self.freeze_authority.key()),
];
Expand All @@ -42,7 +42,7 @@ impl<'a> ThawAccount<'a> {

invoke_signed(
&instruction,
&[self.token, self.mint, self.freeze_authority],
&[self.account, self.mint, self.freeze_authority],
signers,
)
}
Expand Down

0 comments on commit 6c44ab7

Please sign in to comment.