@imtbl/sdk 0.6.0-alpha → 0.6.1-alpha
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.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +18 -3
- package/dist/checkout_sdk.js +2182 -123
- package/dist/checkout_widgets.d.ts +10496 -153
- package/dist/checkout_widgets.js +57 -8
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +176 -42
- package/dist/index.d.ts +29 -7
- package/dist/index.js +176 -42
- package/dist/orderbook.d.ts +1 -3
- package/dist/orderbook.js +1 -3
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/checkout_sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$2 } from 'ethers';
|
|
1
|
+
import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$2, providers, constants } from 'ethers';
|
|
2
2
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
3
3
|
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
4
4
|
import { Token, TradeType, CurrencyAmount, Percent } from '@uniswap/sdk-core';
|
|
@@ -7,7 +7,9 @@ import { BigNumber as BigNumber$1 } from '@ethersproject/bignumber';
|
|
|
7
7
|
import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
|
|
8
8
|
import { keccak256 as keccak256$1 } from '@ethersproject/solidity';
|
|
9
9
|
import { SwapRouter } from '@uniswap/router-sdk';
|
|
10
|
-
import
|
|
10
|
+
import axios from 'axios';
|
|
11
|
+
import FormData from 'form-data';
|
|
12
|
+
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
11
13
|
|
|
12
14
|
var Environment$1;
|
|
13
15
|
(function (Environment) {
|
|
@@ -13669,7 +13671,7 @@ class SecondaryFee__factory extends ContractFactory {
|
|
|
13669
13671
|
/* Autogenerated file. Do not edit manually. */
|
|
13670
13672
|
/* tslint:disable */
|
|
13671
13673
|
/* eslint-disable */
|
|
13672
|
-
const _abi = [
|
|
13674
|
+
const _abi$4 = [
|
|
13673
13675
|
{
|
|
13674
13676
|
inputs: [],
|
|
13675
13677
|
stateMutability: "nonpayable",
|
|
@@ -14665,7 +14667,7 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
14665
14667
|
super(...args);
|
|
14666
14668
|
}
|
|
14667
14669
|
else {
|
|
14668
|
-
super(_abi, _bytecode, args[0]);
|
|
14670
|
+
super(_abi$4, _bytecode, args[0]);
|
|
14669
14671
|
}
|
|
14670
14672
|
}
|
|
14671
14673
|
deploy(overrides) {
|
|
@@ -14681,12 +14683,12 @@ class UniswapV3Pool__factory extends ContractFactory {
|
|
|
14681
14683
|
return super.connect(signer);
|
|
14682
14684
|
}
|
|
14683
14685
|
static bytecode = _bytecode;
|
|
14684
|
-
static abi = _abi;
|
|
14686
|
+
static abi = _abi$4;
|
|
14685
14687
|
static createInterface() {
|
|
14686
|
-
return new utils.Interface(_abi);
|
|
14688
|
+
return new utils.Interface(_abi$4);
|
|
14687
14689
|
}
|
|
14688
14690
|
static connect(address, signerOrProvider) {
|
|
14689
|
-
return new Contract$1(address, _abi, signerOrProvider);
|
|
14691
|
+
return new Contract$1(address, _abi$4, signerOrProvider);
|
|
14690
14692
|
}
|
|
14691
14693
|
}
|
|
14692
14694
|
|
|
@@ -15412,110 +15414,2092 @@ class Exchange {
|
|
|
15412
15414
|
}
|
|
15413
15415
|
}
|
|
15414
15416
|
|
|
15415
|
-
|
|
15417
|
+
class BaseHttpRequest {
|
|
15418
|
+
config;
|
|
15419
|
+
constructor(config) {
|
|
15420
|
+
this.config = config;
|
|
15421
|
+
}
|
|
15422
|
+
}
|
|
15416
15423
|
|
|
15417
|
-
|
|
15418
|
-
|
|
15419
|
-
|
|
15420
|
-
|
|
15421
|
-
|
|
15422
|
-
|
|
15423
|
-
|
|
15424
|
-
|
|
15425
|
-
|
|
15424
|
+
class ApiError extends Error {
|
|
15425
|
+
url;
|
|
15426
|
+
status;
|
|
15427
|
+
statusText;
|
|
15428
|
+
body;
|
|
15429
|
+
request;
|
|
15430
|
+
constructor(request, response, message) {
|
|
15431
|
+
super(message);
|
|
15432
|
+
this.name = 'ApiError';
|
|
15433
|
+
this.url = response.url;
|
|
15434
|
+
this.status = response.status;
|
|
15435
|
+
this.statusText = response.statusText;
|
|
15436
|
+
this.body = response.body;
|
|
15437
|
+
this.request = request;
|
|
15438
|
+
}
|
|
15439
|
+
}
|
|
15440
|
+
|
|
15441
|
+
/* istanbul ignore file */
|
|
15442
|
+
/* tslint:disable */
|
|
15443
|
+
/* eslint-disable */
|
|
15444
|
+
class CancelError extends Error {
|
|
15445
|
+
constructor(message) {
|
|
15446
|
+
super(message);
|
|
15447
|
+
this.name = 'CancelError';
|
|
15448
|
+
}
|
|
15449
|
+
get isCancelled() {
|
|
15450
|
+
return true;
|
|
15451
|
+
}
|
|
15452
|
+
}
|
|
15453
|
+
class CancelablePromise {
|
|
15454
|
+
[Symbol.toStringTag];
|
|
15455
|
+
_isResolved;
|
|
15456
|
+
_isRejected;
|
|
15457
|
+
_isCancelled;
|
|
15458
|
+
_cancelHandlers;
|
|
15459
|
+
_promise;
|
|
15460
|
+
_resolve;
|
|
15461
|
+
_reject;
|
|
15462
|
+
constructor(executor) {
|
|
15463
|
+
this._isResolved = false;
|
|
15464
|
+
this._isRejected = false;
|
|
15465
|
+
this._isCancelled = false;
|
|
15466
|
+
this._cancelHandlers = [];
|
|
15467
|
+
this._promise = new Promise((resolve, reject) => {
|
|
15468
|
+
this._resolve = resolve;
|
|
15469
|
+
this._reject = reject;
|
|
15470
|
+
const onResolve = (value) => {
|
|
15471
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
15472
|
+
return;
|
|
15473
|
+
}
|
|
15474
|
+
this._isResolved = true;
|
|
15475
|
+
this._resolve?.(value);
|
|
15476
|
+
};
|
|
15477
|
+
const onReject = (reason) => {
|
|
15478
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
15479
|
+
return;
|
|
15480
|
+
}
|
|
15481
|
+
this._isRejected = true;
|
|
15482
|
+
this._reject?.(reason);
|
|
15483
|
+
};
|
|
15484
|
+
const onCancel = (cancelHandler) => {
|
|
15485
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
15486
|
+
return;
|
|
15487
|
+
}
|
|
15488
|
+
this._cancelHandlers.push(cancelHandler);
|
|
15489
|
+
};
|
|
15490
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
15491
|
+
get: () => this._isResolved,
|
|
15492
|
+
});
|
|
15493
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
15494
|
+
get: () => this._isRejected,
|
|
15495
|
+
});
|
|
15496
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
15497
|
+
get: () => this._isCancelled,
|
|
15498
|
+
});
|
|
15499
|
+
return executor(onResolve, onReject, onCancel);
|
|
15500
|
+
});
|
|
15501
|
+
}
|
|
15502
|
+
then(onFulfilled, onRejected) {
|
|
15503
|
+
return this._promise.then(onFulfilled, onRejected);
|
|
15504
|
+
}
|
|
15505
|
+
catch(onRejected) {
|
|
15506
|
+
return this._promise.catch(onRejected);
|
|
15507
|
+
}
|
|
15508
|
+
finally(onFinally) {
|
|
15509
|
+
return this._promise.finally(onFinally);
|
|
15510
|
+
}
|
|
15511
|
+
cancel() {
|
|
15512
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
15513
|
+
return;
|
|
15514
|
+
}
|
|
15515
|
+
this._isCancelled = true;
|
|
15516
|
+
if (this._cancelHandlers.length) {
|
|
15517
|
+
try {
|
|
15518
|
+
for (const cancelHandler of this._cancelHandlers) {
|
|
15519
|
+
cancelHandler();
|
|
15520
|
+
}
|
|
15426
15521
|
}
|
|
15427
|
-
|
|
15428
|
-
|
|
15429
|
-
|
|
15430
|
-
},
|
|
15431
|
-
{
|
|
15432
|
-
constant: true,
|
|
15433
|
-
inputs: [],
|
|
15434
|
-
name: "decimals",
|
|
15435
|
-
outputs: [
|
|
15436
|
-
{
|
|
15437
|
-
name: "",
|
|
15438
|
-
type: "uint8"
|
|
15522
|
+
catch (error) {
|
|
15523
|
+
console.warn('Cancellation threw an error', error);
|
|
15524
|
+
return;
|
|
15439
15525
|
}
|
|
15440
|
-
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
}
|
|
15444
|
-
{
|
|
15445
|
-
|
|
15446
|
-
|
|
15447
|
-
|
|
15448
|
-
|
|
15449
|
-
|
|
15526
|
+
}
|
|
15527
|
+
this._cancelHandlers.length = 0;
|
|
15528
|
+
this._reject?.(new CancelError('Request aborted'));
|
|
15529
|
+
}
|
|
15530
|
+
get isCancelled() {
|
|
15531
|
+
return this._isCancelled;
|
|
15532
|
+
}
|
|
15533
|
+
}
|
|
15534
|
+
|
|
15535
|
+
/* istanbul ignore file */
|
|
15536
|
+
/* tslint:disable */
|
|
15537
|
+
/* eslint-disable */
|
|
15538
|
+
const isDefined = (value) => {
|
|
15539
|
+
return value !== undefined && value !== null;
|
|
15540
|
+
};
|
|
15541
|
+
const isString = (value) => {
|
|
15542
|
+
return typeof value === 'string';
|
|
15543
|
+
};
|
|
15544
|
+
const isStringWithValue = (value) => {
|
|
15545
|
+
return isString(value) && value !== '';
|
|
15546
|
+
};
|
|
15547
|
+
const isBlob = (value) => {
|
|
15548
|
+
return (typeof value === 'object' &&
|
|
15549
|
+
typeof value.type === 'string' &&
|
|
15550
|
+
typeof value.stream === 'function' &&
|
|
15551
|
+
typeof value.arrayBuffer === 'function' &&
|
|
15552
|
+
typeof value.constructor === 'function' &&
|
|
15553
|
+
typeof value.constructor.name === 'string' &&
|
|
15554
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
15555
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
15556
|
+
};
|
|
15557
|
+
const isFormData = (value) => {
|
|
15558
|
+
return value instanceof FormData;
|
|
15559
|
+
};
|
|
15560
|
+
const isSuccess = (status) => {
|
|
15561
|
+
return status >= 200 && status < 300;
|
|
15562
|
+
};
|
|
15563
|
+
const base64 = (str) => {
|
|
15564
|
+
try {
|
|
15565
|
+
return btoa(str);
|
|
15566
|
+
}
|
|
15567
|
+
catch (err) {
|
|
15568
|
+
// @ts-ignore
|
|
15569
|
+
return Buffer.from(str).toString('base64');
|
|
15570
|
+
}
|
|
15571
|
+
};
|
|
15572
|
+
const getQueryString = (params) => {
|
|
15573
|
+
const qs = [];
|
|
15574
|
+
const append = (key, value) => {
|
|
15575
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
15576
|
+
};
|
|
15577
|
+
const process = (key, value) => {
|
|
15578
|
+
if (isDefined(value)) {
|
|
15579
|
+
if (Array.isArray(value)) {
|
|
15580
|
+
value.forEach(v => {
|
|
15581
|
+
process(key, v);
|
|
15582
|
+
});
|
|
15450
15583
|
}
|
|
15451
|
-
|
|
15452
|
-
|
|
15453
|
-
|
|
15454
|
-
|
|
15455
|
-
name: "balance",
|
|
15456
|
-
type: "uint256"
|
|
15584
|
+
else if (typeof value === 'object') {
|
|
15585
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
15586
|
+
process(`${key}[${k}]`, v);
|
|
15587
|
+
});
|
|
15457
15588
|
}
|
|
15458
|
-
|
|
15459
|
-
|
|
15460
|
-
type: "function"
|
|
15461
|
-
},
|
|
15462
|
-
{
|
|
15463
|
-
constant: true,
|
|
15464
|
-
inputs: [],
|
|
15465
|
-
name: "symbol",
|
|
15466
|
-
outputs: [
|
|
15467
|
-
{
|
|
15468
|
-
name: "",
|
|
15469
|
-
type: "string"
|
|
15589
|
+
else {
|
|
15590
|
+
append(key, value);
|
|
15470
15591
|
}
|
|
15471
|
-
|
|
15472
|
-
|
|
15473
|
-
|
|
15592
|
+
}
|
|
15593
|
+
};
|
|
15594
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
15595
|
+
process(key, value);
|
|
15596
|
+
});
|
|
15597
|
+
if (qs.length > 0) {
|
|
15598
|
+
return `?${qs.join('&')}`;
|
|
15474
15599
|
}
|
|
15475
|
-
|
|
15476
|
-
|
|
15477
|
-
|
|
15600
|
+
return '';
|
|
15601
|
+
};
|
|
15602
|
+
const getUrl = (config, options) => {
|
|
15603
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
15604
|
+
const path = options.url
|
|
15605
|
+
.replace('{api-version}', config.VERSION)
|
|
15606
|
+
.replace(/{(.*?)}/g, (substring, group) => {
|
|
15607
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
15608
|
+
return encoder(String(options.path[group]));
|
|
15609
|
+
}
|
|
15610
|
+
return substring;
|
|
15611
|
+
});
|
|
15612
|
+
const url = `${config.BASE}${path}`;
|
|
15613
|
+
if (options.query) {
|
|
15614
|
+
return `${url}${getQueryString(options.query)}`;
|
|
15615
|
+
}
|
|
15616
|
+
return url;
|
|
15617
|
+
};
|
|
15618
|
+
const getFormData = (options) => {
|
|
15619
|
+
if (options.formData) {
|
|
15620
|
+
const formData = new FormData();
|
|
15621
|
+
const process = (key, value) => {
|
|
15622
|
+
if (isString(value) || isBlob(value)) {
|
|
15623
|
+
formData.append(key, value);
|
|
15624
|
+
}
|
|
15625
|
+
else {
|
|
15626
|
+
formData.append(key, JSON.stringify(value));
|
|
15627
|
+
}
|
|
15628
|
+
};
|
|
15629
|
+
Object.entries(options.formData)
|
|
15630
|
+
.filter(([_, value]) => isDefined(value))
|
|
15631
|
+
.forEach(([key, value]) => {
|
|
15632
|
+
if (Array.isArray(value)) {
|
|
15633
|
+
value.forEach(v => process(key, v));
|
|
15634
|
+
}
|
|
15635
|
+
else {
|
|
15636
|
+
process(key, value);
|
|
15637
|
+
}
|
|
15638
|
+
});
|
|
15639
|
+
return formData;
|
|
15640
|
+
}
|
|
15641
|
+
return undefined;
|
|
15642
|
+
};
|
|
15643
|
+
const resolve = async (options, resolver) => {
|
|
15644
|
+
if (typeof resolver === 'function') {
|
|
15645
|
+
return resolver(options);
|
|
15646
|
+
}
|
|
15647
|
+
return resolver;
|
|
15648
|
+
};
|
|
15649
|
+
const getHeaders = async (config, options, formData) => {
|
|
15650
|
+
const token = await resolve(options, config.TOKEN);
|
|
15651
|
+
const username = await resolve(options, config.USERNAME);
|
|
15652
|
+
const password = await resolve(options, config.PASSWORD);
|
|
15653
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
15654
|
+
const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {};
|
|
15655
|
+
const headers = Object.entries({
|
|
15656
|
+
Accept: 'application/json',
|
|
15657
|
+
...additionalHeaders,
|
|
15658
|
+
...options.headers,
|
|
15659
|
+
...formHeaders,
|
|
15660
|
+
})
|
|
15661
|
+
.filter(([_, value]) => isDefined(value))
|
|
15662
|
+
.reduce((headers, [key, value]) => ({
|
|
15663
|
+
...headers,
|
|
15664
|
+
[key]: String(value),
|
|
15665
|
+
}), {});
|
|
15666
|
+
if (isStringWithValue(token)) {
|
|
15667
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
15668
|
+
}
|
|
15669
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
15670
|
+
const credentials = base64(`${username}:${password}`);
|
|
15671
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
15672
|
+
}
|
|
15673
|
+
if (options.body) {
|
|
15674
|
+
if (options.mediaType) {
|
|
15675
|
+
headers['Content-Type'] = options.mediaType;
|
|
15676
|
+
}
|
|
15677
|
+
else if (isBlob(options.body)) {
|
|
15678
|
+
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
15679
|
+
}
|
|
15680
|
+
else if (isString(options.body)) {
|
|
15681
|
+
headers['Content-Type'] = 'text/plain';
|
|
15682
|
+
}
|
|
15683
|
+
else if (!isFormData(options.body)) {
|
|
15684
|
+
headers['Content-Type'] = 'application/json';
|
|
15685
|
+
}
|
|
15686
|
+
}
|
|
15687
|
+
return headers;
|
|
15688
|
+
};
|
|
15689
|
+
const getRequestBody = (options) => {
|
|
15690
|
+
if (options.body) {
|
|
15691
|
+
return options.body;
|
|
15692
|
+
}
|
|
15693
|
+
return undefined;
|
|
15694
|
+
};
|
|
15695
|
+
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
15696
|
+
const source = axios.CancelToken.source();
|
|
15697
|
+
const requestConfig = {
|
|
15698
|
+
url,
|
|
15699
|
+
headers,
|
|
15700
|
+
data: body ?? formData,
|
|
15701
|
+
method: options.method,
|
|
15702
|
+
withCredentials: config.WITH_CREDENTIALS,
|
|
15703
|
+
cancelToken: source.token,
|
|
15704
|
+
};
|
|
15705
|
+
onCancel(() => source.cancel('The user aborted a request.'));
|
|
15706
|
+
try {
|
|
15707
|
+
return await axios.request(requestConfig);
|
|
15708
|
+
}
|
|
15709
|
+
catch (error) {
|
|
15710
|
+
const axiosError = error;
|
|
15711
|
+
if (axiosError.response) {
|
|
15712
|
+
return axiosError.response;
|
|
15713
|
+
}
|
|
15714
|
+
throw error;
|
|
15715
|
+
}
|
|
15716
|
+
};
|
|
15717
|
+
const getResponseHeader = (response, responseHeader) => {
|
|
15718
|
+
if (responseHeader) {
|
|
15719
|
+
const content = response.headers[responseHeader];
|
|
15720
|
+
if (isString(content)) {
|
|
15721
|
+
return content;
|
|
15722
|
+
}
|
|
15723
|
+
}
|
|
15724
|
+
return undefined;
|
|
15725
|
+
};
|
|
15726
|
+
const getResponseBody = (response) => {
|
|
15727
|
+
if (response.status !== 204) {
|
|
15728
|
+
return response.data;
|
|
15729
|
+
}
|
|
15730
|
+
return undefined;
|
|
15731
|
+
};
|
|
15732
|
+
const catchErrorCodes = (options, result) => {
|
|
15733
|
+
const errors = {
|
|
15734
|
+
400: 'Bad Request',
|
|
15735
|
+
401: 'Unauthorized',
|
|
15736
|
+
403: 'Forbidden',
|
|
15737
|
+
404: 'Not Found',
|
|
15738
|
+
500: 'Internal Server Error',
|
|
15739
|
+
502: 'Bad Gateway',
|
|
15740
|
+
503: 'Service Unavailable',
|
|
15741
|
+
...options.errors,
|
|
15742
|
+
};
|
|
15743
|
+
const error = errors[result.status];
|
|
15744
|
+
if (error) {
|
|
15745
|
+
throw new ApiError(options, result, error);
|
|
15746
|
+
}
|
|
15747
|
+
if (!result.ok) {
|
|
15748
|
+
throw new ApiError(options, result, 'Generic Error');
|
|
15749
|
+
}
|
|
15750
|
+
};
|
|
15478
15751
|
/**
|
|
15479
|
-
*
|
|
15480
|
-
* @
|
|
15481
|
-
* @
|
|
15482
|
-
* @
|
|
15483
|
-
* @
|
|
15484
|
-
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
|
|
15488
|
-
|
|
15489
|
-
|
|
15490
|
-
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15495
|
-
(
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15501
|
-
|
|
15752
|
+
* Request method
|
|
15753
|
+
* @param config The OpenAPI configuration object
|
|
15754
|
+
* @param options The request options from the service
|
|
15755
|
+
* @returns CancelablePromise<T>
|
|
15756
|
+
* @throws ApiError
|
|
15757
|
+
*/
|
|
15758
|
+
const request = (config, options) => {
|
|
15759
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
15760
|
+
try {
|
|
15761
|
+
const url = getUrl(config, options);
|
|
15762
|
+
const formData = getFormData(options);
|
|
15763
|
+
const body = getRequestBody(options);
|
|
15764
|
+
const headers = await getHeaders(config, options, formData);
|
|
15765
|
+
if (!onCancel.isCancelled) {
|
|
15766
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
15767
|
+
const responseBody = getResponseBody(response);
|
|
15768
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
15769
|
+
const result = {
|
|
15770
|
+
url,
|
|
15771
|
+
ok: isSuccess(response.status),
|
|
15772
|
+
status: response.status,
|
|
15773
|
+
statusText: response.statusText,
|
|
15774
|
+
body: responseHeader ?? responseBody,
|
|
15775
|
+
};
|
|
15776
|
+
catchErrorCodes(options, result);
|
|
15777
|
+
resolve(result.body);
|
|
15778
|
+
}
|
|
15779
|
+
}
|
|
15780
|
+
catch (error) {
|
|
15781
|
+
reject(error);
|
|
15782
|
+
}
|
|
15783
|
+
});
|
|
15784
|
+
};
|
|
15502
15785
|
|
|
15786
|
+
class AxiosHttpRequest extends BaseHttpRequest {
|
|
15787
|
+
constructor(config) {
|
|
15788
|
+
super(config);
|
|
15789
|
+
}
|
|
15790
|
+
/**
|
|
15791
|
+
* Request method
|
|
15792
|
+
* @param options The request options from the service
|
|
15793
|
+
* @returns CancelablePromise<T>
|
|
15794
|
+
* @throws ApiError
|
|
15795
|
+
*/
|
|
15796
|
+
request(options) {
|
|
15797
|
+
return request(this.config, options);
|
|
15798
|
+
}
|
|
15799
|
+
}
|
|
15503
15800
|
|
|
15801
|
+
class OrdersService {
|
|
15802
|
+
httpRequest;
|
|
15803
|
+
constructor(httpRequest) {
|
|
15804
|
+
this.httpRequest = httpRequest;
|
|
15805
|
+
}
|
|
15806
|
+
/**
|
|
15807
|
+
* List all listings
|
|
15808
|
+
* List all listings
|
|
15809
|
+
* @returns ListListingsResult OK response.
|
|
15810
|
+
* @throws ApiError
|
|
15811
|
+
*/
|
|
15812
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
15813
|
+
return this.httpRequest.request({
|
|
15814
|
+
method: 'GET',
|
|
15815
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
15816
|
+
path: {
|
|
15817
|
+
'chain_name': chainName,
|
|
15818
|
+
},
|
|
15819
|
+
query: {
|
|
15820
|
+
'status': status,
|
|
15821
|
+
'sell_item_contract_address': sellItemContractAddress,
|
|
15822
|
+
'buy_item_contract_address': buyItemContractAddress,
|
|
15823
|
+
'sell_item_token_id': sellItemTokenId,
|
|
15824
|
+
'page_size': pageSize,
|
|
15825
|
+
'sort_by': sortBy,
|
|
15826
|
+
'sort_direction': sortDirection,
|
|
15827
|
+
'page_cursor': pageCursor,
|
|
15828
|
+
},
|
|
15829
|
+
errors: {
|
|
15830
|
+
400: `Bad Request (400)`,
|
|
15831
|
+
404: `The specified resource was not found (404)`,
|
|
15832
|
+
500: `Internal Server Error (500)`,
|
|
15833
|
+
},
|
|
15834
|
+
});
|
|
15835
|
+
}
|
|
15836
|
+
/**
|
|
15837
|
+
* Create a listing
|
|
15838
|
+
* Create a listing
|
|
15839
|
+
* @returns ListingResult Created response.
|
|
15840
|
+
* @throws ApiError
|
|
15841
|
+
*/
|
|
15842
|
+
createListing({ chainName, requestBody, }) {
|
|
15843
|
+
return this.httpRequest.request({
|
|
15844
|
+
method: 'POST',
|
|
15845
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
15846
|
+
path: {
|
|
15847
|
+
'chain_name': chainName,
|
|
15848
|
+
},
|
|
15849
|
+
body: requestBody,
|
|
15850
|
+
mediaType: 'application/json',
|
|
15851
|
+
errors: {
|
|
15852
|
+
400: `Bad Request (400)`,
|
|
15853
|
+
404: `The specified resource was not found (404)`,
|
|
15854
|
+
500: `Internal Server Error (500)`,
|
|
15855
|
+
},
|
|
15856
|
+
});
|
|
15857
|
+
}
|
|
15858
|
+
/**
|
|
15859
|
+
* Get a single listing by ID
|
|
15860
|
+
* Get a single listing by ID
|
|
15861
|
+
* @returns ListingResult OK response.
|
|
15862
|
+
* @throws ApiError
|
|
15863
|
+
*/
|
|
15864
|
+
getListing({ chainName, listingId, }) {
|
|
15865
|
+
return this.httpRequest.request({
|
|
15866
|
+
method: 'GET',
|
|
15867
|
+
url: '/v1/chains/{chain_name}/orders/listings/{listing_id}',
|
|
15868
|
+
path: {
|
|
15869
|
+
'chain_name': chainName,
|
|
15870
|
+
'listing_id': listingId,
|
|
15871
|
+
},
|
|
15872
|
+
errors: {
|
|
15873
|
+
400: `Bad Request (400)`,
|
|
15874
|
+
404: `The specified resource was not found (404)`,
|
|
15875
|
+
500: `Internal Server Error (500)`,
|
|
15876
|
+
},
|
|
15877
|
+
});
|
|
15878
|
+
}
|
|
15879
|
+
}
|
|
15504
15880
|
|
|
15881
|
+
class OrderBookClient {
|
|
15882
|
+
orders;
|
|
15883
|
+
request;
|
|
15884
|
+
constructor(config, HttpRequest = AxiosHttpRequest) {
|
|
15885
|
+
this.request = new HttpRequest({
|
|
15886
|
+
BASE: config?.BASE ?? 'https://api.dev.immutable.com',
|
|
15887
|
+
VERSION: config?.VERSION ?? '1.0.0',
|
|
15888
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
15889
|
+
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
15890
|
+
TOKEN: config?.TOKEN,
|
|
15891
|
+
USERNAME: config?.USERNAME,
|
|
15892
|
+
PASSWORD: config?.PASSWORD,
|
|
15893
|
+
HEADERS: config?.HEADERS,
|
|
15894
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
15895
|
+
});
|
|
15896
|
+
this.orders = new OrdersService(this.request);
|
|
15897
|
+
}
|
|
15898
|
+
}
|
|
15505
15899
|
|
|
15900
|
+
/* istanbul ignore file */
|
|
15901
|
+
/* tslint:disable */
|
|
15902
|
+
/* eslint-disable */
|
|
15903
|
+
var CreateOrderProtocolData;
|
|
15904
|
+
(function (CreateOrderProtocolData) {
|
|
15905
|
+
(function (order_type) {
|
|
15906
|
+
order_type["FULL_RESTRICTED"] = "FULL_RESTRICTED";
|
|
15907
|
+
})(CreateOrderProtocolData.order_type || (CreateOrderProtocolData.order_type = {}));
|
|
15908
|
+
})(CreateOrderProtocolData || (CreateOrderProtocolData = {}));
|
|
15909
|
+
|
|
15910
|
+
/* istanbul ignore file */
|
|
15911
|
+
/* tslint:disable */
|
|
15912
|
+
/* eslint-disable */
|
|
15913
|
+
var Fee;
|
|
15914
|
+
(function (Fee) {
|
|
15915
|
+
(function (fee_type) {
|
|
15916
|
+
fee_type["ROYALTY"] = "ROYALTY";
|
|
15917
|
+
})(Fee.fee_type || (Fee.fee_type = {}));
|
|
15918
|
+
})(Fee || (Fee = {}));
|
|
15919
|
+
|
|
15920
|
+
/* istanbul ignore file */
|
|
15921
|
+
/* tslint:disable */
|
|
15922
|
+
/* eslint-disable */
|
|
15923
|
+
/**
|
|
15924
|
+
* The Order status
|
|
15925
|
+
*/
|
|
15926
|
+
var OrderStatus;
|
|
15927
|
+
(function (OrderStatus) {
|
|
15928
|
+
OrderStatus["PENDING"] = "PENDING";
|
|
15929
|
+
OrderStatus["ACTIVE"] = "ACTIVE";
|
|
15930
|
+
OrderStatus["INACTIVE"] = "INACTIVE";
|
|
15931
|
+
OrderStatus["FILLED"] = "FILLED";
|
|
15932
|
+
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
15933
|
+
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
15934
|
+
})(OrderStatus || (OrderStatus = {}));
|
|
15506
15935
|
|
|
15936
|
+
/* eslint-disable */
|
|
15937
|
+
// TODO: Resolve these from seaport-js.
|
|
15938
|
+
// There is some bundling issue that is preventing this from working
|
|
15939
|
+
const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
|
|
15940
|
+
const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
15941
|
+
const SEAPORT_CONTRACT_VERSION_V1_5 = '1.5';
|
|
15942
|
+
const EIP_712_ORDER_TYPE = {
|
|
15943
|
+
OrderComponents: [
|
|
15944
|
+
{ name: 'offerer', type: 'address' },
|
|
15945
|
+
{ name: 'zone', type: 'address' },
|
|
15946
|
+
{ name: 'offer', type: 'OfferItem[]' },
|
|
15947
|
+
{ name: 'consideration', type: 'ConsiderationItem[]' },
|
|
15948
|
+
{ name: 'orderType', type: 'uint8' },
|
|
15949
|
+
{ name: 'startTime', type: 'uint256' },
|
|
15950
|
+
{ name: 'endTime', type: 'uint256' },
|
|
15951
|
+
{ name: 'zoneHash', type: 'bytes32' },
|
|
15952
|
+
{ name: 'salt', type: 'uint256' },
|
|
15953
|
+
{ name: 'conduitKey', type: 'bytes32' },
|
|
15954
|
+
{ name: 'counter', type: 'uint256' },
|
|
15955
|
+
],
|
|
15956
|
+
OfferItem: [
|
|
15957
|
+
{ name: 'itemType', type: 'uint8' },
|
|
15958
|
+
{ name: 'token', type: 'address' },
|
|
15959
|
+
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
15960
|
+
{ name: 'startAmount', type: 'uint256' },
|
|
15961
|
+
{ name: 'endAmount', type: 'uint256' },
|
|
15962
|
+
],
|
|
15963
|
+
ConsiderationItem: [
|
|
15964
|
+
{ name: 'itemType', type: 'uint8' },
|
|
15965
|
+
{ name: 'token', type: 'address' },
|
|
15966
|
+
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
15967
|
+
{ name: 'startAmount', type: 'uint256' },
|
|
15968
|
+
{ name: 'endAmount', type: 'uint256' },
|
|
15969
|
+
{ name: 'recipient', type: 'address' },
|
|
15970
|
+
],
|
|
15971
|
+
};
|
|
15972
|
+
var OrderType;
|
|
15973
|
+
(function (OrderType) {
|
|
15974
|
+
OrderType[OrderType["FULL_OPEN"] = 0] = "FULL_OPEN";
|
|
15975
|
+
OrderType[OrderType["PARTIAL_OPEN"] = 1] = "PARTIAL_OPEN";
|
|
15976
|
+
OrderType[OrderType["FULL_RESTRICTED"] = 2] = "FULL_RESTRICTED";
|
|
15977
|
+
OrderType[OrderType["PARTIAL_RESTRICTED"] = 3] = "PARTIAL_RESTRICTED";
|
|
15978
|
+
})(OrderType || (OrderType = {}));
|
|
15979
|
+
var ItemType;
|
|
15980
|
+
(function (ItemType) {
|
|
15981
|
+
ItemType[ItemType["NATIVE"] = 0] = "NATIVE";
|
|
15982
|
+
ItemType[ItemType["ERC20"] = 1] = "ERC20";
|
|
15983
|
+
ItemType[ItemType["ERC721"] = 2] = "ERC721";
|
|
15984
|
+
ItemType[ItemType["ERC1155"] = 3] = "ERC1155";
|
|
15985
|
+
ItemType[ItemType["ERC721_WITH_CRITERIA"] = 4] = "ERC721_WITH_CRITERIA";
|
|
15986
|
+
ItemType[ItemType["ERC1155_WITH_CRITERIA"] = 5] = "ERC1155_WITH_CRITERIA";
|
|
15987
|
+
})(ItemType || (ItemType = {}));
|
|
15988
|
+
var Side;
|
|
15989
|
+
(function (Side) {
|
|
15990
|
+
Side[Side["OFFER"] = 0] = "OFFER";
|
|
15991
|
+
Side[Side["CONSIDERATION"] = 1] = "CONSIDERATION";
|
|
15992
|
+
})(Side || (Side = {}));
|
|
15993
|
+
var BasicOrderRouteType;
|
|
15994
|
+
(function (BasicOrderRouteType) {
|
|
15995
|
+
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC721"] = 0] = "ETH_TO_ERC721";
|
|
15996
|
+
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC1155"] = 1] = "ETH_TO_ERC1155";
|
|
15997
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC721"] = 2] = "ERC20_TO_ERC721";
|
|
15998
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC1155"] = 3] = "ERC20_TO_ERC1155";
|
|
15999
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC721_TO_ERC20"] = 4] = "ERC721_TO_ERC20";
|
|
16000
|
+
BasicOrderRouteType[BasicOrderRouteType["ERC1155_TO_ERC20"] = 5] = "ERC1155_TO_ERC20";
|
|
16001
|
+
})(BasicOrderRouteType || (BasicOrderRouteType = {}));
|
|
16002
|
+
|
|
16003
|
+
function getOrderComponentsFromMessage(orderMessage) {
|
|
16004
|
+
const data = JSON.parse(orderMessage);
|
|
16005
|
+
const orderComponents = data.message;
|
|
16006
|
+
orderComponents.salt = BigNumber$2.from(orderComponents.salt).toHexString();
|
|
16007
|
+
return orderComponents;
|
|
16008
|
+
}
|
|
15507
16009
|
|
|
15508
|
-
|
|
15509
|
-
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
|
|
16010
|
+
// Add 20% more gas than estimate to prevent out of gas errors
|
|
16011
|
+
// This can always be overwritten by the user signing the transaction
|
|
16012
|
+
async function prepareTransaction(transactionMethods) {
|
|
16013
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
16014
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
16015
|
+
transaction.gasLimit = transaction.gasLimit
|
|
16016
|
+
.add(transaction.gasLimit.div(5));
|
|
16017
|
+
return transaction;
|
|
16018
|
+
}
|
|
15513
16019
|
|
|
16020
|
+
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
16021
|
+
const considerationItems = order.buy.map((buyItem) => {
|
|
16022
|
+
switch (buyItem.item_type) {
|
|
16023
|
+
case 'NATIVE':
|
|
16024
|
+
return {
|
|
16025
|
+
startAmount: buyItem.start_amount,
|
|
16026
|
+
endAmount: buyItem.start_amount,
|
|
16027
|
+
itemType: ItemType.NATIVE,
|
|
16028
|
+
recipient: order.account_address,
|
|
16029
|
+
token: constants.AddressZero,
|
|
16030
|
+
identifierOrCriteria: '0',
|
|
16031
|
+
};
|
|
16032
|
+
case 'ERC20':
|
|
16033
|
+
return {
|
|
16034
|
+
startAmount: buyItem.start_amount,
|
|
16035
|
+
endAmount: buyItem.start_amount,
|
|
16036
|
+
itemType: ItemType.ERC20,
|
|
16037
|
+
recipient: order.account_address,
|
|
16038
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
16039
|
+
identifierOrCriteria: '0',
|
|
16040
|
+
};
|
|
16041
|
+
default: // ERC721
|
|
16042
|
+
return {
|
|
16043
|
+
startAmount: '1',
|
|
16044
|
+
endAmount: '1',
|
|
16045
|
+
itemType: ItemType.ERC721,
|
|
16046
|
+
recipient: order.account_address,
|
|
16047
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
16048
|
+
identifierOrCriteria: '0',
|
|
16049
|
+
};
|
|
16050
|
+
}
|
|
16051
|
+
});
|
|
16052
|
+
const fees = order.fees.map((fee) => ({
|
|
16053
|
+
startAmount: fee.amount,
|
|
16054
|
+
endAmount: fee.amount,
|
|
16055
|
+
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
16056
|
+
recipient: fee.recipient,
|
|
16057
|
+
token: order.buy[0].item_type === 'ERC20'
|
|
16058
|
+
? order.buy[0].contract_address
|
|
16059
|
+
: constants.AddressZero,
|
|
16060
|
+
identifierOrCriteria: '0',
|
|
16061
|
+
}));
|
|
16062
|
+
return {
|
|
16063
|
+
conduitKey: constants.HashZero,
|
|
16064
|
+
consideration: [...considerationItems, ...fees],
|
|
16065
|
+
offer: order.sell.map((sellItem) => {
|
|
16066
|
+
const erc721Item = sellItem;
|
|
16067
|
+
return {
|
|
16068
|
+
startAmount: '1',
|
|
16069
|
+
endAmount: '1',
|
|
16070
|
+
itemType: ItemType.ERC721,
|
|
16071
|
+
token: erc721Item.contract_address,
|
|
16072
|
+
identifierOrCriteria: erc721Item.token_id,
|
|
16073
|
+
};
|
|
16074
|
+
}),
|
|
16075
|
+
counter,
|
|
16076
|
+
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
|
|
16077
|
+
startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
|
|
16078
|
+
salt: order.salt,
|
|
16079
|
+
offerer: order.account_address,
|
|
16080
|
+
zone: zoneAddress,
|
|
16081
|
+
totalOriginalConsiderationItems: 2,
|
|
16082
|
+
orderType: OrderType.FULL_RESTRICTED,
|
|
16083
|
+
zoneHash: constants.HashZero,
|
|
16084
|
+
};
|
|
16085
|
+
}
|
|
15514
16086
|
|
|
15515
|
-
|
|
15516
|
-
|
|
15517
|
-
|
|
15518
|
-
|
|
16087
|
+
class Seaport {
|
|
16088
|
+
seaportLibFactory;
|
|
16089
|
+
provider;
|
|
16090
|
+
seaportContractAddress;
|
|
16091
|
+
zoneContractAddress;
|
|
16092
|
+
constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
|
|
16093
|
+
this.seaportLibFactory = seaportLibFactory;
|
|
16094
|
+
this.provider = provider;
|
|
16095
|
+
this.seaportContractAddress = seaportContractAddress;
|
|
16096
|
+
this.zoneContractAddress = zoneContractAddress;
|
|
16097
|
+
}
|
|
16098
|
+
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
16099
|
+
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
16100
|
+
let approvalTransaction;
|
|
16101
|
+
const approvalAction = actions
|
|
16102
|
+
.find((action) => action.type === 'approval');
|
|
16103
|
+
if (approvalAction) {
|
|
16104
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
16105
|
+
}
|
|
16106
|
+
const createAction = actions
|
|
16107
|
+
.find((action) => action.type === 'create');
|
|
16108
|
+
if (!createAction) {
|
|
16109
|
+
throw new Error('No create order action found');
|
|
16110
|
+
}
|
|
16111
|
+
const orderMessageToSign = await createAction.getMessageToSign();
|
|
16112
|
+
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
16113
|
+
return {
|
|
16114
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
16115
|
+
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
16116
|
+
orderComponents,
|
|
16117
|
+
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
16118
|
+
};
|
|
16119
|
+
}
|
|
16120
|
+
async fulfilOrder(order, account) {
|
|
16121
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
16122
|
+
const seaportLib = this.getSeaportLib(order);
|
|
16123
|
+
const { actions } = await seaportLib.fulfillOrders({
|
|
16124
|
+
accountAddress: account,
|
|
16125
|
+
fulfillOrderDetails: [{
|
|
16126
|
+
order: {
|
|
16127
|
+
parameters: orderComponents,
|
|
16128
|
+
signature: order.signature,
|
|
16129
|
+
},
|
|
16130
|
+
extraData: order.protocol_data.operator_signature,
|
|
16131
|
+
}],
|
|
16132
|
+
});
|
|
16133
|
+
let approvalTransaction;
|
|
16134
|
+
const approvalAction = actions
|
|
16135
|
+
.find((action) => action.type === 'approval');
|
|
16136
|
+
if (approvalAction) {
|
|
16137
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
16138
|
+
}
|
|
16139
|
+
const fulfillmentAction = actions
|
|
16140
|
+
.find((action) => action.type === 'exchange');
|
|
16141
|
+
if (!fulfillmentAction) {
|
|
16142
|
+
throw new Error('No exchange action found');
|
|
16143
|
+
}
|
|
16144
|
+
const fulfillmentTransaction = await prepareTransaction(fulfillmentAction.transactionMethods);
|
|
16145
|
+
return {
|
|
16146
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
16147
|
+
unsignedFulfillmentTransaction: fulfillmentTransaction,
|
|
16148
|
+
};
|
|
16149
|
+
}
|
|
16150
|
+
async cancelOrder(order, account) {
|
|
16151
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
16152
|
+
const seaportLib = this.getSeaportLib(order);
|
|
16153
|
+
const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
|
|
16154
|
+
return prepareTransaction(cancellationTransaction);
|
|
16155
|
+
}
|
|
16156
|
+
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
16157
|
+
const orderCounter = order.protocol_data.counter;
|
|
16158
|
+
return mapImmutableOrderToSeaportOrderComponents(order, orderCounter, this.zoneContractAddress);
|
|
16159
|
+
}
|
|
16160
|
+
createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
16161
|
+
const seaportLib = this.getSeaportLib();
|
|
16162
|
+
return seaportLib.createOrder({
|
|
16163
|
+
allowPartialFills: false,
|
|
16164
|
+
offer: [
|
|
16165
|
+
{
|
|
16166
|
+
itemType: ItemType.ERC721,
|
|
16167
|
+
token: listingItem.contractAddress,
|
|
16168
|
+
identifier: listingItem.tokenId,
|
|
16169
|
+
},
|
|
16170
|
+
],
|
|
16171
|
+
consideration: [
|
|
16172
|
+
{
|
|
16173
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
16174
|
+
amount: considerationItem.amount,
|
|
16175
|
+
recipient: offerer,
|
|
16176
|
+
},
|
|
16177
|
+
{
|
|
16178
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
16179
|
+
amount: royaltyInfo.amountRequired,
|
|
16180
|
+
recipient: royaltyInfo.recipient,
|
|
16181
|
+
},
|
|
16182
|
+
],
|
|
16183
|
+
startTime: (orderStart.getTime() / 1000).toFixed(0),
|
|
16184
|
+
endTime: (orderExpiry.getTime() / 1000).toFixed(0),
|
|
16185
|
+
zone: this.zoneContractAddress,
|
|
16186
|
+
restrictedByZone: true,
|
|
16187
|
+
}, offerer);
|
|
16188
|
+
}
|
|
16189
|
+
async getTypedDataFromOrderComponents(orderComponents) {
|
|
16190
|
+
const { chainId } = await this.provider.getNetwork();
|
|
16191
|
+
const domainData = {
|
|
16192
|
+
name: SEAPORT_CONTRACT_NAME,
|
|
16193
|
+
version: SEAPORT_CONTRACT_VERSION_V1_4,
|
|
16194
|
+
chainId,
|
|
16195
|
+
verifyingContract: this.seaportContractAddress,
|
|
16196
|
+
};
|
|
16197
|
+
return {
|
|
16198
|
+
domain: domainData,
|
|
16199
|
+
types: EIP_712_ORDER_TYPE,
|
|
16200
|
+
value: orderComponents,
|
|
16201
|
+
};
|
|
16202
|
+
}
|
|
16203
|
+
getSeaportLib(order) {
|
|
16204
|
+
const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
|
|
16205
|
+
let seaportVersion = SEAPORT_CONTRACT_VERSION_V1_4;
|
|
16206
|
+
if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
|
|
16207
|
+
seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
|
|
16208
|
+
}
|
|
16209
|
+
return this.seaportLibFactory.create(seaportVersion, seaportAddress);
|
|
16210
|
+
}
|
|
16211
|
+
}
|
|
16212
|
+
|
|
16213
|
+
class ImmutableApiClient {
|
|
16214
|
+
orderbookService;
|
|
16215
|
+
chainName;
|
|
16216
|
+
seaportAddress;
|
|
16217
|
+
constructor(orderbookService, chainName, seaportAddress) {
|
|
16218
|
+
this.orderbookService = orderbookService;
|
|
16219
|
+
this.chainName = chainName;
|
|
16220
|
+
this.seaportAddress = seaportAddress;
|
|
16221
|
+
}
|
|
16222
|
+
async getListing(listingId) {
|
|
16223
|
+
return this.orderbookService.getListing({
|
|
16224
|
+
chainName: this.chainName,
|
|
16225
|
+
listingId,
|
|
16226
|
+
});
|
|
16227
|
+
}
|
|
16228
|
+
async listListings(listOrderParams) {
|
|
16229
|
+
return this.orderbookService.listListings({
|
|
16230
|
+
chainName: this.chainName,
|
|
16231
|
+
...listOrderParams,
|
|
16232
|
+
});
|
|
16233
|
+
}
|
|
16234
|
+
async createListing({ orderHash, orderComponents, orderSignature, }) {
|
|
16235
|
+
if (orderComponents.offer.length !== 1) {
|
|
16236
|
+
throw new Error('Only one item can be listed at a time');
|
|
16237
|
+
}
|
|
16238
|
+
if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
|
|
16239
|
+
throw new Error('Only ERC721 tokens can be listed');
|
|
16240
|
+
}
|
|
16241
|
+
const orderTypes = [
|
|
16242
|
+
...orderComponents.consideration.map((c) => c.itemType),
|
|
16243
|
+
];
|
|
16244
|
+
const isSameConsiderationType = new Set(orderTypes).size === 1;
|
|
16245
|
+
if (!isSameConsiderationType) {
|
|
16246
|
+
throw new Error('All consideration items must be of the same type');
|
|
16247
|
+
}
|
|
16248
|
+
return this.orderbookService.createListing({
|
|
16249
|
+
chainName: this.chainName,
|
|
16250
|
+
requestBody: {
|
|
16251
|
+
order_hash: orderHash,
|
|
16252
|
+
account_address: orderComponents.offerer,
|
|
16253
|
+
buy: [
|
|
16254
|
+
{
|
|
16255
|
+
item_type: Number(orderComponents.consideration[0].itemType)
|
|
16256
|
+
=== ItemType.NATIVE
|
|
16257
|
+
? 'NATIVE'
|
|
16258
|
+
: 'ERC20',
|
|
16259
|
+
start_amount: orderComponents.consideration[0].startAmount,
|
|
16260
|
+
contract_address: orderComponents.consideration[0].token,
|
|
16261
|
+
},
|
|
16262
|
+
],
|
|
16263
|
+
fees: orderComponents.consideration.length > 1
|
|
16264
|
+
? [
|
|
16265
|
+
{
|
|
16266
|
+
amount: orderComponents.consideration[1].startAmount,
|
|
16267
|
+
recipient: orderComponents.consideration[1].recipient,
|
|
16268
|
+
fee_type: Fee.fee_type.ROYALTY,
|
|
16269
|
+
},
|
|
16270
|
+
]
|
|
16271
|
+
: [],
|
|
16272
|
+
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
16273
|
+
protocol_data: {
|
|
16274
|
+
order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
|
|
16275
|
+
zone_address: orderComponents.zone,
|
|
16276
|
+
seaport_address: this.seaportAddress,
|
|
16277
|
+
seaport_version: SEAPORT_CONTRACT_VERSION_V1_4,
|
|
16278
|
+
counter: orderComponents.counter.toString(),
|
|
16279
|
+
},
|
|
16280
|
+
salt: orderComponents.salt,
|
|
16281
|
+
sell: [
|
|
16282
|
+
{
|
|
16283
|
+
contract_address: orderComponents.offer[0].token,
|
|
16284
|
+
token_id: orderComponents.offer[0].identifierOrCriteria,
|
|
16285
|
+
item_type: 'ERC721',
|
|
16286
|
+
},
|
|
16287
|
+
],
|
|
16288
|
+
signature: orderSignature,
|
|
16289
|
+
start_time: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
|
|
16290
|
+
},
|
|
16291
|
+
});
|
|
16292
|
+
}
|
|
16293
|
+
}
|
|
16294
|
+
|
|
16295
|
+
class ImmutableApiClientFactory {
|
|
16296
|
+
chainName;
|
|
16297
|
+
seaportAddress;
|
|
16298
|
+
orderbookClient;
|
|
16299
|
+
constructor(apiEndpoint, chainName, seaportAddress) {
|
|
16300
|
+
this.chainName = chainName;
|
|
16301
|
+
this.seaportAddress = seaportAddress;
|
|
16302
|
+
this.orderbookClient = new OrderBookClient({
|
|
16303
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16304
|
+
BASE: apiEndpoint,
|
|
16305
|
+
});
|
|
16306
|
+
}
|
|
16307
|
+
create() {
|
|
16308
|
+
return new ImmutableApiClient(this.orderbookClient.orders, this.chainName, this.seaportAddress);
|
|
16309
|
+
}
|
|
16310
|
+
}
|
|
16311
|
+
|
|
16312
|
+
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
16313
|
+
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
16314
|
+
function getOrderbookConfig(environment) {
|
|
16315
|
+
switch (environment) {
|
|
16316
|
+
case Environment$1.SANDBOX:
|
|
16317
|
+
return {
|
|
16318
|
+
seaportContractAddress: '0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19',
|
|
16319
|
+
zoneContractAddress: '0x6FeDb4949E5b452700A8a8956999a7E05B6770F3',
|
|
16320
|
+
apiEndpoint: 'https://api.sandbox.immutable.com',
|
|
16321
|
+
chainName: TESTNET_CHAIN_NAME,
|
|
16322
|
+
provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
16323
|
+
};
|
|
16324
|
+
// not yet deployed
|
|
16325
|
+
case Environment$1.PRODUCTION:
|
|
16326
|
+
return {
|
|
16327
|
+
seaportContractAddress: '',
|
|
16328
|
+
zoneContractAddress: '',
|
|
16329
|
+
apiEndpoint: 'https://api.immutable.com',
|
|
16330
|
+
chainName: MAINNET_CHAIN_NAME,
|
|
16331
|
+
provider: new providers.JsonRpcProvider('https://rpc.immutable.com'),
|
|
16332
|
+
};
|
|
16333
|
+
default:
|
|
16334
|
+
return null;
|
|
16335
|
+
}
|
|
16336
|
+
}
|
|
16337
|
+
|
|
16338
|
+
class ERC721 {
|
|
16339
|
+
erc721;
|
|
16340
|
+
constructor(erc721) {
|
|
16341
|
+
this.erc721 = erc721;
|
|
16342
|
+
}
|
|
16343
|
+
async royaltyInfo(tokenId, salePrice) {
|
|
16344
|
+
const [recipient, royaltyRequired] = await this.erc721.royaltyInfo(tokenId, salePrice);
|
|
16345
|
+
return { recipient, amountRequired: royaltyRequired.toString() };
|
|
16346
|
+
}
|
|
16347
|
+
}
|
|
16348
|
+
|
|
16349
|
+
/* Autogenerated file. Do not edit manually. */
|
|
16350
|
+
/* tslint:disable */
|
|
16351
|
+
/* eslint-disable */
|
|
16352
|
+
const _abi = [
|
|
16353
|
+
{
|
|
16354
|
+
inputs: [
|
|
16355
|
+
{
|
|
16356
|
+
internalType: "address",
|
|
16357
|
+
name: "owner_",
|
|
16358
|
+
type: "address",
|
|
16359
|
+
},
|
|
16360
|
+
{
|
|
16361
|
+
internalType: "string",
|
|
16362
|
+
name: "name_",
|
|
16363
|
+
type: "string",
|
|
16364
|
+
},
|
|
16365
|
+
{
|
|
16366
|
+
internalType: "string",
|
|
16367
|
+
name: "symbol_",
|
|
16368
|
+
type: "string",
|
|
16369
|
+
},
|
|
16370
|
+
{
|
|
16371
|
+
internalType: "string",
|
|
16372
|
+
name: "baseURI_",
|
|
16373
|
+
type: "string",
|
|
16374
|
+
},
|
|
16375
|
+
{
|
|
16376
|
+
internalType: "string",
|
|
16377
|
+
name: "contractURI_",
|
|
16378
|
+
type: "string",
|
|
16379
|
+
},
|
|
16380
|
+
{
|
|
16381
|
+
internalType: "address",
|
|
16382
|
+
name: "_receiver",
|
|
16383
|
+
type: "address",
|
|
16384
|
+
},
|
|
16385
|
+
{
|
|
16386
|
+
internalType: "uint96",
|
|
16387
|
+
name: "_feeNumerator",
|
|
16388
|
+
type: "uint96",
|
|
16389
|
+
},
|
|
16390
|
+
],
|
|
16391
|
+
stateMutability: "nonpayable",
|
|
16392
|
+
type: "constructor",
|
|
16393
|
+
},
|
|
16394
|
+
{
|
|
16395
|
+
inputs: [
|
|
16396
|
+
{
|
|
16397
|
+
internalType: "address",
|
|
16398
|
+
name: "target",
|
|
16399
|
+
type: "address",
|
|
16400
|
+
},
|
|
16401
|
+
],
|
|
16402
|
+
name: "ApproveTargetNotInAllowlist",
|
|
16403
|
+
type: "error",
|
|
16404
|
+
},
|
|
16405
|
+
{
|
|
16406
|
+
inputs: [
|
|
16407
|
+
{
|
|
16408
|
+
internalType: "address",
|
|
16409
|
+
name: "caller",
|
|
16410
|
+
type: "address",
|
|
16411
|
+
},
|
|
16412
|
+
],
|
|
16413
|
+
name: "CallerNotInAllowlist",
|
|
16414
|
+
type: "error",
|
|
16415
|
+
},
|
|
16416
|
+
{
|
|
16417
|
+
anonymous: false,
|
|
16418
|
+
inputs: [
|
|
16419
|
+
{
|
|
16420
|
+
indexed: true,
|
|
16421
|
+
internalType: "address",
|
|
16422
|
+
name: "owner",
|
|
16423
|
+
type: "address",
|
|
16424
|
+
},
|
|
16425
|
+
{
|
|
16426
|
+
indexed: true,
|
|
16427
|
+
internalType: "address",
|
|
16428
|
+
name: "approved",
|
|
16429
|
+
type: "address",
|
|
16430
|
+
},
|
|
16431
|
+
{
|
|
16432
|
+
indexed: true,
|
|
16433
|
+
internalType: "uint256",
|
|
16434
|
+
name: "tokenId",
|
|
16435
|
+
type: "uint256",
|
|
16436
|
+
},
|
|
16437
|
+
],
|
|
16438
|
+
name: "Approval",
|
|
16439
|
+
type: "event",
|
|
16440
|
+
},
|
|
16441
|
+
{
|
|
16442
|
+
anonymous: false,
|
|
16443
|
+
inputs: [
|
|
16444
|
+
{
|
|
16445
|
+
indexed: true,
|
|
16446
|
+
internalType: "address",
|
|
16447
|
+
name: "owner",
|
|
16448
|
+
type: "address",
|
|
16449
|
+
},
|
|
16450
|
+
{
|
|
16451
|
+
indexed: true,
|
|
16452
|
+
internalType: "address",
|
|
16453
|
+
name: "operator",
|
|
16454
|
+
type: "address",
|
|
16455
|
+
},
|
|
16456
|
+
{
|
|
16457
|
+
indexed: false,
|
|
16458
|
+
internalType: "bool",
|
|
16459
|
+
name: "approved",
|
|
16460
|
+
type: "bool",
|
|
16461
|
+
},
|
|
16462
|
+
],
|
|
16463
|
+
name: "ApprovalForAll",
|
|
16464
|
+
type: "event",
|
|
16465
|
+
},
|
|
16466
|
+
{
|
|
16467
|
+
anonymous: false,
|
|
16468
|
+
inputs: [
|
|
16469
|
+
{
|
|
16470
|
+
indexed: true,
|
|
16471
|
+
internalType: "bytes32",
|
|
16472
|
+
name: "role",
|
|
16473
|
+
type: "bytes32",
|
|
16474
|
+
},
|
|
16475
|
+
{
|
|
16476
|
+
indexed: true,
|
|
16477
|
+
internalType: "bytes32",
|
|
16478
|
+
name: "previousAdminRole",
|
|
16479
|
+
type: "bytes32",
|
|
16480
|
+
},
|
|
16481
|
+
{
|
|
16482
|
+
indexed: true,
|
|
16483
|
+
internalType: "bytes32",
|
|
16484
|
+
name: "newAdminRole",
|
|
16485
|
+
type: "bytes32",
|
|
16486
|
+
},
|
|
16487
|
+
],
|
|
16488
|
+
name: "RoleAdminChanged",
|
|
16489
|
+
type: "event",
|
|
16490
|
+
},
|
|
16491
|
+
{
|
|
16492
|
+
anonymous: false,
|
|
16493
|
+
inputs: [
|
|
16494
|
+
{
|
|
16495
|
+
indexed: true,
|
|
16496
|
+
internalType: "bytes32",
|
|
16497
|
+
name: "role",
|
|
16498
|
+
type: "bytes32",
|
|
16499
|
+
},
|
|
16500
|
+
{
|
|
16501
|
+
indexed: true,
|
|
16502
|
+
internalType: "address",
|
|
16503
|
+
name: "account",
|
|
16504
|
+
type: "address",
|
|
16505
|
+
},
|
|
16506
|
+
{
|
|
16507
|
+
indexed: true,
|
|
16508
|
+
internalType: "address",
|
|
16509
|
+
name: "sender",
|
|
16510
|
+
type: "address",
|
|
16511
|
+
},
|
|
16512
|
+
],
|
|
16513
|
+
name: "RoleGranted",
|
|
16514
|
+
type: "event",
|
|
16515
|
+
},
|
|
16516
|
+
{
|
|
16517
|
+
anonymous: false,
|
|
16518
|
+
inputs: [
|
|
16519
|
+
{
|
|
16520
|
+
indexed: true,
|
|
16521
|
+
internalType: "bytes32",
|
|
16522
|
+
name: "role",
|
|
16523
|
+
type: "bytes32",
|
|
16524
|
+
},
|
|
16525
|
+
{
|
|
16526
|
+
indexed: true,
|
|
16527
|
+
internalType: "address",
|
|
16528
|
+
name: "account",
|
|
16529
|
+
type: "address",
|
|
16530
|
+
},
|
|
16531
|
+
{
|
|
16532
|
+
indexed: true,
|
|
16533
|
+
internalType: "address",
|
|
16534
|
+
name: "sender",
|
|
16535
|
+
type: "address",
|
|
16536
|
+
},
|
|
16537
|
+
],
|
|
16538
|
+
name: "RoleRevoked",
|
|
16539
|
+
type: "event",
|
|
16540
|
+
},
|
|
16541
|
+
{
|
|
16542
|
+
anonymous: false,
|
|
16543
|
+
inputs: [
|
|
16544
|
+
{
|
|
16545
|
+
indexed: false,
|
|
16546
|
+
internalType: "address",
|
|
16547
|
+
name: "oldRegistry",
|
|
16548
|
+
type: "address",
|
|
16549
|
+
},
|
|
16550
|
+
{
|
|
16551
|
+
indexed: false,
|
|
16552
|
+
internalType: "address",
|
|
16553
|
+
name: "newRegistry",
|
|
16554
|
+
type: "address",
|
|
16555
|
+
},
|
|
16556
|
+
],
|
|
16557
|
+
name: "RoyaltytAllowlistRegistryUpdated",
|
|
16558
|
+
type: "event",
|
|
16559
|
+
},
|
|
16560
|
+
{
|
|
16561
|
+
anonymous: false,
|
|
16562
|
+
inputs: [
|
|
16563
|
+
{
|
|
16564
|
+
indexed: true,
|
|
16565
|
+
internalType: "address",
|
|
16566
|
+
name: "from",
|
|
16567
|
+
type: "address",
|
|
16568
|
+
},
|
|
16569
|
+
{
|
|
16570
|
+
indexed: true,
|
|
16571
|
+
internalType: "address",
|
|
16572
|
+
name: "to",
|
|
16573
|
+
type: "address",
|
|
16574
|
+
},
|
|
16575
|
+
{
|
|
16576
|
+
indexed: true,
|
|
16577
|
+
internalType: "uint256",
|
|
16578
|
+
name: "tokenId",
|
|
16579
|
+
type: "uint256",
|
|
16580
|
+
},
|
|
16581
|
+
],
|
|
16582
|
+
name: "Transfer",
|
|
16583
|
+
type: "event",
|
|
16584
|
+
},
|
|
16585
|
+
{
|
|
16586
|
+
inputs: [],
|
|
16587
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
16588
|
+
outputs: [
|
|
16589
|
+
{
|
|
16590
|
+
internalType: "bytes32",
|
|
16591
|
+
name: "",
|
|
16592
|
+
type: "bytes32",
|
|
16593
|
+
},
|
|
16594
|
+
],
|
|
16595
|
+
stateMutability: "view",
|
|
16596
|
+
type: "function",
|
|
16597
|
+
},
|
|
16598
|
+
{
|
|
16599
|
+
inputs: [],
|
|
16600
|
+
name: "MINTER_ROLE",
|
|
16601
|
+
outputs: [
|
|
16602
|
+
{
|
|
16603
|
+
internalType: "bytes32",
|
|
16604
|
+
name: "",
|
|
16605
|
+
type: "bytes32",
|
|
16606
|
+
},
|
|
16607
|
+
],
|
|
16608
|
+
stateMutability: "view",
|
|
16609
|
+
type: "function",
|
|
16610
|
+
},
|
|
16611
|
+
{
|
|
16612
|
+
inputs: [
|
|
16613
|
+
{
|
|
16614
|
+
internalType: "address",
|
|
16615
|
+
name: "to",
|
|
16616
|
+
type: "address",
|
|
16617
|
+
},
|
|
16618
|
+
{
|
|
16619
|
+
internalType: "uint256",
|
|
16620
|
+
name: "tokenId",
|
|
16621
|
+
type: "uint256",
|
|
16622
|
+
},
|
|
16623
|
+
],
|
|
16624
|
+
name: "approve",
|
|
16625
|
+
outputs: [],
|
|
16626
|
+
stateMutability: "nonpayable",
|
|
16627
|
+
type: "function",
|
|
16628
|
+
},
|
|
16629
|
+
{
|
|
16630
|
+
inputs: [
|
|
16631
|
+
{
|
|
16632
|
+
internalType: "address",
|
|
16633
|
+
name: "owner",
|
|
16634
|
+
type: "address",
|
|
16635
|
+
},
|
|
16636
|
+
],
|
|
16637
|
+
name: "balanceOf",
|
|
16638
|
+
outputs: [
|
|
16639
|
+
{
|
|
16640
|
+
internalType: "uint256",
|
|
16641
|
+
name: "",
|
|
16642
|
+
type: "uint256",
|
|
16643
|
+
},
|
|
16644
|
+
],
|
|
16645
|
+
stateMutability: "view",
|
|
16646
|
+
type: "function",
|
|
16647
|
+
},
|
|
16648
|
+
{
|
|
16649
|
+
inputs: [],
|
|
16650
|
+
name: "baseURI",
|
|
16651
|
+
outputs: [
|
|
16652
|
+
{
|
|
16653
|
+
internalType: "string",
|
|
16654
|
+
name: "",
|
|
16655
|
+
type: "string",
|
|
16656
|
+
},
|
|
16657
|
+
],
|
|
16658
|
+
stateMutability: "view",
|
|
16659
|
+
type: "function",
|
|
16660
|
+
},
|
|
16661
|
+
{
|
|
16662
|
+
inputs: [
|
|
16663
|
+
{
|
|
16664
|
+
internalType: "uint256",
|
|
16665
|
+
name: "tokenId",
|
|
16666
|
+
type: "uint256",
|
|
16667
|
+
},
|
|
16668
|
+
],
|
|
16669
|
+
name: "burn",
|
|
16670
|
+
outputs: [],
|
|
16671
|
+
stateMutability: "nonpayable",
|
|
16672
|
+
type: "function",
|
|
16673
|
+
},
|
|
16674
|
+
{
|
|
16675
|
+
inputs: [],
|
|
16676
|
+
name: "contractURI",
|
|
16677
|
+
outputs: [
|
|
16678
|
+
{
|
|
16679
|
+
internalType: "string",
|
|
16680
|
+
name: "",
|
|
16681
|
+
type: "string",
|
|
16682
|
+
},
|
|
16683
|
+
],
|
|
16684
|
+
stateMutability: "view",
|
|
16685
|
+
type: "function",
|
|
16686
|
+
},
|
|
16687
|
+
{
|
|
16688
|
+
inputs: [],
|
|
16689
|
+
name: "getAdmins",
|
|
16690
|
+
outputs: [
|
|
16691
|
+
{
|
|
16692
|
+
internalType: "address[]",
|
|
16693
|
+
name: "",
|
|
16694
|
+
type: "address[]",
|
|
16695
|
+
},
|
|
16696
|
+
],
|
|
16697
|
+
stateMutability: "view",
|
|
16698
|
+
type: "function",
|
|
16699
|
+
},
|
|
16700
|
+
{
|
|
16701
|
+
inputs: [
|
|
16702
|
+
{
|
|
16703
|
+
internalType: "uint256",
|
|
16704
|
+
name: "tokenId",
|
|
16705
|
+
type: "uint256",
|
|
16706
|
+
},
|
|
16707
|
+
],
|
|
16708
|
+
name: "getApproved",
|
|
16709
|
+
outputs: [
|
|
16710
|
+
{
|
|
16711
|
+
internalType: "address",
|
|
16712
|
+
name: "",
|
|
16713
|
+
type: "address",
|
|
16714
|
+
},
|
|
16715
|
+
],
|
|
16716
|
+
stateMutability: "view",
|
|
16717
|
+
type: "function",
|
|
16718
|
+
},
|
|
16719
|
+
{
|
|
16720
|
+
inputs: [
|
|
16721
|
+
{
|
|
16722
|
+
internalType: "bytes32",
|
|
16723
|
+
name: "role",
|
|
16724
|
+
type: "bytes32",
|
|
16725
|
+
},
|
|
16726
|
+
],
|
|
16727
|
+
name: "getRoleAdmin",
|
|
16728
|
+
outputs: [
|
|
16729
|
+
{
|
|
16730
|
+
internalType: "bytes32",
|
|
16731
|
+
name: "",
|
|
16732
|
+
type: "bytes32",
|
|
16733
|
+
},
|
|
16734
|
+
],
|
|
16735
|
+
stateMutability: "view",
|
|
16736
|
+
type: "function",
|
|
16737
|
+
},
|
|
16738
|
+
{
|
|
16739
|
+
inputs: [
|
|
16740
|
+
{
|
|
16741
|
+
internalType: "bytes32",
|
|
16742
|
+
name: "role",
|
|
16743
|
+
type: "bytes32",
|
|
16744
|
+
},
|
|
16745
|
+
{
|
|
16746
|
+
internalType: "uint256",
|
|
16747
|
+
name: "index",
|
|
16748
|
+
type: "uint256",
|
|
16749
|
+
},
|
|
16750
|
+
],
|
|
16751
|
+
name: "getRoleMember",
|
|
16752
|
+
outputs: [
|
|
16753
|
+
{
|
|
16754
|
+
internalType: "address",
|
|
16755
|
+
name: "",
|
|
16756
|
+
type: "address",
|
|
16757
|
+
},
|
|
16758
|
+
],
|
|
16759
|
+
stateMutability: "view",
|
|
16760
|
+
type: "function",
|
|
16761
|
+
},
|
|
16762
|
+
{
|
|
16763
|
+
inputs: [
|
|
16764
|
+
{
|
|
16765
|
+
internalType: "bytes32",
|
|
16766
|
+
name: "role",
|
|
16767
|
+
type: "bytes32",
|
|
16768
|
+
},
|
|
16769
|
+
],
|
|
16770
|
+
name: "getRoleMemberCount",
|
|
16771
|
+
outputs: [
|
|
16772
|
+
{
|
|
16773
|
+
internalType: "uint256",
|
|
16774
|
+
name: "",
|
|
16775
|
+
type: "uint256",
|
|
16776
|
+
},
|
|
16777
|
+
],
|
|
16778
|
+
stateMutability: "view",
|
|
16779
|
+
type: "function",
|
|
16780
|
+
},
|
|
16781
|
+
{
|
|
16782
|
+
inputs: [
|
|
16783
|
+
{
|
|
16784
|
+
internalType: "address",
|
|
16785
|
+
name: "user",
|
|
16786
|
+
type: "address",
|
|
16787
|
+
},
|
|
16788
|
+
],
|
|
16789
|
+
name: "grantMinterRole",
|
|
16790
|
+
outputs: [],
|
|
16791
|
+
stateMutability: "nonpayable",
|
|
16792
|
+
type: "function",
|
|
16793
|
+
},
|
|
16794
|
+
{
|
|
16795
|
+
inputs: [
|
|
16796
|
+
{
|
|
16797
|
+
internalType: "bytes32",
|
|
16798
|
+
name: "role",
|
|
16799
|
+
type: "bytes32",
|
|
16800
|
+
},
|
|
16801
|
+
{
|
|
16802
|
+
internalType: "address",
|
|
16803
|
+
name: "account",
|
|
16804
|
+
type: "address",
|
|
16805
|
+
},
|
|
16806
|
+
],
|
|
16807
|
+
name: "grantRole",
|
|
16808
|
+
outputs: [],
|
|
16809
|
+
stateMutability: "nonpayable",
|
|
16810
|
+
type: "function",
|
|
16811
|
+
},
|
|
16812
|
+
{
|
|
16813
|
+
inputs: [
|
|
16814
|
+
{
|
|
16815
|
+
internalType: "bytes32",
|
|
16816
|
+
name: "role",
|
|
16817
|
+
type: "bytes32",
|
|
16818
|
+
},
|
|
16819
|
+
{
|
|
16820
|
+
internalType: "address",
|
|
16821
|
+
name: "account",
|
|
16822
|
+
type: "address",
|
|
16823
|
+
},
|
|
16824
|
+
],
|
|
16825
|
+
name: "hasRole",
|
|
16826
|
+
outputs: [
|
|
16827
|
+
{
|
|
16828
|
+
internalType: "bool",
|
|
16829
|
+
name: "",
|
|
16830
|
+
type: "bool",
|
|
16831
|
+
},
|
|
16832
|
+
],
|
|
16833
|
+
stateMutability: "view",
|
|
16834
|
+
type: "function",
|
|
16835
|
+
},
|
|
16836
|
+
{
|
|
16837
|
+
inputs: [
|
|
16838
|
+
{
|
|
16839
|
+
internalType: "address",
|
|
16840
|
+
name: "owner",
|
|
16841
|
+
type: "address",
|
|
16842
|
+
},
|
|
16843
|
+
{
|
|
16844
|
+
internalType: "address",
|
|
16845
|
+
name: "operator",
|
|
16846
|
+
type: "address",
|
|
16847
|
+
},
|
|
16848
|
+
],
|
|
16849
|
+
name: "isApprovedForAll",
|
|
16850
|
+
outputs: [
|
|
16851
|
+
{
|
|
16852
|
+
internalType: "bool",
|
|
16853
|
+
name: "",
|
|
16854
|
+
type: "bool",
|
|
16855
|
+
},
|
|
16856
|
+
],
|
|
16857
|
+
stateMutability: "view",
|
|
16858
|
+
type: "function",
|
|
16859
|
+
},
|
|
16860
|
+
{
|
|
16861
|
+
inputs: [
|
|
16862
|
+
{
|
|
16863
|
+
internalType: "address",
|
|
16864
|
+
name: "to",
|
|
16865
|
+
type: "address",
|
|
16866
|
+
},
|
|
16867
|
+
{
|
|
16868
|
+
internalType: "uint256",
|
|
16869
|
+
name: "amount",
|
|
16870
|
+
type: "uint256",
|
|
16871
|
+
},
|
|
16872
|
+
],
|
|
16873
|
+
name: "mint",
|
|
16874
|
+
outputs: [],
|
|
16875
|
+
stateMutability: "nonpayable",
|
|
16876
|
+
type: "function",
|
|
16877
|
+
},
|
|
16878
|
+
{
|
|
16879
|
+
inputs: [],
|
|
16880
|
+
name: "name",
|
|
16881
|
+
outputs: [
|
|
16882
|
+
{
|
|
16883
|
+
internalType: "string",
|
|
16884
|
+
name: "",
|
|
16885
|
+
type: "string",
|
|
16886
|
+
},
|
|
16887
|
+
],
|
|
16888
|
+
stateMutability: "view",
|
|
16889
|
+
type: "function",
|
|
16890
|
+
},
|
|
16891
|
+
{
|
|
16892
|
+
inputs: [
|
|
16893
|
+
{
|
|
16894
|
+
internalType: "uint256",
|
|
16895
|
+
name: "tokenId",
|
|
16896
|
+
type: "uint256",
|
|
16897
|
+
},
|
|
16898
|
+
],
|
|
16899
|
+
name: "ownerOf",
|
|
16900
|
+
outputs: [
|
|
16901
|
+
{
|
|
16902
|
+
internalType: "address",
|
|
16903
|
+
name: "",
|
|
16904
|
+
type: "address",
|
|
16905
|
+
},
|
|
16906
|
+
],
|
|
16907
|
+
stateMutability: "view",
|
|
16908
|
+
type: "function",
|
|
16909
|
+
},
|
|
16910
|
+
{
|
|
16911
|
+
inputs: [
|
|
16912
|
+
{
|
|
16913
|
+
internalType: "bytes32",
|
|
16914
|
+
name: "role",
|
|
16915
|
+
type: "bytes32",
|
|
16916
|
+
},
|
|
16917
|
+
{
|
|
16918
|
+
internalType: "address",
|
|
16919
|
+
name: "account",
|
|
16920
|
+
type: "address",
|
|
16921
|
+
},
|
|
16922
|
+
],
|
|
16923
|
+
name: "renounceRole",
|
|
16924
|
+
outputs: [],
|
|
16925
|
+
stateMutability: "nonpayable",
|
|
16926
|
+
type: "function",
|
|
16927
|
+
},
|
|
16928
|
+
{
|
|
16929
|
+
inputs: [
|
|
16930
|
+
{
|
|
16931
|
+
internalType: "address",
|
|
16932
|
+
name: "user",
|
|
16933
|
+
type: "address",
|
|
16934
|
+
},
|
|
16935
|
+
],
|
|
16936
|
+
name: "revokeMinterRole",
|
|
16937
|
+
outputs: [],
|
|
16938
|
+
stateMutability: "nonpayable",
|
|
16939
|
+
type: "function",
|
|
16940
|
+
},
|
|
16941
|
+
{
|
|
16942
|
+
inputs: [
|
|
16943
|
+
{
|
|
16944
|
+
internalType: "bytes32",
|
|
16945
|
+
name: "role",
|
|
16946
|
+
type: "bytes32",
|
|
16947
|
+
},
|
|
16948
|
+
{
|
|
16949
|
+
internalType: "address",
|
|
16950
|
+
name: "account",
|
|
16951
|
+
type: "address",
|
|
16952
|
+
},
|
|
16953
|
+
],
|
|
16954
|
+
name: "revokeRole",
|
|
16955
|
+
outputs: [],
|
|
16956
|
+
stateMutability: "nonpayable",
|
|
16957
|
+
type: "function",
|
|
16958
|
+
},
|
|
16959
|
+
{
|
|
16960
|
+
inputs: [],
|
|
16961
|
+
name: "royaltyAllowlist",
|
|
16962
|
+
outputs: [
|
|
16963
|
+
{
|
|
16964
|
+
internalType: "contract IRoyaltyAllowlist",
|
|
16965
|
+
name: "",
|
|
16966
|
+
type: "address",
|
|
16967
|
+
},
|
|
16968
|
+
],
|
|
16969
|
+
stateMutability: "view",
|
|
16970
|
+
type: "function",
|
|
16971
|
+
},
|
|
16972
|
+
{
|
|
16973
|
+
inputs: [
|
|
16974
|
+
{
|
|
16975
|
+
internalType: "uint256",
|
|
16976
|
+
name: "_tokenId",
|
|
16977
|
+
type: "uint256",
|
|
16978
|
+
},
|
|
16979
|
+
{
|
|
16980
|
+
internalType: "uint256",
|
|
16981
|
+
name: "_salePrice",
|
|
16982
|
+
type: "uint256",
|
|
16983
|
+
},
|
|
16984
|
+
],
|
|
16985
|
+
name: "royaltyInfo",
|
|
16986
|
+
outputs: [
|
|
16987
|
+
{
|
|
16988
|
+
internalType: "address",
|
|
16989
|
+
name: "",
|
|
16990
|
+
type: "address",
|
|
16991
|
+
},
|
|
16992
|
+
{
|
|
16993
|
+
internalType: "uint256",
|
|
16994
|
+
name: "",
|
|
16995
|
+
type: "uint256",
|
|
16996
|
+
},
|
|
16997
|
+
],
|
|
16998
|
+
stateMutability: "view",
|
|
16999
|
+
type: "function",
|
|
17000
|
+
},
|
|
17001
|
+
{
|
|
17002
|
+
inputs: [
|
|
17003
|
+
{
|
|
17004
|
+
internalType: "address",
|
|
17005
|
+
name: "from",
|
|
17006
|
+
type: "address",
|
|
17007
|
+
},
|
|
17008
|
+
{
|
|
17009
|
+
internalType: "address",
|
|
17010
|
+
name: "to",
|
|
17011
|
+
type: "address",
|
|
17012
|
+
},
|
|
17013
|
+
{
|
|
17014
|
+
internalType: "uint256",
|
|
17015
|
+
name: "tokenId",
|
|
17016
|
+
type: "uint256",
|
|
17017
|
+
},
|
|
17018
|
+
],
|
|
17019
|
+
name: "safeTransferFrom",
|
|
17020
|
+
outputs: [],
|
|
17021
|
+
stateMutability: "nonpayable",
|
|
17022
|
+
type: "function",
|
|
17023
|
+
},
|
|
17024
|
+
{
|
|
17025
|
+
inputs: [
|
|
17026
|
+
{
|
|
17027
|
+
internalType: "address",
|
|
17028
|
+
name: "from",
|
|
17029
|
+
type: "address",
|
|
17030
|
+
},
|
|
17031
|
+
{
|
|
17032
|
+
internalType: "address",
|
|
17033
|
+
name: "to",
|
|
17034
|
+
type: "address",
|
|
17035
|
+
},
|
|
17036
|
+
{
|
|
17037
|
+
internalType: "uint256",
|
|
17038
|
+
name: "tokenId",
|
|
17039
|
+
type: "uint256",
|
|
17040
|
+
},
|
|
17041
|
+
{
|
|
17042
|
+
internalType: "bytes",
|
|
17043
|
+
name: "data",
|
|
17044
|
+
type: "bytes",
|
|
17045
|
+
},
|
|
17046
|
+
],
|
|
17047
|
+
name: "safeTransferFrom",
|
|
17048
|
+
outputs: [],
|
|
17049
|
+
stateMutability: "nonpayable",
|
|
17050
|
+
type: "function",
|
|
17051
|
+
},
|
|
17052
|
+
{
|
|
17053
|
+
inputs: [
|
|
17054
|
+
{
|
|
17055
|
+
internalType: "address",
|
|
17056
|
+
name: "operator",
|
|
17057
|
+
type: "address",
|
|
17058
|
+
},
|
|
17059
|
+
{
|
|
17060
|
+
internalType: "bool",
|
|
17061
|
+
name: "approved",
|
|
17062
|
+
type: "bool",
|
|
17063
|
+
},
|
|
17064
|
+
],
|
|
17065
|
+
name: "setApprovalForAll",
|
|
17066
|
+
outputs: [],
|
|
17067
|
+
stateMutability: "nonpayable",
|
|
17068
|
+
type: "function",
|
|
17069
|
+
},
|
|
17070
|
+
{
|
|
17071
|
+
inputs: [
|
|
17072
|
+
{
|
|
17073
|
+
internalType: "string",
|
|
17074
|
+
name: "baseURI_",
|
|
17075
|
+
type: "string",
|
|
17076
|
+
},
|
|
17077
|
+
],
|
|
17078
|
+
name: "setBaseURI",
|
|
17079
|
+
outputs: [],
|
|
17080
|
+
stateMutability: "nonpayable",
|
|
17081
|
+
type: "function",
|
|
17082
|
+
},
|
|
17083
|
+
{
|
|
17084
|
+
inputs: [
|
|
17085
|
+
{
|
|
17086
|
+
internalType: "string",
|
|
17087
|
+
name: "_contractURI",
|
|
17088
|
+
type: "string",
|
|
17089
|
+
},
|
|
17090
|
+
],
|
|
17091
|
+
name: "setContractURI",
|
|
17092
|
+
outputs: [],
|
|
17093
|
+
stateMutability: "nonpayable",
|
|
17094
|
+
type: "function",
|
|
17095
|
+
},
|
|
17096
|
+
{
|
|
17097
|
+
inputs: [
|
|
17098
|
+
{
|
|
17099
|
+
internalType: "address",
|
|
17100
|
+
name: "_royaltyAllowlist",
|
|
17101
|
+
type: "address",
|
|
17102
|
+
},
|
|
17103
|
+
],
|
|
17104
|
+
name: "setRoyaltyAllowlistRegistry",
|
|
17105
|
+
outputs: [],
|
|
17106
|
+
stateMutability: "nonpayable",
|
|
17107
|
+
type: "function",
|
|
17108
|
+
},
|
|
17109
|
+
{
|
|
17110
|
+
inputs: [
|
|
17111
|
+
{
|
|
17112
|
+
internalType: "bytes4",
|
|
17113
|
+
name: "interfaceId",
|
|
17114
|
+
type: "bytes4",
|
|
17115
|
+
},
|
|
17116
|
+
],
|
|
17117
|
+
name: "supportsInterface",
|
|
17118
|
+
outputs: [
|
|
17119
|
+
{
|
|
17120
|
+
internalType: "bool",
|
|
17121
|
+
name: "",
|
|
17122
|
+
type: "bool",
|
|
17123
|
+
},
|
|
17124
|
+
],
|
|
17125
|
+
stateMutability: "view",
|
|
17126
|
+
type: "function",
|
|
17127
|
+
},
|
|
17128
|
+
{
|
|
17129
|
+
inputs: [],
|
|
17130
|
+
name: "symbol",
|
|
17131
|
+
outputs: [
|
|
17132
|
+
{
|
|
17133
|
+
internalType: "string",
|
|
17134
|
+
name: "",
|
|
17135
|
+
type: "string",
|
|
17136
|
+
},
|
|
17137
|
+
],
|
|
17138
|
+
stateMutability: "view",
|
|
17139
|
+
type: "function",
|
|
17140
|
+
},
|
|
17141
|
+
{
|
|
17142
|
+
inputs: [
|
|
17143
|
+
{
|
|
17144
|
+
internalType: "uint256",
|
|
17145
|
+
name: "index",
|
|
17146
|
+
type: "uint256",
|
|
17147
|
+
},
|
|
17148
|
+
],
|
|
17149
|
+
name: "tokenByIndex",
|
|
17150
|
+
outputs: [
|
|
17151
|
+
{
|
|
17152
|
+
internalType: "uint256",
|
|
17153
|
+
name: "",
|
|
17154
|
+
type: "uint256",
|
|
17155
|
+
},
|
|
17156
|
+
],
|
|
17157
|
+
stateMutability: "view",
|
|
17158
|
+
type: "function",
|
|
17159
|
+
},
|
|
17160
|
+
{
|
|
17161
|
+
inputs: [
|
|
17162
|
+
{
|
|
17163
|
+
internalType: "address",
|
|
17164
|
+
name: "owner",
|
|
17165
|
+
type: "address",
|
|
17166
|
+
},
|
|
17167
|
+
{
|
|
17168
|
+
internalType: "uint256",
|
|
17169
|
+
name: "index",
|
|
17170
|
+
type: "uint256",
|
|
17171
|
+
},
|
|
17172
|
+
],
|
|
17173
|
+
name: "tokenOfOwnerByIndex",
|
|
17174
|
+
outputs: [
|
|
17175
|
+
{
|
|
17176
|
+
internalType: "uint256",
|
|
17177
|
+
name: "",
|
|
17178
|
+
type: "uint256",
|
|
17179
|
+
},
|
|
17180
|
+
],
|
|
17181
|
+
stateMutability: "view",
|
|
17182
|
+
type: "function",
|
|
17183
|
+
},
|
|
17184
|
+
{
|
|
17185
|
+
inputs: [
|
|
17186
|
+
{
|
|
17187
|
+
internalType: "uint256",
|
|
17188
|
+
name: "tokenId",
|
|
17189
|
+
type: "uint256",
|
|
17190
|
+
},
|
|
17191
|
+
],
|
|
17192
|
+
name: "tokenURI",
|
|
17193
|
+
outputs: [
|
|
17194
|
+
{
|
|
17195
|
+
internalType: "string",
|
|
17196
|
+
name: "",
|
|
17197
|
+
type: "string",
|
|
17198
|
+
},
|
|
17199
|
+
],
|
|
17200
|
+
stateMutability: "view",
|
|
17201
|
+
type: "function",
|
|
17202
|
+
},
|
|
17203
|
+
{
|
|
17204
|
+
inputs: [],
|
|
17205
|
+
name: "totalSupply",
|
|
17206
|
+
outputs: [
|
|
17207
|
+
{
|
|
17208
|
+
internalType: "uint256",
|
|
17209
|
+
name: "",
|
|
17210
|
+
type: "uint256",
|
|
17211
|
+
},
|
|
17212
|
+
],
|
|
17213
|
+
stateMutability: "view",
|
|
17214
|
+
type: "function",
|
|
17215
|
+
},
|
|
17216
|
+
{
|
|
17217
|
+
inputs: [
|
|
17218
|
+
{
|
|
17219
|
+
internalType: "address",
|
|
17220
|
+
name: "from",
|
|
17221
|
+
type: "address",
|
|
17222
|
+
},
|
|
17223
|
+
{
|
|
17224
|
+
internalType: "address",
|
|
17225
|
+
name: "to",
|
|
17226
|
+
type: "address",
|
|
17227
|
+
},
|
|
17228
|
+
{
|
|
17229
|
+
internalType: "uint256",
|
|
17230
|
+
name: "tokenId",
|
|
17231
|
+
type: "uint256",
|
|
17232
|
+
},
|
|
17233
|
+
],
|
|
17234
|
+
name: "transferFrom",
|
|
17235
|
+
outputs: [],
|
|
17236
|
+
stateMutability: "nonpayable",
|
|
17237
|
+
type: "function",
|
|
17238
|
+
},
|
|
17239
|
+
];
|
|
17240
|
+
class ImmutableERC721Base__factory {
|
|
17241
|
+
static abi = _abi;
|
|
17242
|
+
static createInterface() {
|
|
17243
|
+
return new utils.Interface(_abi);
|
|
17244
|
+
}
|
|
17245
|
+
static connect(address, signerOrProvider) {
|
|
17246
|
+
return new Contract$1(address, _abi, signerOrProvider);
|
|
17247
|
+
}
|
|
17248
|
+
}
|
|
17249
|
+
|
|
17250
|
+
class ERC721Factory {
|
|
17251
|
+
erc721;
|
|
17252
|
+
constructor(contractAddress, provider) {
|
|
17253
|
+
this.erc721 = ImmutableERC721Base__factory.connect(contractAddress, provider);
|
|
17254
|
+
}
|
|
17255
|
+
create() {
|
|
17256
|
+
return new ERC721(this.erc721);
|
|
17257
|
+
}
|
|
17258
|
+
}
|
|
17259
|
+
|
|
17260
|
+
class SeaportLibFactory {
|
|
17261
|
+
defaultSeaportContractAddress;
|
|
17262
|
+
provider;
|
|
17263
|
+
constructor(defaultSeaportContractAddress, provider) {
|
|
17264
|
+
this.defaultSeaportContractAddress = defaultSeaportContractAddress;
|
|
17265
|
+
this.provider = provider;
|
|
17266
|
+
}
|
|
17267
|
+
create(orderSeaportVersion, orderSeaportAddress) {
|
|
17268
|
+
const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_4;
|
|
17269
|
+
const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
|
|
17270
|
+
return new Seaport$1(this.provider, {
|
|
17271
|
+
seaportVersion,
|
|
17272
|
+
balanceAndApprovalChecksOnOrderCreation: true,
|
|
17273
|
+
overrides: {
|
|
17274
|
+
contractAddress: seaportContractAddress,
|
|
17275
|
+
},
|
|
17276
|
+
});
|
|
17277
|
+
}
|
|
17278
|
+
}
|
|
17279
|
+
|
|
17280
|
+
/**
|
|
17281
|
+
* zkEVM orderbook SDK
|
|
17282
|
+
* @constructor
|
|
17283
|
+
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
17284
|
+
*/
|
|
17285
|
+
class Orderbook {
|
|
17286
|
+
apiClient;
|
|
17287
|
+
seaport;
|
|
17288
|
+
orderbookConfig;
|
|
17289
|
+
constructor(config) {
|
|
17290
|
+
const obConfig = getOrderbookConfig(config.baseConfig.environment);
|
|
17291
|
+
const finalConfig = {
|
|
17292
|
+
...obConfig,
|
|
17293
|
+
...config.overrides,
|
|
17294
|
+
};
|
|
17295
|
+
if (!finalConfig) {
|
|
17296
|
+
throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
|
|
17297
|
+
}
|
|
17298
|
+
this.orderbookConfig = finalConfig;
|
|
17299
|
+
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
17300
|
+
if (!apiEndpoint) {
|
|
17301
|
+
throw new Error('API endpoint must be provided');
|
|
17302
|
+
}
|
|
17303
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
17304
|
+
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
17305
|
+
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
17306
|
+
}
|
|
17307
|
+
/**
|
|
17308
|
+
* Get an order by ID
|
|
17309
|
+
* @param {string} listingId - The listingId to find.
|
|
17310
|
+
* @return {ListingResult} The returned order result.
|
|
17311
|
+
*/
|
|
17312
|
+
getListing(listingId) {
|
|
17313
|
+
return this.apiClient.getListing(listingId);
|
|
17314
|
+
}
|
|
17315
|
+
/**
|
|
17316
|
+
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
17317
|
+
* in the params object.
|
|
17318
|
+
* @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
|
|
17319
|
+
* @return {Orders} The paged orders.
|
|
17320
|
+
*/
|
|
17321
|
+
listListings(listOrderParams) {
|
|
17322
|
+
return this.apiClient.listListings(listOrderParams);
|
|
17323
|
+
}
|
|
17324
|
+
/**
|
|
17325
|
+
* Get required transactions and messages for signing prior to creating a listing
|
|
17326
|
+
* through the createListing method
|
|
17327
|
+
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
17328
|
+
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
17329
|
+
* the unsigned approval transaction, the typed order message for signing and
|
|
17330
|
+
* the order components that can be submitted to `createListing` with a signature.
|
|
17331
|
+
*/
|
|
17332
|
+
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
17333
|
+
const erc721 = new ERC721Factory(sell.contractAddress, this.orderbookConfig.provider).create();
|
|
17334
|
+
const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
|
|
17335
|
+
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
|
|
17336
|
+
// Default order start to now
|
|
17337
|
+
new Date(),
|
|
17338
|
+
// Default order expiry to 2 years from now
|
|
17339
|
+
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
17340
|
+
}
|
|
17341
|
+
/**
|
|
17342
|
+
* Create an order
|
|
17343
|
+
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
17344
|
+
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
17345
|
+
*/
|
|
17346
|
+
createListing(createListingParams) {
|
|
17347
|
+
return this.apiClient.createListing(createListingParams);
|
|
17348
|
+
}
|
|
17349
|
+
/**
|
|
17350
|
+
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
17351
|
+
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
17352
|
+
* transaction can be submitted or it will be reverted.
|
|
17353
|
+
* @param {string} listingId - The listingId to fulfil.
|
|
17354
|
+
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
17355
|
+
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
17356
|
+
*/
|
|
17357
|
+
async fulfillOrder(listingId, takerAddress) {
|
|
17358
|
+
const orderResult = await this.apiClient.getListing(listingId);
|
|
17359
|
+
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
17360
|
+
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
17361
|
+
}
|
|
17362
|
+
return this.seaport.fulfilOrder(orderResult.result, takerAddress);
|
|
17363
|
+
}
|
|
17364
|
+
/**
|
|
17365
|
+
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
17366
|
+
* the account that created them.
|
|
17367
|
+
* @param {string} listingId - The listingId to cancel.
|
|
17368
|
+
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
17369
|
+
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
17370
|
+
*/
|
|
17371
|
+
async cancelOrder(listingId, accountAddress) {
|
|
17372
|
+
const orderResult = await this.apiClient.getListing(listingId);
|
|
17373
|
+
if (orderResult.result.status !== OrderStatus.ACTIVE
|
|
17374
|
+
&& orderResult.result.status !== OrderStatus.INACTIVE
|
|
17375
|
+
&& orderResult.result.status !== OrderStatus.PENDING) {
|
|
17376
|
+
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
17377
|
+
}
|
|
17378
|
+
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
17379
|
+
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
|
|
17380
|
+
}
|
|
17381
|
+
const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
|
|
17382
|
+
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
|
17383
|
+
}
|
|
17384
|
+
}
|
|
17385
|
+
|
|
17386
|
+
/* eslint-disable class-methods-use-this */
|
|
17387
|
+
|
|
17388
|
+
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
17389
|
+
{
|
|
17390
|
+
constant: true,
|
|
17391
|
+
inputs: [],
|
|
17392
|
+
name: "name",
|
|
17393
|
+
outputs: [
|
|
17394
|
+
{
|
|
17395
|
+
name: "",
|
|
17396
|
+
type: "string"
|
|
17397
|
+
}
|
|
17398
|
+
],
|
|
17399
|
+
payable: false,
|
|
17400
|
+
type: "function"
|
|
17401
|
+
},
|
|
17402
|
+
{
|
|
17403
|
+
constant: true,
|
|
17404
|
+
inputs: [],
|
|
17405
|
+
name: "decimals",
|
|
17406
|
+
outputs: [
|
|
17407
|
+
{
|
|
17408
|
+
name: "",
|
|
17409
|
+
type: "uint8"
|
|
17410
|
+
}
|
|
17411
|
+
],
|
|
17412
|
+
payable: false,
|
|
17413
|
+
type: "function"
|
|
17414
|
+
},
|
|
17415
|
+
{
|
|
17416
|
+
constant: true,
|
|
17417
|
+
inputs: [
|
|
17418
|
+
{
|
|
17419
|
+
name: "_owner",
|
|
17420
|
+
type: "address"
|
|
17421
|
+
}
|
|
17422
|
+
],
|
|
17423
|
+
name: "balanceOf",
|
|
17424
|
+
outputs: [
|
|
17425
|
+
{
|
|
17426
|
+
name: "balance",
|
|
17427
|
+
type: "uint256"
|
|
17428
|
+
}
|
|
17429
|
+
],
|
|
17430
|
+
payable: false,
|
|
17431
|
+
type: "function"
|
|
17432
|
+
},
|
|
17433
|
+
{
|
|
17434
|
+
constant: true,
|
|
17435
|
+
inputs: [],
|
|
17436
|
+
name: "symbol",
|
|
17437
|
+
outputs: [
|
|
17438
|
+
{
|
|
17439
|
+
name: "",
|
|
17440
|
+
type: "string"
|
|
17441
|
+
}
|
|
17442
|
+
],
|
|
17443
|
+
payable: false,
|
|
17444
|
+
type: "function"
|
|
17445
|
+
}
|
|
17446
|
+
];
|
|
17447
|
+
|
|
17448
|
+
|
|
17449
|
+
var $aa144554f9ef124b$export$1fc8f52ad1810e52;
|
|
17450
|
+
(function(ItemType) {
|
|
17451
|
+
ItemType["NATIVE"] = "NATIVE";
|
|
17452
|
+
ItemType["ERC20"] = "ERC20";
|
|
17453
|
+
ItemType["ERC721"] = "ERC721";
|
|
17454
|
+
})($aa144554f9ef124b$export$1fc8f52ad1810e52 || ($aa144554f9ef124b$export$1fc8f52ad1810e52 = {}));
|
|
17455
|
+
var $aa144554f9ef124b$export$537fa3efd10ed435;
|
|
17456
|
+
(function(GasTokenType) {
|
|
17457
|
+
GasTokenType["NATIVE"] = "NATIVE";
|
|
17458
|
+
GasTokenType["ERC20"] = "ERC20";
|
|
17459
|
+
})($aa144554f9ef124b$export$537fa3efd10ed435 || ($aa144554f9ef124b$export$537fa3efd10ed435 = {}));
|
|
17460
|
+
|
|
17461
|
+
|
|
17462
|
+
/**
|
|
17463
|
+
* Enum representing different chain IDs.
|
|
17464
|
+
* @enum {number}
|
|
17465
|
+
* @property {number} IMTBL_ZKEVM_MAINNET - The chain ID for IMTBL ZKEVM Mainnet.
|
|
17466
|
+
* @property {number} IMTBL_ZKEVM_TESTNET - The chain ID for IMTBL ZKEVM Testnet.
|
|
17467
|
+
* @property {number} IMTBL_ZKEVM_DEVNET - The chain ID for IMTBL ZKEVM Devnet.
|
|
17468
|
+
* @property {number} ETHEREUM - The chain ID for Ethereum.
|
|
17469
|
+
* @property {number} SEPOLIA - The chain ID for Sepolia.
|
|
17470
|
+
*/ var $0472f23319457bfb$export$c06e1e7429de6283;
|
|
17471
|
+
(function(ChainId) {
|
|
17472
|
+
ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
|
|
17473
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13472] = "IMTBL_ZKEVM_TESTNET";
|
|
17474
|
+
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13433] = "IMTBL_ZKEVM_DEVNET";
|
|
17475
|
+
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
17476
|
+
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
17477
|
+
})($0472f23319457bfb$export$c06e1e7429de6283 || ($0472f23319457bfb$export$c06e1e7429de6283 = {}));
|
|
17478
|
+
var $0472f23319457bfb$export$b874c6b1dfe85e02;
|
|
17479
|
+
(function(ChainName) {
|
|
17480
|
+
ChainName["ETHEREUM"] = "Ethereum";
|
|
17481
|
+
ChainName["SEPOLIA"] = "Sepolia";
|
|
17482
|
+
ChainName["IMTBL_ZKEVM_TESTNET"] = "Immutable zkEVM Test";
|
|
17483
|
+
ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
|
|
17484
|
+
ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
|
|
17485
|
+
})($0472f23319457bfb$export$b874c6b1dfe85e02 || ($0472f23319457bfb$export$b874c6b1dfe85e02 = {}));
|
|
17486
|
+
|
|
17487
|
+
|
|
17488
|
+
|
|
17489
|
+
|
|
17490
|
+
|
|
17491
|
+
|
|
17492
|
+
var $de275b98d2b651c3$export$788b1fd17f3dad84;
|
|
17493
|
+
(function(GasEstimateType) {
|
|
17494
|
+
GasEstimateType["BRIDGE_TO_L2"] = "BRIDGE_TO_L2";
|
|
17495
|
+
GasEstimateType["SWAP"] = "SWAP";
|
|
17496
|
+
})($de275b98d2b651c3$export$788b1fd17f3dad84 || ($de275b98d2b651c3$export$788b1fd17f3dad84 = {}));
|
|
17497
|
+
|
|
17498
|
+
|
|
17499
|
+
var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
17500
|
+
(function(NetworkFilterTypes) {
|
|
17501
|
+
NetworkFilterTypes["ALL"] = "all";
|
|
17502
|
+
})($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
|
|
15519
17503
|
|
|
15520
17504
|
|
|
15521
17505
|
|
|
@@ -15572,10 +17556,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
15572
17556
|
[(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
|
|
15573
17557
|
[(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
|
|
15574
17558
|
};
|
|
15575
|
-
const $d85ad1457a3f1a83$export$7b057be2a3f512cc = {
|
|
15576
|
-
[(Environment$1).SANDBOX]: "https://zkevm-rpc.sandbox.imtbl.com",
|
|
15577
|
-
[(Environment$1).PRODUCTION]: "https://zkevm-rpc.imtbl.com"
|
|
15578
|
-
};
|
|
15579
17559
|
const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
|
|
15580
17560
|
[
|
|
15581
17561
|
($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
|
|
@@ -15705,6 +17685,8 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
|
|
|
15705
17685
|
CheckoutErrorType["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
15706
17686
|
CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
15707
17687
|
CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
|
|
17688
|
+
CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
|
|
17689
|
+
CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
|
|
15708
17690
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
15709
17691
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
15710
17692
|
message;
|
|
@@ -16151,6 +18133,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
|
|
|
16151
18133
|
|
|
16152
18134
|
|
|
16153
18135
|
|
|
18136
|
+
|
|
16154
18137
|
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
|
|
16155
18138
|
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
16156
18139
|
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
@@ -16179,6 +18162,13 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
|
|
|
16179
18162
|
overrides: dexConfig?.overrides
|
|
16180
18163
|
});
|
|
16181
18164
|
}
|
|
18165
|
+
async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
18166
|
+
return new (Orderbook)({
|
|
18167
|
+
baseConfig: {
|
|
18168
|
+
environment: config.environment
|
|
18169
|
+
}
|
|
18170
|
+
});
|
|
18171
|
+
}
|
|
16182
18172
|
|
|
16183
18173
|
|
|
16184
18174
|
|
|
@@ -16200,7 +18190,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
|
|
|
16200
18190
|
static async makeHttpRequest(url) {
|
|
16201
18191
|
let response;
|
|
16202
18192
|
try {
|
|
16203
|
-
response = await (0,
|
|
18193
|
+
response = await (0, axios).get(url);
|
|
16204
18194
|
} catch (error) {
|
|
16205
18195
|
throw new Error(`Error fetching from api: ${error.message}`);
|
|
16206
18196
|
}
|
|
@@ -16245,23 +18235,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
|
|
|
16245
18235
|
this.message = message;
|
|
16246
18236
|
}
|
|
16247
18237
|
}
|
|
16248
|
-
const $4013c5c91bb535f6$var$networkMap = (prod, dev
|
|
16249
|
-
|
|
16250
|
-
if (
|
|
16251
|
-
|
|
16252
|
-
networks = ($d85ad1457a3f1a83$export$6f24f3cef7d501c4);
|
|
16253
|
-
if (local) {
|
|
16254
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET)?.rpcUrls;
|
|
16255
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).PRODUCTION]);
|
|
16256
|
-
}
|
|
16257
|
-
} else {
|
|
16258
|
-
networks = ($d85ad1457a3f1a83$export$3e81fc0987227f10);
|
|
16259
|
-
if (local) {
|
|
16260
|
-
const rpcUrls = networks.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET)?.rpcUrls;
|
|
16261
|
-
rpcUrls?.splice(0, 1, ($d85ad1457a3f1a83$export$7b057be2a3f512cc)[(Environment$1).SANDBOX]);
|
|
16262
|
-
}
|
|
16263
|
-
}
|
|
16264
|
-
return networks;
|
|
18238
|
+
const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
|
|
18239
|
+
if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
|
|
18240
|
+
if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
|
|
18241
|
+
return $d85ad1457a3f1a83$export$3e81fc0987227f10;
|
|
16265
18242
|
};
|
|
16266
18243
|
const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
|
|
16267
18244
|
// DevMode and Sandbox will both use Sepolia.
|
|
@@ -16279,11 +18256,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
16279
18256
|
// This will be used to get around the lack of
|
|
16280
18257
|
// Environment.DEVELOPMENT
|
|
16281
18258
|
isDevelopment = false;
|
|
16282
|
-
// This is a hidden feature that is only available
|
|
16283
|
-
// when building the project from source code.
|
|
16284
|
-
// This will be used to get around the lack of
|
|
16285
|
-
// Environment.LOCAL_DEVELOPMENT
|
|
16286
|
-
isLocal = false;
|
|
16287
18259
|
isProduction;
|
|
16288
18260
|
remote;
|
|
16289
18261
|
environment;
|
|
@@ -16293,7 +18265,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
|
16293
18265
|
this.environment = config.baseConfig.environment;
|
|
16294
18266
|
// Developer mode will super set any environment configuration
|
|
16295
18267
|
this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
|
|
16296
|
-
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment
|
|
18268
|
+
this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
|
|
16297
18269
|
this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
|
|
16298
18270
|
isDevelopment: this.isDevelopment,
|
|
16299
18271
|
isProduction: this.isProduction
|
|
@@ -16403,6 +18375,84 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
16403
18375
|
|
|
16404
18376
|
|
|
16405
18377
|
|
|
18378
|
+
const $c147333b1f360629$export$92589613aaa38e1f = 300000;
|
|
18379
|
+
const $c147333b1f360629$export$dea9ce0e9bb2441c = "0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19";
|
|
18380
|
+
const $c147333b1f360629$export$5baee63457fa7911 = (type, amount, contractAddress)=>{
|
|
18381
|
+
switch(type){
|
|
18382
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20:
|
|
18383
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721:
|
|
18384
|
+
return {
|
|
18385
|
+
type: type,
|
|
18386
|
+
amount: amount,
|
|
18387
|
+
contractAddress: contractAddress,
|
|
18388
|
+
approvalContractAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
|
|
18389
|
+
};
|
|
18390
|
+
case ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE:
|
|
18391
|
+
default:
|
|
18392
|
+
return {
|
|
18393
|
+
type: ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE,
|
|
18394
|
+
amount: amount
|
|
18395
|
+
};
|
|
18396
|
+
}
|
|
18397
|
+
};
|
|
18398
|
+
const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, orderId)=>{
|
|
18399
|
+
let order;
|
|
18400
|
+
try {
|
|
18401
|
+
const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
18402
|
+
order = await orderbook.getListing(orderId);
|
|
18403
|
+
} catch (err) {
|
|
18404
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while getting the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ORDER_LISTING_ERROR, {
|
|
18405
|
+
orderId: orderId,
|
|
18406
|
+
message: err.message
|
|
18407
|
+
});
|
|
18408
|
+
}
|
|
18409
|
+
let amount = (BigNumber$2).from("0");
|
|
18410
|
+
let type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
|
|
18411
|
+
let contractAddress = "";
|
|
18412
|
+
const buyArray = order.result.buy;
|
|
18413
|
+
if (buyArray.length > 0) switch(buyArray[0].item_type){
|
|
18414
|
+
case "NATIVE":
|
|
18415
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
|
|
18416
|
+
break;
|
|
18417
|
+
case "ERC20":
|
|
18418
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20;
|
|
18419
|
+
contractAddress = buyArray[0].contract_address;
|
|
18420
|
+
break;
|
|
18421
|
+
case "ERC721":
|
|
18422
|
+
type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721;
|
|
18423
|
+
contractAddress = buyArray[0].contract_address;
|
|
18424
|
+
break;
|
|
18425
|
+
default:
|
|
18426
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Purchasing token type is unsupported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_TOKEN_TYPE_ERROR, {
|
|
18427
|
+
orderId: orderId
|
|
18428
|
+
});
|
|
18429
|
+
}
|
|
18430
|
+
buyArray.forEach((item)=>{
|
|
18431
|
+
amount = amount.add((BigNumber$2).from(item.start_amount));
|
|
18432
|
+
});
|
|
18433
|
+
const feeArray = order.result.fees;
|
|
18434
|
+
feeArray.forEach((item)=>{
|
|
18435
|
+
amount = amount.add((BigNumber$2).from(item.amount));
|
|
18436
|
+
});
|
|
18437
|
+
const requirements = [
|
|
18438
|
+
$c147333b1f360629$export$5baee63457fa7911(type, amount, contractAddress)
|
|
18439
|
+
];
|
|
18440
|
+
return {
|
|
18441
|
+
requirements: requirements,
|
|
18442
|
+
gas: {
|
|
18443
|
+
type: ($aa144554f9ef124b$export$537fa3efd10ed435).NATIVE,
|
|
18444
|
+
limit: (BigNumber$2).from($c147333b1f360629$export$92589613aaa38e1f)
|
|
18445
|
+
}
|
|
18446
|
+
};
|
|
18447
|
+
};
|
|
18448
|
+
|
|
18449
|
+
|
|
18450
|
+
|
|
18451
|
+
|
|
18452
|
+
|
|
18453
|
+
|
|
18454
|
+
|
|
18455
|
+
|
|
16406
18456
|
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
16407
18457
|
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
16408
18458
|
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
@@ -16537,6 +18587,15 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
16537
18587
|
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, web3Provider);
|
|
16538
18588
|
}
|
|
16539
18589
|
/**
|
|
18590
|
+
* Determines the requirements for performing a buy.
|
|
18591
|
+
* @param {BuyParams} params - The parameters for the buy.
|
|
18592
|
+
*/ async buy(params) {
|
|
18593
|
+
// eslint-disable-next-line no-console
|
|
18594
|
+
console.warn("This endpoint is currently under construction.");
|
|
18595
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
18596
|
+
await $c147333b1f360629$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
|
|
18597
|
+
}
|
|
18598
|
+
/**
|
|
16540
18599
|
* Checks if the given object is a Web3 provider.
|
|
16541
18600
|
* @param {Web3Provider} web3Provider - The object to check.
|
|
16542
18601
|
* @returns {boolean} - True if the object is a Web3 provider, false otherwise.
|