@imtbl/sdk 0.1.7-alpha.3 → 0.1.8-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
16
16
  chainID,
17
17
  coreContractAddress,
18
18
  registrationContractAddress,
19
- sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.3',
19
+ sdkVersion: 'ts-immutable-sdk-0.1.8-alpha',
20
20
  });
21
21
  /**
22
22
  * Sets `sdkVersion` at the time of build
package/dist/index.cjs CHANGED
@@ -10,7 +10,6 @@ var BN = require('bn.js');
10
10
  var encUtils = require('enc-utils');
11
11
  var constants = require('@opensea/seaport-js/lib/constants');
12
12
  var FormData = require('form-data');
13
- var fetch = require('node-fetch');
14
13
  var seaportJs = require('@opensea/seaport-js');
15
14
  var units = require('@ethersproject/units');
16
15
  var bignumber = require('@ethersproject/bignumber');
@@ -1055,6 +1054,23 @@ class Configuration {
1055
1054
  }
1056
1055
  }
1057
1056
 
1057
+ /**
1058
+ * Custom Error class that is returned from the API when a request fails
1059
+ */
1060
+ class APIError extends Error {
1061
+ code;
1062
+ details;
1063
+ link;
1064
+ traceId;
1065
+ constructor({ message, code, details, link, trace_id: traceId, }) {
1066
+ super(message);
1067
+ this.code = code;
1068
+ this.details = details;
1069
+ this.link = link;
1070
+ this.traceId = traceId;
1071
+ }
1072
+ }
1073
+
1058
1074
  /* eslint-disable implicit-arrow-linebreak */
1059
1075
  const defaultHeaders = {
1060
1076
  sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-__SDK_VERSION__',
@@ -1106,23 +1122,6 @@ class BlockchainDataConfiguration {
1106
1122
  }
1107
1123
  }
1108
1124
 
1109
- /**
1110
- * Custom Error class that is returned from the API when a request fails
1111
- */
1112
- class APIError extends Error {
1113
- code;
1114
- details;
1115
- link;
1116
- traceId;
1117
- constructor({ message, code, details, link, trace_id: traceId, }) {
1118
- super(message);
1119
- this.code = code;
1120
- this.details = details;
1121
- this.link = link;
1122
- this.traceId = traceId;
1123
- }
1124
- }
1125
-
1126
1125
  /* eslint-disable @typescript-eslint/naming-convention */
