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