@silvana-one/nft
Version:
Mina NFT library
715 lines (714 loc) • 19.2 kB
TypeScript
import { AccountUpdate, DeployArgs, PublicKey, State, UInt64, SmartContract, Bool, Field, VerificationKey } from "o1js";
/**
* The BulletinBoard contract serves as a centralized event emitter for NFT marketplace activities.
* It provides a standardized way to broadcast and track various marketplace events such as:
* - New collection listings
* - Offers made on NFTs
* - Offer cancellations
* - Bids placed on NFTs
* - Bid cancellations
* - Completed sales
*
* While anyone can emit events through this contract, all events are prefixed with "BB_" to
* distinguish them from events emitted directly by NFT contracts. This helps maintain clarity
* in event tracking and marketplace activity monitoring.
*
* The BulletinBoard does not handle any NFT transfers or escrow - it purely exists as an
* event broadcasting mechanism to help indexers and UIs track marketplace activity.
*/
export { BB_NewCollectionEvent, BB_OfferEvent, BB_CancelOfferEvent, BB_BidEvent, BB_CancelBidEvent, BB_SaleEvent, BB_UpgradeVerificationKeyEvent, BB_ChangeAdminEvent, BulletinBoard, BulletinBoardDeployProps, };
declare const BB_NewCollectionEvent_base: (new (value: {
collection: PublicKey;
}) => {
collection: PublicKey;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
}) => {
collection: PublicKey;
};
toInput: (x: {
collection: PublicKey;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
}) => {
collection: string;
};
fromJSON: (x: {
collection: string;
}) => {
collection: PublicKey;
};
empty: () => {
collection: PublicKey;
};
};
declare class BB_NewCollectionEvent extends BB_NewCollectionEvent_base {
}
declare const BB_OfferEvent_base: (new (value: {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
nft: {
x: bigint;
isOdd: boolean;
};
offer: {
x: bigint;
isOdd: boolean;
};
price: bigint;
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
nft: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
offer: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
price: number | bigint | UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
};
toInput: (x: {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
}) => {
collection: string;
nft: string;
offer: string;
price: string;
};
fromJSON: (x: {
collection: string;
nft: string;
offer: string;
price: string;
}) => {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
};
empty: () => {
collection: PublicKey;
nft: PublicKey;
offer: PublicKey;
price: UInt64;
};
};
declare class BB_OfferEvent extends BB_OfferEvent_base {
}
declare const BB_CancelOfferEvent_base: (new (value: {
collection: PublicKey;
nft: PublicKey;
}) => {
collection: PublicKey;
nft: PublicKey;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
nft: PublicKey;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
nft: {
x: bigint;
isOdd: boolean;
};
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
nft: PublicKey;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
nft: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
}) => {
collection: PublicKey;
nft: PublicKey;
};
toInput: (x: {
collection: PublicKey;
nft: PublicKey;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
nft: PublicKey;
}) => {
collection: string;
nft: string;
};
fromJSON: (x: {
collection: string;
nft: string;
}) => {
collection: PublicKey;
nft: PublicKey;
};
empty: () => {
collection: PublicKey;
nft: PublicKey;
};
};
declare class BB_CancelOfferEvent extends BB_CancelOfferEvent_base {
}
declare const BB_BidEvent_base: (new (value: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
nft: {
x: bigint;
isOdd: boolean;
};
bid: {
x: bigint;
isOdd: boolean;
};
price: bigint;
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
nft: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
bid: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
price: number | bigint | UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
};
toInput: (x: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
}) => {
collection: string;
nft: string;
bid: string;
price: string;
};
fromJSON: (x: {
collection: string;
nft: string;
bid: string;
price: string;
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
};
empty: () => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
price: UInt64;
};
};
declare class BB_BidEvent extends BB_BidEvent_base {
}
declare const BB_CancelBidEvent_base: (new (value: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
nft: {
x: bigint;
isOdd: boolean;
};
bid: {
x: bigint;
isOdd: boolean;
};
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
nft: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
bid: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
};
toInput: (x: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
}) => {
collection: string;
nft: string;
bid: string;
};
fromJSON: (x: {
collection: string;
nft: string;
bid: string;
}) => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
};
empty: () => {
collection: PublicKey;
nft: PublicKey;
bid: PublicKey;
};
};
declare class BB_CancelBidEvent extends BB_CancelBidEvent_base {
}
declare const BB_SaleEvent_base: (new (value: {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
}, {
collection: {
x: bigint;
isOdd: boolean;
};
nft: {
x: bigint;
isOdd: boolean;
};
buyer: {
x: bigint;
isOdd: boolean;
};
price: bigint;
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
};
} & {
fromValue: (value: {
collection: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
nft: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
buyer: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
price: number | bigint | UInt64;
}) => {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
};
toInput: (x: {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
}) => {
collection: string;
nft: string;
buyer: string;
price: string;
};
fromJSON: (x: {
collection: string;
nft: string;
buyer: string;
price: string;
}) => {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
};
empty: () => {
collection: PublicKey;
nft: PublicKey;
buyer: PublicKey;
price: UInt64;
};
};
declare class BB_SaleEvent extends BB_SaleEvent_base {
}
declare const BB_UpgradeVerificationKeyEvent_base: (new (value: {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}) => {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}, {
vk: bigint;
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
};
} & {
fromValue: (value: {
vk: string | number | bigint | import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}) => {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
};
toInput: (x: {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
}) => {
vk: string;
};
fromJSON: (x: {
vk: string;
}) => {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
};
empty: () => {
vk: import("node_modules/o1js/dist/node/lib/provable/field.js").Field;
};
};
declare class BB_UpgradeVerificationKeyEvent extends BB_UpgradeVerificationKeyEvent_base {
}
declare const BB_ChangeAdminEvent_base: (new (value: {
admin: PublicKey;
}) => {
admin: PublicKey;
}) & {
_isStruct: true;
} & Omit<import("node_modules/o1js/dist/node/lib/provable/types/provable-intf.js").Provable<{
admin: PublicKey;
}, {
admin: {
x: bigint;
isOdd: boolean;
};
}>, "fromFields"> & {
fromFields: (fields: import("node_modules/o1js/dist/node/lib/provable/field.js").Field[]) => {
admin: PublicKey;
};
} & {
fromValue: (value: {
admin: PublicKey | {
x: Field | bigint;
isOdd: Bool | boolean;
};
}) => {
admin: PublicKey;
};
toInput: (x: {
admin: PublicKey;
}) => {
fields?: Field[] | undefined;
packed?: [Field, number][] | undefined;
};
toJSON: (x: {
admin: PublicKey;
}) => {
admin: string;
};
fromJSON: (x: {
admin: string;
}) => {
admin: PublicKey;
};
empty: () => {
admin: PublicKey;
};
};
declare class BB_ChangeAdminEvent extends BB_ChangeAdminEvent_base {
}
interface BulletinBoardDeployProps extends Exclude<DeployArgs, undefined> {
/** The admin. */
admin: PublicKey;
/** The fee. */
fee?: UInt64;
}
/**
* The BulletinBoard contract serves as a centralized event emitter for NFT marketplace activities.
* It provides a standardized way to broadcast and track various marketplace events such as:
* - New collection listings
* - Offers made on NFTs
* - Offer cancellations
* - Bids placed on NFTs
* - Bid cancellations
* - Completed sales
*
* While anyone can emit events through this contract, all events are prefixed with "BB_" to
* distinguish them from events emitted directly by NFT contracts. This helps maintain clarity
* in event tracking and marketplace activity monitoring.
*/
declare class BulletinBoard extends SmartContract {
admin: State<PublicKey>;
fee: State<UInt64>;
deploy(args: BulletinBoardDeployProps): Promise<void>;
events: {
newCollection: typeof BB_NewCollectionEvent;
offer: typeof BB_OfferEvent;
cancelOffer: typeof BB_CancelOfferEvent;
bid: typeof BB_BidEvent;
cancelBid: typeof BB_CancelBidEvent;
sale: typeof BB_SaleEvent;
upgradeVerificationKey: typeof BB_UpgradeVerificationKeyEvent;
changeAdmin: typeof BB_ChangeAdminEvent;
withdraw: typeof UInt64;
setFee: typeof UInt64;
};
/**
* Pays the fee to prevent spamming the BulletinBoard with fake events.
*/
payFee(): Promise<AccountUpdate>;
/**
* Emits a new collection event.
* @param collection - The collection address.
*/
newCollection(collection: PublicKey): Promise<void>;
/**
* Emits an offer event.
* @param collection - The collection address.
* @param nft - The NFT address.
* @param offer - The offer address.
* @param price - The price.
*/
offer(collection: PublicKey, nft: PublicKey, offer: PublicKey, price: UInt64): Promise<void>;
/**
* Emits a cancel offer event.
* @param collection - The collection address.
* @param nft - The NFT address.
*/
cancelOffer(collection: PublicKey, nft: PublicKey): Promise<void>;
/**
* Emits a bid event.
* @param collection - The collection address.
* @param nft - The NFT address.
* @param bid - The bid address.
* @param price - The price.
*/
bid(collection: PublicKey, nft: PublicKey, bid: PublicKey, price: UInt64): Promise<void>;
/**
* Emits a cancel bid event.
* @param collection - The collection address.
* @param nft - The NFT address.
* @param bid - The bid address.
*/
cancelBid(collection: PublicKey, nft: PublicKey, bid: PublicKey): Promise<void>;
/**
* Emits a sale event.
* @param collection - The collection address.
* @param nft - The NFT address.
* @param buyer - The buyer address.
* @param price - The price.
*/
sale(collection: PublicKey, nft: PublicKey, buyer: PublicKey, price: UInt64): Promise<void>;
/**
* Ensures that the transaction is authorized by the contract owner.
* @returns A signed `AccountUpdate` from the admin.
*/
ensureOwnerSignature(): Promise<AccountUpdate>;
/**
* Changes the contract's admin
* @param admin - The new admin.
*/
changeAdmin(admin: PublicKey): Promise<void>;
/**
* Changes the contract's fee
* @param fee - The new fee.
*/
setFee(fee: UInt64): Promise<void>;
/**
* 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>;
/**
* Withdraws the fee by admin
*/
withdraw(amount: UInt64): Promise<void>;
}