@imtbl/sdk 0.6.0-alpha → 0.7.0-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.
@@ -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 $7v2Z6$axios from 'axios';
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,109 +15414,2121 @@ class Exchange {
15412
15414
  }
15413
15415
  }
15414
15416
 
15415
- /* eslint-disable class-methods-use-this */
15417
+ class BaseHttpRequest {
15418
+ config;
15419
+ constructor(config) {
15420
+ this.config = config;
15421
+ }
15422
+ }
15416
15423
 
15417
- const $762782b6c862d954$export$db5daa1b5156ccfe = [
15418
- {
15419
- constant: true,
15420
- inputs: [],
15421
- name: "name",
15422
- outputs: [
15423
- {
15424
- name: "",
15425
- type: "string"
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
- payable: false,
15429
- type: "function"
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
- payable: false,
15442
- type: "function"
15443
- },
15444
- {
15445
- constant: true,
15446
- inputs: [
15447
- {
15448
- name: "_owner",
15449
- type: "address"
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
- name: "balanceOf",
15453
- outputs: [
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
- payable: false,
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
- payable: false,
15473
- type: "function"
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
- * Enum representing different chain IDs.
15480
- * @enum {number}
15481
- * @property {number} IMTBL_ZKEVM_MAINNET - The chain ID for IMTBL ZKEVM Mainnet.
15482
- * @property {number} IMTBL_ZKEVM_TESTNET - The chain ID for IMTBL ZKEVM Testnet.
15483
- * @property {number} IMTBL_ZKEVM_DEVNET - The chain ID for IMTBL ZKEVM Devnet.
15484
- * @property {number} ETHEREUM - The chain ID for Ethereum.
15485
- * @property {number} SEPOLIA - The chain ID for Sepolia.
15486
- */ var $0472f23319457bfb$export$c06e1e7429de6283;
15487
- (function(ChainId) {
15488
- ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
15489
- ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13472] = "IMTBL_ZKEVM_TESTNET";
15490
- ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13433] = "IMTBL_ZKEVM_DEVNET";
15491
- ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
15492
- ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
15493
- })($0472f23319457bfb$export$c06e1e7429de6283 || ($0472f23319457bfb$export$c06e1e7429de6283 = {}));
15494
- var $0472f23319457bfb$export$b874c6b1dfe85e02;
15495
- (function(ChainName) {
15496
- ChainName["ETHEREUM"] = "Ethereum";
15497
- ChainName["SEPOLIA"] = "Sepolia";
15498
- ChainName["IMTBL_ZKEVM_TESTNET"] = "Immutable zkEVM Test";
15499
- ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
15500
- ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
15501
- })($0472f23319457bfb$export$b874c6b1dfe85e02 || ($0472f23319457bfb$export$b874c6b1dfe85e02 = {}));
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 = {}));
15935
+
15936
+ var TransactionPurpose;
15937
+ (function (TransactionPurpose) {
15938
+ TransactionPurpose["APPROVAL"] = "APPROVAL";
15939
+ TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
15940
+ })(TransactionPurpose || (TransactionPurpose = {}));
15941
+ var SignablePurpose;
15942
+ (function (SignablePurpose) {
15943
+ SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
15944
+ })(SignablePurpose || (SignablePurpose = {}));
15945
+ var ActionType;
15946
+ (function (ActionType) {
15947
+ ActionType["TRANSACTION"] = "TRANSACTION";
15948
+ ActionType["SIGNABLE"] = "SIGNABLE";
15949
+ })(ActionType || (ActionType = {}));
15506
15950
 
15951
+ /* eslint-disable */
15952
+ // TODO: Resolve these from seaport-js.
15953
+ // There is some bundling issue that is preventing this from working
15954
+ const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
15955
+ const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
15956
+ const SEAPORT_CONTRACT_VERSION_V1_5 = '1.5';
15957
+ const EIP_712_ORDER_TYPE = {
15958
+ OrderComponents: [
15959
+ { name: 'offerer', type: 'address' },
15960
+ { name: 'zone', type: 'address' },
15961
+ { name: 'offer', type: 'OfferItem[]' },
15962
+ { name: 'consideration', type: 'ConsiderationItem[]' },
15963
+ { name: 'orderType', type: 'uint8' },
15964
+ { name: 'startTime', type: 'uint256' },
15965
+ { name: 'endTime', type: 'uint256' },
15966
+ { name: 'zoneHash', type: 'bytes32' },
15967
+ { name: 'salt', type: 'uint256' },
15968
+ { name: 'conduitKey', type: 'bytes32' },
15969
+ { name: 'counter', type: 'uint256' },
15970
+ ],
15971
+ OfferItem: [
15972
+ { name: 'itemType', type: 'uint8' },
15973
+ { name: 'token', type: 'address' },
15974
+ { name: 'identifierOrCriteria', type: 'uint256' },
15975
+ { name: 'startAmount', type: 'uint256' },
15976
+ { name: 'endAmount', type: 'uint256' },
15977
+ ],
15978
+ ConsiderationItem: [
15979
+ { name: 'itemType', type: 'uint8' },
15980
+ { name: 'token', type: 'address' },
15981
+ { name: 'identifierOrCriteria', type: 'uint256' },
15982
+ { name: 'startAmount', type: 'uint256' },
15983
+ { name: 'endAmount', type: 'uint256' },
15984
+ { name: 'recipient', type: 'address' },
15985
+ ],
15986
+ };
15987
+ var OrderType;
15988
+ (function (OrderType) {
15989
+ OrderType[OrderType["FULL_OPEN"] = 0] = "FULL_OPEN";
15990
+ OrderType[OrderType["PARTIAL_OPEN"] = 1] = "PARTIAL_OPEN";
15991
+ OrderType[OrderType["FULL_RESTRICTED"] = 2] = "FULL_RESTRICTED";
15992
+ OrderType[OrderType["PARTIAL_RESTRICTED"] = 3] = "PARTIAL_RESTRICTED";
15993
+ })(OrderType || (OrderType = {}));
15994
+ var ItemType;
15995
+ (function (ItemType) {
15996
+ ItemType[ItemType["NATIVE"] = 0] = "NATIVE";
15997
+ ItemType[ItemType["ERC20"] = 1] = "ERC20";
15998
+ ItemType[ItemType["ERC721"] = 2] = "ERC721";
15999
+ ItemType[ItemType["ERC1155"] = 3] = "ERC1155";
16000
+ ItemType[ItemType["ERC721_WITH_CRITERIA"] = 4] = "ERC721_WITH_CRITERIA";
16001
+ ItemType[ItemType["ERC1155_WITH_CRITERIA"] = 5] = "ERC1155_WITH_CRITERIA";
16002
+ })(ItemType || (ItemType = {}));
16003
+ var Side;
16004
+ (function (Side) {
16005
+ Side[Side["OFFER"] = 0] = "OFFER";
16006
+ Side[Side["CONSIDERATION"] = 1] = "CONSIDERATION";
16007
+ })(Side || (Side = {}));
16008
+ var BasicOrderRouteType;
16009
+ (function (BasicOrderRouteType) {
16010
+ BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC721"] = 0] = "ETH_TO_ERC721";
16011
+ BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC1155"] = 1] = "ETH_TO_ERC1155";
16012
+ BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC721"] = 2] = "ERC20_TO_ERC721";
16013
+ BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC1155"] = 3] = "ERC20_TO_ERC1155";
16014
+ BasicOrderRouteType[BasicOrderRouteType["ERC721_TO_ERC20"] = 4] = "ERC721_TO_ERC20";
16015
+ BasicOrderRouteType[BasicOrderRouteType["ERC1155_TO_ERC20"] = 5] = "ERC1155_TO_ERC20";
16016
+ })(BasicOrderRouteType || (BasicOrderRouteType = {}));
16017
+
16018
+ function getOrderComponentsFromMessage(orderMessage) {
16019
+ const data = JSON.parse(orderMessage);
16020
+ const orderComponents = data.message;
16021
+ orderComponents.salt = BigNumber$2.from(orderComponents.salt).toHexString();
16022
+ return orderComponents;
16023
+ }
15507
16024
 
15508
- var $de275b98d2b651c3$export$788b1fd17f3dad84;
15509
- (function(GasEstimateType) {
15510
- GasEstimateType["BRIDGE_TO_L2"] = "BRIDGE_TO_L2";
15511
- GasEstimateType["SWAP"] = "SWAP";
15512
- })($de275b98d2b651c3$export$788b1fd17f3dad84 || ($de275b98d2b651c3$export$788b1fd17f3dad84 = {}));
16025
+ // Add 20% more gas than estimate to prevent out of gas errors
16026
+ // This can always be overwritten by the user signing the transaction
16027
+ function prepareTransaction(transactionMethods) {
16028
+ return async () => {
16029
+ const transaction = await transactionMethods.buildTransaction();
16030
+ transaction.gasLimit = await transactionMethods.estimateGas();
16031
+ transaction.gasLimit = transaction.gasLimit
16032
+ .add(transaction.gasLimit.div(5));
16033
+ return transaction;
16034
+ };
16035
+ }
15513
16036
 
16037
+ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
16038
+ const considerationItems = order.buy.map((buyItem) => {
16039
+ switch (buyItem.item_type) {
16040
+ case 'NATIVE':
16041
+ return {
16042
+ startAmount: buyItem.start_amount,
16043
+ endAmount: buyItem.start_amount,
16044
+ itemType: ItemType.NATIVE,
16045
+ recipient: order.account_address,
16046
+ token: constants.AddressZero,
16047
+ identifierOrCriteria: '0',
16048
+ };
16049
+ case 'ERC20':
16050
+ return {
16051
+ startAmount: buyItem.start_amount,
16052
+ endAmount: buyItem.start_amount,
16053
+ itemType: ItemType.ERC20,
16054
+ recipient: order.account_address,
16055
+ token: buyItem.contract_address || constants.AddressZero,
16056
+ identifierOrCriteria: '0',
16057
+ };
16058
+ default: // ERC721
16059
+ return {
16060
+ startAmount: '1',
16061
+ endAmount: '1',
16062
+ itemType: ItemType.ERC721,
16063
+ recipient: order.account_address,
16064
+ token: buyItem.contract_address || constants.AddressZero,
16065
+ identifierOrCriteria: '0',
16066
+ };
16067
+ }
16068
+ });
16069
+ const fees = order.fees.map((fee) => ({
16070
+ startAmount: fee.amount,
16071
+ endAmount: fee.amount,
16072
+ itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
16073
+ recipient: fee.recipient,
16074
+ token: order.buy[0].item_type === 'ERC20'
16075
+ ? order.buy[0].contract_address
16076
+ : constants.AddressZero,
16077
+ identifierOrCriteria: '0',
16078
+ }));
16079
+ return {
16080
+ conduitKey: constants.HashZero,
16081
+ consideration: [...considerationItems, ...fees],
16082
+ offer: order.sell.map((sellItem) => {
16083
+ const erc721Item = sellItem;
16084
+ return {
16085
+ startAmount: '1',
16086
+ endAmount: '1',
16087
+ itemType: ItemType.ERC721,
16088
+ token: erc721Item.contract_address,
16089
+ identifierOrCriteria: erc721Item.token_id,
16090
+ };
16091
+ }),
16092
+ counter,
16093
+ endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
16094
+ startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
16095
+ salt: order.salt,
16096
+ offerer: order.account_address,
16097
+ zone: zoneAddress,
16098
+ totalOriginalConsiderationItems: 2,
16099
+ orderType: OrderType.FULL_RESTRICTED,
16100
+ zoneHash: constants.HashZero,
16101
+ };
16102
+ }
15514
16103
 
15515
- var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
15516
- (function(NetworkFilterTypes) {
15517
- NetworkFilterTypes["ALL"] = "all";
16104
+ class Seaport {
16105
+ seaportLibFactory;
16106
+ provider;
16107
+ seaportContractAddress;
16108
+ zoneContractAddress;
16109
+ constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
16110
+ this.seaportLibFactory = seaportLibFactory;
16111
+ this.provider = provider;
16112
+ this.seaportContractAddress = seaportContractAddress;
16113
+ this.zoneContractAddress = zoneContractAddress;
16114
+ }
16115
+ async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
16116
+ const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
16117
+ const listingActions = [];
16118
+ const approvalAction = seaportActions
16119
+ .find((action) => action.type === 'approval');
16120
+ if (approvalAction) {
16121
+ listingActions.push({
16122
+ type: ActionType.TRANSACTION,
16123
+ purpose: TransactionPurpose.APPROVAL,
16124
+ buildTransaction: prepareTransaction(approvalAction.transactionMethods),
16125
+ });
16126
+ }
16127
+ const createAction = seaportActions
16128
+ .find((action) => action.type === 'create');
16129
+ if (!createAction) {
16130
+ throw new Error('No create order action found');
16131
+ }
16132
+ const orderMessageToSign = await createAction.getMessageToSign();
16133
+ const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
16134
+ listingActions.push({
16135
+ type: ActionType.SIGNABLE,
16136
+ purpose: SignablePurpose.CREATE_LISTING,
16137
+ message: await this.getTypedDataFromOrderComponents(orderComponents),
16138
+ });
16139
+ return {
16140
+ actions: listingActions,
16141
+ orderComponents,
16142
+ orderHash: this.getSeaportLib().getOrderHash(orderComponents),
16143
+ };
16144
+ }
16145
+ async fulfillOrder(order, account) {
16146
+ const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
16147
+ const seaportLib = this.getSeaportLib(order);
16148
+ const { actions: seaportActions } = await seaportLib.fulfillOrders({
16149
+ accountAddress: account,
16150
+ fulfillOrderDetails: [{
16151
+ order: {
16152
+ parameters: orderComponents,
16153
+ signature: order.signature,
16154
+ },
16155
+ extraData: order.protocol_data.operator_signature,
16156
+ }],
16157
+ });
16158
+ const fulfillmentActions = [];
16159
+ const approvalAction = seaportActions
16160
+ .find((action) => action.type === 'approval');
16161
+ if (approvalAction) {
16162
+ fulfillmentActions.push({
16163
+ type: ActionType.TRANSACTION,
16164
+ buildTransaction: prepareTransaction(approvalAction.transactionMethods),
16165
+ purpose: TransactionPurpose.APPROVAL,
16166
+ });
16167
+ }
16168
+ const fulfilOrderAction = seaportActions
16169
+ .find((action) => action.type === 'exchange');
16170
+ if (!fulfilOrderAction) {
16171
+ throw new Error('No exchange action found');
16172
+ }
16173
+ fulfillmentActions.push({
16174
+ type: ActionType.TRANSACTION,
16175
+ buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
16176
+ purpose: TransactionPurpose.FULFILL_ORDER,
16177
+ });
16178
+ return { actions: fulfillmentActions };
16179
+ }
16180
+ async cancelOrder(order, account) {
16181
+ const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
16182
+ const seaportLib = this.getSeaportLib(order);
16183
+ const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
16184
+ return prepareTransaction(cancellationTransaction)();
16185
+ }
16186
+ mapImmutableOrderToSeaportOrderComponents(order) {
16187
+ const orderCounter = order.protocol_data.counter;
16188
+ return mapImmutableOrderToSeaportOrderComponents(order, orderCounter, this.zoneContractAddress);
16189
+ }
16190
+ createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
16191
+ const seaportLib = this.getSeaportLib();
16192
+ return seaportLib.createOrder({
16193
+ allowPartialFills: false,
16194
+ offer: [
16195
+ {
16196
+ itemType: ItemType.ERC721,
16197
+ token: listingItem.contractAddress,
16198
+ identifier: listingItem.tokenId,
16199
+ },
16200
+ ],
16201
+ consideration: [
16202
+ {
16203
+ token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
16204
+ amount: considerationItem.amount,
16205
+ recipient: offerer,
16206
+ },
16207
+ {
16208
+ token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
16209
+ amount: royaltyInfo.amountRequired,
16210
+ recipient: royaltyInfo.recipient,
16211
+ },
16212
+ ],
16213
+ startTime: (orderStart.getTime() / 1000).toFixed(0),
16214
+ endTime: (orderExpiry.getTime() / 1000).toFixed(0),
16215
+ zone: this.zoneContractAddress,
16216
+ restrictedByZone: true,
16217
+ }, offerer);
16218
+ }
16219
+ async getTypedDataFromOrderComponents(orderComponents) {
16220
+ const { chainId } = await this.provider.getNetwork();
16221
+ const domainData = {
16222
+ name: SEAPORT_CONTRACT_NAME,
16223
+ version: SEAPORT_CONTRACT_VERSION_V1_4,
16224
+ chainId,
16225
+ verifyingContract: this.seaportContractAddress,
16226
+ };
16227
+ return {
16228
+ domain: domainData,
16229
+ types: EIP_712_ORDER_TYPE,
16230
+ value: orderComponents,
16231
+ };
16232
+ }
16233
+ getSeaportLib(order) {
16234
+ const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
16235
+ let seaportVersion = SEAPORT_CONTRACT_VERSION_V1_4;
16236
+ if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
16237
+ seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
16238
+ }
16239
+ return this.seaportLibFactory.create(seaportVersion, seaportAddress);
16240
+ }
16241
+ }
16242
+
16243
+ class ImmutableApiClient {
16244
+ orderbookService;
16245
+ chainName;
16246
+ seaportAddress;
16247
+ constructor(orderbookService, chainName, seaportAddress) {
16248
+ this.orderbookService = orderbookService;
16249
+ this.chainName = chainName;
16250
+ this.seaportAddress = seaportAddress;
16251
+ }
16252
+ async getListing(listingId) {
16253
+ return this.orderbookService.getListing({
16254
+ chainName: this.chainName,
16255
+ listingId,
16256
+ });
16257
+ }
16258
+ async listListings(listOrderParams) {
16259
+ return this.orderbookService.listListings({
16260
+ chainName: this.chainName,
16261
+ ...listOrderParams,
16262
+ });
16263
+ }
16264
+ async createListing({ orderHash, orderComponents, orderSignature, }) {
16265
+ if (orderComponents.offer.length !== 1) {
16266
+ throw new Error('Only one item can be listed at a time');
16267
+ }
16268
+ if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
16269
+ throw new Error('Only ERC721 tokens can be listed');
16270
+ }
16271
+ const orderTypes = [
16272
+ ...orderComponents.consideration.map((c) => c.itemType),
16273
+ ];
16274
+ const isSameConsiderationType = new Set(orderTypes).size === 1;
16275
+ if (!isSameConsiderationType) {
16276
+ throw new Error('All consideration items must be of the same type');
16277
+ }
16278
+ return this.orderbookService.createListing({
16279
+ chainName: this.chainName,
16280
+ requestBody: {
16281
+ order_hash: orderHash,
16282
+ account_address: orderComponents.offerer,
16283
+ buy: [
16284
+ {
16285
+ item_type: Number(orderComponents.consideration[0].itemType)
16286
+ === ItemType.NATIVE
16287
+ ? 'NATIVE'
16288
+ : 'ERC20',
16289
+ start_amount: orderComponents.consideration[0].startAmount,
16290
+ contract_address: orderComponents.consideration[0].token,
16291
+ },
16292
+ ],
16293
+ fees: orderComponents.consideration.length > 1
16294
+ ? [
16295
+ {
16296
+ amount: orderComponents.consideration[1].startAmount,
16297
+ recipient: orderComponents.consideration[1].recipient,
16298
+ fee_type: Fee.fee_type.ROYALTY,
16299
+ },
16300
+ ]
16301
+ : [],
16302
+ end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
16303
+ protocol_data: {
16304
+ order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
16305
+ zone_address: orderComponents.zone,
16306
+ seaport_address: this.seaportAddress,
16307
+ seaport_version: SEAPORT_CONTRACT_VERSION_V1_4,
16308
+ counter: orderComponents.counter.toString(),
16309
+ },
16310
+ salt: orderComponents.salt,
16311
+ sell: [
16312
+ {
16313
+ contract_address: orderComponents.offer[0].token,
16314
+ token_id: orderComponents.offer[0].identifierOrCriteria,
16315
+ item_type: 'ERC721',
16316
+ },
16317
+ ],
16318
+ signature: orderSignature,
16319
+ start_time: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
16320
+ },
16321
+ });
16322
+ }
16323
+ }
16324
+
16325
+ class ImmutableApiClientFactory {
16326
+ chainName;
16327
+ seaportAddress;
16328
+ orderbookClient;
16329
+ constructor(apiEndpoint, chainName, seaportAddress) {
16330
+ this.chainName = chainName;
16331
+ this.seaportAddress = seaportAddress;
16332
+ this.orderbookClient = new OrderBookClient({
16333
+ // eslint-disable-next-line @typescript-eslint/naming-convention
16334
+ BASE: apiEndpoint,
16335
+ });
16336
+ }
16337
+ create() {
16338
+ return new ImmutableApiClient(this.orderbookClient.orders, this.chainName, this.seaportAddress);
16339
+ }
16340
+ }
16341
+
16342
+ const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
16343
+ const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
16344
+ function getOrderbookConfig(environment) {
16345
+ switch (environment) {
16346
+ case Environment$1.SANDBOX:
16347
+ return {
16348
+ seaportContractAddress: '0x410000346E270aDbC89b2b688177d3AE76348dE9',
16349
+ zoneContractAddress: '0x979C2aCA989A56554Eb63E01e576E3179Cdad5A0',
16350
+ apiEndpoint: 'https://order-book-mr.sandbox.imtbl.com',
16351
+ chainName: TESTNET_CHAIN_NAME,
16352
+ provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
16353
+ };
16354
+ // not yet deployed
16355
+ case Environment$1.PRODUCTION:
16356
+ return {
16357
+ seaportContractAddress: '',
16358
+ zoneContractAddress: '',
16359
+ apiEndpoint: 'https://api.immutable.com',
16360
+ chainName: MAINNET_CHAIN_NAME,
16361
+ provider: new providers.JsonRpcProvider('https://rpc.immutable.com'),
16362
+ };
16363
+ default:
16364
+ return null;
16365
+ }
16366
+ }
16367
+
16368
+ class ERC721 {
16369
+ erc721;
16370
+ constructor(erc721) {
16371
+ this.erc721 = erc721;
16372
+ }
16373
+ async royaltyInfo(tokenId, salePrice) {
16374
+ const [recipient, royaltyRequired] = await this.erc721.royaltyInfo(tokenId, salePrice);
16375
+ return { recipient, amountRequired: royaltyRequired.toString() };
16376
+ }
16377
+ }
16378
+
16379
+ /* Autogenerated file. Do not edit manually. */
16380
+ /* tslint:disable */
16381
+ /* eslint-disable */
16382
+ const _abi = [
16383
+ {
16384
+ inputs: [
16385
+ {
16386
+ internalType: "address",
16387
+ name: "owner_",
16388
+ type: "address",
16389
+ },
16390
+ {
16391
+ internalType: "string",
16392
+ name: "name_",
16393
+ type: "string",
16394
+ },
16395
+ {
16396
+ internalType: "string",
16397
+ name: "symbol_",
16398
+ type: "string",
16399
+ },
16400
+ {
16401
+ internalType: "string",
16402
+ name: "baseURI_",
16403
+ type: "string",
16404
+ },
16405
+ {
16406
+ internalType: "string",
16407
+ name: "contractURI_",
16408
+ type: "string",
16409
+ },
16410
+ {
16411
+ internalType: "address",
16412
+ name: "_receiver",
16413
+ type: "address",
16414
+ },
16415
+ {
16416
+ internalType: "uint96",
16417
+ name: "_feeNumerator",
16418
+ type: "uint96",
16419
+ },
16420
+ ],
16421
+ stateMutability: "nonpayable",
16422
+ type: "constructor",
16423
+ },
16424
+ {
16425
+ inputs: [
16426
+ {
16427
+ internalType: "address",
16428
+ name: "target",
16429
+ type: "address",
16430
+ },
16431
+ ],
16432
+ name: "ApproveTargetNotInAllowlist",
16433
+ type: "error",
16434
+ },
16435
+ {
16436
+ inputs: [
16437
+ {
16438
+ internalType: "address",
16439
+ name: "caller",
16440
+ type: "address",
16441
+ },
16442
+ ],
16443
+ name: "CallerNotInAllowlist",
16444
+ type: "error",
16445
+ },
16446
+ {
16447
+ anonymous: false,
16448
+ inputs: [
16449
+ {
16450
+ indexed: true,
16451
+ internalType: "address",
16452
+ name: "owner",
16453
+ type: "address",
16454
+ },
16455
+ {
16456
+ indexed: true,
16457
+ internalType: "address",
16458
+ name: "approved",
16459
+ type: "address",
16460
+ },
16461
+ {
16462
+ indexed: true,
16463
+ internalType: "uint256",
16464
+ name: "tokenId",
16465
+ type: "uint256",
16466
+ },
16467
+ ],
16468
+ name: "Approval",
16469
+ type: "event",
16470
+ },
16471
+ {
16472
+ anonymous: false,
16473
+ inputs: [
16474
+ {
16475
+ indexed: true,
16476
+ internalType: "address",
16477
+ name: "owner",
16478
+ type: "address",
16479
+ },
16480
+ {
16481
+ indexed: true,
16482
+ internalType: "address",
16483
+ name: "operator",
16484
+ type: "address",
16485
+ },
16486
+ {
16487
+ indexed: false,
16488
+ internalType: "bool",
16489
+ name: "approved",
16490
+ type: "bool",
16491
+ },
16492
+ ],
16493
+ name: "ApprovalForAll",
16494
+ type: "event",
16495
+ },
16496
+ {
16497
+ anonymous: false,
16498
+ inputs: [
16499
+ {
16500
+ indexed: true,
16501
+ internalType: "bytes32",
16502
+ name: "role",
16503
+ type: "bytes32",
16504
+ },
16505
+ {
16506
+ indexed: true,
16507
+ internalType: "bytes32",
16508
+ name: "previousAdminRole",
16509
+ type: "bytes32",
16510
+ },
16511
+ {
16512
+ indexed: true,
16513
+ internalType: "bytes32",
16514
+ name: "newAdminRole",
16515
+ type: "bytes32",
16516
+ },
16517
+ ],
16518
+ name: "RoleAdminChanged",
16519
+ type: "event",
16520
+ },
16521
+ {
16522
+ anonymous: false,
16523
+ inputs: [
16524
+ {
16525
+ indexed: true,
16526
+ internalType: "bytes32",
16527
+ name: "role",
16528
+ type: "bytes32",
16529
+ },
16530
+ {
16531
+ indexed: true,
16532
+ internalType: "address",
16533
+ name: "account",
16534
+ type: "address",
16535
+ },
16536
+ {
16537
+ indexed: true,
16538
+ internalType: "address",
16539
+ name: "sender",
16540
+ type: "address",
16541
+ },
16542
+ ],
16543
+ name: "RoleGranted",
16544
+ type: "event",
16545
+ },
16546
+ {
16547
+ anonymous: false,
16548
+ inputs: [
16549
+ {
16550
+ indexed: true,
16551
+ internalType: "bytes32",
16552
+ name: "role",
16553
+ type: "bytes32",
16554
+ },
16555
+ {
16556
+ indexed: true,
16557
+ internalType: "address",
16558
+ name: "account",
16559
+ type: "address",
16560
+ },
16561
+ {
16562
+ indexed: true,
16563
+ internalType: "address",
16564
+ name: "sender",
16565
+ type: "address",
16566
+ },
16567
+ ],
16568
+ name: "RoleRevoked",
16569
+ type: "event",
16570
+ },
16571
+ {
16572
+ anonymous: false,
16573
+ inputs: [
16574
+ {
16575
+ indexed: false,
16576
+ internalType: "address",
16577
+ name: "oldRegistry",
16578
+ type: "address",
16579
+ },
16580
+ {
16581
+ indexed: false,
16582
+ internalType: "address",
16583
+ name: "newRegistry",
16584
+ type: "address",
16585
+ },
16586
+ ],
16587
+ name: "RoyaltytAllowlistRegistryUpdated",
16588
+ type: "event",
16589
+ },
16590
+ {
16591
+ anonymous: false,
16592
+ inputs: [
16593
+ {
16594
+ indexed: true,
16595
+ internalType: "address",
16596
+ name: "from",
16597
+ type: "address",
16598
+ },
16599
+ {
16600
+ indexed: true,
16601
+ internalType: "address",
16602
+ name: "to",
16603
+ type: "address",
16604
+ },
16605
+ {
16606
+ indexed: true,
16607
+ internalType: "uint256",
16608
+ name: "tokenId",
16609
+ type: "uint256",
16610
+ },
16611
+ ],
16612
+ name: "Transfer",
16613
+ type: "event",
16614
+ },
16615
+ {
16616
+ inputs: [],
16617
+ name: "DEFAULT_ADMIN_ROLE",
16618
+ outputs: [
16619
+ {
16620
+ internalType: "bytes32",
16621
+ name: "",
16622
+ type: "bytes32",
16623
+ },
16624
+ ],
16625
+ stateMutability: "view",
16626
+ type: "function",
16627
+ },
16628
+ {
16629
+ inputs: [],
16630
+ name: "MINTER_ROLE",
16631
+ outputs: [
16632
+ {
16633
+ internalType: "bytes32",
16634
+ name: "",
16635
+ type: "bytes32",
16636
+ },
16637
+ ],
16638
+ stateMutability: "view",
16639
+ type: "function",
16640
+ },
16641
+ {
16642
+ inputs: [
16643
+ {
16644
+ internalType: "address",
16645
+ name: "to",
16646
+ type: "address",
16647
+ },
16648
+ {
16649
+ internalType: "uint256",
16650
+ name: "tokenId",
16651
+ type: "uint256",
16652
+ },
16653
+ ],
16654
+ name: "approve",
16655
+ outputs: [],
16656
+ stateMutability: "nonpayable",
16657
+ type: "function",
16658
+ },
16659
+ {
16660
+ inputs: [
16661
+ {
16662
+ internalType: "address",
16663
+ name: "owner",
16664
+ type: "address",
16665
+ },
16666
+ ],
16667
+ name: "balanceOf",
16668
+ outputs: [
16669
+ {
16670
+ internalType: "uint256",
16671
+ name: "",
16672
+ type: "uint256",
16673
+ },
16674
+ ],
16675
+ stateMutability: "view",
16676
+ type: "function",
16677
+ },
16678
+ {
16679
+ inputs: [],
16680
+ name: "baseURI",
16681
+ outputs: [
16682
+ {
16683
+ internalType: "string",
16684
+ name: "",
16685
+ type: "string",
16686
+ },
16687
+ ],
16688
+ stateMutability: "view",
16689
+ type: "function",
16690
+ },
16691
+ {
16692
+ inputs: [
16693
+ {
16694
+ internalType: "uint256",
16695
+ name: "tokenId",
16696
+ type: "uint256",
16697
+ },
16698
+ ],
16699
+ name: "burn",
16700
+ outputs: [],
16701
+ stateMutability: "nonpayable",
16702
+ type: "function",
16703
+ },
16704
+ {
16705
+ inputs: [],
16706
+ name: "contractURI",
16707
+ outputs: [
16708
+ {
16709
+ internalType: "string",
16710
+ name: "",
16711
+ type: "string",
16712
+ },
16713
+ ],
16714
+ stateMutability: "view",
16715
+ type: "function",
16716
+ },
16717
+ {
16718
+ inputs: [],
16719
+ name: "getAdmins",
16720
+ outputs: [
16721
+ {
16722
+ internalType: "address[]",
16723
+ name: "",
16724
+ type: "address[]",
16725
+ },
16726
+ ],
16727
+ stateMutability: "view",
16728
+ type: "function",
16729
+ },
16730
+ {
16731
+ inputs: [
16732
+ {
16733
+ internalType: "uint256",
16734
+ name: "tokenId",
16735
+ type: "uint256",
16736
+ },
16737
+ ],
16738
+ name: "getApproved",
16739
+ outputs: [
16740
+ {
16741
+ internalType: "address",
16742
+ name: "",
16743
+ type: "address",
16744
+ },
16745
+ ],
16746
+ stateMutability: "view",
16747
+ type: "function",
16748
+ },
16749
+ {
16750
+ inputs: [
16751
+ {
16752
+ internalType: "bytes32",
16753
+ name: "role",
16754
+ type: "bytes32",
16755
+ },
16756
+ ],
16757
+ name: "getRoleAdmin",
16758
+ outputs: [
16759
+ {
16760
+ internalType: "bytes32",
16761
+ name: "",
16762
+ type: "bytes32",
16763
+ },
16764
+ ],
16765
+ stateMutability: "view",
16766
+ type: "function",
16767
+ },
16768
+ {
16769
+ inputs: [
16770
+ {
16771
+ internalType: "bytes32",
16772
+ name: "role",
16773
+ type: "bytes32",
16774
+ },
16775
+ {
16776
+ internalType: "uint256",
16777
+ name: "index",
16778
+ type: "uint256",
16779
+ },
16780
+ ],
16781
+ name: "getRoleMember",
16782
+ outputs: [
16783
+ {
16784
+ internalType: "address",
16785
+ name: "",
16786
+ type: "address",
16787
+ },
16788
+ ],
16789
+ stateMutability: "view",
16790
+ type: "function",
16791
+ },
16792
+ {
16793
+ inputs: [
16794
+ {
16795
+ internalType: "bytes32",
16796
+ name: "role",
16797
+ type: "bytes32",
16798
+ },
16799
+ ],
16800
+ name: "getRoleMemberCount",
16801
+ outputs: [
16802
+ {
16803
+ internalType: "uint256",
16804
+ name: "",
16805
+ type: "uint256",
16806
+ },
16807
+ ],
16808
+ stateMutability: "view",
16809
+ type: "function",
16810
+ },
16811
+ {
16812
+ inputs: [
16813
+ {
16814
+ internalType: "address",
16815
+ name: "user",
16816
+ type: "address",
16817
+ },
16818
+ ],
16819
+ name: "grantMinterRole",
16820
+ outputs: [],
16821
+ stateMutability: "nonpayable",
16822
+ type: "function",
16823
+ },
16824
+ {
16825
+ inputs: [
16826
+ {
16827
+ internalType: "bytes32",
16828
+ name: "role",
16829
+ type: "bytes32",
16830
+ },
16831
+ {
16832
+ internalType: "address",
16833
+ name: "account",
16834
+ type: "address",
16835
+ },
16836
+ ],
16837
+ name: "grantRole",
16838
+ outputs: [],
16839
+ stateMutability: "nonpayable",
16840
+ type: "function",
16841
+ },
16842
+ {
16843
+ inputs: [
16844
+ {
16845
+ internalType: "bytes32",
16846
+ name: "role",
16847
+ type: "bytes32",
16848
+ },
16849
+ {
16850
+ internalType: "address",
16851
+ name: "account",
16852
+ type: "address",
16853
+ },
16854
+ ],
16855
+ name: "hasRole",
16856
+ outputs: [
16857
+ {
16858
+ internalType: "bool",
16859
+ name: "",
16860
+ type: "bool",
16861
+ },
16862
+ ],
16863
+ stateMutability: "view",
16864
+ type: "function",
16865
+ },
16866
+ {
16867
+ inputs: [
16868
+ {
16869
+ internalType: "address",
16870
+ name: "owner",
16871
+ type: "address",
16872
+ },
16873
+ {
16874
+ internalType: "address",
16875
+ name: "operator",
16876
+ type: "address",
16877
+ },
16878
+ ],
16879
+ name: "isApprovedForAll",
16880
+ outputs: [
16881
+ {
16882
+ internalType: "bool",
16883
+ name: "",
16884
+ type: "bool",
16885
+ },
16886
+ ],
16887
+ stateMutability: "view",
16888
+ type: "function",
16889
+ },
16890
+ {
16891
+ inputs: [
16892
+ {
16893
+ internalType: "address",
16894
+ name: "to",
16895
+ type: "address",
16896
+ },
16897
+ {
16898
+ internalType: "uint256",
16899
+ name: "amount",
16900
+ type: "uint256",
16901
+ },
16902
+ ],
16903
+ name: "mint",
16904
+ outputs: [],
16905
+ stateMutability: "nonpayable",
16906
+ type: "function",
16907
+ },
16908
+ {
16909
+ inputs: [],
16910
+ name: "name",
16911
+ outputs: [
16912
+ {
16913
+ internalType: "string",
16914
+ name: "",
16915
+ type: "string",
16916
+ },
16917
+ ],
16918
+ stateMutability: "view",
16919
+ type: "function",
16920
+ },
16921
+ {
16922
+ inputs: [
16923
+ {
16924
+ internalType: "uint256",
16925
+ name: "tokenId",
16926
+ type: "uint256",
16927
+ },
16928
+ ],
16929
+ name: "ownerOf",
16930
+ outputs: [
16931
+ {
16932
+ internalType: "address",
16933
+ name: "",
16934
+ type: "address",
16935
+ },
16936
+ ],
16937
+ stateMutability: "view",
16938
+ type: "function",
16939
+ },
16940
+ {
16941
+ inputs: [
16942
+ {
16943
+ internalType: "bytes32",
16944
+ name: "role",
16945
+ type: "bytes32",
16946
+ },
16947
+ {
16948
+ internalType: "address",
16949
+ name: "account",
16950
+ type: "address",
16951
+ },
16952
+ ],
16953
+ name: "renounceRole",
16954
+ outputs: [],
16955
+ stateMutability: "nonpayable",
16956
+ type: "function",
16957
+ },
16958
+ {
16959
+ inputs: [
16960
+ {
16961
+ internalType: "address",
16962
+ name: "user",
16963
+ type: "address",
16964
+ },
16965
+ ],
16966
+ name: "revokeMinterRole",
16967
+ outputs: [],
16968
+ stateMutability: "nonpayable",
16969
+ type: "function",
16970
+ },
16971
+ {
16972
+ inputs: [
16973
+ {
16974
+ internalType: "bytes32",
16975
+ name: "role",
16976
+ type: "bytes32",
16977
+ },
16978
+ {
16979
+ internalType: "address",
16980
+ name: "account",
16981
+ type: "address",
16982
+ },
16983
+ ],
16984
+ name: "revokeRole",
16985
+ outputs: [],
16986
+ stateMutability: "nonpayable",
16987
+ type: "function",
16988
+ },
16989
+ {
16990
+ inputs: [],
16991
+ name: "royaltyAllowlist",
16992
+ outputs: [
16993
+ {
16994
+ internalType: "contract IRoyaltyAllowlist",
16995
+ name: "",
16996
+ type: "address",
16997
+ },
16998
+ ],
16999
+ stateMutability: "view",
17000
+ type: "function",
17001
+ },
17002
+ {
17003
+ inputs: [
17004
+ {
17005
+ internalType: "uint256",
17006
+ name: "_tokenId",
17007
+ type: "uint256",
17008
+ },
17009
+ {
17010
+ internalType: "uint256",
17011
+ name: "_salePrice",
17012
+ type: "uint256",
17013
+ },
17014
+ ],
17015
+ name: "royaltyInfo",
17016
+ outputs: [
17017
+ {
17018
+ internalType: "address",
17019
+ name: "",
17020
+ type: "address",
17021
+ },
17022
+ {
17023
+ internalType: "uint256",
17024
+ name: "",
17025
+ type: "uint256",
17026
+ },
17027
+ ],
17028
+ stateMutability: "view",
17029
+ type: "function",
17030
+ },
17031
+ {
17032
+ inputs: [
17033
+ {
17034
+ internalType: "address",
17035
+ name: "from",
17036
+ type: "address",
17037
+ },
17038
+ {
17039
+ internalType: "address",
17040
+ name: "to",
17041
+ type: "address",
17042
+ },
17043
+ {
17044
+ internalType: "uint256",
17045
+ name: "tokenId",
17046
+ type: "uint256",
17047
+ },
17048
+ ],
17049
+ name: "safeTransferFrom",
17050
+ outputs: [],
17051
+ stateMutability: "nonpayable",
17052
+ type: "function",
17053
+ },
17054
+ {
17055
+ inputs: [
17056
+ {
17057
+ internalType: "address",
17058
+ name: "from",
17059
+ type: "address",
17060
+ },
17061
+ {
17062
+ internalType: "address",
17063
+ name: "to",
17064
+ type: "address",
17065
+ },
17066
+ {
17067
+ internalType: "uint256",
17068
+ name: "tokenId",
17069
+ type: "uint256",
17070
+ },
17071
+ {
17072
+ internalType: "bytes",
17073
+ name: "data",
17074
+ type: "bytes",
17075
+ },
17076
+ ],
17077
+ name: "safeTransferFrom",
17078
+ outputs: [],
17079
+ stateMutability: "nonpayable",
17080
+ type: "function",
17081
+ },
17082
+ {
17083
+ inputs: [
17084
+ {
17085
+ internalType: "address",
17086
+ name: "operator",
17087
+ type: "address",
17088
+ },
17089
+ {
17090
+ internalType: "bool",
17091
+ name: "approved",
17092
+ type: "bool",
17093
+ },
17094
+ ],
17095
+ name: "setApprovalForAll",
17096
+ outputs: [],
17097
+ stateMutability: "nonpayable",
17098
+ type: "function",
17099
+ },
17100
+ {
17101
+ inputs: [
17102
+ {
17103
+ internalType: "string",
17104
+ name: "baseURI_",
17105
+ type: "string",
17106
+ },
17107
+ ],
17108
+ name: "setBaseURI",
17109
+ outputs: [],
17110
+ stateMutability: "nonpayable",
17111
+ type: "function",
17112
+ },
17113
+ {
17114
+ inputs: [
17115
+ {
17116
+ internalType: "string",
17117
+ name: "_contractURI",
17118
+ type: "string",
17119
+ },
17120
+ ],
17121
+ name: "setContractURI",
17122
+ outputs: [],
17123
+ stateMutability: "nonpayable",
17124
+ type: "function",
17125
+ },
17126
+ {
17127
+ inputs: [
17128
+ {
17129
+ internalType: "address",
17130
+ name: "_royaltyAllowlist",
17131
+ type: "address",
17132
+ },
17133
+ ],
17134
+ name: "setRoyaltyAllowlistRegistry",
17135
+ outputs: [],
17136
+ stateMutability: "nonpayable",
17137
+ type: "function",
17138
+ },
17139
+ {
17140
+ inputs: [
17141
+ {
17142
+ internalType: "bytes4",
17143
+ name: "interfaceId",
17144
+ type: "bytes4",
17145
+ },
17146
+ ],
17147
+ name: "supportsInterface",
17148
+ outputs: [
17149
+ {
17150
+ internalType: "bool",
17151
+ name: "",
17152
+ type: "bool",
17153
+ },
17154
+ ],
17155
+ stateMutability: "view",
17156
+ type: "function",
17157
+ },
17158
+ {
17159
+ inputs: [],
17160
+ name: "symbol",
17161
+ outputs: [
17162
+ {
17163
+ internalType: "string",
17164
+ name: "",
17165
+ type: "string",
17166
+ },
17167
+ ],
17168
+ stateMutability: "view",
17169
+ type: "function",
17170
+ },
17171
+ {
17172
+ inputs: [
17173
+ {
17174
+ internalType: "uint256",
17175
+ name: "index",
17176
+ type: "uint256",
17177
+ },
17178
+ ],
17179
+ name: "tokenByIndex",
17180
+ outputs: [
17181
+ {
17182
+ internalType: "uint256",
17183
+ name: "",
17184
+ type: "uint256",
17185
+ },
17186
+ ],
17187
+ stateMutability: "view",
17188
+ type: "function",
17189
+ },
17190
+ {
17191
+ inputs: [
17192
+ {
17193
+ internalType: "address",
17194
+ name: "owner",
17195
+ type: "address",
17196
+ },
17197
+ {
17198
+ internalType: "uint256",
17199
+ name: "index",
17200
+ type: "uint256",
17201
+ },
17202
+ ],
17203
+ name: "tokenOfOwnerByIndex",
17204
+ outputs: [
17205
+ {
17206
+ internalType: "uint256",
17207
+ name: "",
17208
+ type: "uint256",
17209
+ },
17210
+ ],
17211
+ stateMutability: "view",
17212
+ type: "function",
17213
+ },
17214
+ {
17215
+ inputs: [
17216
+ {
17217
+ internalType: "uint256",
17218
+ name: "tokenId",
17219
+ type: "uint256",
17220
+ },
17221
+ ],
17222
+ name: "tokenURI",
17223
+ outputs: [
17224
+ {
17225
+ internalType: "string",
17226
+ name: "",
17227
+ type: "string",
17228
+ },
17229
+ ],
17230
+ stateMutability: "view",
17231
+ type: "function",
17232
+ },
17233
+ {
17234
+ inputs: [],
17235
+ name: "totalSupply",
17236
+ outputs: [
17237
+ {
17238
+ internalType: "uint256",
17239
+ name: "",
17240
+ type: "uint256",
17241
+ },
17242
+ ],
17243
+ stateMutability: "view",
17244
+ type: "function",
17245
+ },
17246
+ {
17247
+ inputs: [
17248
+ {
17249
+ internalType: "address",
17250
+ name: "from",
17251
+ type: "address",
17252
+ },
17253
+ {
17254
+ internalType: "address",
17255
+ name: "to",
17256
+ type: "address",
17257
+ },
17258
+ {
17259
+ internalType: "uint256",
17260
+ name: "tokenId",
17261
+ type: "uint256",
17262
+ },
17263
+ ],
17264
+ name: "transferFrom",
17265
+ outputs: [],
17266
+ stateMutability: "nonpayable",
17267
+ type: "function",
17268
+ },
17269
+ ];
17270
+ class ImmutableERC721Base__factory {
17271
+ static abi = _abi;
17272
+ static createInterface() {
17273
+ return new utils.Interface(_abi);
17274
+ }
17275
+ static connect(address, signerOrProvider) {
17276
+ return new Contract$1(address, _abi, signerOrProvider);
17277
+ }
17278
+ }
17279
+
17280
+ class ERC721Factory {
17281
+ erc721;
17282
+ constructor(contractAddress, provider) {
17283
+ this.erc721 = ImmutableERC721Base__factory.connect(contractAddress, provider);
17284
+ }
17285
+ create() {
17286
+ return new ERC721(this.erc721);
17287
+ }
17288
+ }
17289
+
17290
+ class SeaportLibFactory {
17291
+ defaultSeaportContractAddress;
17292
+ provider;
17293
+ constructor(defaultSeaportContractAddress, provider) {
17294
+ this.defaultSeaportContractAddress = defaultSeaportContractAddress;
17295
+ this.provider = provider;
17296
+ }
17297
+ create(orderSeaportVersion, orderSeaportAddress) {
17298
+ const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_4;
17299
+ const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
17300
+ return new Seaport$1(this.provider, {
17301
+ seaportVersion,
17302
+ balanceAndApprovalChecksOnOrderCreation: true,
17303
+ overrides: {
17304
+ contractAddress: seaportContractAddress,
17305
+ },
17306
+ });
17307
+ }
17308
+ }
17309
+
17310
+ /**
17311
+ * zkEVM orderbook SDK
17312
+ * @constructor
17313
+ * @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
17314
+ */
17315
+ class Orderbook {
17316
+ apiClient;
17317
+ seaport;
17318
+ orderbookConfig;
17319
+ constructor(config) {
17320
+ const obConfig = getOrderbookConfig(config.baseConfig.environment);
17321
+ const finalConfig = {
17322
+ ...obConfig,
17323
+ ...config.overrides,
17324
+ };
17325
+ if (!finalConfig) {
17326
+ throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
17327
+ }
17328
+ this.orderbookConfig = finalConfig;
17329
+ const { apiEndpoint, chainName } = this.orderbookConfig;
17330
+ if (!apiEndpoint) {
17331
+ throw new Error('API endpoint must be provided');
17332
+ }
17333
+ this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
17334
+ const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
17335
+ this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
17336
+ }
17337
+ /**
17338
+ * Get an order by ID
17339
+ * @param {string} listingId - The listingId to find.
17340
+ * @return {ListingResult} The returned order result.
17341
+ */
17342
+ getListing(listingId) {
17343
+ return this.apiClient.getListing(listingId);
17344
+ }
17345
+ /**
17346
+ * List orders. This method is used to get a list of orders filtered by conditions specified
17347
+ * in the params object.
17348
+ * @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
17349
+ * @return {Orders} The paged orders.
17350
+ */
17351
+ listListings(listOrderParams) {
17352
+ return this.apiClient.listListings(listOrderParams);
17353
+ }
17354
+ /**
17355
+ * Get required transactions and messages for signing prior to creating a listing
17356
+ * through the createListing method
17357
+ * @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
17358
+ * @return {PrepareListingResponse} PrepareListingResponse includes
17359
+ * the unsigned approval transaction, the typed order message for signing and
17360
+ * the order components that can be submitted to `createListing` with a signature.
17361
+ */
17362
+ async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
17363
+ const erc721 = new ERC721Factory(sell.contractAddress, this.orderbookConfig.provider).create();
17364
+ const royaltyInfo = await erc721.royaltyInfo(sell.tokenId, buy.amount);
17365
+ return this.seaport.prepareSeaportOrder(makerAddress, sell, buy, royaltyInfo,
17366
+ // Default order start to now
17367
+ new Date(),
17368
+ // Default order expiry to 2 years from now
17369
+ orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
17370
+ }
17371
+ /**
17372
+ * Create an order
17373
+ * @param {CreateListingParams} createListingParams - create an order with the given params.
17374
+ * @return {ListingResult} The result of the order created in the Immutable services.
17375
+ */
17376
+ createListing(createListingParams) {
17377
+ return this.apiClient.createListing(createListingParams);
17378
+ }
17379
+ /**
17380
+ * Get unsigned transactions that can be submitted to fulfil an open order. If the approval
17381
+ * transaction exists it must be signed and submitted to the chain before the fulfilment
17382
+ * transaction can be submitted or it will be reverted.
17383
+ * @param {string} listingId - The listingId to fulfil.
17384
+ * @param {string} fulfillerAddress - The address of the account fulfilling the order.
17385
+ * @return {FulfillOrderResponse} Approval and fulfilment transactions.
17386
+ */
17387
+ async fulfillOrder(listingId, takerAddress) {
17388
+ const orderResult = await this.apiClient.getListing(listingId);
17389
+ if (orderResult.result.status !== OrderStatus.ACTIVE) {
17390
+ throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
17391
+ }
17392
+ return this.seaport.fulfillOrder(orderResult.result, takerAddress);
17393
+ }
17394
+ /**
17395
+ * Get an unsigned cancel order transaction. Orders can only be cancelled by
17396
+ * the account that created them.
17397
+ * @param {string} listingId - The listingId to cancel.
17398
+ * @param {string} accountAddress - The address of the account cancelling the order.
17399
+ * @return {CancelOrderResponse} The unsigned cancel order transaction
17400
+ */
17401
+ async cancelOrder(listingId, accountAddress) {
17402
+ const orderResult = await this.apiClient.getListing(listingId);
17403
+ if (orderResult.result.status !== OrderStatus.ACTIVE
17404
+ && orderResult.result.status !== OrderStatus.INACTIVE
17405
+ && orderResult.result.status !== OrderStatus.PENDING) {
17406
+ throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
17407
+ }
17408
+ if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
17409
+ throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
17410
+ }
17411
+ const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
17412
+ return { unsignedCancelOrderTransaction: cancelOrderTransaction };
17413
+ }
17414
+ }
17415
+
17416
+ /* eslint-disable class-methods-use-this */
17417
+
17418
+ const $762782b6c862d954$export$db5daa1b5156ccfe = [
17419
+ {
17420
+ constant: true,
17421
+ inputs: [],
17422
+ name: "name",
17423
+ outputs: [
17424
+ {
17425
+ name: "",
17426
+ type: "string"
17427
+ }
17428
+ ],
17429
+ payable: false,
17430
+ type: "function"
17431
+ },
17432
+ {
17433
+ constant: true,
17434
+ inputs: [],
17435
+ name: "decimals",
17436
+ outputs: [
17437
+ {
17438
+ name: "",
17439
+ type: "uint8"
17440
+ }
17441
+ ],
17442
+ payable: false,
17443
+ type: "function"
17444
+ },
17445
+ {
17446
+ constant: true,
17447
+ inputs: [
17448
+ {
17449
+ name: "_owner",
17450
+ type: "address"
17451
+ }
17452
+ ],
17453
+ name: "balanceOf",
17454
+ outputs: [
17455
+ {
17456
+ name: "balance",
17457
+ type: "uint256"
17458
+ }
17459
+ ],
17460
+ payable: false,
17461
+ type: "function"
17462
+ },
17463
+ {
17464
+ constant: true,
17465
+ inputs: [],
17466
+ name: "symbol",
17467
+ outputs: [
17468
+ {
17469
+ name: "",
17470
+ type: "string"
17471
+ }
17472
+ ],
17473
+ payable: false,
17474
+ type: "function"
17475
+ }
17476
+ ];
17477
+
17478
+
17479
+ var $aa144554f9ef124b$export$1fc8f52ad1810e52;
17480
+ (function(ItemType) {
17481
+ ItemType["NATIVE"] = "NATIVE";
17482
+ ItemType["ERC20"] = "ERC20";
17483
+ ItemType["ERC721"] = "ERC721";
17484
+ })($aa144554f9ef124b$export$1fc8f52ad1810e52 || ($aa144554f9ef124b$export$1fc8f52ad1810e52 = {}));
17485
+ var $aa144554f9ef124b$export$537fa3efd10ed435;
17486
+ (function(GasTokenType) {
17487
+ GasTokenType["NATIVE"] = "NATIVE";
17488
+ GasTokenType["ERC20"] = "ERC20";
17489
+ })($aa144554f9ef124b$export$537fa3efd10ed435 || ($aa144554f9ef124b$export$537fa3efd10ed435 = {}));
17490
+
17491
+
17492
+ /**
17493
+ * Enum representing different chain IDs.
17494
+ * @enum {number}
17495
+ * @property {number} IMTBL_ZKEVM_MAINNET - The chain ID for IMTBL ZKEVM Mainnet.
17496
+ * @property {number} IMTBL_ZKEVM_TESTNET - The chain ID for IMTBL ZKEVM Testnet.
17497
+ * @property {number} IMTBL_ZKEVM_DEVNET - The chain ID for IMTBL ZKEVM Devnet.
17498
+ * @property {number} ETHEREUM - The chain ID for Ethereum.
17499
+ * @property {number} SEPOLIA - The chain ID for Sepolia.
17500
+ */ var $0472f23319457bfb$export$c06e1e7429de6283;
17501
+ (function(ChainId) {
17502
+ ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
17503
+ ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13472] = "IMTBL_ZKEVM_TESTNET";
17504
+ ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13433] = "IMTBL_ZKEVM_DEVNET";
17505
+ ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
17506
+ ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
17507
+ })($0472f23319457bfb$export$c06e1e7429de6283 || ($0472f23319457bfb$export$c06e1e7429de6283 = {}));
17508
+ var $0472f23319457bfb$export$b874c6b1dfe85e02;
17509
+ (function(ChainName) {
17510
+ ChainName["ETHEREUM"] = "Ethereum";
17511
+ ChainName["SEPOLIA"] = "Sepolia";
17512
+ ChainName["IMTBL_ZKEVM_TESTNET"] = "Immutable zkEVM Test";
17513
+ ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
17514
+ ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
17515
+ })($0472f23319457bfb$export$b874c6b1dfe85e02 || ($0472f23319457bfb$export$b874c6b1dfe85e02 = {}));
17516
+
17517
+
17518
+
17519
+
17520
+
17521
+
17522
+ var $de275b98d2b651c3$export$788b1fd17f3dad84;
17523
+ (function(GasEstimateType) {
17524
+ GasEstimateType["BRIDGE_TO_L2"] = "BRIDGE_TO_L2";
17525
+ GasEstimateType["SWAP"] = "SWAP";
17526
+ })($de275b98d2b651c3$export$788b1fd17f3dad84 || ($de275b98d2b651c3$export$788b1fd17f3dad84 = {}));
17527
+
17528
+
17529
+ var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
17530
+ (function(NetworkFilterTypes) {
17531
+ NetworkFilterTypes["ALL"] = "all";
15518
17532
  })($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
15519
17533
 
15520
17534
 
@@ -15557,6 +17571,7 @@ var $4f91c5f280efe242$export$a75605c67ea83a5a;
15557
17571
  var $e768639828688ca3$export$2d7a51a18d87e21d;
15558
17572
  (function(WalletProviderName) {
15559
17573
  WalletProviderName["METAMASK"] = "metamask";
17574
+ WalletProviderName["PASSPORT"] = "passport";
15560
17575
  })($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
15561
17576
  const $e768639828688ca3$export$44dde05038008549 = {
15562
17577
  allowMistmatchedChainId: false,
@@ -15572,10 +17587,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
15572
17587
  [(Environment$1).SANDBOX]: "https://checkout-api.sandbox.immutable.com",
15573
17588
  [(Environment$1).PRODUCTION]: "https://checkout-api.immutable.com"
15574
17589
  };
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
17590
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
15580
17591
  [
15581
17592
  ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
@@ -15705,6 +17716,8 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
15705
17716
  CheckoutErrorType["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
15706
17717
  CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
15707
17718
  CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
17719
+ CheckoutErrorType["UNSUPPORTED_TOKEN_TYPE_ERROR"] = "UNSUPPORTED_TOKEN_TYPE_ERROR";
17720
+ CheckoutErrorType["GET_ORDER_LISTING_ERROR"] = "GET_ORDER_LISTING_ERROR";
15708
17721
  })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
15709
17722
  class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
15710
17723
  message;
@@ -16151,6 +18164,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
16151
18164
 
16152
18165
 
16153
18166
 
18167
+
16154
18168
  async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
16155
18169
  const rootChainProvider = readOnlyProviders.get(fromChainId);
16156
18170
  const childChainProvider = readOnlyProviders.get(toChainId);
@@ -16179,6 +18193,13 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
16179
18193
  overrides: dexConfig?.overrides
16180
18194
  });
