@opensea/sdk 11.7.0 → 11.8.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 +1 -1
- package/lib/abi/abis.d.ts +16 -0
- package/lib/abi/abis.js +13 -1
- package/lib/abi/abis.js.map +1 -1
- package/lib/api/accounts.d.ts +6 -1
- package/lib/api/accounts.js +7 -0
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +10 -4
- package/lib/api/api.js +11 -3
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +1 -0
- package/lib/api/apiPaths.js +6 -2
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/types.d.ts +26 -1
- package/lib/api/types.js.map +1 -1
- package/lib/api/walletAuth.d.ts +37 -0
- package/lib/api/walletAuth.js +40 -5
- package/lib/api/walletAuth.js.map +1 -1
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +7 -1
- package/lib/constants.js.map +1 -1
- package/lib/orders/erc20Fulfillment.d.ts +41 -0
- package/lib/orders/erc20Fulfillment.js +190 -0
- package/lib/orders/erc20Fulfillment.js.map +1 -0
- package/lib/orders/orderUseCase.d.ts +18 -0
- package/lib/orders/orderUseCase.js +29 -0
- package/lib/orders/orderUseCase.js.map +1 -0
- package/lib/sdk/base.d.ts +32 -7
- package/lib/sdk/base.js +19 -7
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/cancellation.d.ts +2 -1
- package/lib/sdk/cancellation.js +2 -0
- package/lib/sdk/cancellation.js.map +1 -1
- package/lib/sdk/fulfillment.d.ts +57 -3
- package/lib/sdk/fulfillment.js +147 -4
- package/lib/sdk/fulfillment.js.map +1 -1
- package/lib/sdk/orders.d.ts +16 -3
- package/lib/sdk/orders.js +27 -13
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +2 -1
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -1
- package/lib/utils/chain.js +6 -0
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/chainIds.generated.js +1 -0
- package/lib/utils/chainIds.generated.js.map +1 -1
- package/package.json +3 -3
- package/src/abi/abis.ts +13 -0
- package/src/api/accounts.ts +14 -0
- package/src/api/api.ts +15 -3
- package/src/api/apiPaths.ts +4 -0
- package/src/api/types.ts +38 -0
- package/src/api/walletAuth.ts +53 -0
- package/src/constants.ts +8 -0
- package/src/orders/erc20Fulfillment.ts +218 -0
- package/src/orders/orderUseCase.ts +34 -0
- package/src/sdk/base.ts +20 -6
- package/src/sdk/cancellation.ts +4 -1
- package/src/sdk/fulfillment.ts +188 -6
- package/src/sdk/orders.ts +27 -15
- package/src/types.ts +1 -0
- package/src/utils/chain.ts +10 -0
- package/src/utils/chainIds.generated.ts +1 -0
|
@@ -18,6 +18,7 @@ export declare class CancellationManager {
|
|
|
18
18
|
* @param options.accountAddress The account address that will be cancelling the order.
|
|
19
19
|
* @param options.protocolAddress Required when using orderHash. The Seaport protocol address for the order.
|
|
20
20
|
* @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.
|
|
21
|
+
* @returns Transaction hash of the cancellation.
|
|
21
22
|
*
|
|
22
23
|
* @throws Error if neither order nor orderHash is provided.
|
|
23
24
|
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
@@ -29,7 +30,7 @@ export declare class CancellationManager {
|
|
|
29
30
|
accountAddress: string;
|
|
30
31
|
protocolAddress?: string;
|
|
31
32
|
domain?: string;
|
|
32
|
-
}): Promise<
|
|
33
|
+
}): Promise<string>;
|
|
33
34
|
/**
|
|
34
35
|
* Cancel multiple orders onchain, preventing them from being fulfilled.
|
|
35
36
|
* This method accepts either full OrderV2 objects, OrderComponents, or order hashes with protocol address.
|
package/lib/sdk/cancellation.js
CHANGED
|
@@ -22,6 +22,7 @@ class CancellationManager {
|
|
|
22
22
|
* @param options.accountAddress The account address that will be cancelling the order.
|
|
23
23
|
* @param options.protocolAddress Required when using orderHash. The Seaport protocol address for the order.
|
|
24
24
|
* @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.
|
|
25
|
+
* @returns Transaction hash of the cancellation.
|
|
25
26
|
*
|
|
26
27
|
* @throws Error if neither order nor orderHash is provided.
|
|
27
28
|
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
@@ -74,6 +75,7 @@ class CancellationManager {
|
|
|
74
75
|
});
|
|
75
76
|
// Await transaction confirmation
|
|
76
77
|
await this.context.confirmTransaction(transactionHash, types_1.EventType.CancelOrder, "Cancelling order");
|
|
78
|
+
return transactionHash;
|
|
77
79
|
}
|
|
78
80
|
/**
|
|
79
81
|
* Cancel multiple orders onchain, preventing them from being fulfilled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../src/sdk/cancellation.ts"],"names":[],"mappings":";;;AAGA,2CAAkE;AAClE,oCAAgD;AAChD,0CAKuB;AAGvB;;GAEG;AACH,MAAa,mBAAmB;IACV;IAApB,YAAoB,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAE3C
|
|
1
|
+
{"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../src/sdk/cancellation.ts"],"names":[],"mappings":";;;AAGA,2CAAkE;AAClE,oCAAgD;AAChD,0CAKuB;AAGvB;;GAEG;AACH,MAAa,mBAAmB;IACV;IAApB,YAAoB,OAAmB;QAAnB,YAAO,GAAP,OAAO,CAAY;IAAG,CAAC;IAE3C;;;;;;;;;;;;;;;OAeG;IACH,KAAK,CAAC,WAAW,CAAC,EAChB,KAAK,EACL,SAAS,EACT,cAAc,EACd,eAAe,GAAG,wCAAgC,EAClD,MAAM,GAOP;QACC,iBAAiB;QACjB,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;QACH,CAAC;QAED,wDAAwD;QACxD,MAAM,IAAI,CAAC,O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AAC,OAAO,CAAC,KAAK,EACjC,gBAAyB,EACzB,iCAA2C;QAE3C,IAAI,iCAAiC,EAAE,CAAC;YACtC,gBAAgB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAC/C,eAAe,EACf,SAAS,EACT,KAAK,CACN,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CACzC,eAAe,EACf,SAAS,EACT,KAAK,EACL,gBAAgB,CACjB,CAAA;IACH,CAAC;CACF;AAjWD,kDAiWC"}
|
package/lib/sdk/fulfillment.d.ts
CHANGED
|
@@ -51,6 +51,24 @@ export declare class FulfillmentManager {
|
|
|
51
51
|
includeOptionalCreatorFees?: boolean;
|
|
52
52
|
overrides?: Record<string, unknown>;
|
|
53
53
|
}): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Throw an actionable error when the buyer cannot pay for an ERC20-priced
|
|
56
|
+
* listing, because they hold too little of the payment token or have not
|
|
57
|
+
* approved the address Seaport pulls it from.
|
|
58
|
+
*
|
|
59
|
+
* The check is skipped for native-priced listings, for offer fulfillments, and
|
|
60
|
+
* for any response shape or RPC read it cannot interpret, so it never blocks a
|
|
61
|
+
* purchase that would otherwise have succeeded.
|
|
62
|
+
*/
|
|
63
|
+
private requireErc20PaymentIsSpendable;
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the address that will pull the payment token: Seaport itself when the
|
|
66
|
+
* fulfiller conduit key is `bytes32(0)`, otherwise the conduit registered for
|
|
67
|
+
* that key. Returns null when the key cannot be resolved.
|
|
68
|
+
*/
|
|
69
|
+
private resolveFulfillerSpender;
|
|
70
|
+
/** Read the buyer's payment-token balance and allowance for a spender. */
|
|
71
|
+
private readErc20SpendState;
|
|
54
72
|
/**
|
|
55
73
|
* Returns whether an order is fulfillable.
|
|
56
74
|
* An order may not be fulfillable if a target item's transfer function
|
|
@@ -80,10 +98,35 @@ export declare class FulfillmentManager {
|
|
|
80
98
|
approveOrder(order: OrderV2, domain?: string): Promise<string>;
|
|
81
99
|
/**
|
|
82
100
|
* Validates an order onchain using Seaport's validate() method.
|
|
101
|
+
*
|
|
102
|
+
* The order is left with an empty signature: Seaport takes the transaction
|
|
103
|
+
* sender as proof the offerer approved it. This does not post the order to
|
|
104
|
+
* OpenSea. It becomes discoverable only once OpenSea ingests the resulting
|
|
105
|
+
* `OrderValidated` event.
|
|
106
|
+
*
|
|
107
|
+
* @param orderComponents The order to validate
|
|
108
|
+
* @param accountAddress Address sending the validate transaction
|
|
109
|
+
* @param protocolAddress Seaport protocol address the components were built
|
|
110
|
+
* for. Defaults to {@link DEFAULT_SEAPORT_CONTRACT_ADDRESS}.
|
|
111
|
+
* @returns Transaction hash of the validate transaction
|
|
112
|
+
*
|
|
113
|
+
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
114
|
+
* @throws Error if the protocol address is not supported by OpenSea. See {@link isValidProtocol}.
|
|
83
115
|
*/
|
|
84
|
-
validateOrderOnchain(orderComponents: OrderComponents, accountAddress: string): Promise<string>;
|
|
116
|
+
validateOrderOnchain(orderComponents: OrderComponents, accountAddress: string, protocolAddress?: string): Promise<string>;
|
|
85
117
|
/**
|
|
86
|
-
* Create and validate
|
|
118
|
+
* Create a listing and validate it onchain, instead of signing it offchain.
|
|
119
|
+
*
|
|
120
|
+
* Runs any token approvals the listing needs, then sends one `validate()`
|
|
121
|
+
* transaction. The wallet is never asked for an EIP-712 signature, so this
|
|
122
|
+
* works for contract accounts that cannot produce one.
|
|
123
|
+
*
|
|
124
|
+
* Unlike {@link OrdersManager.createListing}, this does not post the listing
|
|
125
|
+
* to OpenSea. It becomes discoverable only once OpenSea ingests the
|
|
126
|
+
* `OrderValidated` event, so the returned hash is a transaction hash, not an
|
|
127
|
+
* order hash.
|
|
128
|
+
*
|
|
129
|
+
* @returns Transaction hash of the validate transaction
|
|
87
130
|
*/
|
|
88
131
|
createListingAndValidateOnchain({ asset, accountAddress, amount, quantity, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees, zone, }: {
|
|
89
132
|
asset: AssetWithTokenId;
|
|
@@ -99,7 +142,18 @@ export declare class FulfillmentManager {
|
|
|
99
142
|
zone?: string;
|
|
100
143
|
}): Promise<string>;
|
|
101
144
|
/**
|
|
102
|
-
* Create and validate
|
|
145
|
+
* Create an offer and validate it onchain, instead of signing it offchain.
|
|
146
|
+
*
|
|
147
|
+
* Runs any token approvals the offer needs, then sends one `validate()`
|
|
148
|
+
* transaction. The wallet is never asked for an EIP-712 signature, so this
|
|
149
|
+
* works for contract accounts that cannot produce one.
|
|
150
|
+
*
|
|
151
|
+
* Unlike {@link OrdersManager.createOffer}, this does not post the offer to
|
|
152
|
+
* OpenSea. It becomes discoverable only once OpenSea ingests the
|
|
153
|
+
* `OrderValidated` event, so the returned hash is a transaction hash, not an
|
|
154
|
+
* order hash.
|
|
155
|
+
*
|
|
156
|
+
* @returns Transaction hash of the validate transaction
|
|
103
157
|
*/
|
|
104
158
|
createOfferAndValidateOnchain({ asset, accountAddress, amount, quantity, domain, salt, expirationTime, zone, }: {
|
|
105
159
|
asset: AssetWithTokenId;
|
package/lib/sdk/fulfillment.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FulfillmentManager = void 0;
|
|
4
4
|
const Seaport_1 = require("@opensea/seaport-js/lib/abi/Seaport");
|
|
5
|
+
const abis_1 = require("../abi/abis");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
|
+
const erc20Fulfillment_1 = require("../orders/erc20Fulfillment");
|
|
5
8
|
const privateListings_1 = require("../orders/privateListings");
|
|
6
9
|
const types_1 = require("../orders/types");
|
|
7
10
|
const utils_1 = require("../orders/utils");
|
|
@@ -134,6 +137,12 @@ class FulfillmentManager {
|
|
|
134
137
|
// Fallback: try to use values in object order
|
|
135
138
|
params = Object.values(inputData);
|
|
136
139
|
}
|
|
140
|
+
// ERC20-priced listings send no native value; Seaport pulls the payment from
|
|
141
|
+
// the buyer instead, which reverts with a bare "execution reverted" when the
|
|
142
|
+
// spender has not been approved. Catch that before spending gas.
|
|
143
|
+
await this.requireErc20PaymentIsSpendable(inputData, transaction.to, {
|
|
144
|
+
accountAddress,
|
|
145
|
+
});
|
|
137
146
|
const encodedData = this.context.contractCaller.encodeFunctionData({
|
|
138
147
|
abi: Seaport_1.SeaportABI,
|
|
139
148
|
functionName,
|
|
@@ -153,6 +162,103 @@ class FulfillmentManager {
|
|
|
153
162
|
await this.context.confirmTransaction(tx.hash, types_2.EventType.MatchOrders, "Fulfilling order");
|
|
154
163
|
return tx.hash;
|
|
155
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Throw an actionable error when the buyer cannot pay for an ERC20-priced
|
|
167
|
+
* listing, because they hold too little of the payment token or have not
|
|
168
|
+
* approved the address Seaport pulls it from.
|
|
169
|
+
*
|
|
170
|
+
* The check is skipped for native-priced listings, for offer fulfillments, and
|
|
171
|
+
* for any response shape or RPC read it cannot interpret, so it never blocks a
|
|
172
|
+
* purchase that would otherwise have succeeded.
|
|
173
|
+
*/
|
|
174
|
+
async requireErc20PaymentIsSpendable(inputData, seaportAddress, { accountAddress }) {
|
|
175
|
+
const payment = (0, erc20Fulfillment_1.getErc20Payment)(inputData);
|
|
176
|
+
if (!payment) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const spender = await this.resolveFulfillerSpender((0, erc20Fulfillment_1.getFulfillerConduitKey)(inputData), seaportAddress);
|
|
180
|
+
if (!spender) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const spendState = await this.readErc20SpendState(payment.token, accountAddress, spender);
|
|
184
|
+
if (!spendState) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const amounts = `have ${spendState.balance}, need ${payment.amount} (base units of the payment token)`;
|
|
188
|
+
if (spendState.balance < payment.amount) {
|
|
189
|
+
throw new Error(`Insufficient ${payment.token} balance to fulfill this listing: ${amounts}. ` +
|
|
190
|
+
`Fund ${accountAddress} with the payment token before fulfilling.`);
|
|
191
|
+
}
|
|
192
|
+
if (spendState.allowance < payment.amount) {
|
|
193
|
+
throw new Error(`Payment token ${payment.token} is not approved for this listing: allowance for ` +
|
|
194
|
+
`${spender} is ${spendState.allowance}, need ${payment.amount} (base units of the ` +
|
|
195
|
+
`payment token). ERC20-priced listings send no native value, so Seaport pulls the ` +
|
|
196
|
+
`payment through this spender. Send approve(${spender}, ${payment.amount}) from ` +
|
|
197
|
+
`${accountAddress} first.`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Resolve the address that will pull the payment token: Seaport itself when the
|
|
202
|
+
* fulfiller conduit key is `bytes32(0)`, otherwise the conduit registered for
|
|
203
|
+
* that key. Returns null when the key cannot be resolved.
|
|
204
|
+
*/
|
|
205
|
+
async resolveFulfillerSpender(conduitKey, seaportAddress) {
|
|
206
|
+
if (!conduitKey || (0, erc20Fulfillment_1.isZeroConduitKey)(conduitKey)) {
|
|
207
|
+
return seaportAddress;
|
|
208
|
+
}
|
|
209
|
+
const defaultConduit = (0, utils_2.getDefaultConduit)(this.context.chain);
|
|
210
|
+
if (conduitKey.toLowerCase() === defaultConduit.key.toLowerCase()) {
|
|
211
|
+
return defaultConduit.address;
|
|
212
|
+
}
|
|
213
|
+
try {
|
|
214
|
+
const result = await this.context.contractCaller.readContract({
|
|
215
|
+
address: constants_1.CONDUIT_CONTROLLER_ADDRESS,
|
|
216
|
+
abi: abis_1.CONDUIT_CONTROLLER_ABI,
|
|
217
|
+
functionName: "getConduit",
|
|
218
|
+
args: [conduitKey],
|
|
219
|
+
});
|
|
220
|
+
if (!Array.isArray(result) ||
|
|
221
|
+
typeof result[0] !== "string" ||
|
|
222
|
+
result[1] !== true) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
return result[0];
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
this.context.logger(`Could not resolve conduit for key ${conduitKey}, skipping the ERC20 approval check: ${error}`);
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/** Read the buyer's payment-token balance and allowance for a spender. */
|
|
233
|
+
async readErc20SpendState(token, owner, spender) {
|
|
234
|
+
const contractCaller = this.context.contractCaller;
|
|
235
|
+
try {
|
|
236
|
+
const [rawBalance, rawAllowance] = await Promise.all([
|
|
237
|
+
contractCaller.readContract({
|
|
238
|
+
address: token,
|
|
239
|
+
abi: abis_1.ERC20_ABI,
|
|
240
|
+
functionName: "balanceOf",
|
|
241
|
+
args: [owner],
|
|
242
|
+
}),
|
|
243
|
+
contractCaller.readContract({
|
|
244
|
+
address: token,
|
|
245
|
+
abi: abis_1.ERC20_ABI,
|
|
246
|
+
functionName: "allowance",
|
|
247
|
+
args: [owner, spender],
|
|
248
|
+
}),
|
|
249
|
+
]);
|
|
250
|
+
const balance = (0, erc20Fulfillment_1.toBigInt)(rawBalance);
|
|
251
|
+
const allowance = (0, erc20Fulfillment_1.toBigInt)(rawAllowance);
|
|
252
|
+
if (balance === null || allowance === null) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
return { balance, allowance };
|
|
256
|
+
}
|
|
257
|
+
catch (error) {
|
|
258
|
+
this.context.logger(`Could not read ${token} balance or allowance, skipping the ERC20 approval check: ${error}`);
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
156
262
|
/**
|
|
157
263
|
* Returns whether an order is fulfillable.
|
|
158
264
|
* An order may not be fulfillable if a target item's transfer function
|
|
@@ -207,14 +313,29 @@ class FulfillmentManager {
|
|
|
207
313
|
}
|
|
208
314
|
/**
|
|
209
315
|
* Validates an order onchain using Seaport's validate() method.
|
|
316
|
+
*
|
|
317
|
+
* The order is left with an empty signature: Seaport takes the transaction
|
|
318
|
+
* sender as proof the offerer approved it. This does not post the order to
|
|
319
|
+
* OpenSea. It becomes discoverable only once OpenSea ingests the resulting
|
|
320
|
+
* `OrderValidated` event.
|
|
321
|
+
*
|
|
322
|
+
* @param orderComponents The order to validate
|
|
323
|
+
* @param accountAddress Address sending the validate transaction
|
|
324
|
+
* @param protocolAddress Seaport protocol address the components were built
|
|
325
|
+
* for. Defaults to {@link DEFAULT_SEAPORT_CONTRACT_ADDRESS}.
|
|
326
|
+
* @returns Transaction hash of the validate transaction
|
|
327
|
+
*
|
|
328
|
+
* @throws Error if the accountAddress is not available through wallet or provider.
|
|
329
|
+
* @throws Error if the protocol address is not supported by OpenSea. See {@link isValidProtocol}.
|
|
210
330
|
*/
|
|
211
|
-
async validateOrderOnchain(orderComponents, accountAddress) {
|
|
331
|
+
async validateOrderOnchain(orderComponents, accountAddress, protocolAddress = utils_1.DEFAULT_SEAPORT_CONTRACT_ADDRESS) {
|
|
212
332
|
await this.context.requireAccountIsAvailable(accountAddress);
|
|
333
|
+
(0, utils_2.requireValidProtocol)(protocolAddress);
|
|
213
334
|
this.context.dispatch(types_2.EventType.ApproveOrder, {
|
|
214
335
|
orderV2: { protocolData: orderComponents },
|
|
215
336
|
accountAddress,
|
|
216
337
|
});
|
|
217
|
-
const seaport = (0, utils_2.getSeaportInstance)(
|
|
338
|
+
const seaport = (0, utils_2.getSeaportInstance)(protocolAddress, this.context.seaport);
|
|
218
339
|
const transaction = await seaport
|
|
219
340
|
.validate([{ parameters: orderComponents, signature: "0x" }], accountAddress)
|
|
220
341
|
.transact();
|
|
@@ -222,7 +343,18 @@ class FulfillmentManager {
|
|
|
222
343
|
return transaction.hash;
|
|
223
344
|
}
|
|
224
345
|
/**
|
|
225
|
-
* Create and validate
|
|
346
|
+
* Create a listing and validate it onchain, instead of signing it offchain.
|
|
347
|
+
*
|
|
348
|
+
* Runs any token approvals the listing needs, then sends one `validate()`
|
|
349
|
+
* transaction. The wallet is never asked for an EIP-712 signature, so this
|
|
350
|
+
* works for contract accounts that cannot produce one.
|
|
351
|
+
*
|
|
352
|
+
* Unlike {@link OrdersManager.createListing}, this does not post the listing
|
|
353
|
+
* to OpenSea. It becomes discoverable only once OpenSea ingests the
|
|
354
|
+
* `OrderValidated` event, so the returned hash is a transaction hash, not an
|
|
355
|
+
* order hash.
|
|
356
|
+
*
|
|
357
|
+
* @returns Transaction hash of the validate transaction
|
|
226
358
|
*/
|
|
227
359
|
async createListingAndValidateOnchain({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone, }) {
|
|
228
360
|
const orderComponents = await this.ordersManager.buildListingOrderComponents({
|
|
@@ -241,7 +373,18 @@ class FulfillmentManager {
|
|
|
241
373
|
return this.validateOrderOnchain(orderComponents, accountAddress);
|
|
242
374
|
}
|
|
243
375
|
/**
|
|
244
|
-
* Create and validate
|
|
376
|
+
* Create an offer and validate it onchain, instead of signing it offchain.
|
|
377
|
+
*
|
|
378
|
+
* Runs any token approvals the offer needs, then sends one `validate()`
|
|
379
|
+
* transaction. The wallet is never asked for an EIP-712 signature, so this
|
|
380
|
+
* works for contract accounts that cannot produce one.
|
|
381
|
+
*
|
|
382
|
+
* Unlike {@link OrdersManager.createOffer}, this does not post the offer to
|
|
383
|
+
* OpenSea. It becomes discoverable only once OpenSea ingests the
|
|
384
|
+
* `OrderValidated` event, so the returned hash is a transaction hash, not an
|
|
385
|
+
* order hash.
|
|
386
|
+
*
|
|
387
|
+
* @returns Transaction hash of the validate transaction
|
|
245
388
|
*/
|
|
246
389
|
async createOfferAndValidateOnchain({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone, }) {
|
|
247
390
|
const orderComponents = await this.ordersManager.buildOfferOrderComponents({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fulfillment.js","sourceRoot":"","sources":["../../src/sdk/fulfillment.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;
|
|
1
|
+
{"version":3,"file":"fulfillment.js","sourceRoot":"","sources":["../../src/sdk/fulfillment.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAEhE,sCAA+D;AAE/D,4CAAyD;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,QAAQ,GAAG,CAAC,EACZ,MAAM,EACN,IAAI,EACJ,cAAc,EACd,IAAI,GAUL;QACC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;YACzE,KAAK;YACL,cAAc;YACd,MAAM;YACN,QAAQ;YACR,MAAM;YACN,IAAI;YACJ,cAAc;YACd,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC,oBAAoB,CAAC,eAAe,EAAE,cAAc,CAAC,CAAA;IACnE,CAAC;CACF;AAtkBD,gDAskBC"}
|
package/lib/sdk/orders.d.ts
CHANGED
|
@@ -40,11 +40,19 @@ export declare class OrdersManager {
|
|
|
40
40
|
/**
|
|
41
41
|
* Build listing order without submitting to API
|
|
42
42
|
* @param options Listing parameters
|
|
43
|
-
* @returns
|
|
43
|
+
* @returns The seaport-js use case. Call `executeAllActions()` to approve and
|
|
44
|
+
* sign it for API submission, or
|
|
45
|
+
* {@link executeApprovalsAndGetOrderComponents} to approve it without a
|
|
46
|
+
* signature for onchain validation.
|
|
44
47
|
*/
|
|
45
48
|
private _buildListingOrder;
|
|
46
49
|
/**
|
|
47
|
-
* Build listing order components without submitting to API
|
|
50
|
+
* Build listing order components without submitting to API.
|
|
51
|
+
*
|
|
52
|
+
* Runs any token approvals the order needs, but does not ask the wallet to
|
|
53
|
+
* sign: the components are meant for onchain validation, which needs no
|
|
54
|
+
* offchain signature.
|
|
55
|
+
*
|
|
48
56
|
* @param options Listing parameters
|
|
49
57
|
* @returns OrderComponents ready for onchain validation
|
|
50
58
|
*/
|
|
@@ -68,7 +76,12 @@ export declare class OrdersManager {
|
|
|
68
76
|
*/
|
|
69
77
|
private _buildOfferOrder;
|
|
70
78
|
/**
|
|
71
|
-
* Build offer order components without submitting to API
|
|
79
|
+
* Build offer order components without submitting to API.
|
|
80
|
+
*
|
|
81
|
+
* Runs any token approvals the order needs, but does not ask the wallet to
|
|
82
|
+
* sign: the components are meant for onchain validation, which needs no
|
|
83
|
+
* offchain signature.
|
|
84
|
+
*
|
|
72
85
|
* @param options Offer parameters
|
|
73
86
|
* @returns OrderComponents ready for onchain validation
|
|
74
87
|
*/
|
package/lib/sdk/orders.js
CHANGED
|
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.OrdersManager = void 0;
|
|
37
37
|
const constants_1 = require("../constants");
|
|
38
|
+
const orderUseCase_1 = require("../orders/orderUseCase");
|
|
38
39
|
const types_1 = require("../types");
|
|
39
40
|
const dateHelper_1 = require("../utils/dateHelper");
|
|
40
41
|
const stringHelper_1 = require("../utils/stringHelper");
|
|
@@ -95,7 +96,10 @@ class OrdersManager {
|
|
|
95
96
|
/**
|
|
96
97
|
* Build listing order without submitting to API
|
|
97
98
|
* @param options Listing parameters
|
|
98
|
-
* @returns
|
|
99
|
+
* @returns The seaport-js use case. Call `executeAllActions()` to approve and
|
|
100
|
+
* sign it for API submission, or
|
|
101
|
+
* {@link executeApprovalsAndGetOrderComponents} to approve it without a
|
|
102
|
+
* signature for onchain validation.
|
|
99
103
|
*/
|
|
100
104
|
async _buildListingOrder({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = constants_1.ZERO_ADDRESS, }) {
|
|
101
105
|
await this.context.requireAccountIsAvailable(accountAddress);
|
|
@@ -120,7 +124,7 @@ class OrdersManager {
|
|
|
120
124
|
if (collection.requiredZone) {
|
|
121
125
|
zone = collection.requiredZone;
|
|
122
126
|
}
|
|
123
|
-
|
|
127
|
+
return this.context.seaport.createOrder({
|
|
124
128
|
offer: offerAssetItems,
|
|
125
129
|
consideration: considerationFeeItems,
|
|
126
130
|
startTime: listingTime?.toString(),
|
|
@@ -131,15 +135,19 @@ class OrdersManager {
|
|
|
131
135
|
restrictedByZone: zone !== constants_1.ZERO_ADDRESS,
|
|
132
136
|
allowPartialFills: true,
|
|
133
137
|
}, accountAddress);
|
|
134
|
-
return executeAllActions();
|
|
135
138
|
}
|
|
136
139
|
/**
|
|
137
|
-
* Build listing order components without submitting to API
|
|
140
|
+
* Build listing order components without submitting to API.
|
|
141
|
+
*
|
|
142
|
+
* Runs any token approvals the order needs, but does not ask the wallet to
|
|
143
|
+
* sign: the components are meant for onchain validation, which needs no
|
|
144
|
+
* offchain signature.
|
|
145
|
+
*
|
|
138
146
|
* @param options Listing parameters
|
|
139
147
|
* @returns OrderComponents ready for onchain validation
|
|
140
148
|
*/
|
|
141
149
|
async buildListingOrderComponents({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = constants_1.ZERO_ADDRESS, }) {
|
|
142
|
-
const
|
|
150
|
+
const useCase = await this._buildListingOrder({
|
|
143
151
|
asset,
|
|
144
152
|
accountAddress,
|
|
145
153
|
amount,
|
|
@@ -152,7 +160,7 @@ class OrdersManager {
|
|
|
152
160
|
includeOptionalCreatorFees,
|
|
153
161
|
zone,
|
|
154
162
|
});
|
|
155
|
-
return
|
|
163
|
+
return (0, orderUseCase_1.executeApprovalsAndGetOrderComponents)(useCase);
|
|
156
164
|
}
|
|
157
165
|
/**
|
|
158
166
|
* Build offer order without submitting to API
|
|
@@ -175,7 +183,7 @@ class OrdersManager {
|
|
|
175
183
|
if (collection.requiredZone) {
|
|
176
184
|
zone = collection.requiredZone;
|
|
177
185
|
}
|
|
178
|
-
|
|
186
|
+
return this.context.seaport.createOrder({
|
|
179
187
|
offer: [
|
|
180
188
|
{
|
|
181
189
|
token: paymentTokenAddress,
|
|
@@ -192,15 +200,19 @@ class OrdersManager {
|
|
|
192
200
|
restrictedByZone: zone !== constants_1.ZERO_ADDRESS,
|
|
193
201
|
allowPartialFills: true,
|
|
194
202
|
}, accountAddress);
|
|
195
|
-
return executeAllActions();
|
|
196
203
|
}
|
|
197
204
|
/**
|
|
198
|
-
* Build offer order components without submitting to API
|
|
205
|
+
* Build offer order components without submitting to API.
|
|
206
|
+
*
|
|
207
|
+
* Runs any token approvals the order needs, but does not ask the wallet to
|
|
208
|
+
* sign: the components are meant for onchain validation, which needs no
|
|
209
|
+
* offchain signature.
|
|
210
|
+
*
|
|
199
211
|
* @param options Offer parameters
|
|
200
212
|
* @returns OrderComponents ready for onchain validation
|
|
201
213
|
*/
|
|
202
214
|
async buildOfferOrderComponents({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), }) {
|
|
203
|
-
const
|
|
215
|
+
const useCase = await this._buildOfferOrder({
|
|
204
216
|
asset,
|
|
205
217
|
accountAddress,
|
|
206
218
|
amount,
|
|
@@ -210,7 +222,7 @@ class OrdersManager {
|
|
|
210
222
|
expirationTime,
|
|
211
223
|
zone,
|
|
212
224
|
});
|
|
213
|
-
return
|
|
225
|
+
return (0, orderUseCase_1.executeApprovalsAndGetOrderComponents)(useCase);
|
|
214
226
|
}
|
|
215
227
|
/**
|
|
216
228
|
* Create and submit an offer on an asset.
|
|
@@ -231,7 +243,7 @@ class OrdersManager {
|
|
|
231
243
|
* @throws Error if the amount is not greater than 0.
|
|
232
244
|
*/
|
|
233
245
|
async createOffer({ asset, accountAddress, amount, quantity = 1, domain, salt, expirationTime, zone = (0, utils_1.getSignedZone)(this.context.chain), }) {
|
|
234
|
-
const
|
|
246
|
+
const useCase = await this._buildOfferOrder({
|
|
235
247
|
asset,
|
|
236
248
|
accountAddress,
|
|
237
249
|
amount,
|
|
@@ -241,6 +253,7 @@ class OrdersManager {
|
|
|
241
253
|
expirationTime,
|
|
242
254
|
zone,
|
|
243
255
|
});
|
|
256
|
+
const order = await useCase.executeAllActions();
|
|
244
257
|
return this.context.api.postOffer(order, this.context.seaport.contract.target);
|
|
245
258
|
}
|
|
246
259
|
/**
|
|
@@ -264,7 +277,7 @@ class OrdersManager {
|
|
|
264
277
|
* @throws Error if the amount is not greater than 0.
|
|
265
278
|
*/
|
|
266
279
|
async createListing({ asset, accountAddress, amount, quantity = 1, domain, salt, listingTime, expirationTime, buyerAddress, includeOptionalCreatorFees = false, zone = constants_1.ZERO_ADDRESS, }) {
|
|
267
|
-
const
|
|
280
|
+
const useCase = await this._buildListingOrder({
|
|
268
281
|
asset,
|
|
269
282
|
accountAddress,
|
|
270
283
|
amount,
|
|
@@ -277,6 +290,7 @@ class OrdersManager {
|
|
|
277
290
|
includeOptionalCreatorFees,
|
|
278
291
|
zone,
|
|
279
292
|
});
|
|
293
|
+
const order = await useCase.executeAllActions();
|
|
280
294
|
return this.context.api.postListing(order, this.context.seaport.contract.target);
|
|
281
295
|
}
|
|
282
296
|
/**
|