UNPKG

@dojima-wallet/solver-modules

Version:

Modules of different protocols for solvers

273 lines (272 loc) 11.4 kB
import { Chain, EventType, EventData, OrderV2, CollectionOffer, AssetWithTokenId, Order, AssetWithTokenStandard } from "opensea-js"; import { BigNumberish, ethers, Overrides } from "ethers"; export declare class OpenSeaClient { private sdk; private provider; private signer; private chain; private rpcUrl; protected openseaApiKey: string; constructor(privateKey: string, chain: string, openseaApiKey: string); getWethContract(): Promise<ethers.Contract>; getChain(): Chain; getRpcUrl(): string; /** * Add a listener for events emitted by the SDK. * @param event The EventType to listen to * @param listener A callback that will accept an object with EventData * @param once Whether the listener should only be called once, or continue listening until removed */ addListener(event: EventType, listener: (data: EventData) => void, once?: boolean): void; /** * Instead of signing an off-chain order, this methods allows you to approve an order * with on on-chain transaction. * @param order Order to approve * @param domain An optional domain to be hashed and included at the end of fulfillment calldata * @returns Transaction hash of the approval transaction */ approveOrder(order: OrderV2, domain?: string): Promise<string>; /** * Cancel an order onchain, preventing it from ever being fulfilled. * @param options.order The order to cancel * @param options.accountAddress The account address that will be cancelling the order * @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata */ cancelOrder({ order, accountAddress, domain, }: { order: OrderV2; accountAddress: string; domain?: string; }): Promise<void>; /** * Create and submit a collection offer. * @param options Parameters for creating the collection offer * @returns The CollectionOffer that was created */ createCollectionOffer({ collectionSlug, accountAddress, amount, quantity, domain, salt, expirationTime, paymentTokenAddress, excludeOptionalCreatorFees, offerProtectionEnabled, traitType, traitValue, }: { collectionSlug: string; accountAddress: string; amount: BigNumberish; quantity: number; domain?: string; salt?: BigNumberish; expirationTime?: number | string; paymentTokenAddress: string; excludeOptionalCreatorFees?: boolean; offerProtectionEnabled?: boolean; traitType?: string; traitValue?: string; }): Promise<CollectionOffer | null>; /** * Create and submit a listing for an asset. * @param options Parameters for creating the listing * @returns The OrderV2 that was created */ createListing({ asset, accountAddress, startAmount, endAmount, quantity, domain, salt, listingTime, expirationTime, paymentTokenAddress, buyerAddress, englishAuction, excludeOptionalCreatorFees, zone, }: { asset: AssetWithTokenId; accountAddress: string; startAmount: BigNumberish; endAmount?: BigNumberish; quantity?: BigNumberish; domain?: string; salt?: BigNumberish; listingTime?: number; expirationTime?: number; paymentTokenAddress?: string; buyerAddress?: string; englishAuction?: boolean; excludeOptionalCreatorFees?: boolean; zone?: string; }): Promise<OrderV2>; /** * Create and submit an offer on an asset. * @param options Parameters for creating the offer * @returns The OrderV2 that was created */ createOffer({ asset, accountAddress, startAmount, domain, salt, expirationTime, paymentTokenAddress, quantity, excludeOptionalCreatorFees, zone, }: { asset: AssetWithTokenId; accountAddress: string; startAmount: BigNumberish; domain?: string; salt?: BigNumberish; expirationTime?: BigNumberish; paymentTokenAddress?: string; quantity?: BigNumberish; excludeOptionalCreatorFees?: boolean; zone?: string; }): Promise<OrderV2>; /** * Fulfill an order for an asset. The order can be either a listing or an offer. * @param options Parameters for fulfilling the order * @returns Transaction hash of the order */ fulfillOrder({ order, accountAddress, domain, recipientAddress, overrides, }: { order: OrderV2 | Order; accountAddress: string; domain?: string; recipientAddress?: string; overrides?: Overrides; }): Promise<string>; /** * Get an account's balance of any Asset. This asset can be an ERC20, ERC1155, or ERC721. * @param options Parameters for getting the balance * @returns The balance of the asset for the account * @throws Error if the token standard does not support balanceOf */ getBalance({ accountAddress, asset, }: { accountAddress: string; asset: AssetWithTokenStandard; }): Promise<bigint>; private handleError; /** * Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721. * @param options Parameters for transferring the asset * @returns Promise that resolves when the transfer is complete */ transfer({ amount, asset, fromAddress, overrides, toAddress, }: { amount?: BigNumberish; asset: AssetWithTokenStandard; fromAddress: string; overrides?: Overrides; toAddress: string; }): Promise<void>; /** * Unwrap WETH into ETH. Emits the UnwrapWeth event when the transaction is prompted. * @param options Parameters for unwrapping WETH * @returns Promise that resolves when the unwrap is complete */ wrapEth({ accountAddress, amountInEth, }: { accountAddress: string; amountInEth: BigNumberish; }): Promise<void>; /** * Wrap ETH into WETH. W-ETH is needed for making offers. * @param options Parameters for wrapping ETH * @returns Promise that resolves when the wrap is complete */ unwrapWeth({ accountAddress, amountInEth, }: { accountAddress: string; amountInEth: BigNumberish; }): Promise<void>; /** * Returns whether an order is fulfillable. * @param options Parameters for checking order fulfillability * @returns True if the order is fulfillable, else False * @throws Error if the order's protocol address is not supported by OpenSea */ isOrderFulfillable({ accountAddress, order, }: { accountAddress: string; order: OrderV2; }): Promise<boolean>; /** * Remove an event listener by calling .removeListener() on an event and listener. * @param event The EventType to remove a listener for * @param listener The listener to remove */ removeListener(event: EventType, listener: (data: EventData) => void): void; /** * Remove all event listeners. * This should be called when you're unmounting a component that listens to events to make UI updates. * @param event Optional EventType to remove listeners for */ removeAllListeners(event?: EventType): void; /** * Get a list of OpenSea collections * @returns Promise with the collections data */ getCollections(): Promise<any>; /** * Get a single collection's details * @param collectionSlug The slug of the collection to fetch * @returns Promise with the collection details */ getCollection(collectionSlug: string): Promise<any>; /** * Get an OpenSea Account Profile * @param addressOrUsername The address or username of the account to fetch * @returns Promise with the account profile data */ getAccount(addressOrUsername: string): Promise<any>; /** * Get a smart contract for a given chain and address * @param chain The blockchain where the contract is deployed * @param address The contract address * @returns Promise with the contract details */ getContract(chain: string, address: string): Promise<any>; /** * Get metadata, traits, ownership information, and rarity for a single NFT * @param chain The blockchain where the NFT exists * @param address The NFT contract address * @param identifier The token ID of the NFT * @returns Promise with the NFT details */ getNFT(chain: string, address: string, identifier: string): Promise<any>; /** * Get NFTs owned by a given account address * @param chain The blockchain to query * @param address The account address to get NFTs for * @returns Promise with the account's NFTs */ getNFTsByAccount(chain: string, address: string): Promise<any>; /** * Get multiple NFTs for a collection * @param collectionSlug The slug of the collection * @returns Promise with the collection's NFTs */ getNFTsByCollection(collectionSlug: string): Promise<any>; /** * Get multiple NFTs for a smart contract * @param chain The blockchain where the contract exists * @param address The contract address * @returns Promise with the contract's NFTs */ getNFTsByContract(chain: string, address: string): Promise<any>; /** * Refresh metadata for a single NFT * @param chain The blockchain where the NFT exists * @param address The NFT contract address * @param identifier The token ID of the NFT * @returns Promise with the refresh status */ refreshNFTMetadata(chain: string, address: string, identifier: string): Promise<any>; /** * Get a list of events for an account * @param address The account address * @param options Optional parameters (after, before timestamps) * @returns Promise with the account's events */ getEventsByAccount(address: string, options?: { after?: number; before?: number; }): Promise<any>; /** * Get a list of events for a collection * @param collectionSlug The collection slug * @returns Promise with the collection's events */ getEventsByCollection(collectionSlug: string): Promise<any>; /** * Get a list of events for a single NFT * @param chain The blockchain where the NFT exists * @param address The NFT contract address * @param identifier The token ID of the NFT * @returns Promise with the NFT's events */ getEventsByNFT(chain: string, address: string, identifier: string): Promise<any>; /** * Buy a listed NFT on OpenSea * @param options Parameters for buying the NFT * @param options.order The listing order to fulfill * @param options.accountAddress Address of the wallet that will buy the NFT * @param options.recipientAddress Optional address to receive the NFT (defaults to accountAddress) * @returns Transaction hash of the purchase */ buyNFT(collectionSlug: string, identifier: string, accountAddress: string, recipientAddress?: string): Promise<string>; /** * Get the best listing for an NFT * @param collectionSlug The collection slug * @param identifier The token ID of the NFT * @returns Promise with the best listing details */ getBestListingForNFT(collectionSlug: string, identifier: string): Promise<any>; }