UNPKG

@silvana-one/nft

Version:
58 lines (57 loc) 2.64 kB
import { AccountUpdate, Bool, PublicKey, SmartContract, State, DeployArgs } from "o1js"; import { NFTCollectionContractConstructor } from "./collection.js"; import { TransferExtendedParams } from "./types.js"; export { NFTApprovalBase, NFTApprovalContractConstructor, NFTStandardApproval, NFTApprovalDeployProps, DefineApprovalFactory, }; type DefineApprovalFactory = (params: { collectionContract: () => NFTCollectionContractConstructor; }) => NFTApprovalContractConstructor; /** * The `NFTApprovalBase` interface defines the administrative functionalities required for managing an NFT transfer approval on the Mina Protocol. */ type NFTApprovalBase = SmartContract & { /** * Determines if an NFT can be transferred from one owner (`from`) to another (`to`) for a specific NFT contract address. * * @param params - The transfer details. * @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed. */ canTransfer(params: TransferExtendedParams): Promise<Bool>; }; /** * Defines a constructor for contracts implementing `NFTApprovalBase`, accepting an `address` public key and returning an instance of `NFTApprovalBase`. * * @param address - The public key of the contract's owner. * @returns An instance of `NFTApprovalBase`. */ type NFTApprovalContractConstructor = new (address: PublicKey) => NFTApprovalBase; interface NFTApprovalDeployProps extends Exclude<DeployArgs, undefined> { admin: PublicKey; uri: string; } /** * The **NFTStandardApproval** contract is the default implementation of the `NFTApprovalBase` interface. */ declare class NFTStandardApproval extends SmartContract implements NFTApprovalBase { /** * The public key of the contract's administrator. * This account has the authority to perform administrative actions such as pausing the contract or upgrading the verification key. */ admin: State<PublicKey>; /** * Deploys the contract with initial settings. * @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused. */ deploy(props: NFTApprovalDeployProps): Promise<void>; /** * Ensures that the transaction is authorized by the contract owner. * @returns A signed `AccountUpdate` from the admin. */ ensureOwnerSignature(): Promise<AccountUpdate>; /** * Determines if an NFT can be transferred. * * @param params - The transfer details. * @returns A `Promise` resolving to a `Bool` indicating whether the transfer is allowed. */ canTransfer(params: TransferExtendedParams): Promise<Bool>; }