-
Notifications
You must be signed in to change notification settings - Fork 975
/
Copy pathtypes.ts
377 lines (358 loc) · 8.97 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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import { BigNumberish } from "ethers";
import type { OrderV2 } from "./orders/types";
/**
* Events emitted by the SDK which can be used by frontend applications
* to update state or show useful messages to users.
* @category Events
*/
export enum EventType {
/**
* Emitted when the transaction is sent to the network and the application
* is waiting for the transaction to be mined.
*/
TransactionCreated = "TransactionCreated",
/**
* Emitted when the transaction has succeeded is mined and confirmed.
*/
TransactionConfirmed = "TransactionConfirmed",
/**
* Emitted when the transaction has failed to be submitted.
*/
TransactionDenied = "TransactionDenied",
/**
* Emitted when the transaction has failed to be mined.
*/
TransactionFailed = "TransactionFailed",
/**
* Emitted when the {@link OpenSeaSDK.wrapEth} method is called.
*/
WrapEth = "WrapEth",
/**
* Emitted when the {@link OpenSeaSDK.unwrapWeth} method is called.
*/
UnwrapWeth = "UnwrapWeth",
/**
* Emitted when fulfilling a public or private order.
*/
MatchOrders = "MatchOrders",
/**
* Emitted when the {@link OpenSeaSDK.cancelOrder} method is called.
*/
CancelOrder = "CancelOrder",
/**
* Emitted when the {@link OpenSeaSDK.approveOrder} method is called.
*/
ApproveOrder = "ApproveOrder",
/**
* Emitted when the {@link OpenSeaSDK.transfer} method is called.
*/
Transfer = "Transfer",
}
/**
* Data that gets sent with each {@link EventType}
* @category Events
*/
export interface EventData {
/**
* Wallet address of the user who initiated the event.
*/
accountAddress?: string;
/**
* Amount of ETH sent when wrapping or unwrapping.
*/
amount?: BigNumberish;
/**
* The transaction hash of the event.
*/
transactionHash?: string;
/**
* The {@link EventType} of the event.
*/
event?: EventType;
/**
* Error which occurred when transaction was denied or failed.
*/
error?: unknown;
/**
* The {@link OrderV2} object.
*/
orderV2?: OrderV2;
}
/**
* OpenSea API configuration object
* @param chain `Chain` to use. Defaults to Ethereum Mainnet (`Chain.Mainnet`)
* @param apiKey API key to use. Not required for testnets
* @param apiBaseUrl Optional base URL to use for the API
*/
export interface OpenSeaAPIConfig {
chain?: Chain;
apiKey?: string;
apiBaseUrl?: string;
}
/**
* Each of the possible chains that OpenSea supports.
* ⚠️NOTE: When adding to this list, also add to the util functions `getChainId` and `getWETHAddress`
*/
export enum Chain {
// Mainnet Chains
/** Ethereum */
Mainnet = "ethereum",
/** Polygon */
Polygon = "matic",
/** Klaytn */
Klaytn = "klaytn",
/** Base */
Base = "base",
/** Blast */
Blast = "blast",
/** Arbitrum */
Arbitrum = "arbitrum",
/** Arbitrum Nova */
ArbitrumNova = "arbitrum_nova",
/** Avalanche */
Avalanche = "avalanche",
/** Optimism */
Optimism = "optimism",
/** Solana */
Solana = "solana",
/** Zora */
Zora = "zora",
/** Sei */
Sei = "sei",
/** B3 */
B3 = "b3",
// Testnet Chains
// ⚠️NOTE: When adding to this list, also add to the util function `isTestChain`
/** Sepolia */
Sepolia = "sepolia",
/** Polygon Amoy */
Amoy = "amoy",
/** Klaytn Baobab */
Baobab = "baobab",
/** Base Testnet */
BaseSepolia = "base_sepolia",
/** Blast Testnet */
BlastSepolia = "blast_sepolia",
/** Arbitrum Sepolia */
ArbitrumSepolia = "arbitrum_sepolia",
/** Avalanche Fuji */
Fuji = "avalanche_fuji",
/** Optimism Sepolia */
OptimismSepolia = "optimism_sepolia",
/** Solana Devnet */
SolanaDevnet = "soldev",
/** Zora Sepolia */
ZoraSepolia = "zora_sepolia",
/** Sei Testnet */
SeiTestnet = "sei_testnet",
/** B3 Sepolia */
B3Sepolia = "b3_sepolia",
}
/**
* Order side: listing (ask) or offer (bid)
*/
export enum OrderSide {
LISTING = "ask",
OFFER = "bid",
}
/**
* Token standards
*/
export enum TokenStandard {
ERC20 = "ERC20",
ERC721 = "ERC721",
ERC1155 = "ERC1155",
}
/**
* The collection's approval status within OpenSea.
* Can be one of:
* - not_requested: brand new collections
* - requested: collections that requested safelisting on our site
* - approved: collections that are approved on our site and can be found in search results
* - verified: verified collections
*/
export enum SafelistStatus {
NOT_REQUESTED = "not_requested",
REQUESTED = "requested",
APPROVED = "approved",
VERIFIED = "verified",
DISABLED_TOP_TRENDING = "disabled_top_trending",
}
/**
* Collection fees
* @category API Models
*/
export interface Fee {
fee: number;
recipient: string;
required: boolean;
}
/**
* Generic Blockchain Asset.
* @category API Models
*/
export interface Asset {
/** The asset's token ID, or null if ERC-20 */
tokenId: string | null;
/** The asset's contract address */
tokenAddress: string;
/** The token standard (e.g. "ERC721") for this asset */
tokenStandard?: TokenStandard;
/** Optional for ENS names */
name?: string;
/** Optional for fungible items */
decimals?: number;
}
/**
* Generic Blockchain Asset, with tokenId required.
* @category API Models
*/
export interface AssetWithTokenId extends Asset {
/** The asset's token ID */
tokenId: string;
}
/**
* Generic Blockchain Asset, with tokenStandard required.
* @category API Models
*/
export interface AssetWithTokenStandard extends Asset {
/** The token standard (e.g. "ERC721") for this asset */
tokenStandard: TokenStandard;
}
interface OpenSeaCollectionStatsIntervalData {
interval: "one_day" | "seven_day" | "thirty_day";
volume: number;
volume_diff: number;
volume_change: number;
sales: number;
sales_diff: number;
average_price: number;
}
/**
* OpenSea Collection Stats
* @category API Models
*/
export interface OpenSeaCollectionStats {
total: {
volume: number;
sales: number;
average_price: number;
num_owners: number;
market_cap: number;
floor_price: number;
floor_price_symbol: string;
};
intervals: OpenSeaCollectionStatsIntervalData[];
}
export interface RarityStrategy {
strategyId: string;
strategyVersion: string;
calculatedAt: string;
maxRank: number;
tokensScored: number;
}
/**
* OpenSea collection metadata.
* @category API Models
*/
export interface OpenSeaCollection {
/** Name of the collection */
name: string;
/** The identifier (slug) of the collection */
collection: string;
/** Description of the collection */
description: string;
/** Image for the collection */
imageUrl: string;
/** Banner image for the collection */
bannerImageUrl: string;
/** Owner address of the collection */
owner: string;
/** The collection's safelist status */
safelistStatus: SafelistStatus;
/** The category of the collection */
category: string;
/** If the collection is disabled */
isDisabled: boolean;
/** If the collection is NSFW (not safe for work) */
isNSFW: boolean;
/** If trait offers are enabled */
traitOffersEnabled: boolean;
/** If collection offers are enabled */
collectionOffersEnabled: boolean;
/** The OpenSea url for the collection */
openseaUrl: string;
/** The project url for the collection */
projectUrl: string;
/** The wiki url for the collection */
wikiUrl: string;
/** The discord url for the collection */
discordUrl: string;
/** The telegram url for the collection */
telegramUrl: string;
/** The twitter username for the collection */
twitterUsername: string;
/** The instagram username for the collection */
instagramUsername: string;
/** The contracts for the collection */
contracts: { address: string; chain: Chain }[];
/** Accounts allowed to edit this collection */
editors: string[];
/** The fees for the collection */
fees: Fee[];
/** The rarity strategy for the collection */
rarity: RarityStrategy | null;
/** Payment tokens allowed for orders for this collection */
paymentTokens: OpenSeaPaymentToken[];
/** The total supply of the collection (minted minus burned) */
totalSupply: number;
/** The created date of the collection */
createdDate: string;
/** When defined, the zone required for orders for the collection */
requiredZone?: string;
}
/**
* Full annotated Fungible Token spec with OpenSea metadata
*/
export interface OpenSeaPaymentToken {
name: string;
symbol: string;
decimals: number;
address: string;
chain: Chain;
imageUrl?: string;
ethPrice?: string;
usdPrice?: string;
}
/**
* Query interface for payment tokens
* @category API Models
*/
export interface OpenSeaPaymentTokensQuery {
symbol?: string;
address?: string;
limit?: number;
next?: string;
}
/**
* OpenSea Account
* @category API Models
*/
export interface OpenSeaAccount {
address: string;
username: string;
profileImageUrl: string;
bannerImageUrl: string;
website: string;
socialMediaAccounts: SocialMediaAccount[];
bio: string;
joinedDate: string;
}
/**
* Social media account
* @category API Models
*/
export interface SocialMediaAccount {
platform: string;
username: string;
}