lez-programs/token/src/print_nft.rs
Ricardo Guilherme Schmidt 471abef719 refactor!: Update dependencies and implement new required features across multiple modules
- Updated `nssa_core` and `spel-framework` dependencies to their respective release candidates in `Cargo.toml` and `Cargo.lock` files for `amm`, `ata`, and `token` modules.
- Enhanced the `new_definition` function in `amm/src/new_definition.rs` to include new claim logic and updated PDA seed calculations.
- Modified tests in `integration_tests/tests/amm.rs`, `integration_tests/tests/ata.rs`, and `integration_tests/tests/token.rs` to accommodate changes in transaction handling and account initialization.
- Refactored account initialization logic in `ata/src/create.rs` and `token/src/initialize.rs` to include authorization claims.
- Updated various functions in `token/src/mint.rs`, `token/src/new_definition.rs`, and `token/src/transfer.rs` to utilize the new claim system for account states.
- Adjusted the IDL generation tool to use the latest version of `spel-framework-core`.
2026-04-20 12:25:59 +02:00

59 lines
1.6 KiB
Rust

use nssa_core::{
account::{Account, AccountWithMetadata, Data},
program::{AccountPostState, Claim},
};
use token_core::TokenHolding;
pub fn print_nft(
master_account: AccountWithMetadata,
printed_account: AccountWithMetadata,
) -> Vec<AccountPostState> {
assert!(
master_account.is_authorized,
"Master NFT Account must be authorized"
);
assert_eq!(
printed_account.account,
Account::default(),
"Printed Account must be uninitialized"
);
assert!(
printed_account.is_authorized,
"Printed Account must be authorized"
);
let mut master_account_data =
TokenHolding::try_from(&master_account.account.data).expect("Invalid Token Holding data");
let TokenHolding::NftMaster {
definition_id,
print_balance,
} = &mut master_account_data
else {
panic!("Invalid Token Holding provided as NFT Master Account");
};
let definition_id = *definition_id;
assert!(
*print_balance > 1,
"Insufficient balance to print another NFT copy"
);
*print_balance -= 1;
let mut master_account_post = master_account.account;
master_account_post.data = Data::from(&master_account_data);
let mut printed_account_post = printed_account.account;
printed_account_post.data = Data::from(&TokenHolding::NftPrintedCopy {
definition_id,
owned: true,
});
vec![
AccountPostState::new(master_account_post),
AccountPostState::new_claimed(printed_account_post, Claim::Authorized),
]
}