@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.js CHANGED
@@ -1,32 +1,41 @@
1
- import { ImmutableX, Config, TransfersApi, OrdersApi, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi, Configuration, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
1
+ import { Config as Config$1, ImmutableX, TransfersApi, OrdersApi, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi, Configuration as Configuration$1, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
2
2
  import BN from 'bn.js';
3
3
  import * as encUtils from 'enc-utils';
4
4
  import { parseUnits } from '@ethersproject/units';
5
5
  import { BigNumber } from '@ethersproject/bignumber';
6
- import { ethers, utils, Contract } from 'ethers';
6
+ import { ethers } from 'ethers';
7
7
  import detectEthereumProvider from '@metamask/detect-provider';
8
8
  import { UserManager } from 'oidc-client-ts';
9
9
  import { Magic } from 'magic-sdk';
10
10
  import { OpenIdExtension } from '@magic-ext/oidc';
11
- import { Web3Provider } from '@ethersproject/providers';
12
11
 
13
12
  var Environment;
14
13
  (function (Environment) {
15
- Environment["PRODUCTION"] = "production";
14
+ Environment["DEVELOPMENT"] = "development";
16
15
  Environment["SANDBOX"] = "sandbox";
16
+ Environment["PRODUCTION"] = "production";
17
17
  })(Environment || (Environment = {}));
18
- class ImmutableConfiguration {
19
- environment;
20
- apiKey;
21
- constructor(options) {
22
- this.environment = options.environment;
23
- this.apiKey = options.apiKey;
18
+ class Configuration {
19
+ starkExConfig;
20
+ constructor(config) {
21
+ this.starkExConfig = config;
22
+ }
23
+ getStarkExConfig() {
24
+ return this.starkExConfig;
24
25
  }
25
26
  }
27
+ const PRODUCTION = {
28
+ ...Config$1.PRODUCTION,
29
+ env: Environment.PRODUCTION,
30
+ };
31
+ const SANDBOX = {
32
+ ...Config$1.SANDBOX,
33
+ env: Environment.SANDBOX,
34
+ };
26
35
 
27
36
  /* eslint-disable @typescript-eslint/no-unused-vars */
28
37
  const StarkExAPIFactory = (config) => {
29
- const imtblClient = new ImmutableX(config.immutableXConfig);
38
+ const imtblClient = new ImmutableX(config.getStarkExConfig());
30
39
  const { deposit, registerOffchain, isRegisteredOnchain, prepareWithdrawal, completeWithdrawal, createOrder, cancelOrder, createTrade, transfer, batchNftTransfer, ...StarkEx } = imtblClient;
31
40
  return { ...StarkEx };
32
41
  };
@@ -111,9 +120,9 @@ async function validateChain(signer, config) {
111
120
  }
112
121
 
113
122
  async function transfer$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
114
- await validateChain(ethSigner, config.immutableXConfig);
123
+ await validateChain(ethSigner, config.getStarkExConfig());
115
124
  const ethAddress = await ethSigner.getAddress();
116
- const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
125
+ const transfersApi = new TransfersApi(config.getStarkExConfig().apiConfiguration);
117
126
  const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
118
127
  const signableResult = await transfersApi.getSignableTransferV1({
119
128
  getSignableTransferRequest: {
@@ -151,9 +160,9 @@ async function transfer$1({ signers: { ethSigner, starkExSigner }, request, conf
151
160
  };
152
161
  }
153
162
  async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, config, }) {
154
- await validateChain(ethSigner, config.immutableXConfig);
163
+ await validateChain(ethSigner, config.getStarkExConfig());
155
164
  const ethAddress = await ethSigner.getAddress();
156
- const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
165
+ const transfersApi = new TransfersApi(config.getStarkExConfig().apiConfiguration);
157
166
  const signableRequests = request.map((nftTransfer) => {
158
167
  return {
159
168
  amount: '1',
@@ -207,9 +216,9 @@ async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, c
207
216
  }
208
217
 
209
218
  async function createOrder$1({ signers, request, config, }) {
210
- await validateChain(signers.ethSigner, config.immutableXConfig);
219
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
211
220
  const ethAddress = await signers.ethSigner.getAddress();
212
- const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
221
+ const ordersApi = new OrdersApi(config.getStarkExConfig().apiConfiguration);
213
222
  const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
214
223
  const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
215
224
  const getSignableOrderRequest = {
@@ -252,7 +261,7 @@ async function createOrder$1({ signers, request, config, }) {
252
261
  };
253
262
  }
254
263
  async function cancelOrder$1({ signers, request, config, }) {
255
- const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
264
+ const ordersApi = new OrdersApi(config.getStarkExConfig().apiConfiguration);
256
265
  const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
257
266
  getSignableCancelOrderRequest: {
258
267
  order_id: request.order_id,
@@ -278,8 +287,8 @@ async function cancelOrder$1({ signers, request, config, }) {
278
287
  }
279
288
 
280
289
  async function registerOffchain(signers, config) {
281
- await validateChain(signers.ethSigner, config.immutableXConfig);
282
- const usersApi = new UsersApi(config.immutableXConfig.apiConfiguration);
290
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
291
+ const usersApi = new UsersApi(config.getStarkExConfig().apiConfiguration);
283
292
  const userAddress = await signers.ethSigner.getAddress();
284
293
  const starkPublicKey = await signers.starkExSigner.getAddress();
285
294
  const signableResult = await usersApi.getSignableRegistrationOffchain({
@@ -302,8 +311,8 @@ async function registerOffchain(signers, config) {
302
311
  return registeredUser.data;
303
312
  }
304
313
  async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
305
- await validateChain(ethSigner, config.immutableXConfig);
306
- const registrationContract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
314
+ await validateChain(ethSigner, config.getStarkExConfig());
315
+ const registrationContract = Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
307
316
  try {
308
317
  return await registrationContract.isRegistered(starkPublicKey);
309
318
  }
@@ -378,10 +387,10 @@ async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
378
387
 
379
388
  async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
380
389
  const etherKey = await ethSigner.getAddress();
381
- const starkExConfig = config.immutableXConfig;
390
+ const starkExConfig = config.getStarkExConfig();
382
391
  const usersApi = new UsersApi(starkExConfig.apiConfiguration);
383
392
  const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
384
- const contract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
393
+ const contract = Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
385
394
  const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
386
395
  return ethSigner.sendTransaction(populatedTransaction);
387
396
  }
@@ -391,8 +400,8 @@ async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config
391
400
  return ethSigner.sendTransaction(populatedTransaction);
392
401
  }
393
402
  async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
394
- await validateChain(ethSigner, config.immutableXConfig);
395
- const starkExConfig = config.immutableXConfig;
403
+ await validateChain(ethSigner, config.getStarkExConfig());
404
+ const starkExConfig = config.getStarkExConfig();
396
405
  const assetType = await getEncodeAssetInfo('asset', 'ERC20', starkExConfig, {
397
406
  token_address: token.tokenAddress,
398
407
  });
@@ -429,7 +438,7 @@ function getMintingBlob(token) {
429
438
  return encUtils.sanitizeHex(encUtils.utf8ToHex(`{${id}}:{${blueprint}}`));
430
439
  }
431
440
  async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
432
- const starkExConfig = config.immutableXConfig;
441
+ const starkExConfig = config.getStarkExConfig();
433
442
  const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', starkExConfig, {
434
443
  id: token.data.id,
435
444
  token_address: token.data.tokenAddress,
@@ -458,7 +467,7 @@ async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, token
458
467
  return ethSigner.sendTransaction(populatedTransaction);
459
468
  }
460
469
  async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
461
- const starkExConfig = config.immutableXConfig;
470
+ const starkExConfig = config.getStarkExConfig();
462
471
  const assetType = await getEncodeAssetInfo('asset', 'ERC721', starkExConfig, {
463
472
  token_id: token.tokenId,
464
473
  token_address: token.tokenAddress,
@@ -472,10 +481,10 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
472
481
  }
473
482
  }
474
483
  async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
475
- await validateChain(ethSigner, config.immutableXConfig);
484
+ await validateChain(ethSigner, config.getStarkExConfig());
476
485
  const tokenAddress = token.tokenAddress;
477
486
  const tokenId = token.tokenId;
478
- const starkExConfig = config.immutableXConfig;
487
+ const starkExConfig = config.getStarkExConfig();
479
488
  const mintsApi = new MintsApi(starkExConfig.apiConfiguration);
480
489
  return await mintsApi
481
490
  .getMintableTokenDetailsByClientTokenId({
@@ -513,8 +522,8 @@ async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config)
513
522
  return ethSigner.sendTransaction(populatedTransaction);
514
523
  }
515
524
  async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
516
- await validateChain(ethSigner, config.immutableXConfig);
517
- const starkExConfig = config.immutableXConfig;
525
+ await validateChain(ethSigner, config.getStarkExConfig());
526
+ const starkExConfig = config.getStarkExConfig();
518
527
  const assetType = await getEncodeAssetInfo('asset', 'ETH', starkExConfig);
519
528
  const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
520
529
  if (!isRegistered) {
@@ -526,9 +535,10 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
526
535
  }
527
536
 
528
537
  async function prepareWithdrawal({ signers, withdrawal, config, }) {
538
+ const starkExConfig = config.getStarkExConfig();
529
539
  return prepareWithdrawalAction({
530
540
  signers,
531
- config: config.immutableXConfig,
541
+ config: starkExConfig,
532
542
  ...withdrawal,
533
543
  });
534
544
  }
@@ -554,9 +564,9 @@ async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, toke
554
564
  }
555
565
 
556
566
  async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
557
- await validateChain(ethSigner, config.immutableXConfig);
567
+ await validateChain(ethSigner, config.getStarkExConfig());
558
568
  const ethAddress = await ethSigner.getAddress();
559
- const tradesApi = new TradesApi(config.immutableXConfig.apiConfiguration);
569
+ const tradesApi = new TradesApi(config.getStarkExConfig().apiConfiguration);
560
570
  const signableResult = await tradesApi.getSignableTrade({
561
571
  getSignableTradeRequest: {
562
572
  user: ethAddress,
@@ -591,13 +601,13 @@ async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, c
591
601
  }
592
602
 
593
603
  async function depositEth({ signers: { ethSigner }, deposit, config, }) {
594
- await validateChain(ethSigner, config.immutableXConfig);
604
+ await validateChain(ethSigner, config.getStarkExConfig());
595
605
  const user = await ethSigner.getAddress();
596
606
  const data = {
597
607
  decimals: 18,
598
608
  };
599
609
  const amount = parseUnits(deposit.amount, 'wei');
600
- const starkExConfig = config.immutableXConfig;
610
+ const starkExConfig = config.getStarkExConfig();
601
611
  const depositsApi = new DepositsApi(starkExConfig.apiConfiguration);
602
612
  const encodingApi = new EncodingApi(starkExConfig.apiConfiguration);
603
613
  const usersApi = new UsersApi(starkExConfig.apiConfiguration);
@@ -645,8 +655,8 @@ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, v
645
655
  }
646
656
 
647
657
  async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
648
- await validateChain(ethSigner, config.immutableXConfig);
649
- const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
658
+ await validateChain(ethSigner, config.getStarkExConfig());
659
+ const { apiConfiguration, ethConfiguration } = config.getStarkExConfig();
650
660
  const user = await ethSigner.getAddress();
651
661
  const tokensApi = new TokensApi(apiConfiguration);
652
662
  const depositsApi = new DepositsApi(apiConfiguration);
@@ -713,12 +723,12 @@ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetT
713
723
  }
714
724
 
715
725
  async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
716
- await validateChain(ethSigner, config.immutableXConfig);
726
+ await validateChain(ethSigner, config.getStarkExConfig());
717
727
  const user = await ethSigner.getAddress();
718
- const { immutableXConfig } = config;
719
- const depositsApi = new DepositsApi(immutableXConfig.apiConfiguration);
720
- const encodingApi = new EncodingApi(immutableXConfig.apiConfiguration);
721
- const usersApi = new UsersApi(immutableXConfig.apiConfiguration);
728
+ const starkExConfig = config.getStarkExConfig();
729
+ const depositsApi = new DepositsApi(starkExConfig.apiConfiguration);
730
+ const encodingApi = new EncodingApi(starkExConfig.apiConfiguration);
731
+ const usersApi = new UsersApi(starkExConfig.apiConfiguration);
722
732
  const data = {
723
733
  token_address: deposit.tokenAddress,
724
734
  token_id: deposit.tokenId,
@@ -754,18 +764,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
754
764
  const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
755
765
  // Approve whether an amount of token from an account can be spent by a third-party account
756
766
  const tokenContract = Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
757
- const operator = immutableXConfig.ethConfiguration.coreContractAddress;
767
+ const operator = starkExConfig.ethConfiguration.coreContractAddress;
758
768
  const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
759
769
  if (!isApprovedForAll) {
760
770
  await tokenContract.setApprovalForAll(operator, true);
761
771
  }
762
772
  if (!isRegistered) {
763
773
  const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
764
- const coreContract = Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
774
+ const coreContract = Contracts.Core.connect(starkExConfig.ethConfiguration.coreContractAddress, ethSigner);
765
775
  // Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
766
776
  await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
767
777
  }
768
- return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
778
+ return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, starkExConfig);
769
779
  }
770
780
  async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
771
781
  const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
@@ -785,8 +795,8 @@ async function deposit({ signers, deposit, config }) {
785
795
  }
786
796
 
787
797
  async function exchangeTransfer$1({ signers, request, config, }) {
788
- await validateChain(signers.ethSigner, config.immutableXConfig);
789
- const exchangeApi = new ExchangesApi(config.immutableXConfig.apiConfiguration);
798
+ await validateChain(signers.ethSigner, config.getStarkExConfig());
799
+ const exchangeApi = new ExchangesApi(config.getStarkExConfig().apiConfiguration);
790
800
  const ethAddress = await signers.ethSigner.getAddress();
791
801
  const transferAmount = request.amount;
792
802
  const signableResult = await exchangeApi.getExchangeSignableTransfer({
@@ -1009,6 +1019,7 @@ class ImxSigner {
1009
1019
 
1010
1020
  const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
1011
1021
  const IMX_WALLET_IFRAME_HOSTS = {
1022
+ [Environment.DEVELOPMENT]: 'http://localhost:8080',
1012
1023
  [Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
1013
1024
  [Environment.PRODUCTION]: 'https://wallets.immutable.com',
1014
1025
  };
@@ -1106,11 +1117,12 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
1106
1117
  super(config, ethSigner, starkExSigner);
1107
1118
  }
1108
1119
  static async connect(config) {
1120
+ const starkExConfig = config.getStarkExConfig();
1109
1121
  return await withProviderError(async () => {
1110
1122
  const metaMaskProvider = await connect$1({
1111
- chainID: config.immutableXConfig.ethConfiguration.chainID,
1123
+ chainID: starkExConfig.ethConfiguration.chainID,
1112
1124
  });
1113
- this.imxSigner = await connect(metaMaskProvider, config.baseConfig.environment);
1125
+ this.imxSigner = await connect(metaMaskProvider, starkExConfig.env);
1114
1126
  return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
1115
1127
  }, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
1116
1128
  }
@@ -1132,29 +1144,6 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
1132
1144
  }
1133
1145
  }
1134
1146
 
1135
- class ProviderConfiguration {
1136
- immutableXConfig;
1137
- baseConfig;
1138
- constructor({ baseConfig, overrides }) {
1139
- this.baseConfig = baseConfig;
1140
- if (overrides) {
1141
- this.immutableXConfig = overrides.immutableXConfig;
1142
- }
1143
- else {
1144
- switch (baseConfig.environment) {
1145
- case Environment.SANDBOX: {
1146
- this.immutableXConfig = Config.SANDBOX;
1147
- break;
1148
- }
1149
- case Environment.PRODUCTION: {
1150
- this.immutableXConfig = Config.PRODUCTION;
1151
- break;
1152
- }
1153
- }
1154
- }
1155
- }
1156
- }
1157
-
1158
1147
  var PassportErrorType;
1159
1148
  (function (PassportErrorType) {
1160
1149
  PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
@@ -1207,17 +1196,17 @@ const retryWithDelay = async (fn, options) => {
1207
1196
  }
1208
1197
  };
1209
1198
 
1210
- const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
1199
+ const getAuthConfiguration = ({ oidcConfiguration, }) => {
1211
1200
  const baseConfiguration = {
1212
- authority: authenticationDomain,
1201
+ authority: oidcConfiguration.authenticationDomain,
1213
1202
  redirect_uri: oidcConfiguration.redirectUri,
1214
1203
  popup_redirect_uri: oidcConfiguration.redirectUri,
1215
1204
  client_id: oidcConfiguration.clientId,
1216
1205
  metadata: {
1217
- authorization_endpoint: `${authenticationDomain}/authorize`,
1218
- token_endpoint: `${authenticationDomain}/oauth/token`,
1219
- userinfo_endpoint: `${authenticationDomain}/userinfo`,
1220
- end_session_endpoint: `${authenticationDomain}/v2/logout` +
1206
+ authorization_endpoint: `${oidcConfiguration.authenticationDomain}/authorize`,
1207
+ token_endpoint: `${oidcConfiguration.authenticationDomain}/oauth/token`,
1208
+ userinfo_endpoint: `${oidcConfiguration.authenticationDomain}/userinfo`,
1209
+ end_session_endpoint: `${oidcConfiguration.authenticationDomain}/v2/logout` +
1221
1210
  `?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
1222
1211
  `&client_id=${oidcConfiguration.clientId}`,
1223
1212
  },
@@ -1255,10 +1244,7 @@ class AuthManager {
1255
1244
  };
1256
1245
  async login() {
1257
1246
  return withPassportError(async () => {
1258
- const popupWindowFeatures = { width: 400, height: 420 };
1259
- const oidcUser = await this.userManager.signinPopup({
1260
- popupWindowFeatures,
1261
- });
1247
+ const oidcUser = await this.userManager.signinPopup();
1262
1248
  return this.mapOidcUserToDomainModel(oidcUser);
1263
1249
  }, PassportErrorType.AUTHENTICATION_ERROR);
1264
1250
  }
@@ -1341,12 +1327,26 @@ var TransactionTypes;
1341
1327
  const PassportEventType = 'imx_passport_confirmation';
1342
1328
 
1343
1329
  const openPopupCenter = ({ url, title, width, height, }) => {
1344
- const left = Math.max(0, Math.round(window.screenX + (window.outerWidth - width) / 2));
1345
- const top = Math.max(0, Math.round(window.screenY + (window.outerHeight - height) / 2));
1330
+ // Fixes dual-screen position Most browsers Firefox
1331
+ const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
1332
+ const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
1333
+ const windowWidth = window.innerWidth
1334
+ ? window.innerWidth
1335
+ : document.documentElement.clientWidth
1336
+ ? document.documentElement.clientWidth
1337
+ : screen.width;
1338
+ const windowHeight = window.innerHeight
1339
+ ? window.innerHeight
1340
+ : document.documentElement.clientHeight
1341
+ ? document.documentElement.clientHeight
1342
+ : screen.height;
1343
+ const systemZoom = windowWidth / window.screen.availWidth;
1344
+ const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
1345
+ const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
1346
1346
  const newWindow = window.open(url, title, `
1347
1347
  scrollbars=yes,
1348
- width=${width},
1349
- height=${height},
1348
+ width=${width / systemZoom},
1349
+ height=${height / systemZoom},
1350
1350
  top=${top},
1351
1351
  left=${left}
1352
1352
  `);
@@ -1358,8 +1358,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
1358
1358
  };
1359
1359
 
1360
1360
  const ConfirmationWindowTitle = 'Confirm this transaction';
1361
- const ConfirmationWindowHeight = 380;
1362
- const ConfirmationWindowWidth = 480;
1361
+ const ConfirmationWindowHeight = 600;
1362
+ const ConfirmationWindowWidth = 600;
1363
1363
  const ConfirmationWindowClosedPollingDuration = 1000;
1364
1364
  class ConfirmationScreen {
1365
1365
  config;
@@ -1373,7 +1373,7 @@ class ConfirmationScreen {
1373
1373
  ...message,
1374
1374
  }, this.config.passportDomain);
1375
1375
  }
1376
- startTransaction(accessToken, transaction, popupOptions) {
1376
+ startTransaction(accessToken, transaction) {
1377
1377
  return new Promise((resolve, reject) => {
1378
1378
  const messageHandler = ({ data, origin }) => {
1379
1379
  if (origin != this.config.passportDomain ||
@@ -1404,8 +1404,8 @@ class ConfirmationScreen {
1404
1404
  const confirmationWindow = openPopupCenter({
1405
1405
  url: `${this.config.passportDomain}/transaction-confirmation`,
1406
1406
  title: ConfirmationWindowTitle,
1407
- width: popupOptions?.width || ConfirmationWindowWidth,
1408
- height: popupOptions?.height || ConfirmationWindowHeight,
1407
+ width: ConfirmationWindowWidth,
1408
+ height: ConfirmationWindowHeight,
1409
1409
  });
1410
1410
  // https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
1411
1411
  const timer = setInterval(function () {
@@ -1492,11 +1492,10 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
1492
1492
  getSignableTransferRequestV2,
1493
1493
  });
1494
1494
  const confirmationScreen = new ConfirmationScreen(passportConfig);
1495
- const popupWindowSize = { width: 480, height: 784 };
1496
1495
  const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
1497
1496
  transactionType: TransactionTypes.CreateBatchTransfer,
1498
1497
  transactionData: getSignableTransferRequestV2,
1499
- }, popupWindowSize);
1498
+ });
1500
1499
  if (!confirmationResult.confirmed) {
1501
1500
  throw new Error('Transaction rejected by user');
1502
1501
  }
@@ -1724,8 +1723,8 @@ class PassportImxProvider {
1724
1723
  this.user = user;
1725
1724
  this.starkSigner = starkSigner;
1726
1725
  this.passportConfig = passportConfig;
1727
- const apiConfig = new Configuration({
1728
- basePath: passportConfig.imxApiBasePath,
1726
+ const apiConfig = new Configuration$1({
1727
+ basePath: passportConfig.imxAPIConfiguration.basePath,
1729
1728
  });
1730
1729
  this.transfersApi = new TransfersApi(apiConfig);
1731
1730
  this.ordersApi = new OrdersApi(apiConfig);
@@ -1817,75 +1816,67 @@ var Networks;
1817
1816
  Networks["SANDBOX"] = "goerli";
1818
1817
  })(Networks || (Networks = {}));
1819
1818
 
1820
- const validateConfiguration = (configuration, requiredKeys, prefix) => {
1819
+ const Config = {
1820
+ PRODUCTION: {
1821
+ network: Networks.PRODUCTION,
1822
+ authenticationDomain: 'https://auth.immutable.com',
1823
+ magicPublishableApiKey: 'pk_live_10F423798A540ED7',
1824
+ magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
1825
+ baseIMXApiPath: 'https://api.x.immutable.com',
1826
+ passportDomain: 'https://passport.immutable.com',
1827
+ },
1828
+ SANDBOX: {
1829
+ network: Networks.SANDBOX,
1830
+ authenticationDomain: 'https://auth.immutable.com',
1831
+ magicPublishableApiKey: 'pk_live_10F423798A540ED7',
1832
+ magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
1833
+ baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
1834
+ passportDomain: 'https://passport.sandbox.immutable.com',
1835
+ },
1836
+ };
1837
+ const validateConfiguration = (configurationName, configuration, requiredKeys) => {
1838
+ if (!configuration) {
1839
+ throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
1840
+ }
1821
1841
  const missingKeys = requiredKeys
1822
1842
  .map((key) => !configuration[key] && key)
1823
1843
  .filter((n) => n)
1824
1844
  .join(', ');
1825
1845
  if (missingKeys !== '') {
1826
- const errorMessage = prefix
1827
- ? `${prefix} - ${missingKeys} cannot be null`
1828
- : `${missingKeys} cannot be null`;
1829
- throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
1846
+ throw new PassportError(`${configurationName} - ${missingKeys} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
1830
1847
  }
1831
1848
  };
1832
- class PassportConfiguration {
1833
- network;
1834
- authenticationDomain;
1835
- passportDomain;
1836
- magicPublishableApiKey;
1837
- magicProviderId;
1838
- imxApiBasePath;
1839
- oidcConfiguration;
1840
- baseConfig;
1841
- constructor({ baseConfig, overrides, ...oidcConfiguration }) {
1842
- validateConfiguration(oidcConfiguration, [
1843
- 'clientId',
1844
- 'logoutRedirectUri',
1845
- 'redirectUri',
1846
- ]);
1847
- this.oidcConfiguration = oidcConfiguration;
1848
- this.baseConfig = baseConfig;
1849
- if (overrides) {
1850
- validateConfiguration(overrides, [
1851
- 'network',
1852
- 'authenticationDomain',
1853
- 'magicPublishableApiKey',
1854
- 'magicProviderId',
1855
- 'passportDomain',
1856
- 'imxApiBasePath',
1857
- ], 'overrides');
1858
- this.network = overrides.network;
1859
- this.authenticationDomain = overrides.authenticationDomain;
1860
- this.passportDomain = overrides.passportDomain;
1861
- this.magicPublishableApiKey = overrides.magicPublishableApiKey;
1862
- this.magicProviderId = overrides.magicProviderId;
1863
- this.imxApiBasePath = overrides.imxApiBasePath;
1864
- }
1865
- else {
1866
- switch (baseConfig.environment) {
1867
- case Environment.SANDBOX: {
1868
- this.network = Networks.SANDBOX;
1869
- this.authenticationDomain = 'https://auth.immutable.com';
1870
- this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1871
- this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1872
- this.passportDomain = 'https://passport.immutable.com';
1873
- this.imxApiBasePath = 'https://api.x.immutable.com';
1874
- break;
1875
- }
1876
- case Environment.PRODUCTION: {
1877
- this.network = Networks.PRODUCTION;
1878
- this.authenticationDomain = 'https://auth.immutable.com';
1879
- this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
1880
- this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
1881
- this.passportDomain = 'https://passport.sandbox.immutable.com';
1882
- this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
1883
- break;
1884
- }
1885
- }
1886
- }
1887
- }
1888
- }
1849
+ const getPassportConfiguration = (environmentConfiguration, oidcConfiguration) => {
1850
+ validateConfiguration('EnvironmentConfiguration', environmentConfiguration, [
1851
+ 'network',
1852
+ 'authenticationDomain',
1853
+ 'magicPublishableApiKey',
1854
+ 'magicProviderId',
1855
+ 'passportDomain',
1856
+ ]);
1857
+ validateConfiguration('OidcConfiguration', oidcConfiguration, [
1858
+ 'clientId',
1859
+ 'logoutRedirectUri',
1860
+ 'redirectUri',
1861
+ ]);
1862
+ return {
1863
+ network: environmentConfiguration.network,
1864
+ oidcConfiguration: {
1865
+ authenticationDomain: environmentConfiguration.authenticationDomain,
1866
+ clientId: oidcConfiguration.clientId,
1867
+ logoutRedirectUri: oidcConfiguration.logoutRedirectUri,
1868
+ redirectUri: oidcConfiguration.redirectUri,
1869
+ scope: oidcConfiguration.scope,
1870
+ audience: oidcConfiguration.audience,
1871
+ },
1872
+ imxAPIConfiguration: {
1873
+ basePath: environmentConfiguration.baseIMXApiPath,
1874
+ },
1875
+ passportDomain: environmentConfiguration.passportDomain,
1876
+ magicPublishableApiKey: environmentConfiguration.magicPublishableApiKey,
1877
+ magicProviderId: environmentConfiguration.magicProviderId,
1878
+ };
1879
+ };
1889
1880
 
1890
1881
  const getStarkSigner = async (signer) => {
1891
1882
  return withPassportError(async () => {
@@ -1924,8 +1915,8 @@ class Passport {
1924
1915
  authManager;
1925
1916
  magicAdapter;
1926
1917
  config;
1927
- constructor(passportModuleConfiguration) {
1928
- const passportConfiguration = new PassportConfiguration(passportModuleConfiguration);
1918
+ constructor(environmentConfiguration, oidcConfiguration) {
1919
+ const passportConfiguration = getPassportConfiguration(environmentConfiguration, oidcConfiguration);
1929
1920
  this.config = passportConfiguration;
1930
1921
  this.authManager = new AuthManager(this.config);
1931
1922
  this.magicAdapter = new MagicAdapter(this.config);
@@ -1972,8 +1963,8 @@ class Passport {
1972
1963
  return user.accessToken;
1973
1964
  }
1974
1965
  async registerUser(userAdminKeySigner, starkSigner, jwt) {
1975
- const configuration = new Configuration({
1976
- basePath: this.config.imxApiBasePath,
1966
+ const configuration = new Configuration$1({
1967
+ basePath: this.config.imxAPIConfiguration.basePath,
1977
1968
  });
1978
1969
  const usersApi = new UsersApi(configuration);
1979
1970
  await registerPassport({
@@ -1989,559 +1980,4 @@ class Passport {
1989
1980
  }
1990
1981
  }
1991
1982
 
1992
- function $parcel$interopDefault(a) {
1993
- return a && a.__esModule ? a.default : a;
1994
- }
1995
-
1996
- const $762782b6c862d954$export$db5daa1b5156ccfe = [
1997
- {
1998
- constant: true,
1999
- inputs: [],
2000
- name: "name",
2001
- outputs: [
2002
- {
2003
- name: "",
2004
- type: "string"
2005
- }
2006
- ],
2007
- payable: false,
2008
- type: "function"
2009
- },
2010
- {
2011
- constant: true,
2012
- inputs: [],
2013
- name: "decimals",
2014
- outputs: [
2015
- {
2016
- name: "",
2017
- type: "uint8"
2018
- }
2019
- ],
2020
- payable: false,
2021
- type: "function"
2022
- },
2023
- {
2024
- constant: true,
2025
- inputs: [
2026
- {
2027
- name: "_owner",
2028
- type: "address"
2029
- }
2030
- ],
2031
- name: "balanceOf",
2032
- outputs: [
2033
- {
2034
- name: "balance",
2035
- type: "uint256"
2036
- }
2037
- ],
2038
- payable: false,
2039
- type: "function"
2040
- },
2041
- {
2042
- constant: true,
2043
- inputs: [],
2044
- name: "symbol",
2045
- outputs: [
2046
- {
2047
- name: "",
2048
- type: "string"
2049
- }
2050
- ],
2051
- payable: false,
2052
- type: "function"
2053
- }
2054
- ];
2055
-
2056
-
2057
- let $d176a05e966364ba$export$3bfad4d03ada24c4;
2058
- (function(ConnectionProviders) {
2059
- ConnectionProviders["METAMASK"] = "metamask";
2060
- })($d176a05e966364ba$export$3bfad4d03ada24c4 || ($d176a05e966364ba$export$3bfad4d03ada24c4 = {}));
2061
-
2062
-
2063
- let $a47e48dd2c04791b$export$c06e1e7429de6283;
2064
- (function(ChainId) {
2065
- ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
2066
- ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
2067
- ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
2068
- })($a47e48dd2c04791b$export$c06e1e7429de6283 || ($a47e48dd2c04791b$export$c06e1e7429de6283 = {}));
2069
- const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
2070
- [$a47e48dd2c04791b$export$c06e1e7429de6283.ETHEREUM]: {
2071
- chainIdHex: "0x1",
2072
- chainName: "Ethereum",
2073
- rpcUrls: [
2074
- "https://mainnet.infura.io/v3/"
2075
- ],
2076
- nativeCurrency: {
2077
- name: "Ethereum",
2078
- symbol: "ETH",
2079
- decimals: 18
2080
- },
2081
- blockExplorerUrls: [
2082
- "https://etherscan.io/"
2083
- ]
2084
- },
2085
- [$a47e48dd2c04791b$export$c06e1e7429de6283.GOERLI]: {
2086
- chainIdHex: "0x5",
2087
- chainName: "Goerli",
2088
- rpcUrls: [
2089
- "https://goerli.infura.io/v3/"
2090
- ],
2091
- nativeCurrency: {
2092
- name: "Goerli Eth",
2093
- symbol: "ETH",
2094
- decimals: 18
2095
- },
2096
- blockExplorerUrls: [
2097
- "https://goerli.etherscan.io/"
2098
- ]
2099
- },
2100
- [$a47e48dd2c04791b$export$c06e1e7429de6283.POLYGON]: {
2101
- chainIdHex: "0x89",
2102
- chainName: "Polygon",
2103
- rpcUrls: [
2104
- "https://polygon-rpc.com"
2105
- ],
2106
- nativeCurrency: {
2107
- name: "MATIC",
2108
- symbol: "MATIC",
2109
- decimals: 18
2110
- },
2111
- blockExplorerUrls: [
2112
- "https://polygonscan.com/"
2113
- ]
2114
- }
2115
- };
2116
-
2117
-
2118
- let $08d5ddc39acd6833$export$fd9b17d87f4121d2;
2119
- (function(TokenFilterTypes) {
2120
- TokenFilterTypes["SWAP"] = "swap";
2121
- TokenFilterTypes["BRIDGE"] = "bridge";
2122
- TokenFilterTypes["ALL"] = "all";
2123
- })($08d5ddc39acd6833$export$fd9b17d87f4121d2 || ($08d5ddc39acd6833$export$fd9b17d87f4121d2 = {}));
2124
-
2125
-
2126
-
2127
-
2128
- const $4f91c5f280efe242$export$a130407f3423b97d = {
2129
- CHECK_CONNECTION: "eth_accounts",
2130
- CONNECT: "eth_requestAccounts",
2131
- ADD_NETWORK: "wallet_addEthereumChain",
2132
- SWITCH_NETWORK: "wallet_switchEthereumChain"
2133
- };
2134
- let $4f91c5f280efe242$export$a75605c67ea83a5a;
2135
- (function(WalletFilterTypes) {
2136
- WalletFilterTypes["ALL"] = "all";
2137
- WalletFilterTypes["DESKTOP"] = "desktop";
2138
- WalletFilterTypes["MOBILE"] = "mobile";
2139
- })($4f91c5f280efe242$export$a75605c67ea83a5a || ($4f91c5f280efe242$export$a75605c67ea83a5a = {}));
2140
-
2141
-
2142
-
2143
-
2144
- let $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
2145
- (function(CheckoutErrorType) {
2146
- CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
2147
- CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
2148
- CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
2149
- CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
2150
- CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
2151
- CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
2152
- CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
2153
- CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
2154
- })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
2155
- class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
2156
- constructor(message, type){
2157
- super(message);
2158
- this.type = type;
2159
- }
2160
- }
2161
- const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
2162
- try {
2163
- return await fn();
2164
- } catch (error) {
2165
- const errorMessage = customError.message || `${error.message}` || "UnknownError";
2166
- throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type);
2167
- }
2168
- };
2169
-
2170
-
2171
-
2172
-
2173
-
2174
-
2175
-
2176
- async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
2177
- const network = await provider.getNetwork();
2178
- if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(network.chainId)) // return empty details
2179
- return {};
2180
- const chainIdNetworkInfo = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[network.chainId];
2181
- const networkInfo = {
2182
- name: chainIdNetworkInfo.chainName,
2183
- chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
2184
- nativeCurrency: chainIdNetworkInfo.nativeCurrency
2185
- };
2186
- return networkInfo;
2187
- }
2188
- async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
2189
- if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`${chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
2190
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2191
- // WT-1146 - Refer to the README in this folder for explantion on the switch network flow
2192
- try {
2193
- await $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId);
2194
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2195
- } catch (err) {
2196
- if (err.message.includes("Unrecognized chain ID")) try {
2197
- await $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId);
2198
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2199
- } catch (err) {
2200
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
2201
- }
2202
- else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("user cancelled the switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
2203
- }
2204
- // we can assume that if the above succeeds then user has successfully
2205
- // switched to the network specified
2206
- const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId];
2207
- return {
2208
- network: {
2209
- name: newNetwork.chainName,
2210
- chainId: parseInt(newNetwork.chainIdHex, 16),
2211
- nativeCurrency: newNetwork.nativeCurrency
2212
- }
2213
- };
2214
- }
2215
- // these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
2216
- // make sure to check if(provider.provider?.request) in the exported function and throw an error
2217
- async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
2218
- if (provider.provider?.request) return await provider.provider.request({
2219
- method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
2220
- params: [
2221
- {
2222
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
2223
- }
2224
- ]
2225
- });
2226
- }
2227
- async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
2228
- if (provider.provider?.request) {
2229
- const addNetwork = {
2230
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
2231
- chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
2232
- rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
2233
- nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
2234
- blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
2235
- };
2236
- return await provider.provider.request({
2237
- method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
2238
- params: [
2239
- addNetwork
2240
- ]
2241
- });
2242
- }
2243
- }
2244
-
2245
-
2246
-
2247
-
2248
-
2249
- var $cda6003506e4182e$exports = {};
2250
- $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\"]}]");
2251
-
2252
-
2253
- const $efe60cea83bfc4e8$export$473cec51305fdae8 = function({ type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL , chainId: chainId , exclude: exclude }) {
2254
- // todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2255
- const filteredTokenList = ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
2256
- const chainIdMatches = token.chainId == chainId;
2257
- const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
2258
- const allowAllTokens = type === ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL;
2259
- const tokenAllowedForType = token.tokenFeatures.includes(type);
2260
- return chainIdMatches && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
2261
- }).map((token)=>{
2262
- const { chainId: chainId , tokenFeatures: tokenFeatures , ...tokenInfo } = token;
2263
- return tokenInfo;
2264
- });
2265
- return {
2266
- tokens: filteredTokenList
2267
- };
2268
- };
2269
-
2270
-
2271
-
2272
-
2273
- const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
2274
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2275
- const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
2276
- const balance = await provider.getBalance(walletAddress);
2277
- return {
2278
- balance: balance,
2279
- formattedBalance: (utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
2280
- token: networkInfo.nativeCurrency
2281
- };
2282
- }, {
2283
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
2284
- });
2285
- };
2286
- async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
2287
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2288
- const contract = new (Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
2289
- const name = await contract.name();
2290
- const symbol = await contract.symbol();
2291
- const balance = await contract.balanceOf(walletAddress);
2292
- const decimals = await contract.decimals();
2293
- const formattedBalance = (utils).formatUnits(balance, decimals);
2294
- return {
2295
- balance: balance,
2296
- formattedBalance: formattedBalance,
2297
- token: {
2298
- name: name,
2299
- symbol: symbol,
2300
- decimals: decimals,
2301
- address: contractAddress
2302
- }
2303
- };
2304
- }, {
2305
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
2306
- });
2307
- }
2308
- const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
2309
- if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
2310
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2311
- const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)({
2312
- type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
2313
- chainId: chainId
2314
- });
2315
- const allBalancePromises = [];
2316
- allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
2317
- tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
2318
- const balanceResults = await Promise.allSettled(allBalancePromises);
2319
- const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
2320
- return {
2321
- balances: getBalanceResults
2322
- };
2323
- };
2324
-
2325
-
2326
-
2327
-
2328
-
2329
- /* eslint-disable @typescript-eslint/no-explicit-any */
2330
-
2331
-
2332
-
2333
- async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
2334
- const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
2335
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
2336
- const accounts = await provider.provider.request({
2337
- method: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
2338
- params: []
2339
- });
2340
- // accounts[0] will have the active account if connected.
2341
- return {
2342
- isConnected: accounts && accounts.length > 0,
2343
- walletAddress: accounts[0] ?? ""
2344
- };
2345
- }
2346
- async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
2347
- const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
2348
- await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2349
- if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
2350
- // this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
2351
- await web3Provider.provider.request({
2352
- method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
2353
- params: []
2354
- });
2355
- }, {
2356
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR
2357
- });
2358
- return web3Provider;
2359
- }
2360
- async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
2361
- let web3Provider = null;
2362
- switch(providerPreference){
2363
- case ($d176a05e966364ba$export$3bfad4d03ada24c4).METAMASK:
2364
- web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
2365
- break;
2366
- default:
2367
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference was not detected", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CONNECT_PROVIDER_ERROR);
2368
- }
2369
- return web3Provider;
2370
- }
2371
- async function $c99672cf2294e839$var$getMetaMaskProvider() {
2372
- const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2373
- return await (detectEthereumProvider)();
2374
- }, {
2375
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
2376
- });
2377
- if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
2378
- return new (Web3Provider)(provider);
2379
- }
2380
-
2381
-
2382
-
2383
-
2384
-
2385
- var $6f3c55a615003cbf$exports = {};
2386
- $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"]}]');
2387
-
2388
-
2389
- async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL , exclude: exclude }) {
2390
- // todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2391
- const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
2392
- const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.connectionProvider).includes(wallet.connectionProvider);
2393
- const allowAllWallets = type === ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL;
2394
- const walletsAllowedForType = wallet.platform.includes(type);
2395
- return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
2396
- }).map((wallet)=>{
2397
- const { platform: platform , ...walletInfo } = wallet;
2398
- return walletInfo;
2399
- });
2400
- return {
2401
- allowedWallets: filteredWalletsList
2402
- };
2403
- }
2404
-
2405
-
2406
-
2407
-
2408
-
2409
-
2410
- const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
2411
- const { provider: provider , transaction: transaction } = params;
2412
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2413
- const transactionResponse = await provider.getSigner().sendTransaction(transaction);
2414
- return {
2415
- transactionResponse: transactionResponse
2416
- };
2417
- }, {
2418
- type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).TRANSACTION_ERROR
2419
- });
2420
- };
2421
-
2422
-
2423
-
2424
-
2425
- class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
2426
- async checkIsWalletConnected(params) {
2427
- return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
2428
- }
2429
- async connect(params) {
2430
- const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
2431
- const network = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
2432
- return {
2433
- provider: provider,
2434
- network: network
2435
- };
2436
- }
2437
- async switchNetwork(params) {
2438
- return await ($de192de6ef100f9f$export$b827d9418aeb5dbd)(params.provider, params.chainId);
2439
- }
2440
- async getBalance(params) {
2441
- if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
2442
- return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
2443
- }
2444
- async getAllBalances(params) {
2445
- return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
2446
- }
2447
- getTokenAllowList(params) {
2448
- return $efe60cea83bfc4e8$export$473cec51305fdae8(params);
2449
- }
2450
- async getWalletsAllowList(params) {
2451
- return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
2452
- }
2453
- async sendTransaction(params) {
2454
- return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
2455
- }
2456
- }
2457
-
2458
- function $parcel$export(e, n, v, s) {
2459
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
2460
- }
2461
- var $88e4c575901cd68c$exports = {};
2462
-
2463
- $parcel$export($88e4c575901cd68c$exports, "IMTBLWidgetEvents", () => $88e4c575901cd68c$export$5a0ace85cae72d45);
2464
- let $88e4c575901cd68c$export$5a0ace85cae72d45;
2465
- (function(IMTBLWidgetEvents) {
2466
- IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
2467
- IMTBLWidgetEvents["IMTBL_WALLET_WIDGET_EVENT"] = "imtbl-wallet-widget";
2468
- IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
2469
- IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
2470
- IMTBLWidgetEvents["IMTBL_BUY_WIDGET_EVENT"] = "imtbl-buy-widget";
2471
- })($88e4c575901cd68c$export$5a0ace85cae72d45 || ($88e4c575901cd68c$export$5a0ace85cae72d45 = {}));
2472
-
2473
-
2474
- var $d71a87afc3136184$exports = {};
2475
-
2476
- $parcel$export($d71a87afc3136184$exports, "ConnectEventType", () => $d71a87afc3136184$export$e72e7f9969a47dd3);
2477
- let $d71a87afc3136184$export$e72e7f9969a47dd3;
2478
- (function(ConnectEventType) {
2479
- ConnectEventType["SUCCESS"] = "success";
2480
- ConnectEventType["FAILURE"] = "failure";
2481
- })($d71a87afc3136184$export$e72e7f9969a47dd3 || ($d71a87afc3136184$export$e72e7f9969a47dd3 = {}));
2482
-
2483
-
2484
- var $9d0f1783d4d36e8a$exports = {};
2485
-
2486
- $parcel$export($9d0f1783d4d36e8a$exports, "WalletEventType", () => $9d0f1783d4d36e8a$export$d9be06b70b28c742);
2487
- //wallet widget events
2488
- let $9d0f1783d4d36e8a$export$d9be06b70b28c742;
2489
- (function(WalletEventType) {
2490
- WalletEventType["CLOSE_WIDGET"] = "close-widget";
2491
- WalletEventType["NETWORK_SWITCH"] = "network-switch";
2492
- })($9d0f1783d4d36e8a$export$d9be06b70b28c742 || ($9d0f1783d4d36e8a$export$d9be06b70b28c742 = {}));
2493
-
2494
-
2495
- var $5d497088f13bb116$exports = {};
2496
-
2497
- $parcel$export($5d497088f13bb116$exports, "SwapEventType", () => $5d497088f13bb116$export$140a49745ab55563);
2498
- let $5d497088f13bb116$export$140a49745ab55563;
2499
- (function(SwapEventType) {
2500
- SwapEventType["SUCCESS"] = "success";
2501
- SwapEventType["FAILURE"] = "failure";
2502
- })($5d497088f13bb116$export$140a49745ab55563 || ($5d497088f13bb116$export$140a49745ab55563 = {}));
2503
-
2504
-
2505
- var $28a5fdc2f5e6c742$exports = {};
2506
-
2507
- $parcel$export($28a5fdc2f5e6c742$exports, "BridgeEventType", () => $28a5fdc2f5e6c742$export$d1bfa21f7c76447a);
2508
- let $28a5fdc2f5e6c742$export$d1bfa21f7c76447a;
2509
- (function(BridgeEventType) {
2510
- BridgeEventType["CLOSE_WIDGET"] = "close-widget";
2511
- BridgeEventType["SUCCESS"] = "success";
2512
- BridgeEventType["FAILURE"] = "failure";
2513
- })($28a5fdc2f5e6c742$export$d1bfa21f7c76447a || ($28a5fdc2f5e6c742$export$d1bfa21f7c76447a = {}));
2514
-
2515
-
2516
- var $ede253beebe0de4a$exports = {};
2517
-
2518
- $parcel$export($ede253beebe0de4a$exports, "BuyEventType", () => $ede253beebe0de4a$export$90db5fe1be5993c1);
2519
- let $ede253beebe0de4a$export$90db5fe1be5993c1;
2520
- (function(BuyEventType) {
2521
- BuyEventType["SUCCESS"] = "success";
2522
- BuyEventType["FAILURE"] = "failure";
2523
- BuyEventType["NOT_CONNECTED"] = "not_connected";
2524
- BuyEventType["CLOSE"] = "close";
2525
- })($ede253beebe0de4a$export$90db5fe1be5993c1 || ($ede253beebe0de4a$export$90db5fe1be5993c1 = {}));
2526
-
2527
-
2528
- var $9234b4c577442a97$exports = {};
2529
-
2530
- $parcel$export($9234b4c577442a97$exports, "Network", () => $9234b4c577442a97$export$95be4ae94445245a);
2531
- $parcel$export($9234b4c577442a97$exports, "WidgetTheme", () => $9234b4c577442a97$export$c88931fdc51854eb);
2532
- $parcel$export($9234b4c577442a97$exports, "ConnectionProviders", () => $d176a05e966364ba$export$3bfad4d03ada24c4);
2533
-
2534
- let $9234b4c577442a97$export$95be4ae94445245a;
2535
- (function(Network) {
2536
- Network["ETHEREUM"] = "Ethereum";
2537
- Network["GOERLI"] = "Goerli";
2538
- Network["POLYGON"] = "Polygon";
2539
- })($9234b4c577442a97$export$95be4ae94445245a || ($9234b4c577442a97$export$95be4ae94445245a = {}));
2540
- let $9234b4c577442a97$export$c88931fdc51854eb;
2541
- (function(WidgetTheme) {
2542
- WidgetTheme["LIGHT"] = "light";
2543
- WidgetTheme["DARK"] = "dark";
2544
- WidgetTheme["CUSTOM"] = "custom";
2545
- })($9234b4c577442a97$export$c88931fdc51854eb || ($9234b4c577442a97$export$c88931fdc51854eb = {}));
2546
-
2547
- export { $28a5fdc2f5e6c742$export$d1bfa21f7c76447a as BridgeEventType, $ede253beebe0de4a$export$90db5fe1be5993c1 as BuyEventType, $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $d71a87afc3136184$export$e72e7f9969a47dd3 as ConnectEventType, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, Environment, GenericIMXProvider, $88e4c575901cd68c$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, MetaMaskIMXProvider, $9234b4c577442a97$export$95be4ae94445245a as Network, Passport, PassportConfiguration, PassportError, ProviderConfiguration, StarkExAPIFactory, $5d497088f13bb116$export$140a49745ab55563 as SwapEventType, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $9d0f1783d4d36e8a$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $9234b4c577442a97$export$c88931fdc51854eb as WidgetTheme };
1983
+ export { Config, Configuration, Environment, GenericIMXProvider, MetaMaskIMXProvider, PRODUCTION, Passport, PassportError, SANDBOX, StarkExAPIFactory };