@imtbl/sdk 0.0.1-alpha → 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -10,7 +10,6 @@ var detectEthereumProvider = require('@metamask/detect-provider');
10
10
  var oidcClientTs = require('oidc-client-ts');
11
11
  var magicSdk = require('magic-sdk');
12
12
  var oidc = require('@magic-ext/oidc');
13
- var providers = require('@ethersproject/providers');
14
13
 
15
14
  function _interopNamespaceDefault(e) {
16
15
  var n = Object.create(null);
@@ -33,21 +32,31 @@ var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
33
32
 
34
33
  exports.Environment = void 0;
35
34
  (function (Environment) {
36
- Environment["PRODUCTION"] = "production";
35
+ Environment["DEVELOPMENT"] = "development";
37
36
  Environment["SANDBOX"] = "sandbox";
37
+ Environment["PRODUCTION"] = "production";
38
38
  })(exports.Environment || (exports.Environment = {}));
39
- class ImmutableConfiguration {
40
- environment;
41
- apiKey;
42
- constructor(options) {
43
- this.environment = options.environment;
44
- this.apiKey = options.apiKey;
39
+ class Configuration {
40
+ starkExConfig;
41
+ constructor(config) {
42
+ this.starkExConfig = config;
43
+ }
44
+ getStarkExConfig() {
45
+ return this.starkExConfig;
45
46
  }
46
47
  }
48
+ const PRODUCTION = {
49
+ ...coreSdk.Config.PRODUCTION,
50
+ env: exports.Environment.PRODUCTION,
51
+ };
52
+ const SANDBOX = {
53
+ ...coreSdk.Config.SANDBOX,
54
+ env: exports.Environment.SANDBOX,
55
+ };
47
56
 
48
57
  /* eslint-disable @typescript-eslint/no-unused-vars */
49
58
  const StarkExAPIFactory = (config) => {
50
- const imtblClient = new coreSdk.ImmutableX(config.immutableXConfig);
59
+ const imtblClient = new coreSdk.ImmutableX(config.getStarkExConfig());
51
60
  const { deposit, registerOffchain, isRegisteredOnchain, prepareWithdrawal, completeWithdrawal, createOrder, cancelOrder, createTrade, transfer, batchNftTransfer, ...StarkEx } = imtblClient;
52
61
  return { ...StarkEx };
53
62
  };
@@ -132,9 +141,9 @@ async function validateChain(signer, config) {
132
141
  }
133
142
 
134
143
  async function transfer$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
135
- await validateChain(ethSigner, config.immutableXConfig);
144
+ await validateChain(ethSigner, config.getStarkExConfig());
136
145
  const ethAddress = await ethSigner.getAddress();
137
- const transfersApi = new coreSdk.TransfersApi(config.immutableXConfig.apiConfiguration);
146
+ const transfersApi = new coreSdk.TransfersApi(config.getStarkExConfig().apiConfiguration);
138
147
  const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
139
148
  const signableResult = await transfersApi.getSignableTransferV1({
140
149
  getSignableTransferRequest: {
@@ -172,9 +181,9 @@ async function transfer$1({ signers: { ethSigner, starkExSigner }, request, conf
172
181
  };
173
182
  }
174
183
  async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, config, }) {
175
- await validateChain(ethSigner, config.immutableXConfig);
184
+ await validateChain(ethSigner, config.getStarkExConfig());
176
185
  const ethAddress = await ethSigner.getAddress();
177
- const transfersApi = new coreSdk.TransfersApi(config.immutableXConfig.apiConfiguration);
186
+ const transfersApi = new coreSdk.TransfersApi(config.getStarkExConfig().apiConfiguration);
178
187
  const signableRequests = request.map((nftTransfer) => {
179
188
  return {
180
189
  amount: '1',
@@ -228,9 +237,9 @@ async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, c
228
237
  }
229
238
 
230
239
  async function createOrder$1({ signers, request, config, }) {
231
- await validateChain(signers.ethSigner, config.immutableXConfig);
240
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
232
241
  const ethAddress = await signers.ethSigner.getAddress();
233
- const ordersApi = new coreSdk.OrdersApi(config.immutableXConfig.apiConfiguration);
242
+ const ordersApi = new coreSdk.OrdersApi(config.getStarkExConfig().apiConfiguration);
234
243
  const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
235
244
  const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
236
245
  const getSignableOrderRequest = {
@@ -273,7 +282,7 @@ async function createOrder$1({ signers, request, config, }) {
273
282
  };
274
283
  }
275
284
  async function cancelOrder$1({ signers, request, config, }) {
276
- const ordersApi = new coreSdk.OrdersApi(config.immutableXConfig.apiConfiguration);
285
+ const ordersApi = new coreSdk.OrdersApi(config.getStarkExConfig().apiConfiguration);
277
286
  const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
278
287
  getSignableCancelOrderRequest: {
279
288
  order_id: request.order_id,
@@ -299,8 +308,8 @@ async function cancelOrder$1({ signers, request, config, }) {
299
308
  }
300
309
 
301
310
  async function registerOffchain(signers, config) {
302
- await validateChain(signers.ethSigner, config.immutableXConfig);
303
- const usersApi = new coreSdk.UsersApi(config.immutableXConfig.apiConfiguration);
311
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
312
+ const usersApi = new coreSdk.UsersApi(config.getStarkExConfig().apiConfiguration);
304
313
  const userAddress = await signers.ethSigner.getAddress();
305
314
  const starkPublicKey = await signers.starkExSigner.getAddress();
306
315
  const signableResult = await usersApi.getSignableRegistrationOffchain({
@@ -323,8 +332,8 @@ async function registerOffchain(signers, config) {
323
332
  return registeredUser.data;
324
333
  }
325
334
  async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
326
- await validateChain(ethSigner, config.immutableXConfig);
327
- const registrationContract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
335
+ await validateChain(ethSigner, config.getStarkExConfig());
336
+ const registrationContract = coreSdk.Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
328
337
  try {
329
338
  return await registrationContract.isRegistered(starkPublicKey);
330
339
  }
@@ -399,10 +408,10 @@ async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
399
408
 
400
409
  async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
401
410
  const etherKey = await ethSigner.getAddress();
402
- const starkExConfig = config.immutableXConfig;
411
+ const starkExConfig = config.getStarkExConfig();
403
412
  const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
404
413
  const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
405
- const contract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
414
+ const contract = coreSdk.Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
406
415
  const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
407
416
  return ethSigner.sendTransaction(populatedTransaction);
408
417
  }
@@ -412,8 +421,8 @@ async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config
412
421
  return ethSigner.sendTransaction(populatedTransaction);
413
422
  }
414
423
  async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
415
- await validateChain(ethSigner, config.immutableXConfig);
416
- const starkExConfig = config.immutableXConfig;
424
+ await validateChain(ethSigner, config.getStarkExConfig());
425
+ const starkExConfig = config.getStarkExConfig();
417
426
  const assetType = await getEncodeAssetInfo('asset', 'ERC20', starkExConfig, {
418
427
  token_address: token.tokenAddress,
419
428
  });
@@ -450,7 +459,7 @@ function getMintingBlob(token) {
450
459
  return encUtils__namespace.sanitizeHex(encUtils__namespace.utf8ToHex(`{${id}}:{${blueprint}}`));
451
460
  }
452
461
  async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
453
- const starkExConfig = config.immutableXConfig;
462
+ const starkExConfig = config.getStarkExConfig();
454
463
  const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', starkExConfig, {
455
464
  id: token.data.id,
456
465
  token_address: token.data.tokenAddress,
@@ -479,7 +488,7 @@ async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, token
479
488
  return ethSigner.sendTransaction(populatedTransaction);
480
489
  }
481
490
  async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
482
- const starkExConfig = config.immutableXConfig;
491
+ const starkExConfig = config.getStarkExConfig();
483
492
  const assetType = await getEncodeAssetInfo('asset', 'ERC721', starkExConfig, {
484
493
  token_id: token.tokenId,
485
494
  token_address: token.tokenAddress,
@@ -493,10 +502,10 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
493
502
  }
494
503
  }
495
504
  async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
496
- await validateChain(ethSigner, config.immutableXConfig);
505
+ await validateChain(ethSigner, config.getStarkExConfig());
497
506
  const tokenAddress = token.tokenAddress;
498
507
  const tokenId = token.tokenId;
499
- const starkExConfig = config.immutableXConfig;
508
+ const starkExConfig = config.getStarkExConfig();
500
509
  const mintsApi = new coreSdk.MintsApi(starkExConfig.apiConfiguration);
501
510
  return await mintsApi
502
511
  .getMintableTokenDetailsByClientTokenId({
@@ -534,8 +543,8 @@ async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config)
534
543
  return ethSigner.sendTransaction(populatedTransaction);
535
544
  }
536
545
  async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
537
- await validateChain(ethSigner, config.immutableXConfig);
538
- const starkExConfig = config.immutableXConfig;
546
+ await validateChain(ethSigner, config.getStarkExConfig());
547
+ const starkExConfig = config.getStarkExConfig();
539
548
  const assetType = await getEncodeAssetInfo('asset', 'ETH', starkExConfig);
540
549
  const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
541
550
  if (!isRegistered) {
@@ -547,9 +556,10 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
547
556
  }
548
557
 
549
558
  async function prepareWithdrawal({ signers, withdrawal, config, }) {
559
+ const starkExConfig = config.getStarkExConfig();
550
560
  return prepareWithdrawalAction({
551
561
  signers,
552
- config: config.immutableXConfig,
562
+ config: starkExConfig,
553
563
  ...withdrawal,
554
564
  });
555
565
  }
@@ -575,9 +585,9 @@ async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, toke
575
585
  }
576
586
 
577
587
  async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
578
- await validateChain(ethSigner, config.immutableXConfig);
588
+ await validateChain(ethSigner, config.getStarkExConfig());
579
589
  const ethAddress = await ethSigner.getAddress();
580
- const tradesApi = new coreSdk.TradesApi(config.immutableXConfig.apiConfiguration);
590
+ const tradesApi = new coreSdk.TradesApi(config.getStarkExConfig().apiConfiguration);
581
591
  const signableResult = await tradesApi.getSignableTrade({
582
592
  getSignableTradeRequest: {
583
593
  user: ethAddress,
@@ -612,13 +622,13 @@ async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, c
612
622
  }
613
623
 
614
624
  async function depositEth({ signers: { ethSigner }, deposit, config, }) {
615
- await validateChain(ethSigner, config.immutableXConfig);
625
+ await validateChain(ethSigner, config.getStarkExConfig());
616
626
  const user = await ethSigner.getAddress();
617
627
  const data = {
618
628
  decimals: 18,
619
629
  };
620
630
  const amount = units.parseUnits(deposit.amount, 'wei');
621
- const starkExConfig = config.immutableXConfig;
631
+ const starkExConfig = config.getStarkExConfig();
622
632
  const depositsApi = new coreSdk.DepositsApi(starkExConfig.apiConfiguration);
623
633
  const encodingApi = new coreSdk.EncodingApi(starkExConfig.apiConfiguration);
624
634
  const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
@@ -666,8 +676,8 @@ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, v
666
676
  }
667
677
 
668
678
  async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
669
- await validateChain(ethSigner, config.immutableXConfig);
670
- const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
679
+ await validateChain(ethSigner, config.getStarkExConfig());
680
+ const { apiConfiguration, ethConfiguration } = config.getStarkExConfig();
671
681
  const user = await ethSigner.getAddress();
672
682
  const tokensApi = new coreSdk.TokensApi(apiConfiguration);
673
683
  const depositsApi = new coreSdk.DepositsApi(apiConfiguration);
@@ -734,12 +744,12 @@ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetT
734
744
  }
735
745
 
736
746
  async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
737
- await validateChain(ethSigner, config.immutableXConfig);
747
+ await validateChain(ethSigner, config.getStarkExConfig());
738
748
  const user = await ethSigner.getAddress();
739
- const { immutableXConfig } = config;
740
- const depositsApi = new coreSdk.DepositsApi(immutableXConfig.apiConfiguration);
741
- const encodingApi = new coreSdk.EncodingApi(immutableXConfig.apiConfiguration);
742
- const usersApi = new coreSdk.UsersApi(immutableXConfig.apiConfiguration);
749
+ const starkExConfig = config.getStarkExConfig();
750
+ const depositsApi = new coreSdk.DepositsApi(starkExConfig.apiConfiguration);
751
+ const encodingApi = new coreSdk.EncodingApi(starkExConfig.apiConfiguration);
752
+ const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
743
753
  const data = {
744
754
  token_address: deposit.tokenAddress,
745
755
  token_id: deposit.tokenId,
@@ -775,18 +785,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
775
785
  const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
776
786
  // Approve whether an amount of token from an account can be spent by a third-party account
777
787
  const tokenContract = coreSdk.Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
778
- const operator = immutableXConfig.ethConfiguration.coreContractAddress;
788
+ const operator = starkExConfig.ethConfiguration.coreContractAddress;
779
789
  const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
780
790
  if (!isApprovedForAll) {
781
791
  await tokenContract.setApprovalForAll(operator, true);
782
792
  }
783
793
  if (!isRegistered) {
784
794
  const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
785
- const coreContract = coreSdk.Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
795
+ const coreContract = coreSdk.Contracts.Core.connect(starkExConfig.ethConfiguration.coreContractAddress, ethSigner);
786
796
  // Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
787
797
  await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
788
798
  }
789
- return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
799
+ return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, starkExConfig);
790
800
  }
791
801
  async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
792
802
  const coreContract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
@@ -806,8 +816,8 @@ async function deposit({ signers, deposit, config }) {
806
816
  }
807
817
 
808
818
  async function exchangeTransfer$1({ signers, request, config, }) {
809
- await validateChain(signers.ethSigner, config.immutableXConfig);
810
- const exchangeApi = new coreSdk.ExchangesApi(config.immutableXConfig.apiConfiguration);
819
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
820
+ const exchangeApi = new coreSdk.ExchangesApi(config.getStarkExConfig().apiConfiguration);
811
821
  const ethAddress = await signers.ethSigner.getAddress();
812
822
  const transferAmount = request.amount;
813
823
  const signableResult = await exchangeApi.getExchangeSignableTransfer({
@@ -1030,6 +1040,7 @@ class ImxSigner {
1030
1040
 
1031
1041
  const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
1032
1042
  const IMX_WALLET_IFRAME_HOSTS = {
1043
+ [exports.Environment.DEVELOPMENT]: 'http://localhost:8080',
1033
1044
  [exports.Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
1034
1045
  [exports.Environment.PRODUCTION]: 'https://wallets.immutable.com',
1035
1046
  };
@@ -1127,11 +1138,12 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
1127
1138
  super(config, ethSigner, starkExSigner);
1128
1139
  }
1129
1140
  static async connect(config) {
1141
+ const starkExConfig = config.getStarkExConfig();
1130
1142
  return await withProviderError(async () => {
1131
1143
  const metaMaskProvider = await connect$1({
1132
- chainID: config.immutableXConfig.ethConfiguration.chainID,
1144
+ chainID: starkExConfig.ethConfiguration.chainID,
1133
1145
  });
1134
- this.imxSigner = await connect(metaMaskProvider, config.baseConfig.environment);
1146
+ this.imxSigner = await connect(metaMaskProvider, starkExConfig.env);
1135
1147
  return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
1136
1148
  }, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
1137
1149
  }
@@ -1153,29 +1165,6 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
1153
1165
  }
1154
1166
  }
1155
1167
 
1156
- class ProviderConfiguration {
1157
- immutableXConfig;
1158
- baseConfig;
1159
- constructor({ baseConfig, overrides }) {
1160
- this.baseConfig = baseConfig;
1161
- if (overrides) {
1162
- this.immutableXConfig = overrides.immutableXConfig;
1163
- }
1164
- else {
1165
- switch (baseConfig.environment) {
1166
- case exports.Environment.SANDBOX: {
1167
- this.immutableXConfig = coreSdk.Config.SANDBOX;
1168
- break;
1169
- }
1170
- case exports.Environment.PRODUCTION: {
1171
- this.immutableXConfig = coreSdk.Config.PRODUCTION;
1172
- break;
1173
- }
1174
- }
1175
- }
1176
- }
1177
- }
1178
-
1179
1168
  var PassportErrorType;
1180
1169
  (function (PassportErrorType) {
1181
1170
  PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
@@ -1228,17 +1217,17 @@ const retryWithDelay = async (fn, options) => {
1228
1217
  }
1229
1218
  };
1230
1219
 
1231
- const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
1220
+ const getAuthConfiguration = ({ oidcConfiguration, }) => {
1232
1221
  const baseConfiguration = {
1233
- authority: authenticationDomain,
1222
+ authority: oidcConfiguration.authenticationDomain,
1234
1223
  redirect_uri: oidcConfiguration.redirectUri,
1235
1224
  popup_redirect_uri: oidcConfiguration.redirectUri,
1236
1225
  client_id: oidcConfiguration.clientId,
1237
1226
  metadata: {
1238
- authorization_endpoint: `${authenticationDomain}/authorize`,
1239
- token_endpoint: `${authenticationDomain}/oauth/token`,
1240
- userinfo_endpoint: `${authenticationDomain}/userinfo`,
1241
- end_session_endpoint: `${authenticationDomain}/v2/logout` +
1227
+ authorization_endpoint: `${oidcConfiguration.authenticationDomain}/authorize`,
1228
+ token_endpoint: `${oidcConfiguration.authenticationDomain}/oauth/token`,
1229
+ userinfo_endpoint: `${oidcConfiguration.authenticationDomain}/userinfo`,
1230
+ end_session_endpoint: `${oidcConfiguration.authenticationDomain}/v2/logout` +
1242
1231
  `?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
1243
1232
  `&client_id=${oidcConfiguration.clientId}`,
1244
1233
  },
@@ -1276,10 +1265,7 @@ class AuthManager {
1276
1265
  };
1277
1266
  async login() {
1278
1267
  return withPassportError(async () => {
1279
- const popupWindowFeatures = { width: 400, height: 420 };
1280
- const oidcUser = await this.userManager.signinPopup({
1281
- popupWindowFeatures,
1282
- });
1268
+ const oidcUser = await this.userManager.signinPopup();
1283
1269
  return this.mapOidcUserToDomainModel(oidcUser);
1284
1270
  }, PassportErrorType.AUTHENTICATION_ERROR);
1285
1271
  }
@@ -1362,12 +1348,26 @@ var TransactionTypes;
1362
1348
  const PassportEventType = 'imx_passport_confirmation';
1363
1349
 
1364
1350
  const openPopupCenter = ({ url, title, width, height, }) => {
1365
- const left = Math.max(0, Math.round(window.screenX + (window.outerWidth - width) / 2));
1366
- const top = Math.max(0, Math.round(window.screenY + (window.outerHeight - height) / 2));
1351
+ // Fixes dual-screen position Most browsers Firefox
1352
+ const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
1353
+ const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
1354
+ const windowWidth = window.innerWidth
1355
+ ? window.innerWidth
1356
+ : document.documentElement.clientWidth
1357
+ ? document.documentElement.clientWidth
1358
+ : screen.width;
1359
+ const windowHeight = window.innerHeight
1360
+ ? window.innerHeight
1361
+ : document.documentElement.clientHeight
1362
+ ? document.documentElement.clientHeight
1363
+ : screen.height;
1364
+ const systemZoom = windowWidth / window.screen.availWidth;
1365
+ const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
1366
+ const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
1367
1367
  const newWindow = window.open(url, title, `
1368
1368
  scrollbars=yes,
1369
- width=${width},
1370
- height=${height},
1369
+ width=${width / systemZoom},
1370
+ height=${height / systemZoom},
1371
1371
  top=${top},
1372
1372
  left=${left}
1373
1373
  `);
@@ -1379,8 +1379,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
1379
1379
  };
1380
1380
 
1381
1381
  const ConfirmationWindowTitle = 'Confirm this transaction';
1382
- const ConfirmationWindowHeight = 380;
1383
- const ConfirmationWindowWidth = 480;
1382
+ const ConfirmationWindowHeight = 600;
1383
+ const ConfirmationWindowWidth = 600;
1384
1384
  const ConfirmationWindowClosedPollingDuration = 1000;
1385
1385
  class ConfirmationScreen {
1386
1386
  config;
@@ -1394,7 +1394,7 @@ class ConfirmationScreen {
1394
1394
  ...message,
1395
1395
  }, this.config.passportDomain);
1396
1396
  }
1397
- startTransaction(accessToken, transaction, popupOptions) {
1397
+ startTransaction(accessToken, transaction) {
1398
1398
  return new Promise((resolve, reject) => {
1399
1399
  const messageHandler = ({ data, origin }) => {
1400
1400
  if (origin != this.config.passportDomain ||
@@ -1425,8 +1425,8 @@ class ConfirmationScreen {
1425
1425
  const confirmationWindow = openPopupCenter({
1426
1426
  url: `${this.config.passportDomain}/transaction-confirmation`,
1427
1427
  title: ConfirmationWindowTitle,
1428
- width: popupOptions?.width || ConfirmationWindowWidth,
1429
- height: popupOptions?.height || ConfirmationWindowHeight,
1428
+ width: ConfirmationWindowWidth,
1429
+ height: ConfirmationWindowHeight,
1430
1430
  });
1431
1431
  // https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
1432
1432
  const timer = setInterval(function () {
@@ -1513,11 +1513,10 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
1513
1513
  getSignableTransferRequestV2,
1514
1514
  });
1515
1515
  const confirmationScreen = new ConfirmationScreen(passportConfig);
1516
- const popupWindowSize = { width: 480, height: 784 };
1517
1516
  const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
1518
1517
  transactionType: TransactionTypes.CreateBatchTransfer,
1519
1518
  transactionData: getSignableTransferRequestV2,
1520
- }, popupWindowSize);
1519
+ });
1521
1520
  if (!confirmationResult.confirmed) {
1522
1521
  throw new Error('Transaction rejected by user');
1523
1522
  }
@@ -1746,7 +1745,7 @@ class PassportImxProvider {
1746
1745
  this.starkSigner = starkSigner;
1747
1746
  this.passportConfig = passportConfig;
1748
1747
  const apiConfig = new coreSdk.Configuration({
1749
- basePath: passportConfig.imxApiBasePath,
1748
+ basePath: passportConfig.imxAPIConfiguration.basePath,
1750
1749
  });
1751
1750
  this.transfersApi = new coreSdk.TransfersApi(apiConfig);
1752
1751
  this.ordersApi = new coreSdk.OrdersApi(apiConfig);
@@ -1838,75 +1837,67 @@ var Networks;
1838
1837
  Networks["SANDBOX"] = "goerli";
1839
1838
  })(Networks || (Networks = {}));
1840
1839
 
1841
- const validateConfiguration = (configuration, requiredKeys, prefix) => {
1840
+ const Config = {
1841
+ PRODUCTION: {
1842
+ network: Networks.PRODUCTION,
1843
+ authenticationDomain: 'https://auth.immutable.com',
1844
+ magicPublishableApiKey: 'pk_live_10F423798A540ED7',
1845
+ magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
1846
+ baseIMXApiPath: 'https://api.x.immutable.com',
1847
+ passportDomain: 'https://passport.immutable.com',
1848
+ },
1849
+ SANDBOX: {
1850
+ network: Networks.SANDBOX,
1851
+ authenticationDomain: 'https://auth.immutable.com',
1852
+ magicPublishableApiKey: 'pk_live_10F423798A540ED7',
1853
+ magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
1854
+ baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
1855
+ passportDomain: 'https://passport.sandbox.immutable.com',
1856
+ },
1857
+ };
1858
+ const validateConfiguration = (configurationName, configuration, requiredKeys) => {
1859
+ if (!configuration) {
1860
+ throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
1861
+ }
1842
1862
  const missingKeys = requiredKeys
1843
1863
  .map((key) => !configuration[key] && key)
1844
1864
  .filter((n) => n)
1845
1865
  .join(', ');
1846
1866
  if (missingKeys !== '') {
1847
- const errorMessage = prefix
1848
- ? `${prefix} - ${missingKeys} cannot be null`
1849
- : `${missingKeys} cannot be null`;
1850
- throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
1867
+ throw new PassportError(`${configurationName} - ${missingKeys} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
1851
1868
  }
1852
1869
  };
1853
- class PassportConfiguration {
1854
- network;
1855
- authenticationDomain;
1856
- passportDomain;
1857
- magicPublishableApiKey;
1858
- magicProviderId;
1859
- imxApiBasePath;
1860
- oidcConfiguration;
1861
- baseConfig;
1862
- constructor({ baseConfig, overrides, ...oidcConfiguration }) {
1863
- validateConfiguration(oidcConfiguration, [
1864
- 'clientId',
1865
- 'logoutRedirectUri',
1866
- 'redirectUri',
1867
- ]);
1868
- this.oidcConfiguration = oidcConfiguration;
1869
- this.baseConfig = baseConfig;
1870
- if (overrides) {
1871
- validateConfiguration(overrides, [
1872
- 'network',
1873
- 'authenticationDomain',
1874
- 'magicPublishableApiKey',
1875
- 'magicProviderId',
1876
- 'passportDomain',
1877
- 'imxApiBasePath',
1878
- ], 'overrides');
1879
- this.network = overrides.network;
1880
- this.authenticationDomain = overrides.authenticationDomain;
1881
- this.passportDomain = overrides.passportDomain;
1882
- this.magicPublishableApiKey = overrides.magicPublishableApiKey;
1883
- this.magicProviderId = overrides.magicProviderId;
1884
- this.imxApiBasePath = overrides.imxApiBasePath;
1885
- }
1886
- else {
1887
- switch (baseConfig.environment) {
1888
- case exports.Environment.SANDBOX: {
1889
- this.network = Networks.SANDBOX;
1890
- this.authenticationDomain = 'https://auth.immutable.com';
1891
- this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1892
- this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1893
- this.passportDomain = 'https://passport.immutable.com';
1894
- this.imxApiBasePath = 'https://api.x.immutable.com';
1895
- break;
1896
- }
1897
- case exports.Environment.PRODUCTION: {
1898
- this.network = Networks.PRODUCTION;
1899
- this.authenticationDomain = 'https://auth.immutable.com';
1900
- this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1901
- this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1902
- this.passportDomain = 'https://passport.sandbox.immutable.com';
1903
- this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
1904
- break;
1905
- }
1906
- }
1907
- }
1908
- }
1909
- }
1870
+ const getPassportConfiguration = (environmentConfiguration, oidcConfiguration) => {
1871
+ validateConfiguration('EnvironmentConfiguration', environmentConfiguration, [
1872
+ 'network',
1873
+ 'authenticationDomain',
1874
+ 'magicPublishableApiKey',
1875
+ 'magicProviderId',
1876
+ 'passportDomain',
1877
+ ]);
1878
+ validateConfiguration('OidcConfiguration', oidcConfiguration, [
1879
+ 'clientId',
1880
+ 'logoutRedirectUri',
1881
+ 'redirectUri',
1882
+ ]);
1883
+ return {
1884
+ network: environmentConfiguration.network,
1885
+ oidcConfiguration: {
1886
+ authenticationDomain: environmentConfiguration.authenticationDomain,
1887
+ clientId: oidcConfiguration.clientId,
1888
+ logoutRedirectUri: oidcConfiguration.logoutRedirectUri,
1889
+ redirectUri: oidcConfiguration.redirectUri,
1890
+ scope: oidcConfiguration.scope,
1891
+ audience: oidcConfiguration.audience,
1892
+ },
1893
+ imxAPIConfiguration: {
1894
+ basePath: environmentConfiguration.baseIMXApiPath,
1895
+ },
1896
+ passportDomain: environmentConfiguration.passportDomain,
1897
+ magicPublishableApiKey: environmentConfiguration.magicPublishableApiKey,
1898
+ magicProviderId: environmentConfiguration.magicProviderId,
1899
+ };
1900
+ };
1910
1901
 
1911
1902
  const getStarkSigner = async (signer) => {
1912
1903
  return withPassportError(async () => {
@@ -1945,8 +1936,8 @@ class Passport {
1945
1936
  authManager;
1946
1937
  magicAdapter;
1947
1938
  config;
1948
- constructor(passportModuleConfiguration) {
1949
- const passportConfiguration = new PassportConfiguration(passportModuleConfiguration);
1939
+ constructor(environmentConfiguration, oidcConfiguration) {
1940
+ const passportConfiguration = getPassportConfiguration(environmentConfiguration, oidcConfiguration);
1950
1941
  this.config = passportConfiguration;
1951
1942
  this.authManager = new AuthManager(this.config);
1952
1943
  this.magicAdapter = new MagicAdapter(this.config);
@@ -1994,7 +1985,7 @@ class Passport {
1994
1985
  }
1995
1986
  async registerUser(userAdminKeySigner, starkSigner, jwt) {
1996
1987
  const configuration = new coreSdk.Configuration({
1997
- basePath: this.config.imxApiBasePath,
1988
+ basePath: this.config.imxAPIConfiguration.basePath,
1998
1989
  });
1999
1990
  const usersApi = new coreSdk.UsersApi(configuration);
2000
1991
  await registerPassport({
@@ -2010,567 +2001,12 @@ class Passport {
2010
2001
  }
2011
2002
  }
2012
2003
 
2013
- function $parcel$interopDefault(a) {
2014
- return a && a.__esModule ? a.default : a;
2015
- }
2016
-
2017
- const $762782b6c862d954$export$db5daa1b5156ccfe = [
2018
- {
2019
- constant: true,
2020
- inputs: [],
2021
- name: "name",
2022
- outputs: [
2023
- {
2024
- name: "",
2025
- type: "string"
2026
- }
2027
- ],
2028
- payable: false,
2029
- type: "function"
2030
- },
2031
- {
2032
- constant: true,
2033
- inputs: [],
2034
- name: "decimals",
2035
- outputs: [
2036
- {
2037
- name: "",
2038
- type: "uint8"
2039
- }
2040
- ],
2041
- payable: false,
2042
- type: "function"
2043
- },
2044
- {
2045
- constant: true,
2046
- inputs: [
2047
- {
2048
- name: "_owner",
2049
- type: "address"
2050
- }
2051
- ],
2052
- name: "balanceOf",
2053
- outputs: [
2054
- {
2055
- name: "balance",
2056
- type: "uint256"
2057
- }
2058
- ],
2059
- payable: false,
2060
- type: "function"
2061
- },
2062
- {
2063
- constant: true,
2064
- inputs: [],
2065
- name: "symbol",
2066
- outputs: [
2067
- {
2068
- name: "",
2069
- type: "string"
2070
- }
2071
- ],
2072
- payable: false,
2073
- type: "function"
2074
- }
2075
- ];
2076
-
2077
-
2078
- exports.ConnectionProviders = void 0;
2079
- (function(ConnectionProviders) {
2080
- ConnectionProviders["METAMASK"] = "metamask";
2081
- })(exports.ConnectionProviders || (exports.ConnectionProviders = {}));
2082
-
2083
-
2084
- exports.ChainId = void 0;
2085
- (function(ChainId) {
2086
- ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
2087
- ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
2088
- ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
2089
- })(exports.ChainId || (exports.ChainId = {}));
2090
- const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
2091
- [exports.ChainId.ETHEREUM]: {
2092
- chainIdHex: "0x1",
2093
- chainName: "Ethereum",
2094
- rpcUrls: [
2095
- "https://mainnet.infura.io/v3/"
2096
- ],
2097
- nativeCurrency: {
2098
- name: "Ethereum",
2099
- symbol: "ETH",
2100
- decimals: 18
2101
- },
2102
- blockExplorerUrls: [
2103
- "https://etherscan.io/"
2104
- ]
2105
- },
2106
- [exports.ChainId.GOERLI]: {
2107
- chainIdHex: "0x5",
2108
- chainName: "Goerli",
2109
- rpcUrls: [
2110
- "https://goerli.infura.io/v3/"
2111
- ],
2112
- nativeCurrency: {
2113
- name: "Goerli Eth",
2114
- symbol: "ETH",
2115
- decimals: 18
2116
- },
2117
- blockExplorerUrls: [
2118
- "https://goerli.etherscan.io/"
2119
- ]
2120
- },
2121
- [exports.ChainId.POLYGON]: {
2122
- chainIdHex: "0x89",
2123
- chainName: "Polygon",
2124
- rpcUrls: [
2125
- "https://polygon-rpc.com"
2126
- ],
2127
- nativeCurrency: {
2128
- name: "MATIC",
2129
- symbol: "MATIC",
2130
- decimals: 18
2131
- },
2132
- blockExplorerUrls: [
2133
- "https://polygonscan.com/"
2134
- ]
2135
- }
2136
- };
2137
-
2138
-
2139
- exports.TokenFilterTypes = void 0;
2140
- (function(TokenFilterTypes) {
2141
- TokenFilterTypes["SWAP"] = "swap";
2142
- TokenFilterTypes["BRIDGE"] = "bridge";
2143
- TokenFilterTypes["ALL"] = "all";
2144
- })(exports.TokenFilterTypes || (exports.TokenFilterTypes = {}));
2145
-
2146
-
2147
-
2148
-
2149
- const $4f91c5f280efe242$export$a130407f3423b97d = {
2150
- CHECK_CONNECTION: "eth_accounts",
2151
- CONNECT: "eth_requestAccounts",
2152
- ADD_NETWORK: "wallet_addEthereumChain",
2153
- SWITCH_NETWORK: "wallet_switchEthereumChain"
2154
- };
2155
- exports.WalletFilterTypes = void 0;
2156
- (function(WalletFilterTypes) {
2157
- WalletFilterTypes["ALL"] = "all";
2158
- WalletFilterTypes["DESKTOP"] = "desktop";
2159
- WalletFilterTypes["MOBILE"] = "mobile";
2160
- })(exports.WalletFilterTypes || (exports.WalletFilterTypes = {}));
2161
-
2162
-
2163
-
2164
-
2165
- let $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
2166
- (function(CheckoutErrorType) {
2167
- CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
2168
- CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
2169
- CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
2170
- CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
2171
- CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
2172
- CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
2173
- CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
2174
- CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
2175
- })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
2176
- class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
2177
- constructor(message, type){
2178
- super(message);
2179
- this.type = type;
2180
- }
2181
- }
2182
- const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
2183
- try {
2184
- return await fn();
2185
- } catch (error) {
2186
- const errorMessage = customError.message || `${error.message}` || "UnknownError";
2187
- throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type);
2188
- }
2189
- };
2190
-
2191
-
2192
-
2193
-
2194
-
2195
-
2196
-
2197
- async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
2198
- const network = await provider.getNetwork();
2199
- if (!Object.values((exports.ChainId)).includes(network.chainId)) // return empty details
2200
- return {};
2201
- const chainIdNetworkInfo = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[network.chainId];
2202
- const networkInfo = {
2203
- name: chainIdNetworkInfo.chainName,
2204
- chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
2205
- nativeCurrency: chainIdNetworkInfo.nativeCurrency
2206
- };
2207
- return networkInfo;
2208
- }
2209
- async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
2210
- if (!Object.values((exports.ChainId)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`${chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
2211
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2212
- // WT-1146 - Refer to the README in this folder for explantion on the switch network flow
2213
- try {
2214
- await $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId);
2215
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2216
- } catch (err) {
2217
- if (err.message.includes("Unrecognized chain ID")) try {
2218
- await $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId);
2219
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2220
- } catch (err) {
2221
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
2222
- }
2223
- else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
2224
- }
2225
- // we can assume that if the above succeeds then user has successfully
2226
- // switched to the network specified
2227
- const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId];
2228
- return {
2229
- network: {
2230
- name: newNetwork.chainName,
2231
- chainId: parseInt(newNetwork.chainIdHex, 16),
2232
- nativeCurrency: newNetwork.nativeCurrency
2233
- }
2234
- };
2235
- }
2236
- // these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
2237
- // make sure to check if(provider.provider?.request) in the exported function and throw an error
2238
- async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
2239
- if (provider.provider?.request) return await provider.provider.request({
2240
- method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
2241
- params: [
2242
- {
2243
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
2244
- }
2245
- ]
2246
- });
2247
- }
2248
- async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
2249
- if (provider.provider?.request) {
2250
- const addNetwork = {
2251
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
2252
- chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
2253
- rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
2254
- nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
2255
- blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
2256
- };
2257
- return await provider.provider.request({
2258
- method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
2259
- params: [
2260
- addNetwork
2261
- ]
2262
- });
2263
- }
2264
- }
2265
-
2266
-
2267
-
2268
-
2269
-
2270
- var $cda6003506e4182e$exports = {};
2271
- $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\"]}]");
2272
-
2273
-
2274
- const $efe60cea83bfc4e8$export$473cec51305fdae8 = function({ type: type = (exports.TokenFilterTypes).ALL , chainId: chainId , exclude: exclude }) {
2275
- // todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2276
- const filteredTokenList = ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
2277
- const chainIdMatches = token.chainId == chainId;
2278
- const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
2279
- const allowAllTokens = type === (exports.TokenFilterTypes).ALL;
2280
- const tokenAllowedForType = token.tokenFeatures.includes(type);
2281
- return chainIdMatches && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
2282
- }).map((token)=>{
2283
- const { chainId: chainId , tokenFeatures: tokenFeatures , ...tokenInfo } = token;
2284
- return tokenInfo;
2285
- });
2286
- return {
2287
- tokens: filteredTokenList
2288
- };
2289
- };
2290
-
2291
-
2292
-
2293
-
2294
- const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
2295
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2296
- const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
2297
- const balance = await provider.getBalance(walletAddress);
2298
- return {
2299
- balance: balance,
2300
- formattedBalance: (ethers.utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
2301
- token: networkInfo.nativeCurrency
2302
- };
2303
- }, {
2304
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
2305
- });
2306
- };
2307
- async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
2308
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2309
- const contract = new (ethers.Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
2310
- const name = await contract.name();
2311
- const symbol = await contract.symbol();
2312
- const balance = await contract.balanceOf(walletAddress);
2313
- const decimals = await contract.decimals();
2314
- const formattedBalance = (ethers.utils).formatUnits(balance, decimals);
2315
- return {
2316
- balance: balance,
2317
- formattedBalance: formattedBalance,
2318
- token: {
2319
- name: name,
2320
- symbol: symbol,
2321
- decimals: decimals,
2322
- address: contractAddress
2323
- }
2324
- };
2325
- }, {
2326
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
2327
- });
2328
- }
2329
- const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
2330
- if (!Object.values((exports.ChainId)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
2331
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2332
- const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)({
2333
- type: (exports.TokenFilterTypes).ALL,
2334
- chainId: chainId
2335
- });
2336
- const allBalancePromises = [];
2337
- allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
2338
- tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
2339
- const balanceResults = await Promise.allSettled(allBalancePromises);
2340
- const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
2341
- return {
2342
- balances: getBalanceResults
2343
- };
2344
- };
2345
-
2346
-
2347
-
2348
-
2349
-
2350
- /* eslint-disable @typescript-eslint/no-explicit-any */
2351
-
2352
-
2353
-
2354
- async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
2355
- const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
2356
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2357
- const accounts = await provider.provider.request({
2358
- method: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
2359
- params: []
2360
- });
2361
- // accounts[0] will have the active account if connected.
2362
- return {
2363
- isConnected: accounts && accounts.length > 0,
2364
- walletAddress: accounts[0] ?? ""
2365
- };
2366
- }
2367
- async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
2368
- const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
2369
- await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2370
- if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
2371
- // this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
2372
- await web3Provider.provider.request({
2373
- method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
2374
- params: []
2375
- });
2376
- }, {
2377
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR
2378
- });
2379
- return web3Provider;
2380
- }
2381
- async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
2382
- let web3Provider = null;
2383
- switch(providerPreference){
2384
- case (exports.ConnectionProviders).METAMASK:
2385
- web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
2386
- break;
2387
- default:
2388
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference was not detected", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CONNECT_PROVIDER_ERROR);
2389
- }
2390
- return web3Provider;
2391
- }
2392
- async function $c99672cf2294e839$var$getMetaMaskProvider() {
2393
- const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2394
- return await (detectEthereumProvider)();
2395
- }, {
2396
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
2397
- });
2398
- if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
2399
- return new (providers.Web3Provider)(provider);
2400
- }
2401
-
2402
-
2403
-
2404
-
2405
-
2406
- var $6f3c55a615003cbf$exports = {};
2407
- $6f3c55a615003cbf$exports = JSON.parse('[{"connectionProvider":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["mobile","desktop"]},{"connectionProvider":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile"]},{"connectionProvider":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["desktop"]}]');
2408
-
2409
-
2410
- async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = (exports.WalletFilterTypes).ALL , exclude: exclude }) {
2411
- // todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2412
- const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
2413
- const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.connectionProvider).includes(wallet.connectionProvider);
2414
- const allowAllWallets = type === (exports.WalletFilterTypes).ALL;
2415
- const walletsAllowedForType = wallet.platform.includes(type);
2416
- return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
2417
- }).map((wallet)=>{
2418
- const { platform: platform , ...walletInfo } = wallet;
2419
- return walletInfo;
2420
- });
2421
- return {
2422
- allowedWallets: filteredWalletsList
2423
- };
2424
- }
2425
-
2426
-
2427
-
2428
-
2429
-
2430
-
2431
- const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
2432
- const { provider: provider , transaction: transaction } = params;
2433
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2434
- const transactionResponse = await provider.getSigner().sendTransaction(transaction);
2435
- return {
2436
- transactionResponse: transactionResponse
2437
- };
2438
- }, {
2439
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).TRANSACTION_ERROR
2440
- });
2441
- };
2442
-
2443
-
2444
-
2445
-
2446
- class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
2447
- async checkIsWalletConnected(params) {
2448
- return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
2449
- }
2450
- async connect(params) {
2451
- const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
2452
- const network = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
2453
- return {
2454
- provider: provider,
2455
- network: network
2456
- };
2457
- }
2458
- async switchNetwork(params) {
2459
- return await ($de192de6ef100f9f$export$b827d9418aeb5dbd)(params.provider, params.chainId);
2460
- }
2461
- async getBalance(params) {
2462
- if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
2463
- return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
2464
- }
2465
- async getAllBalances(params) {
2466
- return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
2467
- }
2468
- getTokenAllowList(params) {
2469
- return $efe60cea83bfc4e8$export$473cec51305fdae8(params);
2470
- }
2471
- async getWalletsAllowList(params) {
2472
- return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
2473
- }
2474
- async sendTransaction(params) {
2475
- return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
2476
- }
2477
- }
2478
-
2479
- function $parcel$export(e, n, v, s) {
2480
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
2481
- }
2482
- var $88e4c575901cd68c$exports = {};
2483
-
2484
- $parcel$export($88e4c575901cd68c$exports, "IMTBLWidgetEvents", () => exports.IMTBLWidgetEvents);
2485
- exports.IMTBLWidgetEvents = void 0;
2486
- (function(IMTBLWidgetEvents) {
2487
- IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
2488
- IMTBLWidgetEvents["IMTBL_WALLET_WIDGET_EVENT"] = "imtbl-wallet-widget";
2489
- IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
2490
- IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
2491
- IMTBLWidgetEvents["IMTBL_BUY_WIDGET_EVENT"] = "imtbl-buy-widget";
2492
- })(exports.IMTBLWidgetEvents || (exports.IMTBLWidgetEvents = {}));
2493
-
2494
-
2495
- var $d71a87afc3136184$exports = {};
2496
-
2497
- $parcel$export($d71a87afc3136184$exports, "ConnectEventType", () => exports.ConnectEventType);
2498
- exports.ConnectEventType = void 0;
2499
- (function(ConnectEventType) {
2500
- ConnectEventType["SUCCESS"] = "success";
2501
- ConnectEventType["FAILURE"] = "failure";
2502
- })(exports.ConnectEventType || (exports.ConnectEventType = {}));
2503
-
2504
-
2505
- var $9d0f1783d4d36e8a$exports = {};
2506
-
2507
- $parcel$export($9d0f1783d4d36e8a$exports, "WalletEventType", () => exports.WalletEventType);
2508
- //wallet widget events
2509
- exports.WalletEventType = void 0;
2510
- (function(WalletEventType) {
2511
- WalletEventType["CLOSE_WIDGET"] = "close-widget";
2512
- WalletEventType["NETWORK_SWITCH"] = "network-switch";
2513
- })(exports.WalletEventType || (exports.WalletEventType = {}));
2514
-
2515
-
2516
- var $5d497088f13bb116$exports = {};
2517
-
2518
- $parcel$export($5d497088f13bb116$exports, "SwapEventType", () => exports.SwapEventType);
2519
- exports.SwapEventType = void 0;
2520
- (function(SwapEventType) {
2521
- SwapEventType["SUCCESS"] = "success";
2522
- SwapEventType["FAILURE"] = "failure";
2523
- })(exports.SwapEventType || (exports.SwapEventType = {}));
2524
-
2525
-
2526
- var $28a5fdc2f5e6c742$exports = {};
2527
-
2528
- $parcel$export($28a5fdc2f5e6c742$exports, "BridgeEventType", () => exports.BridgeEventType);
2529
- exports.BridgeEventType = void 0;
2530
- (function(BridgeEventType) {
2531
- BridgeEventType["CLOSE_WIDGET"] = "close-widget";
2532
- BridgeEventType["SUCCESS"] = "success";
2533
- BridgeEventType["FAILURE"] = "failure";
2534
- })(exports.BridgeEventType || (exports.BridgeEventType = {}));
2535
-
2536
-
2537
- var $ede253beebe0de4a$exports = {};
2538
-
2539
- $parcel$export($ede253beebe0de4a$exports, "BuyEventType", () => exports.BuyEventType);
2540
- exports.BuyEventType = void 0;
2541
- (function(BuyEventType) {
2542
- BuyEventType["SUCCESS"] = "success";
2543
- BuyEventType["FAILURE"] = "failure";
2544
- BuyEventType["NOT_CONNECTED"] = "not_connected";
2545
- BuyEventType["CLOSE"] = "close";
2546
- })(exports.BuyEventType || (exports.BuyEventType = {}));
2547
-
2548
-
2549
- var $9234b4c577442a97$exports = {};
2550
-
2551
- $parcel$export($9234b4c577442a97$exports, "Network", () => exports.Network);
2552
- $parcel$export($9234b4c577442a97$exports, "WidgetTheme", () => exports.WidgetTheme);
2553
- $parcel$export($9234b4c577442a97$exports, "ConnectionProviders", () => exports.ConnectionProviders);
2554
-
2555
- exports.Network = void 0;
2556
- (function(Network) {
2557
- Network["ETHEREUM"] = "Ethereum";
2558
- Network["GOERLI"] = "Goerli";
2559
- Network["POLYGON"] = "Polygon";
2560
- })(exports.Network || (exports.Network = {}));
2561
- exports.WidgetTheme = void 0;
2562
- (function(WidgetTheme) {
2563
- WidgetTheme["LIGHT"] = "light";
2564
- WidgetTheme["DARK"] = "dark";
2565
- WidgetTheme["CUSTOM"] = "custom";
2566
- })(exports.WidgetTheme || (exports.WidgetTheme = {}));
2567
-
2568
- exports.Checkout = $a8cb37a3fc8eb863$export$1f60ba4ec72508a0;
2004
+ exports.Config = Config;
2005
+ exports.Configuration = Configuration;
2569
2006
  exports.GenericIMXProvider = GenericIMXProvider;
2570
- exports.ImmutableConfiguration = ImmutableConfiguration;
2571
2007
  exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
2008
+ exports.PRODUCTION = PRODUCTION;
2572
2009
  exports.Passport = Passport;
2573
- exports.PassportConfiguration = PassportConfiguration;
2574
2010
  exports.PassportError = PassportError;
2575
- exports.ProviderConfiguration = ProviderConfiguration;
2011
+ exports.SANDBOX = SANDBOX;
2576
2012
  exports.StarkExAPIFactory = StarkExAPIFactory;