File tree Expand file tree Collapse file tree
tokens/token-extensions/nft-meta-data-pointer/anchor-example/anchor/programs/extension_nft/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use 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]
46pub 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" ) ]
Original file line number Diff line number Diff line change 11pub use crate :: constants:: TOKEN_METADATA_EXTENSION_SPACE ;
22pub use crate :: errors:: GameErrorCode ;
3- pub use crate :: errors:: ProgramErrorCode ;
43pub use crate :: state:: game_data:: GameData ;
54use anchor_lang:: solana_program:: program:: { invoke, invoke_signed} ;
65use 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
You can’t perform that action at this time.
0 commit comments