1
0

Upgradable NFT contract

This commit is contained in:
Jon Michael Aanes 2025-04-09 22:32:50 +02:00
parent 5265d1a234
commit 9423736d6b
2 changed files with 22 additions and 0 deletions

View File

@ -15,6 +15,8 @@ use read_write_state_derive::ReadWriteState;
use notamon_common::{NotamonAttributes, AssetId};
mod upgrade;
/// A permission to transfer and approve NFTs given from an NFT owner to a separate address, called an operator.
#[derive(ReadWriteState, CreateTypeSpec, PartialEq, Copy, Clone, Ord, PartialOrd, Eq)]
struct OperatorApproval {

View File

@ -0,0 +1,20 @@
//! Upgrade logic for allowing upgrade.
use crate::NFTContractState;
use pbc_contract_codegen::upgrade_is_allowed;
use pbc_contract_common::context::ContractContext;
use pbc_contract_common::upgrade::ContractHashes;
/// Checks whether the upgrade is allowed.
///
/// This contract allows the [`ContractState::upgrader`] to upgrade the contract at any time.
#[upgrade_is_allowed]
pub fn is_upgrade_allowed(
context: ContractContext,
state: NFTContractState,
_old_contract_hashes: ContractHashes,
_new_contract_hashes: ContractHashes,
_new_contract_rpc: Vec<u8>,
) -> bool {
context.sender == state.contract_owner
}