Skip to content

Commit

Permalink
Support additional metadata fields
Browse files Browse the repository at this point in the history
  • Loading branch information
yurushao committed Apr 1, 2024
1 parent b4467b3 commit 0bd5e87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
20 changes: 16 additions & 4 deletions anchor/programs/glam/src/instructions/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,25 @@ pub fn initialize_fund_handler<'c: 'info, 'info>(
solana_program::program::invoke_signed(
&init_token_metadata_ix,
&[
share_metadata,
share_metadata_authority,
share_mint,
share_mint_authority,
share_metadata.clone(),
share_metadata_authority.clone(),
share_mint.clone(),
share_mint_authority.clone(),
],
signer_seeds,
)?;
// Add additional metadata fields
solana_program::program::invoke_signed(
&spl_token_metadata_interface::instruction::update_field(
&spl_token_2022::id(),
&share_metadata.key(),
&share_metadata_authority.key(),
spl_token_metadata_interface::state::Field::Key("fund_id".to_string()),
fund_key.to_string(),
),
&[share_mint.clone(), share_mint_authority.clone()],
signer_seeds,
)?;

msg!("Fund created: {}", ctx.accounts.fund.key());
Ok(())
Expand Down
5 changes: 4 additions & 1 deletion anchor/programs/glam/src/state/fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,8 @@ pub struct ShareClassMetadata {
}
impl ShareClassMetadata {
// use the same max sizes as Fund
pub const INIT_SIZE: usize = MAX_FUND_NAME + MAX_FUND_SYMBOL + MAX_FUND_URI;
// more space needed for two reasons:
// 1. we need to support additional metadata
// 2. for each KV pair in metadata, keys ("name" etc) also take up space
pub const INIT_SIZE: usize = MAX_FUND_NAME + MAX_FUND_SYMBOL + MAX_FUND_URI + 100;
}

0 comments on commit 0bd5e87

Please sign in to comment.