16181
18195
  }
18196
+ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
18197
+ return new (Orderbook)({
18198
+ baseConfig: {
18199
+ environment: config.environment
18200
+ }
18201
+ });
18202
+ }
16182
18203
 
16183
18204
 
16184
18205
 
@@ -16200,7 +18221,7 @@ class $a492ee374ae7b613$export$d902b56530cd5f87 {
16200
18221
  static async makeHttpRequest(url) {
16201
18222
  let response;
16202
18223
  try {
16203
- response = await (0, $7v2Z6$axios).get(url);
18224
+ response = await (0, axios).get(url);
16204
18225
  } catch (error) {
16205
18226
  throw new Error(`Error fetching from api: ${error.message}`);
16206
18227
  }
@@ -16245,23 +18266,10 @@ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
16245
18266
  this.message = message;
16246
18267
  }
16247
18268
  }
16248
- const $4013c5c91bb535f6$var$networkMap = (prod, dev, local)=>{
16249
- let networks;
16250
- if (dev) networks = ($d85ad1457a3f1a83$export$3a9ebede6a150274);
16251
- else if (prod) {
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;
18269
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
18270
+ if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
18271
+ if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
18272
+ return $d85ad1457a3f1a83$export$3e81fc0987227f10;
16265
18273
  };
16266
18274
  const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
16267
18275
  // DevMode and Sandbox will both use Sepolia.
@@ -16279,11 +18287,6 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
16279
18287
  // This will be used to get around the lack of
16280
18288
  // Environment.DEVELOPMENT
16281
18289
  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
18290
  isProduction;
16288
18291
  remote;
16289
18292
  environment;
@@ -16293,7 +18296,7 @@ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
16293
18296
  this.environment = config.baseConfig.environment;
16294
18297
  // Developer mode will super set any environment configuration
16295
18298
  this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
16296
- this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment, this.isLocal);
18299
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
16297
18300
  this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
