UNPKG

@silvana-one/nft

Version:
58 lines 2.1 kB
import { __decorate, __metadata } from "tslib"; import { AccountUpdate, Bool, method, PublicKey, SmartContract, state, State, Permissions, } from "o1js"; import { NFTState } from "./types.js"; export { NFTStandardUpdate, }; /** * The **NFTStandardUpdate** contract is the default implementation of the `NFTUpdateBase` interface. */ class NFTStandardUpdate extends SmartContract { constructor() { super(...arguments); /** * The public key of the contract's administrator. */ this.admin = State(); } /** * Deploys the contract with initial settings. * @param props - Deployment properties including admin, upgradeAuthority, uri, canPause, and isPaused. */ async deploy(props) { await super.deploy(props); this.admin.set(props.admin); this.account.zkappUri.set(props.uri); this.account.permissions.set({ ...Permissions.default(), setVerificationKey: Permissions.VerificationKey.signature(), setPermissions: Permissions.impossible(), }); } /** * Ensures that the transaction is authorized by the contract owner. * @returns A signed `AccountUpdate` from the admin. */ async ensureOwnerSignature() { const admin = this.admin.getAndRequireEquals(); const adminUpdate = AccountUpdate.createSigned(admin); adminUpdate.body.useFullCommitment = Bool(true); // Prevent memo and fee change return adminUpdate; } async canUpdate(collectionAddress, nftAddress, input, output) { await this.ensureOwnerSignature(); return Bool(true); } } __decorate([ state(PublicKey), __metadata("design:type", Object) ], NFTStandardUpdate.prototype, "admin", void 0); __decorate([ method.returns(Bool), __metadata("design:type", Function), __metadata("design:paramtypes", [PublicKey, PublicKey, NFTState, NFTState]), __metadata("design:returntype", Promise) ], NFTStandardUpdate.prototype, "canUpdate", null); //# sourceMappingURL=update.js.map