-
Notifications
You must be signed in to change notification settings - Fork 182
/
Copy pathtypes.ts
240 lines (200 loc) · 5.81 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
import { BigNumberish, ContractTransaction } from "ethers";
import { ItemType, OrderType } from "./constants";
import type { TestERC20, TestERC721 } from "./typechain-types";
import { TransactionMethods } from "./utils/usecase";
import { Seaport as SeaportContract } from "./typechain-types/seaport/contracts/Seaport";
export type { SeaportContract };
export type SeaportConfig = {
// Used because fulfillments may be invalid if confirmations take too long. Default buffer is 5 minutes
ascendingAmountFulfillmentBuffer?: number;
// Allow users to optionally skip balance and approval checks on order creation
balanceAndApprovalChecksOnOrderCreation?: boolean;
// A mapping of conduit key to conduit
conduitKeyToConduit?: Record<string, string>;
overrides?: {
// The Seaport version to use
seaportVersion?: string;
// The Seaport contract address to use
contractAddress?: string;
// The domain registry address to use
domainRegistryAddress?: string;
// The default conduit key to use when creating and fulfilling orders
defaultConduitKey?: string;
};
};
export type OfferItem = {
itemType: ItemType;
token: string;
identifierOrCriteria: string;
startAmount: string;
endAmount: string;
};
export type ConsiderationItem = {
itemType: ItemType;
token: string;
identifierOrCriteria: string;
startAmount: string;
endAmount: string;
recipient: string;
};
export type Item = OfferItem | ConsiderationItem;
export type OrderParameters = {
offerer: string;
zone: string;
orderType: OrderType;
startTime: BigNumberish;
endTime: BigNumberish;
zoneHash: string;
salt: string;
offer: OfferItem[];
consideration: ConsiderationItem[];
totalOriginalConsiderationItems: BigNumberish;
conduitKey: string;
};
export type OrderComponents = OrderParameters & { counter: BigNumberish };
export type Order = {
parameters: OrderParameters;
signature: string;
};
export type AdvancedOrder = Order & {
numerator: bigint;
denominator: bigint;
extraData: string;
};
export type BasicErc721Item = {
itemType: ItemType.ERC721;
token: string;
identifier: string;
};
export type Erc721ItemWithCriteria = {
itemType: ItemType.ERC721;
token: string;
amount?: string;
endAmount?: string;
// Used for criteria based items i.e. offering to buy 5 NFTs for a collection
} & ({ identifiers: string[] } | { criteria: string });
type Erc721Item = BasicErc721Item | Erc721ItemWithCriteria;
export type BasicErc1155Item = {
itemType: ItemType.ERC1155;
token: string;
identifier: string;
amount: string;
endAmount?: string;
};
export type Erc1155ItemWithCriteria = {
itemType: ItemType.ERC1155;
token: string;
amount: string;
endAmount?: string;
} & ({ identifiers: string[] } | { criteria: string });
type Erc1155Item = BasicErc1155Item | Erc1155ItemWithCriteria;
export type CurrencyItem = {
token?: string;
amount: string;
endAmount?: string;
};
export type CreateInputItem = Erc721Item | Erc1155Item | CurrencyItem;
export type ConsiderationInputItem = CreateInputItem & { recipient?: string };
export type TipInputItem = CreateInputItem & { recipient: string };
export type Fee = {
recipient: string;
basisPoints: number;
};
export type CreateOrderInput = {
conduitKey?: string;
zone?: string;
zoneHash?: string;
startTime?: BigNumberish;
endTime?: BigNumberish;
offer: readonly CreateInputItem[];
consideration: readonly ConsiderationInputItem[];
counter?: BigNumberish;
fees?: readonly Fee[];
allowPartialFills?: boolean;
restrictedByZone?: boolean;
domain?: string;
salt?: BigNumberish;
};
export type InputCriteria = {
identifier: string;
proof: string[];
};
export type OrderStatus = {
isValidated: boolean;
isCancelled: boolean;
totalFilled: bigint;
totalSize: bigint;
};
export type OrderWithCounter = {
parameters: OrderComponents;
signature: string;
};
export type ApprovalAction = {
type: "approval";
token: string;
identifierOrCriteria: string;
itemType: ItemType;
operator: string;
transactionMethods: TransactionMethods<
TestERC721["setApprovalForAll"] | TestERC20["approve"]
>;
};
export type ExchangeAction<T = unknown> = {
type: "exchange";
transactionMethods: TransactionMethods<T>;
};
export type CreateOrderAction = {
type: "create";
getMessageToSign: () => Promise<string>;
createOrder: () => Promise<OrderWithCounter>;
};
export type CreateBulkOrdersAction = {
type: "createBulk";
getMessageToSign: () => Promise<string>;
createBulkOrders: () => Promise<OrderWithCounter[]>;
};
export type TransactionAction = ApprovalAction | ExchangeAction;
export type CreateOrderActions = readonly [
...ApprovalAction[],
CreateOrderAction,
];
export type CreateBulkOrdersActions = readonly [
...ApprovalAction[],
CreateBulkOrdersAction,
];
export type OrderExchangeActions<T> = readonly [
...ApprovalAction[],
ExchangeAction<T>,
];
export type OrderUseCase<
T extends CreateOrderAction | CreateBulkOrdersAction | ExchangeAction,
> = {
actions: T extends CreateOrderAction
? CreateOrderActions
: T extends CreateBulkOrdersAction
? CreateBulkOrdersActions
: OrderExchangeActions<T extends ExchangeAction<infer U> ? U : never>;
executeAllActions: () => Promise<
T extends CreateOrderAction
? OrderWithCounter
: T extends CreateBulkOrdersAction
? OrderWithCounter[]
: ContractTransaction
>;
};
export type FulfillmentComponent = {
orderIndex: number;
itemIndex: number;
}[];
export type Fulfillment = {
offerComponents: FulfillmentComponent[];
considerationComponents: FulfillmentComponent[];
};
type MatchOrdersFulfillmentComponent = {
orderIndex: number;
itemIndex: number;
};
export type MatchOrdersFulfillment = {
offerComponents: MatchOrdersFulfillmentComponent[];
considerationComponents: MatchOrdersFulfillmentComponent[];
};