1127
1126
  /**
1128
1127
  * [Formats an error in the APIError shape](https://axios-http.com/docs/handling_errors)
@@ -2887,6 +2886,9 @@ const isBlob = (value) => {
2887
2886
  const isFormData = (value) => {
2888
2887
  return value instanceof FormData;
2889
2888
  };
2889
+ const isSuccess = (status) => {
2890
+ return status >= 200 && status < 300;
2891
+ };
2890
2892
  const base64 = (str) => {
2891
2893
  try {
2892
2894
  return btoa(str);
@@ -2973,15 +2975,17 @@ const resolve = async (options, resolver) => {
2973
2975
  }
2974
2976
  return resolver;
2975
2977
  };
2976
- const getHeaders = async (config, options) => {
2978
+ const getHeaders = async (config, options, formData) => {
2977
2979
  const token = await resolve(options, config.TOKEN);
2978
2980
  const username = await resolve(options, config.USERNAME);
2979
2981
  const password = await resolve(options, config.PASSWORD);
2980
2982
  const additionalHeaders = await resolve(options, config.HEADERS);
2983
+ const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {};
2981
2984
  const headers = Object.entries({
2982
2985
  Accept: 'application/json',
2983
2986
  ...additionalHeaders,
2984
2987
  ...options.headers,
2988
+ ...formHeaders,
2985
2989
  })
2986
2990
  .filter(([_, value]) => isDefined(value))
2987
2991
  .reduce((headers, [key, value]) => ({
@@ -3000,7 +3004,7 @@ const getHeaders = async (config, options) => {
3000
3004
  headers['Content-Type'] = options.mediaType;
3001
3005
  }
3002
3006
  else if (isBlob(options.body)) {
3003
- headers['Content-Type'] = 'application/octet-stream';
3007
+ headers['Content-Type'] = options.body.type || 'application/octet-stream';
3004
3008
  }
3005
3009
  else if (isString(options.body)) {
3006
3010
  headers['Content-Type'] = 'text/plain';
@@ -3009,59 +3013,48 @@ const getHeaders = async (config, options) => {
3009
3013
  headers['Content-Type'] = 'application/json';
3010
3014
  }
3011
3015
  }
3012
- return new fetch.Headers(headers);
3016
+ return headers;
3013
3017
  };
3014
3018
  const getRequestBody = (options) => {
3015
3019
  if (options.body) {
3016
- if (options.mediaType?.includes('/json')) {
3017
- return JSON.stringify(options.body);
3018
- }
3019
- else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
3020
- return options.body;
3021
- }
3022
- else {
3023
- return JSON.stringify(options.body);
3024
- }
3020
+ return options.body;
3025
3021
  }
3026
3022
  return undefined;
3027
3023
  };
3028
- const sendRequest = async (options, url, body, formData, headers, onCancel) => {
3029
- const controller = new AbortController();
3030
- const request = {
3024
+ const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
3025
+ const source = globalAxios.CancelToken.source();
3026
+ const requestConfig = {
3027
+ url,
3031
3028
  headers,
3029
+ data: body ?? formData,
3032
3030
  method: options.method,
3033
- body: body ?? formData,
3034
- signal: controller.signal,
3031
+ withCredentials: config.WITH_CREDENTIALS,
3032
+ cancelToken: source.token,
3035
3033
  };
3036
- onCancel(() => controller.abort());
3037
- return await fetch(url, request);
3034
+ onCancel(() => source.cancel('The user aborted a request.'));
3035
+ try {
3036
+ return await globalAxios.request(requestConfig);
3037
+ }
3038
+ catch (error) {
3039
+ const axiosError = error;
3040
+ if (axiosError.response) {
3041
+ return axiosError.response;
3042
+ }
3043
+ throw error;
3044
+ }
3038
3045
  };
3039
3046
  const getResponseHeader = (response, responseHeader) => {
3040
3047
  if (responseHeader) {
3041
- const content = response.headers.get(responseHeader);
3048
+ const content = response.headers[responseHeader];
3042
3049
  if (isString(content)) {
3043
3050
  return content;
3044
3051
  }
3045
3052
  }
3046
3053
  return undefined;
3047
3054
  };
3048
- const getResponseBody = async (response) => {
3055
+ const getResponseBody = (response) => {
3049
3056
  if (response.status !== 204) {
3050
- try {
3051
- const contentType = response.headers.get('Content-Type');
3052
- if (contentType) {
3053
- const isJSON = contentType.toLowerCase().startsWith('application/json');
3054
- if (isJSON) {
3055
- return await response.json();
3056
- }
3057
- else {
3058
- return await response.text();
3059
- }
3060
- }
3061
- }
3062
- catch (error) {
3063
- console.error(error);
3064
- }
3057
+ return response.data;
3065
3058
  }
3066
3059
  return undefined;
3067
3060
  };
@@ -3097,14 +3090,14 @@ const request = (config, options) => {
3097
3090
  const url = getUrl(config, options);
3098
3091
  const formData = getFormData(options);
3099
3092
  const body = getRequestBody(options);
3100
- const headers = await getHeaders(config, options);
3093
+ const headers = await getHeaders(config, options, formData);
3101
3094
  if (!onCancel.isCancelled) {
3102
- const response = await sendRequest(options, url, body, formData, headers, onCancel);
3103
- const responseBody = await getResponseBody(response);
3095
+ const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
3096
+ const responseBody = getResponseBody(response);
3104
3097
  const responseHeader = getResponseHeader(response, options.responseHeader);
3105
3098
  const result = {
3106
3099
  url,
3107
- ok: response.ok,
3100
+ ok: isSuccess(response.status),
3108
3101
  status: response.status,
3109
3102
  statusText: response.statusText,
3110
3103
  body: responseHeader ?? responseBody,
@@ -3119,7 +3112,7 @@ const request = (config, options) => {
3119
3112
  });
3120
3113
  };
3121
3114
 
3122
- class NodeHttpRequest extends BaseHttpRequest {
3115
+ class AxiosHttpRequest extends BaseHttpRequest {
3123
3116
  constructor(config) {
3124
3117
  super(config);
3125
3118
  }
@@ -3216,7 +3209,7 @@ class OrdersService {
3216
3209
  class OrderBookClient {
3217
3210
  orders;
3218
3211
  request;
3219
- constructor(config, HttpRequest = NodeHttpRequest) {
3212
+ constructor(config, HttpRequest = AxiosHttpRequest) {
3220
3213
  this.request = new HttpRequest({
3221
3214
  BASE: config?.BASE ?? 'https://order-book-mr.dev.imtbl.com',
3222
3215
  VERSION: config?.VERSION ?? '1.0.0',
@@ -6673,6 +6666,7 @@ Object.defineProperty(exports, 'imxClientGenerateLegacyStarkPrivateKey', {
6673
6666
  enumerable: true,
6674
6667
  get: function () { return coreSdk.generateLegacyStarkPrivateKey; }
6675
6668
  });
6669
+ exports.APIError = APIError;
6676
6670
  exports.BlockchainData = BlockchainData;
6677
6671
  exports.BridgeReact = $1f969328e5988c99$export$30f61ebf204c69f6;
6678
6672
  exports.BuyReact = $f22931ca9e2f35b6$export$d13582032b79b401;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference path="global.d.ts" />
2
2
  /// <reference types="node" />
3
- import { BlockchainDataConfiguration, BlockchainDataModuleConfiguration, ProviderConfiguration as ProviderConfiguration$1 } from 'config';
3
+ import { BlockchainDataConfiguration, BlockchainDataModuleConfiguration as BlockchainDataModuleConfiguration$1, ProviderConfiguration as ProviderConfiguration$1 } from 'config';
4
4
  import { OrderbookModuleConfiguration } from 'config/config';
5
5
  import { OrderResult, ListOrdersResult } from 'openapi/sdk';
6
6
  import { ListOrderParams, PrepareListingParams, PrepareListingResponse, CreateOrderParams, FulfilOrderResponse, CancelOrderResponse as CancelOrderResponse$1 } from 'types';
@@ -22,6 +22,43 @@ interface ModuleConfiguration<T> {
22
22
  overrides?: T;
23
23
  }
24
24
 
25
+ /**
26
+ * Immutable X API
27
+ * Immutable Multi Rollup API
28
+ *
29
+ * The version of the OpenAPI document: 1.0.0
30
+ * Contact: support@immutable.com
31
+ *
32
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
33
+ * https://openapi-generator.tech
34
+ * Do not edit the class manually.
35
+ */
36
+ /**
37
+ *
38
+ * @export
39
+ * @interface BasicAPIError
40
+ */
41
+ interface BasicAPIError {
42
+ /**
43
+ * Error Message
44
+ * @type {string}
45
+ * @memberof BasicAPIError
46
+ */
47
+ 'message': string;
48
+ /**
49
+ * Link to IMX documentation that can help resolve this error
50
+ * @type {string}
51
+ * @memberof BasicAPIError
52
+ */
53
+ 'link': string;
54
+ /**
55
+ * Trace ID of the initial request
56
+ * @type {string}
57
+ * @memberof BasicAPIError
58
+ */
59
+ 'trace_id': string;
60
+ }
61
+
25
62
  /**
26
63
  * Immutable X API
27
64
  * Immutable Multi Rollup API
@@ -1464,6 +1501,25 @@ interface NftsApiListNFTsByAccountAddressRequest {
1464
1501
  readonly pageSize?: number;
1465
1502
  }
1466
1503
 
1504
+ interface OpenAPIError extends BasicAPIError {
1505
+ code: string;
1506
+ details: {
1507
+ [key: string]: any;
1508
+ } | null;
1509
+ }
1510
+ /**
1511
+ * Custom Error class that is returned from the API when a request fails
1512
+ */
1513
+ declare class APIError extends Error {
1514
+ readonly code: string;
1515
+ readonly details: {
1516
+ [key: string]: any;
1517
+ } | null;
1518
+ readonly link: string;
1519
+ readonly traceId: string;
1520
+ constructor({ message, code, details, link, trace_id: traceId, }: OpenAPIError);
1521
+ }
1522
+
1467
1523
  declare class BlockchainData {
1468
1524
  readonly config: BlockchainDataConfiguration;
1469
1525
  private readonly activities;
@@ -1471,7 +1527,7 @@ declare class BlockchainData {
1471
1527
  private readonly collections;
1472
1528
  private readonly nfts;
1473
1529
  private readonly nftOwners;
1474
- constructor(moduleConfig: BlockchainDataModuleConfiguration);
1530
+ constructor(moduleConfig: BlockchainDataModuleConfiguration$1);
1475
1531
  /**
1476
1532
  * List all activities
1477
1533
  * @param request - the request object containing the parameters to be provided in the API request
@@ -1537,6 +1593,13 @@ declare class BlockchainData {
1537
1593
  listNFTOwners(request: NftOwnersApiListNFTOwnersRequest): Promise<ListNFTOwnersResult>;
1538
1594
  }
1539
1595
 
1596
+ interface APIConfigurationParams {
1597
+ basePath: string;
1598
+ headers?: Record<string, string>;
1599
+ }
1600
+ interface BlockchainDataModuleConfiguration extends ModuleConfiguration<APIConfigurationParams> {
1601
+ }
1602
+
1540
1603
  declare type Bytes = ArrayLike<number>;
1541
1604
  declare type BytesLike = Bytes | string;
1542
1605
  interface Hexable {
@@ -27713,4 +27776,4 @@ declare const erc20 = 1;
27713
27776
 
27714
27777
  declare const erc721permissionedmintable = 1;
27715
27778
 
27716
- export { BlockchainData, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, BuyClose, BuyEventType, BuyFailed, BuyNotConnected, BuyReact, BuyReactProps, BuySuccess, ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectReactProps, ConnectResult, ConnectionFailed, ConnectionProviders, ConnectionSuccess, Environment, ErrorType, ExampleReact, ExampleReactProps, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblBuyProps, ImtblConnectProps, ImtblExampleProps, ImtblInnerWidgetExampleProps, ImtblOuterWidgetExampleProps, ImtblSwapProps, ImtblTransitionExampleProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, MetaMaskIMXProvider, ModuleConfiguration, Network, NetworkFilter, NetworkFilterTypes, NetworkInfo, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, ProviderConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SendTransactionParams, SendTransactionResult, SetProvider, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, erc20, erc721permissionedmintable, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
27779
+ export { APIError, BlockchainData, BlockchainDataModuleConfiguration, BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, BuyClose, BuyEventType, BuyFailed, BuyNotConnected, BuyReact, BuyReactProps, BuySuccess, ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectReact, ConnectReactProps, ConnectResult, ConnectionFailed, ConnectionProviders, ConnectionSuccess, Environment, ErrorType, ExampleReact, ExampleReactProps, GenericIMXProvider, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMTBLWidgetEvents, IMXProvider, ImmutableConfiguration, ImmutableXClient, ImtblBridgeProps, ImtblBuyProps, ImtblConnectProps, ImtblExampleProps, ImtblInnerWidgetExampleProps, ImtblOuterWidgetExampleProps, ImtblSwapProps, ImtblTransitionExampleProps, ImtblWalletProps, ImxModuleConfiguration as ImxClientModuleConfiguration, WalletConnection as ImxClientWalletConnection, MetaMaskIMXProvider, ModuleConfiguration, Network, NetworkFilter, NetworkFilterTypes, NetworkInfo, OrchestrationEventType, Orderbook, Passport, PassportError, PassportModuleConfiguration, ProviderConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SendTransactionParams, SendTransactionResult, SetProvider, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, UpdateConfig, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, erc20, erc721permissionedmintable, createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey, module };
package/dist/index.js CHANGED
@@ -9,7 +9,6 @@ import BN from 'bn.js';
9
9
  import * as encUtils from 'enc-utils';
10
10
  import { ItemType, SEAPORT_CONTRACT_NAME, SEAPORT_CONTRACT_VERSION_V1_4, EIP_712_ORDER_TYPE, OrderType } from '@opensea/seaport-js/lib/constants';
11
11
  import FormData from 'form-data';
12
- import fetch, { Headers } from 'node-fetch';
13
12
  import { Seaport as Seaport$1 } from '@opensea/seaport-js';
14
13
  import { parseUnits } from '@ethersproject/units';
15
14
  import { BigNumber as BigNumber$1 } from '@ethersproject/bignumber';
@@ -1035,9 +1034,26 @@ class Configuration {
1035
1034
  }
1036
1035
  }
1037
1036
 
1037
+ /**
1038
+ * Custom Error class that is returned from the API when a request fails
1039
+ */
1040
+ class APIError extends Error {
1041
+ code;
1042
+ details;
1043
+ link;
1044
+ traceId;
1045
+ constructor({ message, code, details, link, trace_id: traceId, }) {
1046
+ super(message);
1047
+ this.code = code;
1048
+ this.details = details;
1049
+ this.link = link;
1050
+ this.traceId = traceId;
1051
+ }
1052
+ }
1053
+
1038
1054
  /* eslint-disable implicit-arrow-linebreak */
1039
1055
  const defaultHeaders = {
1040
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.1.7-alpha.3',
1056
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.1.8-alpha',
1041
1057
  };
1042
1058
  /**
1043
1059
  * createAPIConfiguration to create a custom APIConfiguration
@@ -1086,23 +1102,6 @@ class BlockchainDataConfiguration {
1086
1102
  }
1087
1103
  }
1088
1104
 
1089
- /**
1090
- * Custom Error class that is returned from the API when a request fails
1091
- */
1092
- class APIError extends Error {
1093
- code;
1094
- details;
1095
- link;
1096
- traceId;
1097
- constructor({ message, code, details, link, trace_id: traceId, }) {
1098
- super(message);
1099
- this.code = code;
1100
- this.details = details;
1101
- this.link = link;
1102
- this.traceId = traceId;
1103
- }
1104
- }
1105
-
1106
1105
  /* eslint-disable @typescript-eslint/naming-convention */
1107
1106
  /**
1108
1107
  * [Formats an error in the APIError shape](https://axios-http.com/docs/handling_errors)
@@ -1290,7 +1289,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
1290
1289
  chainID,
1291
1290
  coreContractAddress,
1292
1291
  registrationContractAddress,
1293
- sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.3',
1292
+ sdkVersion: 'ts-immutable-sdk-0.1.8-alpha',
1294
1293
  });
1295
1294
  /**
1296
1295
  * Sets `sdkVersion` at the time of build
@@ -2867,6 +2866,9 @@ const isBlob = (value) => {
2867
2866
  const isFormData = (value) => {
2868
2867
  return value instanceof FormData;
2869
2868
  };
2869
+ const isSuccess = (status) => {
2870
+ return status >= 200 && status < 300;
2871
+ };
2870
2872
  const base64 = (str) => {
2871
2873
  try {
2872
2874
  return btoa(str);
@@ -2953,15 +2955,17 @@ const resolve = async (options, resolver) => {
2953
2955
  }
2954
2956
  return resolver;
2955
2957
  };
2956
- const getHeaders = async (config, options) => {
2958
+ const getHeaders = async (config, options, formData) => {
2957
2959
  const token = await resolve(options, config.TOKEN);
2958
2960
  const username = await resolve(options, config.USERNAME);
2959
2961
  const password = await resolve(options, config.PASSWORD);
2960
2962
  const additionalHeaders = await resolve(options, config.HEADERS);
2963
+ const formHeaders = typeof formData?.getHeaders === 'function' && formData?.getHeaders() || {};
2961
2964
  const headers = Object.entries({
2962
2965
  Accept: 'application/json',
2963
2966
  ...additionalHeaders,
2964
2967
  ...options.headers,
2968
+ ...formHeaders,
2965
2969
  })
2966
2970
  .filter(([_, value]) => isDefined(value))
2967
2971
  .reduce((headers, [key, value]) => ({
@@ -2980,7 +2984,7 @@ const getHeaders = async (config, options) => {
2980
2984
  headers['Content-Type'] = options.mediaType;
2981
2985
  }
2982
2986
  else if (isBlob(options.body)) {
2983
- headers['Content-Type'] = 'application/octet-stream';
2987
+ headers['Content-Type'] = options.body.type || 'application/octet-stream';
2984
2988
  }
2985
2989
  else if (isString(options.body)) {
2986
2990
  headers['Content-Type'] = 'text/plain';
@@ -2989,59 +2993,48 @@ const getHeaders = async (config, options) => {
2989
2993
  headers['Content-Type'] = 'application/json';
2990
2994
  }
2991
2995
  }
2992
- return new Headers(headers);
2996
+ return headers;
2993
2997
  };
2994
2998
  const getRequestBody = (options) => {
2995
2999
  if (options.body) {
2996
- if (options.mediaType?.includes('/json')) {
2997
- return JSON.stringify(options.body);
2998
- }
2999
- else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
3000
- return options.body;
3001
- }
3002
- else {
3003
- return JSON.stringify(options.body);
3004
- }
3000
+ return options.body;
3005
3001
  }
3006
3002
  return undefined;
3007
3003
  };
3008
- const sendRequest = async (options, url, body, formData, headers, onCancel) => {
3009
- const controller = new AbortController();
3010
- const request = {
3004
+ const sendRequest = async (config, options, url, body, formData, headers, onCancel) => {
3005
+ const source = globalAxios.CancelToken.source();
3006
+ const requestConfig = {
3007
+ url,
3011
3008
  headers,
3009
+ data: body ?? formData,
3012
3010
  method: options.method,
3013
- body: body ?? formData,
3014
- signal: controller.signal,
3011
+ withCredentials: config.WITH_CREDENTIALS,
3012
+ cancelToken: source.token,
3015
3013
  };
3016
- onCancel(() => controller.abort());
3017
- return await fetch(url, request);
3014
+ onCancel(() => source.cancel('The user aborted a request.'));
3015
+ try {
3016
+ return await globalAxios.request(requestConfig);
3017
+ }
3018
+ catch (error) {
3019
+ const axiosError = error;
3020
+ if (axiosError.response) {
3021
+ return axiosError.response;
3022
+ }
3023
+ throw error;
3024
+ }
3018
3025
  };
3019
3026
  const getResponseHeader = (response, responseHeader) => {
3020
3027
  if (responseHeader) {
3021
- const content = response.headers.get(responseHeader);
3028
+ const content = response.headers[responseHeader];
3022
3029
  if (isString(content)) {
3023
3030
  return content;
3024
3031
  }
3025
3032
  }
3026
3033
  return undefined;
3027
3034
  };
3028
- const getResponseBody = async (response) => {
3035
+ const getResponseBody = (response) => {
3029
3036
  if (response.status !== 204) {
3030
- try {
3031
- const contentType = response.headers.get('Content-Type');
3032
- if (contentType) {
3033
- const isJSON = contentType.toLowerCase().startsWith('application/json');
3034
- if (isJSON) {
3035
- return await response.json();
3036
- }
3037
- else {
3038
- return await response.text();
3039
- }
3040
- }
3041
- }
3042
- catch (error) {
3043
- console.error(error);
3044
- }
3037
+ return response.data;
3045
3038
  }
3046
3039
  return undefined;
3047
3040
  };
@@ -3077,14 +3070,14 @@ const request = (config, options) => {
3077
3070
  const url = getUrl(config, options);
3078
3071
  const formData = getFormData(options);
3079
3072
  const body = getRequestBody(options);
3080
- const headers = await getHeaders(config, options);
3073
+ const headers = await getHeaders(config, options, formData);
3081
3074
  if (!onCancel.isCancelled) {
3082
- const response = await sendRequest(options, url, body, formData, headers, onCancel);
3083
- const responseBody = await getResponseBody(response);
3075
+ const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
3076
+ const responseBody = getResponseBody(response);
3084
3077
  const responseHeader = getResponseHeader(response, options.responseHeader);
3085
3078
  const result = {
3086
3079
  url,
3087
- ok: response.ok,
3080
+ ok: isSuccess(response.status),
3088
3081
  status: response.status,
3089
3082
  statusText: response.statusText,
3090
3083
  body: responseHeader ?? responseBody,
@@ -3099,7 +3092,7 @@ const request = (config, options) => {
3099
3092
  });
3100
3093
  };
3101
3094
 
3102
- class NodeHttpRequest extends BaseHttpRequest {
3095
+ class AxiosHttpRequest extends BaseHttpRequest {
3103
3096
  constructor(config) {
3104
3097
  super(config);
3105
3098
  }
@@ -3196,7 +3189,7 @@ class OrdersService {
3196
3189
  class OrderBookClient {
3197
3190
  orders;
3198
3191
  request;
3199
- constructor(config, HttpRequest = NodeHttpRequest) {
3192
+ constructor(config, HttpRequest = AxiosHttpRequest) {
3200
3193
  this.request = new HttpRequest({
3201
3194
  BASE: config?.BASE ?? 'https://order-book-mr.dev.imtbl.com',
3202
3195
  VERSION: config?.VERSION ?? '1.0.0',
@@ -6645,4 +6638,4 @@ const erc20 = 1;
6645
6638
  // only for infrastructure. will be removed once wrapped functions are created
6646
6639
  const erc721permissionedmintable = 1;
6647
6640
 
6648
- export { BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $98cbcca465beec95$export$90db5fe1be5993c1 as BuyEventType, $f22931ca9e2f35b6$export$d13582032b79b401 as BuyReact, $baec09ddc3013323$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, Environment, $d087956fd1002f80$export$fa517eee6594d26c as ExampleReact, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, MetaMaskIMXProvider, $045213b18e9f1f94$export$95be4ae94445245a as Network, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, Orderbook, Passport, PassportError, ProviderConfiguration, $430e3eda76fa4d5f$export$931068bc678f0d73 as SetProvider, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme, erc20, erc721permissionedmintable, module };
6641
+ export { APIError, BlockchainData, $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $98cbcca465beec95$export$90db5fe1be5993c1 as BuyEventType, $f22931ca9e2f35b6$export$d13582032b79b401 as BuyReact, $baec09ddc3013323$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $045213b18e9f1f94$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, Environment, $d087956fd1002f80$export$fa517eee6594d26c as ExampleReact, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, MetaMaskIMXProvider, $045213b18e9f1f94$export$95be4ae94445245a as Network, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $ad06b030b1a3ba34$export$b80d2daf830437b9 as OrchestrationEventType, Orderbook, Passport, PassportError, ProviderConfiguration, $430e3eda76fa4d5f$export$931068bc678f0d73 as SetProvider, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $045213b18e9f1f94$export$c88931fdc51854eb as WidgetTheme, erc20, erc721permissionedmintable, module };