-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jpcaulfi
committed
Jul 26, 2022
1 parent
598ab64
commit a283104
Showing
116 changed files
with
163 additions
and
31 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ustom-instruction-data/anchor/Anchor.toml → ...rocessing-instructions/anchor/Anchor.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ograms/custom-instruction-data/Cargo.toml → ...ograms/processing-instructions/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tom-instruction-data/anchor/tests/test.ts → ...cessing-instructions/anchor/tests/test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
tokens/mint-2/anchor/programs/mint-2/src/instructions/mint_to_another_wallet.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
use { | ||
anchor_lang::prelude::*, | ||
anchor_spl::{ | ||
token, | ||
associated_token, | ||
}, | ||
}; | ||
use crate::create_token_mint::MintAuthorityPda; | ||
|
||
|
||
pub fn mint_to_another_wallet( | ||
ctx: Context<MintToAnotherWallet>, | ||
amount: u64, | ||
mint_authority_pda_bump: u8, | ||
) -> Result<()> { | ||
|
||
msg!("Minting token to token account..."); | ||
msg!("Mint: {}", &ctx.accounts.mint_account.to_account_info().key()); | ||
msg!("Token Address: {}", &ctx.accounts.token_account.key()); | ||
token::mint_to( | ||
CpiContext::new_with_signer( | ||
ctx.accounts.token_program.to_account_info(), | ||
token::MintTo { | ||
mint: ctx.accounts.mint_account.to_account_info(), | ||
to: ctx.accounts.token_account.to_account_info(), | ||
authority: ctx.accounts.mint_authority.to_account_info(), | ||
}, | ||
&[&[ | ||
b"mint_authority_", | ||
ctx.accounts.mint_account.key().as_ref(), | ||
&[mint_authority_pda_bump], | ||
]] | ||
), | ||
amount, | ||
)?; | ||
|
||
msg!("Token minted to wallet successfully."); | ||
|
||
Ok(()) | ||
} | ||
|
||
|
||
#[derive(Accounts)] | ||
#[instruction(amount: u64, mint_authority_pda_bump: u8)] | ||
pub struct MintToAnotherWallet<'info> { | ||
#[account( | ||
mut, | ||
mint::decimals = 9, | ||
mint::authority = mint_authority.key(), | ||
)] | ||
pub mint_account: Account<'info, token::Mint>, | ||
#[account( | ||
mut, | ||
seeds = [ | ||
b"mint_authority_", | ||
mint_account.key().as_ref() | ||
], | ||
bump = mint_authority_pda_bump | ||
)] | ||
pub mint_authority: Account<'info, MintAuthorityPda>, | ||
/// CHECK: This is for airdrops | ||
pub recipient: UncheckedAccount<'info>, | ||
#[account( | ||
init, | ||
payer = payer, | ||
associated_token::mint = mint_account, | ||
associated_token::authority = recipient, | ||
)] | ||
pub token_account: Account<'info, token::TokenAccount>, | ||
#[account(mut)] | ||
pub payer: Signer<'info>, | ||
pub rent: Sysvar<'info, Rent>, | ||
pub system_program: Program<'info, System>, | ||
pub token_program: Program<'info, token::Token>, | ||
pub associated_token_program: Program<'info, associated_token::AssociatedToken>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
tokens/mint-2/anchor/programs/mint-2/src/instructions/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pub mod create_token_mint; | ||
pub mod mint_to_wallet; | ||
pub mod transfer_to_wallet; | ||
pub mod mint_to_your_wallet; | ||
pub mod mint_to_another_wallet; | ||
pub mod transfer_to_another_wallet; | ||
|
||
pub use create_token_mint::*; | ||
pub use mint_to_wallet::*; | ||
pub use transfer_to_wallet::*; | ||
pub use mint_to_your_wallet::*; | ||
pub use mint_to_another_wallet::*; | ||
pub use transfer_to_another_wallet::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters