@opensea/sdk 9.0.0 → 10.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/README.md +25 -4
- package/lib/abi/abis.d.ts +301 -0
- package/lib/abi/abis.js +231 -0
- package/lib/abi/abis.js.map +1 -0
- package/lib/api/api.d.ts +6 -1
- package/lib/api/api.js +60 -51
- package/lib/api/api.js.map +1 -1
- package/lib/api/orders.js +2 -2
- package/lib/api/orders.js.map +1 -1
- package/lib/constants.d.ts +2 -2
- package/lib/constants.js +7 -4
- package/lib/constants.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/orders/privateListings.js +2 -2
- package/lib/orders/privateListings.js.map +1 -1
- package/lib/orders/utils.js +9 -1
- package/lib/orders/utils.js.map +1 -1
- package/lib/provider/ethers-adapter.d.ts +17 -0
- package/lib/provider/ethers-adapter.js +135 -0
- package/lib/provider/ethers-adapter.js.map +1 -0
- package/lib/provider/seaport-bridge.d.ts +11 -0
- package/lib/provider/seaport-bridge.js +130 -0
- package/lib/provider/seaport-bridge.js.map +1 -0
- package/lib/provider/types.d.ts +62 -0
- package/lib/provider/types.js +7 -0
- package/lib/provider/types.js.map +1 -0
- package/lib/provider/viem-adapter.d.ts +27 -0
- package/lib/provider/viem-adapter.js +122 -0
- package/lib/provider/viem-adapter.js.map +1 -0
- package/lib/sdk/assets.d.ts +7 -23
- package/lib/sdk/assets.js +101 -77
- package/lib/sdk/assets.js.map +1 -1
- package/lib/sdk/base.d.ts +334 -0
- package/lib/sdk/base.js +312 -0
- package/lib/sdk/base.js.map +1 -0
- package/lib/sdk/cancellation.d.ts +1 -2
- package/lib/sdk/cancellation.js +4 -4
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/context.d.ts +5 -5
- package/lib/sdk/fulfillment.d.ts +13 -58
- package/lib/sdk/fulfillment.js +16 -58
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.d.ts +25 -26
- package/lib/sdk/orders.js +8 -9
- package/lib/sdk/orders.js.map +1 -1
- package/lib/sdk/tokens.d.ts +3 -3
- package/lib/sdk/tokens.js +17 -7
- package/lib/sdk/tokens.js.map +1 -1
- package/lib/sdk.d.ts +16 -550
- package/lib/sdk.js +35 -663
- package/lib/sdk.js.map +1 -1
- package/lib/types.d.ts +11 -6
- package/lib/types.js +3 -3
- package/lib/types.js.map +1 -1
- package/lib/utils/address.d.ts +12 -0
- package/lib/utils/address.js +39 -0
- package/lib/utils/address.js.map +1 -0
- package/lib/utils/chain.d.ts +1 -1
- package/lib/utils/fees.d.ts +5 -0
- package/lib/utils/fees.js +24 -6
- package/lib/utils/fees.js.map +1 -1
- package/lib/utils/protocol.js +5 -5
- package/lib/utils/protocol.js.map +1 -1
- package/lib/utils/units.d.ts +12 -0
- package/lib/utils/units.js +43 -0
- package/lib/utils/units.js.map +1 -0
- package/lib/utils/utils.d.ts +2 -10
- package/lib/utils/utils.js +2 -17
- package/lib/utils/utils.js.map +1 -1
- package/lib/viem.d.ts +44 -0
- package/lib/viem.js +114 -0
- package/lib/viem.js.map +1 -0
- package/package.json +25 -8
- package/src/abi/abis.ts +236 -0
- package/src/api/api.ts +66 -59
- package/src/api/orders.ts +2 -2
- package/src/constants.ts +7 -3
- package/src/index.ts +8 -0
- package/src/orders/privateListings.ts +2 -2
- package/src/orders/utils.ts +8 -1
- package/src/provider/ethers-adapter.ts +182 -0
- package/src/provider/seaport-bridge.ts +163 -0
- package/src/provider/types.ts +67 -0
- package/src/provider/viem-adapter.ts +165 -0
- package/src/sdk/assets.ts +128 -158
- package/src/sdk/base.ts +558 -0
- package/src/sdk/cancellation.ts +6 -9
- package/src/sdk/context.ts +5 -5
- package/src/sdk/fulfillment.ts +31 -72
- package/src/sdk/orders.ts +44 -44
- package/src/sdk/tokens.ts +18 -18
- package/src/sdk.ts +40 -1011
- package/src/types.ts +12 -6
- package/src/utils/address.ts +40 -0
- package/src/utils/fees.ts +28 -8
- package/src/utils/protocol.ts +5 -5
- package/src/utils/units.ts +47 -0
- package/src/utils/utils.ts +2 -22
- package/src/viem.ts +125 -0
- package/lib/src/api/accounts.d.ts +0 -18
- package/lib/src/api/accounts.js +0 -30
- package/lib/src/api/accounts.js.map +0 -1
- package/lib/src/api/api.d.ts +0 -429
- package/lib/src/api/api.js +0 -652
- package/lib/src/api/api.js.map +0 -1
- package/lib/src/api/apiPaths.d.ts +0 -37
- package/lib/src/api/apiPaths.js +0 -140
- package/lib/src/api/apiPaths.js.map +0 -1
- package/lib/src/api/collections.d.ts +0 -26
- package/lib/src/api/collections.js +0 -57
- package/lib/src/api/collections.js.map +0 -1
- package/lib/src/api/events.d.ts +0 -26
- package/lib/src/api/events.js +0 -42
- package/lib/src/api/events.js.map +0 -1
- package/lib/src/api/fetcher.d.ts +0 -24
- package/lib/src/api/fetcher.js +0 -3
- package/lib/src/api/fetcher.js.map +0 -1
- package/lib/src/api/index.d.ts +0 -2
- package/lib/src/api/index.js +0 -19
- package/lib/src/api/index.js.map +0 -1
- package/lib/src/api/listings.d.ts +0 -44
- package/lib/src/api/listings.js +0 -86
- package/lib/src/api/listings.js.map +0 -1
- package/lib/src/api/nfts.d.ts +0 -35
- package/lib/src/api/nfts.js +0 -66
- package/lib/src/api/nfts.js.map +0 -1
- package/lib/src/api/offers.d.ts +0 -54
- package/lib/src/api/offers.js +0 -122
- package/lib/src/api/offers.js.map +0 -1
- package/lib/src/api/orders.d.ts +0 -50
- package/lib/src/api/orders.js +0 -151
- package/lib/src/api/orders.js.map +0 -1
- package/lib/src/api/search.d.ts +0 -13
- package/lib/src/api/search.js +0 -21
- package/lib/src/api/search.js.map +0 -1
- package/lib/src/api/tokens.d.ts +0 -25
- package/lib/src/api/tokens.js +0 -42
- package/lib/src/api/tokens.js.map +0 -1
- package/lib/src/api/types.d.ts +0 -840
- package/lib/src/api/types.js +0 -65
- package/lib/src/api/types.js.map +0 -1
- package/lib/src/constants.d.ts +0 -22
- package/lib/src/constants.js +0 -52
- package/lib/src/constants.js.map +0 -1
- package/lib/src/index.d.ts +0 -18
- package/lib/src/index.js +0 -24
- package/lib/src/index.js.map +0 -1
- package/lib/src/orders/privateListings.d.ts +0 -12
- package/lib/src/orders/privateListings.js +0 -130
- package/lib/src/orders/privateListings.js.map +0 -1
- package/lib/src/orders/types.d.ts +0 -160
- package/lib/src/orders/types.js +0 -10
- package/lib/src/orders/types.js.map +0 -1
- package/lib/src/orders/utils.d.ts +0 -89
- package/lib/src/orders/utils.js +0 -177
- package/lib/src/orders/utils.js.map +0 -1
- package/lib/src/sdk/assets.d.ts +0 -104
- package/lib/src/sdk/assets.js +0 -397
- package/lib/src/sdk/assets.js.map +0 -1
- package/lib/src/sdk/cancellation.d.ts +0 -97
- package/lib/src/sdk/cancellation.js +0 -234
- package/lib/src/sdk/cancellation.js.map +0 -1
- package/lib/src/sdk/context.d.ts +0 -28
- package/lib/src/sdk/context.js +0 -3
- package/lib/src/sdk/context.js.map +0 -1
- package/lib/src/sdk/fulfillment.d.ts +0 -153
- package/lib/src/sdk/fulfillment.js +0 -296
- package/lib/src/sdk/fulfillment.js.map +0 -1
- package/lib/src/sdk/orders.d.ts +0 -253
- package/lib/src/sdk/orders.js +0 -677
- package/lib/src/sdk/orders.js.map +0 -1
- package/lib/src/sdk/tokens.d.ts +0 -31
- package/lib/src/sdk/tokens.js +0 -64
- package/lib/src/sdk/tokens.js.map +0 -1
- package/lib/src/sdk.d.ts +0 -560
- package/lib/src/sdk.js +0 -675
- package/lib/src/sdk.js.map +0 -1
- package/lib/src/typechain/contracts/ERC1155.d.ts +0 -236
- package/lib/src/typechain/contracts/ERC1155.js +0 -3
- package/lib/src/typechain/contracts/ERC1155.js.map +0 -1
- package/lib/src/typechain/contracts/ERC20.d.ts +0 -141
- package/lib/src/typechain/contracts/ERC20.js +0 -3
- package/lib/src/typechain/contracts/ERC20.js.map +0 -1
- package/lib/src/typechain/contracts/ERC721.d.ts +0 -213
- package/lib/src/typechain/contracts/ERC721.js +0 -3
- package/lib/src/typechain/contracts/ERC721.js.map +0 -1
- package/lib/src/typechain/contracts/Multicall3.d.ts +0 -57
- package/lib/src/typechain/contracts/Multicall3.js +0 -3
- package/lib/src/typechain/contracts/Multicall3.js.map +0 -1
- package/lib/src/typechain/contracts/TransferHelper.d.ts +0 -55
- package/lib/src/typechain/contracts/TransferHelper.js +0 -3
- package/lib/src/typechain/contracts/TransferHelper.js.map +0 -1
- package/lib/src/typechain/contracts/common.d.ts +0 -50
- package/lib/src/typechain/contracts/common.js +0 -3
- package/lib/src/typechain/contracts/common.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js +0 -332
- package/lib/src/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
- package/lib/src/typechain/contracts/factories/ERC20__factory.js +0 -240
- package/lib/src/typechain/contracts/factories/ERC20__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
- package/lib/src/typechain/contracts/factories/ERC721__factory.js +0 -351
- package/lib/src/typechain/contracts/factories/ERC721__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js +0 -68
- package/lib/src/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js +0 -71
- package/lib/src/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
- package/lib/src/typechain/contracts/factories/index.d.ts +0 -5
- package/lib/src/typechain/contracts/factories/index.js +0 -17
- package/lib/src/typechain/contracts/factories/index.js.map +0 -1
- package/lib/src/typechain/contracts/index.d.ts +0 -11
- package/lib/src/typechain/contracts/index.js +0 -48
- package/lib/src/typechain/contracts/index.js.map +0 -1
- package/lib/src/types.d.ts +0 -387
- package/lib/src/types.js +0 -127
- package/lib/src/types.js.map +0 -1
- package/lib/src/utils/chain.d.ts +0 -60
- package/lib/src/utils/chain.js +0 -248
- package/lib/src/utils/chain.js.map +0 -1
- package/lib/src/utils/converters.d.ts +0 -37
- package/lib/src/utils/converters.js +0 -137
- package/lib/src/utils/converters.js.map +0 -1
- package/lib/src/utils/dateHelper.d.ts +0 -38
- package/lib/src/utils/dateHelper.js +0 -52
- package/lib/src/utils/dateHelper.js.map +0 -1
- package/lib/src/utils/fees.d.ts +0 -13
- package/lib/src/utils/fees.js +0 -29
- package/lib/src/utils/fees.js.map +0 -1
- package/lib/src/utils/index.d.ts +0 -2
- package/lib/src/utils/index.js +0 -19
- package/lib/src/utils/index.js.map +0 -1
- package/lib/src/utils/protocol.d.ts +0 -75
- package/lib/src/utils/protocol.js +0 -161
- package/lib/src/utils/protocol.js.map +0 -1
- package/lib/src/utils/rateLimit.d.ts +0 -34
- package/lib/src/utils/rateLimit.js +0 -97
- package/lib/src/utils/rateLimit.js.map +0 -1
- package/lib/src/utils/stringHelper.d.ts +0 -18
- package/lib/src/utils/stringHelper.js +0 -24
- package/lib/src/utils/stringHelper.js.map +0 -1
- package/lib/src/utils/utils.d.ts +0 -18
- package/lib/src/utils/utils.js +0 -45
- package/lib/src/utils/utils.js.map +0 -1
- package/lib/typechain/contracts/ERC1155.d.ts +0 -236
- package/lib/typechain/contracts/ERC1155.js +0 -3
- package/lib/typechain/contracts/ERC1155.js.map +0 -1
- package/lib/typechain/contracts/ERC20.d.ts +0 -141
- package/lib/typechain/contracts/ERC20.js +0 -3
- package/lib/typechain/contracts/ERC20.js.map +0 -1
- package/lib/typechain/contracts/ERC721.d.ts +0 -213
- package/lib/typechain/contracts/ERC721.js +0 -3
- package/lib/typechain/contracts/ERC721.js.map +0 -1
- package/lib/typechain/contracts/Multicall3.d.ts +0 -57
- package/lib/typechain/contracts/Multicall3.js +0 -3
- package/lib/typechain/contracts/Multicall3.js.map +0 -1
- package/lib/typechain/contracts/TransferHelper.d.ts +0 -55
- package/lib/typechain/contracts/TransferHelper.js +0 -3
- package/lib/typechain/contracts/TransferHelper.js.map +0 -1
- package/lib/typechain/contracts/common.d.ts +0 -50
- package/lib/typechain/contracts/common.js +0 -3
- package/lib/typechain/contracts/common.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC1155__factory.d.ts +0 -250
- package/lib/typechain/contracts/factories/ERC1155__factory.js +0 -332
- package/lib/typechain/contracts/factories/ERC1155__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC20__factory.d.ts +0 -174
- package/lib/typechain/contracts/factories/ERC20__factory.js +0 -240
- package/lib/typechain/contracts/factories/ERC20__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/ERC721__factory.d.ts +0 -268
- package/lib/typechain/contracts/factories/ERC721__factory.js +0 -351
- package/lib/typechain/contracts/factories/ERC721__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/Multicall3__factory.d.ts +0 -43
- package/lib/typechain/contracts/factories/Multicall3__factory.js +0 -68
- package/lib/typechain/contracts/factories/Multicall3__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/TransferHelper__factory.d.ts +0 -46
- package/lib/typechain/contracts/factories/TransferHelper__factory.js +0 -71
- package/lib/typechain/contracts/factories/TransferHelper__factory.js.map +0 -1
- package/lib/typechain/contracts/factories/index.d.ts +0 -5
- package/lib/typechain/contracts/factories/index.js +0 -17
- package/lib/typechain/contracts/factories/index.js.map +0 -1
- package/lib/typechain/contracts/index.d.ts +0 -11
- package/lib/typechain/contracts/index.js +0 -48
- package/lib/typechain/contracts/index.js.map +0 -1
- package/src/typechain/contracts/ERC1155.ts +0 -440
- package/src/typechain/contracts/ERC20.ts +0 -286
- package/src/typechain/contracts/ERC721.ts +0 -412
- package/src/typechain/contracts/Multicall3.ts +0 -117
- package/src/typechain/contracts/TransferHelper.ts +0 -122
- package/src/typechain/contracts/common.ts +0 -131
- package/src/typechain/contracts/factories/ERC1155__factory.ts +0 -331
- package/src/typechain/contracts/factories/ERC20__factory.ts +0 -239
- package/src/typechain/contracts/factories/ERC721__factory.ts +0 -350
- package/src/typechain/contracts/factories/Multicall3__factory.ts +0 -67
- package/src/typechain/contracts/factories/TransferHelper__factory.ts +0 -76
- package/src/typechain/contracts/factories/index.ts +0 -8
- package/src/typechain/contracts/index.ts +0 -14
package/src/sdk/fulfillment.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SeaportABI } from "@opensea/seaport-js/lib/abi/Seaport"
|
|
2
2
|
import type { OrderComponents } from "@opensea/seaport-js/lib/types"
|
|
3
|
-
import { type BigNumberish, ethers, type Overrides, type Signer } from "ethers"
|
|
4
3
|
import type { Listing, Offer, Order } from "../api/types"
|
|
5
4
|
import {
|
|
6
5
|
computePrivateListingValue,
|
|
@@ -9,7 +8,12 @@ import {
|
|
|
9
8
|
} from "../orders/privateListings"
|
|
10
9
|
import { OrderType, type OrderV2 } from "../orders/types"
|
|
11
10
|
import { DEFAULT_SEAPORT_CONTRACT_ADDRESS } from "../orders/utils"
|
|
12
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type Amount,
|
|
13
|
+
type AssetWithTokenId,
|
|
14
|
+
EventType,
|
|
15
|
+
OrderSide,
|
|
16
|
+
} from "../types"
|
|
13
17
|
import {
|
|
14
18
|
getSeaportInstance,
|
|
15
19
|
hasErrorCode,
|
|
@@ -32,13 +36,6 @@ export class FulfillmentManager {
|
|
|
32
36
|
|
|
33
37
|
/**
|
|
34
38
|
* Fulfill a private order for a designated address.
|
|
35
|
-
* @param options
|
|
36
|
-
* @param options.order The order to fulfill
|
|
37
|
-
* @param options.accountAddress Address of the wallet taking the order.
|
|
38
|
-
* @param options.domain An optional domain to be hashed and included at the end of fulfillment calldata.
|
|
39
|
-
* This can be used for onchain order attribution to assist with analytics.
|
|
40
|
-
* @param options.overrides Transaction overrides, ignored if not set.
|
|
41
|
-
* @returns Transaction hash of the order.
|
|
42
39
|
*/
|
|
43
40
|
private async fulfillPrivateOrder({
|
|
44
41
|
order,
|
|
@@ -49,7 +46,7 @@ export class FulfillmentManager {
|
|
|
49
46
|
order: OrderV2
|
|
50
47
|
accountAddress: string
|
|
51
48
|
domain?: string
|
|
52
|
-
overrides?:
|
|
49
|
+
overrides?: Record<string, unknown>
|
|
53
50
|
}): Promise<string> {
|
|
54
51
|
if (!order.taker?.address) {
|
|
55
52
|
throw new Error(
|
|
@@ -62,8 +59,6 @@ export class FulfillmentManager {
|
|
|
62
59
|
)
|
|
63
60
|
const fulfillments = getPrivateListingFulfillments(order.protocolData)
|
|
64
61
|
|
|
65
|
-
// Compute ETH value from original order's consideration items
|
|
66
|
-
// This handles both standard private listings and zero-payment listings (e.g., rewards)
|
|
67
62
|
const value = computePrivateListingValue(
|
|
68
63
|
order.protocolData,
|
|
69
64
|
order.taker.address,
|
|
@@ -131,10 +126,10 @@ export class FulfillmentManager {
|
|
|
131
126
|
accountAddress: string
|
|
132
127
|
assetContractAddress?: string
|
|
133
128
|
tokenId?: string
|
|
134
|
-
unitsToFill?:
|
|
129
|
+
unitsToFill?: Amount
|
|
135
130
|
recipientAddress?: string
|
|
136
131
|
includeOptionalCreatorFees?: boolean
|
|
137
|
-
overrides?:
|
|
132
|
+
overrides?: Record<string, unknown>
|
|
138
133
|
}): Promise<string> {
|
|
139
134
|
await this.context.requireAccountIsAvailable(accountAddress)
|
|
140
135
|
|
|
@@ -186,9 +181,6 @@ export class FulfillmentManager {
|
|
|
186
181
|
const transaction = fulfillmentData.fulfillment_data.transaction
|
|
187
182
|
const inputData = transaction.input_data
|
|
188
183
|
|
|
189
|
-
// Use Seaport ABI to encode the transaction
|
|
190
|
-
const seaportInterface = new ethers.Interface(SeaportABI)
|
|
191
|
-
|
|
192
184
|
// Extract function name and build parameters array in correct order
|
|
193
185
|
const rawFunctionName = transaction.function.split("(")[0]
|
|
194
186
|
const functionName =
|
|
@@ -226,18 +218,22 @@ export class FulfillmentManager {
|
|
|
226
218
|
params = Object.values(inputData)
|
|
227
219
|
}
|
|
228
220
|
|
|
229
|
-
const encodedData =
|
|
221
|
+
const encodedData = this.context.contractCaller.encodeFunctionData({
|
|
222
|
+
abi: SeaportABI,
|
|
230
223
|
functionName,
|
|
231
|
-
params,
|
|
232
|
-
)
|
|
224
|
+
args: params,
|
|
225
|
+
})
|
|
233
226
|
|
|
234
|
-
// Send the transaction using the signer from
|
|
235
|
-
const
|
|
236
|
-
|
|
227
|
+
// Send the transaction using the signer from wallet
|
|
228
|
+
const wallet = this.context.wallet
|
|
229
|
+
if (!("signer" in wallet)) {
|
|
230
|
+
throw new Error("A signer is required to fulfill orders")
|
|
231
|
+
}
|
|
232
|
+
const tx = await wallet.signer.sendTransaction({
|
|
237
233
|
to: transaction.to,
|
|
238
|
-
value: transaction.value,
|
|
234
|
+
value: BigInt(transaction.value),
|
|
239
235
|
data: encodedData,
|
|
240
|
-
|
|
236
|
+
overrides: overrides as Record<string, unknown>,
|
|
241
237
|
})
|
|
242
238
|
|
|
243
239
|
await this.context.confirmTransaction(
|
|
@@ -324,15 +320,7 @@ export class FulfillmentManager {
|
|
|
324
320
|
}
|
|
325
321
|
|
|
326
322
|
/**
|
|
327
|
-
* Validates an order onchain using Seaport's validate() method.
|
|
328
|
-
* and pre-validates the order using Seaport, which makes it cheaper to fulfill since a signature
|
|
329
|
-
* is not needed to be verified during fulfillment for the order, but is not strictly required
|
|
330
|
-
* and the alternative is orders can be submitted to the API for free instead of sent onchain.
|
|
331
|
-
* @param orderComponents Order components to validate onchain
|
|
332
|
-
* @param accountAddress Address of the wallet that will pay the gas to validate the order
|
|
333
|
-
* @returns Transaction hash of the validation transaction
|
|
334
|
-
*
|
|
335
|
-
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
323
|
+
* Validates an order onchain using Seaport's validate() method.
|
|
336
324
|
*/
|
|
337
325
|
async validateOrderOnchain(
|
|
338
326
|
orderComponents: OrderComponents,
|
|
@@ -366,23 +354,7 @@ export class FulfillmentManager {
|
|
|
366
354
|
}
|
|
367
355
|
|
|
368
356
|
/**
|
|
369
|
-
* Create and validate a listing onchain.
|
|
370
|
-
* Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
|
|
371
|
-
* @param options
|
|
372
|
-
* @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
|
|
373
|
-
* @param options.accountAddress Address of the wallet making the listing
|
|
374
|
-
* @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
|
|
375
|
-
* @param options.quantity Number of assets to list. Defaults to 1.
|
|
376
|
-
* @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
|
|
377
|
-
* @param options.salt Arbitrary salt. Auto-generated if not provided.
|
|
378
|
-
* @param options.listingTime When order becomes fulfillable (UTC seconds). Defaults to now.
|
|
379
|
-
* @param options.expirationTime Expiration time (UTC seconds).
|
|
380
|
-
* @param options.buyerAddress Optional buyer restriction. Only this address can purchase.
|
|
381
|
-
* @param options.includeOptionalCreatorFees Include optional creator fees. Default: false.
|
|
382
|
-
* @param options.zone Zone for order protection. Defaults to no zone.
|
|
383
|
-
* @returns Transaction hash
|
|
384
|
-
*
|
|
385
|
-
* @throws Error if asset missing token id or accountAddress unavailable.
|
|
357
|
+
* Create and validate a listing onchain.
|
|
386
358
|
*/
|
|
387
359
|
async createListingAndValidateOnchain({
|
|
388
360
|
asset,
|
|
@@ -399,10 +371,10 @@ export class FulfillmentManager {
|
|
|
399
371
|
}: {
|
|
400
372
|
asset: AssetWithTokenId
|
|
401
373
|
accountAddress: string
|
|
402
|
-
amount:
|
|
403
|
-
quantity?:
|
|
374
|
+
amount: Amount
|
|
375
|
+
quantity?: Amount
|
|
404
376
|
domain?: string
|
|
405
|
-
salt?:
|
|
377
|
+
salt?: Amount
|
|
406
378
|
listingTime?: number
|
|
407
379
|
expirationTime?: number
|
|
408
380
|
buyerAddress?: string
|
|
@@ -428,20 +400,7 @@ export class FulfillmentManager {
|
|
|
428
400
|
}
|
|
429
401
|
|
|
430
402
|
/**
|
|
431
|
-
* Create and validate an offer onchain.
|
|
432
|
-
* Validation costs gas upfront but makes fulfillment cheaper (no signature verification needed).
|
|
433
|
-
* @param options
|
|
434
|
-
* @param options.asset The asset to trade. tokenAddress and tokenId must be defined.
|
|
435
|
-
* @param options.accountAddress Address of the wallet making the offer.
|
|
436
|
-
* @param options.amount Amount in decimal format (e.g., "1.5" for 1.5 ETH, not wei). Automatically converted to base units.
|
|
437
|
-
* @param options.quantity Number of assets to bid for. Defaults to 1.
|
|
438
|
-
* @param options.domain Optional domain for onchain attribution. Hashed and included in salt.
|
|
439
|
-
* @param options.salt Arbitrary salt. Auto-generated if not provided.
|
|
440
|
-
* @param options.expirationTime Expiration time (UTC seconds).
|
|
441
|
-
* @param options.zone Zone for order protection. Defaults to chain's signed zone.
|
|
442
|
-
* @returns Transaction hash
|
|
443
|
-
*
|
|
444
|
-
* @throws Error if asset missing token id or accountAddress unavailable.
|
|
403
|
+
* Create and validate an offer onchain.
|
|
445
404
|
*/
|
|
446
405
|
async createOfferAndValidateOnchain({
|
|
447
406
|
asset,
|
|
@@ -455,11 +414,11 @@ export class FulfillmentManager {
|
|
|
455
414
|
}: {
|
|
456
415
|
asset: AssetWithTokenId
|
|
457
416
|
accountAddress: string
|
|
458
|
-
amount:
|
|
459
|
-
quantity?:
|
|
417
|
+
amount: Amount
|
|
418
|
+
quantity?: Amount
|
|
460
419
|
domain?: string
|
|
461
|
-
salt?:
|
|
462
|
-
expirationTime?:
|
|
420
|
+
salt?: Amount
|
|
421
|
+
expirationTime?: Amount
|
|
463
422
|
zone?: string
|
|
464
423
|
}): Promise<string> {
|
|
465
424
|
const orderComponents = await this.ordersManager.buildOfferOrderComponents({
|
package/src/sdk/orders.ts
CHANGED
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
CreateInputItem,
|
|
4
4
|
OrderComponents,
|
|
5
5
|
} from "@opensea/seaport-js/lib/types"
|
|
6
|
-
import { type BigNumberish, ZeroAddress } from "ethers"
|
|
7
6
|
import type { CollectionOffer, NFT } from "../api/types"
|
|
8
|
-
import { INVERSE_BASIS_POINT } from "../constants"
|
|
7
|
+
import { INVERSE_BASIS_POINT, ZERO_ADDRESS } from "../constants"
|
|
9
8
|
import type { OrderV2, ProtocolData } from "../orders/types"
|
|
10
9
|
import {
|
|
10
|
+
type Amount,
|
|
11
11
|
type AssetWithTokenId,
|
|
12
12
|
type Fee,
|
|
13
13
|
type OpenSeaCollection,
|
|
@@ -56,7 +56,7 @@ export class OrdersManager {
|
|
|
56
56
|
private getPriceParametersCallback: (
|
|
57
57
|
orderSide: OrderSide,
|
|
58
58
|
tokenAddress: string,
|
|
59
|
-
amount:
|
|
59
|
+
amount: Amount,
|
|
60
60
|
) => Promise<{ basePrice: bigint }>,
|
|
61
61
|
) {}
|
|
62
62
|
|
|
@@ -153,14 +153,14 @@ export class OrdersManager {
|
|
|
153
153
|
expirationTime,
|
|
154
154
|
buyerAddress,
|
|
155
155
|
includeOptionalCreatorFees = false,
|
|
156
|
-
zone =
|
|
156
|
+
zone = ZERO_ADDRESS,
|
|
157
157
|
}: {
|
|
158
158
|
asset: AssetWithTokenId
|
|
159
159
|
accountAddress: string
|
|
160
|
-
amount:
|
|
161
|
-
quantity?:
|
|
160
|
+
amount: Amount
|
|
161
|
+
quantity?: Amount
|
|
162
162
|
domain?: string
|
|
163
|
-
salt?:
|
|
163
|
+
salt?: Amount
|
|
164
164
|
listingTime?: number
|
|
165
165
|
expirationTime?: number
|
|
166
166
|
buyerAddress?: string
|
|
@@ -219,7 +219,7 @@ export class OrdersManager {
|
|
|
219
219
|
zone,
|
|
220
220
|
domain,
|
|
221
221
|
salt: BigInt(salt ?? 0).toString(),
|
|
222
|
-
restrictedByZone: zone !==
|
|
222
|
+
restrictedByZone: zone !== ZERO_ADDRESS,
|
|
223
223
|
allowPartialFills: true,
|
|
224
224
|
},
|
|
225
225
|
accountAddress,
|
|
@@ -244,14 +244,14 @@ export class OrdersManager {
|
|
|
244
244
|
expirationTime,
|
|
245
245
|
buyerAddress,
|
|
246
246
|
includeOptionalCreatorFees = false,
|
|
247
|
-
zone =
|
|
247
|
+
zone = ZERO_ADDRESS,
|
|
248
248
|
}: {
|
|
249
249
|
asset: AssetWithTokenId
|
|
250
250
|
accountAddress: string
|
|
251
|
-
amount:
|
|
252
|
-
quantity?:
|
|
251
|
+
amount: Amount
|
|
252
|
+
quantity?: Amount
|
|
253
253
|
domain?: string
|
|
254
|
-
salt?:
|
|
254
|
+
salt?: Amount
|
|
255
255
|
listingTime?: number
|
|
256
256
|
expirationTime?: number
|
|
257
257
|
buyerAddress?: string
|
|
@@ -291,11 +291,11 @@ export class OrdersManager {
|
|
|
291
291
|
}: {
|
|
292
292
|
asset: AssetWithTokenId
|
|
293
293
|
accountAddress: string
|
|
294
|
-
amount:
|
|
295
|
-
quantity?:
|
|
294
|
+
amount: Amount
|
|
295
|
+
quantity?: Amount
|
|
296
296
|
domain?: string
|
|
297
|
-
salt?:
|
|
298
|
-
expirationTime?:
|
|
297
|
+
salt?: Amount
|
|
298
|
+
expirationTime?: Amount
|
|
299
299
|
zone?: string
|
|
300
300
|
}) {
|
|
301
301
|
await this.context.requireAccountIsAvailable(accountAddress)
|
|
@@ -347,7 +347,7 @@ export class OrdersManager {
|
|
|
347
347
|
zone,
|
|
348
348
|
domain,
|
|
349
349
|
salt: BigInt(salt ?? 0).toString(),
|
|
350
|
-
restrictedByZone: zone !==
|
|
350
|
+
restrictedByZone: zone !== ZERO_ADDRESS,
|
|
351
351
|
allowPartialFills: true,
|
|
352
352
|
},
|
|
353
353
|
accountAddress,
|
|
@@ -373,11 +373,11 @@ export class OrdersManager {
|
|
|
373
373
|
}: {
|
|
374
374
|
asset: AssetWithTokenId
|
|
375
375
|
accountAddress: string
|
|
376
|
-
amount:
|
|
377
|
-
quantity?:
|
|
376
|
+
amount: Amount
|
|
377
|
+
quantity?: Amount
|
|
378
378
|
domain?: string
|
|
379
|
-
salt?:
|
|
380
|
-
expirationTime?:
|
|
379
|
+
salt?: Amount
|
|
380
|
+
expirationTime?: Amount
|
|
381
381
|
zone?: string
|
|
382
382
|
}): Promise<OrderComponents> {
|
|
383
383
|
const order = await this._buildOfferOrder({
|
|
@@ -423,11 +423,11 @@ export class OrdersManager {
|
|
|
423
423
|
}: {
|
|
424
424
|
asset: AssetWithTokenId
|
|
425
425
|
accountAddress: string
|
|
426
|
-
amount:
|
|
427
|
-
quantity?:
|
|
426
|
+
amount: Amount
|
|
427
|
+
quantity?: Amount
|
|
428
428
|
domain?: string
|
|
429
|
-
salt?:
|
|
430
|
-
expirationTime?:
|
|
429
|
+
salt?: Amount
|
|
430
|
+
expirationTime?: Amount
|
|
431
431
|
zone?: string
|
|
432
432
|
}): Promise<OrderV2> {
|
|
433
433
|
const order = await this._buildOfferOrder({
|
|
@@ -479,14 +479,14 @@ export class OrdersManager {
|
|
|
479
479
|
expirationTime,
|
|
480
480
|
buyerAddress,
|
|
481
481
|
includeOptionalCreatorFees = false,
|
|
482
|
-
zone =
|
|
482
|
+
zone = ZERO_ADDRESS,
|
|
483
483
|
}: {
|
|
484
484
|
asset: AssetWithTokenId
|
|
485
485
|
accountAddress: string
|
|
486
|
-
amount:
|
|
487
|
-
quantity?:
|
|
486
|
+
amount: Amount
|
|
487
|
+
quantity?: Amount
|
|
488
488
|
domain?: string
|
|
489
|
-
salt?:
|
|
489
|
+
salt?: Amount
|
|
490
490
|
listingTime?: number
|
|
491
491
|
expirationTime?: number
|
|
492
492
|
buyerAddress?: string
|
|
@@ -542,10 +542,10 @@ export class OrdersManager {
|
|
|
542
542
|
}: {
|
|
543
543
|
listings: Array<{
|
|
544
544
|
asset: AssetWithTokenId
|
|
545
|
-
amount:
|
|
546
|
-
quantity?:
|
|
545
|
+
amount: Amount
|
|
546
|
+
quantity?: Amount
|
|
547
547
|
domain?: string
|
|
548
|
-
salt?:
|
|
548
|
+
salt?: Amount
|
|
549
549
|
listingTime?: number
|
|
550
550
|
expirationTime?: number
|
|
551
551
|
buyerAddress?: string
|
|
@@ -597,7 +597,7 @@ export class OrdersManager {
|
|
|
597
597
|
paymentTokenAddress: string
|
|
598
598
|
zone: string
|
|
599
599
|
domain?: string
|
|
600
|
-
salt?:
|
|
600
|
+
salt?: Amount
|
|
601
601
|
listingTime?: number
|
|
602
602
|
expirationTime?: number
|
|
603
603
|
}> = []
|
|
@@ -614,7 +614,7 @@ export class OrdersManager {
|
|
|
614
614
|
expirationTime,
|
|
615
615
|
buyerAddress,
|
|
616
616
|
includeOptionalCreatorFees = false,
|
|
617
|
-
zone =
|
|
617
|
+
zone = ZERO_ADDRESS,
|
|
618
618
|
} = listing
|
|
619
619
|
|
|
620
620
|
// Fetch NFT and collection data
|
|
@@ -722,7 +722,7 @@ export class OrdersManager {
|
|
|
722
722
|
salt: metadata.salt
|
|
723
723
|
? BigInt(metadata.salt ?? 0).toString()
|
|
724
724
|
: undefined,
|
|
725
|
-
restrictedByZone: metadata.zone !==
|
|
725
|
+
restrictedByZone: metadata.zone !== ZERO_ADDRESS,
|
|
726
726
|
allowPartialFills: true,
|
|
727
727
|
}
|
|
728
728
|
})
|
|
@@ -823,11 +823,11 @@ export class OrdersManager {
|
|
|
823
823
|
}: {
|
|
824
824
|
offers: Array<{
|
|
825
825
|
asset: AssetWithTokenId
|
|
826
|
-
amount:
|
|
827
|
-
quantity?:
|
|
826
|
+
amount: Amount
|
|
827
|
+
quantity?: Amount
|
|
828
828
|
domain?: string
|
|
829
|
-
salt?:
|
|
830
|
-
expirationTime?:
|
|
829
|
+
salt?: Amount
|
|
830
|
+
expirationTime?: Amount
|
|
831
831
|
zone?: string
|
|
832
832
|
}>
|
|
833
833
|
accountAddress: string
|
|
@@ -875,8 +875,8 @@ export class OrdersManager {
|
|
|
875
875
|
paymentTokenAddress: string
|
|
876
876
|
zone: string
|
|
877
877
|
domain?: string
|
|
878
|
-
salt?:
|
|
879
|
-
expirationTime?:
|
|
878
|
+
salt?: Amount
|
|
879
|
+
expirationTime?: Amount
|
|
880
880
|
}> = []
|
|
881
881
|
|
|
882
882
|
// Build all order inputs
|
|
@@ -954,7 +954,7 @@ export class OrdersManager {
|
|
|
954
954
|
salt: metadata.salt
|
|
955
955
|
? BigInt(metadata.salt ?? 0).toString()
|
|
956
956
|
: undefined,
|
|
957
|
-
restrictedByZone: metadata.zone !==
|
|
957
|
+
restrictedByZone: metadata.zone !== ZERO_ADDRESS,
|
|
958
958
|
allowPartialFills: true,
|
|
959
959
|
}
|
|
960
960
|
})
|
|
@@ -1060,10 +1060,10 @@ export class OrdersManager {
|
|
|
1060
1060
|
}: {
|
|
1061
1061
|
collectionSlug: string
|
|
1062
1062
|
accountAddress: string
|
|
1063
|
-
amount:
|
|
1063
|
+
amount: Amount
|
|
1064
1064
|
quantity: number
|
|
1065
1065
|
domain?: string
|
|
1066
|
-
salt?:
|
|
1066
|
+
salt?: Amount
|
|
1067
1067
|
expirationTime?: number | string
|
|
1068
1068
|
offerProtectionEnabled?: boolean
|
|
1069
1069
|
traitType?: string
|
package/src/sdk/tokens.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventType } from "../types"
|
|
1
|
+
import { WETH_DEPOSIT_ABI, WETH_WITHDRAW_ABI } from "../abi/abis"
|
|
2
|
+
import { type Amount, EventType } from "../types"
|
|
3
3
|
import { getNativeWrapTokenAddress } from "../utils/chain"
|
|
4
|
+
import { parseEther } from "../utils/units"
|
|
4
5
|
import type { SDKContext } from "./context"
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -20,7 +21,7 @@ export class TokensManager {
|
|
|
20
21
|
amountInEth,
|
|
21
22
|
accountAddress,
|
|
22
23
|
}: {
|
|
23
|
-
amountInEth:
|
|
24
|
+
amountInEth: Amount
|
|
24
25
|
accountAddress: string
|
|
25
26
|
}) {
|
|
26
27
|
await this.context.requireAccountIsAvailable(accountAddress)
|
|
@@ -29,14 +30,14 @@ export class TokensManager {
|
|
|
29
30
|
|
|
30
31
|
this.context.dispatch(EventType.WrapEth, { accountAddress, amount: value })
|
|
31
32
|
|
|
32
|
-
const wethContract = new Contract(
|
|
33
|
-
getNativeWrapTokenAddress(this.context.chain),
|
|
34
|
-
["function deposit() payable"],
|
|
35
|
-
this.context.signerOrProvider,
|
|
36
|
-
)
|
|
37
|
-
|
|
38
33
|
try {
|
|
39
|
-
const transaction = await
|
|
34
|
+
const transaction = await this.context.contractCaller.writeContract({
|
|
35
|
+
address: getNativeWrapTokenAddress(this.context.chain),
|
|
36
|
+
abi: WETH_DEPOSIT_ABI,
|
|
37
|
+
functionName: "deposit",
|
|
38
|
+
args: [],
|
|
39
|
+
value,
|
|
40
|
+
})
|
|
40
41
|
await this.context.confirmTransaction(
|
|
41
42
|
transaction.hash,
|
|
42
43
|
EventType.WrapEth,
|
|
@@ -62,7 +63,7 @@ export class TokensManager {
|
|
|
62
63
|
amountInEth,
|
|
63
64
|
accountAddress,
|
|
64
65
|
}: {
|
|
65
|
-
amountInEth:
|
|
66
|
+
amountInEth: Amount
|
|
66
67
|
accountAddress: string
|
|
67
68
|
}) {
|
|
68
69
|
await this.context.requireAccountIsAvailable(accountAddress)
|
|
@@ -71,14 +72,13 @@ export class TokensManager {
|
|
|
71
72
|
|
|
72
73
|
this.context.dispatch(EventType.UnwrapWeth, { accountAddress, amount })
|
|
73
74
|
|
|
74
|
-
const wethContract = new Contract(
|
|
75
|
-
getNativeWrapTokenAddress(this.context.chain),
|
|
76
|
-
["function withdraw(uint wad) public"],
|
|
77
|
-
this.context.signerOrProvider,
|
|
78
|
-
)
|
|
79
|
-
|
|
80
75
|
try {
|
|
81
|
-
const transaction = await
|
|
76
|
+
const transaction = await this.context.contractCaller.writeContract({
|
|
77
|
+
address: getNativeWrapTokenAddress(this.context.chain),
|
|
78
|
+
abi: WETH_WITHDRAW_ABI,
|
|
79
|
+
functionName: "withdraw",
|
|
80
|
+
args: [amount],
|
|
81
|
+
})
|
|
82
82
|
await this.context.confirmTransaction(
|
|
83
83
|
transaction.hash,
|
|
84
84
|
EventType.UnwrapWeth,
|