UNPKG

@salad-labs/loopz-typescript

Version:
195 lines 9.2 kB
import { Asset, Maybe, Network } from "./types/base"; import { SeaportFee, OrderCreated, OrderConfig, OrderListResponse, OrderEvents } from "./types/order"; import { ConnectedWallet } from "@privy-io/react-auth"; import { IOrder } from "."; /** * Order class that handles interactions with the OpenSea trading platform. * @class Order * @extends Client */ export declare class Order { private static _config; private static _instance; private static _client; /** * @property {Maybe<ethers.providers.Web3Provider | ethers.providers.JsonRpcProvider>} _provider - The provider instance. */ private _provider; /** * @property {Maybe<Seaport>} _seaport - The Seaport instance. */ private _seaport; /** * @property {number} _blocksNumberConfirmationRequired - The number of block confirmations required. */ private _blocksNumberConfirmationRequired; /** * @property {number} _MIN_BLOCKS_REQUIRED - The minimum number of block confirmations required */ private _MIN_BLOCKS_REQUIRED; private _eventsCallbacks; private _initialized; private constructor(); /** static methods */ static config(config: { devMode: boolean; }): void; static getInstance(): Order; /** private instance methods */ /** * Asynchronously fetches the platform Gnosis multisig wallet from the backend API. * @returns {Promise<Maybe<<MultiSigWallet>>>} A promise that resolves to the multisig wallet object if successful, * or null if there was an error or no data was returned in the response. */ private _getGnosis; /** * Asynchronously fetches platform fees from the backend API. * @returns A Promise that resolves to a Maybe<Fee> object. */ private _getMasterFee; /** * Analyzes the order initialization object to extract offer and consideration details. * @param {CreateOrderInput} orderInit - The order initialization object. * @returns An object containing offer and consideration details. */ private _analyzeOrder; /** * Adds the master fees to the given order input. * @param {CreateOrderInput} orderInit - The initial order input to add platform fees to. * @returns {Promise<CreateOrderInput>} The order input with platform fees added. */ private _addMasterFee; /** public instance methods */ isInitialized(): boolean; init(wallet: ConnectedWallet): Promise<void>; /** * Emits an event with the specified name and parameters to all registered callbacks for that event. * @param {string} event - The name of the event to emit. * @param {any} [params] - The parameters to pass to the event callbacks. * @returns None */ _emit(event: OrderEvents, params?: any): void; on(eventName: OrderEvents, callback: Function, onlyOnce?: boolean): void; /** * Unsubscribes a callback function from a specific event. * @param {"onFinalizeError"} eventName - The name of the event to unsubscribe from. * @returns None * @throws {Error} If the event is not supported or the callback is not a function. */ off(eventName: OrderEvents): void; /** * Set the block numbers to wait in which consider a transaction mined by the create, cancel and finalize methods. * @param {number} blocksNumberConfirmationRequired - The number of blocks required for confirmation. * @throws {Error} If blocksNumberConfirmationRequired is less than 1. */ setBlocksNumberConfirmationRequired(blocksNumberConfirmationRequired: number): void; /** * Create an order instance with the given maker and taker assets, along with additional parameters. * @param {{Array<Asset>; address: string}} participantOne - The assets offered by the maker. * @param {{Array<Asset>; address: string}} participantTwo - The assets desired by the taker. * @param {number} [end=0] - The end time for the order. * @param {Array<SeaportFee>} [fees] - Optional fees for the order. * @param {string} proposalId - The ID of the proposal. */ create(wallet: ConnectedWallet, participantOne: { assets: Array<Asset>; address: string; }, participantTwo: { assets: Array<Asset>; address: string; }, end?: number, fees?: Array<SeaportFee>, proposalId?: string): Promise<Maybe<OrderCreated>>; /** * Finalizes a order by fetching order details, executing the order, and handling transaction events. * @param {string} orderId - The ID of the trade to be finalized. * @returns None */ finalize(orderId: string): Promise<void>; /** * Cancel an order with the given order ID. * @param {string} orderId - The ID of the order to cancel. * @param {number} [gasLimit=2000000] - The gas limit for the transaction. * @param {Maybe<string>} [gasPrice=null] - The gas price for the transaction. * @returns None */ cancel(orderId: string, gasLimit?: number, gasPrice?: Maybe<string>): Promise<void>; /** * Retrieves order details for a specific network and order ID. * @param {string} networkId - The network ID for the order. * @param {string} id - The ID of the order. * @returns {Promise<Maybe<OrderDetail>>} A Promise that resolves to the order detail information, or null if an error occurs. */ get(networkId: string, id: string): Promise<Maybe<IOrder>>; /** * Retrieves a list of global orderss based on the provided parameters. * @param {object} options - An object containing the parameters for fetching the orders list. * @param {Network | "*"} networkId - The network ID or "*" for all networks. * @param {string | "*"} status - The status of the orders or "*" for all statuses. * @param {number} skip - The number of orders to skip. * @param {number} take - The number of orders to retrieve. * @param {string} [from] - Optional parameter for filtering orders from a specific date. * @param {string} [to] - Optional parameter for filtering orders up to a specific date. * @param {Array<{ address: string; networkId: Network }>} [collectios] - an raary of collections paired with their respective network. * @param {Array<string>} [search] - An array of search terms to filter results. * @param {object} [order] - An object containing direction and field for ordering results. * @param {string} order.direction - The direction of ordering, either "ASC" for ascending or "DESC" for descending. * @param {string} order.field - The field to order results by. */ listOrders({ networkId, status, skip, take, from, to, collections, search, order, }: { networkId: Network | "*"; status: string | "*"; skip: number; take: number; from?: string; to?: string; collections?: Array<{ address: string; networkId: Network; }>; search?: Array<string>; order?: { direction: "ASC" | "DESC"; field: string; }; }): Promise<Maybe<OrderListResponse>>; /** * Retrieves a list of user orders based on the provided parameters. * @param {object} options - An object containing the parameters for fetching user orders. * @param {Network | "*"} networkId - The network ID or "*" for all networks. * @param {string} did - The user's did. * @param {string | "*"} status - The status of the orders or "*" for all statuses. * @param {number} skip - The number of orders to skip. * @param {number} take - The number of orders to retrieve. * @param {string} [from] - Optional parameter for filtering orders from a specific date. * @param {string} [to] - Optional parameter for filtering orders up to a specific date. * @param {Array<{ address: string; networkId: Network }>} [collectios] - an raary of collections paired with their respective network. * @param {Array<string>} [search] - An array of search terms to filter results. * @param {object} [order] - An object containing direction and field for ordering results. * @param {string} order.direction - The direction of ordering, either "ASC" for ascending or "DESC" for descending. * @param {string} order.field - The field to order results by. */ listUserOrders({ networkId, did, status, skip, take, from, to, collections, searchAddress, order, }: { networkId: Network | "*"; did: string; status: string | "*"; skip: number; take: number; from?: string; to?: string; collections?: Array<{ address: string; networkId: Network; }>; searchAddress?: string; order?: { direction: "ASC" | "DESC"; field: string; }; }): Promise<Maybe<OrderListResponse>>; /** * Updates the configuration settings for the order module. * @param {OrderConfig} config - The configuration object for the order module. * @returns None */ config(config: OrderConfig): void; } //# sourceMappingURL=order.d.ts.map