@imtbl/sdk 0.1.6-alpha → 0.1.6

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
@@ -7,12 +7,6 @@ var magicSdk = require('magic-sdk');
7
7
  var oidc = require('@magic-ext/oidc');
8
8
  var BN = require('bn.js');
9
9
  var encUtils = require('enc-utils');
10
- var units = require('@ethersproject/units');
11
- var bignumber = require('@ethersproject/bignumber');
12
- var detectEthereumProvider = require('@metamask/detect-provider');
13
- var providers = require('@ethersproject/providers');
14
- var jsxRuntime = require('react/jsx-runtime');
15
- require('react');
16
10
 
17
11
  function _interopNamespaceDefault(e) {
18
12
  var n = Object.create(null);
@@ -578,15 +572,6 @@ async function signRaw(payload, signer) {
578
572
  const signature = deserializeSignature(await signer.signMessage(payload));
579
573
  return serializeEthSignature(signature);
580
574
  }
581
- async function signMessage(message, signer) {
582
- const ethAddress = await signer.getAddress();
583
- const ethSignature = await signRaw(message, signer);
584
- return {
585
- message,
586
- ethAddress,
587
- ethSignature,
588
- };
589
- }
590
575
 
591
576
  /**
592
577
  * Helper method to convert token type to a SignableToken type
@@ -914,7 +899,7 @@ class ConfirmationScreen {
914
899
  }
915
900
 
916
901
  const ERC721$1 = 'ERC721';
917
- const transfer$1 = ({ request, transfersApi, starkSigner, user, passportConfig,
902
+ const transfer = ({ request, transfersApi, starkSigner, user, passportConfig,
918
903
  // TODO: remove this eslint disable once we have a better solution
919
904
  // eslint-disable-next-line max-len
920
905
  }) => withPassportError(async () => {
@@ -1025,7 +1010,7 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
1025
1010
  }
1026
1011
 
1027
1012
  const ERC721 = 'ERC721';
1028
- async function createOrder$1({ starkSigner, user, request, ordersApi, passportConfig, }) {
1013
+ async function createOrder({ starkSigner, user, request, ordersApi, passportConfig, }) {
1029
1014
  return withPassportError(async () => {
1030
1015
  const ethAddress = user.etherKey;
1031
1016
  const amountSell = request.sell.type === ERC721 ? '1' : request.sell.amount;
@@ -1081,7 +1066,7 @@ async function createOrder$1({ starkSigner, user, request, ordersApi, passportCo
1081
1066
  };
1082
1067
  }, PassportErrorType.CREATE_ORDER_ERROR);
1083
1068
  }
1084
- async function cancelOrder$1({ user, starkSigner, request, ordersApi, passportConfig, }) {
1069
+ async function cancelOrder({ user, starkSigner, request, ordersApi, passportConfig, }) {
1085
1070
  return withPassportError(async () => {
1086
1071
  const getSignableCancelOrderRequest = {
1087
1072
  order_id: request.order_id,
@@ -1117,7 +1102,7 @@ async function cancelOrder$1({ user, starkSigner, request, ordersApi, passportCo
1117
1102
  }, PassportErrorType.CANCEL_ORDER_ERROR);
1118
1103
  }
1119
1104
 
1120
- async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, }) {
1105
+ async function exchangeTransfer({ user, starkSigner, request, exchangesApi, }) {
1121
1106
  return withPassportError(async () => {
1122
1107
  const ethAddress = user.etherKey;
1123
1108
  const transferAmount = request.amount;
@@ -1161,7 +1146,7 @@ async function exchangeTransfer$1({ user, starkSigner, request, exchangesApi, })
1161
1146
  }, PassportErrorType.EXCHANGE_TRANSFER_ERROR);
1162
1147
  }
1163
1148
 
1164
- async function createTrade$1({ request, tradesApi, user, starkSigner, passportConfig, }) {
1149
+ async function createTrade({ request, tradesApi, user, starkSigner, passportConfig, }) {
1165
1150
  return withPassportError(async () => {
1166
1151
  const ethAddress = user.etherKey;
1167
1152
  const getSignableTradeRequest = {
@@ -1223,7 +1208,7 @@ class PassportImxProvider {
1223
1208
  this.immutableXClient = immutableXClient;
1224
1209
  }
1225
1210
  async transfer(request) {
1226
- return transfer$1({
1211
+ return transfer({
1227
1212
  request,
1228
1213
  user: this.user,
1229
1214
  starkSigner: this.starkSigner,
@@ -1242,7 +1227,7 @@ class PassportImxProvider {
1242
1227
  throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
1243
1228
  }
1244
1229
  createOrder(request) {
1245
- return createOrder$1({
1230
+ return createOrder({
1246
1231
  request,
1247
1232
  user: this.user,
1248
1233
  starkSigner: this.starkSigner,
@@ -1251,7 +1236,7 @@ class PassportImxProvider {
1251
1236
  });
1252
1237
  }
1253
1238
  cancelOrder(request) {
1254
- return cancelOrder$1({
1239
+ return cancelOrder({
1255
1240
  request,
1256
1241
  user: this.user,
1257
1242
  starkSigner: this.starkSigner,
@@ -1260,7 +1245,7 @@ class PassportImxProvider {
1260
1245
  });
1261
1246
  }
1262
1247
  createTrade(request) {
1263
- return createTrade$1({
1248
+ return createTrade({
1264
1249
  request,
1265
1250
  user: this.user,
1266
1251
  starkSigner: this.starkSigner,
@@ -1278,7 +1263,7 @@ class PassportImxProvider {
1278
1263
  });
1279
1264
  }
1280
1265
  exchangeTransfer(request) {
1281
- return exchangeTransfer$1({
1266
+ return exchangeTransfer({
1282
1267
  request,
1283
1268
  user: this.user,
1284
1269
  starkSigner: this.starkSigner,
@@ -1496,1960 +1481,6 @@ class Passport {
1496
1481
  }
1497
1482
  }
1498
1483
 
1499
- function isChainValid(chainID, config) {
1500
- return chainID === config.ethConfiguration.chainID;
1501
- }
1502
- async function validateChain(signer, config) {
1503
- const chainID = await signer.getChainId();
1504
- if (!isChainValid(chainID, config))
1505
- throw new Error('The wallet used for this operation is not connected to the correct network.');
1506
- }
1507
-
1508
- async function transfer({ signers: { ethSigner, starkSigner }, request, config, }) {
1509
- await validateChain(ethSigner, config.immutableXConfig);
1510
- const ethAddress = await ethSigner.getAddress();
1511
- const transfersApi = new coreSdk.TransfersApi(config.immutableXConfig.apiConfiguration);
1512
- const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
1513
- const signableResult = await transfersApi.getSignableTransferV1({
1514
- getSignableTransferRequest: {
1515
- sender: ethAddress,
1516
- token: convertToSignableToken(request),
1517
- amount: transferAmount,
1518
- receiver: request.receiver,
1519
- },
1520
- });
1521
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
1522
- const ethSignature = await signRaw(signableMessage, ethSigner);
1523
- const starkSignature = await starkSigner.signMessage(payloadHash);
1524
- const transferSigningParams = {
1525
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1526
- sender_stark_key: signableResult.data.sender_stark_key,
1527
- sender_vault_id: signableResult.data.sender_vault_id,
1528
- receiver_stark_key: signableResult.data.receiver_stark_key,
1529
- receiver_vault_id: signableResult.data.receiver_vault_id,
1530
- asset_id: signableResult.data.asset_id,
1531
- amount: signableResult.data.amount,
1532
- nonce: signableResult.data.nonce,
1533
- expiration_timestamp: signableResult.data.expiration_timestamp,
1534
- stark_signature: starkSignature,
1535
- };
1536
- const response = await transfersApi.createTransferV1({
1537
- createTransferRequest: transferSigningParams,
1538
- xImxEthAddress: ethAddress,
1539
- xImxEthSignature: ethSignature,
1540
- });
1541
- return {
1542
- sent_signature: response?.data.sent_signature,
1543
- status: response?.data.status?.toString(),
1544
- time: response?.data.time,
1545
- transfer_id: response?.data.transfer_id,
1546
- };
1547
- }
1548
- async function batchTransfer({ signers: { ethSigner, starkSigner }, request, config, }) {
1549
- await validateChain(ethSigner, config.immutableXConfig);
1550
- const ethAddress = await ethSigner.getAddress();
1551
- const transfersApi = new coreSdk.TransfersApi(config.immutableXConfig.apiConfiguration);
1552
- const signableRequests = request.map((nftTransfer) => {
1553
- return {
1554
- amount: '1',
1555
- token: convertToSignableToken({
1556
- type: 'ERC721',
1557
- tokenId: nftTransfer.tokenId,
1558
- tokenAddress: nftTransfer.tokenAddress,
1559
- }),
1560
- receiver: nftTransfer.receiver,
1561
- };
1562
- });
1563
- const signableResult = await transfersApi.getSignableTransfer({
1564
- getSignableTransferRequestV2: {
1565
- sender_ether_key: ethAddress,
1566
- signable_requests: signableRequests,
1567
- },
1568
- });
1569
- const signableMessage = signableResult.data.signable_message;
1570
- if (signableMessage === undefined) {
1571
- throw new Error('Invalid response from Signable registration offchain');
1572
- }
1573
- const ethSignature = await signRaw(signableMessage, ethSigner);
1574
- const requests = [];
1575
- for (const resp of signableResult.data.signable_responses) {
1576
- const starkSignature = await starkSigner.signMessage(resp.payload_hash);
1577
- const req = {
1578
- sender_vault_id: resp.sender_vault_id,
1579
- receiver_stark_key: resp.receiver_stark_key,
1580
- receiver_vault_id: resp.receiver_vault_id,
1581
- asset_id: resp.asset_id,
1582
- amount: resp.amount,
1583
- nonce: resp.nonce,
1584
- expiration_timestamp: resp.expiration_timestamp,
1585
- stark_signature: starkSignature,
1586
- };
1587
- requests.push(req);
1588
- }
1589
- // TODO: throw error on missing payload hash?
1590
- const transferSigningParams = {
1591
- sender_stark_key: signableResult.data.sender_stark_key,
1592
- requests,
1593
- };
1594
- const response = await transfersApi.createTransfer({
1595
- createTransferRequestV2: transferSigningParams,
1596
- xImxEthAddress: ethAddress,
1597
- xImxEthSignature: ethSignature,
1598
- });
1599
- return {
1600
- transfer_ids: response?.data.transfer_ids,
1601
- };
1602
- }
1603
-
1604
- async function createOrder({ signers, request, config, }) {
1605
- await validateChain(signers.ethSigner, config.immutableXConfig);
1606
- const ethAddress = await signers.ethSigner.getAddress();
1607
- const ordersApi = new coreSdk.OrdersApi(config.immutableXConfig.apiConfiguration);
1608
- const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
1609
- const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
1610
- const getSignableOrderRequest = {
1611
- user: ethAddress,
1612
- amount_buy: amountBuy,
1613
- token_buy: convertToSignableToken(request.buy),
1614
- amount_sell: amountSell,
1615
- token_sell: convertToSignableToken(request.sell),
1616
- fees: request.fees,
1617
- expiration_timestamp: request.expiration_timestamp,
1618
- };
1619
- const getSignableOrderResponse = await ordersApi.getSignableOrder({
1620
- getSignableOrderRequestV3: getSignableOrderRequest,
1621
- });
1622
- const { signable_message: signableMessage, payload_hash: payloadHash } = getSignableOrderResponse.data;
1623
- const ethSignature = await signRaw(signableMessage, signers.ethSigner);
1624
- const starkSignature = await signers.starkSigner.signMessage(payloadHash);
1625
- const resp = getSignableOrderResponse.data;
1626
- const orderParams = {
1627
- createOrderRequest: {
1628
- amount_buy: resp.amount_buy,
1629
- amount_sell: resp.amount_sell,
1630
- asset_id_buy: resp.asset_id_buy,
1631
- asset_id_sell: resp.asset_id_sell,
1632
- expiration_timestamp: resp.expiration_timestamp,
1633
- include_fees: true,
1634
- fees: request.fees,
1635
- nonce: resp.nonce,
1636
- stark_key: resp.stark_key,
1637
- stark_signature: starkSignature,
1638
- vault_id_buy: resp.vault_id_buy,
1639
- vault_id_sell: resp.vault_id_sell,
1640
- },
1641
- xImxEthAddress: ethAddress,
1642
- xImxEthSignature: ethSignature,
1643
- };
1644
- const createOrderResponse = await ordersApi.createOrder(orderParams);
1645
- return {
1646
- ...createOrderResponse.data,
1647
- };
1648
- }
1649
- async function cancelOrder({ signers, request, config, }) {
1650
- const ordersApi = new coreSdk.OrdersApi(config.immutableXConfig.apiConfiguration);
1651
- const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
1652
- getSignableCancelOrderRequest: {
1653
- order_id: request.order_id,
1654
- },
1655
- });
1656
- const { signable_message: signableMessage, payload_hash: payloadHash } = getSignableCancelOrderResponse.data;
1657
- const ethSignature = await signRaw(signableMessage, signers.ethSigner);
1658
- const starkSignature = await signers.starkSigner.signMessage(payloadHash);
1659
- const ethAddress = await signers.ethSigner.getAddress();
1660
- const cancelOrderResponse = await ordersApi.cancelOrder({
1661
- id: request.order_id.toString(),
1662
- cancelOrderRequest: {
1663
- order_id: request.order_id,
1664
- stark_signature: starkSignature,
1665
- },
1666
- xImxEthAddress: ethAddress,
1667
- xImxEthSignature: ethSignature,
1668
- });
1669
- return {
1670
- order_id: cancelOrderResponse.data.order_id,
1671
- status: cancelOrderResponse.data.status,
1672
- };
1673
- }
1674
-
1675
- async function registerOffchain(signers, config) {
1676
- await validateChain(signers.ethSigner, config.immutableXConfig);
1677
- const usersApi = new coreSdk.UsersApi(config.immutableXConfig.apiConfiguration);
1678
- const userAddress = await signers.ethSigner.getAddress();
1679
- const starkPublicKey = await signers.starkSigner.getAddress();
1680
- const signableResult = await usersApi.getSignableRegistrationOffchain({
1681
- getSignableRegistrationRequest: {
1682
- ether_key: userAddress,
1683
- stark_key: starkPublicKey,
1684
- },
1685
- });
1686
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
1687
- const ethSignature = await signRaw(signableMessage, signers.ethSigner);
1688
- const starkSignature = await signers.starkSigner.signMessage(payloadHash);
1689
- const registeredUser = await usersApi.registerUser({
1690
- registerUserRequest: {
1691
- eth_signature: ethSignature,
1692
- ether_key: userAddress,
1693
- stark_signature: starkSignature,
1694
- stark_key: starkPublicKey,
1695
- },
1696
- });
1697
- return registeredUser.data;
1698
- }
1699
- async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
1700
- await validateChain(ethSigner, config.immutableXConfig);
1701
- const registrationContract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
1702
- try {
1703
- return await registrationContract.isRegistered(starkPublicKey);
1704
- }
1705
- catch (ex) {
1706
- if (ex.reason === 'USER_UNREGISTERED') {
1707
- return false;
1708
- }
1709
- throw ex;
1710
- }
1711
- }
1712
- async function getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi) {
1713
- const response = await usersApi.getSignableRegistration({
1714
- getSignableRegistrationRequest: {
1715
- ether_key: etherKey,
1716
- stark_key: starkPublicKey,
1717
- },
1718
- });
1719
- return {
1720
- operator_signature: response.data.operator_signature,
1721
- payload_hash: response.data.payload_hash,
1722
- };
1723
- }
1724
-
1725
- const assertIsDefined = (value) => {
1726
- if (value !== undefined)
1727
- return value;
1728
- throw new Error('undefined field exception');
1729
- };
1730
- async function prepareWithdrawalAction(params) {
1731
- const { signers: { ethSigner, starkSigner }, type, config, } = params;
1732
- await validateChain(ethSigner, params.config);
1733
- const withdrawalsApi = new coreSdk.WithdrawalsApi(config.apiConfiguration);
1734
- const withdrawalAmount = type === 'ERC721' ? '1' : params.amount;
1735
- const signableWithdrawalResult = await withdrawalsApi.getSignableWithdrawal({
1736
- getSignableWithdrawalRequest: {
1737
- user: await ethSigner.getAddress(),
1738
- token: convertToSignableToken(params),
1739
- amount: withdrawalAmount,
1740
- },
1741
- });
1742
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableWithdrawalResult.data;
1743
- const starkSignature = await starkSigner.signMessage(payloadHash);
1744
- const { ethAddress, ethSignature } = await signMessage(signableMessage, ethSigner);
1745
- const prepareWithdrawalResponse = await withdrawalsApi.createWithdrawal({
1746
- createWithdrawalRequest: {
1747
- stark_key: assertIsDefined(signableWithdrawalResult.data.stark_key),
1748
- amount: withdrawalAmount,
1749
- asset_id: assertIsDefined(signableWithdrawalResult.data.asset_id),
1750
- vault_id: assertIsDefined(signableWithdrawalResult.data.vault_id),
1751
- nonce: assertIsDefined(signableWithdrawalResult.data.nonce),
1752
- stark_signature: starkSignature,
1753
- },
1754
- xImxEthAddress: ethAddress,
1755
- xImxEthSignature: ethSignature,
1756
- });
1757
- return prepareWithdrawalResponse.data;
1758
- }
1759
-
1760
- async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
1761
- const encodingApi = new coreSdk.EncodingApi(config.apiConfiguration);
1762
- const result = await encodingApi.encodeAsset({
1763
- assetType,
1764
- encodeAssetRequest: {
1765
- token: {
1766
- type: tokenType,
1767
- ...(tokenData && { data: tokenData }),
1768
- },
1769
- },
1770
- });
1771
- return result.data;
1772
- }
1773
-
1774
- async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
1775
- const etherKey = await ethSigner.getAddress();
1776
- const imxConfig = config.immutableXConfig;
1777
- const usersApi = new coreSdk.UsersApi(imxConfig.apiConfiguration);
1778
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
1779
- const contract = coreSdk.Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
1780
- const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
1781
- return ethSigner.sendTransaction(populatedTransaction);
1782
- }
1783
- async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config) {
1784
- const contract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
1785
- const populatedTransaction = await contract.populateTransaction.withdraw(starkPublicKey, assetType);
1786
- return ethSigner.sendTransaction(populatedTransaction);
1787
- }
1788
- async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
1789
- await validateChain(ethSigner, config.immutableXConfig);
1790
- const imxConfig = config.immutableXConfig;
1791
- const assetType = await getEncodeAssetInfo('asset', 'ERC20', imxConfig, {
1792
- token_address: token.tokenAddress,
1793
- });
1794
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
1795
- if (!isRegistered) {
1796
- return executeRegisterAndWithdrawERC20({
1797
- ethSigner,
1798
- assetType: assetType.asset_type,
1799
- starkPublicKey,
1800
- config,
1801
- });
1802
- }
1803
- else {
1804
- return executeWithdrawERC20(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
1805
- }
1806
- }
1807
-
1808
- async function executeWithdrawMintableERC721(ethSigner, assetType, starkPublicKey, mintingBlob, config) {
1809
- const contract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
1810
- const populatedTransaction = await contract.populateTransaction.withdrawAndMint(starkPublicKey, assetType, mintingBlob);
1811
- return ethSigner.sendTransaction(populatedTransaction);
1812
- }
1813
- async function executeRegisterAndWithdrawMintableERC721(ethSigner, assetType, starkPublicKey, mintingBlob, config) {
1814
- const etherKey = await ethSigner.getAddress();
1815
- const usersApi = new coreSdk.UsersApi(config.apiConfiguration);
1816
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
1817
- const contract = coreSdk.Contracts.Registration.connect(config.ethConfiguration.registrationContractAddress, ethSigner);
1818
- const populatedTransaction = await contract.populateTransaction.regsiterAndWithdrawAndMint(etherKey, starkPublicKey, signableResult.operator_signature, assetType, mintingBlob);
1819
- return ethSigner.sendTransaction(populatedTransaction);
1820
- }
1821
- function getMintingBlob(token) {
1822
- const id = token.data.id;
1823
- const blueprint = token.data.blueprint || '';
1824
- return encUtils__namespace.sanitizeHex(encUtils__namespace.utf8ToHex(`{${id}}:{${blueprint}}`));
1825
- }
1826
- async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
1827
- const imxConfig = config.immutableXConfig;
1828
- const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', imxConfig, {
1829
- id: token.data.id,
1830
- token_address: token.data.tokenAddress,
1831
- ...(token.data.blueprint && { blueprint: token.data.blueprint }),
1832
- });
1833
- const mintingBlob = getMintingBlob(token);
1834
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
1835
- if (!isRegistered) {
1836
- return executeRegisterAndWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
1837
- }
1838
- else {
1839
- return executeWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
1840
- }
1841
- }
1842
- async function executeRegisterAndWithdrawERC721(ethSigner, assetType, starkPublicKey, tokenId, config) {
1843
- const etherKey = await ethSigner.getAddress();
1844
- const usersApi = new coreSdk.UsersApi(config.apiConfiguration);
1845
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
1846
- const contract = coreSdk.Contracts.Registration.connect(config.ethConfiguration.registrationContractAddress, ethSigner);
1847
- const populatedTransaction = await contract.populateTransaction.registerAndWithdrawNft(etherKey, starkPublicKey, signableResult.operator_signature, assetType, tokenId);
1848
- return ethSigner.sendTransaction(populatedTransaction);
1849
- }
1850
- async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, tokenId, config) {
1851
- const contract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
1852
- const populatedTransaction = await contract.populateTransaction.withdrawNft(starkPublicKey, assetType, tokenId);
1853
- return ethSigner.sendTransaction(populatedTransaction);
1854
- }
1855
- async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
1856
- const imxConfig = config.immutableXConfig;
1857
- const assetType = await getEncodeAssetInfo('asset', 'ERC721', imxConfig, {
1858
- token_id: token.tokenId,
1859
- token_address: token.tokenAddress,
1860
- });
1861
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
1862
- if (!isRegistered) {
1863
- return executeRegisterAndWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
1864
- }
1865
- else {
1866
- return executeWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
1867
- }
1868
- }
1869
- async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
1870
- await validateChain(ethSigner, config.immutableXConfig);
1871
- const tokenAddress = token.tokenAddress;
1872
- const tokenId = token.tokenId;
1873
- const imxConfig = config.immutableXConfig;
1874
- const mintsApi = new coreSdk.MintsApi(imxConfig.apiConfiguration);
1875
- return await mintsApi
1876
- .getMintableTokenDetailsByClientTokenId({
1877
- tokenAddress,
1878
- tokenId,
1879
- })
1880
- .then((mintableToken) => completeMintableERC721Withdrawal(ethSigner, starkPublicKey, {
1881
- type: 'ERC721',
1882
- data: {
1883
- id: tokenId,
1884
- tokenAddress: tokenAddress,
1885
- blueprint: mintableToken.data.blueprint,
1886
- },
1887
- }, config))
1888
- .catch((error) => {
1889
- if (error.response?.status === 404) {
1890
- // token is already minted on L1
1891
- return completeERC721Withdrawal(ethSigner, starkPublicKey, token, config);
1892
- }
1893
- throw error; // unable to recover from any other kind of error
1894
- });
1895
- }
1896
-
1897
- async function executeRegisterAndWithdrawEth(ethSigner, assetType, starkPublicKey, config) {
1898
- const etherKey = await ethSigner.getAddress();
1899
- const usersApi = new coreSdk.UsersApi(config.apiConfiguration);
1900
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
1901
- const contract = coreSdk.Contracts.Registration.connect(config.ethConfiguration.registrationContractAddress, ethSigner);
1902
- const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
1903
- return ethSigner.sendTransaction(populatedTransaction);
1904
- }
1905
- async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config) {
1906
- const contract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
1907
- const populatedTransaction = await contract.populateTransaction.withdraw(starkPublicKey, assetType);
1908
- return ethSigner.sendTransaction(populatedTransaction);
1909
- }
1910
- async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
1911
- await validateChain(ethSigner, config.immutableXConfig);
1912
- const imxConfig = config.immutableXConfig;
1913
- const assetType = await getEncodeAssetInfo('asset', 'ETH', imxConfig);
1914
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
1915
- if (!isRegistered) {
1916
- return executeRegisterAndWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
1917
- }
1918
- else {
1919
- return executeWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
1920
- }
1921
- }
1922
-
1923
- async function prepareWithdrawal({ signers, withdrawal, config, }) {
1924
- return prepareWithdrawalAction({
1925
- signers,
1926
- config: config.immutableXConfig,
1927
- ...withdrawal,
1928
- });
1929
- }
1930
- async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, token, config, }) {
1931
- switch (token.type) {
1932
- case 'ETH':
1933
- return completeEthWithdrawalAction({ ethSigner, starkPublicKey, config });
1934
- case 'ERC20':
1935
- return completeERC20WithdrawalAction({
1936
- ethSigner,
1937
- starkPublicKey,
1938
- token,
1939
- config,
1940
- });
1941
- case 'ERC721':
1942
- return completeERC721WithdrawalAction({
1943
- ethSigner,
1944
- starkPublicKey,
1945
- token,
1946
- config,
1947
- });
1948
- }
1949
- }
1950
-
1951
- async function createTrade({ signers: { ethSigner, starkSigner }, request, config, }) {
1952
- await validateChain(ethSigner, config.immutableXConfig);
1953
- const ethAddress = await ethSigner.getAddress();
1954
- const tradesApi = new coreSdk.TradesApi(config.immutableXConfig.apiConfiguration);
1955
- const signableResult = await tradesApi.getSignableTrade({
1956
- getSignableTradeRequest: {
1957
- user: ethAddress,
1958
- order_id: request.order_id,
1959
- fees: request.fees,
1960
- },
1961
- });
1962
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
1963
- const ethSignature = await signRaw(signableMessage, ethSigner);
1964
- const starkSignature = await starkSigner.signMessage(payloadHash);
1965
- const createTradeResponse = await tradesApi.createTrade({
1966
- createTradeRequest: {
1967
- amount_buy: signableResult.data.amount_buy,
1968
- amount_sell: signableResult.data.amount_sell,
1969
- asset_id_buy: signableResult.data.asset_id_buy,
1970
- asset_id_sell: signableResult.data.asset_id_sell,
1971
- expiration_timestamp: signableResult.data.expiration_timestamp,
1972
- fee_info: signableResult.data.fee_info,
1973
- fees: request.fees,
1974
- include_fees: true,
1975
- nonce: signableResult.data.nonce,
1976
- order_id: request.order_id,
1977
- stark_key: signableResult.data.stark_key,
1978
- vault_id_buy: signableResult.data.vault_id_buy,
1979
- vault_id_sell: signableResult.data.vault_id_sell,
1980
- stark_signature: starkSignature,
1981
- },
1982
- xImxEthAddress: ethAddress,
1983
- xImxEthSignature: ethSignature,
1984
- });
1985
- return createTradeResponse.data;
1986
- }
1987
-
1988
- async function depositEth({ signers: { ethSigner }, deposit, config, }) {
1989
- await validateChain(ethSigner, config.immutableXConfig);
1990
- const user = await ethSigner.getAddress();
1991
- const data = {
1992
- decimals: 18,
1993
- };
1994
- const amount = units.parseUnits(deposit.amount, 'wei');
1995
- const imxConfig = config.immutableXConfig;
1996
- const depositsApi = new coreSdk.DepositsApi(imxConfig.apiConfiguration);
1997
- const encodingApi = new coreSdk.EncodingApi(imxConfig.apiConfiguration);
1998
- const usersApi = new coreSdk.UsersApi(imxConfig.apiConfiguration);
1999
- const getSignableDepositRequest = {
2000
- user,
2001
- token: {
2002
- type: deposit.type,
2003
- data,
2004
- },
2005
- amount: amount.toString(),
2006
- };
2007
- const signableDepositResult = await depositsApi.getSignableDeposit({
2008
- getSignableDepositRequest,
2009
- });
2010
- const encodingResult = await encodingApi.encodeAsset({
2011
- assetType: 'asset',
2012
- encodeAssetRequest: {
2013
- token: {
2014
- type: deposit.type,
2015
- },
2016
- },
2017
- });
2018
- const assetType = encodingResult.data.asset_type;
2019
- const starkPublicKey = signableDepositResult.data.stark_key;
2020
- const vaultId = signableDepositResult.data.vault_id;
2021
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
2022
- if (!isRegistered) {
2023
- return executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig, usersApi);
2024
- }
2025
- else {
2026
- return executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig);
2027
- }
2028
- }
2029
- async function executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config, usersApi) {
2030
- const etherKey = await ethSigner.getAddress();
2031
- const coreContract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
2032
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
2033
- const populatedTransaction = await coreContract.populateTransaction.registerAndDepositEth(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId);
2034
- return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
2035
- }
2036
- async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config) {
2037
- const coreContract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
2038
- const populatedTransaction = await coreContract.populateTransaction['deposit(uint256,uint256,uint256)'](starkPublicKey, assetType, vaultId);
2039
- return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
2040
- }
2041
-
2042
- async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
2043
- await validateChain(ethSigner, config.immutableXConfig);
2044
- const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
2045
- const user = await ethSigner.getAddress();
2046
- const tokensApi = new coreSdk.TokensApi(apiConfiguration);
2047
- const depositsApi = new coreSdk.DepositsApi(apiConfiguration);
2048
- const encodingApi = new coreSdk.EncodingApi(apiConfiguration);
2049
- const usersApi = new coreSdk.UsersApi(apiConfiguration);
2050
- // Get decimals for this specific ERC20
2051
- const token = await tokensApi.getToken({ address: deposit.tokenAddress });
2052
- const decimals = parseInt(token.data.decimals);
2053
- const data = {
2054
- decimals,
2055
- token_address: deposit.tokenAddress,
2056
- };
2057
- const amount = units.parseUnits(deposit.amount, 0); // 0 to always use undecimalized value
2058
- // Approve whether an amount of token from an account can be spent by a third-party account
2059
- const tokenContract = coreSdk.Contracts.IERC20.connect(deposit.tokenAddress, ethSigner);
2060
- const approveTransaction = await tokenContract.populateTransaction.approve(ethConfiguration.coreContractAddress, amount);
2061
- await ethSigner.sendTransaction(approveTransaction);
2062
- const getSignableDepositRequest = {
2063
- user,
2064
- token: {
2065
- type: deposit.type,
2066
- data,
2067
- },
2068
- amount: amount.toString(),
2069
- };
2070
- const signableDepositResult = await depositsApi.getSignableDeposit({
2071
- getSignableDepositRequest,
2072
- });
2073
- // Perform encoding on asset details to get an assetType (required for stark contract request)
2074
- const encodingResult = await encodingApi.encodeAsset({
2075
- assetType: 'asset',
2076
- encodeAssetRequest: {
2077
- token: {
2078
- type: deposit.type,
2079
- data: {
2080
- token_address: deposit.tokenAddress,
2081
- },
2082
- },
2083
- },
2084
- });
2085
- const assetType = encodingResult.data.asset_type;
2086
- const starkPublicKey = signableDepositResult.data.stark_key;
2087
- const vaultId = signableDepositResult.data.vault_id;
2088
- const quantizedAmount = bignumber.BigNumber.from(signableDepositResult.data.amount);
2089
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
2090
- if (!isRegistered) {
2091
- return executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration, usersApi);
2092
- }
2093
- else {
2094
- return executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration);
2095
- }
2096
- }
2097
- async function executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config) {
2098
- const coreContract = coreSdk.Contracts.Core.connect(config.coreContractAddress, ethSigner);
2099
- const populatedTransaction = await coreContract.populateTransaction.depositERC20(starkPublicKey, assetType, vaultId, quantizedAmount);
2100
- return ethSigner.sendTransaction(populatedTransaction);
2101
- }
2102
- async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config, usersApi) {
2103
- const etherKey = await ethSigner.getAddress();
2104
- const coreContract = coreSdk.Contracts.Core.connect(config.coreContractAddress, ethSigner);
2105
- const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
2106
- const populatedTransaction = await coreContract.populateTransaction.registerAndDepositERC20(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId, quantizedAmount);
2107
- return ethSigner.sendTransaction(populatedTransaction);
2108
- }
2109
-
2110
- async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
2111
- await validateChain(ethSigner, config.immutableXConfig);
2112
- const user = await ethSigner.getAddress();
2113
- const { immutableXConfig } = config;
2114
- const depositsApi = new coreSdk.DepositsApi(immutableXConfig.apiConfiguration);
2115
- const encodingApi = new coreSdk.EncodingApi(immutableXConfig.apiConfiguration);
2116
- const usersApi = new coreSdk.UsersApi(immutableXConfig.apiConfiguration);
2117
- const data = {
2118
- token_address: deposit.tokenAddress,
2119
- token_id: deposit.tokenId,
2120
- };
2121
- const amount = '1';
2122
- const getSignableDepositRequest = {
2123
- user,
2124
- token: {
2125
- type: deposit.type,
2126
- data,
2127
- },
2128
- amount: amount.toString(),
2129
- };
2130
- const signableDepositResult = await depositsApi.getSignableDeposit({
2131
- getSignableDepositRequest,
2132
- });
2133
- // Perform encoding on asset details to get an assetType (required for stark contract request)
2134
- const encodingResult = await encodingApi.encodeAsset({
2135
- assetType: 'asset',
2136
- encodeAssetRequest: {
2137
- token: {
2138
- type: deposit.type,
2139
- data: {
2140
- token_address: deposit.tokenAddress,
2141
- token_id: deposit.tokenId,
2142
- },
2143
- },
2144
- },
2145
- });
2146
- const assetType = encodingResult.data.asset_type;
2147
- const starkPublicKey = signableDepositResult.data.stark_key;
2148
- const vaultId = signableDepositResult.data.vault_id;
2149
- const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
2150
- // Approve whether an amount of token from an account can be spent by a third-party account
2151
- const tokenContract = coreSdk.Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
2152
- const operator = immutableXConfig.ethConfiguration.coreContractAddress;
2153
- const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
2154
- if (!isApprovedForAll) {
2155
- await tokenContract.setApprovalForAll(operator, true);
2156
- }
2157
- if (!isRegistered) {
2158
- const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
2159
- const coreContract = coreSdk.Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
2160
- // Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
2161
- await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
2162
- }
2163
- return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
2164
- }
2165
- async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
2166
- const coreContract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
2167
- const populatedTransaction = await coreContract.populateTransaction.depositNft(starkPublicKey, assetType, vaultId, tokenId);
2168
- return ethSigner.sendTransaction(populatedTransaction);
2169
- }
2170
-
2171
- async function deposit({ signers, deposit, config }) {
2172
- switch (deposit.type) {
2173
- case 'ETH':
2174
- return depositEth({ signers, deposit, config });
2175
- case 'ERC20':
2176
- return depositERC20({ signers, deposit, config });
2177
- case 'ERC721':
2178
- return depositERC721({ signers, deposit, config });
2179
- }
2180
- }
2181
-
2182
- async function exchangeTransfer({ signers, request, config, }) {
2183
- await validateChain(signers.ethSigner, config.immutableXConfig);
2184
- const exchangeApi = new coreSdk.ExchangesApi(config.immutableXConfig.apiConfiguration);
2185
- const ethAddress = await signers.ethSigner.getAddress();
2186
- const transferAmount = request.amount;
2187
- const signableResult = await exchangeApi.getExchangeSignableTransfer({
2188
- id: request.transactionID,
2189
- getSignableTransferRequest: {
2190
- sender: ethAddress,
2191
- token: convertToSignableToken(request),
2192
- amount: transferAmount,
2193
- receiver: request.receiver,
2194
- },
2195
- });
2196
- const { signable_message: signableMessage, payload_hash: payloadHash } = signableResult.data;
2197
- const ethSignature = await signRaw(signableMessage, signers.ethSigner);
2198
- const starkSignature = await signers.starkSigner.signMessage(payloadHash);
2199
- const transferSigningParams = {
2200
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
2201
- sender_stark_key: signableResult.data.sender_stark_key,
2202
- sender_vault_id: signableResult.data.sender_vault_id,
2203
- receiver_stark_key: signableResult.data.receiver_stark_key,
2204
- receiver_vault_id: signableResult.data.receiver_vault_id,
2205
- asset_id: signableResult.data.asset_id,
2206
- amount: signableResult.data.amount,
2207
- nonce: signableResult.data.nonce,
2208
- expiration_timestamp: signableResult.data.expiration_timestamp,
2209
- stark_signature: starkSignature,
2210
- };
2211
- const response = await exchangeApi.createExchangeTransfer({
2212
- id: request.transactionID,
2213
- createTransferRequest: transferSigningParams,
2214
- xImxEthAddress: ethAddress,
2215
- xImxEthSignature: ethSignature,
2216
- });
2217
- return {
2218
- sent_signature: response?.data.sent_signature,
2219
- status: response?.data.status?.toString(),
2220
- time: response?.data.time,
2221
- transfer_id: response?.data.transfer_id,
2222
- };
2223
- }
2224
-
2225
- class GenericIMXProvider {
2226
- config;
2227
- signers;
2228
- constructor(config, ethSigner, starkSigner) {
2229
- this.config = config;
2230
- this.signers = { ethSigner, starkSigner };
2231
- }
2232
- async getAddress() {
2233
- return await this.signers.ethSigner.getAddress();
2234
- }
2235
- registerOffchain() {
2236
- return registerOffchain(this.signers, this.config);
2237
- }
2238
- batchNftTransfer(request) {
2239
- return batchTransfer({
2240
- signers: this.signers,
2241
- request,
2242
- config: this.config,
2243
- });
2244
- }
2245
- cancelOrder(request) {
2246
- return cancelOrder({
2247
- signers: this.signers,
2248
- request,
2249
- config: this.config,
2250
- });
2251
- }
2252
- completeWithdrawal(starkPublicKey, token) {
2253
- return completeWithdrawal({
2254
- config: this.config,
2255
- signers: this.signers,
2256
- token,
2257
- starkPublicKey,
2258
- });
2259
- }
2260
- createOrder(request) {
2261
- return createOrder({
2262
- signers: this.signers,
2263
- request,
2264
- config: this.config,
2265
- });
2266
- }
2267
- createTrade(request) {
2268
- return createTrade({
2269
- signers: this.signers,
2270
- request,
2271
- config: this.config,
2272
- });
2273
- }
2274
- deposit(tokenAmount) {
2275
- return deposit({
2276
- signers: this.signers,
2277
- deposit: tokenAmount,
2278
- config: this.config,
2279
- });
2280
- }
2281
- exchangeTransfer(request) {
2282
- return exchangeTransfer({
2283
- signers: this.signers,
2284
- request,
2285
- config: this.config,
2286
- });
2287
- }
2288
- async isRegisteredOnchain() {
2289
- const starkPublicKey = await this.signers.starkSigner.getAddress();
2290
- return isRegisteredOnChain(starkPublicKey, this.signers.ethSigner, this.config);
2291
- }
2292
- prepareWithdrawal(request) {
2293
- return prepareWithdrawal({
2294
- signers: this.signers,
2295
- withdrawal: request,
2296
- config: this.config,
2297
- });
2298
- }
2299
- transfer(request) {
2300
- return transfer({
2301
- signers: this.signers,
2302
- request,
2303
- config: this.config,
2304
- });
2305
- }
2306
- }
2307
-
2308
- const WALLET_ACTION = {
2309
- SWITCH_CHAIN: 'wallet_switchEthereumChain',
2310
- CONNECT: 'eth_requestAccounts',
2311
- };
2312
- function isRequestableProvider(provider) {
2313
- return !!provider?.request;
2314
- }
2315
- async function connectProvider(provider, chainID) {
2316
- await provider.request({ method: WALLET_ACTION.CONNECT });
2317
- if (chainID) {
2318
- await provider.request({
2319
- method: WALLET_ACTION.SWITCH_CHAIN,
2320
- params: [{ chainId: `0x${chainID.toString(16)}` }],
2321
- });
2322
- }
2323
- }
2324
-
2325
- const ERRORS = {
2326
- PROVIDER_NOT_FOUND: 'The Metamask provider was not found',
2327
- };
2328
- async function connect$1({ chainID, }) {
2329
- const provider = (await detectEthereumProvider());
2330
- if (!isRequestableProvider(provider)) {
2331
- throw new Error(ERRORS.PROVIDER_NOT_FOUND);
2332
- }
2333
- await connectProvider(provider, chainID);
2334
- // NOTE: if we want to listen to Metamask events in the future, we can add a
2335
- // listener here.
2336
- return new ethers.ethers.providers.Web3Provider(provider);
2337
- }
2338
-
2339
- const COMMUNICATION_TYPE = 'message';
2340
- var RequestEventType;
2341
- (function (RequestEventType) {
2342
- RequestEventType["GET_CONNECTION_REQUEST"] = "GET_CONNECTION_REQUEST";
2343
- RequestEventType["CONNECT_WALLET_REQUEST"] = "CONNECT_WALLET_REQUEST";
2344
- RequestEventType["SIGN_MESSAGE_REQUEST"] = "SIGN_MESSAGE_REQUEST";
2345
- RequestEventType["DISCONNECT_WALLET_REQUEST"] = "DISCONNECT_WALLET_REQUEST";
2346
- })(RequestEventType || (RequestEventType = {}));
2347
- var ResponseEventType;
2348
- (function (ResponseEventType) {
2349
- ResponseEventType["CONNECT_WALLET_RESPONSE"] = "CONNECT_WALLET_RESPONSE";
2350
- ResponseEventType["SIGN_MESSAGE_RESPONSE"] = "SIGN_MESSAGE_RESPONSE";
2351
- ResponseEventType["GET_CONNECTION_RESPONSE"] = "GET_CONNECTION_RESPONSE";
2352
- ResponseEventType["DISCONNECT_WALLET_RESPONSE"] = "DISCONNECT_WALLET_RESPONSE";
2353
- })(ResponseEventType || (ResponseEventType = {}));
2354
-
2355
- function postRequestMessage(iframe, payload) {
2356
- if (iframe && iframe.contentWindow) {
2357
- iframe.contentWindow.postMessage(payload, new URL(iframe.src).origin);
2358
- }
2359
- }
2360
-
2361
- function messageResponseListener(iframe, event, eventType, callback) {
2362
- if (iframe && event.source !== iframe.contentWindow) {
2363
- return;
2364
- }
2365
- const l2WalletMessage = event.data;
2366
- if (l2WalletMessage.type !== eventType) {
2367
- return;
2368
- }
2369
- callback(l2WalletMessage.details);
2370
- }
2371
-
2372
- class ImxSigner {
2373
- publicAddress;
2374
- iframe;
2375
- constructor(publicAddress, iframe) {
2376
- this.publicAddress = publicAddress;
2377
- this.iframe = iframe;
2378
- }
2379
- getAddress() {
2380
- return this.publicAddress;
2381
- }
2382
- signMessage(rawMessage) {
2383
- return new Promise((resolve, reject) => {
2384
- const listener = (event) => {
2385
- messageResponseListener(this.iframe, event, ResponseEventType.SIGN_MESSAGE_RESPONSE, (messageDetails) => {
2386
- window.removeEventListener(COMMUNICATION_TYPE, listener);
2387
- if (!messageDetails.success) {
2388
- reject(new Error(messageDetails.error?.message));
2389
- }
2390
- resolve(messageDetails.data.signedMessage);
2391
- });
2392
- };
2393
- window.addEventListener(COMMUNICATION_TYPE, listener);
2394
- postRequestMessage(this.iframe, {
2395
- type: RequestEventType.SIGN_MESSAGE_REQUEST,
2396
- details: { starkPublicKey: this.publicAddress, message: rawMessage },
2397
- });
2398
- });
2399
- }
2400
- getIFrame() {
2401
- return this.iframe;
2402
- }
2403
- }
2404
-
2405
- const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
2406
- const IMX_WALLET_IFRAME_HOSTS = {
2407
- [exports.Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
2408
- [exports.Environment.PRODUCTION]: 'https://wallets.immutable.com',
2409
- };
2410
- const IMX_WALLET_IFRAME_STYLE = 'display: none;';
2411
- function getIFrame() {
2412
- return document.querySelector(`iframe#${IMX_WALLET_IFRAME_ID}`);
2413
- }
2414
- async function setupIFrame(env) {
2415
- return new Promise((resolve) => {
2416
- const iframe = document.createElement('iframe');
2417
- iframe.setAttribute('id', IMX_WALLET_IFRAME_ID);
2418
- iframe.setAttribute('src', IMX_WALLET_IFRAME_HOSTS[env]);
2419
- iframe.setAttribute('style', IMX_WALLET_IFRAME_STYLE);
2420
- document.body.appendChild(iframe);
2421
- iframe.onload = () => resolve(iframe);
2422
- });
2423
- }
2424
- async function getOrSetupIFrame(env) {
2425
- const iframe = getIFrame();
2426
- if (iframe)
2427
- return iframe;
2428
- return await setupIFrame(env);
2429
- }
2430
-
2431
- const DEFAULT_CONNECTION_MESSAGE = 'Only sign this request if you’ve initiated an action with Immutable X.';
2432
- const CONNECTION_FAILED_ERROR = 'The L2 IMX Wallet connection has failed';
2433
- async function connect(l1Provider, env) {
2434
- const l1Signer = l1Provider.getSigner();
2435
- const address = await l1Signer.getAddress();
2436
- const signature = await l1Signer.signMessage(DEFAULT_CONNECTION_MESSAGE);
2437
- const iframe = await getOrSetupIFrame(env);
2438
- return new Promise((resolve, reject) => {
2439
- const listener = (event) => {
2440
- messageResponseListener(iframe, event, ResponseEventType.CONNECT_WALLET_RESPONSE, (messageDetails) => {
2441
- window.removeEventListener(COMMUNICATION_TYPE, listener);
2442
- if (!messageDetails.success) {
2443
- reject(new Error(CONNECTION_FAILED_ERROR));
2444
- }
2445
- resolve(new ImxSigner(messageDetails.data.starkPublicKey, iframe));
2446
- });
2447
- };
2448
- window.addEventListener(COMMUNICATION_TYPE, listener);
2449
- postRequestMessage(iframe, {
2450
- type: RequestEventType.CONNECT_WALLET_REQUEST,
2451
- details: { ethAddress: address, signature },
2452
- });
2453
- });
2454
- }
2455
- async function disconnect(imxSigner) {
2456
- const iframe = imxSigner.getIFrame();
2457
- return new Promise((resolve, reject) => {
2458
- const listener = (event) => {
2459
- messageResponseListener(iframe, event, ResponseEventType.DISCONNECT_WALLET_RESPONSE, (messageDetails) => {
2460
- window.removeEventListener(COMMUNICATION_TYPE, listener);
2461
- if (!messageDetails.success && messageDetails.error) {
2462
- reject(messageDetails.error);
2463
- }
2464
- iframe.remove();
2465
- resolve();
2466
- });
2467
- };
2468
- window.addEventListener(COMMUNICATION_TYPE, listener);
2469
- postRequestMessage(iframe, {
2470
- type: RequestEventType.DISCONNECT_WALLET_REQUEST,
2471
- details: { starkPublicKey: imxSigner.getAddress() },
2472
- });
2473
- });
2474
- }
2475
-
2476
- var ProviderErrorType;
2477
- (function (ProviderErrorType) {
2478
- ProviderErrorType["PROVIDER_CONNECTION_ERROR"] = "PROVIDER_CONNECTION_ERROR";
2479
- ProviderErrorType["WALLET_CONNECTION_ERROR"] = "WALLET_CONNECTION_ERROR";
2480
- })(ProviderErrorType || (ProviderErrorType = {}));
2481
- class ProviderError extends Error {
2482
- type;
2483
- constructor(message, type) {
2484
- super(message);
2485
- this.type = type;
2486
- }
2487
- }
2488
- const withProviderError = async (fn, customError) => {
2489
- try {
2490
- return await fn();
2491
- }
2492
- catch (error) {
2493
- const errorMessage = customError.message || `${error.message}` || 'UnknownError';
2494
- throw new ProviderError(errorMessage, customError.type);
2495
- }
2496
- };
2497
-
2498
- class MetaMaskIMXProvider extends GenericIMXProvider {
2499
- static imxSigner;
2500
- constructor(config, ethSigner, starkSigner) {
2501
- super(config, ethSigner, starkSigner);
2502
- }
2503
- static async connect(config) {
2504
- return await withProviderError(async () => {
2505
- const metaMaskProvider = await connect$1({
2506
- chainID: config.immutableXConfig.ethConfiguration.chainID,
2507
- });
2508
- this.imxSigner = await connect(metaMaskProvider, config.baseConfig.environment);
2509
- return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
2510
- }, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
2511
- }
2512
- static async disconnect() {
2513
- if (!this.imxSigner) {
2514
- throw new ProviderError('Attempted to disconnect from the MetaMask IMX provider without an established connection', ProviderErrorType.PROVIDER_CONNECTION_ERROR);
2515
- }
2516
- return withProviderError(async () => {
2517
- await disconnect(this.imxSigner);
2518
- }, { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
2519
- }
2520
- static async signMessage(message) {
2521
- if (!this.imxSigner) {
2522
- throw new ProviderError('Attempted to sign a message with the MetaMask IMX provider without an established connection', ProviderErrorType.PROVIDER_CONNECTION_ERROR);
2523
- }
2524
- return withProviderError(async () => {
2525
- return await this.imxSigner.signMessage(message);
2526
- }, { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
2527
- }
2528
- }
2529
-
2530
- class ProviderConfiguration {
2531
- immutableXConfig;
2532
- baseConfig;
2533
- constructor({ baseConfig, overrides }) {
2534
- this.baseConfig = baseConfig;
2535
- if (overrides) {
2536
- this.immutableXConfig = overrides.immutableXConfig;
2537
- }
2538
- else {
2539
- switch (baseConfig.environment) {
2540
- case exports.Environment.SANDBOX: {
2541
- this.immutableXConfig = coreSdk.Config.SANDBOX;
2542
- break;
2543
- }
2544
- case exports.Environment.PRODUCTION: {
2545
- this.immutableXConfig = coreSdk.Config.PRODUCTION;
2546
- break;
2547
- }
2548
- }
2549
- }
2550
- }
2551
- }
2552
-
2553
- function $parcel$interopDefault(a) {
2554
- return a && a.__esModule ? a.default : a;
2555
- }
2556
-
2557
- const $762782b6c862d954$export$db5daa1b5156ccfe = [
2558
- {
2559
- constant: true,
2560
- inputs: [],
2561
- name: "name",
2562
- outputs: [
2563
- {
2564
- name: "",
2565
- type: "string"
2566
- }
2567
- ],
2568
- payable: false,
2569
- type: "function"
2570
- },
2571
- {
2572
- constant: true,
2573
- inputs: [],
2574
- name: "decimals",
2575
- outputs: [
2576
- {
2577
- name: "",
2578
- type: "uint8"
2579
- }
2580
- ],
2581
- payable: false,
2582
- type: "function"
2583
- },
2584
- {
2585
- constant: true,
2586
- inputs: [
2587
- {
2588
- name: "_owner",
2589
- type: "address"
2590
- }
2591
- ],
2592
- name: "balanceOf",
2593
- outputs: [
2594
- {
2595
- name: "balance",
2596
- type: "uint256"
2597
- }
2598
- ],
2599
- payable: false,
2600
- type: "function"
2601
- },
2602
- {
2603
- constant: true,
2604
- inputs: [],
2605
- name: "symbol",
2606
- outputs: [
2607
- {
2608
- name: "",
2609
- type: "string"
2610
- }
2611
- ],
2612
- payable: false,
2613
- type: "function"
2614
- }
2615
- ];
2616
-
2617
-
2618
- exports.ConnectionProviders = void 0;
2619
- (function(ConnectionProviders) {
2620
- ConnectionProviders["METAMASK"] = "metamask";
2621
- })(exports.ConnectionProviders || (exports.ConnectionProviders = {}));
2622
-
2623
-
2624
- exports.ChainId = void 0;
2625
- (function(ChainId) {
2626
- ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
2627
- ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
2628
- ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
2629
- })(exports.ChainId || (exports.ChainId = {}));
2630
- const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
2631
- [exports.ChainId.ETHEREUM]: {
2632
- chainIdHex: "0x1",
2633
- chainName: "Ethereum",
2634
- rpcUrls: [
2635
- "https://mainnet.infura.io/v3/"
2636
- ],
2637
- nativeCurrency: {
2638
- name: "Ethereum",
2639
- symbol: "ETH",
2640
- decimals: 18
2641
- },
2642
- blockExplorerUrls: [
2643
- "https://etherscan.io/"
2644
- ]
2645
- },
2646
- [exports.ChainId.GOERLI]: {
2647
- chainIdHex: "0x5",
2648
- chainName: "Goerli",
2649
- rpcUrls: [
2650
- "https://goerli.infura.io/v3/"
2651
- ],
2652
- nativeCurrency: {
2653
- name: "Goerli Eth",
2654
- symbol: "ETH",
2655
- decimals: 18
2656
- },
2657
- blockExplorerUrls: [
2658
- "https://goerli.etherscan.io/"
2659
- ]
2660
- },
2661
- [exports.ChainId.POLYGON]: {
2662
- chainIdHex: "0x89",
2663
- chainName: "Polygon",
2664
- rpcUrls: [
2665
- "https://polygon-rpc.com"
2666
- ],
2667
- nativeCurrency: {
2668
- name: "MATIC",
2669
- symbol: "MATIC",
2670
- decimals: 18
2671
- },
2672
- blockExplorerUrls: [
2673
- "https://polygonscan.com/"
2674
- ]
2675
- }
2676
- };
2677
- exports.NetworkFilterTypes = void 0;
2678
- (function(NetworkFilterTypes) {
2679
- NetworkFilterTypes["ALL"] = "all";
2680
- })(exports.NetworkFilterTypes || (exports.NetworkFilterTypes = {}));
2681
-
2682
-
2683
- exports.TokenFilterTypes = void 0;
2684
- (function(TokenFilterTypes) {
2685
- TokenFilterTypes["SWAP"] = "swap";
2686
- TokenFilterTypes["BRIDGE"] = "bridge";
2687
- TokenFilterTypes["ALL"] = "all";
2688
- })(exports.TokenFilterTypes || (exports.TokenFilterTypes = {}));
2689
-
2690
-
2691
-
2692
-
2693
- const $4f91c5f280efe242$export$a130407f3423b97d = {
2694
- CHECK_CONNECTION: "eth_accounts",
2695
- CONNECT: "eth_requestAccounts",
2696
- ADD_NETWORK: "wallet_addEthereumChain",
2697
- SWITCH_NETWORK: "wallet_switchEthereumChain"
2698
- };
2699
- exports.WalletFilterTypes = void 0;
2700
- (function(WalletFilterTypes) {
2701
- WalletFilterTypes["ALL"] = "all";
2702
- WalletFilterTypes["DESKTOP"] = "desktop";
2703
- WalletFilterTypes["MOBILE"] = "mobile";
2704
- })(exports.WalletFilterTypes || (exports.WalletFilterTypes = {}));
2705
-
2706
-
2707
- exports.SupportedFiatCurrencies = void 0;
2708
- (function(SupportedFiatCurrencies) {
2709
- SupportedFiatCurrencies["USD"] = "USD";
2710
- })(exports.SupportedFiatCurrencies || (exports.SupportedFiatCurrencies = {}));
2711
-
2712
-
2713
-
2714
-
2715
- /**
2716
- * The different types of errors that can be returned by the checkout process.
2717
- */ exports.CheckoutErrorType = void 0;
2718
- (function(CheckoutErrorType) {
2719
- CheckoutErrorType["PROVIDER_PREFERENCE_ERROR"] = "PROVIDER_PREFERENCE_ERROR";
2720
- CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
2721
- CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
2722
- CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
2723
- CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
2724
- CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
2725
- CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
2726
- CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
2727
- CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
2728
- CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
2729
- CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
2730
- CheckoutErrorType["FIAT_CONVERSION_ERROR"] = "FIAT_CONVERSION_ERROR";
2731
- CheckoutErrorType["TOKEN_NOT_SUPPORTED_ERROR"] = "TOKEN_NOT_SUPPORTED_ERROR";
2732
- CheckoutErrorType["FIAT_CURRENCY_NOT_SUPPORTED_ERROR"] = "FIAT_CURRENCY_NOT_SUPPORTED_ERROR";
2733
- })(exports.CheckoutErrorType || (exports.CheckoutErrorType = {}));
2734
- class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
2735
- constructor(message, type, data){
2736
- super(message);
2737
- this.message = message;
2738
- this.type = type;
2739
- this.data = data;
2740
- }
2741
- }
2742
- let $a8bc256d81a5e2c1$export$a22d4e0719ee6def;
2743
- (function(CheckoutInternalErrorType) {
2744
- CheckoutInternalErrorType["REJECTED_SWITCH_AFTER_ADDING_NETWORK"] = "REJECTED_SWITCH_AFTER_ADDING_NETWORK";
2745
- })($a8bc256d81a5e2c1$export$a22d4e0719ee6def || ($a8bc256d81a5e2c1$export$a22d4e0719ee6def = {}));
2746
- const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
2747
- try {
2748
- return await fn();
2749
- } catch (error) {
2750
- const cause = `${error.message}` || "UnknownError";
2751
- const errorMessage = customError.message ? `[${customError.type}]:${customError.message}. Cause:${cause}` : `[${customError.type}] Cause:${cause}`;
2752
- if (error instanceof $a8bc256d81a5e2c1$export$b722478a3cbfa3bc) throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
2753
- ...customError.data,
2754
- innerErrorType: error.type,
2755
- ...error.data
2756
- });
2757
- throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
2758
- ...customError.data
2759
- });
2760
- }
2761
- };
2762
-
2763
-
2764
-
2765
-
2766
- /* eslint-disable @typescript-eslint/no-explicit-any */
2767
-
2768
- /* eslint-disable @typescript-eslint/no-explicit-any */
2769
-
2770
-
2771
-
2772
- async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
2773
- const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
2774
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", (exports.CheckoutErrorType).PROVIDER_REQUEST_MISSING_ERROR, {
2775
- details: `Unsupported provider for ${providerPreference}`
2776
- });
2777
- let accounts = [];
2778
- try {
2779
- accounts = await provider.provider.request({
2780
- method: (0, $4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
2781
- params: []
2782
- });
2783
- } catch (err) {
2784
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Check wallet connection request failed`, (exports.CheckoutErrorType).PROVIDER_REQUEST_FAILED_ERROR, {
2785
- rpcMethod: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION
2786
- });
2787
- }
2788
- // accounts[0] will have the active account if connected.
2789
- return {
2790
- isConnected: accounts && accounts.length > 0,
2791
- walletAddress: accounts[0] ?? ""
2792
- };
2793
- }
2794
- async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
2795
- const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
2796
- await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2797
- if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", (exports.CheckoutErrorType).PROVIDER_REQUEST_MISSING_ERROR, {
2798
- details: `Unsupported provider for ${params.providerPreference}`
2799
- });
2800
- // this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
2801
- await web3Provider.provider.request({
2802
- method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
2803
- params: []
2804
- });
2805
- }, {
2806
- type: (exports.CheckoutErrorType).USER_REJECTED_REQUEST_ERROR
2807
- });
2808
- return web3Provider;
2809
- }
2810
- async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
2811
- let web3Provider = null;
2812
- switch(providerPreference){
2813
- case (exports.ConnectionProviders).METAMASK:
2814
- web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
2815
- break;
2816
- default:
2817
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference is not supported", (exports.CheckoutErrorType).PROVIDER_PREFERENCE_ERROR);
2818
- }
2819
- return web3Provider;
2820
- }
2821
- async function $c99672cf2294e839$var$getMetaMaskProvider() {
2822
- const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2823
- return await (detectEthereumProvider)();
2824
- }, {
2825
- type: (exports.CheckoutErrorType).METAMASK_PROVIDER_ERROR
2826
- });
2827
- if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", (exports.CheckoutErrorType).METAMASK_PROVIDER_ERROR);
2828
- return new (providers.Web3Provider)(provider);
2829
- }
2830
-
2831
-
2832
- var $497c134ecbc8a50f$exports = {};
2833
- $497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":137}]');
2834
-
2835
-
2836
- const $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE = 4902; // error code (MetaMask)
2837
- async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
2838
- return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2839
- const network = await provider.getNetwork();
2840
- if (!Object.values((exports.ChainId)).includes(network.chainId)) // return empty details
2841
- return {
2842
- chainId: network.chainId,
2843
- name: network.name,
2844
- isSupported: false
2845
- };
2846
- const chainIdNetworkInfo = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[network.chainId];
2847
- return {
2848
- name: chainIdNetworkInfo.chainName,
2849
- chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
2850
- nativeCurrency: chainIdNetworkInfo.nativeCurrency,
2851
- isSupported: true
2852
- };
2853
- }, {
2854
- type: (exports.CheckoutErrorType).GET_NETWORK_INFO_ERROR
2855
- });
2856
- }
2857
- async function $de192de6ef100f9f$export$b827d9418aeb5dbd(providerPreference, provider, chainId) {
2858
- let currentProvider = provider;
2859
- if (!Object.values((exports.ChainId)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${chainId} is not a supported chain`, (exports.CheckoutErrorType).CHAIN_NOT_SUPPORTED_ERROR);
2860
- if (!currentProvider || !currentProvider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", (exports.CheckoutErrorType).PROVIDER_REQUEST_MISSING_ERROR, {
2861
- details: `Unsupported provider`
2862
- });
2863
- // WT-1146 - Refer to the README in this folder for explantion on the switch network flow
2864
- try {
2865
- await $de192de6ef100f9f$var$switchNetworkInWallet(currentProvider, chainId);
2866
- } catch (err) {
2867
- if (err.code === $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE) try {
2868
- await $de192de6ef100f9f$var$addNetworkToWallet(currentProvider, chainId);
2869
- } catch (err) {
2870
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled add network request", (exports.CheckoutErrorType).USER_REJECTED_REQUEST_ERROR);
2871
- }
2872
- else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", (exports.CheckoutErrorType).USER_REJECTED_REQUEST_ERROR);
2873
- }
2874
- currentProvider = await ($c99672cf2294e839$export$fba2f6c3656e07c1)({
2875
- providerPreference: providerPreference
2876
- });
2877
- if ((await currentProvider.getNetwork()).chainId !== chainId) // user didn't actually switch
2878
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", (exports.CheckoutErrorType).USER_REJECTED_REQUEST_ERROR);
2879
- // we can assume that if the above succeeds then user has successfully
2880
- // switched to the network specified
2881
- const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId];
2882
- return {
2883
- network: {
2884
- name: newNetwork.chainName,
2885
- chainId: parseInt(newNetwork.chainIdHex, 16),
2886
- nativeCurrency: newNetwork.nativeCurrency
2887
- },
2888
- provider: currentProvider
2889
- };
2890
- }
2891
- async function $de192de6ef100f9f$export$3043f6442a9ef563({ type: type = (exports.NetworkFilterTypes).ALL , exclude: exclude }) {
2892
- const list = ((/*@__PURE__*/$parcel$interopDefault($497c134ecbc8a50f$exports))).filter((network)=>{
2893
- const allowAllTokens = type === (exports.NetworkFilterTypes).ALL;
2894
- const networkNotExcluded = !(exclude || []).map((exc)=>exc.chainId).includes(network.chainId);
2895
- return allowAllTokens && networkNotExcluded;
2896
- });
2897
- const allowedNetworks = [];
2898
- list.forEach((element)=>{
2899
- const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[element.chainId];
2900
- allowedNetworks.push({
2901
- name: newNetwork.chainName,
2902
- chainId: parseInt(newNetwork.chainIdHex, 16),
2903
- nativeCurrency: newNetwork.nativeCurrency,
2904
- isSupported: true
2905
- });
2906
- });
2907
- return {
2908
- networks: allowedNetworks
2909
- };
2910
- }
2911
- // these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
2912
- // make sure to check if(provider.provider?.request) in the exported function and throw an error
2913
- async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
2914
- if (provider.provider?.request) return await provider.provider.request({
2915
- method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
2916
- params: [
2917
- {
2918
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
2919
- }
2920
- ]
2921
- });
2922
- }
2923
- async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
2924
- if (provider.provider?.request) {
2925
- const addNetwork = {
2926
- chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
2927
- chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
2928
- rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
2929
- nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
2930
- blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
2931
- };
2932
- return await provider.provider.request({
2933
- method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
2934
- params: [
2935
- addNetwork
2936
- ]
2937
- });
2938
- }
2939
- }
2940
-
2941
-
2942
-
2943
-
2944
-
2945
- var $cda6003506e4182e$exports = {};
2946
- $cda6003506e4182e$exports = JSON.parse("[{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":137,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":1,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF\",\"chainId\":1,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":1,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":5,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x1facdd0165489f373255a90304650e15481b2c85\",\"chainId\":5,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Swap Coin\",\"symbol\":\"SWC\",\"decimals\":18,\"tokenFeatures\":[\"swap\",\"fakeFeature\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Bridge Coin\",\"symbol\":\"BDC\",\"decimals\":18,\"tokenFeatures\":[\"bridge\",\"fakeFeature\"]}]");
2947
-
2948
-
2949
- const $efe60cea83bfc4e8$var$filterTokenList = function({ type: type , chainId: chainId , exclude: exclude }) {
2950
- return ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
2951
- const skipChainIdCheck = !chainId;
2952
- const chainIdMatches = token.chainId == chainId;
2953
- const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
2954
- const allowAllTokens = type === (exports.TokenFilterTypes).ALL;
2955
- const tokenAllowedForType = token.tokenFeatures.includes(type);
2956
- return (skipChainIdCheck || chainIdMatches) && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
2957
- });
2958
- };
2959
- const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type = (exports.TokenFilterTypes).ALL , chainId: chainId , exclude: exclude }) {
2960
- // todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
2961
- const filteredTokenList = $efe60cea83bfc4e8$var$filterTokenList({
2962
- type: type,
2963
- chainId: chainId,
2964
- exclude: exclude
2965
- }).map((token)=>{
2966
- const { chainId: chainId , tokenFeatures: tokenFeatures , ...tokenInfo } = token;
2967
- return tokenInfo;
2968
- });
2969
- return {
2970
- tokens: filteredTokenList
2971
- };
2972
- };
2973
-
2974
-
2975
-
2976
-
2977
- const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
2978
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2979
- const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
2980
- if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, (exports.CheckoutErrorType).CHAIN_NOT_SUPPORTED_ERROR, {
2981
- chainName: networkInfo.name
2982
- });
2983
- const balance = await provider.getBalance(walletAddress);
2984
- return {
2985
- balance: balance,
2986
- formattedBalance: (ethers.utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
2987
- token: networkInfo.nativeCurrency
2988
- };
2989
- }, {
2990
- type: (exports.CheckoutErrorType).GET_BALANCE_ERROR
2991
- });
2992
- };
2993
- async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
2994
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
2995
- const contract = new (ethers.Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
2996
- const name = await contract.name();
2997
- const symbol = await contract.symbol();
2998
- const balance = await contract.balanceOf(walletAddress);
2999
- const decimals = await contract.decimals();
3000
- const formattedBalance = (ethers.utils).formatUnits(balance, decimals);
3001
- return {
3002
- balance: balance,
3003
- formattedBalance: formattedBalance,
3004
- token: {
3005
- name: name,
3006
- symbol: symbol,
3007
- decimals: decimals,
3008
- address: contractAddress
3009
- }
3010
- };
3011
- }, {
3012
- type: (exports.CheckoutErrorType).GET_ERC20_BALANCE_ERROR
3013
- });
3014
- }
3015
- const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
3016
- if (!Object.values((exports.ChainId)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, (exports.CheckoutErrorType).CHAIN_NOT_SUPPORTED_ERROR);
3017
- if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", (exports.CheckoutErrorType).PROVIDER_REQUEST_MISSING_ERROR);
3018
- const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)({
3019
- type: (exports.TokenFilterTypes).ALL,
3020
- chainId: chainId
3021
- });
3022
- const allBalancePromises = [];
3023
- allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
3024
- tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
3025
- const balanceResults = await Promise.allSettled(allBalancePromises);
3026
- const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
3027
- return {
3028
- balances: getBalanceResults
3029
- };
3030
- };
3031
-
3032
-
3033
-
3034
-
3035
-
3036
-
3037
-
3038
-
3039
-
3040
- var $6f3c55a615003cbf$exports = {};
3041
- $6f3c55a615003cbf$exports = JSON.parse('[{"connectionProvider":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["desktop"]},{"connectionProvider":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile","desktop"]},{"connectionProvider":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["mobile"]}]');
3042
-
3043
-
3044
- async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = (exports.WalletFilterTypes).ALL , exclude: exclude }) {
3045
- // todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
3046
- const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
3047
- const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.connectionProvider).includes(wallet.connectionProvider);
3048
- const allowAllWallets = type === (exports.WalletFilterTypes).ALL;
3049
- const walletsAllowedForType = wallet.platform.includes(type);
3050
- return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
3051
- }).map((wallet)=>{
3052
- const { platform: platform , ...walletInfo } = wallet;
3053
- return walletInfo;
3054
- });
3055
- return {
3056
- wallets: filteredWalletsList
3057
- };
3058
- }
3059
-
3060
-
3061
-
3062
-
3063
-
3064
-
3065
- const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
3066
- const { provider: provider , transaction: transaction } = params;
3067
- return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
3068
- const transactionResponse = await provider.getSigner().sendTransaction(transaction);
3069
- return {
3070
- transactionResponse: transactionResponse
3071
- };
3072
- }, {
3073
- type: (exports.CheckoutErrorType).TRANSACTION_ERROR
3074
- });
3075
- };
3076
-
3077
-
3078
-
3079
-
3080
-
3081
- class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
3082
- /**
3083
- * Check if a wallet is connected to the current application without requesting permission from the wallet and hence triggering a connect popup.
3084
- * @param {CheckConnectionParams} params - The necessary data required to verify a wallet connection status.
3085
- * @returns Wallet connection status details.
3086
- * @throws {@link ErrorType}
3087
- */ async checkIsWalletConnected(params) {
3088
- return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
3089
- }
3090
- /**
3091
- * Establish a connection with a wallet provider such as MetaMask and returns the provider object and the current network details.
3092
- * @param {ConnectParams} params - The necessary data required to establish a connection with a wallet provider.
3093
- * @returns Wallet provider and current network information.
3094
- * @throws {@link ErrorType}
3095
- */ async connect(params) {
3096
- this.providerPreference = params.providerPreference;
3097
- const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
3098
- const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider);
3099
- return {
3100
- provider: provider,
3101
- network: networkInfo
3102
- };
3103
- }
3104
- /**
3105
- * Switch the currently connected wallet to a new network.
3106
- * @param {SwitchNetworkParams} params - The necessary data required to switch network.
3107
- * @returns The new network information.
3108
- * @throws {@link ErrorType}
3109
- */ async switchNetwork(params) {
3110
- if (!this.providerPreference) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`connect should be called before switchNetwork to set the provider preference`, (exports.CheckoutErrorType).PROVIDER_PREFERENCE_ERROR);
3111
- return await $de192de6ef100f9f$export$b827d9418aeb5dbd(this.providerPreference, params.provider, params.chainId);
3112
- }
3113
- /**
3114
- * Fetch the balance of the native token of the current connected network or, if a contract address is provided, it will return the balance of that ERC20 token. For example, if the wallet is connected to the Ethereum Mainnet then the function gets the wallet ETH L1 balance.
3115
- * @param {GetBalanceParams} params - The necessary data required to fetch the wallet balance.
3116
- * @returns Native token balance for the given wallet.
3117
- * @throws {@link ErrorType}
3118
- */ async getBalance(params) {
3119
- if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
3120
- return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
3121
- }
3122
- /**
3123
- * Fetch all available balances (ERC20 & Native) of the current connected network of the given wallet. It will loop through the list of allowed tokens and check for balance on each one.
3124
- * @param {GetAllBalancesParams} params - The necessary data required to fetch all the wallet balances.
3125
- * @returns List of tokens balance for the given wallet.
3126
- * @throws {@link ErrorType}
3127
- */ async getAllBalances(params) {
3128
- return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
3129
- }
3130
- /**
3131
- * Fetch the list of available networks that a wallet can add or/and switch to.
3132
- * @param {GetNetworkAllowListParams} params - The necessary data required to fetch the list of available networks.
3133
- * @returns List of networks.
3134
- * @throws {@link ErrorType}
3135
- */ async getNetworkAllowList(params) {
3136
- return await $de192de6ef100f9f$export$3043f6442a9ef563(params);
3137
- }
3138
- /**
3139
- * Get the list of tokens which are allowed to be used with the product.
3140
- * @param {GetTokenAllowListParams} params - The necessary data required to fetch the list of allowed tokens.
3141
- * @returns List of allowed tokens.
3142
- * @throws {@link ErrorType}
3143
- */ async getTokenAllowList(params) {
3144
- return await $efe60cea83bfc4e8$export$473cec51305fdae8(params);
3145
- }
3146
- /**
3147
- * Fetch the list of wallets which are available to connect with.
3148
- * @param {GetWalletAllowListParams} params - The necessary data required to fetch the list of allowed wallets.
3149
- * @returns List of allowed wallets.
3150
- * @throws {@link ErrorType}
3151
- */ async getWalletAllowList(params) {
3152
- return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
3153
- }
3154
- /**
3155
- * Send a generic transaction to the provider.
3156
- * @param {SendTransactionParams} params - The necessary data required to send a transaction.
3157
- * @returns Transaction response.
3158
- * @throws {@link ErrorType}
3159
- * @remarks
3160
- * Further documenation can be found at [MetaMask | Sending Transactions](https://docs.metamask.io/guide/sending-transactions.html).
3161
- */ async sendTransaction(params) {
3162
- return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
3163
- }
3164
- /**
3165
- * Get network information about the currently selected network.
3166
- * @param {GetNetworkParams} params - The necessary data required to get the current network information.
3167
- * @returns Network details.
3168
- * @throws {@link ErrorType}
3169
- */ async getNetworkInfo(params) {
3170
- return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(params.provider);
3171
- }
3172
- }
3173
-
3174
- function $parcel$export(e, n, v, s) {
3175
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
3176
- }
3177
- var $207ed853f11d19d5$exports = {};
3178
-
3179
- $parcel$export($207ed853f11d19d5$exports, "IMTBLWidgetEvents", () => exports.IMTBLWidgetEvents);
3180
- /**
3181
- * Enum representing the events emitted by the widgets.
3182
- */ exports.IMTBLWidgetEvents = void 0;
3183
- (function(IMTBLWidgetEvents) {
3184
- IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
3185
- IMTBLWidgetEvents["IMTBL_WALLET_WIDGET_EVENT"] = "imtbl-wallet-widget";
3186
- IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
3187
- IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
3188
- IMTBLWidgetEvents["IMTBL_BUY_WIDGET_EVENT"] = "imtbl-buy-widget";
3189
- IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
3190
- })(exports.IMTBLWidgetEvents || (exports.IMTBLWidgetEvents = {}));
3191
-
3192
-
3193
- var $a85ecdbd885c58ad$exports = {};
3194
-
3195
- $parcel$export($a85ecdbd885c58ad$exports, "ConnectEventType", () => exports.ConnectEventType);
3196
- exports.ConnectEventType = void 0;
3197
- (function(ConnectEventType) {
3198
- ConnectEventType["SUCCESS"] = "success";
3199
- ConnectEventType["FAILURE"] = "failure";
3200
- ConnectEventType["CLOSE_WIDGET"] = "close-widget";
3201
- })(exports.ConnectEventType || (exports.ConnectEventType = {}));
3202
-
3203
-
3204
- var $77b6aac5c353d4a9$exports = {};
3205
-
3206
- $parcel$export($77b6aac5c353d4a9$exports, "WalletEventType", () => exports.WalletEventType);
3207
- exports.WalletEventType = void 0;
3208
- (function(WalletEventType) {
3209
- WalletEventType["CLOSE_WIDGET"] = "close-widget";
3210
- WalletEventType["NETWORK_SWITCH"] = "network-switch";
3211
- WalletEventType["ADD_COINS"] = "add-coins";
3212
- WalletEventType["REQUEST_SWAP"] = "request-swap";
3213
- WalletEventType["REQUEST_BRIDGE"] = "request-bridge";
3214
- WalletEventType["REQUEST_ONRAMP"] = "request-onramp";
3215
- })(exports.WalletEventType || (exports.WalletEventType = {}));
3216
-
3217
-
3218
- var $53d219e7f6bf0cd6$exports = {};
3219
-
3220
- $parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => exports.SwapEventType);
3221
- /**
3222
- * Represents an event object emitted by the Swap Widget.
3223
- * @property {SwapEventType} type - The type of the event.
3224
- * @property {T} data - The data contained in the event.
3225
- */ exports.SwapEventType = void 0;
3226
- (function(SwapEventType) {
3227
- SwapEventType["SUCCESS"] = "success";
3228
- SwapEventType["FAILURE"] = "failure";
3229
- })(exports.SwapEventType || (exports.SwapEventType = {}));
3230
-
3231
-
3232
- var $15cc9e120aa6f3bf$exports = {};
3233
-
3234
- $parcel$export($15cc9e120aa6f3bf$exports, "BridgeEventType", () => exports.BridgeEventType);
3235
- /**
3236
- * Represents an event object emitted by the Bridge Widget.
3237
- * @property {BridgeEventType} type - The type of the event.
3238
- * @property {T} data - The data associated with the event.
3239
- */ exports.BridgeEventType = void 0;
3240
- (function(BridgeEventType) {
3241
- BridgeEventType["CLOSE_WIDGET"] = "close-widget";
3242
- BridgeEventType["SUCCESS"] = "success";
3243
- BridgeEventType["FAILURE"] = "failure";
3244
- })(exports.BridgeEventType || (exports.BridgeEventType = {}));
3245
-
3246
-
3247
- var $98cbcca465beec95$exports = {};
3248
-
3249
- $parcel$export($98cbcca465beec95$exports, "BuyEventType", () => exports.BuyEventType);
3250
- /**
3251
- * Represents an event object emitted by the Buy Widget.
3252
- * @property {BuyEventType} type - The type of the event.
3253
- * @property {T} data - The data contained in the event.
3254
- */ exports.BuyEventType = void 0;
3255
- (function(BuyEventType) {
3256
- BuyEventType["SUCCESS"] = "success";
3257
- BuyEventType["FAILURE"] = "failure";
3258
- BuyEventType["NOT_CONNECTED"] = "not_connected";
3259
- BuyEventType["CLOSE"] = "close";
3260
- })(exports.BuyEventType || (exports.BuyEventType = {}));
3261
-
3262
-
3263
- var $66ceef112c0ee49e$exports = {};
3264
-
3265
- $parcel$export($66ceef112c0ee49e$exports, "OnRampEventType", () => exports.OnRampEventType);
3266
- exports.OnRampEventType = void 0;
3267
- exports.OnRampEventType || (exports.OnRampEventType = {});
3268
-
3269
-
3270
- var $14d7a2bbb79e0dae$exports = {};
3271
-
3272
- $parcel$export($14d7a2bbb79e0dae$exports, "Network", () => exports.Network);
3273
- $parcel$export($14d7a2bbb79e0dae$exports, "WidgetTheme", () => exports.WidgetTheme);
3274
- $parcel$export($14d7a2bbb79e0dae$exports, "WidgetConnectionProviders", () => exports.WidgetConnectionProviders);
3275
- $parcel$export($14d7a2bbb79e0dae$exports, "CheckoutWidgetTagNames", () => exports.CheckoutWidgetTagNames);
3276
- /**
3277
- * Enum representing the networks supported by Checkout.
3278
- */ exports.Network = void 0;
3279
- (function(Network) {
3280
- Network["ETHEREUM"] = "Ethereum";
3281
- Network["GOERLI"] = "Goerli";
3282
- Network["POLYGON"] = "Polygon";
3283
- })(exports.Network || (exports.Network = {}));
3284
- exports.WidgetTheme = void 0;
3285
- (function(WidgetTheme) {
3286
- WidgetTheme["LIGHT"] = "light";
3287
- WidgetTheme["DARK"] = "dark";
3288
- WidgetTheme["CUSTOM"] = "custom";
3289
- })(exports.WidgetTheme || (exports.WidgetTheme = {}));
3290
- exports.WidgetConnectionProviders = void 0;
3291
- (function(WidgetConnectionProviders) {
3292
- WidgetConnectionProviders["METAMASK"] = "metamask";
3293
- })(exports.WidgetConnectionProviders || (exports.WidgetConnectionProviders = {}));
3294
- exports.CheckoutWidgetTagNames = void 0;
3295
- (function(CheckoutWidgetTagNames) {
3296
- CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
3297
- CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
3298
- CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
3299
- CheckoutWidgetTagNames["BUY"] = "imtbl-buy";
3300
- CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
3301
- CheckoutWidgetTagNames["EXAMPLE"] = "imtbl-example";
3302
- })(exports.CheckoutWidgetTagNames || (exports.CheckoutWidgetTagNames = {}));
3303
-
3304
-
3305
- var $1f969328e5988c99$exports = {};
3306
-
3307
- $parcel$export($1f969328e5988c99$exports, "BridgeReact", () => $1f969328e5988c99$export$30f61ebf204c69f6);
3308
-
3309
-
3310
-
3311
- function $1f969328e5988c99$export$30f61ebf204c69f6(props) {
3312
- const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , fromNetwork: fromNetwork } = props;
3313
- const config = window.ImtblCheckoutWidgetConfig;
3314
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-bridge", {
3315
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3316
- theme: config.theme ?? (exports.WidgetTheme).DARK,
3317
- fromContractAddress: fromContractAddress ?? "",
3318
- fromNetwork: fromNetwork ?? "",
3319
- amount: amount ?? ""
3320
- });
3321
- }
3322
-
3323
-
3324
- var $f22931ca9e2f35b6$exports = {};
3325
-
3326
- $parcel$export($f22931ca9e2f35b6$exports, "BuyReact", () => $f22931ca9e2f35b6$export$d13582032b79b401);
3327
-
3328
-
3329
-
3330
- function $f22931ca9e2f35b6$export$d13582032b79b401(props) {
3331
- const { providerPreference: providerPreference , orderId: orderId } = props;
3332
- const config = window.ImtblCheckoutWidgetConfig;
3333
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-buy", {
3334
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3335
- theme: config.theme ?? (exports.WidgetTheme).DARK,
3336
- orderId: orderId
3337
- });
3338
- }
3339
-
3340
-
3341
- var $f2083cd30e2f5c56$exports = {};
3342
-
3343
- $parcel$export($f2083cd30e2f5c56$exports, "ConnectReact", () => $f2083cd30e2f5c56$export$49d62957f420a1e2);
3344
-
3345
-
3346
-
3347
- function $f2083cd30e2f5c56$export$49d62957f420a1e2(props) {
3348
- const { providerPreference: providerPreference } = props;
3349
- const config = window.ImtblCheckoutWidgetConfig;
3350
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-connect", {
3351
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3352
- theme: config.theme ?? (exports.WidgetTheme).DARK
3353
- });
3354
- }
3355
-
3356
-
3357
- var $a4fbb8e3a6aeff58$exports = {};
3358
-
3359
- $parcel$export($a4fbb8e3a6aeff58$exports, "SwapReact", () => $a4fbb8e3a6aeff58$export$971e031379577f4);
3360
-
3361
-
3362
-
3363
- function $a4fbb8e3a6aeff58$export$971e031379577f4(props) {
3364
- const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , toContractAddress: toContractAddress } = props;
3365
- const config = window.ImtblCheckoutWidgetConfig;
3366
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-swap", {
3367
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3368
- theme: config.theme ?? (exports.WidgetTheme).DARK,
3369
- fromContractAddress: fromContractAddress ?? "",
3370
- toContractAddress: toContractAddress ?? "",
3371
- amount: amount ?? ""
3372
- });
3373
- }
3374
-
3375
-
3376
- var $89d55ace0f8f1c07$exports = {};
3377
-
3378
- $parcel$export($89d55ace0f8f1c07$exports, "WalletReact", () => $89d55ace0f8f1c07$export$ceaac94f34dba154);
3379
-
3380
-
3381
-
3382
- function $89d55ace0f8f1c07$export$ceaac94f34dba154(props) {
3383
- const { providerPreference: providerPreference , isBridgeEnabled: isBridgeEnabled , isOnRampEnabled: isOnRampEnabled , isSwapEnabled: isSwapEnabled } = props;
3384
- const config = window.ImtblCheckoutWidgetConfig;
3385
- // isOnRampEnabled, isBridgeEnabled, isSwapEnabled is a boolean type for better devExp
3386
- // converting them to string for compatible webComponent properties
3387
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-wallet", {
3388
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3389
- theme: config.theme ?? (exports.WidgetTheme).DARK,
3390
- isBridgeEnabled: isBridgeEnabled?.toString(),
3391
- isSwapEnabled: isSwapEnabled?.toString(),
3392
- isOnRampEnabled: isOnRampEnabled?.toString()
3393
- });
3394
- }
3395
-
3396
-
3397
- var $d087956fd1002f80$exports = {};
3398
-
3399
- $parcel$export($d087956fd1002f80$exports, "ExampleReact", () => $d087956fd1002f80$export$fa517eee6594d26c);
3400
-
3401
-
3402
-
3403
- function $d087956fd1002f80$export$fa517eee6594d26c(props) {
3404
- const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , fromNetwork: fromNetwork } = props;
3405
- const config = window.ImtblCheckoutWidgetConfig;
3406
- return /*#__PURE__*/ (jsxRuntime.jsx)("imtbl-example", {
3407
- providerPreference: providerPreference ?? (exports.WidgetConnectionProviders).METAMASK,
3408
- theme: config.theme ?? (exports.WidgetTheme).DARK
3409
- });
3410
- }
3411
-
3412
-
3413
- var $fa90757d8d7a0962$exports = {};
3414
-
3415
- $parcel$export($fa90757d8d7a0962$exports, "CheckoutWidgets", () => $fa90757d8d7a0962$export$af210a0808087845);
3416
- $parcel$export($fa90757d8d7a0962$exports, "UpdateConfig", () => $fa90757d8d7a0962$export$bf1548ba7e61c17f);
3417
- $parcel$export($fa90757d8d7a0962$exports, "SetProvider", () => $fa90757d8d7a0962$export$931068bc678f0d73);
3418
- function $fa90757d8d7a0962$export$af210a0808087845(config) {
3419
- var checkoutWidgetJS = document.createElement("script");
3420
- checkoutWidgetJS.setAttribute("src", "http://localhost:3000/lib/js/imtbl-checkout.js");
3421
- document.head.appendChild(checkoutWidgetJS);
3422
- window.ImtblCheckoutWidgetConfig = config;
3423
- }
3424
- function $fa90757d8d7a0962$export$bf1548ba7e61c17f(config) {
3425
- window.ImtblCheckoutWidgetConfig = config;
3426
- }
3427
- function $fa90757d8d7a0962$export$931068bc678f0d73(tagName, provider) {
3428
- if (!provider) {
3429
- console.error("no provider parsed");
3430
- return;
3431
- }
3432
- const elements = document.getElementsByTagName(tagName);
3433
- const widget = elements[0];
3434
- let attempts = 0;
3435
- const maxAttempts = 10;
3436
- let timer;
3437
- const attemptToSetProvider = ()=>{
3438
- try {
3439
- widget.setProvider(provider);
3440
- window.clearInterval(timer);
3441
- } catch (err) {
3442
- attempts++;
3443
- if (attempts >= maxAttempts) {
3444
- window.clearInterval(timer);
3445
- console.error("failed to set the provider");
3446
- }
3447
- }
3448
- };
3449
- timer = window.setInterval(attemptToSetProvider, 10);
3450
- attemptToSetProvider();
3451
- }
3452
-
3453
1484
  Object.defineProperty(exports, 'imxClientCreateStarkSigner', {
3454
1485
  enumerable: true,
3455
1486
  get: function () { return coreSdk.createStarkSigner; }
@@ -3458,20 +1489,7 @@ Object.defineProperty(exports, 'imxClientGenerateLegacyStarkPrivateKey', {
3458
1489
  enumerable: true,
3459
1490
  get: function () { return coreSdk.generateLegacyStarkPrivateKey; }
3460
1491
  });
3461
- exports.BridgeReact = $1f969328e5988c99$export$30f61ebf204c69f6;
3462
- exports.BuyReact = $f22931ca9e2f35b6$export$d13582032b79b401;
3463
- exports.Checkout = $a8cb37a3fc8eb863$export$1f60ba4ec72508a0;
3464
- exports.CheckoutWidgets = $fa90757d8d7a0962$export$af210a0808087845;
3465
- exports.ConnectReact = $f2083cd30e2f5c56$export$49d62957f420a1e2;
3466
- exports.ExampleReact = $d087956fd1002f80$export$fa517eee6594d26c;
3467
- exports.GenericIMXProvider = GenericIMXProvider;
3468
1492
  exports.ImmutableConfiguration = ImmutableConfiguration;
3469
1493
  exports.ImmutableXClient = ImmutableXClient;
3470
- exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
3471
1494
  exports.Passport = Passport;
3472
1495
  exports.PassportError = PassportError;
3473
- exports.ProviderConfiguration = ProviderConfiguration;
3474
- exports.SetProvider = $fa90757d8d7a0962$export$931068bc678f0d73;
3475
- exports.SwapReact = $a4fbb8e3a6aeff58$export$971e031379577f4;
3476
- exports.UpdateConfig = $fa90757d8d7a0962$export$bf1548ba7e61c17f;
3477
- exports.WalletReact = $89d55ace0f8f1c07$export$ceaac94f34dba154;