Skip to content

Commit cc1a3eb

Browse files
committed
chore : resolve comments and refactor
1 parent 568f976 commit cc1a3eb

23 files changed

+83
-77
lines changed

programs/token-2022/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pinocchio-token-2022"
3-
description = "Pinocchio helpers to invoke Token program 2022 instructions"
3+
description = "Pinocchio helpers to invoke Token-2022 program instructions"
44
version = "0.1.0"
55
edition = { workspace = true }
66
license = { workspace = true }

programs/token-2022/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
## Overview
1313

14-
This crate contains [`pinocchio`](https://crates.io/crates/pinocchio) helpers to perform cross-program invocations (CPIs) for SPL Token instructions.
14+
This crate contains [`pinocchio`](https://crates.io/crates/pinocchio) helpers to perform cross-program invocations (CPIs) for SPL Token-2022 instructions.
1515

1616
Each instruction defines a `struct` with the accounts and parameters required. Once all values are set, you can call directly `invoke` or `invoke_signed` to perform the CPI.
1717

18+
Instruction that are common to both SPL Token and SPL Token-2022 programs expect the program address, so they can be used to invoke either token program.
19+
1820
This is a `no_std` crate.
1921

2022
> **Note:** The API defined in this crate is subject to change.
@@ -26,14 +28,14 @@ Initializing a mint account:
2628
```rust
2729
// This example assumes that the instruction receives a writable `mint`
2830
// account; `authority` is a `Pubkey`.
29-
// Token Program : Legacy Token Program
31+
// The SPL Token program is being invoked.
3032
InitializeMint {
3133
mint,
3234
rent_sysvar,
3335
decimals: 9,
3436
mint_authority: authority,
3537
freeze_authority: Some(authority),
36-
program: Pubkey::from_str("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
38+
token_program: Pubkey::from_str("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
3739
}.invoke()?;
3840
```
3941

@@ -42,13 +44,13 @@ Performing a transfer of tokens:
4244
```rust
4345
// This example assumes that the instruction receives writable `from` and `to`
4446
// accounts, and a signer `authority` account.
45-
// Token Program : Token program 2022
47+
// The SPL Token-2022 is being invoked.
4648
Transfer {
4749
from,
4850
to,
4951
authority,
5052
amount: 10,
51-
program: Pubkey::from_str("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
53+
token_program: Pubkey::from_str("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
5254
}.invoke()?;
5355
```
5456

programs/token-2022/src/instructions/approve.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{write_bytes, UNINIT_BYTE};
1616
/// 0. `[WRITE]` The token account.
1717
/// 1. `[]` The delegate.
1818
/// 2. `[SIGNER]` The source account owner.
19-
pub struct Approve<'a> {
19+
pub struct Approve<'a, 'b> {
2020
/// Source Account.
2121
pub source: &'a AccountInfo,
2222
/// Delegate Account
@@ -26,10 +26,10 @@ pub struct Approve<'a> {
2626
/// Amount
2727
pub amount: u64,
2828
/// Token Program
29-
pub token_program: &'a Pubkey,
29+
pub token_program: &'b Pubkey,
3030
}
3131

32-
impl Approve<'_> {
32+
impl Approve<'_, '_> {
3333
#[inline(always)]
3434
pub fn invoke(&self) -> ProgramResult {
3535
self.invoke_signed(&[])

programs/token-2022/src/instructions/approve_checked.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{write_bytes, UNINIT_BYTE};
1717
/// 1. `[]` The token mint.
1818
/// 2. `[]` The delegate.
1919
/// 3. `[SIGNER]` The source account owner.
20-
pub struct ApproveChecked<'a> {
20+
pub struct ApproveChecked<'a, 'b> {
2121
/// Source Account.
2222
pub source: &'a AccountInfo,
2323
/// Mint Account.
@@ -31,10 +31,10 @@ pub struct ApproveChecked<'a> {
3131
/// Decimals.
3232
pub decimals: u8,
3333
/// Token Program
34-
pub token_program: &'a Pubkey,
34+
pub token_program: &'b Pubkey,
3535
}
3636

37-
impl ApproveChecked<'_> {
37+
impl ApproveChecked<'_, '_> {
3838
#[inline(always)]
3939
pub fn invoke(&self) -> ProgramResult {
4040
self.invoke_signed(&[])

programs/token-2022/src/instructions/burn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{write_bytes, UNINIT_BYTE};
1616
/// 0. `[WRITE]` The account to burn from.
1717
/// 1. `[WRITE]` The token mint.
1818
/// 2. `[SIGNER]` The account's owner/delegate.
19-
pub struct Burn<'a> {
19+
pub struct Burn<'a, 'b> {
2020
/// Source of the Burn Account
2121
pub account: &'a AccountInfo,
2222
/// Mint Account
@@ -26,10 +26,10 @@ pub struct Burn<'a> {
2626
/// Amount
2727
pub amount: u64,
2828
/// Token Program
29-
pub token_program: &'a Pubkey,
29+
pub token_program: &'b Pubkey,
3030
}
3131

32-
impl Burn<'_> {
32+
impl Burn<'_, '_> {
3333
#[inline(always)]
3434
pub fn invoke(&self) -> ProgramResult {
3535
self.invoke_signed(&[])

programs/token-2022/src/instructions/burn_checked.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use pinocchio::{
1515
/// 0. `[WRITE]` The account to burn from.
1616
/// 1. `[WRITE]` The token mint.
1717
/// 2. `[SIGNER]` The account's owner/delegate.
18-
pub struct BurnChecked<'a> {
18+
pub struct BurnChecked<'a, 'b> {
1919
/// Source of the Burn Account
2020
pub account: &'a AccountInfo,
2121
/// Mint Account
@@ -27,10 +27,10 @@ pub struct BurnChecked<'a> {
2727
/// Decimals
2828
pub decimals: u8,
2929
/// Token Program
30-
pub token_program: &'a Pubkey,
30+
pub token_program: &'b Pubkey,
3131
}
3232

33-
impl BurnChecked<'_> {
33+
impl BurnChecked<'_, '_> {
3434
#[inline(always)]
3535
pub fn invoke(&self) -> ProgramResult {
3636
self.invoke_signed(&[])

programs/token-2022/src/instructions/close_account.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ use pinocchio::{
1212
/// 0. `[WRITE]` The account to close.
1313
/// 1. `[WRITE]` The destination account.
1414
/// 2. `[SIGNER]` The account's owner.
15-
pub struct CloseAccount<'a> {
15+
pub struct CloseAccount<'a, 'b> {
1616
/// Token Account.
1717
pub account: &'a AccountInfo,
1818
/// Destination Account
1919
pub destination: &'a AccountInfo,
2020
/// Owner Account
2121
pub authority: &'a AccountInfo,
2222
/// Token Program
23-
pub token_program: &'a Pubkey,
23+
pub token_program: &'b Pubkey,
2424
}
2525

26-
impl CloseAccount<'_> {
26+
impl CloseAccount<'_, '_> {
2727
#[inline(always)]
2828
pub fn invoke(&self) -> ProgramResult {
2929
self.invoke_signed(&[])

programs/token-2022/src/instructions/freeze_account.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ use pinocchio::{
1212
/// 0. `[WRITE]` The account to freeze.
1313
/// 1. `[]` The token mint.
1414
/// 2. `[SIGNER]` The mint freeze authority.
15-
pub struct FreezeAccount<'a> {
15+
pub struct FreezeAccount<'a, 'b> {
1616
/// Token Account to freeze.
1717
pub account: &'a AccountInfo,
1818
/// Mint Account.
1919
pub mint: &'a AccountInfo,
2020
/// Mint Freeze Authority Account
2121
pub freeze_authority: &'a AccountInfo,
2222
/// Token Program
23-
pub token_program: &'a Pubkey,
23+
pub token_program: &'b Pubkey,
2424
}
2525

26-
impl FreezeAccount<'_> {
26+
impl FreezeAccount<'_, '_> {
2727
#[inline(always)]
2828
pub fn invoke(&self) -> ProgramResult {
2929
self.invoke_signed(&[])

programs/token-2022/src/instructions/initialize_account.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use pinocchio::{
1313
/// 1. `[]` The mint this account will be associated with.
1414
/// 2. `[]` The new account's owner/multisignature.
1515
/// 3. `[]` Rent sysvar
16-
pub struct InitializeAccount<'a> {
16+
pub struct InitializeAccount<'a, 'b> {
1717
/// New Account.
1818
pub account: &'a AccountInfo,
1919
/// Mint Account.
@@ -23,10 +23,10 @@ pub struct InitializeAccount<'a> {
2323
/// Rent Sysvar Account
2424
pub rent_sysvar: &'a AccountInfo,
2525
/// Token Program
26-
pub token_program: &'a Pubkey,
26+
pub token_program: &'b Pubkey,
2727
}
2828

29-
impl InitializeAccount<'_> {
29+
impl InitializeAccount<'_, '_> {
3030
#[inline(always)]
3131
pub fn invoke(&self) -> ProgramResult {
3232
self.invoke_signed(&[])

programs/token-2022/src/instructions/initialize_account_2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{write_bytes, UNINIT_BYTE};
1616
/// 0. `[WRITE]` The account to initialize.
1717
/// 1. `[]` The mint this account will be associated with.
1818
/// 3. `[]` Rent sysvar
19-
pub struct InitializeAccount2<'a> {
19+
pub struct InitializeAccount2<'a, 'b> {
2020
/// New Account.
2121
pub account: &'a AccountInfo,
2222
/// Mint Account.
@@ -26,10 +26,10 @@ pub struct InitializeAccount2<'a> {
2626
/// Owner of the new Account.
2727
pub owner: &'a Pubkey,
2828
/// Token Program
29-
pub token_program: &'a Pubkey,
29+
pub token_program: &'b Pubkey,
3030
}
3131

32-
impl InitializeAccount2<'_> {
32+
impl InitializeAccount2<'_, '_> {
3333
#[inline(always)]
3434
pub fn invoke(&self) -> ProgramResult {
3535
self.invoke_signed(&[])

0 commit comments

Comments
 (0)