@imtbl/sdk 0.28.5-alpha.2 → 0.28.5-alpha.3
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/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -25
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +11 -1593
- package/dist/index.d.ts +28 -1450
- package/dist/index.js +13 -1594
- package/dist/passport.js +2 -2
- package/package.json +1 -5
- package/dist/orderbook.d.ts +0 -1600
- package/dist/orderbook.js +0 -1580
package/dist/index.js
CHANGED
|
@@ -5,15 +5,13 @@ import jwt_decode from 'jwt-decode';
|
|
|
5
5
|
import * as crypto from 'crypto';
|
|
6
6
|
import { Magic } from 'magic-sdk';
|
|
7
7
|
import { OpenIdExtension } from '@magic-ext/oidc';
|
|
8
|
-
import { BigNumber, ethers
|
|
8
|
+
import { BigNumber, ethers } from 'ethers';
|
|
9
9
|
import BN from 'bn.js';
|
|
10
10
|
import * as encUtils from 'enc-utils';
|
|
11
11
|
import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
|
|
12
12
|
import { EventEmitter } from 'events';
|
|
13
13
|
import { walletContracts } from '@0xsequence/abi';
|
|
14
14
|
import { encodeSignature, decodeSignature } from '@0xsequence/config';
|
|
15
|
-
import FormData$2 from 'form-data';
|
|
16
|
-
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
17
15
|
import { parseUnits } from '@ethersproject/units';
|
|
18
16
|
import { BigNumber as BigNumber$1 } from '@ethersproject/bignumber';
|
|
19
17
|
import detectEthereumProvider from '@metamask/detect-provider';
|
|
@@ -3311,7 +3309,7 @@ const NativeItemItemTypeEnum = {
|
|
|
3311
3309
|
* @export
|
|
3312
3310
|
* @enum {string}
|
|
3313
3311
|
*/
|
|
3314
|
-
const OrderStatusName
|
|
3312
|
+
const OrderStatusName = {
|
|
3315
3313
|
Pending: 'PENDING',
|
|
3316
3314
|
Active: 'ACTIVE',
|
|
3317
3315
|
Inactive: 'INACTIVE',
|
|
@@ -3452,7 +3450,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
3452
3450
|
NftsApiAxiosParamCreator: NftsApiAxiosParamCreator,
|
|
3453
3451
|
NftsApiFactory: NftsApiFactory,
|
|
3454
3452
|
NftsApiFp: NftsApiFp,
|
|
3455
|
-
OrderStatusName: OrderStatusName
|
|
3453
|
+
OrderStatusName: OrderStatusName,
|
|
3456
3454
|
OrdersApi: OrdersApi,
|
|
3457
3455
|
OrdersApiAxiosParamCreator: OrdersApiAxiosParamCreator,
|
|
3458
3456
|
OrdersApiFactory: OrdersApiFactory,
|
|
@@ -3621,7 +3619,7 @@ class MultiRollupApiClients {
|
|
|
3621
3619
|
}
|
|
3622
3620
|
|
|
3623
3621
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3624
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.5-alpha.
|
|
3622
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.28.5-alpha.3' };
|
|
3625
3623
|
const createConfig = ({ basePath, headers, }) => {
|
|
3626
3624
|
if (!basePath.trim()) {
|
|
3627
3625
|
throw Error('basePath can not be empty');
|
|
@@ -3681,7 +3679,7 @@ class APIError extends Error {
|
|
|
3681
3679
|
|
|
3682
3680
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3683
3681
|
const defaultHeaders = {
|
|
3684
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.5-alpha.
|
|
3682
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.5-alpha.3',
|
|
3685
3683
|
};
|
|
3686
3684
|
/**
|
|
3687
3685
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4092,7 +4090,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4092
4090
|
chainID,
|
|
4093
4091
|
coreContractAddress,
|
|
4094
4092
|
registrationContractAddress,
|
|
4095
|
-
sdkVersion: 'ts-immutable-sdk-0.28.5-alpha.
|
|
4093
|
+
sdkVersion: 'ts-immutable-sdk-0.28.5-alpha.3',
|
|
4096
4094
|
});
|
|
4097
4095
|
/**
|
|
4098
4096
|
* Sets `sdkVersion` at the time of build
|
|
@@ -4690,7 +4688,7 @@ function isArrayBufferView(val) {
|
|
|
4690
4688
|
*
|
|
4691
4689
|
* @returns {boolean} True if value is a String, otherwise false
|
|
4692
4690
|
*/
|
|
4693
|
-
const isString
|
|
4691
|
+
const isString = typeOfTest('string');
|
|
4694
4692
|
|
|
4695
4693
|
/**
|
|
4696
4694
|
* Determine if a value is a Function
|
|
@@ -4767,7 +4765,7 @@ const isFile = kindOfTest('File');
|
|
|
4767
4765
|
*
|
|
4768
4766
|
* @returns {boolean} True if value is a Blob, otherwise false
|
|
4769
4767
|
*/
|
|
4770
|
-
const isBlob
|
|
4768
|
+
const isBlob = kindOfTest('Blob');
|
|
4771
4769
|
|
|
4772
4770
|
/**
|
|
4773
4771
|
* Determine if a value is a FileList
|
|
@@ -4794,7 +4792,7 @@ const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
|
4794
4792
|
*
|
|
4795
4793
|
* @returns {boolean} True if value is an FormData, otherwise false
|
|
4796
4794
|
*/
|
|
4797
|
-
const isFormData
|
|
4795
|
+
const isFormData = (thing) => {
|
|
4798
4796
|
let kind;
|
|
4799
4797
|
return thing && (
|
|
4800
4798
|
(typeof FormData === 'function' && thing instanceof FormData) || (
|
|
@@ -5278,9 +5276,9 @@ var utils = {
|
|
|
5278
5276
|
isArray,
|
|
5279
5277
|
isArrayBuffer,
|
|
5280
5278
|
isBuffer,
|
|
5281
|
-
isFormData
|
|
5279
|
+
isFormData,
|
|
5282
5280
|
isArrayBufferView,
|
|
5283
|
-
isString
|
|
5281
|
+
isString,
|
|
5284
5282
|
isNumber,
|
|
5285
5283
|
isBoolean,
|
|
5286
5284
|
isObject,
|
|
@@ -5288,7 +5286,7 @@ var utils = {
|
|
|
5288
5286
|
isUndefined,
|
|
5289
5287
|
isDate,
|
|
5290
5288
|
isFile,
|
|
5291
|
-
isBlob
|
|
5289
|
+
isBlob,
|
|
5292
5290
|
isRegExp,
|
|
5293
5291
|
isFunction,
|
|
5294
5292
|
isStream,
|
|
@@ -10908,1585 +10906,6 @@ var passport = /*#__PURE__*/Object.freeze({
|
|
|
10908
10906
|
get RpcErrorCode () { return RpcErrorCode; }
|
|
10909
10907
|
});
|
|
10910
10908
|
|
|
10911
|
-
class BaseHttpRequest {
|
|
10912
|
-
config;
|
|
10913
|
-
constructor(config) {
|
|
10914
|
-
this.config = config;
|
|
10915
|
-
}
|
|
10916
|
-
}
|
|
10917
|
-
|
|
10918
|
-
class ApiError extends Error {
|
|
10919
|
-
url;
|
|
10920
|
-
status;
|
|
10921
|
-
statusText;
|
|
10922
|
-
body;
|
|
10923
|
-
request;
|
|
10924
|
-
constructor(request, response, message) {
|
|
10925
|
-
super(message);
|
|
10926
|
-
this.name = 'ApiError';
|
|
10927
|
-
this.url = response.url;
|
|
10928
|
-
this.status = response.status;
|
|
10929
|
-
this.statusText = response.statusText;
|
|
10930
|
-
this.body = response.body;
|
|
10931
|
-
this.request = request;
|
|
10932
|
-
}
|
|
10933
|
-
}
|
|
10934
|
-
|
|
10935
|
-
/* istanbul ignore file */
|
|
10936
|
-
/* tslint:disable */
|
|
10937
|
-
/* eslint-disable */
|
|
10938
|
-
class CancelError extends Error {
|
|
10939
|
-
constructor(message) {
|
|
10940
|
-
super(message);
|
|
10941
|
-
this.name = 'CancelError';
|
|
10942
|
-
}
|
|
10943
|
-
get isCancelled() {
|
|
10944
|
-
return true;
|
|
10945
|
-
}
|
|
10946
|
-
}
|
|
10947
|
-
class CancelablePromise {
|
|
10948
|
-
[Symbol.toStringTag];
|
|
10949
|
-
_isResolved;
|
|
10950
|
-
_isRejected;
|
|
10951
|
-
_isCancelled;
|
|
10952
|
-
_cancelHandlers;
|
|
10953
|
-
_promise;
|
|
10954
|
-
_resolve;
|
|
10955
|
-
_reject;
|
|
10956
|
-
constructor(executor) {
|
|
10957
|
-
this._isResolved = false;
|
|
10958
|
-
this._isRejected = false;
|
|
10959
|
-
this._isCancelled = false;
|
|
10960
|
-
this._cancelHandlers = [];
|
|
10961
|
-
this._promise = new Promise((resolve, reject) => {
|
|
10962
|
-
this._resolve = resolve;
|
|
10963
|
-
this._reject = reject;
|
|
10964
|
-
const onResolve = (value) => {
|
|
10965
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
10966
|
-
return;
|
|
10967
|
-
}
|
|
10968
|
-
this._isResolved = true;
|
|
10969
|
-
this._resolve?.(value);
|
|
10970
|
-
};
|
|
10971
|
-
const onReject = (reason) => {
|
|
10972
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
10973
|
-
return;
|
|
10974
|
-
}
|
|
10975
|
-
this._isRejected = true;
|
|
10976
|
-
this._reject?.(reason);
|
|
10977
|
-
};
|
|
10978
|
-
const onCancel = (cancelHandler) => {
|
|
10979
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
10980
|
-
return;
|
|
10981
|
-
}
|
|
10982
|
-
this._cancelHandlers.push(cancelHandler);
|
|
10983
|
-
};
|
|
10984
|
-
Object.defineProperty(onCancel, 'isResolved', {
|
|
10985
|
-
get: () => this._isResolved,
|
|
10986
|
-
});
|
|
10987
|
-
Object.defineProperty(onCancel, 'isRejected', {
|
|
10988
|
-
get: () => this._isRejected,
|
|
10989
|
-
});
|
|
10990
|
-
Object.defineProperty(onCancel, 'isCancelled', {
|
|
10991
|
-
get: () => this._isCancelled,
|
|
10992
|
-
});
|
|
10993
|
-
return executor(onResolve, onReject, onCancel);
|
|
10994
|
-
});
|
|
10995
|
-
}
|
|
10996
|
-
then(onFulfilled, onRejected) {
|
|
10997
|
-
return this._promise.then(onFulfilled, onRejected);
|
|
10998
|
-
}
|
|
10999
|
-
catch(onRejected) {
|
|
11000
|
-
return this._promise.catch(onRejected);
|
|
11001
|
-
}
|
|
11002
|
-
finally(onFinally) {
|
|
11003
|
-
return this._promise.finally(onFinally);
|
|
11004
|
-
}
|
|
11005
|
-
cancel() {
|
|
11006
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
11007
|
-
return;
|
|
11008
|
-
}
|
|
11009
|
-
this._isCancelled = true;
|
|
11010
|
-
if (this._cancelHandlers.length) {
|
|
11011
|
-
try {
|
|
11012
|
-
for (const cancelHandler of this._cancelHandlers) {
|
|
11013
|
-
cancelHandler();
|
|
11014
|
-
}
|
|
11015
|
-
}
|
|
11016
|
-
catch (error) {
|
|
11017
|
-
console.warn('Cancellation threw an error', error);
|
|
11018
|
-
return;
|
|
11019
|
-
}
|
|
11020
|
-
}
|
|
11021
|
-
this._cancelHandlers.length = 0;
|
|
11022
|
-
this._reject?.(new CancelError('Request aborted'));
|
|
11023
|
-
}
|
|
11024
|
-
get isCancelled() {
|
|
11025
|
-
return this._isCancelled;
|
|
11026
|
-
}
|
|
11027
|
-
}
|
|
11028
|
-
|
|
11029
|
-
/* istanbul ignore file */
|
|
11030
|
-
/* tslint:disable */
|
|
11031
|
-
/* eslint-disable */
|
|
11032
|
-
const isDefined = (value) => {
|
|
11033
|
-
return value !== undefined && value !== null;
|
|
11034
|
-
};
|
|
11035
|
-
const isString = (value) => {
|
|
11036
|
-
return typeof value === 'string';
|
|
11037
|
-
};
|
|
11038
|
-
const isStringWithValue = (value) => {
|
|
11039
|
-
return isString(value) && value !== '';
|
|
11040
|
-
};
|
|
11041
|
-
const isBlob = (value) => {
|
|
11042
|
-
return (typeof value === 'object' &&
|
|
11043
|
-
typeof value.type === 'string' &&
|
|
11044
|
-
typeof value.stream === 'function' &&
|
|
11045
|
-
typeof value.arrayBuffer === 'function' &&
|
|
11046
|
-
typeof value.constructor === 'function' &&
|
|
11047
|
-
typeof value.constructor.name === 'string' &&
|
|
11048
|
-
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
11049
|
-
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
11050
|
-
};
|
|
11051
|
-
const isFormData = (value) => {
|
|
11052
|
-
return value instanceof FormData$2;
|
|
11053
|
-
};
|
|
11054
|
-
const isSuccess = (status) => {
|
|
11055
|
-
return status >= 200 && status < 300;
|
|
11056
|
-
};
|
|
11057
|
-
const base64 = (str) => {
|
|
11058
|
-
try {
|
|
11059
|
-
return btoa(str);
|
|
11060
|
-
}
|
|
11061
|
-
catch (err) {
|
|
11062
|
-
// @ts-ignore
|
|
11063
|
-
return Buffer.from(str).toString('base64');
|
|
11064
|
-
}
|
|
11065
|
-
};
|
|
11066
|
-
const getQueryString = (params) => {
|
|
11067
|
-
const qs = [];
|
|
11068
|
-
const append = (key, value) => {
|
|
11069
|
-
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
11070
|
-
};
|
|
11071
|
-
const process = (key, value) => {
|
|
11072
|
-
if (isDefined(value)) {
|
|
11073
|
-
if (Array.isArray(value)) {
|
|
11074
|
-
value.forEach(v => {
|
|
11075
|
-
process(key, v);
|
|
11076
|
-
});
|
|
11077
|
-
}
|
|
11078
|
-
else if (typeof value === 'object') {
|
|
11079
|
-
Object.entries(value).forEach(([k, v]) => {
|
|
11080
|
-
process(`${key}[${k}]`, v);
|
|
11081
|
-
});
|
|
11082
|
-
}
|
|
11083
|
-
else {
|
|
11084
|
-
append(key, value);
|
|
11085
|
-
}
|
|
11086
|
-
}
|
|
11087
|
-
};
|
|
11088
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
11089
|
-
process(key, value);
|
|
11090
|
-
});
|
|
11091
|
-
if (qs.length > 0) {
|
|
11092
|
-
return `?${qs.join('&')}`;
|
|
11093
|
-
}
|
|
11094
|
-
return '';
|
|
11095
|
-
};
|
|
11096
|
-
const getUrl = (config, options) => {
|
|
11097
|
-
const encoder = config.ENCODE_PATH || encodeURI;
|
|
11098
|
-
const path = options.url
|
|
11099
|
-
.replace('{api-version}', config.VERSION)
|
|
11100
|
-
.replace(/{(.*?)}/g, (substring, group) => {
|
|
11101
|
-
if (options.path?.hasOwnProperty(group)) {
|
|
11102
|
-
return encoder(String(options.path[group]));
|
|
11103
|
-
}
|
|
11104
|
-
return substring;
|
|
11105
|
-
});
|
|
11106
|
-
const url = `${config.BASE}${path}`;
|
|
11107
|
-
if (options.query) {
|
|
11108
|
-
return `${url}${getQueryString(options.query)}`;
|
|
11109
|
-
}
|
|
11110
|
-
return url;
|
|
11111
|
-
};
|
|
11112
|
-
const getFormData = (options) => {
|
|
11113
|
-
if (options.formData) {
|
|
11114
|
-
const formData = new FormData$2();
|
|
11115
|
-
const process = (key, value) => {
|
|
11116
|
-
if (isString(value) || isBlob(value)) {
|
|
11117
|
-
formData.append(key, value);
|
|
11118
|
-
}
|
|
11119
|
-
else {
|
|
11120
|
-
formData.append(key, JSON.stringify(value));
|
|
11121
|
-
}
|
|
11122
|
-
};
|
|
11123
|
-
Object.entries(options.formData)
|
|
11124
|
-
.filter(([_, value]) => isDefined(value))
|
|
11125
|
-
.forEach(([key, value]) => {
|
|
11126
|
-
if (Array.isArray(value)) {
|
|
11127
|
-
value.forEach(v => process(key, v));
|
|
11128
|
-
}
|
|
11129
|
-
else {
|
|
11130
|
-
process(key, value);
|
|
11131
|
-
}
|
|
11132
|
-
});
|
|
11133
|
-
return formData;
|
|
11134
|
-
}
|
|
11135
|
-
return undefined;
|
|
11136
|
-
};
|
|
11137
|
-
const resolve = async (options, resolver) => {
|
|
11138
|
-
if (typeof resolver === 'function') {
|
|
11139
|
-
return resolver(options);
|
|
11140
|
-
}
|
|
11141
|
-
return resolver;
|
|
11142
|
-
};
|
|
11143
|
-
const getHeaders = async (config, options, formData) => {
|
|
11144
|
-
const token = await resolve(options, config.TOKEN);
|
|
11145
|
-
const username = await resolve(options, config.USERNAME);
|
|
11146
|
-
const password = await resolve(options, config.PASSWORD);
|
|
11147
|
-
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
11148
|
-
const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {};
|
|
11149
|
-
const headers = Object.entries({
|
|
11150
|
-
Accept: 'application/json',
|
|
11151
|
-
...additionalHeaders,
|
|
11152
|
-
...options.headers,
|
|
11153
|
-
...formHeaders,
|
|
11154
|
-
})
|
|
11155
|
-
.filter(([_, value]) => isDefined(value))
|
|
11156
|
-
.reduce((headers, [key, value]) => ({
|
|
11157
|
-
...headers,
|
|
11158
|
-
[key]: String(value),
|
|
11159
|
-
}), {});
|
|
11160
|
-
if (isStringWithValue(token)) {
|
|
11161
|
-
headers['Authorization'] = `Bearer ${token}`;
|
|
11162
|
-
}
|
|
11163
|
-
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
11164
|
-
const credentials = base64(`${username}:${password}`);
|
|
11165
|
-
headers['Authorization'] = `Basic ${credentials}`;
|
|
11166
|
-
}
|
|
11167
|
-
if (options.body) {
|
|
11168
|
-
if (options.mediaType) {
|
|
11169
|
-
headers['Content-Type'] = options.mediaType;
|
|
11170
|
-
}
|
|
11171
|
-
else if (isBlob(options.body)) {
|
|
11172
|
-
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
11173
|
-
}
|
|
11174
|
-
else if (isString(options.body)) {
|
|
11175
|
-
headers['Content-Type'] = 'text/plain';
|
|
11176
|
-
}
|
|
11177
|
-
else if (!isFormData(options.body)) {
|
|
11178
|
-
headers['Content-Type'] = 'application/json';
|
|
11179
|
-
}
|
|
11180
|
-
}
|
|
11181
|
-
return headers;
|
|
11182
|
-
};
|
|
11183
|
-
const getRequestBody = (options) => {
|
|
11184
|
-
if (options.body) {
|
|
11185
|
-
return options.body;
|
|
11186
|
-
}
|
|
11187
|
-
return undefined;
|
|
11188
|
-
};
|
|
11189
|
-
const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
|
|
11190
|
-
const source = globalAxios$1.CancelToken.source();
|
|
11191
|
-
const requestConfig = {
|
|
11192
|
-
url,
|
|
11193
|
-
headers,
|
|
11194
|
-
data: body ?? formData,
|
|
11195
|
-
method: options.method,
|
|
11196
|
-
withCredentials: config.WITH_CREDENTIALS,
|
|
11197
|
-
cancelToken: source.token,
|
|
11198
|
-
};
|
|
11199
|
-
onCancel(() => source.cancel('The user aborted a request.'));
|
|
11200
|
-
try {
|
|
11201
|
-
return await globalAxios$1.request(requestConfig);
|
|
11202
|
-
}
|
|
11203
|
-
catch (error) {
|
|
11204
|
-
const axiosError = error;
|
|
11205
|
-
if (axiosError.response) {
|
|
11206
|
-
return axiosError.response;
|
|
11207
|
-
}
|
|
11208
|
-
throw error;
|
|
11209
|
-
}
|
|
11210
|
-
};
|
|
11211
|
-
const getResponseHeader = (response, responseHeader) => {
|
|
11212
|
-
if (responseHeader) {
|
|
11213
|
-
const content = response.headers[responseHeader];
|
|
11214
|
-
if (isString(content)) {
|
|
11215
|
-
return content;
|
|
11216
|
-
}
|
|
11217
|
-
}
|
|
11218
|
-
return undefined;
|
|
11219
|
-
};
|
|
11220
|
-
const getResponseBody = (response) => {
|
|
11221
|
-
if (response.status !== 204) {
|
|
11222
|
-
return response.data;
|
|
11223
|
-
}
|
|
11224
|
-
return undefined;
|
|
11225
|
-
};
|
|
11226
|
-
const catchErrorCodes = (options, result) => {
|
|
11227
|
-
const errors = {
|
|
11228
|
-
400: 'Bad Request',
|
|
11229
|
-
401: 'Unauthorized',
|
|
11230
|
-
403: 'Forbidden',
|
|
11231
|
-
404: 'Not Found',
|
|
11232
|
-
500: 'Internal Server Error',
|
|
11233
|
-
502: 'Bad Gateway',
|
|
11234
|
-
503: 'Service Unavailable',
|
|
11235
|
-
...options.errors,
|
|
11236
|
-
};
|
|
11237
|
-
const error = errors[result.status];
|
|
11238
|
-
if (error) {
|
|
11239
|
-
throw new ApiError(options, result, error);
|
|
11240
|
-
}
|
|
11241
|
-
if (!result.ok) {
|
|
11242
|
-
throw new ApiError(options, result, 'Generic Error');
|
|
11243
|
-
}
|
|
11244
|
-
};
|
|
11245
|
-
/**
|
|
11246
|
-
* Request method
|
|
11247
|
-
* @param config The OpenAPI configuration object
|
|
11248
|
-
* @param options The request options from the service
|
|
11249
|
-
* @returns CancelablePromise<T>
|
|
11250
|
-
* @throws ApiError
|
|
11251
|
-
*/
|
|
11252
|
-
const request = (config, options) => {
|
|
11253
|
-
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
11254
|
-
try {
|
|
11255
|
-
const url = getUrl(config, options);
|
|
11256
|
-
const formData = getFormData(options);
|
|
11257
|
-
const body = getRequestBody(options);
|
|
11258
|
-
const headers = await getHeaders(config, options, formData);
|
|
11259
|
-
if (!onCancel.isCancelled) {
|
|
11260
|
-
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
11261
|
-
const responseBody = getResponseBody(response);
|
|
11262
|
-
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
11263
|
-
const result = {
|
|
11264
|
-
url,
|
|
11265
|
-
ok: isSuccess(response.status),
|
|
11266
|
-
status: response.status,
|
|
11267
|
-
statusText: response.statusText,
|
|
11268
|
-
body: responseHeader ?? responseBody,
|
|
11269
|
-
};
|
|
11270
|
-
catchErrorCodes(options, result);
|
|
11271
|
-
resolve(result.body);
|
|
11272
|
-
}
|
|
11273
|
-
}
|
|
11274
|
-
catch (error) {
|
|
11275
|
-
reject(error);
|
|
11276
|
-
}
|
|
11277
|
-
});
|
|
11278
|
-
};
|
|
11279
|
-
|
|
11280
|
-
class AxiosHttpRequest extends BaseHttpRequest {
|
|
11281
|
-
constructor(config) {
|
|
11282
|
-
super(config);
|
|
11283
|
-
}
|
|
11284
|
-
/**
|
|
11285
|
-
* Request method
|
|
11286
|
-
* @param options The request options from the service
|
|
11287
|
-
* @returns CancelablePromise<T>
|
|
11288
|
-
* @throws ApiError
|
|
11289
|
-
*/
|
|
11290
|
-
request(options) {
|
|
11291
|
-
return request(this.config, options);
|
|
11292
|
-
}
|
|
11293
|
-
}
|
|
11294
|
-
|
|
11295
|
-
class OrdersService {
|
|
11296
|
-
httpRequest;
|
|
11297
|
-
constructor(httpRequest) {
|
|
11298
|
-
this.httpRequest = httpRequest;
|
|
11299
|
-
}
|
|
11300
|
-
/**
|
|
11301
|
-
* Cancel one or more orders
|
|
11302
|
-
* Cancel one or more orders
|
|
11303
|
-
* @returns CancelOrdersResult Orders cancellation response.
|
|
11304
|
-
* @throws ApiError
|
|
11305
|
-
*/
|
|
11306
|
-
cancelOrders({ chainName, requestBody, }) {
|
|
11307
|
-
return this.httpRequest.request({
|
|
11308
|
-
method: 'POST',
|
|
11309
|
-
url: '/v1/chains/{chain_name}/orders/cancel',
|
|
11310
|
-
path: {
|
|
11311
|
-
'chain_name': chainName,
|
|
11312
|
-
},
|
|
11313
|
-
body: requestBody,
|
|
11314
|
-
mediaType: 'application/json',
|
|
11315
|
-
errors: {
|
|
11316
|
-
400: `Bad Request (400)`,
|
|
11317
|
-
401: `Unauthorised Request (401)`,
|
|
11318
|
-
404: `The specified resource was not found (404)`,
|
|
11319
|
-
429: `Too Many Requests (429)`,
|
|
11320
|
-
500: `Internal Server Error (500)`,
|
|
11321
|
-
501: `Not Implemented Error (501)`,
|
|
11322
|
-
},
|
|
11323
|
-
});
|
|
11324
|
-
}
|
|
11325
|
-
/**
|
|
11326
|
-
* List all listings
|
|
11327
|
-
* List all listings
|
|
11328
|
-
* @returns ListListingsResult OK response.
|
|
11329
|
-
* @throws ApiError
|
|
11330
|
-
*/
|
|
11331
|
-
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11332
|
-
return this.httpRequest.request({
|
|
11333
|
-
method: 'GET',
|
|
11334
|
-
url: '/v1/chains/{chain_name}/orders/listings',
|
|
11335
|
-
path: {
|
|
11336
|
-
'chain_name': chainName,
|
|
11337
|
-
},
|
|
11338
|
-
query: {
|
|
11339
|
-
'status': status,
|
|
11340
|
-
'sell_item_contract_address': sellItemContractAddress,
|
|
11341
|
-
'buy_item_contract_address': buyItemContractAddress,
|
|
11342
|
-
'sell_item_token_id': sellItemTokenId,
|
|
11343
|
-
'from_updated_at': fromUpdatedAt,
|
|
11344
|
-
'page_size': pageSize,
|
|
11345
|
-
'sort_by': sortBy,
|
|
11346
|
-
'sort_direction': sortDirection,
|
|
11347
|
-
'page_cursor': pageCursor,
|
|
11348
|
-
},
|
|
11349
|
-
errors: {
|
|
11350
|
-
400: `Bad Request (400)`,
|
|
11351
|
-
404: `The specified resource was not found (404)`,
|
|
11352
|
-
500: `Internal Server Error (500)`,
|
|
11353
|
-
},
|
|
11354
|
-
});
|
|
11355
|
-
}
|
|
11356
|
-
/**
|
|
11357
|
-
* Create a listing
|
|
11358
|
-
* Create a listing
|
|
11359
|
-
* @returns ListingResult Created response.
|
|
11360
|
-
* @throws ApiError
|
|
11361
|
-
*/
|
|
11362
|
-
createListing({ chainName, requestBody, }) {
|
|
11363
|
-
return this.httpRequest.request({
|
|
11364
|
-
method: 'POST',
|
|
11365
|
-
url: '/v1/chains/{chain_name}/orders/listings',
|
|
11366
|
-
path: {
|
|
11367
|
-
'chain_name': chainName,
|
|
11368
|
-
},
|
|
11369
|
-
body: requestBody,
|
|
11370
|
-
mediaType: 'application/json',
|
|
11371
|
-
errors: {
|
|
11372
|
-
400: `Bad Request (400)`,
|
|
11373
|
-
404: `The specified resource was not found (404)`,
|
|
11374
|
-
500: `Internal Server Error (500)`,
|
|
11375
|
-
},
|
|
11376
|
-
});
|
|
11377
|
-
}
|
|
11378
|
-
/**
|
|
11379
|
-
* Get a single listing by ID
|
|
11380
|
-
* Get a single listing by ID
|
|
11381
|
-
* @returns ListingResult OK response.
|
|
11382
|
-
* @throws ApiError
|
|
11383
|
-
*/
|
|
11384
|
-
getListing({ chainName, listingId, }) {
|
|
11385
|
-
return this.httpRequest.request({
|
|
11386
|
-
method: 'GET',
|
|
11387
|
-
url: '/v1/chains/{chain_name}/orders/listings/{listing_id}',
|
|
11388
|
-
path: {
|
|
11389
|
-
'chain_name': chainName,
|
|
11390
|
-
'listing_id': listingId,
|
|
11391
|
-
},
|
|
11392
|
-
errors: {
|
|
11393
|
-
400: `Bad Request (400)`,
|
|
11394
|
-
404: `The specified resource was not found (404)`,
|
|
11395
|
-
500: `Internal Server Error (500)`,
|
|
11396
|
-
},
|
|
11397
|
-
});
|
|
11398
|
-
}
|
|
11399
|
-
/**
|
|
11400
|
-
* Retrieve fulfillment data for orders
|
|
11401
|
-
* Retrieve signed fulfillment data based on the list of order IDs and corresponding fees.
|
|
11402
|
-
* @returns any Successful response
|
|
11403
|
-
* @throws ApiError
|
|
11404
|
-
*/
|
|
11405
|
-
fulfillmentData({ chainName, requestBody, }) {
|
|
11406
|
-
return this.httpRequest.request({
|
|
11407
|
-
method: 'POST',
|
|
11408
|
-
url: '/v1/chains/{chain_name}/orders/fulfillment-data',
|
|
11409
|
-
path: {
|
|
11410
|
-
'chain_name': chainName,
|
|
11411
|
-
},
|
|
11412
|
-
body: requestBody,
|
|
11413
|
-
mediaType: 'application/json',
|
|
11414
|
-
errors: {
|
|
11415
|
-
400: `Bad Request (400)`,
|
|
11416
|
-
404: `The specified resource was not found (404)`,
|
|
11417
|
-
500: `Internal Server Error (500)`,
|
|
11418
|
-
},
|
|
11419
|
-
});
|
|
11420
|
-
}
|
|
11421
|
-
/**
|
|
11422
|
-
* List all trades
|
|
11423
|
-
* List all trades
|
|
11424
|
-
* @returns ListTradeResult OK response.
|
|
11425
|
-
* @throws ApiError
|
|
11426
|
-
*/
|
|
11427
|
-
listTrades({ chainName, accountAddress, fromIndexedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11428
|
-
return this.httpRequest.request({
|
|
11429
|
-
method: 'GET',
|
|
11430
|
-
url: '/v1/chains/{chain_name}/trades',
|
|
11431
|
-
path: {
|
|
11432
|
-
'chain_name': chainName,
|
|
11433
|
-
},
|
|
11434
|
-
query: {
|
|
11435
|
-
'account_address': accountAddress,
|
|
11436
|
-
'from_indexed_at': fromIndexedAt,
|
|
11437
|
-
'page_size': pageSize,
|
|
11438
|
-
'sort_by': sortBy,
|
|
11439
|
-
'sort_direction': sortDirection,
|
|
11440
|
-
'page_cursor': pageCursor,
|
|
11441
|
-
},
|
|
11442
|
-
errors: {
|
|
11443
|
-
400: `Bad Request (400)`,
|
|
11444
|
-
404: `The specified resource was not found (404)`,
|
|
11445
|
-
500: `Internal Server Error (500)`,
|
|
11446
|
-
},
|
|
11447
|
-
});
|
|
11448
|
-
}
|
|
11449
|
-
/**
|
|
11450
|
-
* Get a single trade by ID
|
|
11451
|
-
* Get a single trade by ID
|
|
11452
|
-
* @returns TradeResult OK response.
|
|
11453
|
-
* @throws ApiError
|
|
11454
|
-
*/
|
|
11455
|
-
getTrade({ chainName, tradeId, }) {
|
|
11456
|
-
return this.httpRequest.request({
|
|
11457
|
-
method: 'GET',
|
|
11458
|
-
url: '/v1/chains/{chain_name}/trades/{trade_id}',
|
|
11459
|
-
path: {
|
|
11460
|
-
'chain_name': chainName,
|
|
11461
|
-
'trade_id': tradeId,
|
|
11462
|
-
},
|
|
11463
|
-
errors: {
|
|
11464
|
-
400: `Bad Request (400)`,
|
|
11465
|
-
404: `The specified resource was not found (404)`,
|
|
11466
|
-
500: `Internal Server Error (500)`,
|
|
11467
|
-
},
|
|
11468
|
-
});
|
|
11469
|
-
}
|
|
11470
|
-
}
|
|
11471
|
-
|
|
11472
|
-
class OrderBookClient {
|
|
11473
|
-
orders;
|
|
11474
|
-
request;
|
|
11475
|
-
constructor(config, HttpRequest = AxiosHttpRequest) {
|
|
11476
|
-
this.request = new HttpRequest({
|
|
11477
|
-
BASE: config?.BASE ?? 'https://api.sandbox.immutable.com',
|
|
11478
|
-
VERSION: config?.VERSION ?? '1.0.0',
|
|
11479
|
-
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
11480
|
-
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
11481
|
-
TOKEN: config?.TOKEN,
|
|
11482
|
-
USERNAME: config?.USERNAME,
|
|
11483
|
-
PASSWORD: config?.PASSWORD,
|
|
11484
|
-
HEADERS: config?.HEADERS,
|
|
11485
|
-
ENCODE_PATH: config?.ENCODE_PATH,
|
|
11486
|
-
});
|
|
11487
|
-
this.orders = new OrdersService(this.request);
|
|
11488
|
-
}
|
|
11489
|
-
}
|
|
11490
|
-
|
|
11491
|
-
/* istanbul ignore file */
|
|
11492
|
-
/* tslint:disable */
|
|
11493
|
-
/* eslint-disable */
|
|
11494
|
-
var CancelledOrderStatus;
|
|
11495
|
-
(function (CancelledOrderStatus) {
|
|
11496
|
-
(function (cancellation_type) {
|
|
11497
|
-
cancellation_type["ON_CHAIN"] = "ON_CHAIN";
|
|
11498
|
-
cancellation_type["OFF_CHAIN"] = "OFF_CHAIN";
|
|
11499
|
-
})(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
|
|
11500
|
-
})(CancelledOrderStatus || (CancelledOrderStatus = {}));
|
|
11501
|
-
|
|
11502
|
-
/* istanbul ignore file */
|
|
11503
|
-
/* tslint:disable */
|
|
11504
|
-
/* eslint-disable */
|
|
11505
|
-
var FailedOrderCancellation;
|
|
11506
|
-
(function (FailedOrderCancellation) {
|
|
11507
|
-
(function (reason_code) {
|
|
11508
|
-
reason_code["FILLED"] = "FILLED";
|
|
11509
|
-
})(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
|
|
11510
|
-
})(FailedOrderCancellation || (FailedOrderCancellation = {}));
|
|
11511
|
-
|
|
11512
|
-
/* istanbul ignore file */
|
|
11513
|
-
/* tslint:disable */
|
|
11514
|
-
/* eslint-disable */
|
|
11515
|
-
var Fee;
|
|
11516
|
-
(function (Fee) {
|
|
11517
|
-
(function (fee_type) {
|
|
11518
|
-
fee_type["ROYALTY"] = "ROYALTY";
|
|
11519
|
-
fee_type["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
|
|
11520
|
-
fee_type["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
|
|
11521
|
-
fee_type["PROTOCOL"] = "PROTOCOL";
|
|
11522
|
-
})(Fee.fee_type || (Fee.fee_type = {}));
|
|
11523
|
-
})(Fee || (Fee = {}));
|
|
11524
|
-
|
|
11525
|
-
/* istanbul ignore file */
|
|
11526
|
-
/* tslint:disable */
|
|
11527
|
-
/* eslint-disable */
|
|
11528
|
-
/**
|
|
11529
|
-
* The Order status
|
|
11530
|
-
*/
|
|
11531
|
-
var OrderStatusName;
|
|
11532
|
-
(function (OrderStatusName) {
|
|
11533
|
-
OrderStatusName["PENDING"] = "PENDING";
|
|
11534
|
-
OrderStatusName["ACTIVE"] = "ACTIVE";
|
|
11535
|
-
OrderStatusName["INACTIVE"] = "INACTIVE";
|
|
11536
|
-
OrderStatusName["FILLED"] = "FILLED";
|
|
11537
|
-
OrderStatusName["EXPIRED"] = "EXPIRED";
|
|
11538
|
-
OrderStatusName["CANCELLED"] = "CANCELLED";
|
|
11539
|
-
})(OrderStatusName || (OrderStatusName = {}));
|
|
11540
|
-
|
|
11541
|
-
/* istanbul ignore file */
|
|
11542
|
-
/* tslint:disable */
|
|
11543
|
-
/* eslint-disable */
|
|
11544
|
-
var ProtocolData;
|
|
11545
|
-
(function (ProtocolData) {
|
|
11546
|
-
(function (order_type) {
|
|
11547
|
-
order_type["FULL_RESTRICTED"] = "FULL_RESTRICTED";
|
|
11548
|
-
})(ProtocolData.order_type || (ProtocolData.order_type = {}));
|
|
11549
|
-
})(ProtocolData || (ProtocolData = {}));
|
|
11550
|
-
|
|
11551
|
-
var FeeType;
|
|
11552
|
-
(function (FeeType) {
|
|
11553
|
-
FeeType["MAKER_ECOSYSTEM"] = "MAKER_ECOSYSTEM";
|
|
11554
|
-
FeeType["TAKER_ECOSYSTEM"] = "TAKER_ECOSYSTEM";
|
|
11555
|
-
FeeType["PROTOCOL"] = "PROTOCOL";
|
|
11556
|
-
FeeType["ROYALTY"] = "ROYALTY";
|
|
11557
|
-
})(FeeType || (FeeType = {}));
|
|
11558
|
-
var TransactionPurpose;
|
|
11559
|
-
(function (TransactionPurpose) {
|
|
11560
|
-
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
11561
|
-
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
11562
|
-
TransactionPurpose["CANCEL"] = "CANCEL";
|
|
11563
|
-
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
11564
|
-
var SignablePurpose;
|
|
11565
|
-
(function (SignablePurpose) {
|
|
11566
|
-
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
11567
|
-
SignablePurpose["OFF_CHAIN_CANCELLATION"] = "OFF_CHAIN_CANCELLATION";
|
|
11568
|
-
})(SignablePurpose || (SignablePurpose = {}));
|
|
11569
|
-
var ActionType;
|
|
11570
|
-
(function (ActionType) {
|
|
11571
|
-
ActionType["TRANSACTION"] = "TRANSACTION";
|
|
11572
|
-
ActionType["SIGNABLE"] = "SIGNABLE";
|
|
11573
|
-
})(ActionType || (ActionType = {}));
|
|
11574
|
-
|
|
11575
|
-
function mapFromOpenApiOrder(order) {
|
|
11576
|
-
const buyItems = order.buy.map((item) => {
|
|
11577
|
-
if (item.item_type === 'ERC20') {
|
|
11578
|
-
return {
|
|
11579
|
-
type: 'ERC20',
|
|
11580
|
-
contractAddress: item.contract_address,
|
|
11581
|
-
amount: item.start_amount,
|
|
11582
|
-
};
|
|
11583
|
-
}
|
|
11584
|
-
if (item.item_type === 'NATIVE') {
|
|
11585
|
-
return {
|
|
11586
|
-
type: 'NATIVE',
|
|
11587
|
-
amount: item.start_amount,
|
|
11588
|
-
};
|
|
11589
|
-
}
|
|
11590
|
-
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
11591
|
-
});
|
|
11592
|
-
const sellItems = order.sell.map((item) => {
|
|
11593
|
-
if (item.item_type === 'ERC721') {
|
|
11594
|
-
return {
|
|
11595
|
-
type: 'ERC721',
|
|
11596
|
-
contractAddress: item.contract_address,
|
|
11597
|
-
tokenId: item.token_id,
|
|
11598
|
-
};
|
|
11599
|
-
}
|
|
11600
|
-
throw new Error('Sell items must ERC721');
|
|
11601
|
-
});
|
|
11602
|
-
return {
|
|
11603
|
-
id: order.id,
|
|
11604
|
-
accountAddress: order.account_address,
|
|
11605
|
-
buy: buyItems,
|
|
11606
|
-
sell: sellItems,
|
|
11607
|
-
fees: order.fees.map((fee) => ({
|
|
11608
|
-
amount: fee.amount,
|
|
11609
|
-
recipient: fee.recipient,
|
|
11610
|
-
type: fee.fee_type,
|
|
11611
|
-
})),
|
|
11612
|
-
chain: order.chain,
|
|
11613
|
-
createdAt: order.created_at,
|
|
11614
|
-
endAt: order.end_at,
|
|
11615
|
-
protocolData: {
|
|
11616
|
-
counter: order.protocol_data.counter,
|
|
11617
|
-
orderType: order.protocol_data.order_type,
|
|
11618
|
-
seaportAddress: order.protocol_data.seaport_address,
|
|
11619
|
-
seaportVersion: order.protocol_data.seaport_version,
|
|
11620
|
-
zoneAddress: order.protocol_data.zone_address,
|
|
11621
|
-
},
|
|
11622
|
-
salt: order.salt,
|
|
11623
|
-
signature: order.signature,
|
|
11624
|
-
startAt: order.start_at,
|
|
11625
|
-
status: order.status,
|
|
11626
|
-
updatedAt: order.updated_at,
|
|
11627
|
-
};
|
|
11628
|
-
}
|
|
11629
|
-
function mapFromOpenApiTrade(trade) {
|
|
11630
|
-
const buyItems = trade.buy.map((item) => {
|
|
11631
|
-
if (item.item_type === 'ERC20') {
|
|
11632
|
-
return {
|
|
11633
|
-
type: 'ERC20',
|
|
11634
|
-
contractAddress: item.contract_address,
|
|
11635
|
-
amount: item.start_amount,
|
|
11636
|
-
};
|
|
11637
|
-
}
|
|
11638
|
-
if (item.item_type === 'NATIVE') {
|
|
11639
|
-
return {
|
|
11640
|
-
type: 'NATIVE',
|
|
11641
|
-
amount: item.start_amount,
|
|
11642
|
-
};
|
|
11643
|
-
}
|
|
11644
|
-
throw new Error('Buy items must be either ERC20 or NATIVE');
|
|
11645
|
-
});
|
|
11646
|
-
const sellItems = trade.sell.map((item) => {
|
|
11647
|
-
if (item.item_type === 'ERC721') {
|
|
11648
|
-
return {
|
|
11649
|
-
type: 'ERC721',
|
|
11650
|
-
contractAddress: item.contract_address,
|
|
11651
|
-
tokenId: item.token_id,
|
|
11652
|
-
};
|
|
11653
|
-
}
|
|
11654
|
-
throw new Error('Sell items must ERC721');
|
|
11655
|
-
});
|
|
11656
|
-
return {
|
|
11657
|
-
id: trade.id,
|
|
11658
|
-
orderId: trade.order_id,
|
|
11659
|
-
buy: buyItems,
|
|
11660
|
-
sell: sellItems,
|
|
11661
|
-
buyerFees: trade.buyer_fees.map((fee) => ({
|
|
11662
|
-
amount: fee.amount,
|
|
11663
|
-
recipient: fee.recipient,
|
|
11664
|
-
type: fee.fee_type,
|
|
11665
|
-
})),
|
|
11666
|
-
chain: trade.chain,
|
|
11667
|
-
indexedAt: trade.indexed_at,
|
|
11668
|
-
blockchainMetadata: {
|
|
11669
|
-
blockNumber: trade.blockchain_metadata.block_number,
|
|
11670
|
-
logIndex: trade.blockchain_metadata.log_index,
|
|
11671
|
-
transactionHash: trade.blockchain_metadata.transaction_hash,
|
|
11672
|
-
transactionIndex: trade.blockchain_metadata.transaction_index,
|
|
11673
|
-
},
|
|
11674
|
-
buyerAddress: trade.buyer_address,
|
|
11675
|
-
makerAddress: trade.maker_address,
|
|
11676
|
-
sellerAddress: trade.seller_address,
|
|
11677
|
-
takerAddress: trade.taker_address,
|
|
11678
|
-
};
|
|
11679
|
-
}
|
|
11680
|
-
function mapFromOpenApiPage(page) {
|
|
11681
|
-
return {
|
|
11682
|
-
nextCursor: page.next_cursor,
|
|
11683
|
-
previousCursor: page.previous_cursor,
|
|
11684
|
-
};
|
|
11685
|
-
}
|
|
11686
|
-
|
|
11687
|
-
/* eslint-disable */
|
|
11688
|
-
// TODO: Resolve these from seaport-js.
|
|
11689
|
-
// There is some bundling issue that is preventing this from working
|
|
11690
|
-
const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
|
|
11691
|
-
// export const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
11692
|
-
const SEAPORT_CONTRACT_VERSION_V1_5 = '1.5';
|
|
11693
|
-
const EIP_712_ORDER_TYPE = {
|
|
11694
|
-
OrderComponents: [
|
|
11695
|
-
{ name: 'offerer', type: 'address' },
|
|
11696
|
-
{ name: 'zone', type: 'address' },
|
|
11697
|
-
{ name: 'offer', type: 'OfferItem[]' },
|
|
11698
|
-
{ name: 'consideration', type: 'ConsiderationItem[]' },
|
|
11699
|
-
{ name: 'orderType', type: 'uint8' },
|
|
11700
|
-
{ name: 'startTime', type: 'uint256' },
|
|
11701
|
-
{ name: 'endTime', type: 'uint256' },
|
|
11702
|
-
{ name: 'zoneHash', type: 'bytes32' },
|
|
11703
|
-
{ name: 'salt', type: 'uint256' },
|
|
11704
|
-
{ name: 'conduitKey', type: 'bytes32' },
|
|
11705
|
-
{ name: 'counter', type: 'uint256' },
|
|
11706
|
-
],
|
|
11707
|
-
OfferItem: [
|
|
11708
|
-
{ name: 'itemType', type: 'uint8' },
|
|
11709
|
-
{ name: 'token', type: 'address' },
|
|
11710
|
-
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
11711
|
-
{ name: 'startAmount', type: 'uint256' },
|
|
11712
|
-
{ name: 'endAmount', type: 'uint256' },
|
|
11713
|
-
],
|
|
11714
|
-
ConsiderationItem: [
|
|
11715
|
-
{ name: 'itemType', type: 'uint8' },
|
|
11716
|
-
{ name: 'token', type: 'address' },
|
|
11717
|
-
{ name: 'identifierOrCriteria', type: 'uint256' },
|
|
11718
|
-
{ name: 'startAmount', type: 'uint256' },
|
|
11719
|
-
{ name: 'endAmount', type: 'uint256' },
|
|
11720
|
-
{ name: 'recipient', type: 'address' },
|
|
11721
|
-
],
|
|
11722
|
-
};
|
|
11723
|
-
var OrderType;
|
|
11724
|
-
(function (OrderType) {
|
|
11725
|
-
OrderType[OrderType["FULL_OPEN"] = 0] = "FULL_OPEN";
|
|
11726
|
-
OrderType[OrderType["PARTIAL_OPEN"] = 1] = "PARTIAL_OPEN";
|
|
11727
|
-
OrderType[OrderType["FULL_RESTRICTED"] = 2] = "FULL_RESTRICTED";
|
|
11728
|
-
OrderType[OrderType["PARTIAL_RESTRICTED"] = 3] = "PARTIAL_RESTRICTED";
|
|
11729
|
-
})(OrderType || (OrderType = {}));
|
|
11730
|
-
var ItemType;
|
|
11731
|
-
(function (ItemType) {
|
|
11732
|
-
ItemType[ItemType["NATIVE"] = 0] = "NATIVE";
|
|
11733
|
-
ItemType[ItemType["ERC20"] = 1] = "ERC20";
|
|
11734
|
-
ItemType[ItemType["ERC721"] = 2] = "ERC721";
|
|
11735
|
-
ItemType[ItemType["ERC1155"] = 3] = "ERC1155";
|
|
11736
|
-
ItemType[ItemType["ERC721_WITH_CRITERIA"] = 4] = "ERC721_WITH_CRITERIA";
|
|
11737
|
-
ItemType[ItemType["ERC1155_WITH_CRITERIA"] = 5] = "ERC1155_WITH_CRITERIA";
|
|
11738
|
-
})(ItemType || (ItemType = {}));
|
|
11739
|
-
var Side;
|
|
11740
|
-
(function (Side) {
|
|
11741
|
-
Side[Side["OFFER"] = 0] = "OFFER";
|
|
11742
|
-
Side[Side["CONSIDERATION"] = 1] = "CONSIDERATION";
|
|
11743
|
-
})(Side || (Side = {}));
|
|
11744
|
-
var BasicOrderRouteType;
|
|
11745
|
-
(function (BasicOrderRouteType) {
|
|
11746
|
-
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC721"] = 0] = "ETH_TO_ERC721";
|
|
11747
|
-
BasicOrderRouteType[BasicOrderRouteType["ETH_TO_ERC1155"] = 1] = "ETH_TO_ERC1155";
|
|
11748
|
-
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC721"] = 2] = "ERC20_TO_ERC721";
|
|
11749
|
-
BasicOrderRouteType[BasicOrderRouteType["ERC20_TO_ERC1155"] = 3] = "ERC20_TO_ERC1155";
|
|
11750
|
-
BasicOrderRouteType[BasicOrderRouteType["ERC721_TO_ERC20"] = 4] = "ERC721_TO_ERC20";
|
|
11751
|
-
BasicOrderRouteType[BasicOrderRouteType["ERC1155_TO_ERC20"] = 5] = "ERC1155_TO_ERC20";
|
|
11752
|
-
})(BasicOrderRouteType || (BasicOrderRouteType = {}));
|
|
11753
|
-
|
|
11754
|
-
function getOrderComponentsFromMessage(orderMessage) {
|
|
11755
|
-
const data = JSON.parse(orderMessage);
|
|
11756
|
-
const orderComponents = data.message;
|
|
11757
|
-
orderComponents.salt = BigNumber.from(orderComponents.salt).toHexString();
|
|
11758
|
-
return orderComponents;
|
|
11759
|
-
}
|
|
11760
|
-
|
|
11761
|
-
// Add 20% more gas than estimate to prevent out of gas errors
|
|
11762
|
-
// This can always be overwritten by the user signing the transaction
|
|
11763
|
-
function prepareTransaction(transactionMethods) {
|
|
11764
|
-
return async () => {
|
|
11765
|
-
const transaction = await transactionMethods.buildTransaction();
|
|
11766
|
-
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
11767
|
-
transaction.gasLimit = transaction.gasLimit
|
|
11768
|
-
.add(transaction.gasLimit.div(5));
|
|
11769
|
-
return transaction;
|
|
11770
|
-
};
|
|
11771
|
-
}
|
|
11772
|
-
|
|
11773
|
-
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
11774
|
-
const considerationItems = order.buy.map((buyItem) => {
|
|
11775
|
-
switch (buyItem.item_type) {
|
|
11776
|
-
case 'NATIVE':
|
|
11777
|
-
return {
|
|
11778
|
-
startAmount: buyItem.start_amount,
|
|
11779
|
-
endAmount: buyItem.start_amount,
|
|
11780
|
-
itemType: ItemType.NATIVE,
|
|
11781
|
-
recipient: order.account_address,
|
|
11782
|
-
token: constants$1.AddressZero,
|
|
11783
|
-
identifierOrCriteria: '0',
|
|
11784
|
-
};
|
|
11785
|
-
case 'ERC20':
|
|
11786
|
-
return {
|
|
11787
|
-
startAmount: buyItem.start_amount,
|
|
11788
|
-
endAmount: buyItem.start_amount,
|
|
11789
|
-
itemType: ItemType.ERC20,
|
|
11790
|
-
recipient: order.account_address,
|
|
11791
|
-
token: buyItem.contract_address || constants$1.AddressZero,
|
|
11792
|
-
identifierOrCriteria: '0',
|
|
11793
|
-
};
|
|
11794
|
-
default: // ERC721
|
|
11795
|
-
return {
|
|
11796
|
-
startAmount: '1',
|
|
11797
|
-
endAmount: '1',
|
|
11798
|
-
itemType: ItemType.ERC721,
|
|
11799
|
-
recipient: order.account_address,
|
|
11800
|
-
token: buyItem.contract_address || constants$1.AddressZero,
|
|
11801
|
-
identifierOrCriteria: '0',
|
|
11802
|
-
};
|
|
11803
|
-
}
|
|
11804
|
-
});
|
|
11805
|
-
const fees = order.fees.map((fee) => ({
|
|
11806
|
-
amount: fee.amount,
|
|
11807
|
-
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
11808
|
-
recipient: fee.recipient,
|
|
11809
|
-
token: order.buy[0].item_type === 'ERC20'
|
|
11810
|
-
? order.buy[0].contract_address
|
|
11811
|
-
: constants$1.AddressZero,
|
|
11812
|
-
identifierOrCriteria: '0',
|
|
11813
|
-
}));
|
|
11814
|
-
return {
|
|
11815
|
-
orderComponents: {
|
|
11816
|
-
conduitKey: constants$1.HashZero,
|
|
11817
|
-
consideration: [...considerationItems],
|
|
11818
|
-
offer: order.sell.map((sellItem) => {
|
|
11819
|
-
const erc721Item = sellItem;
|
|
11820
|
-
return {
|
|
11821
|
-
startAmount: '1',
|
|
11822
|
-
endAmount: '1',
|
|
11823
|
-
itemType: ItemType.ERC721,
|
|
11824
|
-
token: erc721Item.contract_address,
|
|
11825
|
-
identifierOrCriteria: erc721Item.token_id,
|
|
11826
|
-
};
|
|
11827
|
-
}),
|
|
11828
|
-
counter,
|
|
11829
|
-
endTime: Math.round(new Date(order.end_at).getTime() / 1000).toString(),
|
|
11830
|
-
startTime: Math.round(new Date(order.start_at).getTime() / 1000).toString(),
|
|
11831
|
-
salt: order.salt,
|
|
11832
|
-
offerer: order.account_address,
|
|
11833
|
-
zone: zoneAddress,
|
|
11834
|
-
// this should be the fee exclusive number of items the user signed for
|
|
11835
|
-
totalOriginalConsiderationItems: considerationItems.length,
|
|
11836
|
-
orderType: OrderType.FULL_RESTRICTED,
|
|
11837
|
-
zoneHash: constants$1.HashZero,
|
|
11838
|
-
},
|
|
11839
|
-
tips: fees,
|
|
11840
|
-
};
|
|
11841
|
-
}
|
|
11842
|
-
|
|
11843
|
-
class Seaport {
|
|
11844
|
-
seaportLibFactory;
|
|
11845
|
-
provider;
|
|
11846
|
-
seaportContractAddress;
|
|
11847
|
-
zoneContractAddress;
|
|
11848
|
-
constructor(seaportLibFactory, provider, seaportContractAddress, zoneContractAddress) {
|
|
11849
|
-
this.seaportLibFactory = seaportLibFactory;
|
|
11850
|
-
this.provider = provider;
|
|
11851
|
-
this.seaportContractAddress = seaportContractAddress;
|
|
11852
|
-
this.zoneContractAddress = zoneContractAddress;
|
|
11853
|
-
}
|
|
11854
|
-
async prepareSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
|
|
11855
|
-
const { actions: seaportActions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry);
|
|
11856
|
-
const listingActions = [];
|
|
11857
|
-
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
11858
|
-
if (approvalAction) {
|
|
11859
|
-
listingActions.push({
|
|
11860
|
-
type: ActionType.TRANSACTION,
|
|
11861
|
-
purpose: TransactionPurpose.APPROVAL,
|
|
11862
|
-
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
11863
|
-
});
|
|
11864
|
-
}
|
|
11865
|
-
const createAction = seaportActions.find((action) => action.type === 'create');
|
|
11866
|
-
if (!createAction) {
|
|
11867
|
-
throw new Error('No create order action found');
|
|
11868
|
-
}
|
|
11869
|
-
const orderMessageToSign = await createAction.getMessageToSign();
|
|
11870
|
-
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
11871
|
-
listingActions.push({
|
|
11872
|
-
type: ActionType.SIGNABLE,
|
|
11873
|
-
purpose: SignablePurpose.CREATE_LISTING,
|
|
11874
|
-
message: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
11875
|
-
});
|
|
11876
|
-
return {
|
|
11877
|
-
actions: listingActions,
|
|
11878
|
-
orderComponents,
|
|
11879
|
-
orderHash: this.getSeaportLib().getOrderHash(orderComponents),
|
|
11880
|
-
};
|
|
11881
|
-
}
|
|
11882
|
-
async fulfillOrder(order, account, extraData) {
|
|
11883
|
-
const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
11884
|
-
const seaportLib = this.getSeaportLib(order);
|
|
11885
|
-
const { actions: seaportActions } = await seaportLib.fulfillOrders({
|
|
11886
|
-
accountAddress: account,
|
|
11887
|
-
fulfillOrderDetails: [
|
|
11888
|
-
{
|
|
11889
|
-
order: {
|
|
11890
|
-
parameters: orderComponents,
|
|
11891
|
-
signature: order.signature,
|
|
11892
|
-
},
|
|
11893
|
-
extraData,
|
|
11894
|
-
tips,
|
|
11895
|
-
},
|
|
11896
|
-
],
|
|
11897
|
-
});
|
|
11898
|
-
const fulfillmentActions = [];
|
|
11899
|
-
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
11900
|
-
if (approvalAction) {
|
|
11901
|
-
fulfillmentActions.push({
|
|
11902
|
-
type: ActionType.TRANSACTION,
|
|
11903
|
-
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
11904
|
-
purpose: TransactionPurpose.APPROVAL,
|
|
11905
|
-
});
|
|
11906
|
-
}
|
|
11907
|
-
const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
|
|
11908
|
-
if (!fulfilOrderAction) {
|
|
11909
|
-
throw new Error('No exchange action found');
|
|
11910
|
-
}
|
|
11911
|
-
fulfillmentActions.push({
|
|
11912
|
-
type: ActionType.TRANSACTION,
|
|
11913
|
-
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
11914
|
-
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
11915
|
-
});
|
|
11916
|
-
return {
|
|
11917
|
-
actions: fulfillmentActions,
|
|
11918
|
-
expiration: Seaport.getExpirationISOTimeFromExtraData(extraData),
|
|
11919
|
-
order: mapFromOpenApiOrder(order),
|
|
11920
|
-
};
|
|
11921
|
-
}
|
|
11922
|
-
async fulfillBulkOrders(fulfillingOrders, account) {
|
|
11923
|
-
const fulfillOrderDetails = fulfillingOrders.map((o) => {
|
|
11924
|
-
const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(o.order);
|
|
11925
|
-
return {
|
|
11926
|
-
order: {
|
|
11927
|
-
parameters: orderComponents,
|
|
11928
|
-
signature: o.order.signature,
|
|
11929
|
-
},
|
|
11930
|
-
extraData: o.extra_data,
|
|
11931
|
-
tips,
|
|
11932
|
-
};
|
|
11933
|
-
});
|
|
11934
|
-
const { actions: seaportActions } = await this.getSeaportLib().fulfillOrders({
|
|
11935
|
-
fulfillOrderDetails,
|
|
11936
|
-
accountAddress: account,
|
|
11937
|
-
});
|
|
11938
|
-
const fulfillmentActions = [];
|
|
11939
|
-
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
11940
|
-
if (approvalAction) {
|
|
11941
|
-
fulfillmentActions.push({
|
|
11942
|
-
type: ActionType.TRANSACTION,
|
|
11943
|
-
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
11944
|
-
purpose: TransactionPurpose.APPROVAL,
|
|
11945
|
-
});
|
|
11946
|
-
}
|
|
11947
|
-
const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
|
|
11948
|
-
if (!fulfilOrderAction) {
|
|
11949
|
-
throw new Error('No exchange action found');
|
|
11950
|
-
}
|
|
11951
|
-
fulfillmentActions.push({
|
|
11952
|
-
type: ActionType.TRANSACTION,
|
|
11953
|
-
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
11954
|
-
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
11955
|
-
});
|
|
11956
|
-
return {
|
|
11957
|
-
actions: fulfillmentActions,
|
|
11958
|
-
// return the shortest expiration out of all extraData - they should be very close
|
|
11959
|
-
expiration: fulfillOrderDetails
|
|
11960
|
-
.map((d) => Seaport.getExpirationISOTimeFromExtraData(d.extraData))
|
|
11961
|
-
.reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
|
|
11962
|
-
};
|
|
11963
|
-
}
|
|
11964
|
-
async cancelOrders(orders, account) {
|
|
11965
|
-
const orderComponents = orders.map((order) => this.mapImmutableOrderToSeaportOrderComponents(order).orderComponents);
|
|
11966
|
-
const seaportLib = this.getSeaportLib(orders[0]);
|
|
11967
|
-
const cancellationTransaction = await seaportLib.cancelOrders(orderComponents, account);
|
|
11968
|
-
return {
|
|
11969
|
-
type: ActionType.TRANSACTION,
|
|
11970
|
-
buildTransaction: prepareTransaction(cancellationTransaction),
|
|
11971
|
-
purpose: TransactionPurpose.CANCEL,
|
|
11972
|
-
};
|
|
11973
|
-
}
|
|
11974
|
-
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
11975
|
-
const orderCounter = order.protocol_data.counter;
|
|
11976
|
-
return mapImmutableOrderToSeaportOrderComponents(order, orderCounter, this.zoneContractAddress);
|
|
11977
|
-
}
|
|
11978
|
-
createSeaportOrder(offerer, listingItem, considerationItem, orderStart, orderExpiry) {
|
|
11979
|
-
const seaportLib = this.getSeaportLib();
|
|
11980
|
-
return seaportLib.createOrder({
|
|
11981
|
-
allowPartialFills: false,
|
|
11982
|
-
offer: [
|
|
11983
|
-
{
|
|
11984
|
-
itemType: ItemType.ERC721,
|
|
11985
|
-
token: listingItem.contractAddress,
|
|
11986
|
-
identifier: listingItem.tokenId,
|
|
11987
|
-
},
|
|
11988
|
-
],
|
|
11989
|
-
consideration: [
|
|
11990
|
-
{
|
|
11991
|
-
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
11992
|
-
amount: considerationItem.amount,
|
|
11993
|
-
recipient: offerer,
|
|
11994
|
-
},
|
|
11995
|
-
],
|
|
11996
|
-
startTime: (orderStart.getTime() / 1000).toFixed(0),
|
|
11997
|
-
endTime: (orderExpiry.getTime() / 1000).toFixed(0),
|
|
11998
|
-
zone: this.zoneContractAddress,
|
|
11999
|
-
restrictedByZone: true,
|
|
12000
|
-
}, offerer);
|
|
12001
|
-
}
|
|
12002
|
-
async getTypedDataFromOrderComponents(orderComponents) {
|
|
12003
|
-
const { chainId } = await this.provider.getNetwork();
|
|
12004
|
-
const domainData = {
|
|
12005
|
-
name: SEAPORT_CONTRACT_NAME,
|
|
12006
|
-
version: SEAPORT_CONTRACT_VERSION_V1_5,
|
|
12007
|
-
chainId,
|
|
12008
|
-
verifyingContract: this.seaportContractAddress,
|
|
12009
|
-
};
|
|
12010
|
-
return {
|
|
12011
|
-
domain: domainData,
|
|
12012
|
-
types: EIP_712_ORDER_TYPE,
|
|
12013
|
-
value: orderComponents,
|
|
12014
|
-
};
|
|
12015
|
-
}
|
|
12016
|
-
getSeaportLib(order) {
|
|
12017
|
-
const seaportAddress = order?.protocol_data?.seaport_address ?? this.seaportContractAddress;
|
|
12018
|
-
const seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
|
|
12019
|
-
// if (order?.protocol_data?.seaport_version === SEAPORT_CONTRACT_VERSION_V1_5) {
|
|
12020
|
-
// seaportVersion = SEAPORT_CONTRACT_VERSION_V1_5;
|
|
12021
|
-
// }
|
|
12022
|
-
return this.seaportLibFactory.create(seaportVersion, seaportAddress);
|
|
12023
|
-
}
|
|
12024
|
-
static getExpirationISOTimeFromExtraData(extraData) {
|
|
12025
|
-
// Expirtaion bytes in SIP7 extra data [21:29]
|
|
12026
|
-
// In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
|
|
12027
|
-
// In JS slice (start, end_inclusive), (44,60)
|
|
12028
|
-
// 8 bytes uint64 epoch time in seconds
|
|
12029
|
-
const expirationHex = extraData.slice(44, 60);
|
|
12030
|
-
const expirationInSeconds = parseInt(expirationHex, 16);
|
|
12031
|
-
return new Date(expirationInSeconds * 1000).toISOString();
|
|
12032
|
-
}
|
|
12033
|
-
}
|
|
12034
|
-
|
|
12035
|
-
class ImmutableApiClient {
|
|
12036
|
-
orderbookService;
|
|
12037
|
-
chainName;
|
|
12038
|
-
seaportAddress;
|
|
12039
|
-
constructor(orderbookService, chainName, seaportAddress) {
|
|
12040
|
-
this.orderbookService = orderbookService;
|
|
12041
|
-
this.chainName = chainName;
|
|
12042
|
-
this.seaportAddress = seaportAddress;
|
|
12043
|
-
}
|
|
12044
|
-
async fulfillmentData(requests) {
|
|
12045
|
-
return this.orderbookService.fulfillmentData({
|
|
12046
|
-
chainName: this.chainName,
|
|
12047
|
-
requestBody: requests,
|
|
12048
|
-
});
|
|
12049
|
-
}
|
|
12050
|
-
async getListing(listingId) {
|
|
12051
|
-
return this.orderbookService.getListing({
|
|
12052
|
-
chainName: this.chainName,
|
|
12053
|
-
listingId,
|
|
12054
|
-
});
|
|
12055
|
-
}
|
|
12056
|
-
async getTrade(tradeId) {
|
|
12057
|
-
return this.orderbookService.getTrade({
|
|
12058
|
-
chainName: this.chainName,
|
|
12059
|
-
tradeId,
|
|
12060
|
-
});
|
|
12061
|
-
}
|
|
12062
|
-
async listListings(listOrderParams) {
|
|
12063
|
-
return this.orderbookService.listListings({
|
|
12064
|
-
chainName: this.chainName,
|
|
12065
|
-
...listOrderParams,
|
|
12066
|
-
});
|
|
12067
|
-
}
|
|
12068
|
-
async listTrades(listTradesParams) {
|
|
12069
|
-
return this.orderbookService.listTrades({
|
|
12070
|
-
chainName: this.chainName,
|
|
12071
|
-
...listTradesParams,
|
|
12072
|
-
});
|
|
12073
|
-
}
|
|
12074
|
-
async cancelOrders(orderIds, accountAddress, signature) {
|
|
12075
|
-
return this.orderbookService.cancelOrders({
|
|
12076
|
-
chainName: this.chainName,
|
|
12077
|
-
requestBody: {
|
|
12078
|
-
account_address: accountAddress,
|
|
12079
|
-
orders: orderIds,
|
|
12080
|
-
signature,
|
|
12081
|
-
},
|
|
12082
|
-
});
|
|
12083
|
-
}
|
|
12084
|
-
async createListing({ orderHash, orderComponents, orderSignature, makerFees, }) {
|
|
12085
|
-
if (orderComponents.offer.length !== 1) {
|
|
12086
|
-
throw new Error('Only one item can be listed at a time');
|
|
12087
|
-
}
|
|
12088
|
-
if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
|
|
12089
|
-
throw new Error('Only ERC721 tokens can be listed');
|
|
12090
|
-
}
|
|
12091
|
-
const orderTypes = [
|
|
12092
|
-
...orderComponents.consideration.map((c) => c.itemType),
|
|
12093
|
-
];
|
|
12094
|
-
const isSameConsiderationType = new Set(orderTypes).size === 1;
|
|
12095
|
-
if (!isSameConsiderationType) {
|
|
12096
|
-
throw new Error('All consideration items must be of the same type');
|
|
12097
|
-
}
|
|
12098
|
-
return this.orderbookService.createListing({
|
|
12099
|
-
chainName: this.chainName,
|
|
12100
|
-
requestBody: {
|
|
12101
|
-
order_hash: orderHash,
|
|
12102
|
-
account_address: orderComponents.offerer,
|
|
12103
|
-
buy: [
|
|
12104
|
-
{
|
|
12105
|
-
item_type: Number(orderComponents.consideration[0].itemType)
|
|
12106
|
-
=== ItemType.NATIVE
|
|
12107
|
-
? 'NATIVE'
|
|
12108
|
-
: 'ERC20',
|
|
12109
|
-
start_amount: orderComponents.consideration[0].startAmount,
|
|
12110
|
-
contract_address: orderComponents.consideration[0].token,
|
|
12111
|
-
},
|
|
12112
|
-
],
|
|
12113
|
-
fees: makerFees.map((x) => ({
|
|
12114
|
-
amount: x.amount,
|
|
12115
|
-
fee_type: FeeType.MAKER_ECOSYSTEM,
|
|
12116
|
-
recipient: x.recipient,
|
|
12117
|
-
})),
|
|
12118
|
-
end_at: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
12119
|
-
protocol_data: {
|
|
12120
|
-
order_type: ProtocolData.order_type.FULL_RESTRICTED,
|
|
12121
|
-
zone_address: orderComponents.zone,
|
|
12122
|
-
seaport_address: this.seaportAddress,
|
|
12123
|
-
seaport_version: SEAPORT_CONTRACT_VERSION_V1_5,
|
|
12124
|
-
counter: orderComponents.counter.toString(),
|
|
12125
|
-
},
|
|
12126
|
-
salt: orderComponents.salt,
|
|
12127
|
-
sell: [
|
|
12128
|
-
{
|
|
12129
|
-
contract_address: orderComponents.offer[0].token,
|
|
12130
|
-
token_id: orderComponents.offer[0].identifierOrCriteria,
|
|
12131
|
-
item_type: 'ERC721',
|
|
12132
|
-
},
|
|
12133
|
-
],
|
|
12134
|
-
signature: orderSignature,
|
|
12135
|
-
start_at: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
|
|
12136
|
-
},
|
|
12137
|
-
});
|
|
12138
|
-
}
|
|
12139
|
-
}
|
|
12140
|
-
|
|
12141
|
-
class ImmutableApiClientFactory {
|
|
12142
|
-
chainName;
|
|
12143
|
-
seaportAddress;
|
|
12144
|
-
orderbookClient;
|
|
12145
|
-
constructor(apiEndpoint, chainName, seaportAddress) {
|
|
12146
|
-
this.chainName = chainName;
|
|
12147
|
-
this.seaportAddress = seaportAddress;
|
|
12148
|
-
this.orderbookClient = new OrderBookClient({
|
|
12149
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12150
|
-
BASE: apiEndpoint,
|
|
12151
|
-
});
|
|
12152
|
-
}
|
|
12153
|
-
create() {
|
|
12154
|
-
return new ImmutableApiClient(this.orderbookClient.orders, this.chainName, this.seaportAddress);
|
|
12155
|
-
}
|
|
12156
|
-
}
|
|
12157
|
-
|
|
12158
|
-
const TESTNET_CHAIN_NAME = 'imtbl-zkevm-testnet';
|
|
12159
|
-
const MAINNET_CHAIN_NAME = 'imtbl-zkevm-mainnet';
|
|
12160
|
-
function getOrderbookConfig(environment) {
|
|
12161
|
-
switch (environment) {
|
|
12162
|
-
case Environment.SANDBOX:
|
|
12163
|
-
return {
|
|
12164
|
-
seaportContractAddress: '0x7Fb7Da6De152597830eD16361633e362A2F59410',
|
|
12165
|
-
zoneContractAddress: '0x63441cBfBd15Dd8f5E92598E535661Ac5aCB808E',
|
|
12166
|
-
apiEndpoint: 'https://api.sandbox.immutable.com',
|
|
12167
|
-
chainName: TESTNET_CHAIN_NAME,
|
|
12168
|
-
provider: new providers.JsonRpcProvider('https://rpc.testnet.immutable.com'),
|
|
12169
|
-
};
|
|
12170
|
-
// not yet deployed
|
|
12171
|
-
case Environment.PRODUCTION:
|
|
12172
|
-
return {
|
|
12173
|
-
seaportContractAddress: '',
|
|
12174
|
-
zoneContractAddress: '',
|
|
12175
|
-
apiEndpoint: 'https://api.immutable.com',
|
|
12176
|
-
chainName: MAINNET_CHAIN_NAME,
|
|
12177
|
-
provider: new providers.JsonRpcProvider('https://rpc.immutable.com'),
|
|
12178
|
-
};
|
|
12179
|
-
default:
|
|
12180
|
-
return null;
|
|
12181
|
-
}
|
|
12182
|
-
}
|
|
12183
|
-
|
|
12184
|
-
class SeaportLibFactory {
|
|
12185
|
-
defaultSeaportContractAddress;
|
|
12186
|
-
provider;
|
|
12187
|
-
constructor(defaultSeaportContractAddress, provider) {
|
|
12188
|
-
this.defaultSeaportContractAddress = defaultSeaportContractAddress;
|
|
12189
|
-
this.provider = provider;
|
|
12190
|
-
}
|
|
12191
|
-
create(orderSeaportVersion, orderSeaportAddress) {
|
|
12192
|
-
const seaportVersion = orderSeaportVersion ?? SEAPORT_CONTRACT_VERSION_V1_5;
|
|
12193
|
-
const seaportContractAddress = orderSeaportAddress ?? this.defaultSeaportContractAddress;
|
|
12194
|
-
return new Seaport$1(this.provider, {
|
|
12195
|
-
seaportVersion,
|
|
12196
|
-
balanceAndApprovalChecksOnOrderCreation: true,
|
|
12197
|
-
overrides: {
|
|
12198
|
-
contractAddress: seaportContractAddress,
|
|
12199
|
-
},
|
|
12200
|
-
});
|
|
12201
|
-
}
|
|
12202
|
-
}
|
|
12203
|
-
|
|
12204
|
-
/**
|
|
12205
|
-
* zkEVM orderbook SDK
|
|
12206
|
-
* @constructor
|
|
12207
|
-
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
12208
|
-
*/
|
|
12209
|
-
class Orderbook {
|
|
12210
|
-
apiClient;
|
|
12211
|
-
seaport;
|
|
12212
|
-
orderbookConfig;
|
|
12213
|
-
constructor(config) {
|
|
12214
|
-
const obConfig = getOrderbookConfig(config.baseConfig.environment);
|
|
12215
|
-
const finalConfig = {
|
|
12216
|
-
...obConfig,
|
|
12217
|
-
...config.overrides,
|
|
12218
|
-
};
|
|
12219
|
-
if (!finalConfig) {
|
|
12220
|
-
throw new Error('Orderbook configuration not passed, please specify the environment under config.baseConfig.environment');
|
|
12221
|
-
}
|
|
12222
|
-
this.orderbookConfig = finalConfig;
|
|
12223
|
-
const { apiEndpoint, chainName } = this.orderbookConfig;
|
|
12224
|
-
if (!apiEndpoint) {
|
|
12225
|
-
throw new Error('API endpoint must be provided');
|
|
12226
|
-
}
|
|
12227
|
-
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.orderbookConfig.seaportContractAddress).create();
|
|
12228
|
-
const seaportLibFactory = new SeaportLibFactory(this.orderbookConfig.seaportContractAddress, this.orderbookConfig.provider);
|
|
12229
|
-
this.seaport = new Seaport(seaportLibFactory, this.orderbookConfig.provider, this.orderbookConfig.seaportContractAddress, this.orderbookConfig.zoneContractAddress);
|
|
12230
|
-
}
|
|
12231
|
-
/**
|
|
12232
|
-
* Return the configuration for the orderbook module.
|
|
12233
|
-
* @return {OrderbookModuleConfiguration} The configuration for the orderbook module.
|
|
12234
|
-
*/
|
|
12235
|
-
config() {
|
|
12236
|
-
return this.orderbookConfig;
|
|
12237
|
-
}
|
|
12238
|
-
/**
|
|
12239
|
-
* Get an order by ID
|
|
12240
|
-
* @param {string} listingId - The listingId to find.
|
|
12241
|
-
* @return {ListingResult} The returned order result.
|
|
12242
|
-
*/
|
|
12243
|
-
async getListing(listingId) {
|
|
12244
|
-
const apiListing = await this.apiClient.getListing(listingId);
|
|
12245
|
-
return {
|
|
12246
|
-
result: mapFromOpenApiOrder(apiListing.result),
|
|
12247
|
-
};
|
|
12248
|
-
}
|
|
12249
|
-
/**
|
|
12250
|
-
* Get a trade by ID
|
|
12251
|
-
* @param {string} tradeId - The tradeId to find.
|
|
12252
|
-
* @return {TradeResult} The returned order result.
|
|
12253
|
-
*/
|
|
12254
|
-
async getTrade(tradeId) {
|
|
12255
|
-
const apiListing = await this.apiClient.getTrade(tradeId);
|
|
12256
|
-
return {
|
|
12257
|
-
result: mapFromOpenApiTrade(apiListing.result),
|
|
12258
|
-
};
|
|
12259
|
-
}
|
|
12260
|
-
/**
|
|
12261
|
-
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
12262
|
-
* in the params object.
|
|
12263
|
-
* @param {ListListingsParams} listOrderParams - Filtering, ordering and page parameters.
|
|
12264
|
-
* @return {ListListingsResult} The paged orders.
|
|
12265
|
-
*/
|
|
12266
|
-
async listListings(listOrderParams) {
|
|
12267
|
-
const apiListings = await this.apiClient.listListings(listOrderParams);
|
|
12268
|
-
return {
|
|
12269
|
-
page: mapFromOpenApiPage(apiListings.page),
|
|
12270
|
-
result: apiListings.result.map(mapFromOpenApiOrder),
|
|
12271
|
-
};
|
|
12272
|
-
}
|
|
12273
|
-
/**
|
|
12274
|
-
* List trades. This method is used to get a list of trades filtered by conditions specified
|
|
12275
|
-
* in the params object
|
|
12276
|
-
* @param {ListTradesParams} listTradesParams - Filtering, ordering and page parameters.
|
|
12277
|
-
* @return {ListTradesResult} The paged trades.
|
|
12278
|
-
*/
|
|
12279
|
-
async listTrades(listTradesParams) {
|
|
12280
|
-
const apiListings = await this.apiClient.listTrades(listTradesParams);
|
|
12281
|
-
return {
|
|
12282
|
-
page: mapFromOpenApiPage(apiListings.page),
|
|
12283
|
-
result: apiListings.result.map(mapFromOpenApiTrade),
|
|
12284
|
-
};
|
|
12285
|
-
}
|
|
12286
|
-
/**
|
|
12287
|
-
* Get required transactions and messages for signing prior to creating a listing
|
|
12288
|
-
* through the createListing method
|
|
12289
|
-
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
12290
|
-
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
12291
|
-
* the unsigned approval transaction, the typed order message for signing and
|
|
12292
|
-
* the order components that can be submitted to `createListing` with a signature.
|
|
12293
|
-
*/
|
|
12294
|
-
async prepareListing({ makerAddress, sell, buy, orderExpiry, }) {
|
|
12295
|
-
return this.seaport.prepareSeaportOrder(makerAddress, sell, buy,
|
|
12296
|
-
// Default order start to now
|
|
12297
|
-
new Date(),
|
|
12298
|
-
// Default order expiry to 2 years from now
|
|
12299
|
-
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
12300
|
-
}
|
|
12301
|
-
/**
|
|
12302
|
-
* Create an order
|
|
12303
|
-
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
12304
|
-
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
12305
|
-
*/
|
|
12306
|
-
async createListing(createListingParams) {
|
|
12307
|
-
const apiListingResponse = await this.apiClient.createListing({
|
|
12308
|
-
...createListingParams,
|
|
12309
|
-
});
|
|
12310
|
-
return {
|
|
12311
|
-
result: mapFromOpenApiOrder(apiListingResponse.result),
|
|
12312
|
-
};
|
|
12313
|
-
}
|
|
12314
|
-
/**
|
|
12315
|
-
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
12316
|
-
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
12317
|
-
* transaction can be submitted or it will be reverted.
|
|
12318
|
-
* @param {string} listingId - The listingId to fulfil.
|
|
12319
|
-
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
12320
|
-
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
12321
|
-
*/
|
|
12322
|
-
async fulfillOrder(listingId, takerAddress, takerFees) {
|
|
12323
|
-
const fulfillmentDataRes = await this.apiClient.fulfillmentData([
|
|
12324
|
-
{
|
|
12325
|
-
order_id: listingId,
|
|
12326
|
-
fees: takerFees.map((fee) => ({
|
|
12327
|
-
amount: fee.amount,
|
|
12328
|
-
fee_type: FeeType.TAKER_ECOSYSTEM,
|
|
12329
|
-
recipient: fee.recipient,
|
|
12330
|
-
})),
|
|
12331
|
-
},
|
|
12332
|
-
]);
|
|
12333
|
-
if (fulfillmentDataRes.result.unfulfillable_orders?.length > 0) {
|
|
12334
|
-
throw new Error(`Unable to prepare fulfillment date: ${fulfillmentDataRes.result.unfulfillable_orders[0].reason}`);
|
|
12335
|
-
}
|
|
12336
|
-
else if (fulfillmentDataRes.result.fulfillable_orders?.length !== 1) {
|
|
12337
|
-
throw new Error('unexpected fulfillable order result length');
|
|
12338
|
-
}
|
|
12339
|
-
const extraData = fulfillmentDataRes.result.fulfillable_orders[0].extra_data;
|
|
12340
|
-
const orderResult = fulfillmentDataRes.result.fulfillable_orders[0].order;
|
|
12341
|
-
if (orderResult.status.name !== OrderStatusName.ACTIVE) {
|
|
12342
|
-
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
|
|
12343
|
-
}
|
|
12344
|
-
return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
|
|
12345
|
-
}
|
|
12346
|
-
async fulfillBulkOrders(listings, takerAddress) {
|
|
12347
|
-
const fulfillmentDataRes = await this.apiClient.fulfillmentData(listings.map((listingRequest) => ({
|
|
12348
|
-
order_id: listingRequest.listingId,
|
|
12349
|
-
fees: listingRequest.takerFees.map((fee) => ({
|
|
12350
|
-
amount: fee.amount,
|
|
12351
|
-
fee_type: FeeType.TAKER_ECOSYSTEM,
|
|
12352
|
-
recipient: fee.recipient,
|
|
12353
|
-
})),
|
|
12354
|
-
})));
|
|
12355
|
-
try {
|
|
12356
|
-
return {
|
|
12357
|
-
...(await this.seaport.fulfillBulkOrders(fulfillmentDataRes.result.fulfillable_orders, takerAddress)),
|
|
12358
|
-
fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
|
|
12359
|
-
unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
|
|
12360
|
-
orderId: o.order_id,
|
|
12361
|
-
reason: o.reason,
|
|
12362
|
-
})),
|
|
12363
|
-
sufficientBalance: true,
|
|
12364
|
-
};
|
|
12365
|
-
}
|
|
12366
|
-
catch (e) {
|
|
12367
|
-
// if insufficient balance error, we return FulfillBulkOrdersInsufficientBalanceResponse
|
|
12368
|
-
if (String(e).includes('The fulfiller does not have the balances needed to fulfill.')) {
|
|
12369
|
-
return {
|
|
12370
|
-
fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
|
|
12371
|
-
unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
|
|
12372
|
-
orderId: o.order_id,
|
|
12373
|
-
reason: o.reason,
|
|
12374
|
-
})),
|
|
12375
|
-
sufficientBalance: false,
|
|
12376
|
-
};
|
|
12377
|
-
}
|
|
12378
|
-
// if some other error is thrown,
|
|
12379
|
-
// there likely is a race condition of the original order validity
|
|
12380
|
-
// we throw the error back out
|
|
12381
|
-
throw e;
|
|
12382
|
-
}
|
|
12383
|
-
}
|
|
12384
|
-
/**
|
|
12385
|
-
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
12386
|
-
* `cancelOrdersOnChain`. For the orderbook to authenticate the cancellation, the creator
|
|
12387
|
-
* of the orders must sign an EIP712 message containing the orderIds
|
|
12388
|
-
* @param {string} orderIds - The orderIds to attempt to cancel.
|
|
12389
|
-
* @return {PrepareCancelOrdersResponse} The signable action to cancel the orders.
|
|
12390
|
-
*/
|
|
12391
|
-
async prepareOrderCancellations(orderIds) {
|
|
12392
|
-
const network = await this.orderbookConfig.provider.getNetwork();
|
|
12393
|
-
const domain = {
|
|
12394
|
-
name: 'imtbl-order-book',
|
|
12395
|
-
chainId: network.chainId,
|
|
12396
|
-
verifyingContract: this.orderbookConfig.seaportContractAddress,
|
|
12397
|
-
};
|
|
12398
|
-
const types = {
|
|
12399
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12400
|
-
CancelPayload: [
|
|
12401
|
-
{ name: 'orders', type: 'Order[]' },
|
|
12402
|
-
],
|
|
12403
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12404
|
-
Order: [
|
|
12405
|
-
{ name: 'id', type: 'string' },
|
|
12406
|
-
],
|
|
12407
|
-
};
|
|
12408
|
-
const cancelMessage = {
|
|
12409
|
-
orders: orderIds.map((id) => ({ id })),
|
|
12410
|
-
};
|
|
12411
|
-
return {
|
|
12412
|
-
signableAction: {
|
|
12413
|
-
purpose: SignablePurpose.OFF_CHAIN_CANCELLATION,
|
|
12414
|
-
type: ActionType.SIGNABLE,
|
|
12415
|
-
message: {
|
|
12416
|
-
domain,
|
|
12417
|
-
types,
|
|
12418
|
-
value: cancelMessage,
|
|
12419
|
-
},
|
|
12420
|
-
},
|
|
12421
|
-
};
|
|
12422
|
-
}
|
|
12423
|
-
/**
|
|
12424
|
-
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
12425
|
-
* `cancelOrdersOnChain`. Orders cancelled this way cannot be fulfilled and will be removed
|
|
12426
|
-
* from the orderbook. If there is pending fulfillment data outstanding for the order, its
|
|
12427
|
-
* cancellation will be pending until the fulfillment window has passed.
|
|
12428
|
-
* `prepareOffchainOrderCancellations` can be used to get the signable action that is signed
|
|
12429
|
-
* to get the signature required for this call.
|
|
12430
|
-
* @param {string[]} orderIds - The orderIds to attempt to cancel.
|
|
12431
|
-
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
12432
|
-
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
12433
|
-
* @return {CancelOrdersResult} The result of the off-chain cancellation request
|
|
12434
|
-
*/
|
|
12435
|
-
async cancelOrders(orderIds, accountAddress, signature) {
|
|
12436
|
-
return this.apiClient.cancelOrders(orderIds, accountAddress, signature);
|
|
12437
|
-
}
|
|
12438
|
-
/**
|
|
12439
|
-
* Get an unsigned order cancellation transaction. Orders can only be cancelled by
|
|
12440
|
-
* the account that created them. All of the orders must be from the same seaport contract.
|
|
12441
|
-
* If trying to cancel orders from multiple seaport contracts, group the orderIds by seaport
|
|
12442
|
-
* contract and call this method for each group.
|
|
12443
|
-
* @param {string[]} orderIds - The orderIds to cancel.
|
|
12444
|
-
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
12445
|
-
* @return {CancelOrdersOnChainResponse} The unsigned cancel order action
|
|
12446
|
-
*/
|
|
12447
|
-
async cancelOrdersOnChain(orderIds, accountAddress) {
|
|
12448
|
-
const orderResults = await Promise.all(orderIds.map((id) => this.apiClient.getListing(id)));
|
|
12449
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
12450
|
-
for (const orderResult of orderResults) {
|
|
12451
|
-
if (orderResult.result.status.name !== OrderStatusName.ACTIVE
|
|
12452
|
-
&& orderResult.result.status.name !== OrderStatusName.INACTIVE
|
|
12453
|
-
&& orderResult.result.status.name !== OrderStatusName.PENDING) {
|
|
12454
|
-
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
12455
|
-
}
|
|
12456
|
-
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
12457
|
-
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${orderResult.result.id}`);
|
|
12458
|
-
}
|
|
12459
|
-
}
|
|
12460
|
-
const orders = orderResults.map((orderResult) => orderResult.result);
|
|
12461
|
-
const seaportAddresses = orders.map((o) => o.protocol_data.seaport_address);
|
|
12462
|
-
const distinctSeaportAddresses = new Set(...[seaportAddresses]);
|
|
12463
|
-
if (distinctSeaportAddresses.size !== 1) {
|
|
12464
|
-
throw new Error('Cannot cancel multiple orders from different seaport contracts. Please group your orderIds accordingly');
|
|
12465
|
-
}
|
|
12466
|
-
const cancellationAction = await this.seaport.cancelOrders(orders, accountAddress);
|
|
12467
|
-
return { cancellationAction };
|
|
12468
|
-
}
|
|
12469
|
-
}
|
|
12470
|
-
|
|
12471
|
-
// Consumers might want an estimated gas limit for fulfilling an order
|
|
12472
|
-
// without calling the transaction builder. This is an estimate that
|
|
12473
|
-
// should work for all fulfillment scenarios.
|
|
12474
|
-
const ESTIMATED_FULFILLMENT_GAS_GWEI = 400000;
|
|
12475
|
-
const constants = {
|
|
12476
|
-
estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
|
|
12477
|
-
};
|
|
12478
|
-
|
|
12479
|
-
var orderbook = /*#__PURE__*/Object.freeze({
|
|
12480
|
-
__proto__: null,
|
|
12481
|
-
get ActionType () { return ActionType; },
|
|
12482
|
-
get FeeType () { return FeeType; },
|
|
12483
|
-
get OrderStatusName () { return OrderStatusName; },
|
|
12484
|
-
Orderbook: Orderbook,
|
|
12485
|
-
get SignablePurpose () { return SignablePurpose; },
|
|
12486
|
-
get TransactionPurpose () { return TransactionPurpose; },
|
|
12487
|
-
constants: constants
|
|
12488
|
-
});
|
|
12489
|
-
|
|
12490
10909
|
function isChainValid(chainID, config) {
|
|
12491
10910
|
return chainID === config.ethConfiguration.chainID;
|
|
12492
10911
|
}
|
|
@@ -13571,4 +11990,4 @@ var provider = /*#__PURE__*/Object.freeze({
|
|
|
13571
11990
|
ProviderConfiguration: ProviderConfiguration
|
|
13572
11991
|
});
|
|
13573
11992
|
|
|
13574
|
-
export { blockchain_data as blockchainData, config, immutablex_client as immutablexClient,
|
|
11993
|
+
export { blockchain_data as blockchainData, config, immutablex_client as immutablexClient, passport, provider };
|