opensea-js
Version:
TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data
98 lines (97 loc) • 5.87 kB
TypeScript
import { OrderComponents } from "@opensea/seaport-js/lib/types";
import { Overrides } from "ethers";
import { OrderV2 } from "../orders/types";
import { Chain } from "../types";
import { SDKContext } from "./context";
/**
* Order cancellation operations
*/
export declare class CancellationManager {
private context;
constructor(context: SDKContext);
/**
* Cancel an order onchain, preventing it from ever being fulfilled.
* This method accepts either a full OrderV2 object or an order hash with protocol address.
*
* @param options
* @param options.order The order to cancel (OrderV2 object)
* @param options.orderHash Optional order hash to cancel. Must provide protocolAddress if using this.
* @param options.accountAddress The account address that will be cancelling the order.
* @param options.protocolAddress Required when using orderHash. The Seaport protocol address for the order.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for on-chain order attribution to assist with analytics.
*
* @throws Error if neither order nor orderHash is provided.
* @throws Error if the accountAddress is not available through wallet or provider.
* @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
*/
cancelOrder({ order, orderHash, accountAddress, protocolAddress, domain, }: {
order?: OrderV2;
orderHash?: string;
accountAddress: string;
protocolAddress?: string;
domain?: string;
}): Promise<void>;
/**
* Cancel multiple orders onchain, preventing them from being fulfilled.
* This method accepts either full OrderV2 objects, OrderComponents, or order hashes with protocol address.
*
* **Event Behavior**: For backwards compatibility with the singular `cancelOrder` method,
* this method dispatches a `CancelOrder` event for the first order only, and only when
* an OrderV2 object is available (either provided directly or fetched via orderHashes).
* No event is dispatched when using OrderComponents directly, as they lack the full order data.
*
* @param options
* @param options.orders Array of orders to cancel. Can be OrderV2 objects or OrderComponents.
* @param options.orderHashes Optional array of order hashes to cancel. Must provide protocolAddress if using this.
* @param options.accountAddress The account address cancelling the orders.
* @param options.protocolAddress Required when using orderHashes. The Seaport protocol address for the orders.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the cancellation.
*
* @throws Error if orderHashes is provided without protocolAddress.
* @throws Error if neither orders nor orderHashes is provided.
* @throws Error if the accountAddress is not available through wallet or provider.
* @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
*/
cancelOrders({ orders, orderHashes, accountAddress, protocolAddress, domain, overrides, }: {
orders?: Array<OrderV2 | OrderComponents>;
orderHashes?: string[];
accountAddress: string;
protocolAddress?: string;
domain?: string;
overrides?: Overrides;
}): Promise<string>;
/**
* Cancel orders onchain, preventing them from being fulfilled.
* @param options
* @param options.orders The orders to cancel
* @param options.accountAddress The account address cancelling the orders.
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
* This can be used for on-chain order attribution to assist with analytics.
* @param options.overrides Transaction overrides, ignored if not set.
* @returns Transaction hash of the order.
*/
private cancelSeaportOrders;
/**
* Get the offerer signature for canceling an order offchain.
* The signature will only be valid if the signer address is the address of the order's offerer.
*/
getOffererSignature(protocolAddress: string, orderHash: string, chain: Chain): Promise<string>;
/**
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
* Protocol and Chain are required to prevent hash collisions.
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation.
* @param protocolAddress The Seaport address for the order.
* @param orderHash The order hash, or external identifier, of the order.
* @param chain The chain where the order is located.
* @param offererSignature An EIP-712 signature from the offerer of the order.
* If this is not provided, the API key used to initialize the SDK must belong to the order's offerer.
* The signature must be a EIP-712 signature consisting of the order's Seaport contract's
* name, version, address, and chain. The struct to sign is `OrderHash` containing a
* single bytes32 field.
* @param useSignerToDeriveOffererSignature Derive the offererSignature from the Ethers signer passed into this sdk.
* @returns The response from the API.
*/
offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string, useSignerToDeriveOffererSignature?: boolean): Promise<import("../api/types").CancelOrderResponse>;
}