UNPKG

@xoxno/sdk-js

Version:

The SDK to interact with the XOXNO Protocol!

256 lines 12.6 kB
import type { IPlainTransactionObject } from '@multiversx/sdk-core/out/interface'; import type { NftData } from '..'; import type { GlobalOffer } from '../types/collection'; import type { AcceptGlobalOffer, Auction, ChangeListing, NewListingArgs, Payment, SendCustomOffer, SendGlobalOffer, WithSenderAndNonce } from '../types/interactions'; export declare class SCInteraction { private xo; private call; private api; private config; private factory; private constructor(); static init(): Promise<SCInteraction>; private getResult; /** * Gets the percentage of each transaction that will be paid to the marketplace. * * @returns The percentage of each transaction that will be paid to the marketplace. */ getMarketplaceFees: () => Promise<number>; /** * Retrieves the list of accepted payment tokens. * @returns {string[]} A list of accepted payment tokens. */ getAcceptedPaymentTokens: () => Promise<string[]>; /** * This function returns a list of IDs of global offers. * @returns {number[]} a list of IDs of global offers. */ getGlobalOfferIDs: () => Promise<number[]>; /** * Gets the balance of a user in a token of a specific pool. * @param address The address of the user. * @param token The token address. * @param nonce The nonce of the pool. * @returns {number} The balance of the user in the token of the pool. */ getUserPoolBalance(address: string, token: string, nonce: number): Promise<number>; private isOfferActive; /** * Returns the global offer data for the offer with the given id. * * @param global_offer_id The id of the global offer for which to return the data. * * @returns An object containing the global offer data for the offer with the given id. If the global offer id is invalid, the return value will be null. */ getGlobalOfferData: (global_offer_id: number) => Promise<GlobalOffer>; /** * Returns the auction struct for the given id. * * @param auctionID The id of the auction for which to return the data. * * @returns {Auction} An object containing the auction data for the given id. If the auction id is invalid, the return value will be null. */ getAuctionInfo: (auctionID: number) => Promise<Auction | null>; /** Gets the number of listings. * @returns {number} The number of listings. * */ getListingsCount(): Promise<number>; /** Gets the number of custom offers. * @returns {number} The number of custom offers. * */ getOffersCount(): Promise<number>; /** Gets the number of global offers. * @returns {number} The number of global offers. * */ getGlobalOffersCount(): Promise<number>; /** Gets the number of collections listed. * @returns {number} The number of collections listed. * */ getCollectionsCount(): Promise<number>; /** * Checks whether a collection is listed with at least 1 NFT. * * @param collection name of the collection * @return true if the collection is listed, false otherwise */ isCollectionListed(collection: string): Promise<boolean>; /** Gets the on sale NFT count of the collection. * * @param collection The collection identifier for which one wants to get the on sale NFT count. * * @returns {number} The on sale NFT count of the collection. * */ getCollectionNFTsOnSaleCount(collection: string): Promise<number>; /** Gets the active unique auction IDs of collection. * * @param collection The collection identifier for which one wants to get the active unique auction IDs. * * @returns {number[]} The active unique auction IDs of collection. * */ getAuctionIDsForCollection(collection: string): Promise<number[]>; /** * Withdraw auctions from the smart contract. * * @param auctionIDs The IDs of the auctions to withdraw from * @returns {IPlainTransactionObject} The interaction object of the smart contract */ withdrawAuctions({ auctionIDs, sender, market, signature, }: { auctionIDs: number[]; sender: WithSenderAndNonce; signature?: string; market?: string; }): IPlainTransactionObject[]; /** * Withdraw global offer from the smart contract. * * @param auctionIDs The IDs of the global offer to withdraw * @returns {IPlainTransactionObject} The interaction object of the smart contract */ withdrawGlobalOffer(offerID: number, market: string | undefined, senderNonce: WithSenderAndNonce): IPlainTransactionObject; /** * Accept a global offer * * @param offerID The offer ID * @returns {IPlainTransactionObject} The interaction object of the smart contract */ acceptGlobalOffer({ signature, offer_id, auction_ids_opt, market, nfts, address, nonce, }: AcceptGlobalOffer & WithSenderAndNonce): IPlainTransactionObject; /** * Send a global offer * @param payment_token The token used for payment * @param payment_nonce The nonce of the payment token * @param price The price of the offer * @param collection The collection of the NFT * @param attributes The attributes of the NFT * @param depositAmount The deposit amount * @returns {IPlainTransactionObject} The interaction object of the smart contract * */ sendGlobalOffer({ payment_token, payment_nonce, price, collection, quantity, attributes, depositAmount, address, nonce, }: SendGlobalOffer & WithSenderAndNonce): IPlainTransactionObject; /** * Send a custom offer * @param payment_token The token used for payment * @param payment_nonce The nonce of the payment token * @param price The price of the offer * @param deadline The deadline of the offer * @param nft The NFT to be sold * @param depositAmount The deposit amount * @returns {IPlainTransactionObject} The interaction object of the smart contract * */ sendCustomOffer({ payment_token, payment_nonce, price, deadline, nft, depositAmount, address, nonce, }: SendCustomOffer & WithSenderAndNonce): IPlainTransactionObject; /** * Withdraws a custom offer * * @param offerID The offer ID * @returns {IPlainTransactionObject} The interaction object of the smart contract */ withdrawCustomOffer(offerID: number, senderNonce: WithSenderAndNonce, market: string): IPlainTransactionObject; /** * Decline a custom offer * * @param offerID The offer ID * @returns {IPlainTransactionObject} The interaction object of the smart contract */ declineCustomOffer(offerID: number, sender: WithSenderAndNonce, nft: NftData, market: string): IPlainTransactionObject; /** * Accept a custom offer * * @param offerID The offer ID * @returns {IPlainTransactionObject} The interaction object of the smart contract */ acceptCustomOffer(offerID: number, sender: WithSenderAndNonce, nft: NftData, market: string): IPlainTransactionObject; /** * @public * @function endAuction * @param {number} auctionID - The unique identifier of the auction. * @returns {IPlainTransactionObject} The resulting interaction with the specified chainID and gas limit. * * This function allows ending an auction by its auctionID. It takes the following parameter: * - auctionID (number): The unique identifier of the auction. * * The function calls the `endAuction` method on the smart contract with the provided auctionID. * Finally, it returns the resulting interaction with the specified chainID and gas limit. */ endAuction(auctionID: number, sender: WithSenderAndNonce, market?: string): IPlainTransactionObject; /** * Bid on an auction * * @param auctionID The auction ID * @param collection The NFT Collection * @param nonce The NFT nonce * @param payment The payment object * @returns {IPlainTransactionObject} The interaction object of the smart contract */ bidOnAuctionId(auctionID: number, collection: string, nonce: number, payment: Payment, sender: WithSenderAndNonce): IPlainTransactionObject; /** * Bulk buy auctions * * @param auctionIDs The auction IDs * @param payment The payment object * @returns {IPlainTransactionObject} The interaction object of the smart contract */ bulkBuy(auctionIDs: number[], payment: Payment, sender: WithSenderAndNonce): IPlainTransactionObject; /** * @public * @async * @function buyAuctionById * @param {Object} options - An object containing the necessary parameters to buy an auction. * @param {number} options.auctionID - The unique identifier of the auction. * @param {string} [options.collection] - The collection the auctioned token belongs to (optional). * @param {number} [options.nonce] - The nonce of the auctioned token (optional). * @param {number} [options.quantity=1] - The quantity of tokens to buy (default is 1). * @param {string} [options.token='EGLD'] - The payment token (default is 'EGLD'). * @param {number} [options.paymentAmount] - The payment amount for the auction (optional). * @param {boolean} [options.withCheck=true] - Whether to check the auction information (default is true). * @param {boolean} [options.isBigUintPayment=false] - Whether the payment amount is a big integer (default is false). * @returns {Promise<IPlainTransactionObject>} The resulting interaction with the specified chainID and gas limit. * * This function allows a user to buy an auction by its auctionID. It takes an object with the following properties: * - auctionID (number): The unique identifier of the auction. * - collection (string, optional): The collection the auctioned token belongs to. * - nonce (number, optional): The nonce of the auctioned token. * - quantity (number, optional): The quantity of tokens to buy (default is 1). * - token (string, optional): The payment token (default is 'EGLD'). * - paymentAmount (number, optional): The payment amount for the auction. * - withCheck (boolean, optional): Whether to check the auction information (default is true). * - isBigUintPayment (boolean, optional): Whether the payment amount is a big integer (default is false). * * The function first checks if the auction exists and if its type is NFT or SftOnePerPayment. If not, an error is thrown. * Then, it calculates the payment amount and calls the `buy` method on the smart contract with the provided parameters. * Finally, the function returns the resulting interaction with the specified chainID and gas limit. */ buyAuctionById({ auctionID, collection, nonce, paymentAmount, quantity, token, withCheck, isBigUintPayment, isBid, decimals, market, sender, }: { auctionID: number; collection?: string; nonce?: number; quantity?: number; token?: string; paymentAmount?: string; withCheck?: boolean; isBigUintPayment?: boolean; isBid?: boolean; market?: string; decimals?: number; sender: WithSenderAndNonce; }): Promise<IPlainTransactionObject>; /** * @docutype * @public * @async * @function changeListing * @param {ChangeListing[]} listings - An array of objects containing the information needed to change a listing. * @returns {IPlainTransactionObject} The resulting interaction with the specified chainID and gas limit. * * This function takes an array of `ChangeListing` objects and constructs `Struct` instances using the provided * information. Each `ChangeListing` object should have the following properties: * - paymentToken (string): The identifier of the payment token type. * - price (BigInt): The new price for the listing. * - auctionID (number): The unique identifier of the auction. * - deadline (number): The deadline (in Unix time) for the listing. * * The function then calls the `changeListing` method on the smart contract and returns the resulting interaction * with the specified chainID and gas limit. */ changeListing(listings: ChangeListing[], sender: WithSenderAndNonce, marketplace: string): Promise<IPlainTransactionObject>; listNFTs(listings: NewListingArgs[], sender: WithSenderAndNonce): Promise<IPlainTransactionObject>; } //# sourceMappingURL=index.d.ts.map