@opensea/sdk 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +70 -0
- package/lib/api/accounts.d.ts +27 -0
- package/lib/api/accounts.js +46 -0
- package/lib/api/accounts.js.map +1 -0
- package/lib/api/api.d.ts +489 -0
- package/lib/api/api.js +754 -0
- package/lib/api/api.js.map +1 -0
- package/lib/api/apiPaths.d.ts +46 -0
- package/lib/api/apiPaths.js +176 -0
- package/lib/api/apiPaths.js.map +1 -0
- package/lib/api/chains.d.ts +13 -0
- package/lib/api/chains.js +22 -0
- package/lib/api/chains.js.map +1 -0
- package/lib/api/collections.d.ts +34 -0
- package/lib/api/collections.js +80 -0
- package/lib/api/collections.js.map +1 -0
- package/lib/api/drops.d.ts +21 -0
- package/lib/api/drops.js +39 -0
- package/lib/api/drops.js.map +1 -0
- package/lib/api/events.d.ts +26 -0
- package/lib/api/events.js +43 -0
- package/lib/api/events.js.map +1 -0
- package/lib/api/fetcher.d.ts +24 -0
- package/lib/api/fetcher.js +3 -0
- package/lib/api/fetcher.js.map +1 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +19 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/listings.d.ts +44 -0
- package/lib/api/listings.js +88 -0
- package/lib/api/listings.js.map +1 -0
- package/lib/api/nfts.d.ts +39 -0
- package/lib/api/nfts.js +79 -0
- package/lib/api/nfts.js.map +1 -0
- package/lib/api/offers.d.ts +54 -0
- package/lib/api/offers.js +124 -0
- package/lib/api/offers.js.map +1 -0
- package/lib/api/orders.d.ts +50 -0
- package/lib/api/orders.js +153 -0
- package/lib/api/orders.js.map +1 -0
- package/lib/api/search.d.ts +13 -0
- package/lib/api/search.js +22 -0
- package/lib/api/search.js.map +1 -0
- package/lib/api/tokens.d.ts +25 -0
- package/lib/api/tokens.js +43 -0
- package/lib/api/tokens.js.map +1 -0
- package/lib/api/types.d.ts +1113 -0
- package/lib/api/types.js +65 -0
- package/lib/api/types.js.map +1 -0
- package/lib/constants.d.ts +22 -0
- package/lib/constants.js +52 -0
- package/lib/constants.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/orders/privateListings.d.ts +12 -0
- package/lib/orders/privateListings.js +130 -0
- package/lib/orders/privateListings.js.map +1 -0
- package/lib/orders/types.d.ts +160 -0
- package/lib/orders/types.js +10 -0
- package/lib/orders/types.js.map +1 -0
- package/lib/orders/utils.d.ts +89 -0
- package/lib/orders/utils.js +177 -0
- package/lib/orders/utils.js.map +1 -0
- package/lib/sdk/assets.d.ts +104 -0
- package/lib/sdk/assets.js +398 -0
- package/lib/sdk/assets.js.map +1 -0
- package/lib/sdk/cancellation.d.ts +97 -0
- package/lib/sdk/cancellation.js +235 -0
- package/lib/sdk/cancellation.js.map +1 -0
- package/lib/sdk/context.d.ts +28 -0
- package/lib/sdk/context.js +3 -0
- package/lib/sdk/context.js.map +1 -0
- package/lib/sdk/fulfillment.d.ts +153 -0
- package/lib/sdk/fulfillment.js +298 -0
- package/lib/sdk/fulfillment.js.map +1 -0
- package/lib/sdk/orders.d.ts +253 -0
- package/lib/sdk/orders.js +679 -0
- package/lib/sdk/orders.js.map +1 -0
- package/lib/sdk/tokens.d.ts +31 -0
- package/lib/sdk/tokens.js +65 -0
- package/lib/sdk/tokens.js.map +1 -0
- package/lib/sdk.d.ts +560 -0
- package/lib/sdk.js +693 -0
- package/lib/sdk.js.map +1 -0
- package/lib/src/api/accounts.d.ts +18 -0
- package/lib/src/api/accounts.js +30 -0
- package/lib/src/api/accounts.js.map +1 -0
- package/lib/src/api/api.d.ts +429 -0
- package/lib/src/api/api.js +652 -0
- package/lib/src/api/api.js.map +1 -0
- package/lib/src/api/apiPaths.d.ts +37 -0
- package/lib/src/api/apiPaths.js +140 -0
- package/lib/src/api/apiPaths.js.map +1 -0
- package/lib/src/api/collections.d.ts +26 -0
- package/lib/src/api/collections.js +57 -0
- package/lib/src/api/collections.js.map +1 -0
- package/lib/src/api/events.d.ts +26 -0
- package/lib/src/api/events.js +42 -0
- package/lib/src/api/events.js.map +1 -0
- package/lib/src/api/fetcher.d.ts +24 -0
- package/lib/src/api/fetcher.js +3 -0
- package/lib/src/api/fetcher.js.map +1 -0
- package/lib/src/api/index.d.ts +2 -0
- package/lib/src/api/index.js +19 -0
- package/lib/src/api/index.js.map +1 -0
- package/lib/src/api/listings.d.ts +44 -0
- package/lib/src/api/listings.js +86 -0
- package/lib/src/api/listings.js.map +1 -0
- package/lib/src/api/nfts.d.ts +35 -0
- package/lib/src/api/nfts.js +66 -0
- package/lib/src/api/nfts.js.map +1 -0
- package/lib/src/api/offers.d.ts +54 -0
- package/lib/src/api/offers.js +122 -0
- package/lib/src/api/offers.js.map +1 -0
- package/lib/src/api/orders.d.ts +50 -0
- package/lib/src/api/orders.js +151 -0
- package/lib/src/api/orders.js.map +1 -0
- package/lib/src/api/search.d.ts +13 -0
- package/lib/src/api/search.js +21 -0
- package/lib/src/api/search.js.map +1 -0
- package/lib/src/api/tokens.d.ts +25 -0
- package/lib/src/api/tokens.js +42 -0
- package/lib/src/api/tokens.js.map +1 -0
- package/lib/src/api/types.d.ts +840 -0
- package/lib/src/api/types.js +65 -0
- package/lib/src/api/types.js.map +1 -0
- package/lib/src/constants.d.ts +22 -0
- package/lib/src/constants.js +52 -0
- package/lib/src/constants.js.map +1 -0
- package/lib/src/index.d.ts +18 -0
- package/lib/src/index.js +24 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/orders/privateListings.d.ts +12 -0
- package/lib/src/orders/privateListings.js +130 -0
- package/lib/src/orders/privateListings.js.map +1 -0
- package/lib/src/orders/types.d.ts +160 -0
- package/lib/src/orders/types.js +10 -0
- package/lib/src/orders/types.js.map +1 -0
- package/lib/src/orders/utils.d.ts +89 -0
- package/lib/src/orders/utils.js +177 -0
- package/lib/src/orders/utils.js.map +1 -0
- package/lib/src/sdk/assets.d.ts +104 -0
- package/lib/src/sdk/assets.js +397 -0
- package/lib/src/sdk/assets.js.map +1 -0
- package/lib/src/sdk/cancellation.d.ts +97 -0
- package/lib/src/sdk/cancellation.js +234 -0
- package/lib/src/sdk/cancellation.js.map +1 -0
- package/lib/src/sdk/context.d.ts +28 -0
- package/lib/src/sdk/context.js +3 -0
- package/lib/src/sdk/context.js.map +1 -0
- package/lib/src/sdk/fulfillment.d.ts +153 -0
- package/lib/src/sdk/fulfillment.js +296 -0
- package/lib/src/sdk/fulfillment.js.map +1 -0
- package/lib/src/sdk/orders.d.ts +253 -0
- package/lib/src/sdk/orders.js +677 -0
- package/lib/src/sdk/orders.js.map +1 -0
- package/lib/src/sdk/tokens.d.ts +31 -0
- package/lib/src/sdk/tokens.js +64 -0
- package/lib/src/sdk/tokens.js.map +1 -0
- package/lib/src/sdk.d.ts +560 -0
- package/lib/src/sdk.js +675 -0
- package/lib/src/sdk.js.map +1 -0
- package/lib/src/typechain/contracts/ERC1155.d.ts +236 -0
- package/lib/src/typechain/contracts/ERC1155.js +3 -0
- package/lib/src/typechain/contracts/ERC1155.js.map +1 -0
- package/lib/src/typechain/contracts/ERC20.d.ts +141 -0
- package/lib/src/typechain/contracts/ERC20.js +3 -0
- package/lib/src/typechain/contracts/ERC20.js.map +1 -0
- package/lib/src/typechain/contracts/ERC721.d.ts +213 -0
- package/lib/src/typechain/contracts/ERC721.js +3 -0
- package/lib/src/typechain/contracts/ERC721.js.map +1 -0
- package/lib/src/typechain/contracts/Multicall3.d.ts +57 -0
- package/lib/src/typechain/contracts/Multicall3.js +3 -0
- package/lib/src/typechain/contracts/Multicall3.js.map +1 -0
- package/lib/src/typechain/contracts/TransferHelper.d.ts +55 -0
- package/lib/src/typechain/contracts/TransferHelper.js +3 -0
- package/lib/src/typechain/contracts/TransferHelper.js.map +1 -0
- package/lib/src/typechain/contracts/common.d.ts +50 -0
- package/lib/src/typechain/contracts/common.js +3 -0
- package/lib/src/typechain/contracts/common.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js +332 -0
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.js +240 -0
- package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.js +351 -0
- package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js +68 -0
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +71 -0
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
- package/lib/src/typechain/contracts/factories/index.d.ts +5 -0
- package/lib/src/typechain/contracts/factories/index.js +17 -0
- package/lib/src/typechain/contracts/factories/index.js.map +1 -0
- package/lib/src/typechain/contracts/index.d.ts +11 -0
- package/lib/src/typechain/contracts/index.js +48 -0
- package/lib/src/typechain/contracts/index.js.map +1 -0
- package/lib/src/types.d.ts +387 -0
- package/lib/src/types.js +127 -0
- package/lib/src/types.js.map +1 -0
- package/lib/src/utils/chain.d.ts +60 -0
- package/lib/src/utils/chain.js +248 -0
- package/lib/src/utils/chain.js.map +1 -0
- package/lib/src/utils/converters.d.ts +37 -0
- package/lib/src/utils/converters.js +137 -0
- package/lib/src/utils/converters.js.map +1 -0
- package/lib/src/utils/dateHelper.d.ts +38 -0
- package/lib/src/utils/dateHelper.js +52 -0
- package/lib/src/utils/dateHelper.js.map +1 -0
- package/lib/src/utils/fees.d.ts +13 -0
- package/lib/src/utils/fees.js +29 -0
- package/lib/src/utils/fees.js.map +1 -0
- package/lib/src/utils/index.d.ts +2 -0
- package/lib/src/utils/index.js +19 -0
- package/lib/src/utils/index.js.map +1 -0
- package/lib/src/utils/protocol.d.ts +75 -0
- package/lib/src/utils/protocol.js +161 -0
- package/lib/src/utils/protocol.js.map +1 -0
- package/lib/src/utils/rateLimit.d.ts +34 -0
- package/lib/src/utils/rateLimit.js +97 -0
- package/lib/src/utils/rateLimit.js.map +1 -0
- package/lib/src/utils/stringHelper.d.ts +18 -0
- package/lib/src/utils/stringHelper.js +24 -0
- package/lib/src/utils/stringHelper.js.map +1 -0
- package/lib/src/utils/utils.d.ts +18 -0
- package/lib/src/utils/utils.js +45 -0
- package/lib/src/utils/utils.js.map +1 -0
- package/lib/typechain/contracts/ERC1155.d.ts +236 -0
- package/lib/typechain/contracts/ERC1155.js +3 -0
- package/lib/typechain/contracts/ERC1155.js.map +1 -0
- package/lib/typechain/contracts/ERC20.d.ts +141 -0
- package/lib/typechain/contracts/ERC20.js +3 -0
- package/lib/typechain/contracts/ERC20.js.map +1 -0
- package/lib/typechain/contracts/ERC721.d.ts +213 -0
- package/lib/typechain/contracts/ERC721.js +3 -0
- package/lib/typechain/contracts/ERC721.js.map +1 -0
- package/lib/typechain/contracts/Multicall3.d.ts +57 -0
- package/lib/typechain/contracts/Multicall3.js +3 -0
- package/lib/typechain/contracts/Multicall3.js.map +1 -0
- package/lib/typechain/contracts/TransferHelper.d.ts +55 -0
- package/lib/typechain/contracts/TransferHelper.js +3 -0
- package/lib/typechain/contracts/TransferHelper.js.map +1 -0
- package/lib/typechain/contracts/common.d.ts +50 -0
- package/lib/typechain/contracts/common.js +3 -0
- package/lib/typechain/contracts/common.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +250 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.js +332 -0
- package/lib/typechain/contracts/factories/ERC1155__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC20__factory.d.ts +174 -0
- package/lib/typechain/contracts/factories/ERC20__factory.js +240 -0
- package/lib/typechain/contracts/factories/ERC20__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/ERC721__factory.d.ts +268 -0
- package/lib/typechain/contracts/factories/ERC721__factory.js +351 -0
- package/lib/typechain/contracts/factories/ERC721__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +43 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.js +68 -0
- package/lib/typechain/contracts/factories/Multicall3__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +46 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.js +71 -0
- package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +1 -0
- package/lib/typechain/contracts/factories/index.d.ts +5 -0
- package/lib/typechain/contracts/factories/index.js +17 -0
- package/lib/typechain/contracts/factories/index.js.map +1 -0
- package/lib/typechain/contracts/index.d.ts +11 -0
- package/lib/typechain/contracts/index.js +48 -0
- package/lib/typechain/contracts/index.js.map +1 -0
- package/lib/types.d.ts +389 -0
- package/lib/types.js +129 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/chain.d.ts +64 -0
- package/lib/utils/chain.js +211 -0
- package/lib/utils/chain.js.map +1 -0
- package/lib/utils/chainIds.generated.d.ts +7 -0
- package/lib/utils/chainIds.generated.js +37 -0
- package/lib/utils/chainIds.generated.js.map +1 -0
- package/lib/utils/converters.d.ts +37 -0
- package/lib/utils/converters.js +137 -0
- package/lib/utils/converters.js.map +1 -0
- package/lib/utils/dateHelper.d.ts +38 -0
- package/lib/utils/dateHelper.js +52 -0
- package/lib/utils/dateHelper.js.map +1 -0
- package/lib/utils/fees.d.ts +13 -0
- package/lib/utils/fees.js +29 -0
- package/lib/utils/fees.js.map +1 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +19 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/protocol.d.ts +75 -0
- package/lib/utils/protocol.js +161 -0
- package/lib/utils/protocol.js.map +1 -0
- package/lib/utils/rateLimit.d.ts +34 -0
- package/lib/utils/rateLimit.js +97 -0
- package/lib/utils/rateLimit.js.map +1 -0
- package/lib/utils/stringHelper.d.ts +18 -0
- package/lib/utils/stringHelper.js +24 -0
- package/lib/utils/stringHelper.js.map +1 -0
- package/lib/utils/utils.d.ts +18 -0
- package/lib/utils/utils.js +45 -0
- package/lib/utils/utils.js.map +1 -0
- package/package.json +72 -0
- package/src/abi/ERC1155.json +314 -0
- package/src/abi/ERC20.json +222 -0
- package/src/abi/ERC721.json +333 -0
- package/src/abi/Multicall3.json +50 -0
- package/src/abi/TransferHelper.json +53 -0
- package/src/api/accounts.ts +69 -0
- package/src/api/api.ts +1152 -0
- package/src/api/apiPaths.ts +208 -0
- package/src/api/chains.ts +18 -0
- package/src/api/collections.ts +120 -0
- package/src/api/drops.ts +49 -0
- package/src/api/events.ts +71 -0
- package/src/api/fetcher.ts +31 -0
- package/src/api/index.ts +2 -0
- package/src/api/listings.ts +126 -0
- package/src/api/nfts.ts +144 -0
- package/src/api/offers.ts +242 -0
- package/src/api/orders.ts +283 -0
- package/src/api/search.ts +21 -0
- package/src/api/tokens.ts +67 -0
- package/src/api/types.ts +1210 -0
- package/src/constants.ts +90 -0
- package/src/index.ts +22 -0
- package/src/orders/privateListings.ts +173 -0
- package/src/orders/types.ts +191 -0
- package/src/orders/utils.ts +253 -0
- package/src/sdk/assets.ts +591 -0
- package/src/sdk/cancellation.ts +346 -0
- package/src/sdk/context.ts +33 -0
- package/src/sdk/fulfillment.ts +478 -0
- package/src/sdk/orders.ts +1149 -0
- package/src/sdk/tokens.ts +95 -0
- package/src/sdk.ts +1051 -0
- package/src/typechain/contracts/ERC1155.ts +440 -0
- package/src/typechain/contracts/ERC20.ts +286 -0
- package/src/typechain/contracts/ERC721.ts +412 -0
- package/src/typechain/contracts/Multicall3.ts +117 -0
- package/src/typechain/contracts/TransferHelper.ts +122 -0
- package/src/typechain/contracts/common.ts +131 -0
- package/src/typechain/contracts/factories/ERC1155__factory.ts +331 -0
- package/src/typechain/contracts/factories/ERC20__factory.ts +239 -0
- package/src/typechain/contracts/factories/ERC721__factory.ts +350 -0
- package/src/typechain/contracts/factories/Multicall3__factory.ts +67 -0
- package/src/typechain/contracts/factories/TransferHelper__factory.ts +76 -0
- package/src/typechain/contracts/factories/index.ts +8 -0
- package/src/typechain/contracts/index.ts +14 -0
- package/src/types.ts +413 -0
- package/src/utils/chain.ts +224 -0
- package/src/utils/chainIds.generated.ts +34 -0
- package/src/utils/converters.ts +145 -0
- package/src/utils/dateHelper.ts +48 -0
- package/src/utils/fees.ts +31 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/protocol.ts +185 -0
- package/src/utils/rateLimit.ts +147 -0
- package/src/utils/stringHelper.ts +25 -0
- package/src/utils/utils.ts +36 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssetsManager = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const contracts_1 = require("../typechain/contracts");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const utils_1 = require("../utils/utils");
|
|
9
|
+
/**
|
|
10
|
+
* Asset transfer and approval operations
|
|
11
|
+
*/
|
|
12
|
+
class AssetsManager {
|
|
13
|
+
context;
|
|
14
|
+
constructor(context) {
|
|
15
|
+
this.context = context;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get an account's balance of any Asset. This asset can be an ERC20, ERC1155, or ERC721.
|
|
19
|
+
* @param options
|
|
20
|
+
* @param options.accountAddress Account address to check
|
|
21
|
+
* @param options.asset The Asset to check balance for. tokenStandard must be set.
|
|
22
|
+
* @returns The balance of the asset for the account.
|
|
23
|
+
*
|
|
24
|
+
* @throws Error if the token standard does not support balanceOf.
|
|
25
|
+
*/
|
|
26
|
+
async getBalance({ accountAddress, asset, }) {
|
|
27
|
+
switch (asset.tokenStandard) {
|
|
28
|
+
case types_1.TokenStandard.ERC20: {
|
|
29
|
+
const contract = contracts_1.ERC20__factory.connect(asset.tokenAddress, this.context.provider);
|
|
30
|
+
return await contract.balanceOf.staticCall(accountAddress);
|
|
31
|
+
}
|
|
32
|
+
case types_1.TokenStandard.ERC1155: {
|
|
33
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
34
|
+
throw new Error("Missing ERC1155 tokenId for getBalance");
|
|
35
|
+
}
|
|
36
|
+
const contract = contracts_1.ERC1155__factory.connect(asset.tokenAddress, this.context.provider);
|
|
37
|
+
return await contract.balanceOf.staticCall(accountAddress, asset.tokenId);
|
|
38
|
+
}
|
|
39
|
+
case types_1.TokenStandard.ERC721: {
|
|
40
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
41
|
+
throw new Error("Missing ERC721 tokenId for getBalance");
|
|
42
|
+
}
|
|
43
|
+
const contract = contracts_1.ERC721__factory.connect(asset.tokenAddress, this.context.provider);
|
|
44
|
+
try {
|
|
45
|
+
const owner = await contract.ownerOf.staticCall(asset.tokenId);
|
|
46
|
+
return BigInt(owner.toLowerCase() === accountAddress.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.context.logger(`Failed to get ownerOf ERC721: ${error.message ?? error}`);
|
|
50
|
+
return 0n;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
default:
|
|
54
|
+
throw new Error("Unsupported token standard for getBalance");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Transfer an asset. This asset can be an ERC20, ERC1155, or ERC721.
|
|
59
|
+
* @param options
|
|
60
|
+
* @param options.asset The Asset to transfer. tokenStandard must be set.
|
|
61
|
+
* @param options.amount Amount of asset to transfer. Not used for ERC721.
|
|
62
|
+
* @param options.fromAddress The address to transfer from
|
|
63
|
+
* @param options.toAddress The address to transfer to
|
|
64
|
+
* @param options.overrides Transaction overrides, ignored if not set.
|
|
65
|
+
*/
|
|
66
|
+
async transfer({ asset, amount, fromAddress, toAddress, overrides, }) {
|
|
67
|
+
overrides = { ...overrides, from: fromAddress };
|
|
68
|
+
let transaction;
|
|
69
|
+
switch (asset.tokenStandard) {
|
|
70
|
+
case types_1.TokenStandard.ERC20: {
|
|
71
|
+
if (!amount) {
|
|
72
|
+
throw new Error("Missing ERC20 amount for transfer");
|
|
73
|
+
}
|
|
74
|
+
const contract = contracts_1.ERC20__factory.connect(asset.tokenAddress, this.context.signerOrProvider);
|
|
75
|
+
transaction = contract.transfer(toAddress, amount, overrides);
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case types_1.TokenStandard.ERC1155: {
|
|
79
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
80
|
+
throw new Error("Missing ERC1155 tokenId for transfer");
|
|
81
|
+
}
|
|
82
|
+
if (!amount) {
|
|
83
|
+
throw new Error("Missing ERC1155 amount for transfer");
|
|
84
|
+
}
|
|
85
|
+
const contract = contracts_1.ERC1155__factory.connect(asset.tokenAddress, this.context.signerOrProvider);
|
|
86
|
+
transaction = contract.safeTransferFrom(fromAddress, toAddress, asset.tokenId, amount, "0x", overrides);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case types_1.TokenStandard.ERC721: {
|
|
90
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
91
|
+
throw new Error("Missing ERC721 tokenId for transfer");
|
|
92
|
+
}
|
|
93
|
+
const contract = contracts_1.ERC721__factory.connect(asset.tokenAddress, this.context.signerOrProvider);
|
|
94
|
+
transaction = contract.transferFrom(fromAddress, toAddress, asset.tokenId, overrides);
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
default:
|
|
98
|
+
throw new Error("Unsupported token standard for transfer");
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const transactionResponse = await transaction;
|
|
102
|
+
await this.context.confirmTransaction(transactionResponse.hash, types_1.EventType.Transfer, "Transferring asset");
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
console.error(error);
|
|
106
|
+
this.context.dispatch(types_1.EventType.TransactionDenied, {
|
|
107
|
+
error,
|
|
108
|
+
accountAddress: fromAddress,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Bulk transfer multiple assets using OpenSea's TransferHelper contract.
|
|
114
|
+
* This method is more gas-efficient than calling transfer() multiple times.
|
|
115
|
+
* Note: All assets must be approved for transfer to the OpenSea conduit before calling this method.
|
|
116
|
+
* @param options
|
|
117
|
+
* @param options.assets Array of assets to transfer. Each asset must have tokenStandard set.
|
|
118
|
+
* @param options.fromAddress The address to transfer from
|
|
119
|
+
* @param options.overrides Transaction overrides, ignored if not set.
|
|
120
|
+
* @returns Transaction hash of the bulk transfer
|
|
121
|
+
*
|
|
122
|
+
* @throws Error if any asset is missing required fields (tokenId for NFTs, amount for ERC20/ERC1155).
|
|
123
|
+
* @throws Error if any asset is not approved for transfer to the OpenSea conduit.
|
|
124
|
+
* @throws Error if the fromAddress is not available through wallet or provider.
|
|
125
|
+
*/
|
|
126
|
+
async bulkTransfer({ assets, fromAddress, overrides, }) {
|
|
127
|
+
// Validate basic parameters before making any blockchain calls
|
|
128
|
+
if (assets.length === 0) {
|
|
129
|
+
throw new Error("At least one asset must be provided");
|
|
130
|
+
}
|
|
131
|
+
// Validate asset data and build transfer items array for TransferHelper
|
|
132
|
+
// This validation happens before any blockchain calls to ensure proper error messages
|
|
133
|
+
const transferItems = [];
|
|
134
|
+
for (const { asset, toAddress, amount } of assets) {
|
|
135
|
+
let itemType;
|
|
136
|
+
let identifier;
|
|
137
|
+
let transferAmount;
|
|
138
|
+
switch (asset.tokenStandard) {
|
|
139
|
+
case types_1.TokenStandard.ERC20:
|
|
140
|
+
itemType = 1; // ERC20
|
|
141
|
+
identifier = "0";
|
|
142
|
+
if (!amount) {
|
|
143
|
+
throw new Error("Missing ERC20 amount for bulk transfer");
|
|
144
|
+
}
|
|
145
|
+
transferAmount = amount.toString();
|
|
146
|
+
break;
|
|
147
|
+
case types_1.TokenStandard.ERC721:
|
|
148
|
+
itemType = 2; // ERC721
|
|
149
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
150
|
+
throw new Error("Missing ERC721 tokenId for bulk transfer");
|
|
151
|
+
}
|
|
152
|
+
identifier = asset.tokenId.toString();
|
|
153
|
+
transferAmount = "1";
|
|
154
|
+
break;
|
|
155
|
+
case types_1.TokenStandard.ERC1155:
|
|
156
|
+
itemType = 3; // ERC1155
|
|
157
|
+
if (asset.tokenId === undefined || asset.tokenId === null) {
|
|
158
|
+
throw new Error("Missing ERC1155 tokenId for bulk transfer");
|
|
159
|
+
}
|
|
160
|
+
if (!amount) {
|
|
161
|
+
throw new Error("Missing ERC1155 amount for bulk transfer");
|
|
162
|
+
}
|
|
163
|
+
identifier = asset.tokenId.toString();
|
|
164
|
+
transferAmount = amount.toString();
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new Error(`Unsupported token standard for bulk transfer: ${asset.tokenStandard}`);
|
|
168
|
+
}
|
|
169
|
+
transferItems.push({
|
|
170
|
+
itemType,
|
|
171
|
+
token: asset.tokenAddress,
|
|
172
|
+
identifier,
|
|
173
|
+
amount: transferAmount,
|
|
174
|
+
recipient: toAddress,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// Check account availability after parameter validation
|
|
178
|
+
await this.context.requireAccountIsAvailable(fromAddress);
|
|
179
|
+
// Get the chain-specific default conduit
|
|
180
|
+
const defaultConduit = (0, utils_1.getDefaultConduit)(this.context.chain);
|
|
181
|
+
// Check approvals for all assets before attempting transfer
|
|
182
|
+
const unapprovedAssets = [];
|
|
183
|
+
for (const { asset, amount } of assets) {
|
|
184
|
+
const isApproved = await this.checkAssetApproval(asset, fromAddress, defaultConduit.address, amount);
|
|
185
|
+
if (!isApproved) {
|
|
186
|
+
const assetIdentifier = asset.tokenId !== undefined
|
|
187
|
+
? `${asset.tokenAddress}:${asset.tokenId}`
|
|
188
|
+
: asset.tokenAddress;
|
|
189
|
+
unapprovedAssets.push(assetIdentifier);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (unapprovedAssets.length > 0) {
|
|
193
|
+
throw new Error(`The following asset(s) are not approved for transfer to the OpenSea conduit:\n${unapprovedAssets.join("\n")}\n\n` +
|
|
194
|
+
`Please approve these assets before transferring. You can use the batchApproveAssets() method to approve multiple assets efficiently in a single transaction.`);
|
|
195
|
+
}
|
|
196
|
+
// Create TransferHelper contract instance
|
|
197
|
+
const transferHelper = this.getTransferHelperContract();
|
|
198
|
+
this.context.dispatch(types_1.EventType.Transfer, {
|
|
199
|
+
accountAddress: fromAddress,
|
|
200
|
+
assets,
|
|
201
|
+
});
|
|
202
|
+
try {
|
|
203
|
+
// Use chain-specific conduit key for bulk transfers
|
|
204
|
+
const transaction = await transferHelper.bulkTransfer(transferItems, defaultConduit.key, { ...overrides, from: fromAddress });
|
|
205
|
+
await this.context.confirmTransaction(transaction.hash, types_1.EventType.Transfer, `Bulk transferring ${assets.length} asset(s)`);
|
|
206
|
+
return transaction.hash;
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
console.error(error);
|
|
210
|
+
this.context.dispatch(types_1.EventType.TransactionDenied, {
|
|
211
|
+
error,
|
|
212
|
+
accountAddress: fromAddress,
|
|
213
|
+
});
|
|
214
|
+
throw error;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Batch approve multiple assets for transfer to the OpenSea conduit.
|
|
219
|
+
* This method checks which assets need approval and batches them efficiently:
|
|
220
|
+
* - 0 approvals needed: Returns early
|
|
221
|
+
* - 1 approval needed: Sends single transaction
|
|
222
|
+
* - 2+ approvals needed: Uses Multicall3 to batch all approvals in one transaction
|
|
223
|
+
*
|
|
224
|
+
* @param options
|
|
225
|
+
* @param options.assets Array of assets to approve for transfer
|
|
226
|
+
* @param options.fromAddress The address that owns the assets
|
|
227
|
+
* @param options.overrides Transaction overrides, ignored if not set.
|
|
228
|
+
* @returns Transaction hash of the approval transaction, or undefined if no approvals needed
|
|
229
|
+
*
|
|
230
|
+
* @throws Error if the fromAddress is not available through wallet or provider.
|
|
231
|
+
*/
|
|
232
|
+
async batchApproveAssets({ assets, fromAddress, overrides, }) {
|
|
233
|
+
// Validate basic parameters before making any blockchain calls
|
|
234
|
+
if (assets.length === 0) {
|
|
235
|
+
return undefined;
|
|
236
|
+
}
|
|
237
|
+
// Validate ERC20 assets have amounts before making any blockchain calls
|
|
238
|
+
for (const { asset, amount } of assets) {
|
|
239
|
+
if (asset.tokenStandard === types_1.TokenStandard.ERC20 && !amount) {
|
|
240
|
+
throw new Error(`Amount required for ERC20 approval: ${asset.tokenAddress}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// Check account availability after parameter validation
|
|
244
|
+
await this.context.requireAccountIsAvailable(fromAddress);
|
|
245
|
+
// Get the chain-specific default conduit
|
|
246
|
+
const defaultConduit = (0, utils_1.getDefaultConduit)(this.context.chain);
|
|
247
|
+
// Check which assets need approval and build approval calldata
|
|
248
|
+
const approvalsNeeded = [];
|
|
249
|
+
const processedContracts = new Set();
|
|
250
|
+
for (const { asset, amount } of assets) {
|
|
251
|
+
const isApproved = await this.checkAssetApproval(asset, fromAddress, defaultConduit.address, amount);
|
|
252
|
+
if (!isApproved) {
|
|
253
|
+
// For ERC721/ERC1155, only approve once per contract
|
|
254
|
+
if (asset.tokenStandard === types_1.TokenStandard.ERC721 ||
|
|
255
|
+
asset.tokenStandard === types_1.TokenStandard.ERC1155) {
|
|
256
|
+
if (processedContracts.has(asset.tokenAddress.toLowerCase())) {
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
processedContracts.add(asset.tokenAddress.toLowerCase());
|
|
260
|
+
// setApprovalForAll(operator, true)
|
|
261
|
+
const iface = new ethers_1.ethers.Interface([
|
|
262
|
+
"function setApprovalForAll(address operator, bool approved)",
|
|
263
|
+
]);
|
|
264
|
+
const callData = iface.encodeFunctionData("setApprovalForAll", [
|
|
265
|
+
defaultConduit.address,
|
|
266
|
+
true,
|
|
267
|
+
]);
|
|
268
|
+
approvalsNeeded.push({
|
|
269
|
+
target: asset.tokenAddress,
|
|
270
|
+
callData,
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
else if (asset.tokenStandard === types_1.TokenStandard.ERC20) {
|
|
274
|
+
// approve(spender, amount) - use max uint256 for unlimited
|
|
275
|
+
const iface = new ethers_1.ethers.Interface([
|
|
276
|
+
"function approve(address spender, uint256 amount) returns (bool)",
|
|
277
|
+
]);
|
|
278
|
+
const callData = iface.encodeFunctionData("approve", [
|
|
279
|
+
defaultConduit.address,
|
|
280
|
+
ethers_1.ethers.MaxUint256, // Approve max for convenience
|
|
281
|
+
]);
|
|
282
|
+
approvalsNeeded.push({
|
|
283
|
+
target: asset.tokenAddress,
|
|
284
|
+
callData,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// No approvals needed
|
|
290
|
+
if (approvalsNeeded.length === 0) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
// Single approval: send directly
|
|
294
|
+
if (approvalsNeeded.length === 1) {
|
|
295
|
+
const { target, callData } = approvalsNeeded[0];
|
|
296
|
+
const signer = this.context.signerOrProvider;
|
|
297
|
+
const tx = await signer.sendTransaction({
|
|
298
|
+
to: target,
|
|
299
|
+
data: callData,
|
|
300
|
+
...overrides,
|
|
301
|
+
from: fromAddress,
|
|
302
|
+
});
|
|
303
|
+
await this.context.confirmTransaction(tx.hash, types_1.EventType.ApproveAllAssets, "Approving asset for transfer");
|
|
304
|
+
return tx.hash;
|
|
305
|
+
}
|
|
306
|
+
// Multiple approvals: use Multicall3
|
|
307
|
+
const multicall3 = this.getMulticall3Contract();
|
|
308
|
+
const calls = approvalsNeeded.map(({ target, callData }) => ({
|
|
309
|
+
target,
|
|
310
|
+
allowFailure: false,
|
|
311
|
+
callData,
|
|
312
|
+
}));
|
|
313
|
+
try {
|
|
314
|
+
const transaction = await multicall3.aggregate3(calls, {
|
|
315
|
+
...overrides,
|
|
316
|
+
from: fromAddress,
|
|
317
|
+
});
|
|
318
|
+
await this.context.confirmTransaction(transaction.hash, types_1.EventType.ApproveAllAssets, `Batch approving ${approvalsNeeded.length} asset(s) for transfer`);
|
|
319
|
+
return transaction.hash;
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
console.error(error);
|
|
323
|
+
this.context.dispatch(types_1.EventType.TransactionDenied, {
|
|
324
|
+
error,
|
|
325
|
+
accountAddress: fromAddress,
|
|
326
|
+
});
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Check if an asset is approved for transfer to a specific operator (conduit).
|
|
332
|
+
* @param asset The asset to check approval for
|
|
333
|
+
* @param owner The owner address
|
|
334
|
+
* @param operator The operator address (conduit)
|
|
335
|
+
* @param amount Optional amount for ERC20 tokens
|
|
336
|
+
* @returns True if approved, false otherwise
|
|
337
|
+
*/
|
|
338
|
+
async checkAssetApproval(asset, owner, operator, amount) {
|
|
339
|
+
try {
|
|
340
|
+
switch (asset.tokenStandard) {
|
|
341
|
+
case types_1.TokenStandard.ERC20: {
|
|
342
|
+
const contract = contracts_1.ERC20__factory.connect(asset.tokenAddress, this.context.provider);
|
|
343
|
+
const allowance = await contract.allowance.staticCall(owner, operator);
|
|
344
|
+
// Check if allowance is sufficient
|
|
345
|
+
if (!amount) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
return allowance >= BigInt(amount.toString());
|
|
349
|
+
}
|
|
350
|
+
case types_1.TokenStandard.ERC721: {
|
|
351
|
+
const contract = contracts_1.ERC721__factory.connect(asset.tokenAddress, this.context.provider);
|
|
352
|
+
// Check isApprovedForAll first
|
|
353
|
+
const isApprovedForAll = await contract.isApprovedForAll.staticCall(owner, operator);
|
|
354
|
+
if (isApprovedForAll) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
357
|
+
// Check individual token approval
|
|
358
|
+
if (asset.tokenId !== undefined && asset.tokenId !== null) {
|
|
359
|
+
const approved = await contract.getApproved.staticCall(asset.tokenId);
|
|
360
|
+
return approved.toLowerCase() === operator.toLowerCase();
|
|
361
|
+
}
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
case types_1.TokenStandard.ERC1155: {
|
|
365
|
+
const contract = contracts_1.ERC1155__factory.connect(asset.tokenAddress, this.context.provider);
|
|
366
|
+
return await contract.isApprovedForAll.staticCall(owner, operator);
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
// If there's an error checking approval (e.g., contract doesn't exist), return false
|
|
374
|
+
this.context.logger(`Error checking approval for ${asset.tokenAddress}: ${error}`);
|
|
375
|
+
return false;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Get a TransferHelper contract instance.
|
|
380
|
+
* @returns Contract instance for TransferHelper
|
|
381
|
+
*/
|
|
382
|
+
getTransferHelperContract() {
|
|
383
|
+
return new ethers_1.Contract(constants_1.TRANSFER_HELPER_ADDRESS, [
|
|
384
|
+
"function bulkTransfer(tuple(uint8 itemType, address token, uint256 identifier, uint256 amount, address recipient)[] items, bytes32 conduitKey) external returns (bytes4)",
|
|
385
|
+
], this.context.signerOrProvider);
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Get a Multicall3 contract instance.
|
|
389
|
+
* @returns Contract instance for Multicall3
|
|
390
|
+
*/
|
|
391
|
+
getMulticall3Contract() {
|
|
392
|
+
return new ethers_1.Contract(constants_1.MULTICALL3_ADDRESS, [
|
|
393
|
+
"function aggregate3(tuple(address target, bool allowFailure, bytes callData)[] calls) payable returns (tuple(bool success, bytes returnData)[] returnData)",
|
|
394
|
+
], this.context.signerOrProvider);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
exports.AssetsManager = AssetsManager;
|
|
398
|
+
//# sourceMappingURL=assets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.js","sourceRoot":"","sources":["../../src/sdk/assets.ts"],"names":[],"mappings":";;;AAAA,mCAOe;AACf,4CAA0E;AAC1E,sDAI+B;AAC/B,oCAAgF;AAChF,0CAAkD;AAGlD;;GAEG;AACH,MAAa,aAAa;IACJ;IAApB,YAAoB,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAE3C;;;;;;;;OAQG;IACH,KAAK,CAAC,UAAU,CAAC,EACf,cAAc,EACd,KAAK,GAIN;QACC,QAAQ,KAAK,CAAC,aAAa,EAAE,CAAC;YAC5B,KAAK,qBAAa,CAAC,KAAK,CAAC,CAAC,CAAC;gBACzB,MAAM,QAAQ,GAAG,0BAAc,CAAC,OAAO,CACrC,KAAK,CAAC,YAAY,EAClB,IAAI,CAAC,OAAO,CAAC,QAAQ,CACtB,CAAA;gBACD,OAAO,MAAM,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;YAC5D,CAAC;YACD,KAAK,qBAAa,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC3B,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;oBAC1D,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;gBAC3D,CAAC;gBACD,MAAM,QAAQ,GAAG,4BAAgB,CAAC,OAAO,CACvC,KAAK,CAAC,YAAY,EAClB,IAAI,CAAC,OAAO,CAAC,QAAQ,CACtB,CAAA;gBACD,OAAO,MAAM,QAAQ,CAAC,SAAS,CAAC,UAAU,CACxC,cAAc,EACd,KAAK,CAAC,OAAO,CACd,CAAA;YACH,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|
1
|
+
import type { OrderComponents } from "@opensea/seaport-js/lib/types";
|
|
2
|
+
import type { Overrides } from "ethers";
|
|
3
|
+
import type { OrderV2 } from "../orders/types";
|
|
4
|
+
import { type Chain } from "../types";
|
|
5
|
+
import type { SDKContext } from "./context";
|
|
6
|
+
/**
|
|
7
|
+
* Order cancellation operations
|
|
8
|
+
*/
|
|
9
|
+
export declare class CancellationManager {
|
|
10
|
+
private context;
|
|
11
|
+
constructor(context: SDKContext);
|
|
12
|
+
/**
|
|
13
|
+
* Cancel an order onchain, preventing it from ever being fulfilled.
|
|
14
|
+
* This method accepts either a full OrderV2 object or an order hash with protocol address.
|
|
15
|
+
*
|
|
16
|
+
* @param options
|
|
17
|
+
* @param options.order The order to cancel (OrderV2 object)
|
|
18
|
+
* @param options.orderHash Optional order hash to cancel. Must provide protocolAddress if using this.
|
|
19
|
+
* @param options.accountAddress The account address that will be cancelling the order.
|
|
20
|
+
* @param options.protocolAddress Required when using orderHash. The Seaport protocol address for the order.
|
|
21
|
+
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata. This can be used for onchain order attribution to assist with analytics.
|
|
22
|
+
*
|
|
23
|
+
* @throws Error if neither order nor orderHash is provided.
|
|
24
|
+
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
25
|
+
* @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
|
|
26
|
+
*/
|
|
27
|
+
cancelOrder({ order, orderHash, accountAddress, protocolAddress, domain, }: {
|
|
28
|
+
order?: OrderV2;
|
|
29
|
+
orderHash?: string;
|
|
30
|
+
accountAddress: string;
|
|
31
|
+
protocolAddress?: string;
|
|
32
|
+
domain?: string;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Cancel multiple orders onchain, preventing them from being fulfilled.
|
|
36
|
+
* This method accepts either full OrderV2 objects, OrderComponents, or order hashes with protocol address.
|
|
37
|
+
*
|
|
38
|
+
* **Event Behavior**: For backwards compatibility with the singular `cancelOrder` method,
|
|
39
|
+
* this method dispatches a `CancelOrder` event for the first order only, and only when
|
|
40
|
+
* an OrderV2 object is available (either provided directly or fetched via orderHashes).
|
|
41
|
+
* No event is dispatched when using OrderComponents directly, as they lack the full order data.
|
|
42
|
+
*
|
|
43
|
+
* @param options
|
|
44
|
+
* @param options.orders Array of orders to cancel. Can be OrderV2 objects or OrderComponents.
|
|
45
|
+
* @param options.orderHashes Optional array of order hashes to cancel. Must provide protocolAddress if using this.
|
|
46
|
+
* @param options.accountAddress The account address cancelling the orders.
|
|
47
|
+
* @param options.protocolAddress Required when using orderHashes. The Seaport protocol address for the orders.
|
|
48
|
+
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
|
|
49
|
+
* @param options.overrides Transaction overrides, ignored if not set.
|
|
50
|
+
* @returns Transaction hash of the cancellation.
|
|
51
|
+
*
|
|
52
|
+
* @throws Error if orderHashes is provided without protocolAddress.
|
|
53
|
+
* @throws Error if neither orders nor orderHashes is provided.
|
|
54
|
+
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
55
|
+
* @throws Error if the order's protocol address is not supported by OpenSea. See {@link isValidProtocol}.
|
|
56
|
+
*/
|
|
57
|
+
cancelOrders({ orders, orderHashes, accountAddress, protocolAddress, domain, overrides, }: {
|
|
58
|
+
orders?: Array<OrderV2 | OrderComponents>;
|
|
59
|
+
orderHashes?: string[];
|
|
60
|
+
accountAddress: string;
|
|
61
|
+
protocolAddress?: string;
|
|
62
|
+
domain?: string;
|
|
63
|
+
overrides?: Overrides;
|
|
64
|
+
}): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Cancel orders onchain, preventing them from being fulfilled.
|
|
67
|
+
* @param options
|
|
68
|
+
* @param options.orders The orders to cancel
|
|
69
|
+
* @param options.accountAddress The account address cancelling the orders.
|
|
70
|
+
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
|
|
71
|
+
* This can be used for onchain order attribution to assist with analytics.
|
|
72
|
+
* @param options.overrides Transaction overrides, ignored if not set.
|
|
73
|
+
* @returns Transaction hash of the order.
|
|
74
|
+
*/
|
|
75
|
+
private cancelSeaportOrders;
|
|
76
|
+
/**
|
|
77
|
+
* Get the offerer signature for canceling an order offchain.
|
|
78
|
+
* The signature will only be valid if the signer address is the address of the order's offerer.
|
|
79
|
+
*/
|
|
80
|
+
getOffererSignature(protocolAddress: string, orderHash: string, chain: Chain): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
|
|
83
|
+
* Protocol and Chain are required to prevent hash collisions.
|
|
84
|
+
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation.
|
|
85
|
+
* @param protocolAddress The Seaport address for the order.
|
|
86
|
+
* @param orderHash The order hash, or external identifier, of the order.
|
|
87
|
+
* @param chain The chain where the order is located.
|
|
88
|
+
* @param offererSignature An EIP-712 signature from the offerer of the order.
|
|
89
|
+
* If this is not provided, the API key used to initialize the SDK must belong to the order's offerer.
|
|
90
|
+
* The signature must be a EIP-712 signature consisting of the order's Seaport contract's
|
|
91
|
+
* name, version, address, and chain. The struct to sign is `OrderHash` containing a
|
|
92
|
+
* single bytes32 field.
|
|
93
|
+
* @param useSignerToDeriveOffererSignature Derive the offererSignature from the Ethers signer passed into this sdk.
|
|
94
|
+
* @returns The response from the API.
|
|
95
|
+
*/
|
|
96
|
+
offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain, offererSignature?: string, useSignerToDeriveOffererSignature?: boolean): Promise<import("../api/types").CancelOrderResponse>;
|
|
97
|
+
}
|