Skip to content

Commit ea707cb

Browse files
committed
refactor: added manual addition cmnts
1 parent 6550e95 commit ea707cb

File tree

1 file changed

+37
-3
lines changed
  • tokens/spl-token-minter/poseidon/spl-token-minter/programs/spl-token-minter/src

1 file changed

+37
-3
lines changed

tokens/spl-token-minter/poseidon/spl-token-minter/programs/spl-token-minter/src/lib.rs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anchor_lang::prelude::*;
22
use anchor_spl::{
3-
token::{mint_to, Mint, MintTo, Token, TokenAccount},
43
associated_token::AssociatedToken,
4+
token::{mint_to, Mint, MintTo, Token, TokenAccount},
55
};
66
declare_id!("DmrXSUGWYaqtWg8sbi9JQN48yVZ1y2m7HvWXbND52Mcw");
77
#[program]
@@ -12,9 +12,36 @@ pub mod spl_token_minter {
1212
decimals: u8,
1313
freeze_authority: Pubkey,
1414
) -> Result<()> {
15+
// Note: Initialization for mint handled manually
16+
// As Poseidon's transpiler does not support initializeMint yet.
17+
1518
Ok(())
1619
}
1720
pub fn mint(ctx: Context<MintContext>, amount: u64) -> Result<()> {
21+
// here in CpiContext::new, when transpiling from Poseidon new_with_signer was used instead of new
22+
// so remove this code
23+
// let cpi_ctx = CpiContext::new_with_signer(
24+
// ctx.accounts.token_program.to_account_info(),
25+
// MintTo {
26+
// mint: ctx.accounts.mint_account.to_account_info(),
27+
// to: ctx.accounts.associated_token_account.to_account_info(),
28+
// authority: ctx.accounts.mint_authority.to_account_info(),
29+
// },
30+
// signer,
31+
// );
32+
// mint_to(cpi_ctx, amount)?;
33+
// and change manually to :
34+
// let cpi_ctx = CpiContext::new(
35+
// ctx.accounts.token_program.to_account_info(),
36+
// MintTo {
37+
// mint: ctx.accounts.mint_account.to_account_info(),
38+
// to: ctx.accounts.associated_token_account.to_account_info(),
39+
// authority: ctx.accounts.mint_authority.to_account_info(),
40+
// },
41+
// );
42+
// mint_to(cpi_ctx, amount)?;
43+
44+
1845
let cpi_ctx = CpiContext::new(
1946
ctx.accounts.token_program.to_account_info(),
2047
MintTo {
@@ -32,27 +59,34 @@ pub mod spl_token_minter {
3259
pub struct CreateTokenMintContext<'info> {
3360
#[account(mut)]
3461
pub mint_authority: Signer<'info>,
62+
// Note: Poseidon's transpiler does not support initializeMint yet,
63+
// so this code is done manually using Anchor's InitializeMint.
64+
// init,
65+
// payer = mint_authority,
66+
// mint::decimals = decimals,
67+
// mint::authority = mint_authority.key(), this code is added manually
3568
#[account(
3669
init,
3770
payer = mint_authority,
3871
mint::decimals = decimals,
3972
mint::authority = mint_authority.key(),
4073
)]
4174
pub mint_account: Account<'info, Mint>,
75+
// Token Program and System Program is added manually as Poseidon does not support it yet using initializeMint
4276
pub token_program: Program<'info, Token>,
4377
pub system_program: Program<'info, System>,
4478
}
4579
#[derive(Accounts)]
4680
pub struct MintContext<'info> {
47-
#[account(mut)]
81+
#[account(mut)] // here (mut) is added manually as Poseidon didn't add it by its own causing error in build
4882
pub mint_account: Account<'info, Mint>,
4983
#[account(mut)]
5084
pub mint_authority: Signer<'info>,
5185
#[account(mut)]
5286
pub recipient: SystemAccount<'info>,
5387
#[account(
5488
init_if_needed,
55-
payer = mint_authority,
89+
payer = mint_authority, // Explicitly set payer to mint_authority due to Poseidon issue. Here poseidon added payer as mintAuthority but it should be mint_authority
5690
associated_token::mint = mint_account,
5791
associated_token::authority = recipient,
5892
)]

0 commit comments

Comments
 (0)