@silvana-one/nft
Version:
Mina NFT library
231 lines (230 loc) • 11.1 kB
TypeScript
import { Bool, DeployArgs, PublicKey, SmartContract, State, VerificationKey, UInt64, Field, AccountUpdate, UInt32, UInt8 } from "o1js";
import { MintRequest, NFTState, NFTAdminBase, MintParamsOption, PausableContract, PauseEvent, OwnershipChangeEvent, OwnableContract, TransferEvent } from "../interfaces/index.js";
export { NFTAdmin, NFTAdminDeployProps, NFTAdminAllowFlags };
interface NFTAdminDeployProps extends Exclude<DeployArgs, undefined> {
admin: PublicKey;
uri: string;
canBePaused?: Bool;
allowChangeRoyalty?: Bool;
allowChangeTransferFee?: Bool;
allowPauseCollection?: Bool;
isPaused?: Bool;
}
declare const NFTAdminAllowFlags_base: (new (value: {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}, {
allowChangeRoyalty: boolean;
allowChangeTransferFee: boolean;
allowPauseCollection: boolean;
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
};
} & {
fromValue: (value: {
allowChangeRoyalty: boolean | import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: boolean | import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: boolean | import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
};
toInput: (x: {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
}) => {
allowChangeRoyalty: boolean;
allowChangeTransferFee: boolean;
allowPauseCollection: boolean;
};
fromJSON: (x: {
allowChangeRoyalty: boolean;
allowChangeTransferFee: boolean;
allowPauseCollection: boolean;
}) => {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
};
empty: () => {
allowChangeRoyalty: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowChangeTransferFee: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
allowPauseCollection: import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool;
};
};
/**
* Contains flags for the admin contract related to the NFT collection permissions.
*/
declare class NFTAdminAllowFlags extends NFTAdminAllowFlags_base {
/**
* Packs the NFTAdminAllowFlags into a UInt8 representation for efficient storage.
* @returns The packed UInt8 instance.
*/
pack(): UInt8;
/**
* Unpacks a UInt8 instance into a NFTAdminAllowFlags instance.
* @param packed The packed UInt8 instance.
* @returns A new NFTAdminAllowFlags instance.
*/
static unpack(packed: UInt8): NFTAdminAllowFlags;
}
/**
* The **NFTAdmin** contract serves as the foundational administrative layer for NFT collections on the Mina Protocol.
* It provides essential functionalities such as contract upgrades, pausing and resuming operations, and ownership management.
* This contract can be extended by custom admin contracts to implement specific administrative logic,
* ensuring flexibility while maintaining a standardized interface.
*/
declare class NFTAdmin extends SmartContract implements NFTAdminBase, PausableContract, OwnableContract {
/**
* 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>;
/**
* The public key of the contract's pending administrator.
*/
pendingAdmin: State<PublicKey>;
/**
* A boolean flag indicating whether the contract is currently paused.
* When `true`, certain operations are disabled.
*/
isPaused: State<import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool>;
/**
* A boolean flag indicating whether the contract has the ability to be paused.
* This allows for disabling the pause functionality if desired.
*/
canBePaused: State<import("node_modules/o1js/dist/node/lib/provable/bool.js").Bool>;
/**
* A boolean flags indicating whether the collection is allowed to change the royalty fee, transfer fee and pause the collection.
*/
flags: State<UInt8>;
/**
* Deploys the contract with initial settings.
* @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused.
*/
deploy(props: NFTAdminDeployProps): Promise<void>;
/**
* Contract events emitted during various operations.
*/
events: {
/** Emitted when the verification key is upgraded. */
upgradeVerificationKey: typeof import("node_modules/o1js/dist/node/lib/provable/field.js").Field & ((x: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldConst | import("node_modules/o1js/dist/node/lib/provable/core/fieldvar.js").FieldVar | import("node_modules/o1js/dist/node/lib/provable/field.js").Field) => import("node_modules/o1js/dist/node/lib/provable/field.js").Field);
/** Emitted when the contract is paused. */
pause: typeof PauseEvent;
/** Emitted when the contract is resumed. */
resume: typeof PauseEvent;
/** Emitted when ownership of the contract changes. */
ownershipTransfer: typeof OwnershipChangeEvent;
/** Emitted when ownership of the contract is accepted. */
ownershipAccepted: typeof OwnershipChangeEvent;
};
/**
* Ensures that the transaction is authorized by the contract owner.
* @returns A signed `AccountUpdate` from the admin.
*/
ensureOwnerSignature(): Promise<AccountUpdate>;
/**
* Upgrades the contract's verification key after validating with the upgrade authority.
* @param vk - The new verification key to upgrade to.
*/
upgradeVerificationKey(vk: VerificationKey): Promise<void>;
/**
* Determines whether minting is allowed for the given request.
* Returns mint parameters if allowed, or none if not allowed.
* @param mintRequest - The minting request details.
* @returns A `MintParamsOption` indicating if minting is permitted.
*/
canMint(mintRequest: MintRequest): Promise<MintParamsOption>;
/**
* Checks whether the NFT state can be updated.
* Typically returns true if the contract is not paused.
* @param input - The current state of the NFT.
* @param output - The desired new state of the NFT.
* @returns A `Bool` indicating whether the update is allowed.
*/
canUpdate(input: NFTState, output: NFTState): Promise<Bool>;
/**
* Determines whether a transfer between the specified addresses is permitted.
* @param transferEvent - The transfer event details.
* @returns A `Bool` indicating whether the transfer is allowed.
*/
canTransfer(transferEvent: TransferEvent): Promise<Bool>;
/**
* Pauses the contract, disabling certain administrative actions.
* Can only be called by the admin if `canPause` is `true`.
*/
pause(): Promise<void>;
/**
* Resumes the contract, re-enabling administrative actions.
* Can only be called by the admin if `canPause` is `true`.
*/
resume(): Promise<void>;
/**
* Transfers ownership of the contract to a new admin.
* @param to - The public key of the new owner.
* @returns The public key of the previous admin.
*/
transferOwnership(to: PublicKey): Promise<PublicKey>;
/**
* Accept transfer of the ownership of the contract.
* @returns The public key of the previous admin.
*/
acceptOwnership(): Promise<PublicKey>;
canChangeVerificationKey(vk: VerificationKey, address: PublicKey, tokenId: Field): Promise<Bool>;
/**
* Determines if the name can be changed for a Collection.
*/
canChangeName(name: Field): Promise<Bool>;
/**
* Determines if the creator can be changed for a Collection.
*/
canChangeCreator(creator: PublicKey): Promise<Bool>;
/**
* Determines if the base URI can be changed for a Collection.
*/
canChangeBaseUri(baseUri: Field): Promise<Bool>;
/**
* Determines if the royalty fee can be changed for a Collection.
*/
canChangeRoyalty(royaltyFee: UInt32): Promise<Bool>;
/**
* Determines if the transfer fee can be changed for a Collection.
*/
canChangeTransferFee(transferFee: UInt64): Promise<Bool>;
/**
* Determines if the admin contract can be changed for a Collection.
*/
canSetAdmin(admin: PublicKey): Promise<Bool>;
/**
* Determines if the collection can be paused.
*/
canPause(): Promise<Bool>;
/**
* Determines if the collection can be resumed.
*/
canResume(): Promise<Bool>;
}