Skip to content

Commit

Permalink
Make extra Mint fields a separate account
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarkushin committed Oct 23, 2024
1 parent 5762f98 commit 60281e1
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 210 deletions.
8 changes: 4 additions & 4 deletions token/program/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ pub enum TokenError {
/// Instruction does not support non-native tokens
#[error("Instruction does not support non-native tokens")]
NonNativeNotSupported,
/// The token mint is not a rebasing token
#[error("The token mint is not a rebasing token")]
NotRebasingMint,
/// Invalid token mint extra
#[error("Invalid token mint extra")]
InvalidMintExtra,
/// The share price of the token can only increase
#[error("Share Price Can Only Increase")]
SharePriceCanOnlyIncrease,
Expand Down Expand Up @@ -140,7 +140,7 @@ impl PrintProgramError for TokenError {
TokenError::NonNativeNotSupported => {
msg!("Error: Instruction does not support non-native tokens")
}
TokenError::NotRebasingMint => {
TokenError::InvalidMintExtra => {
msg!("Error: The token mint is not a rebasing token")
}
TokenError::SharePriceCanOnlyIncrease => {
Expand Down
15 changes: 13 additions & 2 deletions token/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ pub fn initialize_mint2(
pub fn initialize_mint2_with_rebasing(
token_program_id: &Pubkey,
mint_pubkey: &Pubkey,
mint_extra_pubkey: &Pubkey,
mint_authority_pubkey: &Pubkey,
freeze_authority_pubkey: Option<&Pubkey>,
decimals: u8,
Expand All @@ -896,7 +897,10 @@ pub fn initialize_mint2_with_rebasing(
}
.pack();

let accounts = vec![AccountMeta::new(*mint_pubkey, false)];
let accounts = vec![
AccountMeta::new(*mint_pubkey, false),
AccountMeta::new(*mint_extra_pubkey, false),
];

Ok(Instruction {
program_id: *token_program_id,
Expand Down Expand Up @@ -1512,15 +1516,22 @@ pub fn ui_amount_to_amount(
pub fn update_l1_token_supply(
token_program_id: &Pubkey,
mint_pubkey: &Pubkey,
mint_extra_pubkey: &Pubkey,
signer_pubkeys: &[&Pubkey],
new_l1_token_supply: u64,
) -> Result<Instruction, ProgramError> {
check_program_account(token_program_id)?;

let mut accounts = vec![AccountMeta::new(*mint_pubkey, false)];
let mut accounts = vec![
AccountMeta::new(*mint_pubkey, false),
];
for signer_pubkey in signer_pubkeys.iter() {
accounts.push(AccountMeta::new_readonly(**signer_pubkey, true));
}
accounts.push(
AccountMeta::new(*mint_extra_pubkey, false),

);

Ok(Instruction {
program_id: *token_program_id,
Expand Down
Loading

0 comments on commit 60281e1

Please sign in to comment.