Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/.ghaignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ tokens/token-2022/group/anchor
# error in tests
tokens/external-delegate-token-master/anchor

# build failed - program outdated
tokens/token-2022/metadata/anchor

# dependency issues
tokens/token-2022/nft-meta-data-pointer/anchor-example/anchor

Expand Down
3 changes: 2 additions & 1 deletion tokens/token-2022/metadata/anchor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"@types/node": "^22.19.1",
"chai": "^4.3.4",
"mocha": "^9.0.3",
"prettier": "^2.6.2",
"ts-mocha": "^10.0.0",
"typescript": "^5.3.3"
"typescript": "^5.5.0"
}
}
42 changes: 18 additions & 24 deletions tokens/token-2022/metadata/anchor/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ custom-panic = []
[dependencies]
anchor-lang = "1.0.2"
anchor-spl = "1.0.2"
spl-token-metadata-interface = "0.3.3"
spl-type-length-value = "0.4.3"
spl-token-metadata-interface = "0.8.0"
spl-type-length-value = "0.9.1"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("solana"))'] }
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use anchor_lang::prelude::*;
use anchor_lang::solana_program::rent::{
DEFAULT_EXEMPTION_THRESHOLD, DEFAULT_LAMPORTS_PER_BYTE_YEAR,
};
use anchor_lang::system_program::{transfer, Transfer};
use anchor_spl::token_interface::{
token_metadata_initialize, Mint, Token2022, TokenMetadataInitialize,
Expand Down Expand Up @@ -41,9 +38,11 @@ pub fn process_initialize(ctx: Context<Initialize>, args: TokenMetadataArgs) ->
// Add 4 extra bytes for size of MetadataExtension (2 bytes for type, 2 bytes for length)
let data_len = 4 + token_metadata.get_packed_len()?;

// Calculate lamports required for the additional metadata
let lamports =
data_len as u64 * DEFAULT_LAMPORTS_PER_BYTE_YEAR * DEFAULT_EXEMPTION_THRESHOLD as u64;
// Calculate lamports required for the additional metadata bytes only.
// The mint's base account overhead (128 bytes) is already funded by Anchor's `init`,
// so subtract minimum_balance(0) to avoid double-charging that overhead.
let rent = Rent::get()?;
let lamports = rent.minimum_balance(data_len).saturating_sub(rent.minimum_balance(0));

// Transfer additional lamports to mint account
transfer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn process_update_authority(ctx: Context<UpdateAuthority>) -> Result<()> {
CpiContext::new(
ctx.accounts.token_program.key(),
TokenMetadataUpdateAuthority {
token_program_id: ctx.accounts.token_program.to_account_info(),
program_id: ctx.accounts.token_program.to_account_info(),
metadata: ctx.accounts.mint_account.to_account_info(),
current_authority: ctx.accounts.current_authority.to_account_info(),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn process_update_field(ctx: Context<UpdateField>, args: UpdateFieldArgs) ->
CpiContext::new(
ctx.accounts.token_program.key(),
TokenMetadataUpdateField {
token_program_id: ctx.accounts.token_program.to_account_info(),
program_id: ctx.accounts.token_program.to_account_info(),
metadata: ctx.accounts.mint_account.to_account_info(),
update_authority: ctx.accounts.authority.to_account_info(),
},
Expand Down
9 changes: 5 additions & 4 deletions tokens/token-2022/metadata/anchor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"compilerOptions": {
"types": ["mocha", "chai"],
"types": ["mocha", "chai", "node"],
"typeRoots": ["./node_modules/@types"],
"lib": ["es2015"],
"lib": ["es2020"],
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
"target": "es2020",
"esModuleInterop": true,
"skipLibCheck": true
}
}
Loading