@opensea/seaport-js 2.0.4 → 2.0.6
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 +4 -4
- package/lib/bundle.js +10 -5
- package/lib/seaport.js +10 -5
- package/lib/seaport.js.map +1 -1
- package/lib/typechain-types/seaport-core/src/lib/Assertions.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/BasicOrderFulfiller.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/Consideration.d.ts +6 -6
- package/lib/typechain-types/seaport-core/src/lib/ConsiderationBase.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/CounterManager.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/Executor.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/GettersAndDerivers.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/OrderCombiner.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/OrderFulfiller.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/OrderValidator.d.ts +4 -4
- package/lib/typechain-types/seaport-core/src/lib/Verifiers.d.ts +4 -4
- package/lib/typechain-types/seaport-types/src/interfaces/ConsiderationEventsAndErrors.d.ts +4 -4
- package/lib/typechain-types/seaport-types/src/interfaces/ConsiderationInterface.d.ts +2 -2
- package/lib/typechain-types/seaport_v1_4/contracts/Seaport.d.ts +6 -6
- package/lib/typechain-types/seaport_v1_5/contracts/Seaport.d.ts +6 -6
- package/lib/types.d.ts +1 -0
- package/lib/utils/criteria.js.map +1 -1
- package/package.json +6 -6
- package/src/constants.ts +1 -1
- package/src/seaport.ts +66 -59
- package/src/typechain-types/seaport-core/src/lib/Assertions.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/BasicOrderFulfiller.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/Consideration.ts +6 -6
- package/src/typechain-types/seaport-core/src/lib/ConsiderationBase.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/CounterManager.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/Executor.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/GettersAndDerivers.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/OrderCombiner.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/OrderFulfiller.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/OrderValidator.ts +4 -4
- package/src/typechain-types/seaport-core/src/lib/Verifiers.ts +4 -4
- package/src/typechain-types/seaport-types/src/interfaces/ConsiderationEventsAndErrors.ts +4 -4
- package/src/typechain-types/seaport-types/src/interfaces/ConsiderationInterface.ts +2 -2
- package/src/typechain-types/seaport_v1_4/contracts/Seaport.ts +6 -6
- package/src/typechain-types/seaport_v1_5/contracts/Seaport.ts +6 -6
- package/src/types.ts +13 -12
- package/src/utils/approval.ts +9 -9
- package/src/utils/balance.ts +7 -7
- package/src/utils/balanceAndApprovalCheck.ts +22 -22
- package/src/utils/criteria.ts +7 -7
- package/src/utils/eip712/Eip712MerkleTree.ts +2 -2
- package/src/utils/eip712/bulk-orders.ts +2 -2
- package/src/utils/eip712/defaults.ts +5 -5
- package/src/utils/eip712/utils.ts +1 -1
- package/src/utils/fulfill.ts +44 -44
- package/src/utils/item.ts +3 -3
- package/src/utils/merkletree.ts +2 -2
- package/src/utils/order.ts +15 -15
- package/src/utils/usecase.ts +8 -8
|
@@ -41,7 +41,7 @@ export type InsufficientApprovals = {
|
|
|
41
41
|
const findBalanceAndApproval = (
|
|
42
42
|
balancesAndApprovals: BalancesAndApprovals,
|
|
43
43
|
token: string,
|
|
44
|
-
identifierOrCriteria: string
|
|
44
|
+
identifierOrCriteria: string,
|
|
45
45
|
) => {
|
|
46
46
|
const balanceAndApproval = balancesAndApprovals.find(
|
|
47
47
|
({
|
|
@@ -50,12 +50,12 @@ const findBalanceAndApproval = (
|
|
|
50
50
|
}) =>
|
|
51
51
|
token.toLowerCase() === checkedToken.toLowerCase() &&
|
|
52
52
|
checkedIdentifierOrCriteria.toLowerCase() ===
|
|
53
|
-
identifierOrCriteria.toLowerCase()
|
|
53
|
+
identifierOrCriteria.toLowerCase(),
|
|
54
54
|
);
|
|
55
55
|
|
|
56
56
|
if (!balanceAndApproval) {
|
|
57
57
|
throw new Error(
|
|
58
|
-
"Balances and approvals didn't contain all tokens and identifiers"
|
|
58
|
+
"Balances and approvals didn't contain all tokens and identifiers",
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -86,14 +86,14 @@ export const getBalancesAndApprovals = async ({
|
|
|
86
86
|
owner,
|
|
87
87
|
item,
|
|
88
88
|
operator,
|
|
89
|
-
multicallProvider
|
|
89
|
+
multicallProvider,
|
|
90
90
|
);
|
|
91
91
|
} else if (isErc20Item(item.itemType)) {
|
|
92
92
|
approvedAmountPromise = approvedItemAmount(
|
|
93
93
|
owner,
|
|
94
94
|
item,
|
|
95
95
|
operator,
|
|
96
|
-
multicallProvider
|
|
96
|
+
multicallProvider,
|
|
97
97
|
);
|
|
98
98
|
}
|
|
99
99
|
// If native token, we don't need to check for approvals
|
|
@@ -109,12 +109,12 @@ export const getBalancesAndApprovals = async ({
|
|
|
109
109
|
owner,
|
|
110
110
|
item,
|
|
111
111
|
multicallProvider,
|
|
112
|
-
itemToCriteria.get(item)
|
|
112
|
+
itemToCriteria.get(item),
|
|
113
113
|
),
|
|
114
114
|
approvedAmount: await approvedAmountPromise,
|
|
115
115
|
itemType: item.itemType,
|
|
116
116
|
};
|
|
117
|
-
})
|
|
117
|
+
}),
|
|
118
118
|
);
|
|
119
119
|
};
|
|
120
120
|
|
|
@@ -137,27 +137,27 @@ export const getInsufficientBalanceAndApprovalAmounts = ({
|
|
|
137
137
|
([token, identifierToAmount]) =>
|
|
138
138
|
Object.entries(identifierToAmount).map(
|
|
139
139
|
([identifierOrCriteria, amountNeeded]) =>
|
|
140
|
-
[token, identifierOrCriteria, amountNeeded] as const
|
|
141
|
-
)
|
|
140
|
+
[token, identifierOrCriteria, amountNeeded] as const,
|
|
141
|
+
),
|
|
142
142
|
),
|
|
143
143
|
].flat();
|
|
144
144
|
|
|
145
145
|
const filterBalancesOrApprovals = (
|
|
146
|
-
filterKey: "balance" | "approvedAmount"
|
|
146
|
+
filterKey: "balance" | "approvedAmount",
|
|
147
147
|
): InsufficientBalances =>
|
|
148
148
|
tokenAndIdentifierAndAmountNeeded
|
|
149
149
|
.filter(([token, identifierOrCriteria, amountNeeded]) =>
|
|
150
150
|
findBalanceAndApproval(
|
|
151
151
|
balancesAndApprovals,
|
|
152
152
|
token,
|
|
153
|
-
identifierOrCriteria
|
|
154
|
-
)[filterKey].lt(amountNeeded)
|
|
153
|
+
identifierOrCriteria,
|
|
154
|
+
)[filterKey].lt(amountNeeded),
|
|
155
155
|
)
|
|
156
156
|
.map(([token, identifierOrCriteria, amount]) => {
|
|
157
157
|
const balanceAndApproval = findBalanceAndApproval(
|
|
158
158
|
balancesAndApprovals,
|
|
159
159
|
token,
|
|
160
|
-
identifierOrCriteria
|
|
160
|
+
identifierOrCriteria,
|
|
161
161
|
);
|
|
162
162
|
|
|
163
163
|
return {
|
|
@@ -170,7 +170,7 @@ export const getInsufficientBalanceAndApprovalAmounts = ({
|
|
|
170
170
|
});
|
|
171
171
|
|
|
172
172
|
const mapToApproval = (
|
|
173
|
-
insufficientBalance: InsufficientBalances[number]
|
|
173
|
+
insufficientBalance: InsufficientBalances[number],
|
|
174
174
|
): InsufficientApprovals[number] => ({
|
|
175
175
|
token: insufficientBalance.token,
|
|
176
176
|
identifierOrCriteria: insufficientBalance.identifierOrCriteria,
|
|
@@ -230,7 +230,7 @@ export const validateOfferBalancesAndApprovals = ({
|
|
|
230
230
|
|
|
231
231
|
if (throwOnInsufficientBalances && insufficientBalances.length > 0) {
|
|
232
232
|
throw new Error(
|
|
233
|
-
"The offerer does not have the amount needed to create or fulfill."
|
|
233
|
+
"The offerer does not have the amount needed to create or fulfill.",
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -284,7 +284,7 @@ export const validateBasicFulfillBalancesAndApprovals = ({
|
|
|
284
284
|
});
|
|
285
285
|
|
|
286
286
|
const considerationWithoutOfferItemType = consideration.filter(
|
|
287
|
-
(item) => item.itemType !== offer[0].itemType
|
|
287
|
+
(item) => item.itemType !== offer[0].itemType,
|
|
288
288
|
);
|
|
289
289
|
|
|
290
290
|
const { insufficientBalances, insufficientApprovals } =
|
|
@@ -303,7 +303,7 @@ export const validateBasicFulfillBalancesAndApprovals = ({
|
|
|
303
303
|
|
|
304
304
|
if (insufficientBalances.length > 0) {
|
|
305
305
|
throw new Error(
|
|
306
|
-
"The fulfiller does not have the balances needed to fulfill."
|
|
306
|
+
"The fulfiller does not have the balances needed to fulfill.",
|
|
307
307
|
);
|
|
308
308
|
}
|
|
309
309
|
|
|
@@ -379,7 +379,7 @@ export const validateStandardFulfillBalancesAndApprovals = ({
|
|
|
379
379
|
|
|
380
380
|
if (insufficientBalances.length > 0) {
|
|
381
381
|
throw new Error(
|
|
382
|
-
"The fulfiller does not have the balances needed to fulfill."
|
|
382
|
+
"The fulfiller does not have the balances needed to fulfill.",
|
|
383
383
|
);
|
|
384
384
|
}
|
|
385
385
|
|
|
@@ -405,7 +405,7 @@ const addToExistingBalances = ({
|
|
|
405
405
|
|
|
406
406
|
// Deep clone existing balances
|
|
407
407
|
const balancesAndApprovalsAfterReceivingItems = balancesAndApprovals.map(
|
|
408
|
-
(item) => ({ ...item })
|
|
408
|
+
(item) => ({ ...item }),
|
|
409
409
|
);
|
|
410
410
|
|
|
411
411
|
// Add each summed item amount to the existing balances as we may want tocheck balances after receiving all items
|
|
@@ -416,7 +416,7 @@ const addToExistingBalances = ({
|
|
|
416
416
|
const balanceAndApproval = findBalanceAndApproval(
|
|
417
417
|
balancesAndApprovalsAfterReceivingItems,
|
|
418
418
|
token,
|
|
419
|
-
identifierOrCriteria
|
|
419
|
+
identifierOrCriteria,
|
|
420
420
|
);
|
|
421
421
|
|
|
422
422
|
const balanceAndApprovalIndex =
|
|
@@ -428,8 +428,8 @@ const addToExistingBalances = ({
|
|
|
428
428
|
balancesAndApprovalsAfterReceivingItems[
|
|
429
429
|
balanceAndApprovalIndex
|
|
430
430
|
].balance.add(amount);
|
|
431
|
-
}
|
|
432
|
-
)
|
|
431
|
+
},
|
|
432
|
+
),
|
|
433
433
|
);
|
|
434
434
|
|
|
435
435
|
return balancesAndApprovalsAfterReceivingItems;
|
package/src/utils/criteria.ts
CHANGED
|
@@ -20,9 +20,9 @@ export const generateCriteriaResolvers = ({
|
|
|
20
20
|
item,
|
|
21
21
|
index,
|
|
22
22
|
side: Side.OFFER,
|
|
23
|
-
} as const
|
|
23
|
+
}) as const,
|
|
24
24
|
)
|
|
25
|
-
.filter(({ item }) => isCriteriaItem(item.itemType))
|
|
25
|
+
.filter(({ item }) => isCriteriaItem(item.itemType)),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const considerationCriteriaItems = orders.flatMap((order, orderIndex) =>
|
|
@@ -34,16 +34,16 @@ export const generateCriteriaResolvers = ({
|
|
|
34
34
|
item,
|
|
35
35
|
index,
|
|
36
36
|
side: Side.CONSIDERATION,
|
|
37
|
-
} as const
|
|
37
|
+
}) as const,
|
|
38
38
|
)
|
|
39
|
-
.filter(({ item }) => isCriteriaItem(item.itemType))
|
|
39
|
+
.filter(({ item }) => isCriteriaItem(item.itemType)),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const mapCriteriaItemsToResolver = (
|
|
43
43
|
criteriaItems:
|
|
44
44
|
| typeof offerCriteriaItems
|
|
45
45
|
| typeof considerationCriteriaItems,
|
|
46
|
-
criterias: InputCriteria[][]
|
|
46
|
+
criterias: InputCriteria[][],
|
|
47
47
|
) =>
|
|
48
48
|
criteriaItems.map(({ orderIndex, item, index, side }) => {
|
|
49
49
|
const merkleRoot = item.identifierOrCriteria || "0";
|
|
@@ -61,7 +61,7 @@ export const generateCriteriaResolvers = ({
|
|
|
61
61
|
...mapCriteriaItemsToResolver(offerCriteriaItems, offerCriterias),
|
|
62
62
|
...mapCriteriaItemsToResolver(
|
|
63
63
|
considerationCriteriaItems,
|
|
64
|
-
considerationCriterias
|
|
64
|
+
considerationCriterias,
|
|
65
65
|
),
|
|
66
66
|
];
|
|
67
67
|
|
|
@@ -70,7 +70,7 @@ export const generateCriteriaResolvers = ({
|
|
|
70
70
|
|
|
71
71
|
export const getItemToCriteriaMap = (
|
|
72
72
|
items: Item[],
|
|
73
|
-
criterias: InputCriteria[]
|
|
73
|
+
criterias: InputCriteria[],
|
|
74
74
|
) => {
|
|
75
75
|
const criteriasCopy = [...criterias];
|
|
76
76
|
|
|
@@ -34,7 +34,7 @@ const getTree = (leaves: string[], defaultLeafHash: string) =>
|
|
|
34
34
|
const encodeProof = (
|
|
35
35
|
key: number,
|
|
36
36
|
proof: string[],
|
|
37
|
-
signature = `0x${"ff".repeat(64)}
|
|
37
|
+
signature = `0x${"ff".repeat(64)}`,
|
|
38
38
|
) => {
|
|
39
39
|
return hexConcat([
|
|
40
40
|
signature,
|
|
@@ -116,7 +116,7 @@ export class Eip712MerkleTree<BaseType extends Record<string, any> = any> {
|
|
|
116
116
|
public rootType: string,
|
|
117
117
|
public leafType: string,
|
|
118
118
|
public elements: BaseType[],
|
|
119
|
-
public depth: number
|
|
119
|
+
public depth: number,
|
|
120
120
|
) {
|
|
121
121
|
const encoder = TypedDataEncoder.from(types);
|
|
122
122
|
this.encoder = encoder;
|
|
@@ -24,7 +24,7 @@ export function getBulkOrderTreeHeight(length: number): number {
|
|
|
24
24
|
export function getBulkOrderTree(
|
|
25
25
|
orderComponents: OrderComponents[],
|
|
26
26
|
startIndex = 0,
|
|
27
|
-
height = getBulkOrderTreeHeight(orderComponents.length + startIndex)
|
|
27
|
+
height = getBulkOrderTreeHeight(orderComponents.length + startIndex),
|
|
28
28
|
) {
|
|
29
29
|
const types = getBulkOrderTypes(height);
|
|
30
30
|
const defaultNode = DefaultGetter.from(types, "OrderComponents");
|
|
@@ -41,7 +41,7 @@ export function getBulkOrderTree(
|
|
|
41
41
|
"BulkOrder",
|
|
42
42
|
"OrderComponents",
|
|
43
43
|
elements,
|
|
44
|
-
height
|
|
44
|
+
height,
|
|
45
45
|
);
|
|
46
46
|
return tree;
|
|
47
47
|
}
|
|
@@ -52,7 +52,7 @@ export class DefaultGetter<Types extends EIP712TypeDefinitions> {
|
|
|
52
52
|
this.defaultValues[name] = defaultValue;
|
|
53
53
|
if (!isNullish(defaultValue)) {
|
|
54
54
|
logger.throwError(
|
|
55
|
-
`Got non-empty value for type ${name} in default generator: ${defaultValue}
|
|
55
|
+
`Got non-empty value for type ${name} in default generator: ${defaultValue}`,
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -60,17 +60,17 @@ export class DefaultGetter<Types extends EIP712TypeDefinitions> {
|
|
|
60
60
|
|
|
61
61
|
/* eslint-disable no-dupe-class-members */
|
|
62
62
|
static from<Types extends EIP712TypeDefinitions>(
|
|
63
|
-
types: Types
|
|
63
|
+
types: Types,
|
|
64
64
|
): DefaultMap<Types>;
|
|
65
65
|
|
|
66
66
|
static from<Types extends EIP712TypeDefinitions>(
|
|
67
67
|
types: Types,
|
|
68
|
-
type: keyof Types
|
|
68
|
+
type: keyof Types,
|
|
69
69
|
): any;
|
|
70
70
|
|
|
71
71
|
static from<Types extends EIP712TypeDefinitions>(
|
|
72
72
|
types: Types,
|
|
73
|
-
type?: keyof Types
|
|
73
|
+
type?: keyof Types,
|
|
74
74
|
): DefaultMap<Types> {
|
|
75
75
|
const { defaultValues } = new DefaultGetter(types);
|
|
76
76
|
if (type) return defaultValues[type];
|
|
@@ -104,7 +104,7 @@ export class DefaultGetter<Types extends EIP712TypeDefinitions> {
|
|
|
104
104
|
...obj,
|
|
105
105
|
[name]: this.getDefaultValue(type),
|
|
106
106
|
}),
|
|
107
|
-
{}
|
|
107
|
+
{},
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -9,7 +9,7 @@ export const makeArray = <T>(len: number, getValue: (i: number) => T) =>
|
|
|
9
9
|
|
|
10
10
|
export const chunk = <T>(array: T[], size: number) => {
|
|
11
11
|
return makeArray(Math.ceil(array.length / size), (i) =>
|
|
12
|
-
array.slice(i * size, (i + 1) * size)
|
|
12
|
+
array.slice(i * size, (i + 1) * size),
|
|
13
13
|
);
|
|
14
14
|
};
|
|
15
15
|
|
package/src/utils/fulfill.ts
CHANGED
|
@@ -68,7 +68,7 @@ import { executeAllActions, getTransactionMethods } from "./usecase";
|
|
|
68
68
|
*/
|
|
69
69
|
export const shouldUseBasicFulfill = (
|
|
70
70
|
{ offer, consideration, offerer }: OrderParameters,
|
|
71
|
-
totalFilled: OrderStatus["totalFilled"]
|
|
71
|
+
totalFilled: OrderStatus["totalFilled"],
|
|
72
72
|
) => {
|
|
73
73
|
// 1. The order must not be partially filled
|
|
74
74
|
if (!totalFilled.eq(0)) {
|
|
@@ -83,11 +83,11 @@ export const shouldUseBasicFulfill = (
|
|
|
83
83
|
const allItems = [...offer, ...consideration];
|
|
84
84
|
|
|
85
85
|
const nfts = allItems.filter(({ itemType }) =>
|
|
86
|
-
[ItemType.ERC721, ItemType.ERC1155].includes(itemType)
|
|
86
|
+
[ItemType.ERC721, ItemType.ERC1155].includes(itemType),
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
const nftsWithCriteria = allItems.filter(({ itemType }) =>
|
|
90
|
-
isCriteriaItem(itemType)
|
|
90
|
+
isCriteriaItem(itemType),
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
const offersNativeCurrency = isNativeCurrencyItem(offer[0]);
|
|
@@ -109,7 +109,7 @@ export const shouldUseBasicFulfill = (
|
|
|
109
109
|
|
|
110
110
|
// 6. All individual items need to have the same startAmount and endAmount
|
|
111
111
|
const differentStartAndEndAmount = allItems.some(
|
|
112
|
-
({ startAmount, endAmount }) => startAmount !== endAmount
|
|
112
|
+
({ startAmount, endAmount }) => startAmount !== endAmount,
|
|
113
113
|
);
|
|
114
114
|
|
|
115
115
|
if (differentStartAndEndAmount) {
|
|
@@ -147,7 +147,7 @@ export const shouldUseBasicFulfill = (
|
|
|
147
147
|
.every(({ token }) => token === ethers.constants.AddressZero);
|
|
148
148
|
|
|
149
149
|
const currencyIdentifiersAreZero = currencies.every(
|
|
150
|
-
({ identifierOrCriteria }) => BigNumber.from(identifierOrCriteria).eq(0)
|
|
150
|
+
({ identifierOrCriteria }) => BigNumber.from(identifierOrCriteria).eq(0),
|
|
151
151
|
);
|
|
152
152
|
|
|
153
153
|
const erc721sAreSingleAmount = nfts
|
|
@@ -204,7 +204,7 @@ export function fulfillBasicOrder(
|
|
|
204
204
|
conduitKey: string;
|
|
205
205
|
domain?: string;
|
|
206
206
|
},
|
|
207
|
-
exactApproval: boolean
|
|
207
|
+
exactApproval: boolean,
|
|
208
208
|
): OrderUseCase<
|
|
209
209
|
ExchangeAction<ContractMethodReturnType<SeaportContract, "fulfillBasicOrder">>
|
|
210
210
|
> {
|
|
@@ -221,7 +221,7 @@ export function fulfillBasicOrder(
|
|
|
221
221
|
|
|
222
222
|
if (basicOrderRouteType === undefined) {
|
|
223
223
|
throw new Error(
|
|
224
|
-
"Order parameters did not result in a valid basic fulfillment"
|
|
224
|
+
"Order parameters did not result in a valid basic fulfillment",
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -229,11 +229,11 @@ export function fulfillBasicOrder(
|
|
|
229
229
|
({ startAmount, recipient }) => ({
|
|
230
230
|
amount: startAmount,
|
|
231
231
|
recipient,
|
|
232
|
-
})
|
|
232
|
+
}),
|
|
233
233
|
);
|
|
234
234
|
|
|
235
235
|
const considerationWithoutOfferItemType = considerationIncludingTips.filter(
|
|
236
|
-
(item) => item.itemType !== offer[0].itemType
|
|
236
|
+
(item) => item.itemType !== offer[0].itemType,
|
|
237
237
|
);
|
|
238
238
|
|
|
239
239
|
const totalNativeAmount = getSummedTokenAndIdentifierAmounts({
|
|
@@ -286,7 +286,7 @@ export function fulfillBasicOrder(
|
|
|
286
286
|
const approvalActions = getApprovalActions(
|
|
287
287
|
insufficientApprovals,
|
|
288
288
|
exactApproval,
|
|
289
|
-
signer
|
|
289
|
+
signer,
|
|
290
290
|
);
|
|
291
291
|
|
|
292
292
|
const exchangeAction = {
|
|
@@ -295,7 +295,7 @@ export function fulfillBasicOrder(
|
|
|
295
295
|
seaportContract.connect(signer),
|
|
296
296
|
"fulfillBasicOrder",
|
|
297
297
|
[basicOrderParameters, payableOverrides],
|
|
298
|
-
domain
|
|
298
|
+
domain,
|
|
299
299
|
),
|
|
300
300
|
} as const;
|
|
301
301
|
|
|
@@ -348,7 +348,7 @@ export function fulfillStandardOrder(
|
|
|
348
348
|
signer: Signer;
|
|
349
349
|
domain?: string;
|
|
350
350
|
},
|
|
351
|
-
exactApproval: boolean
|
|
351
|
+
exactApproval: boolean,
|
|
352
352
|
): OrderUseCase<
|
|
353
353
|
ExchangeAction<
|
|
354
354
|
ContractMethodReturnType<
|
|
@@ -377,11 +377,11 @@ export function fulfillStandardOrder(
|
|
|
377
377
|
const considerationIncludingTips = [...consideration, ...tips];
|
|
378
378
|
|
|
379
379
|
const offerCriteriaItems = offer.filter(({ itemType }) =>
|
|
380
|
-
isCriteriaItem(itemType)
|
|
380
|
+
isCriteriaItem(itemType),
|
|
381
381
|
);
|
|
382
382
|
|
|
383
383
|
const considerationCriteriaItems = considerationIncludingTips.filter(
|
|
384
|
-
({ itemType }) => isCriteriaItem(itemType)
|
|
384
|
+
({ itemType }) => isCriteriaItem(itemType),
|
|
385
385
|
);
|
|
386
386
|
|
|
387
387
|
const hasCriteriaItems =
|
|
@@ -392,7 +392,7 @@ export function fulfillStandardOrder(
|
|
|
392
392
|
considerationCriteriaItems.length !== considerationCriteria.length
|
|
393
393
|
) {
|
|
394
394
|
throw new Error(
|
|
395
|
-
"You must supply the appropriate criterias for criteria based items"
|
|
395
|
+
"You must supply the appropriate criterias for criteria based items",
|
|
396
396
|
);
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -422,7 +422,7 @@ export function fulfillStandardOrder(
|
|
|
422
422
|
const approvalActions = getApprovalActions(
|
|
423
423
|
insufficientApprovals,
|
|
424
424
|
exactApproval,
|
|
425
|
-
signer
|
|
425
|
+
signer,
|
|
426
426
|
);
|
|
427
427
|
|
|
428
428
|
const isGift = recipientAddress !== ethers.constants.AddressZero;
|
|
@@ -440,7 +440,7 @@ export function fulfillStandardOrder(
|
|
|
440
440
|
|
|
441
441
|
const { numerator, denominator } = getAdvancedOrderNumeratorDenominator(
|
|
442
442
|
order,
|
|
443
|
-
unitsToFill
|
|
443
|
+
unitsToFill,
|
|
444
444
|
);
|
|
445
445
|
|
|
446
446
|
const exchangeAction = {
|
|
@@ -467,13 +467,13 @@ export function fulfillStandardOrder(
|
|
|
467
467
|
recipientAddress,
|
|
468
468
|
payableOverrides,
|
|
469
469
|
],
|
|
470
|
-
domain
|
|
470
|
+
domain,
|
|
471
471
|
)
|
|
472
472
|
: getTransactionMethods(
|
|
473
473
|
seaportContract.connect(signer),
|
|
474
474
|
"fulfillOrder",
|
|
475
475
|
[orderAccountingForTips, conduitKey, payableOverrides],
|
|
476
|
-
domain
|
|
476
|
+
domain,
|
|
477
477
|
),
|
|
478
478
|
} as const;
|
|
479
479
|
|
|
@@ -488,7 +488,7 @@ export function fulfillStandardOrder(
|
|
|
488
488
|
|
|
489
489
|
export function validateAndSanitizeFromOrderStatus(
|
|
490
490
|
order: Order,
|
|
491
|
-
orderStatus: OrderStatus
|
|
491
|
+
orderStatus: OrderStatus,
|
|
492
492
|
): Order {
|
|
493
493
|
const { isValidated, isCancelled, totalFilled, totalSize } = orderStatus;
|
|
494
494
|
|
|
@@ -553,7 +553,7 @@ export function fulfillAvailableOrders({
|
|
|
553
553
|
...orderMetadata,
|
|
554
554
|
order: validateAndSanitizeFromOrderStatus(
|
|
555
555
|
orderMetadata.order,
|
|
556
|
-
orderMetadata.orderStatus
|
|
556
|
+
orderMetadata.orderStatus,
|
|
557
557
|
),
|
|
558
558
|
}));
|
|
559
559
|
|
|
@@ -572,7 +572,7 @@ export function fulfillAvailableOrders({
|
|
|
572
572
|
totalFilled: orderMetadata.orderStatus.totalFilled,
|
|
573
573
|
totalSize: orderMetadata.orderStatus.totalSize,
|
|
574
574
|
}),
|
|
575
|
-
})
|
|
575
|
+
}),
|
|
576
576
|
);
|
|
577
577
|
|
|
578
578
|
let totalNativeAmount = BigNumber.from(0);
|
|
@@ -588,12 +588,12 @@ export function fulfillAvailableOrders({
|
|
|
588
588
|
const hasCriteriaItems = criteriaOffersAndConsiderations.length > 0;
|
|
589
589
|
|
|
590
590
|
const addApprovalIfNeeded = (
|
|
591
|
-
orderInsufficientApprovals: InsufficientApprovals
|
|
591
|
+
orderInsufficientApprovals: InsufficientApprovals,
|
|
592
592
|
) => {
|
|
593
593
|
orderInsufficientApprovals.forEach((insufficientApproval) => {
|
|
594
594
|
if (
|
|
595
595
|
!totalInsufficientApprovals.find(
|
|
596
|
-
(approval) => approval.token === insufficientApproval.token
|
|
596
|
+
(approval) => approval.token === insufficientApproval.token,
|
|
597
597
|
)
|
|
598
598
|
) {
|
|
599
599
|
totalInsufficientApprovals.push(insufficientApproval);
|
|
@@ -628,7 +628,7 @@ export function fulfillAvailableOrders({
|
|
|
628
628
|
items: considerationIncludingTips,
|
|
629
629
|
criterias: considerationCriteria,
|
|
630
630
|
timeBasedItemParams,
|
|
631
|
-
})[ethers.constants.AddressZero]?.["0"] ?? BigNumber.from(0)
|
|
631
|
+
})[ethers.constants.AddressZero]?.["0"] ?? BigNumber.from(0),
|
|
632
632
|
);
|
|
633
633
|
|
|
634
634
|
const insufficientApprovals = validateStandardFulfillBalancesAndApprovals(
|
|
@@ -642,15 +642,15 @@ export function fulfillAvailableOrders({
|
|
|
642
642
|
timeBasedItemParams,
|
|
643
643
|
offererOperator,
|
|
644
644
|
fulfillerOperator,
|
|
645
|
-
}
|
|
645
|
+
},
|
|
646
646
|
);
|
|
647
647
|
|
|
648
648
|
const offerCriteriaItems = order.parameters.offer.filter(({ itemType }) =>
|
|
649
|
-
isCriteriaItem(itemType)
|
|
649
|
+
isCriteriaItem(itemType),
|
|
650
650
|
);
|
|
651
651
|
|
|
652
652
|
const considerationCriteriaItems = considerationIncludingTips.filter(
|
|
653
|
-
({ itemType }) => isCriteriaItem(itemType)
|
|
653
|
+
({ itemType }) => isCriteriaItem(itemType),
|
|
654
654
|
);
|
|
655
655
|
|
|
656
656
|
if (
|
|
@@ -658,12 +658,12 @@ export function fulfillAvailableOrders({
|
|
|
658
658
|
considerationCriteriaItems.length !== considerationCriteria.length
|
|
659
659
|
) {
|
|
660
660
|
throw new Error(
|
|
661
|
-
"You must supply the appropriate criterias for criteria based items"
|
|
661
|
+
"You must supply the appropriate criterias for criteria based items",
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
addApprovalIfNeeded(insufficientApprovals);
|
|
666
|
-
}
|
|
666
|
+
},
|
|
667
667
|
);
|
|
668
668
|
|
|
669
669
|
const payableOverrides = { value: totalNativeAmount };
|
|
@@ -671,14 +671,14 @@ export function fulfillAvailableOrders({
|
|
|
671
671
|
const approvalActions = getApprovalActions(
|
|
672
672
|
totalInsufficientApprovals,
|
|
673
673
|
exactApproval,
|
|
674
|
-
signer
|
|
674
|
+
signer,
|
|
675
675
|
);
|
|
676
676
|
|
|
677
677
|
const advancedOrdersWithTips: AdvancedOrder[] = sanitizedOrdersMetadata.map(
|
|
678
678
|
({ order, unitsToFill = 0, tips, extraData }) => {
|
|
679
679
|
const { numerator, denominator } = getAdvancedOrderNumeratorDenominator(
|
|
680
680
|
order,
|
|
681
|
-
unitsToFill
|
|
681
|
+
unitsToFill,
|
|
682
682
|
);
|
|
683
683
|
|
|
684
684
|
const considerationIncludingTips = [
|
|
@@ -697,7 +697,7 @@ export function fulfillAvailableOrders({
|
|
|
697
697
|
denominator,
|
|
698
698
|
extraData,
|
|
699
699
|
};
|
|
700
|
-
}
|
|
700
|
+
},
|
|
701
701
|
);
|
|
702
702
|
|
|
703
703
|
const { offerFulfillments, considerationFulfillments } =
|
|
@@ -714,10 +714,10 @@ export function fulfillAvailableOrders({
|
|
|
714
714
|
? generateCriteriaResolvers({
|
|
715
715
|
orders: ordersMetadata.map(({ order }) => order),
|
|
716
716
|
offerCriterias: ordersMetadata.map(
|
|
717
|
-
({ offerCriteria }) => offerCriteria
|
|
717
|
+
({ offerCriteria }) => offerCriteria,
|
|
718
718
|
),
|
|
719
719
|
considerationCriterias: ordersMetadata.map(
|
|
720
|
-
({ considerationCriteria }) => considerationCriteria
|
|
720
|
+
({ considerationCriteria }) => considerationCriteria,
|
|
721
721
|
),
|
|
722
722
|
})
|
|
723
723
|
: [],
|
|
@@ -728,7 +728,7 @@ export function fulfillAvailableOrders({
|
|
|
728
728
|
advancedOrdersWithTips.length,
|
|
729
729
|
payableOverrides,
|
|
730
730
|
],
|
|
731
|
-
domain
|
|
731
|
+
domain,
|
|
732
732
|
),
|
|
733
733
|
} as const;
|
|
734
734
|
|
|
@@ -742,7 +742,7 @@ export function fulfillAvailableOrders({
|
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
export function generateFulfillOrdersFulfillments(
|
|
745
|
-
ordersMetadata: FulfillOrdersMetadata
|
|
745
|
+
ordersMetadata: FulfillOrdersMetadata,
|
|
746
746
|
): {
|
|
747
747
|
offerFulfillments: FulfillmentComponentStruct[];
|
|
748
748
|
considerationFulfillments: FulfillmentComponentStruct[];
|
|
@@ -773,7 +773,7 @@ export function generateFulfillOrdersFulfillments(
|
|
|
773
773
|
({ order, offererOperator, offerCriteria }, orderIndex) => {
|
|
774
774
|
const itemToCriteria = getItemToCriteriaMap(
|
|
775
775
|
order.parameters.offer,
|
|
776
|
-
offerCriteria
|
|
776
|
+
offerCriteria,
|
|
777
777
|
);
|
|
778
778
|
|
|
779
779
|
return order.parameters.offer.forEach((item, itemIndex) => {
|
|
@@ -791,14 +791,14 @@ export function generateFulfillOrdersFulfillments(
|
|
|
791
791
|
{ orderIndex, itemIndex },
|
|
792
792
|
] as any;
|
|
793
793
|
});
|
|
794
|
-
}
|
|
794
|
+
},
|
|
795
795
|
);
|
|
796
796
|
|
|
797
797
|
ordersMetadata.forEach(
|
|
798
798
|
({ order, considerationCriteria, tips }, orderIndex) => {
|
|
799
799
|
const itemToCriteria = getItemToCriteriaMap(
|
|
800
800
|
order.parameters.consideration,
|
|
801
|
-
considerationCriteria
|
|
801
|
+
considerationCriteria,
|
|
802
802
|
);
|
|
803
803
|
return [...order.parameters.consideration, ...tips].forEach(
|
|
804
804
|
(item, itemIndex) => {
|
|
@@ -815,22 +815,22 @@ export function generateFulfillOrdersFulfillments(
|
|
|
815
815
|
[]) as any),
|
|
816
816
|
{ orderIndex, itemIndex },
|
|
817
817
|
] as any;
|
|
818
|
-
}
|
|
818
|
+
},
|
|
819
819
|
);
|
|
820
|
-
}
|
|
820
|
+
},
|
|
821
821
|
);
|
|
822
822
|
|
|
823
823
|
return {
|
|
824
824
|
offerFulfillments: Object.values(offerAggregatedFulfillments),
|
|
825
825
|
considerationFulfillments: Object.values(
|
|
826
|
-
considerationAggregatedFulfillments
|
|
826
|
+
considerationAggregatedFulfillments,
|
|
827
827
|
),
|
|
828
828
|
};
|
|
829
829
|
}
|
|
830
830
|
|
|
831
831
|
export const getAdvancedOrderNumeratorDenominator = (
|
|
832
832
|
order: Order,
|
|
833
|
-
unitsToFill?: BigNumberish
|
|
833
|
+
unitsToFill?: BigNumberish,
|
|
834
834
|
) => {
|
|
835
835
|
// Used for advanced order cases
|
|
836
836
|
const maxUnits = getMaximumSizeForOrder(order);
|
package/src/utils/item.ts
CHANGED
|
@@ -21,7 +21,7 @@ export const isErc1155Item = (itemType: Item["itemType"]) =>
|
|
|
21
21
|
|
|
22
22
|
export const isCriteriaItem = (itemType: Item["itemType"]) =>
|
|
23
23
|
[ItemType.ERC721_WITH_CRITERIA, ItemType.ERC1155_WITH_CRITERIA].includes(
|
|
24
|
-
itemType
|
|
24
|
+
itemType,
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
export type TimeBasedItemParams = {
|
|
@@ -57,7 +57,7 @@ export const getPresentItemAmount = ({
|
|
|
57
57
|
const adjustedBlockTimestamp = BigNumber.from(
|
|
58
58
|
isAscending
|
|
59
59
|
? currentBlockTimestamp + ascendingAmountTimestampBuffer
|
|
60
|
-
: currentBlockTimestamp
|
|
60
|
+
: currentBlockTimestamp,
|
|
61
61
|
);
|
|
62
62
|
|
|
63
63
|
if (adjustedBlockTimestamp.lt(startTime)) {
|
|
@@ -112,7 +112,7 @@ export const getSummedTokenAndIdentifierAmounts = ({
|
|
|
112
112
|
startAmount: item.startAmount,
|
|
113
113
|
endAmount: item.endAmount,
|
|
114
114
|
timeBasedItemParams,
|
|
115
|
-
})
|
|
115
|
+
}),
|
|
116
116
|
),
|
|
117
117
|
},
|
|
118
118
|
};
|