@imtbl/sdk 0.0.1-alpha.2 → 0.0.1-alpha.3
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/base.d.ts +14 -119
- package/dist/base.js +8 -20
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +53 -2
- package/dist/checkout_sdk.js +178 -93
- package/dist/checkout_widgets.d.ts +10 -5
- package/dist/checkout_widgets.js +29 -11
- package/dist/index.cjs +384 -248
- package/dist/index.d.ts +2089 -822
- package/dist/index.js +384 -248
- package/dist/passport.d.ts +40 -14
- package/dist/passport.js +96 -92
- package/dist/provider.d.ts +36 -20
- package/dist/provider.js +66 -55
- package/dist/starkex.d.ts +2015 -824
- package/dist/starkex.js +52 -4
- package/package.json +22 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImmutableX, Config, TransfersApi, OrdersApi, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi, Configuration, generateLegacyStarkPrivateKey, createStarkSigner } from '@imtbl/core-sdk';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import * as encUtils from 'enc-utils';
|
|
4
4
|
import { parseUnits } from '@ethersproject/units';
|
|
@@ -12,31 +12,63 @@ import { Web3Provider } from '@ethersproject/providers';
|
|
|
12
12
|
|
|
13
13
|
var Environment;
|
|
14
14
|
(function (Environment) {
|
|
15
|
-
Environment["DEVELOPMENT"] = "development";
|
|
16
|
-
Environment["SANDBOX"] = "sandbox";
|
|
17
15
|
Environment["PRODUCTION"] = "production";
|
|
16
|
+
Environment["SANDBOX"] = "sandbox";
|
|
18
17
|
})(Environment || (Environment = {}));
|
|
19
|
-
class
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
class ImmutableConfiguration {
|
|
19
|
+
environment;
|
|
20
|
+
apiKey;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.environment = options.environment;
|
|
23
|
+
this.apiKey = options.apiKey;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Set `sdkVersion` on config
|
|
28
|
+
const PRODUCTION = () => {
|
|
29
|
+
return Config.createConfig({
|
|
30
|
+
basePath: 'https://api.x.immutable.com',
|
|
31
|
+
chainID: 1,
|
|
32
|
+
coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
|
|
33
|
+
registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
|
|
34
|
+
sdkVersion: 'ts-immutable-sdk-0.0.1-alpha.3',
|
|
35
|
+
});
|
|
31
36
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
// Set `sdkVersion` on config
|
|
38
|
+
const SANDBOX = () => {
|
|
39
|
+
return Config.createConfig({
|
|
40
|
+
basePath: 'https://api.sandbox.x.immutable.com',
|
|
41
|
+
chainID: 5,
|
|
42
|
+
coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
|
|
43
|
+
registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
|
|
44
|
+
sdkVersion: 'ts-immutable-sdk-0.0.1-alpha.3',
|
|
45
|
+
});
|
|
35
46
|
};
|
|
47
|
+
class StarkExConfiguration {
|
|
48
|
+
immutableXConfig;
|
|
49
|
+
baseConfig;
|
|
50
|
+
constructor({ baseConfig, overrides }) {
|
|
51
|
+
this.baseConfig = baseConfig;
|
|
52
|
+
if (overrides) {
|
|
53
|
+
this.immutableXConfig = overrides.immutableXConfig;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
switch (baseConfig.environment) {
|
|
57
|
+
case Environment.SANDBOX: {
|
|
58
|
+
this.immutableXConfig = SANDBOX();
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case Environment.PRODUCTION: {
|
|
62
|
+
this.immutableXConfig = PRODUCTION();
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
36
69
|
|
|
37
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
38
70
|
const StarkExAPIFactory = (config) => {
|
|
39
|
-
const imtblClient = new ImmutableX(config.
|
|
71
|
+
const imtblClient = new ImmutableX(config.immutableXConfig);
|
|
40
72
|
const { deposit, registerOffchain, isRegisteredOnchain, prepareWithdrawal, completeWithdrawal, createOrder, cancelOrder, createTrade, transfer, batchNftTransfer, ...StarkEx } = imtblClient;
|
|
41
73
|
return { ...StarkEx };
|
|
42
74
|
};
|
|
@@ -121,9 +153,9 @@ async function validateChain(signer, config) {
|
|
|
121
153
|
}
|
|
122
154
|
|
|
123
155
|
async function transfer$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
124
|
-
await validateChain(ethSigner, config.
|
|
156
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
125
157
|
const ethAddress = await ethSigner.getAddress();
|
|
126
|
-
const transfersApi = new TransfersApi(config.
|
|
158
|
+
const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
|
|
127
159
|
const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
|
|
128
160
|
const signableResult = await transfersApi.getSignableTransferV1({
|
|
129
161
|
getSignableTransferRequest: {
|
|
@@ -161,9 +193,9 @@ async function transfer$1({ signers: { ethSigner, starkExSigner }, request, conf
|
|
|
161
193
|
};
|
|
162
194
|
}
|
|
163
195
|
async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
164
|
-
await validateChain(ethSigner, config.
|
|
196
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
165
197
|
const ethAddress = await ethSigner.getAddress();
|
|
166
|
-
const transfersApi = new TransfersApi(config.
|
|
198
|
+
const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
|
|
167
199
|
const signableRequests = request.map((nftTransfer) => {
|
|
168
200
|
return {
|
|
169
201
|
amount: '1',
|
|
@@ -217,9 +249,9 @@ async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
217
249
|
}
|
|
218
250
|
|
|
219
251
|
async function createOrder$1({ signers, request, config, }) {
|
|
220
|
-
await validateChain(signers.ethSigner, config.
|
|
252
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
221
253
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
222
|
-
const ordersApi = new OrdersApi(config.
|
|
254
|
+
const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
|
|
223
255
|
const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
|
|
224
256
|
const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
|
|
225
257
|
const getSignableOrderRequest = {
|
|
@@ -262,7 +294,7 @@ async function createOrder$1({ signers, request, config, }) {
|
|
|
262
294
|
};
|
|
263
295
|
}
|
|
264
296
|
async function cancelOrder$1({ signers, request, config, }) {
|
|
265
|
-
const ordersApi = new OrdersApi(config.
|
|
297
|
+
const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
|
|
266
298
|
const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
|
|
267
299
|
getSignableCancelOrderRequest: {
|
|
268
300
|
order_id: request.order_id,
|
|
@@ -288,8 +320,8 @@ async function cancelOrder$1({ signers, request, config, }) {
|
|
|
288
320
|
}
|
|
289
321
|
|
|
290
322
|
async function registerOffchain(signers, config) {
|
|
291
|
-
await validateChain(signers.ethSigner, config.
|
|
292
|
-
const usersApi = new UsersApi(config.
|
|
323
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
324
|
+
const usersApi = new UsersApi(config.immutableXConfig.apiConfiguration);
|
|
293
325
|
const userAddress = await signers.ethSigner.getAddress();
|
|
294
326
|
const starkPublicKey = await signers.starkExSigner.getAddress();
|
|
295
327
|
const signableResult = await usersApi.getSignableRegistrationOffchain({
|
|
@@ -312,8 +344,8 @@ async function registerOffchain(signers, config) {
|
|
|
312
344
|
return registeredUser.data;
|
|
313
345
|
}
|
|
314
346
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
315
|
-
await validateChain(ethSigner, config.
|
|
316
|
-
const registrationContract = Contracts.Registration.connect(config.
|
|
347
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
348
|
+
const registrationContract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
317
349
|
try {
|
|
318
350
|
return await registrationContract.isRegistered(starkPublicKey);
|
|
319
351
|
}
|
|
@@ -388,10 +420,10 @@ async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
|
|
|
388
420
|
|
|
389
421
|
async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
|
|
390
422
|
const etherKey = await ethSigner.getAddress();
|
|
391
|
-
const starkExConfig = config.
|
|
423
|
+
const starkExConfig = config.immutableXConfig;
|
|
392
424
|
const usersApi = new UsersApi(starkExConfig.apiConfiguration);
|
|
393
425
|
const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
|
|
394
|
-
const contract = Contracts.Registration.connect(config.
|
|
426
|
+
const contract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
395
427
|
const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
|
|
396
428
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
397
429
|
}
|
|
@@ -401,8 +433,8 @@ async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config
|
|
|
401
433
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
402
434
|
}
|
|
403
435
|
async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
404
|
-
await validateChain(ethSigner, config.
|
|
405
|
-
const starkExConfig = config.
|
|
436
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
437
|
+
const starkExConfig = config.immutableXConfig;
|
|
406
438
|
const assetType = await getEncodeAssetInfo('asset', 'ERC20', starkExConfig, {
|
|
407
439
|
token_address: token.tokenAddress,
|
|
408
440
|
});
|
|
@@ -439,7 +471,7 @@ function getMintingBlob(token) {
|
|
|
439
471
|
return encUtils.sanitizeHex(encUtils.utf8ToHex(`{${id}}:{${blueprint}}`));
|
|
440
472
|
}
|
|
441
473
|
async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
442
|
-
const starkExConfig = config.
|
|
474
|
+
const starkExConfig = config.immutableXConfig;
|
|
443
475
|
const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', starkExConfig, {
|
|
444
476
|
id: token.data.id,
|
|
445
477
|
token_address: token.data.tokenAddress,
|
|
@@ -468,7 +500,7 @@ async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, token
|
|
|
468
500
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
469
501
|
}
|
|
470
502
|
async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
471
|
-
const starkExConfig = config.
|
|
503
|
+
const starkExConfig = config.immutableXConfig;
|
|
472
504
|
const assetType = await getEncodeAssetInfo('asset', 'ERC721', starkExConfig, {
|
|
473
505
|
token_id: token.tokenId,
|
|
474
506
|
token_address: token.tokenAddress,
|
|
@@ -482,10 +514,10 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
|
|
|
482
514
|
}
|
|
483
515
|
}
|
|
484
516
|
async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
485
|
-
await validateChain(ethSigner, config.
|
|
517
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
486
518
|
const tokenAddress = token.tokenAddress;
|
|
487
519
|
const tokenId = token.tokenId;
|
|
488
|
-
const starkExConfig = config.
|
|
520
|
+
const starkExConfig = config.immutableXConfig;
|
|
489
521
|
const mintsApi = new MintsApi(starkExConfig.apiConfiguration);
|
|
490
522
|
return await mintsApi
|
|
491
523
|
.getMintableTokenDetailsByClientTokenId({
|
|
@@ -523,8 +555,8 @@ async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config)
|
|
|
523
555
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
524
556
|
}
|
|
525
557
|
async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
|
|
526
|
-
await validateChain(ethSigner, config.
|
|
527
|
-
const starkExConfig = config.
|
|
558
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
559
|
+
const starkExConfig = config.immutableXConfig;
|
|
528
560
|
const assetType = await getEncodeAssetInfo('asset', 'ETH', starkExConfig);
|
|
529
561
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
530
562
|
if (!isRegistered) {
|
|
@@ -536,10 +568,9 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
|
|
|
536
568
|
}
|
|
537
569
|
|
|
538
570
|
async function prepareWithdrawal({ signers, withdrawal, config, }) {
|
|
539
|
-
const starkExConfig = config.getStarkExConfig();
|
|
540
571
|
return prepareWithdrawalAction({
|
|
541
572
|
signers,
|
|
542
|
-
config:
|
|
573
|
+
config: config.immutableXConfig,
|
|
543
574
|
...withdrawal,
|
|
544
575
|
});
|
|
545
576
|
}
|
|
@@ -565,9 +596,9 @@ async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, toke
|
|
|
565
596
|
}
|
|
566
597
|
|
|
567
598
|
async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
568
|
-
await validateChain(ethSigner, config.
|
|
599
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
569
600
|
const ethAddress = await ethSigner.getAddress();
|
|
570
|
-
const tradesApi = new TradesApi(config.
|
|
601
|
+
const tradesApi = new TradesApi(config.immutableXConfig.apiConfiguration);
|
|
571
602
|
const signableResult = await tradesApi.getSignableTrade({
|
|
572
603
|
getSignableTradeRequest: {
|
|
573
604
|
user: ethAddress,
|
|
@@ -602,13 +633,13 @@ async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
602
633
|
}
|
|
603
634
|
|
|
604
635
|
async function depositEth({ signers: { ethSigner }, deposit, config, }) {
|
|
605
|
-
await validateChain(ethSigner, config.
|
|
636
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
606
637
|
const user = await ethSigner.getAddress();
|
|
607
638
|
const data = {
|
|
608
639
|
decimals: 18,
|
|
609
640
|
};
|
|
610
641
|
const amount = parseUnits(deposit.amount, 'wei');
|
|
611
|
-
const starkExConfig = config.
|
|
642
|
+
const starkExConfig = config.immutableXConfig;
|
|
612
643
|
const depositsApi = new DepositsApi(starkExConfig.apiConfiguration);
|
|
613
644
|
const encodingApi = new EncodingApi(starkExConfig.apiConfiguration);
|
|
614
645
|
const usersApi = new UsersApi(starkExConfig.apiConfiguration);
|
|
@@ -656,8 +687,8 @@ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, v
|
|
|
656
687
|
}
|
|
657
688
|
|
|
658
689
|
async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
659
|
-
await validateChain(ethSigner, config.
|
|
660
|
-
const { apiConfiguration, ethConfiguration } = config.
|
|
690
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
691
|
+
const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
|
|
661
692
|
const user = await ethSigner.getAddress();
|
|
662
693
|
const tokensApi = new TokensApi(apiConfiguration);
|
|
663
694
|
const depositsApi = new DepositsApi(apiConfiguration);
|
|
@@ -724,12 +755,12 @@ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetT
|
|
|
724
755
|
}
|
|
725
756
|
|
|
726
757
|
async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
727
|
-
await validateChain(ethSigner, config.
|
|
758
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
728
759
|
const user = await ethSigner.getAddress();
|
|
729
|
-
const
|
|
730
|
-
const depositsApi = new DepositsApi(
|
|
731
|
-
const encodingApi = new EncodingApi(
|
|
732
|
-
const usersApi = new UsersApi(
|
|
760
|
+
const { immutableXConfig } = config;
|
|
761
|
+
const depositsApi = new DepositsApi(immutableXConfig.apiConfiguration);
|
|
762
|
+
const encodingApi = new EncodingApi(immutableXConfig.apiConfiguration);
|
|
763
|
+
const usersApi = new UsersApi(immutableXConfig.apiConfiguration);
|
|
733
764
|
const data = {
|
|
734
765
|
token_address: deposit.tokenAddress,
|
|
735
766
|
token_id: deposit.tokenId,
|
|
@@ -765,18 +796,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
|
765
796
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
766
797
|
// Approve whether an amount of token from an account can be spent by a third-party account
|
|
767
798
|
const tokenContract = Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
|
|
768
|
-
const operator =
|
|
799
|
+
const operator = immutableXConfig.ethConfiguration.coreContractAddress;
|
|
769
800
|
const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
|
|
770
801
|
if (!isApprovedForAll) {
|
|
771
802
|
await tokenContract.setApprovalForAll(operator, true);
|
|
772
803
|
}
|
|
773
804
|
if (!isRegistered) {
|
|
774
805
|
const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
|
|
775
|
-
const coreContract = Contracts.Core.connect(
|
|
806
|
+
const coreContract = Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
|
|
776
807
|
// Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
|
|
777
808
|
await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
|
|
778
809
|
}
|
|
779
|
-
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId,
|
|
810
|
+
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
|
|
780
811
|
}
|
|
781
812
|
async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
|
|
782
813
|
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
@@ -796,8 +827,8 @@ async function deposit({ signers, deposit, config }) {
|
|
|
796
827
|
}
|
|
797
828
|
|
|
798
829
|
async function exchangeTransfer$1({ signers, request, config, }) {
|
|
799
|
-
await validateChain(signers.ethSigner, config.
|
|
800
|
-
const exchangeApi = new ExchangesApi(config.
|
|
830
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
831
|
+
const exchangeApi = new ExchangesApi(config.immutableXConfig.apiConfiguration);
|
|
801
832
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
802
833
|
const transferAmount = request.amount;
|
|
803
834
|
const signableResult = await exchangeApi.getExchangeSignableTransfer({
|
|
@@ -1020,7 +1051,6 @@ class ImxSigner {
|
|
|
1020
1051
|
|
|
1021
1052
|
const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
|
|
1022
1053
|
const IMX_WALLET_IFRAME_HOSTS = {
|
|
1023
|
-
[Environment.DEVELOPMENT]: 'http://localhost:8080',
|
|
1024
1054
|
[Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
|
|
1025
1055
|
[Environment.PRODUCTION]: 'https://wallets.immutable.com',
|
|
1026
1056
|
};
|
|
@@ -1118,12 +1148,11 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1118
1148
|
super(config, ethSigner, starkExSigner);
|
|
1119
1149
|
}
|
|
1120
1150
|
static async connect(config) {
|
|
1121
|
-
const starkExConfig = config.getStarkExConfig();
|
|
1122
1151
|
return await withProviderError(async () => {
|
|
1123
1152
|
const metaMaskProvider = await connect$1({
|
|
1124
|
-
chainID:
|
|
1153
|
+
chainID: config.immutableXConfig.ethConfiguration.chainID,
|
|
1125
1154
|
});
|
|
1126
|
-
this.imxSigner = await connect(metaMaskProvider,
|
|
1155
|
+
this.imxSigner = await connect(metaMaskProvider, config.baseConfig.environment);
|
|
1127
1156
|
return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
|
|
1128
1157
|
}, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
|
|
1129
1158
|
}
|
|
@@ -1145,6 +1174,29 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1145
1174
|
}
|
|
1146
1175
|
}
|
|
1147
1176
|
|
|
1177
|
+
class ProviderConfiguration {
|
|
1178
|
+
immutableXConfig;
|
|
1179
|
+
baseConfig;
|
|
1180
|
+
constructor({ baseConfig, overrides }) {
|
|
1181
|
+
this.baseConfig = baseConfig;
|
|
1182
|
+
if (overrides) {
|
|
1183
|
+
this.immutableXConfig = overrides.immutableXConfig;
|
|
1184
|
+
}
|
|
1185
|
+
else {
|
|
1186
|
+
switch (baseConfig.environment) {
|
|
1187
|
+
case Environment.SANDBOX: {
|
|
1188
|
+
this.immutableXConfig = Config.SANDBOX;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
case Environment.PRODUCTION: {
|
|
1192
|
+
this.immutableXConfig = Config.PRODUCTION;
|
|
1193
|
+
break;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1148
1200
|
var PassportErrorType;
|
|
1149
1201
|
(function (PassportErrorType) {
|
|
1150
1202
|
PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
|
|
@@ -1197,17 +1249,17 @@ const retryWithDelay = async (fn, options) => {
|
|
|
1197
1249
|
}
|
|
1198
1250
|
};
|
|
1199
1251
|
|
|
1200
|
-
const getAuthConfiguration = ({ oidcConfiguration, }) => {
|
|
1252
|
+
const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
1201
1253
|
const baseConfiguration = {
|
|
1202
|
-
authority:
|
|
1254
|
+
authority: authenticationDomain,
|
|
1203
1255
|
redirect_uri: oidcConfiguration.redirectUri,
|
|
1204
1256
|
popup_redirect_uri: oidcConfiguration.redirectUri,
|
|
1205
1257
|
client_id: oidcConfiguration.clientId,
|
|
1206
1258
|
metadata: {
|
|
1207
|
-
authorization_endpoint: `${
|
|
1208
|
-
token_endpoint: `${
|
|
1209
|
-
userinfo_endpoint: `${
|
|
1210
|
-
end_session_endpoint: `${
|
|
1259
|
+
authorization_endpoint: `${authenticationDomain}/authorize`,
|
|
1260
|
+
token_endpoint: `${authenticationDomain}/oauth/token`,
|
|
1261
|
+
userinfo_endpoint: `${authenticationDomain}/userinfo`,
|
|
1262
|
+
end_session_endpoint: `${authenticationDomain}/v2/logout` +
|
|
1211
1263
|
`?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
|
|
1212
1264
|
`&client_id=${oidcConfiguration.clientId}`,
|
|
1213
1265
|
},
|
|
@@ -1245,7 +1297,10 @@ class AuthManager {
|
|
|
1245
1297
|
};
|
|
1246
1298
|
async login() {
|
|
1247
1299
|
return withPassportError(async () => {
|
|
1248
|
-
const
|
|
1300
|
+
const popupWindowFeatures = { width: 400, height: 420 };
|
|
1301
|
+
const oidcUser = await this.userManager.signinPopup({
|
|
1302
|
+
popupWindowFeatures,
|
|
1303
|
+
});
|
|
1249
1304
|
return this.mapOidcUserToDomainModel(oidcUser);
|
|
1250
1305
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
1251
1306
|
}
|
|
@@ -1328,26 +1383,12 @@ var TransactionTypes;
|
|
|
1328
1383
|
const PassportEventType = 'imx_passport_confirmation';
|
|
1329
1384
|
|
|
1330
1385
|
const openPopupCenter = ({ url, title, width, height, }) => {
|
|
1331
|
-
|
|
1332
|
-
const
|
|
1333
|
-
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
|
|
1334
|
-
const windowWidth = window.innerWidth
|
|
1335
|
-
? window.innerWidth
|
|
1336
|
-
: document.documentElement.clientWidth
|
|
1337
|
-
? document.documentElement.clientWidth
|
|
1338
|
-
: screen.width;
|
|
1339
|
-
const windowHeight = window.innerHeight
|
|
1340
|
-
? window.innerHeight
|
|
1341
|
-
: document.documentElement.clientHeight
|
|
1342
|
-
? document.documentElement.clientHeight
|
|
1343
|
-
: screen.height;
|
|
1344
|
-
const systemZoom = windowWidth / window.screen.availWidth;
|
|
1345
|
-
const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
|
|
1346
|
-
const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
|
|
1386
|
+
const left = Math.max(0, Math.round(window.screenX + (window.outerWidth - width) / 2));
|
|
1387
|
+
const top = Math.max(0, Math.round(window.screenY + (window.outerHeight - height) / 2));
|
|
1347
1388
|
const newWindow = window.open(url, title, `
|
|
1348
1389
|
scrollbars=yes,
|
|
1349
|
-
width=${width
|
|
1350
|
-
height=${height
|
|
1390
|
+
width=${width},
|
|
1391
|
+
height=${height},
|
|
1351
1392
|
top=${top},
|
|
1352
1393
|
left=${left}
|
|
1353
1394
|
`);
|
|
@@ -1359,8 +1400,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
|
|
|
1359
1400
|
};
|
|
1360
1401
|
|
|
1361
1402
|
const ConfirmationWindowTitle = 'Confirm this transaction';
|
|
1362
|
-
const ConfirmationWindowHeight =
|
|
1363
|
-
const ConfirmationWindowWidth =
|
|
1403
|
+
const ConfirmationWindowHeight = 380;
|
|
1404
|
+
const ConfirmationWindowWidth = 480;
|
|
1364
1405
|
const ConfirmationWindowClosedPollingDuration = 1000;
|
|
1365
1406
|
class ConfirmationScreen {
|
|
1366
1407
|
config;
|
|
@@ -1374,7 +1415,7 @@ class ConfirmationScreen {
|
|
|
1374
1415
|
...message,
|
|
1375
1416
|
}, this.config.passportDomain);
|
|
1376
1417
|
}
|
|
1377
|
-
startTransaction(accessToken, transaction) {
|
|
1418
|
+
startTransaction(accessToken, transaction, popupOptions) {
|
|
1378
1419
|
return new Promise((resolve, reject) => {
|
|
1379
1420
|
const messageHandler = ({ data, origin }) => {
|
|
1380
1421
|
if (origin != this.config.passportDomain ||
|
|
@@ -1405,8 +1446,8 @@ class ConfirmationScreen {
|
|
|
1405
1446
|
const confirmationWindow = openPopupCenter({
|
|
1406
1447
|
url: `${this.config.passportDomain}/transaction-confirmation`,
|
|
1407
1448
|
title: ConfirmationWindowTitle,
|
|
1408
|
-
width: ConfirmationWindowWidth,
|
|
1409
|
-
height: ConfirmationWindowHeight,
|
|
1449
|
+
width: popupOptions?.width || ConfirmationWindowWidth,
|
|
1450
|
+
height: popupOptions?.height || ConfirmationWindowHeight,
|
|
1410
1451
|
});
|
|
1411
1452
|
// https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
|
|
1412
1453
|
const timer = setInterval(function () {
|
|
@@ -1493,10 +1534,11 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
|
|
|
1493
1534
|
getSignableTransferRequestV2,
|
|
1494
1535
|
});
|
|
1495
1536
|
const confirmationScreen = new ConfirmationScreen(passportConfig);
|
|
1537
|
+
const popupWindowSize = { width: 480, height: 784 };
|
|
1496
1538
|
const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
|
|
1497
1539
|
transactionType: TransactionTypes.CreateBatchTransfer,
|
|
1498
1540
|
transactionData: getSignableTransferRequestV2,
|
|
1499
|
-
});
|
|
1541
|
+
}, popupWindowSize);
|
|
1500
1542
|
if (!confirmationResult.confirmed) {
|
|
1501
1543
|
throw new Error('Transaction rejected by user');
|
|
1502
1544
|
}
|
|
@@ -1705,7 +1747,7 @@ async function createTrade({ request, tradesApi, user, starkSigner, passportConf
|
|
|
1705
1747
|
},
|
|
1706
1748
|
};
|
|
1707
1749
|
const headers = { Authorization: 'Bearer ' + user.accessToken };
|
|
1708
|
-
const { data: createTradeResponse } = await tradesApi.
|
|
1750
|
+
const { data: createTradeResponse } = await tradesApi.createTradeV3(tradeParams, {
|
|
1709
1751
|
headers,
|
|
1710
1752
|
});
|
|
1711
1753
|
return createTradeResponse;
|
|
@@ -1724,8 +1766,8 @@ class PassportImxProvider {
|
|
|
1724
1766
|
this.user = user;
|
|
1725
1767
|
this.starkSigner = starkSigner;
|
|
1726
1768
|
this.passportConfig = passportConfig;
|
|
1727
|
-
const apiConfig = new Configuration
|
|
1728
|
-
basePath: passportConfig.
|
|
1769
|
+
const apiConfig = new Configuration({
|
|
1770
|
+
basePath: passportConfig.imxApiBasePath,
|
|
1729
1771
|
});
|
|
1730
1772
|
this.transfersApi = new TransfersApi(apiConfig);
|
|
1731
1773
|
this.ordersApi = new OrdersApi(apiConfig);
|
|
@@ -1817,67 +1859,75 @@ var Networks;
|
|
|
1817
1859
|
Networks["SANDBOX"] = "goerli";
|
|
1818
1860
|
})(Networks || (Networks = {}));
|
|
1819
1861
|
|
|
1820
|
-
const
|
|
1821
|
-
PRODUCTION: {
|
|
1822
|
-
network: Networks.PRODUCTION,
|
|
1823
|
-
authenticationDomain: 'https://auth.immutable.com',
|
|
1824
|
-
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1825
|
-
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1826
|
-
baseIMXApiPath: 'https://api.x.immutable.com',
|
|
1827
|
-
passportDomain: 'https://passport.immutable.com',
|
|
1828
|
-
},
|
|
1829
|
-
SANDBOX: {
|
|
1830
|
-
network: Networks.SANDBOX,
|
|
1831
|
-
authenticationDomain: 'https://auth.immutable.com',
|
|
1832
|
-
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1833
|
-
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1834
|
-
baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
|
|
1835
|
-
passportDomain: 'https://passport.sandbox.immutable.com',
|
|
1836
|
-
},
|
|
1837
|
-
};
|
|
1838
|
-
const validateConfiguration = (configurationName, configuration, requiredKeys) => {
|
|
1839
|
-
if (!configuration) {
|
|
1840
|
-
throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
|
|
1841
|
-
}
|
|
1862
|
+
const validateConfiguration = (configuration, requiredKeys, prefix) => {
|
|
1842
1863
|
const missingKeys = requiredKeys
|
|
1843
1864
|
.map((key) => !configuration[key] && key)
|
|
1844
1865
|
.filter((n) => n)
|
|
1845
1866
|
.join(', ');
|
|
1846
1867
|
if (missingKeys !== '') {
|
|
1847
|
-
|
|
1868
|
+
const errorMessage = prefix
|
|
1869
|
+
? `${prefix} - ${missingKeys} cannot be null`
|
|
1870
|
+
: `${missingKeys} cannot be null`;
|
|
1871
|
+
throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
|
|
1848
1872
|
}
|
|
1849
1873
|
};
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
oidcConfiguration
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1874
|
+
class PassportConfiguration {
|
|
1875
|
+
network;
|
|
1876
|
+
authenticationDomain;
|
|
1877
|
+
passportDomain;
|
|
1878
|
+
magicPublishableApiKey;
|
|
1879
|
+
magicProviderId;
|
|
1880
|
+
imxApiBasePath;
|
|
1881
|
+
oidcConfiguration;
|
|
1882
|
+
baseConfig;
|
|
1883
|
+
constructor({ baseConfig, overrides, ...oidcConfiguration }) {
|
|
1884
|
+
validateConfiguration(oidcConfiguration, [
|
|
1885
|
+
'clientId',
|
|
1886
|
+
'logoutRedirectUri',
|
|
1887
|
+
'redirectUri',
|
|
1888
|
+
]);
|
|
1889
|
+
this.oidcConfiguration = oidcConfiguration;
|
|
1890
|
+
this.baseConfig = baseConfig;
|
|
1891
|
+
if (overrides) {
|
|
1892
|
+
validateConfiguration(overrides, [
|
|
1893
|
+
'network',
|
|
1894
|
+
'authenticationDomain',
|
|
1895
|
+
'magicPublishableApiKey',
|
|
1896
|
+
'magicProviderId',
|
|
1897
|
+
'passportDomain',
|
|
1898
|
+
'imxApiBasePath',
|
|
1899
|
+
], 'overrides');
|
|
1900
|
+
this.network = overrides.network;
|
|
1901
|
+
this.authenticationDomain = overrides.authenticationDomain;
|
|
1902
|
+
this.passportDomain = overrides.passportDomain;
|
|
1903
|
+
this.magicPublishableApiKey = overrides.magicPublishableApiKey;
|
|
1904
|
+
this.magicProviderId = overrides.magicProviderId;
|
|
1905
|
+
this.imxApiBasePath = overrides.imxApiBasePath;
|
|
1906
|
+
}
|
|
1907
|
+
else {
|
|
1908
|
+
switch (baseConfig.environment) {
|
|
1909
|
+
case Environment.SANDBOX: {
|
|
1910
|
+
this.network = Networks.SANDBOX;
|
|
1911
|
+
this.authenticationDomain = 'https://auth.immutable.com';
|
|
1912
|
+
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
1913
|
+
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
1914
|
+
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
1915
|
+
this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
case Environment.PRODUCTION: {
|
|
1919
|
+
this.network = Networks.PRODUCTION;
|
|
1920
|
+
this.authenticationDomain = 'https://auth.immutable.com';
|
|
1921
|
+
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
1922
|
+
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
1923
|
+
this.passportDomain = 'https://passport.immutable.com';
|
|
1924
|
+
this.imxApiBasePath = 'https://api.x.immutable.com';
|
|
1925
|
+
break;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1881
1931
|
|
|
1882
1932
|
const getStarkSigner = async (signer) => {
|
|
1883
1933
|
return withPassportError(async () => {
|
|
@@ -1916,8 +1966,8 @@ class Passport {
|
|
|
1916
1966
|
authManager;
|
|
1917
1967
|
magicAdapter;
|
|
1918
1968
|
config;
|
|
1919
|
-
constructor(
|
|
1920
|
-
const passportConfiguration =
|
|
1969
|
+
constructor(passportModuleConfiguration) {
|
|
1970
|
+
const passportConfiguration = new PassportConfiguration(passportModuleConfiguration);
|
|
1921
1971
|
this.config = passportConfiguration;
|
|
1922
1972
|
this.authManager = new AuthManager(this.config);
|
|
1923
1973
|
this.magicAdapter = new MagicAdapter(this.config);
|
|
@@ -1964,8 +2014,8 @@ class Passport {
|
|
|
1964
2014
|
return user.accessToken;
|
|
1965
2015
|
}
|
|
1966
2016
|
async registerUser(userAdminKeySigner, starkSigner, jwt) {
|
|
1967
|
-
const configuration = new Configuration
|
|
1968
|
-
basePath: this.config.
|
|
2017
|
+
const configuration = new Configuration({
|
|
2018
|
+
basePath: this.config.imxApiBasePath,
|
|
1969
2019
|
});
|
|
1970
2020
|
const usersApi = new UsersApi(configuration);
|
|
1971
2021
|
await registerPassport({
|
|
@@ -1981,6 +2031,10 @@ class Passport {
|
|
|
1981
2031
|
}
|
|
1982
2032
|
}
|
|
1983
2033
|
|
|
2034
|
+
function $parcel$interopDefault(a) {
|
|
2035
|
+
return a && a.__esModule ? a.default : a;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1984
2038
|
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
1985
2039
|
{
|
|
1986
2040
|
constant: true,
|
|
@@ -2101,8 +2155,18 @@ const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
|
|
|
2101
2155
|
]
|
|
2102
2156
|
}
|
|
2103
2157
|
};
|
|
2158
|
+
let $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
2159
|
+
(function(NetworkFilterTypes) {
|
|
2160
|
+
NetworkFilterTypes["ALL"] = "all";
|
|
2161
|
+
})($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
|
|
2104
2162
|
|
|
2105
2163
|
|
|
2164
|
+
let $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
2165
|
+
(function(TokenFilterTypes) {
|
|
2166
|
+
TokenFilterTypes["SWAP"] = "swap";
|
|
2167
|
+
TokenFilterTypes["BRIDGE"] = "bridge";
|
|
2168
|
+
TokenFilterTypes["ALL"] = "all";
|
|
2169
|
+
})($08d5ddc39acd6833$export$fd9b17d87f4121d2 || ($08d5ddc39acd6833$export$fd9b17d87f4121d2 = {}));
|
|
2106
2170
|
|
|
2107
2171
|
|
|
2108
2172
|
|
|
@@ -2113,24 +2177,45 @@ const $4f91c5f280efe242$export$a130407f3423b97d = {
|
|
|
2113
2177
|
ADD_NETWORK: "wallet_addEthereumChain",
|
|
2114
2178
|
SWITCH_NETWORK: "wallet_switchEthereumChain"
|
|
2115
2179
|
};
|
|
2180
|
+
let $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
2181
|
+
(function(WalletFilterTypes) {
|
|
2182
|
+
WalletFilterTypes["ALL"] = "all";
|
|
2183
|
+
WalletFilterTypes["DESKTOP"] = "desktop";
|
|
2184
|
+
WalletFilterTypes["MOBILE"] = "mobile";
|
|
2185
|
+
})($4f91c5f280efe242$export$a75605c67ea83a5a || ($4f91c5f280efe242$export$a75605c67ea83a5a = {}));
|
|
2116
2186
|
|
|
2117
2187
|
|
|
2118
2188
|
|
|
2119
2189
|
|
|
2120
2190
|
let $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
|
|
2121
2191
|
(function(CheckoutErrorType) {
|
|
2192
|
+
CheckoutErrorType["PROVIDER_PREFERENCE_ERROR"] = "PROVIDER_PREFERENCE_ERROR";
|
|
2122
2193
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
2123
2194
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
2124
2195
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
2196
|
+
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
2125
2197
|
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
2126
2198
|
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
2127
2199
|
CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
|
|
2200
|
+
CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
|
|
2128
2201
|
CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
|
|
2129
2202
|
CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
|
|
2130
2203
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
2131
2204
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
2132
|
-
constructor(message, type){
|
|
2205
|
+
constructor(message, type, data){
|
|
2133
2206
|
super(message);
|
|
2207
|
+
this.message = message;
|
|
2208
|
+
this.type = type;
|
|
2209
|
+
this.data = data;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
let $a8bc256d81a5e2c1$export$a22d4e0719ee6def;
|
|
2213
|
+
(function(CheckoutInternalErrorType) {
|
|
2214
|
+
CheckoutInternalErrorType["REJECTED_SWITCH_AFTER_ADDING_NETWORK"] = "REJECTED_SWITCH_AFTER_ADDING_NETWORK";
|
|
2215
|
+
})($a8bc256d81a5e2c1$export$a22d4e0719ee6def || ($a8bc256d81a5e2c1$export$a22d4e0719ee6def = {}));
|
|
2216
|
+
class $a8bc256d81a5e2c1$export$620a0d5f1b58ea1d extends Error {
|
|
2217
|
+
constructor(type){
|
|
2218
|
+
super("Checkout internal error");
|
|
2134
2219
|
this.type = type;
|
|
2135
2220
|
}
|
|
2136
2221
|
}
|
|
@@ -2138,44 +2223,67 @@ const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
|
|
|
2138
2223
|
try {
|
|
2139
2224
|
return await fn();
|
|
2140
2225
|
} catch (error) {
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2226
|
+
const cause = `${error.message}` || "UnknownError";
|
|
2227
|
+
const errorMessage = customError.message ? `[${customError.type}]:${customError.message}. Cause:${cause}` : `[${customError.type}] Cause:${cause}`;
|
|
2228
|
+
if (error instanceof $a8bc256d81a5e2c1$export$b722478a3cbfa3bc) throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
|
|
2229
|
+
...customError.data,
|
|
2230
|
+
innerErrorType: error.type,
|
|
2231
|
+
...error.data
|
|
2232
|
+
});
|
|
2233
|
+
throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
|
|
2234
|
+
...customError.data
|
|
2235
|
+
});
|
|
2143
2236
|
}
|
|
2144
2237
|
};
|
|
2145
2238
|
|
|
2146
2239
|
|
|
2147
2240
|
|
|
2148
2241
|
|
|
2242
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2149
2243
|
|
|
2244
|
+
var $497c134ecbc8a50f$exports = {};
|
|
2245
|
+
$497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":5},{"chainId":137}]');
|
|
2150
2246
|
|
|
2151
2247
|
|
|
2248
|
+
const $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE = 4902; // error code (MetaMask)
|
|
2152
2249
|
async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2250
|
+
return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2251
|
+
const network = await provider.getNetwork();
|
|
2252
|
+
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(network.chainId)) // return empty details
|
|
2253
|
+
return {
|
|
2254
|
+
chainId: network.chainId,
|
|
2255
|
+
name: network.name,
|
|
2256
|
+
isSupported: false
|
|
2257
|
+
};
|
|
2258
|
+
const chainIdNetworkInfo = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[network.chainId];
|
|
2259
|
+
return {
|
|
2260
|
+
name: chainIdNetworkInfo.chainName,
|
|
2261
|
+
chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
|
|
2262
|
+
nativeCurrency: chainIdNetworkInfo.nativeCurrency,
|
|
2263
|
+
isSupported: true
|
|
2264
|
+
};
|
|
2265
|
+
}, {
|
|
2266
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_NETWORK_INFO_ERROR
|
|
2267
|
+
});
|
|
2163
2268
|
}
|
|
2164
2269
|
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
|
|
2165
|
-
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(
|
|
2166
|
-
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider
|
|
2270
|
+
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);
|
|
2271
|
+
if (!provider || !provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
2272
|
+
details: `Unsupported provider`
|
|
2273
|
+
});
|
|
2167
2274
|
// WT-1146 - Refer to the README in this folder for explantion on the switch network flow
|
|
2168
2275
|
try {
|
|
2169
2276
|
await $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId);
|
|
2170
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2171
2277
|
} catch (err) {
|
|
2172
|
-
if (err.
|
|
2278
|
+
if (err.code === $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE) try {
|
|
2173
2279
|
await $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId);
|
|
2174
|
-
|
|
2280
|
+
if ((await provider.getNetwork()).chainId !== chainId) // user didn't actually switch
|
|
2281
|
+
throw new (0, $a8bc256d81a5e2c1$export$620a0d5f1b58ea1d)((0, $a8bc256d81a5e2c1$export$a22d4e0719ee6def).REJECTED_SWITCH_AFTER_ADDING_NETWORK);
|
|
2175
2282
|
} catch (err) {
|
|
2176
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("
|
|
2283
|
+
if (err?.type === ($a8bc256d81a5e2c1$export$a22d4e0719ee6def).REJECTED_SWITCH_AFTER_ADDING_NETWORK) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2284
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2177
2285
|
}
|
|
2178
|
-
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("
|
|
2286
|
+
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2179
2287
|
}
|
|
2180
2288
|
// we can assume that if the above succeeds then user has successfully
|
|
2181
2289
|
// switched to the network specified
|
|
@@ -2188,6 +2296,26 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
|
|
|
2188
2296
|
}
|
|
2189
2297
|
};
|
|
2190
2298
|
}
|
|
2299
|
+
async function $de192de6ef100f9f$export$3043f6442a9ef563({ type: type = ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL , exclude: exclude }) {
|
|
2300
|
+
const list = ((/*@__PURE__*/$parcel$interopDefault($497c134ecbc8a50f$exports))).filter((network)=>{
|
|
2301
|
+
const allowAllTokens = type === ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL;
|
|
2302
|
+
const networkNotExcluded = !(exclude || []).map((exc)=>exc.chainId).includes(network.chainId);
|
|
2303
|
+
return allowAllTokens && networkNotExcluded;
|
|
2304
|
+
});
|
|
2305
|
+
const allowedNetworks = [];
|
|
2306
|
+
list.forEach((element)=>{
|
|
2307
|
+
const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[element.chainId];
|
|
2308
|
+
allowedNetworks.push({
|
|
2309
|
+
name: newNetwork.chainName,
|
|
2310
|
+
chainId: parseInt(newNetwork.chainIdHex, 16),
|
|
2311
|
+
nativeCurrency: newNetwork.nativeCurrency,
|
|
2312
|
+
isSupported: true
|
|
2313
|
+
});
|
|
2314
|
+
});
|
|
2315
|
+
return {
|
|
2316
|
+
networks: allowedNetworks
|
|
2317
|
+
};
|
|
2318
|
+
}
|
|
2191
2319
|
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
2192
2320
|
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
2193
2321
|
async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
|
|
@@ -2222,67 +2350,24 @@ async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
|
|
|
2222
2350
|
|
|
2223
2351
|
|
|
2224
2352
|
|
|
2225
|
-
|
|
2226
|
-
(
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
const $
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
}
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
address: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
|
|
2242
|
-
decimals: 18,
|
|
2243
|
-
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"
|
|
2244
|
-
},
|
|
2245
|
-
{
|
|
2246
|
-
name: "Immutable X",
|
|
2247
|
-
symbol: "IMX",
|
|
2248
|
-
address: "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF",
|
|
2249
|
-
decimals: 18,
|
|
2250
|
-
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"
|
|
2251
|
-
}
|
|
2252
|
-
];
|
|
2253
|
-
const $efe60cea83bfc4e8$var$goerliTokensList = [
|
|
2254
|
-
{
|
|
2255
|
-
name: "Ethereum",
|
|
2256
|
-
symbol: "ETH",
|
|
2257
|
-
decimals: 18,
|
|
2258
|
-
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"
|
|
2259
|
-
},
|
|
2260
|
-
{
|
|
2261
|
-
name: "Immutable X",
|
|
2262
|
-
symbol: "IMX",
|
|
2263
|
-
address: "0x1facdd0165489f373255a90304650e15481b2c85",
|
|
2264
|
-
decimals: 18,
|
|
2265
|
-
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"
|
|
2266
|
-
}
|
|
2267
|
-
];
|
|
2268
|
-
const $efe60cea83bfc4e8$var$polygonTokensList = [];
|
|
2269
|
-
const $efe60cea83bfc4e8$export$473cec51305fdae8 = (chainId)=>{
|
|
2270
|
-
let tokenList = [];
|
|
2271
|
-
switch(chainId){
|
|
2272
|
-
case ($a47e48dd2c04791b$export$c06e1e7429de6283).ETHEREUM:
|
|
2273
|
-
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
2274
|
-
break;
|
|
2275
|
-
case ($a47e48dd2c04791b$export$c06e1e7429de6283).GOERLI:
|
|
2276
|
-
tokenList = $efe60cea83bfc4e8$var$goerliTokensList;
|
|
2277
|
-
break;
|
|
2278
|
-
case ($a47e48dd2c04791b$export$c06e1e7429de6283).POLYGON:
|
|
2279
|
-
tokenList = $efe60cea83bfc4e8$var$polygonTokensList;
|
|
2280
|
-
break;
|
|
2281
|
-
default:
|
|
2282
|
-
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
2283
|
-
}
|
|
2353
|
+
var $cda6003506e4182e$exports = {};
|
|
2354
|
+
$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\"]}]");
|
|
2355
|
+
|
|
2356
|
+
|
|
2357
|
+
const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL , chainId: chainId , exclude: exclude }) {
|
|
2358
|
+
// todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
|
|
2359
|
+
const filteredTokenList = ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
|
|
2360
|
+
const chainIdMatches = token.chainId == chainId;
|
|
2361
|
+
const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
|
|
2362
|
+
const allowAllTokens = type === ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL;
|
|
2363
|
+
const tokenAllowedForType = token.tokenFeatures.includes(type);
|
|
2364
|
+
return chainIdMatches && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
|
|
2365
|
+
}).map((token)=>{
|
|
2366
|
+
const { chainId: chainId , tokenFeatures: tokenFeatures , ...tokenInfo } = token;
|
|
2367
|
+
return tokenInfo;
|
|
2368
|
+
});
|
|
2284
2369
|
return {
|
|
2285
|
-
tokens:
|
|
2370
|
+
tokens: filteredTokenList
|
|
2286
2371
|
};
|
|
2287
2372
|
};
|
|
2288
2373
|
|
|
@@ -2292,6 +2377,9 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = (chainId)=>{
|
|
|
2292
2377
|
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
|
|
2293
2378
|
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2294
2379
|
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
|
|
2380
|
+
if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
|
|
2381
|
+
chainName: networkInfo.name
|
|
2382
|
+
});
|
|
2295
2383
|
const balance = await provider.getBalance(walletAddress);
|
|
2296
2384
|
return {
|
|
2297
2385
|
balance: balance,
|
|
@@ -2327,7 +2415,10 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress
|
|
|
2327
2415
|
const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
|
|
2328
2416
|
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);
|
|
2329
2417
|
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
2330
|
-
const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)(
|
|
2418
|
+
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)({
|
|
2419
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
2420
|
+
chainId: chainId
|
|
2421
|
+
});
|
|
2331
2422
|
const allBalancePromises = [];
|
|
2332
2423
|
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
|
|
2333
2424
|
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
|
|
@@ -2348,11 +2439,20 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress
|
|
|
2348
2439
|
|
|
2349
2440
|
async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
2350
2441
|
const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
|
|
2351
|
-
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR
|
|
2352
|
-
|
|
2353
|
-
method: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
|
|
2354
|
-
params: []
|
|
2442
|
+
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
2443
|
+
details: `Unsupported provider for ${providerPreference}`
|
|
2355
2444
|
});
|
|
2445
|
+
let accounts = [];
|
|
2446
|
+
try {
|
|
2447
|
+
accounts = await provider.provider.request({
|
|
2448
|
+
method: (0, $4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION,
|
|
2449
|
+
params: []
|
|
2450
|
+
});
|
|
2451
|
+
} catch (err) {
|
|
2452
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Check wallet connection request failed`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_FAILED_ERROR, {
|
|
2453
|
+
rpcMethod: ($4f91c5f280efe242$export$a130407f3423b97d).CHECK_CONNECTION
|
|
2454
|
+
});
|
|
2455
|
+
}
|
|
2356
2456
|
// accounts[0] will have the active account if connected.
|
|
2357
2457
|
return {
|
|
2358
2458
|
isConnected: accounts && accounts.length > 0,
|
|
@@ -2362,7 +2462,9 @@ async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
|
2362
2462
|
async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
|
|
2363
2463
|
const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
|
|
2364
2464
|
await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2365
|
-
if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("
|
|
2465
|
+
if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
2466
|
+
details: `Unsupported provider for ${params.providerPreference}`
|
|
2467
|
+
});
|
|
2366
2468
|
// this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
|
|
2367
2469
|
await web3Provider.provider.request({
|
|
2368
2470
|
method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
|
|
@@ -2380,7 +2482,7 @@ async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPref
|
|
|
2380
2482
|
web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
|
|
2381
2483
|
break;
|
|
2382
2484
|
default:
|
|
2383
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference
|
|
2485
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference is not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_PREFERENCE_ERROR);
|
|
2384
2486
|
}
|
|
2385
2487
|
return web3Provider;
|
|
2386
2488
|
}
|
|
@@ -2398,6 +2500,30 @@ async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
|
2398
2500
|
|
|
2399
2501
|
|
|
2400
2502
|
|
|
2503
|
+
var $6f3c55a615003cbf$exports = {};
|
|
2504
|
+
$6f3c55a615003cbf$exports = JSON.parse('[{"connectionProvider":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["mobile","desktop"]},{"connectionProvider":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile"]},{"connectionProvider":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["desktop"]}]');
|
|
2505
|
+
|
|
2506
|
+
|
|
2507
|
+
async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL , exclude: exclude }) {
|
|
2508
|
+
// todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
|
|
2509
|
+
const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
|
|
2510
|
+
const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.connectionProvider).includes(wallet.connectionProvider);
|
|
2511
|
+
const allowAllWallets = type === ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL;
|
|
2512
|
+
const walletsAllowedForType = wallet.platform.includes(type);
|
|
2513
|
+
return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
|
|
2514
|
+
}).map((wallet)=>{
|
|
2515
|
+
const { platform: platform , ...walletInfo } = wallet;
|
|
2516
|
+
return walletInfo;
|
|
2517
|
+
});
|
|
2518
|
+
return {
|
|
2519
|
+
wallets: filteredWalletsList
|
|
2520
|
+
};
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
|
|
2524
|
+
|
|
2525
|
+
|
|
2526
|
+
|
|
2401
2527
|
|
|
2402
2528
|
const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
|
|
2403
2529
|
const { provider: provider , transaction: transaction } = params;
|
|
@@ -2420,14 +2546,14 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
2420
2546
|
}
|
|
2421
2547
|
async connect(params) {
|
|
2422
2548
|
const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
|
|
2423
|
-
const
|
|
2549
|
+
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider);
|
|
2424
2550
|
return {
|
|
2425
2551
|
provider: provider,
|
|
2426
|
-
network:
|
|
2552
|
+
network: networkInfo
|
|
2427
2553
|
};
|
|
2428
2554
|
}
|
|
2429
2555
|
async switchNetwork(params) {
|
|
2430
|
-
return await
|
|
2556
|
+
return await $de192de6ef100f9f$export$b827d9418aeb5dbd(params.provider, params.chainId);
|
|
2431
2557
|
}
|
|
2432
2558
|
async getBalance(params) {
|
|
2433
2559
|
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
|
|
@@ -2436,12 +2562,21 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
2436
2562
|
async getAllBalances(params) {
|
|
2437
2563
|
return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
|
|
2438
2564
|
}
|
|
2439
|
-
|
|
2440
|
-
return $
|
|
2565
|
+
async getNetworkAllowList(params) {
|
|
2566
|
+
return await $de192de6ef100f9f$export$3043f6442a9ef563(params);
|
|
2567
|
+
}
|
|
2568
|
+
async getTokenAllowList(params) {
|
|
2569
|
+
return await $efe60cea83bfc4e8$export$473cec51305fdae8(params);
|
|
2570
|
+
}
|
|
2571
|
+
async getWalletsAllowList(params) {
|
|
2572
|
+
return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
|
|
2441
2573
|
}
|
|
2442
2574
|
async sendTransaction(params) {
|
|
2443
2575
|
return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
|
|
2444
2576
|
}
|
|
2577
|
+
async getNetworkInfo(params) {
|
|
2578
|
+
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(params.provider);
|
|
2579
|
+
}
|
|
2445
2580
|
}
|
|
2446
2581
|
|
|
2447
2582
|
function $parcel$export(e, n, v, s) {
|
|
@@ -2467,6 +2602,7 @@ let $d71a87afc3136184$export$e72e7f9969a47dd3;
|
|
|
2467
2602
|
(function(ConnectEventType) {
|
|
2468
2603
|
ConnectEventType["SUCCESS"] = "success";
|
|
2469
2604
|
ConnectEventType["FAILURE"] = "failure";
|
|
2605
|
+
ConnectEventType["CLOSE_WIDGET"] = "close-widget";
|
|
2470
2606
|
})($d71a87afc3136184$export$e72e7f9969a47dd3 || ($d71a87afc3136184$export$e72e7f9969a47dd3 = {}));
|
|
2471
2607
|
|
|
2472
2608
|
|
|
@@ -2533,4 +2669,4 @@ let $9234b4c577442a97$export$c88931fdc51854eb;
|
|
|
2533
2669
|
WidgetTheme["CUSTOM"] = "custom";
|
|
2534
2670
|
})($9234b4c577442a97$export$c88931fdc51854eb || ($9234b4c577442a97$export$c88931fdc51854eb = {}));
|
|
2535
2671
|
|
|
2536
|
-
export { $28a5fdc2f5e6c742$export$d1bfa21f7c76447a as BridgeEventType, $ede253beebe0de4a$export$90db5fe1be5993c1 as BuyEventType, $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout,
|
|
2672
|
+
export { $28a5fdc2f5e6c742$export$d1bfa21f7c76447a as BridgeEventType, $ede253beebe0de4a$export$90db5fe1be5993c1 as BuyEventType, $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $d71a87afc3136184$export$e72e7f9969a47dd3 as ConnectEventType, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, Environment, GenericIMXProvider, $88e4c575901cd68c$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, MetaMaskIMXProvider, $9234b4c577442a97$export$95be4ae94445245a as Network, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, Passport, PassportConfiguration, PassportError, ProviderConfiguration, StarkExAPIFactory, StarkExConfiguration, $5d497088f13bb116$export$140a49745ab55563 as SwapEventType, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $9d0f1783d4d36e8a$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $9234b4c577442a97$export$c88931fdc51854eb as WidgetTheme };
|