Upgradable NFT contract
This commit is contained in:
parent
5265d1a234
commit
9423736d6b
|
@ -15,6 +15,8 @@ use read_write_state_derive::ReadWriteState;
|
||||||
|
|
||||||
use notamon_common::{NotamonAttributes, AssetId};
|
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.
|
/// 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)]
|
#[derive(ReadWriteState, CreateTypeSpec, PartialEq, Copy, Clone, Ord, PartialOrd, Eq)]
|
||||||
struct OperatorApproval {
|
struct OperatorApproval {
|
||||||
|
|
20
rust/notamon-nft/src/upgrade.rs
Normal file
20
rust/notamon-nft/src/upgrade.rs
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user