@imtbl/sdk 0.1.4-alpha → 0.1.5-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -11,6 +11,8 @@ var units = require('@ethersproject/units');
11
11
  var bignumber = require('@ethersproject/bignumber');
12
12
  var detectEthereumProvider = require('@metamask/detect-provider');
13
13
  var providers = require('@ethersproject/providers');
14
+ var jsxRuntime = require('react/jsx-runtime');
15
+ require('react');
14
16
 
15
17
  function _interopNamespaceDefault(e) {
16
18
  var n = Object.create(null);
@@ -45,26 +47,26 @@ class ImmutableConfiguration {
45
47
  }
46
48
  }
47
49
 
48
- // Set `sdkVersion` on config
49
- const PRODUCTION = () => {
50
- return coreSdk.Config.createConfig({
51
- basePath: 'https://api.x.immutable.com',
52
- chainID: 1,
53
- coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
54
- registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
55
- sdkVersion: 'ts-immutable-sdk-__SDK_VERSION__',
56
- });
57
- };
58
- // Set `sdkVersion` on config
59
- const SANDBOX = () => {
60
- return coreSdk.Config.createConfig({
61
- basePath: 'https://api.sandbox.x.immutable.com',
62
- chainID: 5,
63
- coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
64
- registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
65
- sdkVersion: 'ts-immutable-sdk-__SDK_VERSION__',
66
- });
67
- };
50
+ /**
51
+ * Set `sdkVersion` on config
52
+ */
53
+ const production = () => coreSdk.Config.createConfig({
54
+ basePath: 'https://api.x.immutable.com',
55
+ chainID: 1,
56
+ coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
57
+ registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
58
+ sdkVersion: 'ts-immutable-sdk-__SDK_VERSION__',
59
+ });
60
+ /**
61
+ * Set `sdkVersion` on config
62
+ */
63
+ const sandbox = () => coreSdk.Config.createConfig({
64
+ basePath: 'https://api.sandbox.x.immutable.com',
65
+ chainID: 5,
66
+ coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
67
+ registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
68
+ sdkVersion: 'ts-immutable-sdk-__SDK_VERSION__',
69
+ });
68
70
  class ImxConfiguration {
69
71
  immutableXConfig;
70
72
  baseConfig;
@@ -76,13 +78,16 @@ class ImxConfiguration {
76
78
  else {
77
79
  switch (baseConfig.environment) {
78
80
  case exports.Environment.SANDBOX: {
79
- this.immutableXConfig = SANDBOX();
81
+ this.immutableXConfig = sandbox();
80
82
  break;
81
83
  }
82
84
  case exports.Environment.PRODUCTION: {
83
- this.immutableXConfig = PRODUCTION();
85
+ this.immutableXConfig = production();
84
86
  break;
85
87
  }
88
+ default: {
89
+ this.immutableXConfig = sandbox();
90
+ }
86
91
  }
87
92
  }
88
93
  }
@@ -137,7 +142,7 @@ class ImmutableXClient {
137
142
  }
138
143
  /**
139
144
  * Get a list of Deposits
140
- * @param request - optional request object containing the parameters to be provided in the API request
145
+ * @param request - optional object containing the parameters to be provided in the API request
141
146
  * @returns a promise that resolves with the requested list of Deposits
142
147
  * @throws {@link index.IMXError}
143
148
  */
@@ -164,7 +169,7 @@ class ImmutableXClient {
164
169
  }
165
170
  /**
166
171
  * Get a list of Assets
167
- * @param request - optional request object containing the parameters to be provided in the API request
172
+ * @param request - optional object containing the parameters to be provided in the API request
168
173
  * @returns a promise that resolves with the requested list of Assets
169
174
  * @throws {@link index.IMXError}
170
175
  */
@@ -201,7 +206,7 @@ class ImmutableXClient {
201
206
  }
202
207
  /**
203
208
  * Get a list of Collections
204
- * @param request - optional request object containing the parameters to be provided in the API request
209
+ * @param request - optional object containing the parameters to be provided in the API request
205
210
  * @returns a promise that resolves with the requested list of Collections
206
211
  * @throws {@link index.IMXError}
207
212
  */
@@ -357,7 +362,7 @@ class ImmutableXClient {
357
362
  }
358
363
  /**
359
364
  * Get a list of Mints
360
- * @param request optional request object containing the parameters to be provided in the API request
365
+ * @param request optional object containing the parameters to be provided in the API request
361
366
  * @returns a promise that resolves with the requested list of Mints
362
367
  * @throws {@link index.IMXError}
363
368
  */
@@ -376,7 +381,7 @@ class ImmutableXClient {
376
381
  }
377
382
  /**
378
383
  * Get a list of Withdrawals
379
- * @param request - optional request object containing the parameters to be provided in the API request
384
+ * @param request - optional object containing the parameters to be provided in the API request
380
385
  * @returns a promise that resolves with the requested list of Withdrawals
381
386
  * @throws {@link index.IMXError}
382
387
  */
@@ -403,7 +408,7 @@ class ImmutableXClient {
403
408
  }
404
409
  /**
405
410
  * Get a list of Orders
406
- * @param request - optional request object containing the parameters to be provided in the API request
411
+ * @param request - optional object containing the parameters to be provided in the API request
407
412
  * @returns a promise that resolves with the requested list of Orders
408
413
  * @throws {@link index.IMXError}
409
414
  */
@@ -421,7 +426,7 @@ class ImmutableXClient {
421
426
  }
422
427
  /**
423
428
  * Get a list of Trades
424
- * @param request - optional request object containing the parameters to be provided in the API request
429
+ * @param request - optional object containing the parameters to be provided in the API request
425
430
  * @returns a promise that resolves with the requested list of Trades
426
431
  * @throws {@link index.IMXError}
427
432
  */
@@ -439,7 +444,7 @@ class ImmutableXClient {
439
444
  }
440
445
  /**
441
446
  * Get a list of Tokens
442
- * @param request - optional request object containing the parameters to be provided in the API request
447
+ * @param request - optional object containing the parameters to be provided in the API request
443
448
  * @returns a promise that resolves with the requested list of Tokens
444
449
  * @throws {@link index.IMXError}
445
450
  */
@@ -457,7 +462,7 @@ class ImmutableXClient {
457
462
  }
458
463
  /**
459
464
  * Get a list of Transfers
460
- * @param request - optional request object containing the parameters to be provided in the API request
465
+ * @param request - optional object containing the parameters to be provided in the API request
461
466
  * @returns a promise that resolves with the requested list of Transfers
462
467
  * @throws {@link index.IMXError}
463
468
  */
@@ -678,9 +683,9 @@ const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
678
683
  authorization_endpoint: `${authenticationDomain}/authorize`,
679
684
  token_endpoint: `${authenticationDomain}/oauth/token`,
680
685
  userinfo_endpoint: `${authenticationDomain}/userinfo`,
681
- end_session_endpoint: `${authenticationDomain}/v2/logout` +
682
- `?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
683
- `&client_id=${oidcConfiguration.clientId}`,
686
+ end_session_endpoint: `${authenticationDomain}/v2/logout`
687
+ + `?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}`
688
+ + `&client_id=${oidcConfiguration.clientId}`,
684
689
  },
685
690
  mergeClaims: true,
686
691
  loadUserInfo: true,
@@ -700,7 +705,7 @@ class AuthManager {
700
705
  this.config = config;
701
706
  this.userManager = new oidcClientTs.UserManager(getAuthConfiguration(config));
702
707
  }
703
- mapOidcUserToDomainModel = (oidcUser) => {
708
+ static mapOidcUserToDomainModel = (oidcUser) => {
704
709
  const passport = oidcUser.profile?.passport;
705
710
  return {
706
711
  expired: oidcUser.expired,
@@ -721,7 +726,7 @@ class AuthManager {
721
726
  const oidcUser = await this.userManager.signinPopup({
722
727
  popupWindowFeatures,
723
728
  });
724
- return this.mapOidcUserToDomainModel(oidcUser);
729
+ return AuthManager.mapOidcUserToDomainModel(oidcUser);
725
730
  }, PassportErrorType.AUTHENTICATION_ERROR);
726
731
  }
727
732
  async loginCallback() {
@@ -740,7 +745,7 @@ class AuthManager {
740
745
  if (!oidcUser) {
741
746
  return null;
742
747
  }
743
- return this.mapOidcUserToDomainModel(oidcUser);
748
+ return AuthManager.mapOidcUserToDomainModel(oidcUser);
744
749
  }, PassportErrorType.SILENT_LOGIN_ERROR);
745
750
  }
746
751
  async getUser() {
@@ -749,7 +754,7 @@ class AuthManager {
749
754
  if (!oidcUser) {
750
755
  return null;
751
756
  }
752
- return this.mapOidcUserToDomainModel(oidcUser);
757
+ return AuthManager.mapOidcUserToDomainModel(oidcUser);
753
758
  }, PassportErrorType.NOT_LOGGED_IN_ERROR);
754
759
  }
755
760
  async requestRefreshTokenAfterRegistration() {
@@ -757,18 +762,18 @@ class AuthManager {
757
762
  const updatedUser = await retryWithDelay(async () => {
758
763
  const user = await this.userManager.signinSilent();
759
764
  const passportMetadata = user?.profile?.passport;
760
- const metadataExists = !!passportMetadata?.ether_key &&
761
- !!passportMetadata?.stark_key &&
762
- !!passportMetadata?.user_admin_key;
765
+ const metadataExists = !!passportMetadata?.ether_key
766
+ && !!passportMetadata?.stark_key
767
+ && !!passportMetadata?.user_admin_key;
763
768
  if (metadataExists) {
764
769
  return user;
765
770
  }
766
- return Promise.reject('user wallet addresses not exist');
771
+ return Promise.reject(new Error('user wallet addresses not exist'));
767
772
  });
768
773
  if (!updatedUser) {
769
774
  return null;
770
775
  }
771
- return this.mapOidcUserToDomainModel(updatedUser);
776
+ return AuthManager.mapOidcUserToDomainModel(updatedUser);
772
777
  }, PassportErrorType.REFRESH_TOKEN_ERROR);
773
778
  }
774
779
  }
@@ -807,12 +812,24 @@ var SendMessage;
807
812
  })(SendMessage || (SendMessage = {}));
808
813
  var TransactionTypes;
809
814
  (function (TransactionTypes) {
815
+ // TODO: remove this once the naming has been fixed
816
+ // eslint-disable-next-line @typescript-eslint/naming-convention
810
817
  TransactionTypes["CancelOrder"] = "delete:v1/orders";
818
+ // TODO: remove this once the naming has been fixed
819
+ // eslint-disable-next-line @typescript-eslint/naming-convention
811
820
  TransactionTypes["CreateOrder"] = "post:v1/orders";
821
+ // TODO: remove this once the naming has been fixed
822
+ // eslint-disable-next-line @typescript-eslint/naming-convention
812
823
  TransactionTypes["CreateTrade"] = "post:v1/trades";
824
+ // TODO: remove this once the naming has been fixed
825
+ // eslint-disable-next-line @typescript-eslint/naming-convention
813
826
  TransactionTypes["CreateTransfer"] = "post:v1/transfers";
827
+ // TODO: remove this once the naming has been fixed
828
+ // eslint-disable-next-line @typescript-eslint/naming-convention
814
829
  TransactionTypes["CreateBatchTransfer"] = "post:v2/transfers";
815
830
  })(TransactionTypes || (TransactionTypes = {}));
831
+ // TODO: remove this once the naming has been fixed
832
+ // eslint-disable-next-line @typescript-eslint/naming-convention
816
833
  const PassportEventType = 'imx_passport_confirmation';
817
834
 
818
835
  const openPopupCenter = ({ url, title, width, height, }) => {
@@ -832,10 +849,10 @@ const openPopupCenter = ({ url, title, width, height, }) => {
832
849
  return newWindow;
833
850
  };
834
851
 
835
- const ConfirmationWindowTitle = 'Confirm this transaction';
836
- const ConfirmationWindowHeight = 380;
837
- const ConfirmationWindowWidth = 480;
838
- const ConfirmationWindowClosedPollingDuration = 1000;
852
+ const CONFIRMATION_WINDOW_TITLE = 'Confirm this transaction';
853
+ const CONFIRMATION_WINDOW_HEIGHT = 380;
854
+ const CONFIRMATION_WINDOW_WIDTH = 480;
855
+ const CONFIRMATION_WINDOW_CLOSED_POLLING_DURATION = 1000;
839
856
  class ConfirmationScreen {
840
857
  config;
841
858
  constructor(config) {
@@ -851,12 +868,14 @@ class ConfirmationScreen {
851
868
  startTransaction(accessToken, transaction, popupOptions) {
852
869
  return new Promise((resolve, reject) => {
853
870
  const messageHandler = ({ data, origin }) => {
854
- if (origin != this.config.passportDomain ||
855
- data.eventType != PassportEventType) {
871
+ if (origin !== this.config.passportDomain
872
+ || data.eventType !== PassportEventType) {
856
873
  return;
857
874
  }
858
875
  switch (data.messageType) {
859
876
  case ReceiveMessage.CONFIRMATION_WINDOW_READY: {
877
+ // TODO: remove once fixed
878
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
860
879
  this.postMessage(confirmationWindow, accessToken, {
861
880
  messageType: SendMessage.TRANSACTION_START,
862
881
  messageData: transaction,
@@ -878,87 +897,87 @@ class ConfirmationScreen {
878
897
  window.addEventListener('message', messageHandler);
879
898
  const confirmationWindow = openPopupCenter({
880
899
  url: `${this.config.passportDomain}/transaction-confirmation`,
881
- title: ConfirmationWindowTitle,
882
- width: popupOptions?.width || ConfirmationWindowWidth,
883
- height: popupOptions?.height || ConfirmationWindowHeight,
900
+ title: CONFIRMATION_WINDOW_TITLE,
901
+ width: popupOptions?.width || CONFIRMATION_WINDOW_WIDTH,
902
+ height: popupOptions?.height || CONFIRMATION_WINDOW_HEIGHT,
884
903
  });
885
904
  // https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
886
- const timer = setInterval(function () {
905
+ const timer = setInterval(() => {
887
906
  if (confirmationWindow.closed) {
888
907
  clearInterval(timer);
889
908
  window.removeEventListener('message', messageHandler);
890
909
  resolve({ confirmed: false });
891
910
  }
892
- }, ConfirmationWindowClosedPollingDuration);
911
+ }, CONFIRMATION_WINDOW_CLOSED_POLLING_DURATION);
893
912
  });
894
913
  }
895
914
  }
896
915
 
897
916
  const ERC721$1 = 'ERC721';
898
- const transfer$1 = ({ request, transfersApi, starkSigner, user, passportConfig, }) => {
899
- return withPassportError(async () => {
900
- const transferAmount = request.type === ERC721$1 ? '1' : request.amount;
901
- const getSignableTransferRequest = {
902
- sender: user.etherKey,
903
- token: convertToSignableToken(request),
904
- amount: transferAmount,
905
- receiver: request.receiver,
906
- };
907
- const signableResult = await transfersApi.getSignableTransferV1({
908
- getSignableTransferRequest,
909
- });
910
- const confirmationScreen = new ConfirmationScreen(passportConfig);
911
- const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
912
- transactionType: TransactionTypes.CreateTransfer,
913
- transactionData: getSignableTransferRequest,
914
- });
915
- if (!confirmationResult.confirmed) {
916
- throw new Error('Transaction rejected by user');
917
- }
918
- const signableResultData = signableResult.data;
919
- const { payload_hash: payloadHash } = signableResultData;
920
- const starkSignature = await starkSigner.signMessage(payloadHash);
921
- const senderStarkKey = await starkSigner.getAddress();
922
- const transferSigningParams = {
923
- sender_stark_key: signableResultData.sender_stark_key || senderStarkKey,
924
- sender_vault_id: signableResultData.sender_vault_id,
925
- receiver_stark_key: signableResultData.receiver_stark_key,
926
- receiver_vault_id: signableResultData.receiver_vault_id,
927
- asset_id: signableResultData.asset_id,
928
- amount: signableResultData.amount,
929
- nonce: signableResultData.nonce,
930
- expiration_timestamp: signableResultData.expiration_timestamp,
931
- stark_signature: starkSignature,
932
- };
933
- const createTransferRequest = {
934
- createTransferRequest: transferSigningParams,
935
- };
936
- const headers = {
937
- Authorization: 'Bearer ' + user.accessToken,
938
- };
939
- const { data: responseData } = await transfersApi.createTransferV1(createTransferRequest, { headers });
940
- return {
941
- sent_signature: responseData.sent_signature,
942
- status: responseData.status?.toString(),
943
- time: responseData.time,
944
- transfer_id: responseData.transfer_id,
945
- };
946
- }, PassportErrorType.TRANSFER_ERROR);
947
- };
917
+ const transfer$1 = ({ request, transfersApi, starkSigner, user, passportConfig,
918
+ // TODO: remove this eslint disable once we have a better solution
919
+ // eslint-disable-next-line max-len
920
+ }) => withPassportError(async () => {
921
+ const transferAmount = request.type === ERC721$1 ? '1' : request.amount;
922
+ const getSignableTransferRequest = {
923
+ sender: user.etherKey,
924
+ token: convertToSignableToken(request),
925
+ amount: transferAmount,
926
+ receiver: request.receiver,
927
+ };
928
+ const signableResult = await transfersApi.getSignableTransferV1({
929
+ getSignableTransferRequest,
930
+ });
931
+ const confirmationScreen = new ConfirmationScreen(passportConfig);
932
+ const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
933
+ transactionType: TransactionTypes.CreateTransfer,
934
+ transactionData: getSignableTransferRequest,
935
+ });
936
+ if (!confirmationResult.confirmed) {
937
+ throw new Error('Transaction rejected by user');
938
+ }
939
+ const signableResultData = signableResult.data;
940
+ const { payload_hash: payloadHash } = signableResultData;
941
+ const starkSignature = await starkSigner.signMessage(payloadHash);
942
+ const senderStarkKey = await starkSigner.getAddress();
943
+ const transferSigningParams = {
944
+ sender_stark_key: signableResultData.sender_stark_key || senderStarkKey,
945
+ sender_vault_id: signableResultData.sender_vault_id,
946
+ receiver_stark_key: signableResultData.receiver_stark_key,
947
+ receiver_vault_id: signableResultData.receiver_vault_id,
948
+ asset_id: signableResultData.asset_id,
949
+ amount: signableResultData.amount,
950
+ nonce: signableResultData.nonce,
951
+ expiration_timestamp: signableResultData.expiration_timestamp,
952
+ stark_signature: starkSignature,
953
+ };
954
+ const createTransferRequest = {
955
+ createTransferRequest: transferSigningParams,
956
+ };
957
+ const headers = {
958
+ // eslint-disable-next-line @typescript-eslint/naming-convention
959
+ Authorization: `Bearer ${user.accessToken}`,
960
+ };
961
+ const { data: responseData } = await transfersApi.createTransferV1(createTransferRequest, { headers });
962
+ return {
963
+ sent_signature: responseData.sent_signature,
964
+ status: responseData.status?.toString(),
965
+ time: responseData.time,
966
+ transfer_id: responseData.transfer_id,
967
+ };
968
+ }, PassportErrorType.TRANSFER_ERROR);
948
969
  async function batchNftTransfer({ user, starkSigner, request, transfersApi, passportConfig, }) {
949
970
  return withPassportError(async () => {
950
971
  const ethAddress = user.etherKey;
951
- const signableRequests = request.map((nftTransfer) => {
952
- return {
953
- amount: '1',
954
- token: convertToSignableToken({
955
- type: ERC721$1,
956
- tokenId: nftTransfer.tokenId,
957
- tokenAddress: nftTransfer.tokenAddress,
958
- }),
959
- receiver: nftTransfer.receiver,
960
- };
961
- });
972
+ const signableRequests = request.map((nftTransfer) => ({
973
+ amount: '1',
974
+ token: convertToSignableToken({
975
+ type: ERC721$1,
976
+ tokenId: nftTransfer.tokenId,
977
+ tokenAddress: nftTransfer.tokenAddress,
978
+ }),
979
+ receiver: nftTransfer.receiver,
980
+ }));
962
981
  const getSignableTransferRequestV2 = {
963
982
  sender_ether_key: ethAddress,
964
983
  signable_requests: signableRequests,
@@ -993,7 +1012,8 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
993
1012
  requests,
994
1013
  };
995
1014
  const headers = {
996
- Authorization: 'Bearer ' + user.accessToken,
1015
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1016
+ Authorization: `Bearer ${user.accessToken}`,
997
1017
  };
998
1018
  const response = await transfersApi.createTransfer({
999
1019
  createTransferRequestV2: transferSigningParams,
@@ -1050,7 +1070,8 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, passportCo
1050
1070
  },
1051
1071
  };
1052
1072
  const headers = {
1053
- Authorization: 'Bearer ' + user.accessToken,
1073
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1074
+ Authorization: `Bearer ${user.accessToken}`,
1054
1075
  };
1055
1076
  const createOrderResponse = await ordersApi.createOrder(orderParams, {
1056
1077
  headers,
@@ -1079,7 +1100,8 @@ async function cancelOrder$1({ user, starkSigner, request, ordersApi, passportCo
1079
1100
  const { payload_hash: payloadHash } = getSignableCancelOrderResponse.data;
1080
1101
  const starkSignature = await starkSigner.signMessage(payloadHash);
1081
1102
  const headers = {
1082
- Authorization: 'Bearer ' + user.accessToken,
1103
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1104
+ Authorization: `Bearer ${user.accessToken}`,
1083
1105
  };
1084
1106
  const cancelOrderResponse = await ordersApi.cancelOrder({
1085
1107
  id: request.order_id.toString(),
@@ -1123,7 +1145,8 @@ async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, })
1123
1145
  stark_signature: starkSignature,
1124
1146
  };
1125
1147
  const headers = {
1126
- Authorization: 'Bearer ' + user.accessToken,
1148
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1149
+ Authorization: `Bearer ${user.accessToken}`,
1127
1150
  };
1128
1151
  const response = await exchangesApi.createExchangeTransfer({
1129
1152
  id: request.transactionID,
@@ -1179,7 +1202,8 @@ async function createTrade$1({ request, tradesApi, user, starkSigner, passportCo
1179
1202
  vault_id_sell: signableResultData.vault_id_sell,
1180
1203
  },
1181
1204
  };
1182
- const headers = { Authorization: 'Bearer ' + user.accessToken };
1205
+ // eslint-disable-next-line @typescript-eslint/naming-convention
1206
+ const headers = { Authorization: `Bearer ${user.accessToken}` };
1183
1207
  const { data: createTradeResponse } = await tradesApi.createTradeV3(tradeParams, {
1184
1208
  headers,
1185
1209
  });
@@ -1207,9 +1231,13 @@ class PassportImxProvider {
1207
1231
  passportConfig: this.passportConfig,
1208
1232
  });
1209
1233
  }
1234
+ // TODO: Remove once implemented
1235
+ // eslint-disable-next-line class-methods-use-this
1210
1236
  registerOffchain() {
1211
1237
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1212
1238
  }
1239
+ // TODO: Remove once implemented
1240
+ // eslint-disable-next-line class-methods-use-this
1213
1241
  isRegisteredOnchain() {
1214
1242
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1215
1243
  }
@@ -1257,14 +1285,18 @@ class PassportImxProvider {
1257
1285
  exchangesApi: this.immutableXClient.exchangeApi,
1258
1286
  });
1259
1287
  }
1260
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1288
+ // TODO: Remove once implemented
1289
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
1261
1290
  deposit(deposit) {
1262
1291
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1263
1292
  }
1264
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1293
+ // TODO: Remove once implemented
1294
+ // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
1265
1295
  prepareWithdrawal(request) {
1266
1296
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1267
1297
  }
1298
+ // TODO: Remove once implemented
1299
+ // eslint-disable-next-line class-methods-use-this
1268
1300
  completeWithdrawal(
1269
1301
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1270
1302
  starkPublicKey,
@@ -1327,20 +1359,21 @@ class PassportConfiguration {
1327
1359
  }
1328
1360
  else {
1329
1361
  switch (baseConfig.environment) {
1330
- case exports.Environment.SANDBOX: {
1331
- this.network = Networks.SANDBOX;
1362
+ case exports.Environment.PRODUCTION: {
1363
+ this.network = Networks.PRODUCTION;
1332
1364
  this.authenticationDomain = 'https://auth.immutable.com';
1333
1365
  this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1334
1366
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1335
- this.passportDomain = 'https://passport.sandbox.immutable.com';
1367
+ this.passportDomain = 'https://passport.immutable.com';
1336
1368
  break;
1337
1369
  }
1338
- case exports.Environment.PRODUCTION: {
1339
- this.network = Networks.PRODUCTION;
1370
+ case exports.Environment.SANDBOX:
1371
+ default: {
1372
+ this.network = Networks.SANDBOX;
1340
1373
  this.authenticationDomain = 'https://auth.immutable.com';
1341
1374
  this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1342
1375
  this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1343
- this.passportDomain = 'https://passport.immutable.com';
1376
+ this.passportDomain = 'https://passport.sandbox.immutable.com';
1344
1377
  break;
1345
1378
  }
1346
1379
  }
@@ -1348,12 +1381,12 @@ class PassportConfiguration {
1348
1381
  }
1349
1382
  }
1350
1383
 
1351
- const getStarkSigner = async (signer) => {
1352
- return withPassportError(async () => {
1353
- const privateKey = await coreSdk.generateLegacyStarkPrivateKey(signer);
1354
- return coreSdk.createStarkSigner(privateKey);
1355
- }, PassportErrorType.WALLET_CONNECTION_ERROR);
1356
- };
1384
+ // TODO: remove this eslint disable once we have a better solution
1385
+ // eslint-disable-next-line max-len
1386
+ const getStarkSigner = async (signer) => withPassportError(async () => {
1387
+ const privateKey = await coreSdk.generateLegacyStarkPrivateKey(signer);
1388
+ return coreSdk.createStarkSigner(privateKey);
1389
+ }, PassportErrorType.WALLET_CONNECTION_ERROR);
1357
1390
 
1358
1391
  async function registerPassport({ ethSigner, starkSigner, usersApi }, authorization) {
1359
1392
  return withPassportError(async () => {
@@ -1369,7 +1402,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
1369
1402
  const ethSignature = await signRaw(signableMessage, ethSigner);
1370
1403
  const starkSignature = await starkSigner.signMessage(payloadHash);
1371
1404
  const response = await usersApi.registerPassportUser({
1372
- authorization: `Bearer ` + authorization,
1405
+ authorization: `Bearer ${authorization}`,
1373
1406
  registerPassportUserRequest: {
1374
1407
  eth_signature: ethSignature,
1375
1408
  ether_key: userAddress,
@@ -1381,6 +1414,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
1381
1414
  }, PassportErrorType.USER_REGISTRATION_ERROR);
1382
1415
  }
1383
1416
 
1417
+ // TODO: Remove this once the dependency has been added
1384
1418
  class Passport {
1385
1419
  authManager;
1386
1420
  magicAdapter;
@@ -1390,11 +1424,10 @@ class Passport {
1390
1424
  this.config = new PassportConfiguration(passportModuleConfiguration);
1391
1425
  this.authManager = new AuthManager(this.config);
1392
1426
  this.magicAdapter = new MagicAdapter(this.config);
1393
- this.immutableXClient =
1394
- passportModuleConfiguration.overrides?.immutableXClient ||
1395
- new ImmutableXClient({
1396
- baseConfig: passportModuleConfiguration.baseConfig,
1397
- });
1427
+ this.immutableXClient = passportModuleConfiguration.overrides?.immutableXClient
1428
+ || new ImmutableXClient({
1429
+ baseConfig: passportModuleConfiguration.baseConfig,
1430
+ });
1398
1431
  }
1399
1432
  async getImxProvider(user) {
1400
1433
  if (!user || !user.idToken) {
@@ -2671,6 +2704,12 @@ exports.WalletFilterTypes = void 0;
2671
2704
  })(exports.WalletFilterTypes || (exports.WalletFilterTypes = {}));
2672
2705
 
2673
2706
 
2707
+ exports.SupportedFiatCurrencies = void 0;
2708
+ (function(SupportedFiatCurrencies) {
2709
+ SupportedFiatCurrencies["USD"] = "USD";
2710
+ })(exports.SupportedFiatCurrencies || (exports.SupportedFiatCurrencies = {}));
2711
+
2712
+
2674
2713
 
2675
2714
 
2676
2715
  /**
@@ -2688,6 +2727,9 @@ exports.WalletFilterTypes = void 0;
2688
2727
  CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
2689
2728
  CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
2690
2729
  CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
2730
+ CheckoutErrorType["FIAT_CONVERSION_ERROR"] = "FIAT_CONVERSION_ERROR";
2731
+ CheckoutErrorType["TOKEN_NOT_SUPPORTED_ERROR"] = "TOKEN_NOT_SUPPORTED_ERROR";
2732
+ CheckoutErrorType["FIAT_CURRENCY_NOT_SUPPORTED_ERROR"] = "FIAT_CURRENCY_NOT_SUPPORTED_ERROR";
2691
2733
  })(exports.CheckoutErrorType || (exports.CheckoutErrorType = {}));
2692
2734
  class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
2693
2735
  constructor(message, type, data){
@@ -2904,14 +2946,22 @@ var $cda6003506e4182e$exports = {};
2904
2946
  $cda6003506e4182e$exports = JSON.parse("[{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":137,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":1,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF\",\"chainId\":1,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":1,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":5,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x1facdd0165489f373255a90304650e15481b2c85\",\"chainId\":5,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Swap Coin\",\"symbol\":\"SWC\",\"decimals\":18,\"tokenFeatures\":[\"swap\",\"fakeFeature\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Bridge Coin\",\"symbol\":\"BDC\",\"decimals\":18,\"tokenFeatures\":[\"bridge\",\"fakeFeature\"]}]");
2905
2947
 
2906
2948
 
2907
- const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type = (exports.TokenFilterTypes).ALL , chainId: chainId , exclude: exclude }) {
2908
- // todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2909
- const filteredTokenList = ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
2949
+ const $efe60cea83bfc4e8$var$filterTokenList = function({ type: type , chainId: chainId , exclude: exclude }) {
2950
+ return ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
2951
+ const skipChainIdCheck = !chainId;
2910
2952
  const chainIdMatches = token.chainId == chainId;
2911
2953
  const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
2912
2954
  const allowAllTokens = type === (exports.TokenFilterTypes).ALL;
2913
2955
  const tokenAllowedForType = token.tokenFeatures.includes(type);
2914
- return chainIdMatches && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
2956
+ return (skipChainIdCheck || chainIdMatches) && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
2957
+ });
2958
+ };
2959
+ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type = (exports.TokenFilterTypes).ALL , chainId: chainId , exclude: exclude }) {
2960
+ // todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2961
+ const filteredTokenList = $efe60cea83bfc4e8$var$filterTokenList({
2962
+ type: type,
2963
+ chainId: chainId,
2964
+ exclude: exclude
2915
2965
  }).map((token)=>{
2916
2966
  const { chainId: chainId , tokenFeatures: tokenFeatures , ...tokenInfo } = token;
2917
2967
  return tokenInfo;
@@ -3124,9 +3174,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
3124
3174
  function $parcel$export(e, n, v, s) {
3125
3175
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3126
3176
  }
3127
- var $88e4c575901cd68c$exports = {};
3177
+ var $207ed853f11d19d5$exports = {};
3128
3178
 
3129
- $parcel$export($88e4c575901cd68c$exports, "IMTBLWidgetEvents", () => exports.IMTBLWidgetEvents);
3179
+ $parcel$export($207ed853f11d19d5$exports, "IMTBLWidgetEvents", () => exports.IMTBLWidgetEvents);
3130
3180
  exports.IMTBLWidgetEvents = void 0;
3131
3181
  (function(IMTBLWidgetEvents) {
3132
3182
  IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
@@ -3137,9 +3187,9 @@ exports.IMTBLWidgetEvents = void 0;
3137
3187
  })(exports.IMTBLWidgetEvents || (exports.IMTBLWidgetEvents = {}));
3138
3188
 
3139
3189
 
3140
- var $d71a87afc3136184$exports = {};
3190
+ var $a85ecdbd885c58ad$exports = {};
3141
3191
 
3142
- $parcel$export($d71a87afc3136184$exports, "ConnectEventType", () => exports.ConnectEventType);
3192
+ $parcel$export($a85ecdbd885c58ad$exports, "ConnectEventType", () => exports.ConnectEventType);
3143
3193
  exports.ConnectEventType = void 0;
3144
3194
  (function(ConnectEventType) {
3145
3195
  ConnectEventType["SUCCESS"] = "success";
@@ -3148,9 +3198,9 @@ exports.ConnectEventType = void 0;
3148
3198
  })(exports.ConnectEventType || (exports.ConnectEventType = {}));
3149
3199
 
3150
3200
 
3151
- var $9d0f1783d4d36e8a$exports = {};
3201
+ var $77b6aac5c353d4a9$exports = {};
3152
3202
 
3153
- $parcel$export($9d0f1783d4d36e8a$exports, "WalletEventType", () => exports.WalletEventType);
3203
+ $parcel$export($77b6aac5c353d4a9$exports, "WalletEventType", () => exports.WalletEventType);
3154
3204
  //wallet widget events
3155
3205
  exports.WalletEventType = void 0;
3156
3206
  (function(WalletEventType) {
@@ -3159,9 +3209,9 @@ exports.WalletEventType = void 0;
3159
3209
  })(exports.WalletEventType || (exports.WalletEventType = {}));
3160
3210
 
3161
3211
 
3162
- var $5d497088f13bb116$exports = {};
3212
+ var $53d219e7f6bf0cd6$exports = {};
3163
3213
 
3164
- $parcel$export($5d497088f13bb116$exports, "SwapEventType", () => exports.SwapEventType);
3214
+ $parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => exports.SwapEventType);
3165
3215
  exports.SwapEventType = void 0;
3166
3216
  (function(SwapEventType) {
3167
3217
  SwapEventType["SUCCESS"] = "success";
@@ -3169,9 +3219,9 @@ exports.SwapEventType = void 0;
3169
3219
  })(exports.SwapEventType || (exports.SwapEventType = {}));
3170
3220
 
3171
3221
 
3172
- var $28a5fdc2f5e6c742$exports = {};
3222
+ var $15cc9e120aa6f3bf$exports = {};
3173
3223
 
3174
- $parcel$export($28a5fdc2f5e6c742$exports, "BridgeEventType", () => exports.BridgeEventType);
3224
+ $parcel$export($15cc9e120aa6f3bf$exports, "BridgeEventType", () => exports.BridgeEventType);
3175
3225
  exports.BridgeEventType = void 0;
3176
3226
  (function(BridgeEventType) {
3177
3227
  BridgeEventType["CLOSE_WIDGET"] = "close-widget";
@@ -3180,9 +3230,9 @@ exports.BridgeEventType = void 0;
3180
3230
  })(exports.BridgeEventType || (exports.BridgeEventType = {}));
3181
3231
 
3182
3232
 
3183
- var $ede253beebe0de4a$exports = {};
3233
+ var $98cbcca465beec95$exports = {};
3184
3234
 
3185
- $parcel$export($ede253beebe0de4a$exports, "BuyEventType", () => exports.BuyEventType);
3235
+ $parcel$export($98cbcca465beec95$exports, "BuyEventType", () => exports.BuyEventType);
3186
3236
  exports.BuyEventType = void 0;
3187
3237
  (function(BuyEventType) {
3188
3238
  BuyEventType["SUCCESS"] = "success";
@@ -3192,12 +3242,12 @@ exports.BuyEventType = void 0;
3192
3242
  })(exports.BuyEventType || (exports.BuyEventType = {}));
3193
3243
 
3194
3244
 
3195
- var $9234b4c577442a97$exports = {};
3196
-
3197
- $parcel$export($9234b4c577442a97$exports, "Network", () => exports.Network);
3198
- $parcel$export($9234b4c577442a97$exports, "WidgetTheme", () => exports.WidgetTheme);
3199
- $parcel$export($9234b4c577442a97$exports, "ConnectionProviders", () => exports.ConnectionProviders);
3245
+ var $14d7a2bbb79e0dae$exports = {};
3200
3246
 
3247
+ $parcel$export($14d7a2bbb79e0dae$exports, "Network", () => exports.Network);
3248
+ $parcel$export($14d7a2bbb79e0dae$exports, "WidgetTheme", () => exports.WidgetTheme);
3249
+ $parcel$export($14d7a2bbb79e0dae$exports, "WidgetConnectionProviders", () => exports.WidgetConnectionProviders);
3250
+ $parcel$export($14d7a2bbb79e0dae$exports, "CheckoutWidgetTagNames", () => exports.CheckoutWidgetTagNames);
3201
3251
  exports.Network = void 0;
3202
3252
  (function(Network) {
3203
3253
  Network["ETHEREUM"] = "Ethereum";
@@ -3210,6 +3260,163 @@ exports.WidgetTheme = void 0;
3210
3260
  WidgetTheme["DARK"] = "dark";
3211
3261
  WidgetTheme["CUSTOM"] = "custom";
3212
3262
  })(exports.WidgetTheme || (exports.WidgetTheme = {}));
3263
+ exports.WidgetConnectionProviders = void 0;
3264
+ (function(WidgetConnectionProviders) {
3265
+ WidgetConnectionProviders["METAMASK"] = "metamask";
3266
+ })(exports.WidgetConnectionProviders || (exports.WidgetConnectionProviders = {}));
3267
+ exports.CheckoutWidgetTagNames = void 0;
3268
+ (function(CheckoutWidgetTagNames) {
3269
+ CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
3270
+ CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
3271
+ CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
3272
+ CheckoutWidgetTagNames["BUY"] = "imtbl-buy";
3273
+ CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
3274
+ CheckoutWidgetTagNames["EXAMPLe"] = "imtbl-example";
3275
+ })(exports.CheckoutWidgetTagNames || (exports.CheckoutWidgetTagNames = {}));
3276
+
3277
+
3278
+ var $1f969328e5988c99$exports = {};
3279
+
3280
+ $parcel$export($1f969328e5988c99$exports, "BridgeReact", () => $1f969328e5988c99$export$30f61ebf204c69f6);
3281
+
3282
+
3283
+
3284
+ function $1f969328e5988c99$export$30f61ebf204c69f6(props) {
3285
+ const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , fromNetwork: fromNetwork } = props;
3286
+ const config = window.ImtblCheckoutWidgetConfig;
3287
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-bridge", {
3288
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3289
+ theme: config.theme ?? (exports.WidgetTheme).DARK,
3290
+ fromContractAddress: fromContractAddress ?? "",
3291
+ fromNetwork: fromNetwork ?? "",
3292
+ amount: amount ?? ""
3293
+ });
3294
+ }
3295
+
3296
+
3297
+ var $f22931ca9e2f35b6$exports = {};
3298
+
3299
+ $parcel$export($f22931ca9e2f35b6$exports, "BuyReact", () => $f22931ca9e2f35b6$export$d13582032b79b401);
3300
+
3301
+
3302
+
3303
+ function $f22931ca9e2f35b6$export$d13582032b79b401(props) {
3304
+ const { providerPreference: providerPreference , orderId: orderId } = props;
3305
+ const config = window.ImtblCheckoutWidgetConfig;
3306
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-buy", {
3307
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3308
+ theme: config.theme ?? (exports.WidgetTheme).DARK,
3309
+ orderId: orderId
3310
+ });
3311
+ }
3312
+
3313
+
3314
+ var $fa90757d8d7a0962$exports = {};
3315
+
3316
+ $parcel$export($fa90757d8d7a0962$exports, "CheckoutWidgets", () => $fa90757d8d7a0962$export$af210a0808087845);
3317
+ $parcel$export($fa90757d8d7a0962$exports, "UpdateConfig", () => $fa90757d8d7a0962$export$bf1548ba7e61c17f);
3318
+ $parcel$export($fa90757d8d7a0962$exports, "SetProvider", () => $fa90757d8d7a0962$export$931068bc678f0d73);
3319
+ function $fa90757d8d7a0962$export$af210a0808087845(config) {
3320
+ var checkoutWidgetJS = document.createElement("script");
3321
+ checkoutWidgetJS.setAttribute("src", "http://localhost:3000/lib/js/imtbl-checkout.js");
3322
+ document.head.appendChild(checkoutWidgetJS);
3323
+ window.ImtblCheckoutWidgetConfig = config;
3324
+ }
3325
+ function $fa90757d8d7a0962$export$bf1548ba7e61c17f(config) {
3326
+ window.ImtblCheckoutWidgetConfig = config;
3327
+ }
3328
+ function $fa90757d8d7a0962$export$931068bc678f0d73(tagName, provider) {
3329
+ if (!provider) {
3330
+ console.error("no provider parsed");
3331
+ return;
3332
+ }
3333
+ const elements = document.getElementsByTagName(tagName);
3334
+ const widget = elements[0];
3335
+ let attempts = 0;
3336
+ const maxAttempts = 10;
3337
+ let timer;
3338
+ const attemptToSetProvider = ()=>{
3339
+ try {
3340
+ widget.setProvider(provider);
3341
+ window.clearInterval(timer);
3342
+ } catch (err) {
3343
+ attempts++;
3344
+ if (attempts >= maxAttempts) {
3345
+ window.clearInterval(timer);
3346
+ console.error("failed to set the provider");
3347
+ }
3348
+ }
3349
+ };
3350
+ timer = window.setInterval(attemptToSetProvider, 10);
3351
+ attemptToSetProvider();
3352
+ }
3353
+
3354
+
3355
+ var $f2083cd30e2f5c56$exports = {};
3356
+
3357
+ $parcel$export($f2083cd30e2f5c56$exports, "ConnectReact", () => $f2083cd30e2f5c56$export$49d62957f420a1e2);
3358
+
3359
+
3360
+
3361
+ function $f2083cd30e2f5c56$export$49d62957f420a1e2(props) {
3362
+ const { providerPreference: providerPreference } = props;
3363
+ const config = window.ImtblCheckoutWidgetConfig;
3364
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-connect", {
3365
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3366
+ theme: config.theme ?? (exports.WidgetTheme).DARK
3367
+ });
3368
+ }
3369
+
3370
+
3371
+ var $a4fbb8e3a6aeff58$exports = {};
3372
+
3373
+ $parcel$export($a4fbb8e3a6aeff58$exports, "SwapReact", () => $a4fbb8e3a6aeff58$export$971e031379577f4);
3374
+
3375
+
3376
+
3377
+ function $a4fbb8e3a6aeff58$export$971e031379577f4(props) {
3378
+ const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , toContractAddress: toContractAddress } = props;
3379
+ const config = window.ImtblCheckoutWidgetConfig;
3380
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-swap", {
3381
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3382
+ theme: config.theme ?? (exports.WidgetTheme).DARK,
3383
+ fromContractAddress: fromContractAddress ?? "",
3384
+ toContractAddress: toContractAddress ?? "",
3385
+ amount: amount ?? ""
3386
+ });
3387
+ }
3388
+
3389
+
3390
+ var $89d55ace0f8f1c07$exports = {};
3391
+
3392
+ $parcel$export($89d55ace0f8f1c07$exports, "WalletReact", () => $89d55ace0f8f1c07$export$ceaac94f34dba154);
3393
+
3394
+
3395
+
3396
+ function $89d55ace0f8f1c07$export$ceaac94f34dba154(props) {
3397
+ const { providerPreference: providerPreference } = props;
3398
+ const config = window.ImtblCheckoutWidgetConfig;
3399
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-wallet", {
3400
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3401
+ theme: config.theme ?? (exports.WidgetTheme).DARK
3402
+ });
3403
+ }
3404
+
3405
+
3406
+ var $d087956fd1002f80$exports = {};
3407
+
3408
+ $parcel$export($d087956fd1002f80$exports, "ExampleReact", () => $d087956fd1002f80$export$fa517eee6594d26c);
3409
+
3410
+
3411
+
3412
+ function $d087956fd1002f80$export$fa517eee6594d26c(props) {
3413
+ const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , fromNetwork: fromNetwork } = props;
3414
+ const config = window.ImtblCheckoutWidgetConfig;
3415
+ return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-example", {
3416
+ providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3417
+ theme: config.theme ?? (exports.WidgetTheme).DARK
3418
+ });
3419
+ }
3213
3420
 
3214
3421
  Object.defineProperty(exports, 'imxClientCreateStarkSigner', {
3215
3422
  enumerable: true,
@@ -3219,7 +3426,12 @@ Object.defineProperty(exports, 'imxClientGenerateLegacyStarkPrivateKey', {
3219
3426
  enumerable: true,
3220
3427
  get: function () { return coreSdk.generateLegacyStarkPrivateKey; }
3221
3428
  });
3429
+ exports.BridgeReact = $1f969328e5988c99$export$30f61ebf204c69f6;
3430
+ exports.BuyReact = $f22931ca9e2f35b6$export$d13582032b79b401;
3222
3431
  exports.Checkout = $a8cb37a3fc8eb863$export$1f60ba4ec72508a0;
3432
+ exports.CheckoutWidgets = $fa90757d8d7a0962$export$af210a0808087845;
3433
+ exports.ConnectReact = $f2083cd30e2f5c56$export$49d62957f420a1e2;
3434
+ exports.ExampleReact = $d087956fd1002f80$export$fa517eee6594d26c;
3223
3435
  exports.GenericIMXProvider = GenericIMXProvider;
3224
3436
  exports.ImmutableConfiguration = ImmutableConfiguration;
3225
3437
  exports.ImmutableXClient = ImmutableXClient;
@@ -3227,3 +3439,7 @@ exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
3227
3439
  exports.Passport = Passport;
3228
3440
  exports.PassportError = PassportError;
3229
3441
  exports.ProviderConfiguration = ProviderConfiguration;
3442
+ exports.SetProvider = $fa90757d8d7a0962$export$931068bc678f0d73;
3443
+ exports.SwapReact = $a4fbb8e3a6aeff58$export$971e031379577f4;
3444
+ exports.UpdateConfig = $fa90757d8d7a0962$export$bf1548ba7e61c17f;
3445
+ exports.WalletReact = $89d55ace0f8f1c07$export$ceaac94f34dba154;