16298
18301
  isDevelopment: this.isDevelopment,
16299
18302
  isProduction: this.isProduction
@@ -16403,6 +18406,84 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
16403
18406
 
16404
18407
 
16405
18408
 
18409
+ const $c147333b1f360629$export$92589613aaa38e1f = 300000;
18410
+ const $c147333b1f360629$export$dea9ce0e9bb2441c = "0x474989C4D25DD41B0B9b1ECb4643B9Fe25f83B19";
18411
+ const $c147333b1f360629$export$5baee63457fa7911 = (type, amount, contractAddress)=>{
18412
+ switch(type){
18413
+ case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20:
18414
+ case ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721:
18415
+ return {
18416
+ type: type,
18417
+ amount: amount,
18418
+ contractAddress: contractAddress,
18419
+ approvalContractAddress: $c147333b1f360629$export$dea9ce0e9bb2441c
18420
+ };
18421
+ case ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE:
18422
+ default:
18423
+ return {
18424
+ type: ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE,
18425
+ amount: amount
18426
+ };
18427
+ }
18428
+ };
18429
+ const $c147333b1f360629$export$7f8e2b98eca5a7f0 = async (config, provider, orderId)=>{
18430
+ let order;
18431
+ try {
18432
+ const orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
18433
+ order = await orderbook.getListing(orderId);
18434
+ } catch (err) {
18435
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while getting the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ORDER_LISTING_ERROR, {
18436
+ orderId: orderId,
18437
+ message: err.message
18438
+ });
18439
+ }
18440
+ let amount = (BigNumber$2).from("0");
18441
+ let type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
18442
+ let contractAddress = "";
18443
+ const buyArray = order.result.buy;
18444
+ if (buyArray.length > 0) switch(buyArray[0].item_type){
18445
+ case "NATIVE":
18446
+ type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).NATIVE;
18447
+ break;
18448
+ case "ERC20":
18449
+ type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC20;
18450
+ contractAddress = buyArray[0].contract_address;
18451
+ break;
18452
+ case "ERC721":
18453
+ type = ($aa144554f9ef124b$export$1fc8f52ad1810e52).ERC721;
18454
+ contractAddress = buyArray[0].contract_address;
18455
+ break;
18456
+ default:
18457
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Purchasing token type is unsupported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_TOKEN_TYPE_ERROR, {
18458
+ orderId: orderId
18459
+ });
18460
+ }
18461
+ buyArray.forEach((item)=>{
18462
+ amount = amount.add((BigNumber$2).from(item.start_amount));
18463
+ });
18464
+ const feeArray = order.result.fees;
18465
+ feeArray.forEach((item)=>{
18466
+ amount = amount.add((BigNumber$2).from(item.amount));
18467
+ });
18468
+ const requirements = [
18469
+ $c147333b1f360629$export$5baee63457fa7911(type, amount, contractAddress)
18470
+ ];
18471
+ return {
18472
+ requirements: requirements,
18473
+ gas: {
18474
+ type: ($aa144554f9ef124b$export$537fa3efd10ed435).NATIVE,
18475
+ limit: (BigNumber$2).from($c147333b1f360629$export$92589613aaa38e1f)
18476
+ }
18477
+ };
18478
+ };
18479
+
18480
+
18481
+
18482
+
18483
+
18484
+
18485
+
18486
+
16406
18487
  async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
16407
18488
  if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
16408
18489
  if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
@@ -16537,6 +18618,15 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
16537
18618
  return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, web3Provider);
16538
18619
  }
16539
18620
  /**
18621
+ * Determines the requirements for performing a buy.
18622
+ * @param {BuyParams} params - The parameters for the buy.
18623
+ */ async buy(params) {
18624
+ // eslint-disable-next-line no-console
18625
+ console.warn("This endpoint is currently under construction.");
18626
+ const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
18627
+ await $c147333b1f360629$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orderId);
18628
+ }
18629
+ /**
16540
18630
  * Checks if the given object is a Web3 provider.
16541
18631
  * @param {Web3Provider} web3Provider - The object to check.
16542
18632
  * @returns {boolean} - True if the object is a Web3 provider, false otherwise.