UNPKG

@silvana-one/nft

Version:
54 lines (53 loc) 2.48 kB
import { AccountUpdate, Bool, PublicKey, SmartContract, State, DeployArgs } from "o1js"; import { NFTCollectionContractConstructor } from "./collection.js"; import { NFTState } from "./types.js"; export { NFTUpdateBase, NFTUpdateContractConstructor, NFTStandardUpdate, NFTUpdateDeployProps, DefineUpdateFactory, }; type DefineUpdateFactory = (params: { collectionContract: () => NFTCollectionContractConstructor; }) => NFTUpdateContractConstructor; /** * The `NFTUpdateBase` interface defines the update functionalities required for managing an NFT update */ type NFTUpdateBase = SmartContract & { /** * Checks if an NFT can be updated from its current state (`input`) to a new state (`output`). * * @param collectionAddress - The public key of the NFT collection address. * @param nftAddress - The public key of the NFT. * @param input - The current state of the NFT. * @param output - The desired new state of the NFT. * @returns A `Promise` resolving to a `Bool` indicating whether the update is permitted. */ canUpdate(collectionAddress: PublicKey, nftAddress: PublicKey, input: NFTState, output: NFTState): Promise<Bool>; }; /** * Defines a constructor for contracts implementing `NFTUpdateBase`, accepting an `address` public key and returning an instance of `NFTUpdateBase`. * * @param address - The public key of the contract's owner. * @returns An instance of `NFTUpdateBase`. */ type NFTUpdateContractConstructor = new (address: PublicKey) => NFTUpdateBase; interface NFTUpdateDeployProps extends Exclude<DeployArgs, undefined> { admin: PublicKey; uri: string; } /** * The **NFTStandardUpdate** contract is the default implementation of the `NFTUpdateBase` interface. */ declare class NFTStandardUpdate extends SmartContract implements NFTUpdateBase { /** * The public key of the contract's administrator. */ admin: State<PublicKey>; /** * Deploys the contract with initial settings. * @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused. */ deploy(props: NFTUpdateDeployProps): Promise<void>; /** * Ensures that the transaction is authorized by the contract owner. * @returns A signed `AccountUpdate` from the admin. */ ensureOwnerSignature(): Promise<AccountUpdate>; canUpdate(collectionAddress: PublicKey, nftAddress: PublicKey, input: NFTState, output: NFTState): Promise<Bool>; }