Skip to content

Commit b78db00

Browse files
committed
fix(nft-meta-data-pointer): merge into one #[error_code] enum (anchor IDL build allows only one)
1 parent 91880a1 commit b78db00

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

  • tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/src

tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/src/errors.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
use anchor_lang::error_code;
22

3+
// Anchor's IDL build allows only a single `#[error_code]` enum per program, so
4+
// the game and program-level errors live in one enum.
35
#[error_code]
46
pub enum GameErrorCode {
57
#[msg("Not enough energy")]
68
NotEnoughEnergy,
79
#[msg("Wrong Authority")]
810
WrongAuthority,
9-
}
10-
11-
#[error_code]
12-
pub enum ProgramErrorCode {
1311
#[msg("Invalid Mint account space")]
1412
InvalidMintAccountSpace,
1513
#[msg("Cant initialize metadata_pointer")]

tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/src/instructions/mint_nft.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
pub use crate::constants::TOKEN_METADATA_EXTENSION_SPACE;
22
pub use crate::errors::GameErrorCode;
3-
pub use crate::errors::ProgramErrorCode;
43
pub use crate::state::game_data::GameData;
54
use anchor_lang::solana_program::program::{invoke, invoke_signed};
65
use anchor_lang::{prelude::*, system_program};
@@ -21,7 +20,7 @@ pub fn handle_mint_nft(context: Context<MintNft>) -> Result<()> {
2120
match ExtensionType::try_calculate_account_len::<Mint>(&[ExtensionType::MetadataPointer]) {
2221
Ok(space) => space,
2322
Err(_) => {
24-
return err!(ProgramErrorCode::InvalidMintAccountSpace);
23+
return err!(GameErrorCode::InvalidMintAccountSpace);
2524
}
2625
};
2726

@@ -72,7 +71,7 @@ pub fn handle_mint_nft(context: Context<MintNft>) -> Result<()> {
7271
) {
7372
Ok(ix) => ix,
7473
Err(_) => {
75-
return err!(ProgramErrorCode::CantInitializeMetadataPointer);
74+
return err!(GameErrorCode::CantInitializeMetadataPointer);
7675
}
7776
};
7877

0 commit comments

Comments
 (0)