@imtbl/sdk 0.1.7 → 0.1.8-alpha.1
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/dist/blockchain-data.d.ts +1598 -0
- package/dist/blockchain-data.js +1258 -0
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +967 -0
- package/dist/checkout_sdk.js +752 -0
- package/dist/checkout_widgets.d.ts +15428 -0
- package/dist/checkout_widgets.js +281 -0
- package/dist/erc20.d.ts +3 -0
- package/dist/erc20.js +4 -0
- package/dist/erc721-permissioned-mintable.d.ts +3 -0
- package/dist/erc721-permissioned-mintable.js +4 -0
- package/dist/immutablex_client.js +15 -6
- package/dist/index.cjs +5781 -1594
- package/dist/index.d.ts +23513 -6293
- package/dist/index.js +5763 -1592
- package/dist/orderbook.d.ts +64 -0
- package/dist/orderbook.js +1913 -0
- package/dist/passport.d.ts +1 -0
- package/dist/passport.js +93 -102
- package/package.json +34 -2
|
@@ -0,0 +1,1913 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import FormData from 'form-data';
|
|
3
|
+
import { utils, Contract, BigNumber, constants } from 'ethers';
|
|
4
|
+
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
5
|
+
|
|
6
|
+
class BaseHttpRequest {
|
|
7
|
+
config;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
class ApiError extends Error {
|
|
14
|
+
url;
|
|
15
|
+
status;
|
|
16
|
+
statusText;
|
|
17
|
+
body;
|
|
18
|
+
request;
|
|
19
|
+
constructor(request, response, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = 'ApiError';
|
|
22
|
+
this.url = response.url;
|
|
23
|
+
this.status = response.status;
|
|
24
|
+
this.statusText = response.statusText;
|
|
25
|
+
this.body = response.body;
|
|
26
|
+
this.request = request;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* istanbul ignore file */
|
|
31
|
+
/* tslint:disable */
|
|
32
|
+
/* eslint-disable */
|
|
33
|
+
class CancelError extends Error {
|
|
34
|
+
constructor(message) {
|
|
35
|
+
super(message);
|
|
36
|
+
this.name = 'CancelError';
|
|
37
|
+
}
|
|
38
|
+
get isCancelled() {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class CancelablePromise {
|
|
43
|
+
[Symbol.toStringTag];
|
|
44
|
+
_isResolved;
|
|
45
|
+
_isRejected;
|
|
46
|
+
_isCancelled;
|
|
47
|
+
_cancelHandlers;
|
|
48
|
+
_promise;
|
|
49
|
+
_resolve;
|
|
50
|
+
_reject;
|
|
51
|
+
constructor(executor) {
|
|
52
|
+
this._isResolved = false;
|
|
53
|
+
this._isRejected = false;
|
|
54
|
+
this._isCancelled = false;
|
|
55
|
+
this._cancelHandlers = [];
|
|
56
|
+
this._promise = new Promise((resolve, reject) => {
|
|
57
|
+
this._resolve = resolve;
|
|
58
|
+
this._reject = reject;
|
|
59
|
+
const onResolve = (value) => {
|
|
60
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this._isResolved = true;
|
|
64
|
+
this._resolve?.(value);
|
|
65
|
+
};
|
|
66
|
+
const onReject = (reason) => {
|
|
67
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this._isRejected = true;
|
|
71
|
+
this._reject?.(reason);
|
|
72
|
+
};
|
|
73
|
+
const onCancel = (cancelHandler) => {
|
|
74
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this._cancelHandlers.push(cancelHandler);
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
80
|
+
get: () => this._isResolved,
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
83
|
+
get: () => this._isRejected,
|
|
84
|
+
});
|
|
85
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
86
|
+
get: () => this._isCancelled,
|
|
87
|
+
});
|
|
88
|
+
return executor(onResolve, onReject, onCancel);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
then(onFulfilled, onRejected) {
|
|
92
|
+
return this._promise.then(onFulfilled, onRejected);
|
|
93
|
+
}
|
|
94
|
+
catch(onRejected) {
|
|
95
|
+
return this._promise.catch(onRejected);
|
|
96
|
+
}
|
|
97
|
+
finally(onFinally) {
|
|
98
|
+
return this._promise.finally(onFinally);
|
|
99
|
+
}
|
|
100
|
+
cancel() {
|
|
101
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
this._isCancelled = true;
|
|
105
|
+
if (this._cancelHandlers.length) {
|
|
106
|
+
try {
|
|
107
|
+
for (const cancelHandler of this._cancelHandlers) {
|
|
108
|
+
cancelHandler();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.warn('Cancellation threw an error', error);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
this._cancelHandlers.length = 0;
|
|
117
|
+
this._reject?.(new CancelError('Request aborted'));
|
|
118
|
+
}
|
|
119
|
+
get isCancelled() {
|
|
120
|
+
return this._isCancelled;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* istanbul ignore file */
|
|
125
|
+
/* tslint:disable */
|
|
126
|
+
/* eslint-disable */
|
|
127
|
+
const isDefined = (value) => {
|
|
128
|
+
return value !== undefined && value !== null;
|
|
129
|
+
};
|
|
130
|
+
const isString = (value) => {
|
|
131
|
+
return typeof value === 'string';
|
|
132
|
+
};
|
|
133
|
+
const isStringWithValue = (value) => {
|
|
134
|
+
return isString(value) && value !== '';
|
|
135
|
+
};
|
|
136
|
+
const isBlob = (value) => {
|
|
137
|
+
return (typeof value === 'object' &&
|
|
138
|
+
typeof value.type === 'string' &&
|
|
139
|
+
typeof value.stream === 'function' &&
|
|
140
|
+
typeof value.arrayBuffer === 'function' &&
|
|
141
|
+
typeof value.constructor === 'function' &&
|
|
142
|
+
typeof value.constructor.name === 'string' &&
|
|
143
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
144
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
145
|
+
};
|
|
146
|
+
const isFormData = (value) => {
|
|
147
|
+
return value instanceof FormData;
|
|
148
|
+
};
|
|
149
|
+
const isSuccess = (status) => {
|
|
150
|
+
return status >= 200 && status < 300;
|
|
151
|
+
};
|
|
152
|
+
const base64 = (str) => {
|
|
153
|
+
try {
|
|
154
|
+
return btoa(str);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
return Buffer.from(str).toString('base64');
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const getQueryString = (params) => {
|
|
162
|
+
const qs = [];
|
|
163
|
+
const append = (key, value) => {
|
|
164
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
165
|
+
};
|
|
166
|
+
const process = (key, value) => {
|
|
167
|
+
if (isDefined(value)) {
|
|
168
|
+
if (Array.isArray(value)) {
|
|
169
|
+
value.forEach(v => {
|
|
170
|
+
process(key, v);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (typeof value === 'object') {
|
|
174
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
175
|
+
process(`${key}[${k}]`, v);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
append(key, value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
184
|
+
process(key, value);
|
|
185
|
+
});
|
|
186
|
+
if (qs.length > 0) {
|
|
187
|
+
return `?${qs.join('&')}`;
|
|
188
|
+
}
|
|
189
|
+
return '';
|
|
190
|
+
};
|
|
191
|
+
const getUrl = (config, options) => {
|
|
192
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
193
|
+
const path = options.url
|
|
194
|
+
.replace('{api-version}', config.VERSION)
|
|
195
|
+
.replace(/{(.*?)}/g, (substring, group) => {
|
|
196
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
197
|
+
return encoder(String(options.path[group]));
|
|
198
|
+
}
|
|
199
|
+
return substring;
|
|
200
|
+
});
|
|
201
|
+
const url = `${config.BASE}${path}`;
|
|
202
|
+
if (options.query) {
|
|
203
|
+
return `${url}${getQueryString(options.query)}`;
|
|
204
|
+
}
|
|
205
|
+
return url;
|
|
206
|
+
};
|
|
207
|
+
const getFormData = (options) => {
|
|
208
|
+
if (options.formData) {
|
|
209
|
+
const formData = new FormData();
|
|
210
|
+
const process = (key, value) => {
|
|
211
|
+
if (isString(value) || isBlob(value)) {
|
|
212
|
+
formData.append(key, value);
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
formData.append(key, JSON.stringify(value));
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
Object.entries(options.formData)
|
|
219
|
+
.filter(([_, value]) => isDefined(value))
|
|
220
|
+
.forEach(([key, value]) => {
|
|
221
|
+
if (Array.isArray(value)) {
|
|
222
|
+
value.forEach(v => process(key, v));
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
process(key, value);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
return formData;
|
|
229
|
+
}
|
|
230
|
+
return undefined;
|
|
231
|
+
};
|
|
232
|
+
const resolve = async (options, resolver) => {
|
|
233
|
+
if (typeof resolver === 'function') {
|
|
234
|
+
return resolver(options);
|
|
235
|
+
}
|
|
236
|
+
return resolver;
|
|
237
|
+
};
|
|
238
|
+
const getHeaders = async (config, options, formData) => {
|
|
239
|
+
const token = await resolve(options, config.TOKEN);
|
|
240
|
+
const username = await resolve(options, config.USERNAME);
|
|
241
|
+
const password = await resolve(options, config.PASSWORD);
|
|
242
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
243
|
+
const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {};
|
|
244
|
+
const headers = Object.entries({
|
|
245
|
+
Accept: 'application/json',
|
|
246
|
+
...additionalHeaders,
|
|
247
|
+
...options.headers,
|
|
248
|
+
...formHeaders,
|
|
249
|
+
})
|
|
250
|
+
.filter(([_, value]) => isDefined(value))
|
|
251
|
+
.reduce((headers, [key, value]) => ({
|
|
252
|
+
...headers,
|
|
253
|
+
[key]: String(value),
|
|
254
|
+
}), {});
|
|
255
|
+
if (isStringWithValue(token)) {
|
|
256
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
257
|
+
}
|
|
258
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
259
|
+
const credentials = base64(`${username}:${password}`);
|
|
260
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
261
|
+
}
|
|
262
|
+
if (options.body) {
|
|
263
|
+
if (options.mediaType) {
|
|
264
|
+
headers['Content-Type'] = options.mediaType;
|
|
265
|
+
}
|
|
266
|
+
else if (isBlob(options.body)) {
|
|
267
|
+
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
268
|
+
}
|
|
269
|
+
else if (isString(options.body)) {
|
|
270
|
+
headers['Content-Type'] = 'text/plain';
|
|
271
|
+
}
|
|
272
|
+
else if (!isFormData(options.body)) {
|
|
273
|
+
headers['Content-Type'] = 'application/json';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return headers;
|
|
277
|
+
};
|
|
278
|
+
const getRequestBody = (options) => {
|
|
279
|
+
if (options.body) {
|
|
280
|
+
return options.body;
|
|
281
|
+
}
|
|
282
|
+
return undefined;
|
|
283
|
+
};
|
|
284
|
+
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
285
|
+
const source = axios.CancelToken.source();
|
|
286
|
+
const requestConfig = {
|
|
287
|
+
url,
|
|
288
|
+
headers,
|
|
289
|
+
data: body ?? formData,
|
|
290
|
+
method: options.method,
|
|
291
|
+
withCredentials: config.WITH_CREDENTIALS,
|
|
292
|
+
cancelToken: source.token,
|
|
293
|
+
};
|
|
294
|
+
onCancel(() => source.cancel('The user aborted a request.'));
|
|
295
|
+
try {
|
|
296
|
+
return await axios.request(requestConfig);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
const axiosError = error;
|
|
300
|
+
if (axiosError.response) {
|
|
301
|
+
return axiosError.response;
|
|
302
|
+
}
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
const getResponseHeader = (response, responseHeader) => {
|
|
307
|
+
if (responseHeader) {
|
|
308
|
+
const content = response.headers[responseHeader];
|
|
309
|
+
if (isString(content)) {
|
|
310
|
+
return content;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return undefined;
|
|
314
|
+
};
|
|
315
|
+
const getResponseBody = (response) => {
|
|
316
|
+
if (response.status !== 204) {
|
|
317
|
+
return response.data;
|
|
318
|
+
}
|
|
319
|
+
return undefined;
|
|
320
|
+
};
|
|
321
|
+
const catchErrorCodes = (options, result) => {
|
|
322
|
+
const errors = {
|
|
323
|
+
400: 'Bad Request',
|
|
324
|
+
401: 'Unauthorized',
|
|
325
|
+
403: 'Forbidden',
|
|
326
|
+
404: 'Not Found',
|
|
327
|
+
500: 'Internal Server Error',
|
|
328
|
+
502: 'Bad Gateway',
|
|
329
|
+
503: 'Service Unavailable',
|
|
330
|
+
...options.errors,
|
|
331
|
+
};
|
|
332
|
+
const error = errors[result.status];
|
|
333
|
+
if (error) {
|
|
334
|
+
throw new ApiError(options, result, error);
|
|
335
|
+
}
|
|
336
|
+
if (!result.ok) {
|
|
337
|
+
throw new ApiError(options, result, 'Generic Error');
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* Request method
|
|
342
|
+
* @param config The OpenAPI configuration object
|
|
343
|
+
* @param options The request options from the service
|
|
344
|
+
* @returns CancelablePromise<T>
|
|
345
|
+
* @throws ApiError
|
|
346
|
+
*/
|
|
347
|
+
const request = (config, options) => {
|
|
348
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
349
|
+
try {
|
|
350
|
+
const url = getUrl(config, options);
|
|
351
|
+
const formData = getFormData(options);
|
|
352
|
+
const body = getRequestBody(options);
|
|
353
|
+
const headers = await getHeaders(config, options, formData);
|
|
354
|
+
if (!onCancel.isCancelled) {
|
|
355
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
356
|
+
const responseBody = getResponseBody(response);
|
|
357
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
358
|
+
const result = {
|
|
359
|
+
url,
|
|
360
|
+
ok: isSuccess(response.status),
|
|
361
|
+
status: response.status,
|
|
362
|
+
statusText: response.statusText,
|
|
363
|
+
body: responseHeader ?? responseBody,
|
|
364
|
+
};
|
|
365
|
+
catchErrorCodes(options, result);
|
|
366
|
+
resolve(result.body);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
catch (error) {
|
|
370
|
+
reject(error);
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
class AxiosHttpRequest extends BaseHttpRequest {
|
|
376
|
+
constructor(config) {
|
|
377
|
+
super(config);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Request method
|
|
381
|
+
* @param options The request options from the service
|
|
382
|
+
* @returns CancelablePromise<T>
|
|
383
|
+
* @throws ApiError
|
|
384
|
+
*/
|
|
385
|
+
request(options) {
|
|
386
|
+
return request(this.config, options);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
class OrdersService {
|
|
391
|
+
httpRequest;
|
|
392
|
+
constructor(httpRequest) {
|
|
393
|
+
this.httpRequest = httpRequest;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* List all orders
|
|
397
|
+
* List all orders
|
|
398
|
+
* @returns ListOrdersResult OK response.
|
|
399
|
+
* @throws ApiError
|
|
400
|
+
*/
|
|
401
|
+
listOrders({ chainId, status, sellItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
402
|
+
return this.httpRequest.request({
|
|
403
|
+
method: 'GET',
|
|
404
|
+
url: '/v1/chains/{chain_id}/orders',
|
|
405
|
+
path: {
|
|
406
|
+
'chain_id': chainId,
|
|
407
|
+
},
|
|
408
|
+
query: {
|
|
409
|
+
'status': status,
|
|
410
|
+
'sell_item_contract_address': sellItemContractAddress,
|
|
411
|
+
'sell_item_token_id': sellItemTokenId,
|
|
412
|
+
'page_size': pageSize,
|
|
413
|
+
'sort_by': sortBy,
|
|
414
|
+
'sort_direction': sortDirection,
|
|
415
|
+
'page_cursor': pageCursor,
|
|
416
|
+
},
|
|
417
|
+
errors: {
|
|
418
|
+
400: `Client error`,
|
|
419
|
+
404: `The specified resource was not found`,
|
|
420
|
+
500: `Internal server error`,
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Create an order
|
|
426
|
+
* Create an order
|
|
427
|
+
* @returns OrderResult Created response.
|
|
428
|
+
* @throws ApiError
|
|
429
|
+
*/
|
|
430
|
+
createOrder({ chainId, requestBody, }) {
|
|
431
|
+
return this.httpRequest.request({
|
|
432
|
+
method: 'POST',
|
|
433
|
+
url: '/v1/chains/{chain_id}/orders',
|
|
434
|
+
path: {
|
|
435
|
+
'chain_id': chainId,
|
|
436
|
+
},
|
|
437
|
+
body: requestBody,
|
|
438
|
+
mediaType: 'application/json',
|
|
439
|
+
errors: {
|
|
440
|
+
400: `Client error`,
|
|
441
|
+
404: `The specified resource was not found`,
|
|
442
|
+
500: `Internal server error`,
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Get a single order by ID
|
|
448
|
+
* Get a single order by ID
|
|
449
|
+
* @returns OrderResult OK response.
|
|
450
|
+
* @throws ApiError
|
|
451
|
+
*/
|
|
452
|
+
getOrder({ chainId, orderId, }) {
|
|
453
|
+
return this.httpRequest.request({
|
|
454
|
+
method: 'GET',
|
|
455
|
+
url: '/v1/chains/{chain_id}/orders/{order_id}',
|
|
456
|
+
path: {
|
|
457
|
+
'chain_id': chainId,
|
|
458
|
+
'order_id': orderId,
|
|
459
|
+
},
|
|
460
|
+
errors: {
|
|
461
|
+
400: `Client error`,
|
|
462
|
+
404: `The specified resource was not found`,
|
|
463
|
+
500: `Internal server error`,
|
|
464
|
+
},
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
class OrderBookClient {
|
|
470
|
+
orders;
|
|
471
|
+
request;
|
|
472
|
+
constructor(config, HttpRequest = AxiosHttpRequest) {
|
|
473
|
+
this.request = new HttpRequest({
|
|
474
|
+
BASE: config?.BASE ?? 'https://order-book-mr.dev.imtbl.com',
|
|
475
|
+
VERSION: config?.VERSION ?? '1.0.0',
|
|
476
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
477
|
+
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
478
|
+
TOKEN: config?.TOKEN,
|
|
479
|
+
USERNAME: config?.USERNAME,
|
|
480
|
+
PASSWORD: config?.PASSWORD,
|
|
481
|
+
HEADERS: config?.HEADERS,
|
|
482
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
483
|
+
});
|
|
484
|
+
this.orders = new OrdersService(this.request);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/* istanbul ignore file */
|
|
489
|
+
/* tslint:disable */
|
|
490
|
+
/* eslint-disable */
|
|
491
|
+
var BuyItem;
|
|
492
|
+
(function (BuyItem) {
|
|
493
|
+
(function (item_type) {
|
|
494
|
+
item_type["NATIVE"] = "NATIVE";
|
|
495
|
+
item_type["ERC20"] = "ERC20";
|
|
496
|
+
})(BuyItem.item_type || (BuyItem.item_type = {}));
|
|
497
|
+
})(BuyItem || (BuyItem = {}));
|
|
498
|
+
|
|
499
|
+
/* istanbul ignore file */
|
|
500
|
+
/* tslint:disable */
|
|
501
|
+
/* eslint-disable */
|
|
502
|
+
var CreateOrderProtocolData;
|
|
503
|
+
(function (CreateOrderProtocolData) {
|
|
504
|
+
(function (order_type) {
|
|
505
|
+
order_type["FULL_RESTRICTED"] = "FULL_RESTRICTED";
|
|
506
|
+
})(CreateOrderProtocolData.order_type || (CreateOrderProtocolData.order_type = {}));
|
|
507
|
+
})(CreateOrderProtocolData || (CreateOrderProtocolData = {}));
|
|
508
|
+
|
|
509
|
+
/* istanbul ignore file */
|
|
510
|
+
/* tslint:disable */
|
|
511
|
+
/* eslint-disable */
|
|
512
|
+
var Fee;
|
|
513
|
+
(function (Fee) {
|
|
514
|
+
(function (fee_type) {
|
|
515
|
+
fee_type["ROYALTY"] = "ROYALTY";
|
|
516
|
+
})(Fee.fee_type || (Fee.fee_type = {}));
|
|
517
|
+
})(Fee || (Fee = {}));
|
|
518
|
+
|
|
519
|
+
/* istanbul ignore file */
|
|
520
|
+
/* tslint:disable */
|
|
521
|
+
/* eslint-disable */
|
|
522
|
+
/**
|
|
523
|
+
* The Order status
|
|
524
|
+
*/
|
|
525
|
+
var OrderStatus;
|
|
526
|
+
(function (OrderStatus) {
|
|
527
|
+
OrderStatus["PENDING"] = "PENDING";
|
|
528
|
+
OrderStatus["ACTIVE"] = "ACTIVE";
|
|
529
|
+
OrderStatus["INACTIVE"] = "INACTIVE";
|
|
530
|
+
OrderStatus["FILLED"] = "FILLED";
|
|
531
|
+
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
532
|
+
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
533
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
534
|
+
|
|
535
|
+
/* istanbul ignore file */
|
|
536
|
+
/* tslint:disable */
|
|
537
|
+
/* eslint-disable */
|
|
538
|
+
var SellItem;
|
|
539
|
+
(function (SellItem) {
|
|
540
|
+
(function (item_type) {
|
|
541
|
+
item_type["ERC721"] = "ERC721";
|
|
542
|
+
})(SellItem.item_type || (SellItem.item_type = {}));
|
|
543
|
+
})(SellItem || (SellItem = {}));
|
|
544
|
+
|
|
545
|
+
/* eslint-disable */
|
|
546
|
+
// TODO: Resolve these from seaport-js.
|
|
547
|
+
// There is some bundling issue that is preventing this from working
|
|
548
|
+
const SEAPORT_CONTRACT_NAME = 'Seaport';
|
|
549
|
+
const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
550
|
+
const EIP_712_ORDER_TYPE = {
|
|
551
|
+
OrderComponents: [
|
|
552
|
+
{ name: 'offerer', type: 'address' },
|
|
553
|
+
{ name: 'zone', type: 'address' },
|
|
554
|
+
{ name: 'offer', type: 'OfferItem[]' },
|
|
555
|
+
{ name: 'consideration', type: 'ConsiderationItem[]' },
|
|
556
|
+
{ name: 'orderType', type: 'uint8' },
|
|
557
|
+
{ name: 'startTime', type: 'uint256' },
|
|
558
|
+
{ name: 'endTime', type: 'uint256' },
|
|
559
|
+
{ name: 'zoneHash', type: 'bytes32' },
|
|
560
|
+
{ name: 'salt', type: 'uint256' },
|
|
561
|
+
{ name: 'conduitKey', type: 'bytes32' },
|
|
562
|
+
{ name: 'counter', type: 'uint256' },
|
|
563
|
+
],
|
|
564
|
+
OfferItem: [
|
|
565
|
+
{ name: 'itemType', type: 'uint8' },
|
|
566
|
+
{ name: 'token', type: 'address' },
|
|
567
|
+
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
568
|
+
{ name: 'startAmount', type: 'uint256' },
|
|
569
|
+
{ name: 'endAmount', type: 'uint256' },
|
|
570
|
+
],
|
|
571
|
+
ConsiderationItem: [
|
|
572
|
+
{ name: 'itemType', type: 'uint8' },
|
|
573
|
+
{ name: 'token', type: 'address' },
|
|
574
|
+
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
575
|
+
{ name: 'startAmount', type: 'uint256' },
|
|
576
|
+
{ name: 'endAmount', type: 'uint256' },
|
|
577
|
+
{ name: 'recipient', type: 'address' },
|
|
578
|
+
],
|
|
579
|
+
};
|
|
580
|
+
var OrderType;
|
|
581
|
+
(function (OrderType) {
|
|
582
|
+
OrderType[OrderType["FULL_OPEN"] = 0] = "FULL_OPEN";
|
|
583
|
+
OrderType[OrderType["PARTIAL_OPEN"] = 1] = "PARTIAL_OPEN";
|
|
584
|
+
OrderType[OrderType["FULL_RESTRICTED"] = 2] = "FULL_RESTRICTED";
|
|
585
|
+
OrderType[OrderType["PARTIAL_RESTRICTED"] = 3] = "PARTIAL_RESTRICTED";
|
|
586
|
+
})(OrderType || (OrderType = {}));
|
|
587
|
+
var ItemType;
|
|
588
|
+
(function (ItemType) {
|
|
589
|
+
ItemType[ItemType["NATIVE"] = 0] = "NATIVE";
|
|
590
|
+
ItemType[ItemType["ERC20"] = 1] = "ERC20";
|
|
591
|
+
ItemType[ItemType["ERC721"] = 2] = "ERC721";
|
|
592
|
+
ItemType[ItemType["ERC1155"] = 3] = "ERC1155";
|
|
593
|
+
ItemType[ItemType["ERC721_WITH_CRITERIA"] = 4] = "ERC721_WITH_CRITERIA";
|
|
594
|
+
ItemType[ItemType["ERC1155_WITH_CRITERIA"] = 5] = "ERC1155_WITH_CRITERIA";
|
|
595
|
+
})(ItemType || (ItemType = {}));
|
|
596
|
+
var Side;
|
|
597
|
+
(function (Side) {
|
|
598
|
+
Side[Side["OFFER"] = 0] = "OFFER";
|
|
599
|
+
Side[Side["CONSIDERATION"] = 1] = "CONSIDERATION";
|
|
600
|
+
})(Side || (Side = {}));
|
|
601
|
+
var BasicOrderRouteType;
|
|
602
|
+
(function (BasicOrderRouteType) {
|
|
603
|
+
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC721"] = 0] = "ETH_TO_ERC721";
|
|
604
|
+
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC1155"] = 1] = "ETH_TO_ERC1155";
|
|
605
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC721"] = 2] = "ERC20_TO_ERC721";
|
|
606
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC1155"] = 3] = "ERC20_TO_ERC1155";
|
|
607
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC721_TO_ERC20"] = 4] = "ERC721_TO_ERC20";
|
|
608
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC1155_TO_ERC20"] = 5] = "ERC1155_TO_ERC20";
|
|
609
|
+
})(BasicOrderRouteType || (BasicOrderRouteType = {}));
|
|
610
|
+
|
|
611
|
+
function getOrderComponentsFromMessage(orderMessage) {
|
|
612
|
+
const data = JSON.parse(orderMessage);
|
|
613
|
+
const orderComponents = data.message;
|
|
614
|
+
orderComponents.salt = BigNumber.from(orderComponents.salt).toHexString();
|
|
615
|
+
return orderComponents;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// Add 20% more gas than estimate to prevent out of gas errors
|
|
619
|
+
// This can always be overwritten by the user signing the transaction
|
|
620
|
+
async function prepareTransaction(transactionMethods) {
|
|
621
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
622
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
623
|
+
transaction.gasLimit = transaction.gasLimit
|
|
624
|
+
.add(transaction.gasLimit.div(5));
|
|
625
|
+
return transaction;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
629
|
+
const considerationItems = order.buy.map((buyItem) => ({
|
|
630
|
+
startAmount: buyItem.start_amount,
|
|
631
|
+
endAmount: buyItem.start_amount,
|
|
632
|
+
itemType: buyItem.item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
633
|
+
recipient: order.account_address,
|
|
634
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
635
|
+
identifierOrCriteria: '0',
|
|
636
|
+
}));
|
|
637
|
+
const fees = order.buy_fees.map((fee) => ({
|
|
638
|
+
startAmount: fee.amount,
|
|
639
|
+
endAmount: fee.amount,
|
|
640
|
+
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
641
|
+
recipient: fee.recipient,
|
|
642
|
+
token: order.buy[0].contract_address || constants.AddressZero,
|
|
643
|
+
identifierOrCriteria: '0',
|
|
644
|
+
}));
|
|
645
|
+
return {
|
|
646
|
+
conduitKey: constants.HashZero,
|
|
647
|
+
consideration: [...considerationItems, ...fees],
|
|
648
|
+
offer: order.sell.map((sellItem) => ({
|
|
649
|
+
startAmount: '1',
|
|
650
|
+
endAmount: '1',
|
|
651
|
+
itemType: ItemType.ERC721,
|
|
652
|
+
token: sellItem.contract_address,
|
|
653
|
+
identifierOrCriteria: sellItem.token_id,
|
|
654
|
+
})),
|
|
655
|
+
counter,
|
|
656
|
+
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
|
|
657
|
+
startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
|
|
658
|
+
salt: order.salt,
|
|
659
|
+
offerer: order.account_address,
|
|
660
|
+
zone: zoneAddress,
|
|
661
|
+
totalOriginalConsiderationItems: 2,
|
|
662
|
+
orderType: OrderType.FULL_RESTRICTED,
|
|
663
|
+
zoneHash: constants.HashZero,
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
class Seaport {
|
|
668
|
+
seaport;
|
|
669
|
+
provider;
|
|
670
|
+
seaportContractAddress;
|
|
671
|
+
zoneContractAddress;
|
|
672
|
+
constructor(seaport, provider, seaportContractAddress, zoneContractAddress) {
|
|
673
|
+
this.seaport = seaport;
|
|
674
|
+
this.provider = provider;
|
|
675
|
+
this.seaportContractAddress = seaportContractAddress;
|
|
676
|
+
this.zoneContractAddress = zoneContractAddress;
|
|
677
|
+
}
|
|
678
|
+
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
679
|
+
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
680
|
+
let approvalTransaction;
|
|
681
|
+
const approvalAction = actions
|
|
682
|
+
.find((action) => action.type === 'approval');
|
|
683
|
+
if (approvalAction) {
|
|
684
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
685
|
+
}
|
|
686
|
+
const createAction = actions
|
|
687
|
+
.find((action) => action.type === 'create');
|
|
688
|
+
if (!createAction) {
|
|
689
|
+
throw new Error('No create order action found');
|
|
690
|
+
}
|
|
691
|
+
const orderMessageToSign = await createAction.getMessageToSign();
|
|
692
|
+
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
693
|
+
return {
|
|
694
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
695
|
+
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
696
|
+
orderComponents,
|
|
697
|
+
orderHash: await this.seaport.getOrderHash(orderComponents),
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
async fulfilOrder(order, account) {
|
|
701
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
702
|
+
const { actions } = await this.seaport.fulfillOrders({
|
|
703
|
+
accountAddress: account,
|
|
704
|
+
fulfillOrderDetails: [{
|
|
705
|
+
order: {
|
|
706
|
+
parameters: orderComponents,
|
|
707
|
+
signature: order.signature,
|
|
708
|
+
},
|
|
709
|
+
extraData: order.protocol_data.operator_signature,
|
|
710
|
+
}],
|
|
711
|
+
});
|
|
712
|
+
let approvalTransaction;
|
|
713
|
+
const approvalAction = actions
|
|
714
|
+
.find((action) => action.type === 'approval');
|
|
715
|
+
if (approvalAction) {
|
|
716
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
717
|
+
}
|
|
718
|
+
const fulfillmentAction = actions
|
|
719
|
+
.find((action) => action.type === 'exchange');
|
|
720
|
+
if (!fulfillmentAction) {
|
|
721
|
+
throw new Error('No exchange action found');
|
|
722
|
+
}
|
|
723
|
+
const fulfillmentTransaction = await prepareTransaction(fulfillmentAction.transactionMethods);
|
|
724
|
+
return {
|
|
725
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
726
|
+
unsignedFulfillmentTransaction: fulfillmentTransaction,
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
async cancelOrder(order, account) {
|
|
730
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
731
|
+
const cancellationTransaction = await this.seaport.cancelOrders([orderComponents], account);
|
|
732
|
+
return prepareTransaction(cancellationTransaction);
|
|
733
|
+
}
|
|
734
|
+
async mapImmutableOrderToSeaportOrderComponents(order) {
|
|
735
|
+
const counterForOfferer = await this.seaport.getCounter(order.account_address);
|
|
736
|
+
return mapImmutableOrderToSeaportOrderComponents(order, counterForOfferer.toString(), this.zoneContractAddress);
|
|
737
|
+
}
|
|
738
|
+
createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
739
|
+
return this.seaport.createOrder({
|
|
740
|
+
allowPartialFills: false,
|
|
741
|
+
offer: [
|
|
742
|
+
{
|
|
743
|
+
itemType: ItemType.ERC721,
|
|
744
|
+
token: listingItem.contractAddress,
|
|
745
|
+
identifier: listingItem.tokenId,
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
consideration: [
|
|
749
|
+
{
|
|
750
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
751
|
+
amount: considerationItem.amount,
|
|
752
|
+
recipient: offerer,
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
756
|
+
amount: royaltyInfo.amountRequired,
|
|
757
|
+
recipient: royaltyInfo.recipient,
|
|
758
|
+
},
|
|
759
|
+
],
|
|
760
|
+
startTime: (orderStart.getTime() / 1000).toFixed(0),
|
|
761
|
+
endTime: (orderExpiry.getTime() / 1000).toFixed(0),
|
|
762
|
+
zone: this.zoneContractAddress,
|
|
763
|
+
restrictedByZone: true,
|
|
764
|
+
}, offerer);
|
|
765
|
+
}
|
|
766
|
+
async getTypedDataFromOrderComponents(orderComponents) {
|
|
767
|
+
const { chainId } = await this.provider.getNetwork();
|
|
768
|
+
const domainData = {
|
|
769
|
+
name: SEAPORT_CONTRACT_NAME,
|
|
770
|
+
version: SEAPORT_CONTRACT_VERSION_V1_4,
|
|
771
|
+
chainId,
|
|
772
|
+
verifyingContract: this.seaportContractAddress,
|
|
773
|
+
};
|
|
774
|
+
return {
|
|
775
|
+
domain: domainData,
|
|
776
|
+
types: EIP_712_ORDER_TYPE,
|
|
777
|
+
value: orderComponents,
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
class SeaportFactory {
|
|
783
|
+
seaportContractAddress;
|
|
784
|
+
zoneContractAddress;
|
|
785
|
+
provider;
|
|
786
|
+
seaport;
|
|
787
|
+
constructor(seaportContractAddress, zoneContractAddress, provider) {
|
|
788
|
+
this.seaportContractAddress = seaportContractAddress;
|
|
789
|
+
this.zoneContractAddress = zoneContractAddress;
|
|
790
|
+
this.provider = provider;
|
|
791
|
+
this.seaport = new Seaport$1(provider, {
|
|
792
|
+
seaportVersion: '1.4',
|
|
793
|
+
balanceAndApprovalChecksOnOrderCreation: true,
|
|
794
|
+
overrides: {
|
|
795
|
+
contractAddress: seaportContractAddress,
|
|
796
|
+
},
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
create() {
|
|
800
|
+
return new Seaport(this.seaport, this.provider, this.seaportContractAddress, this.zoneContractAddress);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
class ImmutableApiClient {
|
|
805
|
+
orderbookService;
|
|
806
|
+
chainId;
|
|
807
|
+
constructor(orderbookService, chainId) {
|
|
808
|
+
this.orderbookService = orderbookService;
|
|
809
|
+
this.chainId = chainId;
|
|
810
|
+
}
|
|
811
|
+
async getOrder(orderId) {
|
|
812
|
+
return this.orderbookService.getOrder({ chainId: this.chainId, orderId });
|
|
813
|
+
}
|
|
814
|
+
async listOrders(listOrderParams) {
|
|
815
|
+
return this.orderbookService.listOrders({
|
|
816
|
+
chainId: this.chainId,
|
|
817
|
+
...listOrderParams,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
async createOrder({ orderHash, orderComponents, offerer, orderSignature, }) {
|
|
821
|
+
if (orderComponents.offer.length !== 1) {
|
|
822
|
+
throw new Error('Only one item can be listed at a time');
|
|
823
|
+
}
|
|
824
|
+
if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
|
|
825
|
+
throw new Error('Only ERC721 tokens can be listed');
|
|
826
|
+
}
|
|
827
|
+
const considerationItemTypeTheSame = new Set([...orderComponents.consideration.map((c) => c.itemType)]).size === 1;
|
|
828
|
+
if (!considerationItemTypeTheSame) {
|
|
829
|
+
throw new Error('All consideration items must be of the same type');
|
|
830
|
+
}
|
|
831
|
+
return this.orderbookService.createOrder({
|
|
832
|
+
chainId: this.chainId,
|
|
833
|
+
requestBody: {
|
|
834
|
+
order_hash: orderHash,
|
|
835
|
+
account_address: offerer,
|
|
836
|
+
buy: [
|
|
837
|
+
{
|
|
838
|
+
item_type: Number(orderComponents.consideration[0].itemType) === ItemType.NATIVE
|
|
839
|
+
? BuyItem.item_type.NATIVE
|
|
840
|
+
: BuyItem.item_type.ERC20,
|
|
841
|
+
start_amount: orderComponents.consideration[0].startAmount,
|
|
842
|
+
}
|
|
843
|
+
],
|
|
844
|
+
buy_fees: orderComponents.consideration.length > 1
|
|
845
|
+
? [
|
|
846
|
+
{
|
|
847
|
+
amount: orderComponents.consideration[1].startAmount,
|
|
848
|
+
recipient: orderComponents.consideration[1].recipient,
|
|
849
|
+
fee_type: Fee.fee_type.ROYALTY,
|
|
850
|
+
},
|
|
851
|
+
]
|
|
852
|
+
: [],
|
|
853
|
+
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
854
|
+
protocol_data: {
|
|
855
|
+
order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
|
|
856
|
+
zone_address: orderComponents.zone,
|
|
857
|
+
},
|
|
858
|
+
salt: orderComponents.salt,
|
|
859
|
+
sell: [{
|
|
860
|
+
contract_address: orderComponents.offer[0].token,
|
|
861
|
+
token_id: orderComponents.offer[0].identifierOrCriteria,
|
|
862
|
+
item_type: SellItem.item_type.ERC721,
|
|
863
|
+
}],
|
|
864
|
+
signature: orderSignature,
|
|
865
|
+
start_time: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
|
|
866
|
+
},
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
class ImmutableApiClientFactory {
|
|
872
|
+
chainId;
|
|
873
|
+
orderbookClient;
|
|
874
|
+
constructor(apiEndpoint, chainId) {
|
|
875
|
+
this.chainId = chainId;
|
|
876
|
+
this.orderbookClient = new OrderBookClient({
|
|
877
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
878
|
+
BASE: apiEndpoint,
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
create() {
|
|
882
|
+
return new ImmutableApiClient(this.orderbookClient.orders, this.chainId);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
class ERC721 {
|
|
887
|
+
erc721;
|
|
888
|
+
constructor(erc721) {
|
|
889
|
+
this.erc721 = erc721;
|
|
890
|
+
}
|
|
891
|
+
async royaltyInfo(tokenId, salePrice) {
|
|
892
|
+
const [recipient, royaltyRequired] = await this.erc721.royaltyInfo(tokenId, salePrice);
|
|
893
|
+
return { recipient, amountRequired: royaltyRequired.toString() };
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
/* Autogenerated file. Do not edit manually. */
|
|
898
|
+
/* tslint:disable */
|
|
899
|
+
/* eslint-disable */
|
|
900
|
+
const _abi = [
|
|
901
|
+
{
|
|
902
|
+
inputs: [
|
|
903
|
+
{
|
|
904
|
+
internalType: "address",
|
|
905
|
+
name: "owner_",
|
|
906
|
+
type: "address",
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
internalType: "string",
|
|
910
|
+
name: "name_",
|
|
911
|
+
type: "string",
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
internalType: "string",
|
|
915
|
+
name: "symbol_",
|
|
916
|
+
type: "string",
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
internalType: "string",
|
|
920
|
+
name: "baseURI_",
|
|
921
|
+
type: "string",
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
internalType: "string",
|
|
925
|
+
name: "contractURI_",
|
|
926
|
+
type: "string",
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
internalType: "address",
|
|
930
|
+
name: "_receiver",
|
|
931
|
+
type: "address",
|
|
932
|
+
},
|
|
933
|
+
{
|
|
934
|
+
internalType: "uint96",
|
|
935
|
+
name: "_feeNumerator",
|
|
936
|
+
type: "uint96",
|
|
937
|
+
},
|
|
938
|
+
],
|
|
939
|
+
stateMutability: "nonpayable",
|
|
940
|
+
type: "constructor",
|
|
941
|
+
},
|
|
942
|
+
{
|
|
943
|
+
inputs: [
|
|
944
|
+
{
|
|
945
|
+
internalType: "address",
|
|
946
|
+
name: "target",
|
|
947
|
+
type: "address",
|
|
948
|
+
},
|
|
949
|
+
],
|
|
950
|
+
name: "ApproveTargetNotInAllowlist",
|
|
951
|
+
type: "error",
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
inputs: [
|
|
955
|
+
{
|
|
956
|
+
internalType: "address",
|
|
957
|
+
name: "caller",
|
|
958
|
+
type: "address",
|
|
959
|
+
},
|
|
960
|
+
],
|
|
961
|
+
name: "CallerNotInAllowlist",
|
|
962
|
+
type: "error",
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
anonymous: false,
|
|
966
|
+
inputs: [
|
|
967
|
+
{
|
|
968
|
+
indexed: true,
|
|
969
|
+
internalType: "address",
|
|
970
|
+
name: "owner",
|
|
971
|
+
type: "address",
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
indexed: true,
|
|
975
|
+
internalType: "address",
|
|
976
|
+
name: "approved",
|
|
977
|
+
type: "address",
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
indexed: true,
|
|
981
|
+
internalType: "uint256",
|
|
982
|
+
name: "tokenId",
|
|
983
|
+
type: "uint256",
|
|
984
|
+
},
|
|
985
|
+
],
|
|
986
|
+
name: "Approval",
|
|
987
|
+
type: "event",
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
anonymous: false,
|
|
991
|
+
inputs: [
|
|
992
|
+
{
|
|
993
|
+
indexed: true,
|
|
994
|
+
internalType: "address",
|
|
995
|
+
name: "owner",
|
|
996
|
+
type: "address",
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
indexed: true,
|
|
1000
|
+
internalType: "address",
|
|
1001
|
+
name: "operator",
|
|
1002
|
+
type: "address",
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
indexed: false,
|
|
1006
|
+
internalType: "bool",
|
|
1007
|
+
name: "approved",
|
|
1008
|
+
type: "bool",
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
1011
|
+
name: "ApprovalForAll",
|
|
1012
|
+
type: "event",
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
anonymous: false,
|
|
1016
|
+
inputs: [
|
|
1017
|
+
{
|
|
1018
|
+
indexed: true,
|
|
1019
|
+
internalType: "bytes32",
|
|
1020
|
+
name: "role",
|
|
1021
|
+
type: "bytes32",
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
indexed: true,
|
|
1025
|
+
internalType: "bytes32",
|
|
1026
|
+
name: "previousAdminRole",
|
|
1027
|
+
type: "bytes32",
|
|
1028
|
+
},
|
|
1029
|
+
{
|
|
1030
|
+
indexed: true,
|
|
1031
|
+
internalType: "bytes32",
|
|
1032
|
+
name: "newAdminRole",
|
|
1033
|
+
type: "bytes32",
|
|
1034
|
+
},
|
|
1035
|
+
],
|
|
1036
|
+
name: "RoleAdminChanged",
|
|
1037
|
+
type: "event",
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
anonymous: false,
|
|
1041
|
+
inputs: [
|
|
1042
|
+
{
|
|
1043
|
+
indexed: true,
|
|
1044
|
+
internalType: "bytes32",
|
|
1045
|
+
name: "role",
|
|
1046
|
+
type: "bytes32",
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
indexed: true,
|
|
1050
|
+
internalType: "address",
|
|
1051
|
+
name: "account",
|
|
1052
|
+
type: "address",
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
indexed: true,
|
|
1056
|
+
internalType: "address",
|
|
1057
|
+
name: "sender",
|
|
1058
|
+
type: "address",
|
|
1059
|
+
},
|
|
1060
|
+
],
|
|
1061
|
+
name: "RoleGranted",
|
|
1062
|
+
type: "event",
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
anonymous: false,
|
|
1066
|
+
inputs: [
|
|
1067
|
+
{
|
|
1068
|
+
indexed: true,
|
|
1069
|
+
internalType: "bytes32",
|
|
1070
|
+
name: "role",
|
|
1071
|
+
type: "bytes32",
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
indexed: true,
|
|
1075
|
+
internalType: "address",
|
|
1076
|
+
name: "account",
|
|
1077
|
+
type: "address",
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
indexed: true,
|
|
1081
|
+
internalType: "address",
|
|
1082
|
+
name: "sender",
|
|
1083
|
+
type: "address",
|
|
1084
|
+
},
|
|
1085
|
+
],
|
|
1086
|
+
name: "RoleRevoked",
|
|
1087
|
+
type: "event",
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
anonymous: false,
|
|
1091
|
+
inputs: [
|
|
1092
|
+
{
|
|
1093
|
+
indexed: false,
|
|
1094
|
+
internalType: "address",
|
|
1095
|
+
name: "oldRegistry",
|
|
1096
|
+
type: "address",
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
indexed: false,
|
|
1100
|
+
internalType: "address",
|
|
1101
|
+
name: "newRegistry",
|
|
1102
|
+
type: "address",
|
|
1103
|
+
},
|
|
1104
|
+
],
|
|
1105
|
+
name: "RoyaltytAllowlistRegistryUpdated",
|
|
1106
|
+
type: "event",
|
|
1107
|
+
},
|
|
1108
|
+
{
|
|
1109
|
+
anonymous: false,
|
|
1110
|
+
inputs: [
|
|
1111
|
+
{
|
|
1112
|
+
indexed: true,
|
|
1113
|
+
internalType: "address",
|
|
1114
|
+
name: "from",
|
|
1115
|
+
type: "address",
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
indexed: true,
|
|
1119
|
+
internalType: "address",
|
|
1120
|
+
name: "to",
|
|
1121
|
+
type: "address",
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
indexed: true,
|
|
1125
|
+
internalType: "uint256",
|
|
1126
|
+
name: "tokenId",
|
|
1127
|
+
type: "uint256",
|
|
1128
|
+
},
|
|
1129
|
+
],
|
|
1130
|
+
name: "Transfer",
|
|
1131
|
+
type: "event",
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
inputs: [],
|
|
1135
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
1136
|
+
outputs: [
|
|
1137
|
+
{
|
|
1138
|
+
internalType: "bytes32",
|
|
1139
|
+
name: "",
|
|
1140
|
+
type: "bytes32",
|
|
1141
|
+
},
|
|
1142
|
+
],
|
|
1143
|
+
stateMutability: "view",
|
|
1144
|
+
type: "function",
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
inputs: [],
|
|
1148
|
+
name: "MINTER_ROLE",
|
|
1149
|
+
outputs: [
|
|
1150
|
+
{
|
|
1151
|
+
internalType: "bytes32",
|
|
1152
|
+
name: "",
|
|
1153
|
+
type: "bytes32",
|
|
1154
|
+
},
|
|
1155
|
+
],
|
|
1156
|
+
stateMutability: "view",
|
|
1157
|
+
type: "function",
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
inputs: [
|
|
1161
|
+
{
|
|
1162
|
+
internalType: "address",
|
|
1163
|
+
name: "to",
|
|
1164
|
+
type: "address",
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
internalType: "uint256",
|
|
1168
|
+
name: "tokenId",
|
|
1169
|
+
type: "uint256",
|
|
1170
|
+
},
|
|
1171
|
+
],
|
|
1172
|
+
name: "approve",
|
|
1173
|
+
outputs: [],
|
|
1174
|
+
stateMutability: "nonpayable",
|
|
1175
|
+
type: "function",
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
inputs: [
|
|
1179
|
+
{
|
|
1180
|
+
internalType: "address",
|
|
1181
|
+
name: "owner",
|
|
1182
|
+
type: "address",
|
|
1183
|
+
},
|
|
1184
|
+
],
|
|
1185
|
+
name: "balanceOf",
|
|
1186
|
+
outputs: [
|
|
1187
|
+
{
|
|
1188
|
+
internalType: "uint256",
|
|
1189
|
+
name: "",
|
|
1190
|
+
type: "uint256",
|
|
1191
|
+
},
|
|
1192
|
+
],
|
|
1193
|
+
stateMutability: "view",
|
|
1194
|
+
type: "function",
|
|
1195
|
+
},
|
|
1196
|
+
{
|
|
1197
|
+
inputs: [],
|
|
1198
|
+
name: "baseURI",
|
|
1199
|
+
outputs: [
|
|
1200
|
+
{
|
|
1201
|
+
internalType: "string",
|
|
1202
|
+
name: "",
|
|
1203
|
+
type: "string",
|
|
1204
|
+
},
|
|
1205
|
+
],
|
|
1206
|
+
stateMutability: "view",
|
|
1207
|
+
type: "function",
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
inputs: [
|
|
1211
|
+
{
|
|
1212
|
+
internalType: "uint256",
|
|
1213
|
+
name: "tokenId",
|
|
1214
|
+
type: "uint256",
|
|
1215
|
+
},
|
|
1216
|
+
],
|
|
1217
|
+
name: "burn",
|
|
1218
|
+
outputs: [],
|
|
1219
|
+
stateMutability: "nonpayable",
|
|
1220
|
+
type: "function",
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
inputs: [],
|
|
1224
|
+
name: "contractURI",
|
|
1225
|
+
outputs: [
|
|
1226
|
+
{
|
|
1227
|
+
internalType: "string",
|
|
1228
|
+
name: "",
|
|
1229
|
+
type: "string",
|
|
1230
|
+
},
|
|
1231
|
+
],
|
|
1232
|
+
stateMutability: "view",
|
|
1233
|
+
type: "function",
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
inputs: [],
|
|
1237
|
+
name: "getAdmins",
|
|
1238
|
+
outputs: [
|
|
1239
|
+
{
|
|
1240
|
+
internalType: "address[]",
|
|
1241
|
+
name: "",
|
|
1242
|
+
type: "address[]",
|
|
1243
|
+
},
|
|
1244
|
+
],
|
|
1245
|
+
stateMutability: "view",
|
|
1246
|
+
type: "function",
|
|
1247
|
+
},
|
|
1248
|
+
{
|
|
1249
|
+
inputs: [
|
|
1250
|
+
{
|
|
1251
|
+
internalType: "uint256",
|
|
1252
|
+
name: "tokenId",
|
|
1253
|
+
type: "uint256",
|
|
1254
|
+
},
|
|
1255
|
+
],
|
|
1256
|
+
name: "getApproved",
|
|
1257
|
+
outputs: [
|
|
1258
|
+
{
|
|
1259
|
+
internalType: "address",
|
|
1260
|
+
name: "",
|
|
1261
|
+
type: "address",
|
|
1262
|
+
},
|
|
1263
|
+
],
|
|
1264
|
+
stateMutability: "view",
|
|
1265
|
+
type: "function",
|
|
1266
|
+
},
|
|
1267
|
+
{
|
|
1268
|
+
inputs: [
|
|
1269
|
+
{
|
|
1270
|
+
internalType: "bytes32",
|
|
1271
|
+
name: "role",
|
|
1272
|
+
type: "bytes32",
|
|
1273
|
+
},
|
|
1274
|
+
],
|
|
1275
|
+
name: "getRoleAdmin",
|
|
1276
|
+
outputs: [
|
|
1277
|
+
{
|
|
1278
|
+
internalType: "bytes32",
|
|
1279
|
+
name: "",
|
|
1280
|
+
type: "bytes32",
|
|
1281
|
+
},
|
|
1282
|
+
],
|
|
1283
|
+
stateMutability: "view",
|
|
1284
|
+
type: "function",
|
|
1285
|
+
},
|
|
1286
|
+
{
|
|
1287
|
+
inputs: [
|
|
1288
|
+
{
|
|
1289
|
+
internalType: "bytes32",
|
|
1290
|
+
name: "role",
|
|
1291
|
+
type: "bytes32",
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
internalType: "uint256",
|
|
1295
|
+
name: "index",
|
|
1296
|
+
type: "uint256",
|
|
1297
|
+
},
|
|
1298
|
+
],
|
|
1299
|
+
name: "getRoleMember",
|
|
1300
|
+
outputs: [
|
|
1301
|
+
{
|
|
1302
|
+
internalType: "address",
|
|
1303
|
+
name: "",
|
|
1304
|
+
type: "address",
|
|
1305
|
+
},
|
|
1306
|
+
],
|
|
1307
|
+
stateMutability: "view",
|
|
1308
|
+
type: "function",
|
|
1309
|
+
},
|
|
1310
|
+
{
|
|
1311
|
+
inputs: [
|
|
1312
|
+
{
|
|
1313
|
+
internalType: "bytes32",
|
|
1314
|
+
name: "role",
|
|
1315
|
+
type: "bytes32",
|
|
1316
|
+
},
|
|
1317
|
+
],
|
|
1318
|
+
name: "getRoleMemberCount",
|
|
1319
|
+
outputs: [
|
|
1320
|
+
{
|
|
1321
|
+
internalType: "uint256",
|
|
1322
|
+
name: "",
|
|
1323
|
+
type: "uint256",
|
|
1324
|
+
},
|
|
1325
|
+
],
|
|
1326
|
+
stateMutability: "view",
|
|
1327
|
+
type: "function",
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
inputs: [
|
|
1331
|
+
{
|
|
1332
|
+
internalType: "address",
|
|
1333
|
+
name: "user",
|
|
1334
|
+
type: "address",
|
|
1335
|
+
},
|
|
1336
|
+
],
|
|
1337
|
+
name: "grantMinterRole",
|
|
1338
|
+
outputs: [],
|
|
1339
|
+
stateMutability: "nonpayable",
|
|
1340
|
+
type: "function",
|
|
1341
|
+
},
|
|
1342
|
+
{
|
|
1343
|
+
inputs: [
|
|
1344
|
+
{
|
|
1345
|
+
internalType: "bytes32",
|
|
1346
|
+
name: "role",
|
|
1347
|
+
type: "bytes32",
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
internalType: "address",
|
|
1351
|
+
name: "account",
|
|
1352
|
+
type: "address",
|
|
1353
|
+
},
|
|
1354
|
+
],
|
|
1355
|
+
name: "grantRole",
|
|
1356
|
+
outputs: [],
|
|
1357
|
+
stateMutability: "nonpayable",
|
|
1358
|
+
type: "function",
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
inputs: [
|
|
1362
|
+
{
|
|
1363
|
+
internalType: "bytes32",
|
|
1364
|
+
name: "role",
|
|
1365
|
+
type: "bytes32",
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
internalType: "address",
|
|
1369
|
+
name: "account",
|
|
1370
|
+
type: "address",
|
|
1371
|
+
},
|
|
1372
|
+
],
|
|
1373
|
+
name: "hasRole",
|
|
1374
|
+
outputs: [
|
|
1375
|
+
{
|
|
1376
|
+
internalType: "bool",
|
|
1377
|
+
name: "",
|
|
1378
|
+
type: "bool",
|
|
1379
|
+
},
|
|
1380
|
+
],
|
|
1381
|
+
stateMutability: "view",
|
|
1382
|
+
type: "function",
|
|
1383
|
+
},
|
|
1384
|
+
{
|
|
1385
|
+
inputs: [
|
|
1386
|
+
{
|
|
1387
|
+
internalType: "address",
|
|
1388
|
+
name: "owner",
|
|
1389
|
+
type: "address",
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
internalType: "address",
|
|
1393
|
+
name: "operator",
|
|
1394
|
+
type: "address",
|
|
1395
|
+
},
|
|
1396
|
+
],
|
|
1397
|
+
name: "isApprovedForAll",
|
|
1398
|
+
outputs: [
|
|
1399
|
+
{
|
|
1400
|
+
internalType: "bool",
|
|
1401
|
+
name: "",
|
|
1402
|
+
type: "bool",
|
|
1403
|
+
},
|
|
1404
|
+
],
|
|
1405
|
+
stateMutability: "view",
|
|
1406
|
+
type: "function",
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
inputs: [
|
|
1410
|
+
{
|
|
1411
|
+
internalType: "address",
|
|
1412
|
+
name: "to",
|
|
1413
|
+
type: "address",
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
internalType: "uint256",
|
|
1417
|
+
name: "amount",
|
|
1418
|
+
type: "uint256",
|
|
1419
|
+
},
|
|
1420
|
+
],
|
|
1421
|
+
name: "mint",
|
|
1422
|
+
outputs: [],
|
|
1423
|
+
stateMutability: "nonpayable",
|
|
1424
|
+
type: "function",
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
inputs: [],
|
|
1428
|
+
name: "name",
|
|
1429
|
+
outputs: [
|
|
1430
|
+
{
|
|
1431
|
+
internalType: "string",
|
|
1432
|
+
name: "",
|
|
1433
|
+
type: "string",
|
|
1434
|
+
},
|
|
1435
|
+
],
|
|
1436
|
+
stateMutability: "view",
|
|
1437
|
+
type: "function",
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
inputs: [
|
|
1441
|
+
{
|
|
1442
|
+
internalType: "uint256",
|
|
1443
|
+
name: "tokenId",
|
|
1444
|
+
type: "uint256",
|
|
1445
|
+
},
|
|
1446
|
+
],
|
|
1447
|
+
name: "ownerOf",
|
|
1448
|
+
outputs: [
|
|
1449
|
+
{
|
|
1450
|
+
internalType: "address",
|
|
1451
|
+
name: "",
|
|
1452
|
+
type: "address",
|
|
1453
|
+
},
|
|
1454
|
+
],
|
|
1455
|
+
stateMutability: "view",
|
|
1456
|
+
type: "function",
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
inputs: [
|
|
1460
|
+
{
|
|
1461
|
+
internalType: "bytes32",
|
|
1462
|
+
name: "role",
|
|
1463
|
+
type: "bytes32",
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
internalType: "address",
|
|
1467
|
+
name: "account",
|
|
1468
|
+
type: "address",
|
|
1469
|
+
},
|
|
1470
|
+
],
|
|
1471
|
+
name: "renounceRole",
|
|
1472
|
+
outputs: [],
|
|
1473
|
+
stateMutability: "nonpayable",
|
|
1474
|
+
type: "function",
|
|
1475
|
+
},
|
|
1476
|
+
{
|
|
1477
|
+
inputs: [
|
|
1478
|
+
{
|
|
1479
|
+
internalType: "address",
|
|
1480
|
+
name: "user",
|
|
1481
|
+
type: "address",
|
|
1482
|
+
},
|
|
1483
|
+
],
|
|
1484
|
+
name: "revokeMinterRole",
|
|
1485
|
+
outputs: [],
|
|
1486
|
+
stateMutability: "nonpayable",
|
|
1487
|
+
type: "function",
|
|
1488
|
+
},
|
|
1489
|
+
{
|
|
1490
|
+
inputs: [
|
|
1491
|
+
{
|
|
1492
|
+
internalType: "bytes32",
|
|
1493
|
+
name: "role",
|
|
1494
|
+
type: "bytes32",
|
|
1495
|
+
},
|
|
1496
|
+
{
|
|
1497
|
+
internalType: "address",
|
|
1498
|
+
name: "account",
|
|
1499
|
+
type: "address",
|
|
1500
|
+
},
|
|
1501
|
+
],
|
|
1502
|
+
name: "revokeRole",
|
|
1503
|
+
outputs: [],
|
|
1504
|
+
stateMutability: "nonpayable",
|
|
1505
|
+
type: "function",
|
|
1506
|
+
},
|
|
1507
|
+
{
|
|
1508
|
+
inputs: [],
|
|
1509
|
+
name: "royaltyAllowlist",
|
|
1510
|
+
outputs: [
|
|
1511
|
+
{
|
|
1512
|
+
internalType: "contract IRoyaltyAllowlist",
|
|
1513
|
+
name: "",
|
|
1514
|
+
type: "address",
|
|
1515
|
+
},
|
|
1516
|
+
],
|
|
1517
|
+
stateMutability: "view",
|
|
1518
|
+
type: "function",
|
|
1519
|
+
},
|
|
1520
|
+
{
|
|
1521
|
+
inputs: [
|
|
1522
|
+
{
|
|
1523
|
+
internalType: "uint256",
|
|
1524
|
+
name: "_tokenId",
|
|
1525
|
+
type: "uint256",
|
|
1526
|
+
},
|
|
1527
|
+
{
|
|
1528
|
+
internalType: "uint256",
|
|
1529
|
+
name: "_salePrice",
|
|
1530
|
+
type: "uint256",
|
|
1531
|
+
},
|
|
1532
|
+
],
|
|
1533
|
+
name: "royaltyInfo",
|
|
1534
|
+
outputs: [
|
|
1535
|
+
{
|
|
1536
|
+
internalType: "address",
|
|
1537
|
+
name: "",
|
|
1538
|
+
type: "address",
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
internalType: "uint256",
|
|
1542
|
+
name: "",
|
|
1543
|
+
type: "uint256",
|
|
1544
|
+
},
|
|
1545
|
+
],
|
|
1546
|
+
stateMutability: "view",
|
|
1547
|
+
type: "function",
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
inputs: [
|
|
1551
|
+
{
|
|
1552
|
+
internalType: "address",
|
|
1553
|
+
name: "from",
|
|
1554
|
+
type: "address",
|
|
1555
|
+
},
|
|
1556
|
+
{
|
|
1557
|
+
internalType: "address",
|
|
1558
|
+
name: "to",
|
|
1559
|
+
type: "address",
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
internalType: "uint256",
|
|
1563
|
+
name: "tokenId",
|
|
1564
|
+
type: "uint256",
|
|
1565
|
+
},
|
|
1566
|
+
],
|
|
1567
|
+
name: "safeTransferFrom",
|
|
1568
|
+
outputs: [],
|
|
1569
|
+
stateMutability: "nonpayable",
|
|
1570
|
+
type: "function",
|
|
1571
|
+
},
|
|
1572
|
+
{
|
|
1573
|
+
inputs: [
|
|
1574
|
+
{
|
|
1575
|
+
internalType: "address",
|
|
1576
|
+
name: "from",
|
|
1577
|
+
type: "address",
|
|
1578
|
+
},
|
|
1579
|
+
{
|
|
1580
|
+
internalType: "address",
|
|
1581
|
+
name: "to",
|
|
1582
|
+
type: "address",
|
|
1583
|
+
},
|
|
1584
|
+
{
|
|
1585
|
+
internalType: "uint256",
|
|
1586
|
+
name: "tokenId",
|
|
1587
|
+
type: "uint256",
|
|
1588
|
+
},
|
|
1589
|
+
{
|
|
1590
|
+
internalType: "bytes",
|
|
1591
|
+
name: "data",
|
|
1592
|
+
type: "bytes",
|
|
1593
|
+
},
|
|
1594
|
+
],
|
|
1595
|
+
name: "safeTransferFrom",
|
|
1596
|
+
outputs: [],
|
|
1597
|
+
stateMutability: "nonpayable",
|
|
1598
|
+
type: "function",
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
inputs: [
|
|
1602
|
+
{
|
|
1603
|
+
internalType: "address",
|
|
1604
|
+
name: "operator",
|
|
1605
|
+
type: "address",
|
|
1606
|
+
},
|
|
1607
|
+
{
|
|
1608
|
+
internalType: "bool",
|
|
1609
|
+
name: "approved",
|
|
1610
|
+
type: "bool",
|
|
1611
|
+
},
|
|
1612
|
+
],
|
|
1613
|
+
name: "setApprovalForAll",
|
|
1614
|
+
outputs: [],
|
|
1615
|
+
stateMutability: "nonpayable",
|
|
1616
|
+
type: "function",
|
|
1617
|
+
},
|
|
1618
|
+
{
|
|
1619
|
+
inputs: [
|
|
1620
|
+
{
|
|
1621
|
+
internalType: "string",
|
|
1622
|
+
name: "baseURI_",
|
|
1623
|
+
type: "string",
|
|
1624
|
+
},
|
|
1625
|
+
],
|
|
1626
|
+
name: "setBaseURI",
|
|
1627
|
+
outputs: [],
|
|
1628
|
+
stateMutability: "nonpayable",
|
|
1629
|
+
type: "function",
|
|
1630
|
+
},
|
|
1631
|
+
{
|
|
1632
|
+
inputs: [
|
|
1633
|
+
{
|
|
1634
|
+
internalType: "string",
|
|
1635
|
+
name: "_contractURI",
|
|
1636
|
+
type: "string",
|
|
1637
|
+
},
|
|
1638
|
+
],
|
|
1639
|
+
name: "setContractURI",
|
|
1640
|
+
outputs: [],
|
|
1641
|
+
stateMutability: "nonpayable",
|
|
1642
|
+
type: "function",
|
|
1643
|
+
},
|
|
1644
|
+
{
|
|
1645
|
+
inputs: [
|
|
1646
|
+
{
|
|
1647
|
+
internalType: "address",
|
|
1648
|
+
name: "_royaltyAllowlist",
|
|
1649
|
+
type: "address",
|
|
1650
|
+
},
|
|
1651
|
+
],
|
|
1652
|
+
name: "setRoyaltyAllowlistRegistry",
|
|
1653
|
+
outputs: [],
|
|
1654
|
+
stateMutability: "nonpayable",
|
|
1655
|
+
type: "function",
|
|
1656
|
+
},
|
|
1657
|
+
{
|
|
1658
|
+
inputs: [
|
|
1659
|
+
{
|
|
1660
|
+
internalType: "bytes4",
|
|
1661
|
+
name: "interfaceId",
|
|
1662
|
+
type: "bytes4",
|
|
1663
|
+
},
|
|
1664
|
+
],
|
|
1665
|
+
name: "supportsInterface",
|
|
1666
|
+
outputs: [
|
|
1667
|
+
{
|
|
1668
|
+
internalType: "bool",
|
|
1669
|
+
name: "",
|
|
1670
|
+
type: "bool",
|
|
1671
|
+
},
|
|
1672
|
+
],
|
|
1673
|
+
stateMutability: "view",
|
|
1674
|
+
type: "function",
|
|
1675
|
+
},
|
|
1676
|
+
{
|
|
1677
|
+
inputs: [],
|
|
1678
|
+
name: "symbol",
|
|
1679
|
+
outputs: [
|
|
1680
|
+
{
|
|
1681
|
+
internalType: "string",
|
|
1682
|
+
name: "",
|
|
1683
|
+
type: "string",
|
|
1684
|
+
},
|
|
1685
|
+
],
|
|
1686
|
+
stateMutability: "view",
|
|
1687
|
+
type: "function",
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
inputs: [
|
|
1691
|
+
{
|
|
1692
|
+
internalType: "uint256",
|
|
1693
|
+
name: "index",
|
|
1694
|
+
type: "uint256",
|
|
1695
|
+
},
|
|
1696
|
+
],
|
|
1697
|
+
name: "tokenByIndex",
|
|
1698
|
+
outputs: [
|
|
1699
|
+
{
|
|
1700
|
+
internalType: "uint256",
|
|
1701
|
+
name: "",
|
|
1702
|
+
type: "uint256",
|
|
1703
|
+
},
|
|
1704
|
+
],
|
|
1705
|
+
stateMutability: "view",
|
|
1706
|
+
type: "function",
|
|
1707
|
+
},
|
|
1708
|
+
{
|
|
1709
|
+
inputs: [
|
|
1710
|
+
{
|
|
1711
|
+
internalType: "address",
|
|
1712
|
+
name: "owner",
|
|
1713
|
+
type: "address",
|
|
1714
|
+
},
|
|
1715
|
+
{
|
|
1716
|
+
internalType: "uint256",
|
|
1717
|
+
name: "index",
|
|
1718
|
+
type: "uint256",
|
|
1719
|
+
},
|
|
1720
|
+
],
|
|
1721
|
+
name: "tokenOfOwnerByIndex",
|
|
1722
|
+
outputs: [
|
|
1723
|
+
{
|
|
1724
|
+
internalType: "uint256",
|
|
1725
|
+
name: "",
|
|
1726
|
+
type: "uint256",
|
|
1727
|
+
},
|
|
1728
|
+
],
|
|
1729
|
+
stateMutability: "view",
|
|
1730
|
+
type: "function",
|
|
1731
|
+
},
|
|
1732
|
+
{
|
|
1733
|
+
inputs: [
|
|
1734
|
+
{
|
|
1735
|
+
internalType: "uint256",
|
|
1736
|
+
name: "tokenId",
|
|
1737
|
+
type: "uint256",
|
|
1738
|
+
},
|
|
1739
|
+
],
|
|
1740
|
+
name: "tokenURI",
|
|
1741
|
+
outputs: [
|
|
1742
|
+
{
|
|
1743
|
+
internalType: "string",
|
|
1744
|
+
name: "",
|
|
1745
|
+
type: "string",
|
|
1746
|
+
},
|
|
1747
|
+
],
|
|
1748
|
+
stateMutability: "view",
|
|
1749
|
+
type: "function",
|
|
1750
|
+
},
|
|
1751
|
+
{
|
|
1752
|
+
inputs: [],
|
|
1753
|
+
name: "totalSupply",
|
|
1754
|
+
outputs: [
|
|
1755
|
+
{
|
|
1756
|
+
internalType: "uint256",
|
|
1757
|
+
name: "",
|
|
1758
|
+
type: "uint256",
|
|
1759
|
+
},
|
|
1760
|
+
],
|
|
1761
|
+
stateMutability: "view",
|
|
1762
|
+
type: "function",
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
inputs: [
|
|
1766
|
+
{
|
|
1767
|
+
internalType: "address",
|
|
1768
|
+
name: "from",
|
|
1769
|
+
type: "address",
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
internalType: "address",
|
|
1773
|
+
name: "to",
|
|
1774
|
+
type: "address",
|
|
1775
|
+
},
|
|
1776
|
+
{
|
|
1777
|
+
internalType: "uint256",
|
|
1778
|
+
name: "tokenId",
|
|
1779
|
+
type: "uint256",
|
|
1780
|
+
},
|
|
1781
|
+
],
|
|
1782
|
+
name: "transferFrom",
|
|
1783
|
+
outputs: [],
|
|
1784
|
+
stateMutability: "nonpayable",
|
|
1785
|
+
type: "function",
|
|
1786
|
+
},
|
|
1787
|
+
];
|
|
1788
|
+
class ImmutableERC721Base__factory {
|
|
1789
|
+
static abi = _abi;
|
|
1790
|
+
static createInterface() {
|
|
1791
|
+
return new utils.Interface(_abi);
|
|
1792
|
+
}
|
|
1793
|
+
static connect(address, signerOrProvider) {
|
|
1794
|
+
return new Contract(address, _abi, signerOrProvider);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
class ERC721Factory {
|
|
1799
|
+
erc721;
|
|
1800
|
+
constructor(contractAddress, provider) {
|
|
1801
|
+
this.erc721 = ImmutableERC721Base__factory.connect(contractAddress, provider);
|
|
1802
|
+
}
|
|
1803
|
+
create() {
|
|
1804
|
+
return new ERC721(this.erc721);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* zkEVM orderbook SDK
|
|
1810
|
+
* @constructor
|
|
1811
|
+
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
1812
|
+
*/
|
|
1813
|
+
class Orderbook {
|
|
1814
|
+
config;
|
|
1815
|
+
apiClient;
|
|
1816
|
+
seaport;
|
|
1817
|
+
constructor(config) {
|
|
1818
|
+
this.config = config;
|
|
1819
|
+
// TODO: Move endpoint lookup to a map based on env. Just using override to get dev started
|
|
1820
|
+
const apiEndpoint = config.overrides?.apiEndpoint;
|
|
1821
|
+
if (!apiEndpoint) {
|
|
1822
|
+
throw new Error('API endpoint must be provided as an override');
|
|
1823
|
+
}
|
|
1824
|
+
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
1825
|
+
const chainId = config.overrides?.chainId;
|
|
1826
|
+
if (!chainId) {
|
|
1827
|
+
throw new Error('ChainID must be provided as an override');
|
|
1828
|
+
}
|
|
1829
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainId).create();
|
|
1830
|
+
this.seaport = new SeaportFactory(this.config.seaportContractAddress, this.config.zoneContractAddress, this.config.provider).create();
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Get an order by ID
|
|
1834
|
+
* @param {string} orderId - The orderId to find.
|
|
1835
|
+
* @return {OrderResult} The returned order result.
|
|
1836
|
+
*/
|
|
1837
|
+
getOrder(orderId) {
|
|
1838
|
+
return this.apiClient.getOrder(orderId);
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
1842
|
+
* in the params object.
|
|
1843
|
+
* @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
|
|
1844
|
+
* @return {Orders} The paged orders.
|
|
1845
|
+
*/
|
|
1846
|
+
listOrders(listOrderParams) {
|
|
1847
|
+
return this.apiClient.listOrders(listOrderParams);
|
|
1848
|
+
}
|
|
1849
|
+
/**
|
|
1850
|
+
* Get required transactions and messages for signing prior to creating a listing
|
|
1851
|
+
* through the createOrder method
|
|
1852
|
+
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
1853
|
+
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
1854
|
+
* the unsigned approval transaction, the typed order message for signing and
|
|
1855
|
+
* the order components that can be submitted to `createOrder` with a signature.
|
|
1856
|
+
*/
|
|
1857
|
+
async prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }) {
|
|
1858
|
+
const erc721 = new ERC721Factory(listingItem.contractAddress, this.config.provider).create();
|
|
1859
|
+
const royaltyInfo = await erc721.royaltyInfo(listingItem.tokenId, considerationItem.amount);
|
|
1860
|
+
return this.seaport.prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo,
|
|
1861
|
+
// Default order start to now
|
|
1862
|
+
new Date(),
|
|
1863
|
+
// Default order expiry to 2 years from now
|
|
1864
|
+
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
1865
|
+
}
|
|
1866
|
+
/**
|
|
1867
|
+
* Create an order
|
|
1868
|
+
* @param {CreateOrderParams} createOrderParams - create an order with the given params.
|
|
1869
|
+
* @return {OrderResult} The result of the order created in the Immutable services.
|
|
1870
|
+
*/
|
|
1871
|
+
createOrder(createOrderParams) {
|
|
1872
|
+
return this.apiClient.createOrder(createOrderParams);
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
1876
|
+
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
1877
|
+
* transaction can be submitted or it will be reverted.
|
|
1878
|
+
* @param {string} orderId - The orderId to fulfil.
|
|
1879
|
+
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
1880
|
+
* @return {FulfilOrderResponse} Approval and fulfilment transactions.
|
|
1881
|
+
*/
|
|
1882
|
+
async fulfillOrder(orderId, fulfillerAddress) {
|
|
1883
|
+
const orderResult = await this.apiClient.getOrder(orderId);
|
|
1884
|
+
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
1885
|
+
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
1886
|
+
}
|
|
1887
|
+
return this.seaport.fulfilOrder(orderResult.result, fulfillerAddress);
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
1891
|
+
* the account that created them.
|
|
1892
|
+
* @param {string} orderId - The orderId to cancel.
|
|
1893
|
+
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
1894
|
+
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
1895
|
+
*/
|
|
1896
|
+
async cancelOrder(orderId, accountAddress) {
|
|
1897
|
+
const orderResult = await this.apiClient.getOrder(orderId);
|
|
1898
|
+
if (orderResult.result.status !== OrderStatus.ACTIVE
|
|
1899
|
+
&& orderResult.result.status !== OrderStatus.INACTIVE
|
|
1900
|
+
&& orderResult.result.status !== OrderStatus.PENDING) {
|
|
1901
|
+
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
1902
|
+
}
|
|
1903
|
+
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
1904
|
+
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${orderId}`);
|
|
1905
|
+
}
|
|
1906
|
+
const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
|
|
1907
|
+
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
const module = 'orderbook';
|
|
1912
|
+
|
|
1913
|
+
export { Orderbook, module };
|