@imtbl/sdk 0.0.1-alpha.1 → 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 -0
- package/dist/checkout_sdk.d.ts +692 -0
- package/dist/checkout_sdk.js +553 -0
- package/dist/checkout_widgets.d.ts +14447 -0
- package/dist/checkout_widgets.js +198 -0
- package/dist/index.cjs +844 -154
- package/dist/index.d.ts +20637 -4534
- package/dist/index.js +844 -155
- 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 +32 -4
package/dist/index.js
CHANGED
|
@@ -1,41 +1,74 @@
|
|
|
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';
|
|
5
5
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
6
|
-
import { ethers } from 'ethers';
|
|
6
|
+
import { ethers, utils, Contract } from 'ethers';
|
|
7
7
|
import detectEthereumProvider from '@metamask/detect-provider';
|
|
8
8
|
import { UserManager } from 'oidc-client-ts';
|
|
9
9
|
import { Magic } from 'magic-sdk';
|
|
10
10
|
import { OpenIdExtension } from '@magic-ext/oidc';
|
|
11
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
11
12
|
|
|
12
13
|
var Environment;
|
|
13
14
|
(function (Environment) {
|
|
14
|
-
Environment["DEVELOPMENT"] = "development";
|
|
15
|
-
Environment["SANDBOX"] = "sandbox";
|
|
16
15
|
Environment["PRODUCTION"] = "production";
|
|
16
|
+
Environment["SANDBOX"] = "sandbox";
|
|
17
17
|
})(Environment || (Environment = {}));
|
|
18
|
-
class
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return this.starkExConfig;
|
|
18
|
+
class ImmutableConfiguration {
|
|
19
|
+
environment;
|
|
20
|
+
apiKey;
|
|
21
|
+
constructor(options) {
|
|
22
|
+
this.environment = options.environment;
|
|
23
|
+
this.apiKey = options.apiKey;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
});
|
|
30
36
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
});
|
|
34
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
|
+
}
|
|
35
69
|
|
|
36
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
37
70
|
const StarkExAPIFactory = (config) => {
|
|
38
|
-
const imtblClient = new ImmutableX(config.
|
|
71
|
+
const imtblClient = new ImmutableX(config.immutableXConfig);
|
|
39
72
|
const { deposit, registerOffchain, isRegisteredOnchain, prepareWithdrawal, completeWithdrawal, createOrder, cancelOrder, createTrade, transfer, batchNftTransfer, ...StarkEx } = imtblClient;
|
|
40
73
|
return { ...StarkEx };
|
|
41
74
|
};
|
|
@@ -120,9 +153,9 @@ async function validateChain(signer, config) {
|
|
|
120
153
|
}
|
|
121
154
|
|
|
122
155
|
async function transfer$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
123
|
-
await validateChain(ethSigner, config.
|
|
156
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
124
157
|
const ethAddress = await ethSigner.getAddress();
|
|
125
|
-
const transfersApi = new TransfersApi(config.
|
|
158
|
+
const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
|
|
126
159
|
const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
|
|
127
160
|
const signableResult = await transfersApi.getSignableTransferV1({
|
|
128
161
|
getSignableTransferRequest: {
|
|
@@ -160,9 +193,9 @@ async function transfer$1({ signers: { ethSigner, starkExSigner }, request, conf
|
|
|
160
193
|
};
|
|
161
194
|
}
|
|
162
195
|
async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
163
|
-
await validateChain(ethSigner, config.
|
|
196
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
164
197
|
const ethAddress = await ethSigner.getAddress();
|
|
165
|
-
const transfersApi = new TransfersApi(config.
|
|
198
|
+
const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
|
|
166
199
|
const signableRequests = request.map((nftTransfer) => {
|
|
167
200
|
return {
|
|
168
201
|
amount: '1',
|
|
@@ -216,9 +249,9 @@ async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
216
249
|
}
|
|
217
250
|
|
|
218
251
|
async function createOrder$1({ signers, request, config, }) {
|
|
219
|
-
await validateChain(signers.ethSigner, config.
|
|
252
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
220
253
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
221
|
-
const ordersApi = new OrdersApi(config.
|
|
254
|
+
const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
|
|
222
255
|
const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
|
|
223
256
|
const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
|
|
224
257
|
const getSignableOrderRequest = {
|
|
@@ -261,7 +294,7 @@ async function createOrder$1({ signers, request, config, }) {
|
|
|
261
294
|
};
|
|
262
295
|
}
|
|
263
296
|
async function cancelOrder$1({ signers, request, config, }) {
|
|
264
|
-
const ordersApi = new OrdersApi(config.
|
|
297
|
+
const ordersApi = new OrdersApi(config.immutableXConfig.apiConfiguration);
|
|
265
298
|
const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
|
|
266
299
|
getSignableCancelOrderRequest: {
|
|
267
300
|
order_id: request.order_id,
|
|
@@ -287,8 +320,8 @@ async function cancelOrder$1({ signers, request, config, }) {
|
|
|
287
320
|
}
|
|
288
321
|
|
|
289
322
|
async function registerOffchain(signers, config) {
|
|
290
|
-
await validateChain(signers.ethSigner, config.
|
|
291
|
-
const usersApi = new UsersApi(config.
|
|
323
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
324
|
+
const usersApi = new UsersApi(config.immutableXConfig.apiConfiguration);
|
|
292
325
|
const userAddress = await signers.ethSigner.getAddress();
|
|
293
326
|
const starkPublicKey = await signers.starkExSigner.getAddress();
|
|
294
327
|
const signableResult = await usersApi.getSignableRegistrationOffchain({
|
|
@@ -311,8 +344,8 @@ async function registerOffchain(signers, config) {
|
|
|
311
344
|
return registeredUser.data;
|
|
312
345
|
}
|
|
313
346
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
314
|
-
await validateChain(ethSigner, config.
|
|
315
|
-
const registrationContract = Contracts.Registration.connect(config.
|
|
347
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
348
|
+
const registrationContract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
316
349
|
try {
|
|
317
350
|
return await registrationContract.isRegistered(starkPublicKey);
|
|
318
351
|
}
|
|
@@ -387,10 +420,10 @@ async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
|
|
|
387
420
|
|
|
388
421
|
async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
|
|
389
422
|
const etherKey = await ethSigner.getAddress();
|
|
390
|
-
const starkExConfig = config.
|
|
423
|
+
const starkExConfig = config.immutableXConfig;
|
|
391
424
|
const usersApi = new UsersApi(starkExConfig.apiConfiguration);
|
|
392
425
|
const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
|
|
393
|
-
const contract = Contracts.Registration.connect(config.
|
|
426
|
+
const contract = Contracts.Registration.connect(config.immutableXConfig.ethConfiguration.registrationContractAddress, ethSigner);
|
|
394
427
|
const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
|
|
395
428
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
396
429
|
}
|
|
@@ -400,8 +433,8 @@ async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config
|
|
|
400
433
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
401
434
|
}
|
|
402
435
|
async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
403
|
-
await validateChain(ethSigner, config.
|
|
404
|
-
const starkExConfig = config.
|
|
436
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
437
|
+
const starkExConfig = config.immutableXConfig;
|
|
405
438
|
const assetType = await getEncodeAssetInfo('asset', 'ERC20', starkExConfig, {
|
|
406
439
|
token_address: token.tokenAddress,
|
|
407
440
|
});
|
|
@@ -438,7 +471,7 @@ function getMintingBlob(token) {
|
|
|
438
471
|
return encUtils.sanitizeHex(encUtils.utf8ToHex(`{${id}}:{${blueprint}}`));
|
|
439
472
|
}
|
|
440
473
|
async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
441
|
-
const starkExConfig = config.
|
|
474
|
+
const starkExConfig = config.immutableXConfig;
|
|
442
475
|
const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', starkExConfig, {
|
|
443
476
|
id: token.data.id,
|
|
444
477
|
token_address: token.data.tokenAddress,
|
|
@@ -467,7 +500,7 @@ async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, token
|
|
|
467
500
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
468
501
|
}
|
|
469
502
|
async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
470
|
-
const starkExConfig = config.
|
|
503
|
+
const starkExConfig = config.immutableXConfig;
|
|
471
504
|
const assetType = await getEncodeAssetInfo('asset', 'ERC721', starkExConfig, {
|
|
472
505
|
token_id: token.tokenId,
|
|
473
506
|
token_address: token.tokenAddress,
|
|
@@ -481,10 +514,10 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
|
|
|
481
514
|
}
|
|
482
515
|
}
|
|
483
516
|
async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
484
|
-
await validateChain(ethSigner, config.
|
|
517
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
485
518
|
const tokenAddress = token.tokenAddress;
|
|
486
519
|
const tokenId = token.tokenId;
|
|
487
|
-
const starkExConfig = config.
|
|
520
|
+
const starkExConfig = config.immutableXConfig;
|
|
488
521
|
const mintsApi = new MintsApi(starkExConfig.apiConfiguration);
|
|
489
522
|
return await mintsApi
|
|
490
523
|
.getMintableTokenDetailsByClientTokenId({
|
|
@@ -522,8 +555,8 @@ async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config)
|
|
|
522
555
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
523
556
|
}
|
|
524
557
|
async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
|
|
525
|
-
await validateChain(ethSigner, config.
|
|
526
|
-
const starkExConfig = config.
|
|
558
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
559
|
+
const starkExConfig = config.immutableXConfig;
|
|
527
560
|
const assetType = await getEncodeAssetInfo('asset', 'ETH', starkExConfig);
|
|
528
561
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
529
562
|
if (!isRegistered) {
|
|
@@ -535,10 +568,9 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
|
|
|
535
568
|
}
|
|
536
569
|
|
|
537
570
|
async function prepareWithdrawal({ signers, withdrawal, config, }) {
|
|
538
|
-
const starkExConfig = config.getStarkExConfig();
|
|
539
571
|
return prepareWithdrawalAction({
|
|
540
572
|
signers,
|
|
541
|
-
config:
|
|
573
|
+
config: config.immutableXConfig,
|
|
542
574
|
...withdrawal,
|
|
543
575
|
});
|
|
544
576
|
}
|
|
@@ -564,9 +596,9 @@ async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, toke
|
|
|
564
596
|
}
|
|
565
597
|
|
|
566
598
|
async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
567
|
-
await validateChain(ethSigner, config.
|
|
599
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
568
600
|
const ethAddress = await ethSigner.getAddress();
|
|
569
|
-
const tradesApi = new TradesApi(config.
|
|
601
|
+
const tradesApi = new TradesApi(config.immutableXConfig.apiConfiguration);
|
|
570
602
|
const signableResult = await tradesApi.getSignableTrade({
|
|
571
603
|
getSignableTradeRequest: {
|
|
572
604
|
user: ethAddress,
|
|
@@ -601,13 +633,13 @@ async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
601
633
|
}
|
|
602
634
|
|
|
603
635
|
async function depositEth({ signers: { ethSigner }, deposit, config, }) {
|
|
604
|
-
await validateChain(ethSigner, config.
|
|
636
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
605
637
|
const user = await ethSigner.getAddress();
|
|
606
638
|
const data = {
|
|
607
639
|
decimals: 18,
|
|
608
640
|
};
|
|
609
641
|
const amount = parseUnits(deposit.amount, 'wei');
|
|
610
|
-
const starkExConfig = config.
|
|
642
|
+
const starkExConfig = config.immutableXConfig;
|
|
611
643
|
const depositsApi = new DepositsApi(starkExConfig.apiConfiguration);
|
|
612
644
|
const encodingApi = new EncodingApi(starkExConfig.apiConfiguration);
|
|
613
645
|
const usersApi = new UsersApi(starkExConfig.apiConfiguration);
|
|
@@ -655,8 +687,8 @@ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, v
|
|
|
655
687
|
}
|
|
656
688
|
|
|
657
689
|
async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
658
|
-
await validateChain(ethSigner, config.
|
|
659
|
-
const { apiConfiguration, ethConfiguration } = config.
|
|
690
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
691
|
+
const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
|
|
660
692
|
const user = await ethSigner.getAddress();
|
|
661
693
|
const tokensApi = new TokensApi(apiConfiguration);
|
|
662
694
|
const depositsApi = new DepositsApi(apiConfiguration);
|
|
@@ -723,12 +755,12 @@ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetT
|
|
|
723
755
|
}
|
|
724
756
|
|
|
725
757
|
async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
726
|
-
await validateChain(ethSigner, config.
|
|
758
|
+
await validateChain(ethSigner, config.immutableXConfig);
|
|
727
759
|
const user = await ethSigner.getAddress();
|
|
728
|
-
const
|
|
729
|
-
const depositsApi = new DepositsApi(
|
|
730
|
-
const encodingApi = new EncodingApi(
|
|
731
|
-
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);
|
|
732
764
|
const data = {
|
|
733
765
|
token_address: deposit.tokenAddress,
|
|
734
766
|
token_id: deposit.tokenId,
|
|
@@ -764,18 +796,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
|
764
796
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
765
797
|
// Approve whether an amount of token from an account can be spent by a third-party account
|
|
766
798
|
const tokenContract = Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
|
|
767
|
-
const operator =
|
|
799
|
+
const operator = immutableXConfig.ethConfiguration.coreContractAddress;
|
|
768
800
|
const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
|
|
769
801
|
if (!isApprovedForAll) {
|
|
770
802
|
await tokenContract.setApprovalForAll(operator, true);
|
|
771
803
|
}
|
|
772
804
|
if (!isRegistered) {
|
|
773
805
|
const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
|
|
774
|
-
const coreContract = Contracts.Core.connect(
|
|
806
|
+
const coreContract = Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
|
|
775
807
|
// Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
|
|
776
808
|
await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
|
|
777
809
|
}
|
|
778
|
-
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId,
|
|
810
|
+
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
|
|
779
811
|
}
|
|
780
812
|
async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
|
|
781
813
|
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
@@ -795,8 +827,8 @@ async function deposit({ signers, deposit, config }) {
|
|
|
795
827
|
}
|
|
796
828
|
|
|
797
829
|
async function exchangeTransfer$1({ signers, request, config, }) {
|
|
798
|
-
await validateChain(signers.ethSigner, config.
|
|
799
|
-
const exchangeApi = new ExchangesApi(config.
|
|
830
|
+
await validateChain(signers.ethSigner, config.immutableXConfig);
|
|
831
|
+
const exchangeApi = new ExchangesApi(config.immutableXConfig.apiConfiguration);
|
|
800
832
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
801
833
|
const transferAmount = request.amount;
|
|
802
834
|
const signableResult = await exchangeApi.getExchangeSignableTransfer({
|
|
@@ -1019,7 +1051,6 @@ class ImxSigner {
|
|
|
1019
1051
|
|
|
1020
1052
|
const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
|
|
1021
1053
|
const IMX_WALLET_IFRAME_HOSTS = {
|
|
1022
|
-
[Environment.DEVELOPMENT]: 'http://localhost:8080',
|
|
1023
1054
|
[Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
|
|
1024
1055
|
[Environment.PRODUCTION]: 'https://wallets.immutable.com',
|
|
1025
1056
|
};
|
|
@@ -1117,12 +1148,11 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1117
1148
|
super(config, ethSigner, starkExSigner);
|
|
1118
1149
|
}
|
|
1119
1150
|
static async connect(config) {
|
|
1120
|
-
const starkExConfig = config.getStarkExConfig();
|
|
1121
1151
|
return await withProviderError(async () => {
|
|
1122
1152
|
const metaMaskProvider = await connect$1({
|
|
1123
|
-
chainID:
|
|
1153
|
+
chainID: config.immutableXConfig.ethConfiguration.chainID,
|
|
1124
1154
|
});
|
|
1125
|
-
this.imxSigner = await connect(metaMaskProvider,
|
|
1155
|
+
this.imxSigner = await connect(metaMaskProvider, config.baseConfig.environment);
|
|
1126
1156
|
return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
|
|
1127
1157
|
}, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
|
|
1128
1158
|
}
|
|
@@ -1144,6 +1174,29 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1144
1174
|
}
|
|
1145
1175
|
}
|
|
1146
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
|
+
|
|
1147
1200
|
var PassportErrorType;
|
|
1148
1201
|
(function (PassportErrorType) {
|
|
1149
1202
|
PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
|
|
@@ -1196,17 +1249,17 @@ const retryWithDelay = async (fn, options) => {
|
|
|
1196
1249
|
}
|
|
1197
1250
|
};
|
|
1198
1251
|
|
|
1199
|
-
const getAuthConfiguration = ({ oidcConfiguration, }) => {
|
|
1252
|
+
const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
1200
1253
|
const baseConfiguration = {
|
|
1201
|
-
authority:
|
|
1254
|
+
authority: authenticationDomain,
|
|
1202
1255
|
redirect_uri: oidcConfiguration.redirectUri,
|
|
1203
1256
|
popup_redirect_uri: oidcConfiguration.redirectUri,
|
|
1204
1257
|
client_id: oidcConfiguration.clientId,
|
|
1205
1258
|
metadata: {
|
|
1206
|
-
authorization_endpoint: `${
|
|
1207
|
-
token_endpoint: `${
|
|
1208
|
-
userinfo_endpoint: `${
|
|
1209
|
-
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` +
|
|
1210
1263
|
`?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
|
|
1211
1264
|
`&client_id=${oidcConfiguration.clientId}`,
|
|
1212
1265
|
},
|
|
@@ -1244,7 +1297,10 @@ class AuthManager {
|
|
|
1244
1297
|
};
|
|
1245
1298
|
async login() {
|
|
1246
1299
|
return withPassportError(async () => {
|
|
1247
|
-
const
|
|
1300
|
+
const popupWindowFeatures = { width: 400, height: 420 };
|
|
1301
|
+
const oidcUser = await this.userManager.signinPopup({
|
|
1302
|
+
popupWindowFeatures,
|
|
1303
|
+
});
|
|
1248
1304
|
return this.mapOidcUserToDomainModel(oidcUser);
|
|
1249
1305
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
1250
1306
|
}
|
|
@@ -1327,26 +1383,12 @@ var TransactionTypes;
|
|
|
1327
1383
|
const PassportEventType = 'imx_passport_confirmation';
|
|
1328
1384
|
|
|
1329
1385
|
const openPopupCenter = ({ url, title, width, height, }) => {
|
|
1330
|
-
|
|
1331
|
-
const
|
|
1332
|
-
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
|
|
1333
|
-
const windowWidth = window.innerWidth
|
|
1334
|
-
? window.innerWidth
|
|
1335
|
-
: document.documentElement.clientWidth
|
|
1336
|
-
? document.documentElement.clientWidth
|
|
1337
|
-
: screen.width;
|
|
1338
|
-
const windowHeight = window.innerHeight
|
|
1339
|
-
? window.innerHeight
|
|
1340
|
-
: document.documentElement.clientHeight
|
|
1341
|
-
? document.documentElement.clientHeight
|
|
1342
|
-
: screen.height;
|
|
1343
|
-
const systemZoom = windowWidth / window.screen.availWidth;
|
|
1344
|
-
const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
|
|
1345
|
-
const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
|
|
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));
|
|
1346
1388
|
const newWindow = window.open(url, title, `
|
|
1347
1389
|
scrollbars=yes,
|
|
1348
|
-
width=${width
|
|
1349
|
-
height=${height
|
|
1390
|
+
width=${width},
|
|
1391
|
+
height=${height},
|
|
1350
1392
|
top=${top},
|
|
1351
1393
|
left=${left}
|
|
1352
1394
|
`);
|
|
@@ -1358,8 +1400,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
|
|
|
1358
1400
|
};
|
|
1359
1401
|
|
|
1360
1402
|
const ConfirmationWindowTitle = 'Confirm this transaction';
|
|
1361
|
-
const ConfirmationWindowHeight =
|
|
1362
|
-
const ConfirmationWindowWidth =
|
|
1403
|
+
const ConfirmationWindowHeight = 380;
|
|
1404
|
+
const ConfirmationWindowWidth = 480;
|
|
1363
1405
|
const ConfirmationWindowClosedPollingDuration = 1000;
|
|
1364
1406
|
class ConfirmationScreen {
|
|
1365
1407
|
config;
|
|
@@ -1373,7 +1415,7 @@ class ConfirmationScreen {
|
|
|
1373
1415
|
...message,
|
|
1374
1416
|
}, this.config.passportDomain);
|
|
1375
1417
|
}
|
|
1376
|
-
startTransaction(accessToken, transaction) {
|
|
1418
|
+
startTransaction(accessToken, transaction, popupOptions) {
|
|
1377
1419
|
return new Promise((resolve, reject) => {
|
|
1378
1420
|
const messageHandler = ({ data, origin }) => {
|
|
1379
1421
|
if (origin != this.config.passportDomain ||
|
|
@@ -1404,8 +1446,8 @@ class ConfirmationScreen {
|
|
|
1404
1446
|
const confirmationWindow = openPopupCenter({
|
|
1405
1447
|
url: `${this.config.passportDomain}/transaction-confirmation`,
|
|
1406
1448
|
title: ConfirmationWindowTitle,
|
|
1407
|
-
width: ConfirmationWindowWidth,
|
|
1408
|
-
height: ConfirmationWindowHeight,
|
|
1449
|
+
width: popupOptions?.width || ConfirmationWindowWidth,
|
|
1450
|
+
height: popupOptions?.height || ConfirmationWindowHeight,
|
|
1409
1451
|
});
|
|
1410
1452
|
// https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
|
|
1411
1453
|
const timer = setInterval(function () {
|
|
@@ -1492,10 +1534,11 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
|
|
|
1492
1534
|
getSignableTransferRequestV2,
|
|
1493
1535
|
});
|
|
1494
1536
|
const confirmationScreen = new ConfirmationScreen(passportConfig);
|
|
1537
|
+
const popupWindowSize = { width: 480, height: 784 };
|
|
1495
1538
|
const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
|
|
1496
1539
|
transactionType: TransactionTypes.CreateBatchTransfer,
|
|
1497
1540
|
transactionData: getSignableTransferRequestV2,
|
|
1498
|
-
});
|
|
1541
|
+
}, popupWindowSize);
|
|
1499
1542
|
if (!confirmationResult.confirmed) {
|
|
1500
1543
|
throw new Error('Transaction rejected by user');
|
|
1501
1544
|
}
|
|
@@ -1704,7 +1747,7 @@ async function createTrade({ request, tradesApi, user, starkSigner, passportConf
|
|
|
1704
1747
|
},
|
|
1705
1748
|
};
|
|
1706
1749
|
const headers = { Authorization: 'Bearer ' + user.accessToken };
|
|
1707
|
-
const { data: createTradeResponse } = await tradesApi.
|
|
1750
|
+
const { data: createTradeResponse } = await tradesApi.createTradeV3(tradeParams, {
|
|
1708
1751
|
headers,
|
|
1709
1752
|
});
|
|
1710
1753
|
return createTradeResponse;
|
|
@@ -1723,8 +1766,8 @@ class PassportImxProvider {
|
|
|
1723
1766
|
this.user = user;
|
|
1724
1767
|
this.starkSigner = starkSigner;
|
|
1725
1768
|
this.passportConfig = passportConfig;
|
|
1726
|
-
const apiConfig = new Configuration
|
|
1727
|
-
basePath: passportConfig.
|
|
1769
|
+
const apiConfig = new Configuration({
|
|
1770
|
+
basePath: passportConfig.imxApiBasePath,
|
|
1728
1771
|
});
|
|
1729
1772
|
this.transfersApi = new TransfersApi(apiConfig);
|
|
1730
1773
|
this.ordersApi = new OrdersApi(apiConfig);
|
|
@@ -1816,67 +1859,75 @@ var Networks;
|
|
|
1816
1859
|
Networks["SANDBOX"] = "goerli";
|
|
1817
1860
|
})(Networks || (Networks = {}));
|
|
1818
1861
|
|
|
1819
|
-
const
|
|
1820
|
-
PRODUCTION: {
|
|
1821
|
-
network: Networks.PRODUCTION,
|
|
1822
|
-
authenticationDomain: 'https://auth.immutable.com',
|
|
1823
|
-
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1824
|
-
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1825
|
-
baseIMXApiPath: 'https://api.x.immutable.com',
|
|
1826
|
-
passportDomain: 'https://passport.immutable.com',
|
|
1827
|
-
},
|
|
1828
|
-
SANDBOX: {
|
|
1829
|
-
network: Networks.SANDBOX,
|
|
1830
|
-
authenticationDomain: 'https://auth.immutable.com',
|
|
1831
|
-
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1832
|
-
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1833
|
-
baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
|
|
1834
|
-
passportDomain: 'https://passport.sandbox.immutable.com',
|
|
1835
|
-
},
|
|
1836
|
-
};
|
|
1837
|
-
const validateConfiguration = (configurationName, configuration, requiredKeys) => {
|
|
1838
|
-
if (!configuration) {
|
|
1839
|
-
throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
|
|
1840
|
-
}
|
|
1862
|
+
const validateConfiguration = (configuration, requiredKeys, prefix) => {
|
|
1841
1863
|
const missingKeys = requiredKeys
|
|
1842
1864
|
.map((key) => !configuration[key] && key)
|
|
1843
1865
|
.filter((n) => n)
|
|
1844
1866
|
.join(', ');
|
|
1845
1867
|
if (missingKeys !== '') {
|
|
1846
|
-
|
|
1868
|
+
const errorMessage = prefix
|
|
1869
|
+
? `${prefix} - ${missingKeys} cannot be null`
|
|
1870
|
+
: `${missingKeys} cannot be null`;
|
|
1871
|
+
throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
|
|
1847
1872
|
}
|
|
1848
1873
|
};
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
oidcConfiguration
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
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
|
+
}
|
|
1880
1931
|
|
|
1881
1932
|
const getStarkSigner = async (signer) => {
|
|
1882
1933
|
return withPassportError(async () => {
|
|
@@ -1915,8 +1966,8 @@ class Passport {
|
|
|
1915
1966
|
authManager;
|
|
1916
1967
|
magicAdapter;
|
|
1917
1968
|
config;
|
|
1918
|
-
constructor(
|
|
1919
|
-
const passportConfiguration =
|
|
1969
|
+
constructor(passportModuleConfiguration) {
|
|
1970
|
+
const passportConfiguration = new PassportConfiguration(passportModuleConfiguration);
|
|
1920
1971
|
this.config = passportConfiguration;
|
|
1921
1972
|
this.authManager = new AuthManager(this.config);
|
|
1922
1973
|
this.magicAdapter = new MagicAdapter(this.config);
|
|
@@ -1963,8 +2014,8 @@ class Passport {
|
|
|
1963
2014
|
return user.accessToken;
|
|
1964
2015
|
}
|
|
1965
2016
|
async registerUser(userAdminKeySigner, starkSigner, jwt) {
|
|
1966
|
-
const configuration = new Configuration
|
|
1967
|
-
basePath: this.config.
|
|
2017
|
+
const configuration = new Configuration({
|
|
2018
|
+
basePath: this.config.imxApiBasePath,
|
|
1968
2019
|
});
|
|
1969
2020
|
const usersApi = new UsersApi(configuration);
|
|
1970
2021
|
await registerPassport({
|
|
@@ -1980,4 +2031,642 @@ class Passport {
|
|
|
1980
2031
|
}
|
|
1981
2032
|
}
|
|
1982
2033
|
|
|
1983
|
-
|
|
2034
|
+
function $parcel$interopDefault(a) {
|
|
2035
|
+
return a && a.__esModule ? a.default : a;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
2039
|
+
{
|
|
2040
|
+
constant: true,
|
|
2041
|
+
inputs: [],
|
|
2042
|
+
name: "name",
|
|
2043
|
+
outputs: [
|
|
2044
|
+
{
|
|
2045
|
+
name: "",
|
|
2046
|
+
type: "string"
|
|
2047
|
+
}
|
|
2048
|
+
],
|
|
2049
|
+
payable: false,
|
|
2050
|
+
type: "function"
|
|
2051
|
+
},
|
|
2052
|
+
{
|
|
2053
|
+
constant: true,
|
|
2054
|
+
inputs: [],
|
|
2055
|
+
name: "decimals",
|
|
2056
|
+
outputs: [
|
|
2057
|
+
{
|
|
2058
|
+
name: "",
|
|
2059
|
+
type: "uint8"
|
|
2060
|
+
}
|
|
2061
|
+
],
|
|
2062
|
+
payable: false,
|
|
2063
|
+
type: "function"
|
|
2064
|
+
},
|
|
2065
|
+
{
|
|
2066
|
+
constant: true,
|
|
2067
|
+
inputs: [
|
|
2068
|
+
{
|
|
2069
|
+
name: "_owner",
|
|
2070
|
+
type: "address"
|
|
2071
|
+
}
|
|
2072
|
+
],
|
|
2073
|
+
name: "balanceOf",
|
|
2074
|
+
outputs: [
|
|
2075
|
+
{
|
|
2076
|
+
name: "balance",
|
|
2077
|
+
type: "uint256"
|
|
2078
|
+
}
|
|
2079
|
+
],
|
|
2080
|
+
payable: false,
|
|
2081
|
+
type: "function"
|
|
2082
|
+
},
|
|
2083
|
+
{
|
|
2084
|
+
constant: true,
|
|
2085
|
+
inputs: [],
|
|
2086
|
+
name: "symbol",
|
|
2087
|
+
outputs: [
|
|
2088
|
+
{
|
|
2089
|
+
name: "",
|
|
2090
|
+
type: "string"
|
|
2091
|
+
}
|
|
2092
|
+
],
|
|
2093
|
+
payable: false,
|
|
2094
|
+
type: "function"
|
|
2095
|
+
}
|
|
2096
|
+
];
|
|
2097
|
+
|
|
2098
|
+
|
|
2099
|
+
let $d176a05e966364ba$export$3bfad4d03ada24c4;
|
|
2100
|
+
(function(ConnectionProviders) {
|
|
2101
|
+
ConnectionProviders["METAMASK"] = "metamask";
|
|
2102
|
+
})($d176a05e966364ba$export$3bfad4d03ada24c4 || ($d176a05e966364ba$export$3bfad4d03ada24c4 = {}));
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
let $a47e48dd2c04791b$export$c06e1e7429de6283;
|
|
2106
|
+
(function(ChainId) {
|
|
2107
|
+
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
2108
|
+
ChainId[ChainId["GOERLI"] = 5] = "GOERLI";
|
|
2109
|
+
ChainId[ChainId["POLYGON"] = 137] = "POLYGON";
|
|
2110
|
+
})($a47e48dd2c04791b$export$c06e1e7429de6283 || ($a47e48dd2c04791b$export$c06e1e7429de6283 = {}));
|
|
2111
|
+
const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
|
|
2112
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.ETHEREUM]: {
|
|
2113
|
+
chainIdHex: "0x1",
|
|
2114
|
+
chainName: "Ethereum",
|
|
2115
|
+
rpcUrls: [
|
|
2116
|
+
"https://mainnet.infura.io/v3/"
|
|
2117
|
+
],
|
|
2118
|
+
nativeCurrency: {
|
|
2119
|
+
name: "Ethereum",
|
|
2120
|
+
symbol: "ETH",
|
|
2121
|
+
decimals: 18
|
|
2122
|
+
},
|
|
2123
|
+
blockExplorerUrls: [
|
|
2124
|
+
"https://etherscan.io/"
|
|
2125
|
+
]
|
|
2126
|
+
},
|
|
2127
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.GOERLI]: {
|
|
2128
|
+
chainIdHex: "0x5",
|
|
2129
|
+
chainName: "Goerli",
|
|
2130
|
+
rpcUrls: [
|
|
2131
|
+
"https://goerli.infura.io/v3/"
|
|
2132
|
+
],
|
|
2133
|
+
nativeCurrency: {
|
|
2134
|
+
name: "Goerli Eth",
|
|
2135
|
+
symbol: "ETH",
|
|
2136
|
+
decimals: 18
|
|
2137
|
+
},
|
|
2138
|
+
blockExplorerUrls: [
|
|
2139
|
+
"https://goerli.etherscan.io/"
|
|
2140
|
+
]
|
|
2141
|
+
},
|
|
2142
|
+
[$a47e48dd2c04791b$export$c06e1e7429de6283.POLYGON]: {
|
|
2143
|
+
chainIdHex: "0x89",
|
|
2144
|
+
chainName: "Polygon",
|
|
2145
|
+
rpcUrls: [
|
|
2146
|
+
"https://polygon-rpc.com"
|
|
2147
|
+
],
|
|
2148
|
+
nativeCurrency: {
|
|
2149
|
+
name: "MATIC",
|
|
2150
|
+
symbol: "MATIC",
|
|
2151
|
+
decimals: 18
|
|
2152
|
+
},
|
|
2153
|
+
blockExplorerUrls: [
|
|
2154
|
+
"https://polygonscan.com/"
|
|
2155
|
+
]
|
|
2156
|
+
}
|
|
2157
|
+
};
|
|
2158
|
+
let $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
2159
|
+
(function(NetworkFilterTypes) {
|
|
2160
|
+
NetworkFilterTypes["ALL"] = "all";
|
|
2161
|
+
})($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
|
|
2162
|
+
|
|
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 = {}));
|
|
2170
|
+
|
|
2171
|
+
|
|
2172
|
+
|
|
2173
|
+
|
|
2174
|
+
const $4f91c5f280efe242$export$a130407f3423b97d = {
|
|
2175
|
+
CHECK_CONNECTION: "eth_accounts",
|
|
2176
|
+
CONNECT: "eth_requestAccounts",
|
|
2177
|
+
ADD_NETWORK: "wallet_addEthereumChain",
|
|
2178
|
+
SWITCH_NETWORK: "wallet_switchEthereumChain"
|
|
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 = {}));
|
|
2186
|
+
|
|
2187
|
+
|
|
2188
|
+
|
|
2189
|
+
|
|
2190
|
+
let $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
|
|
2191
|
+
(function(CheckoutErrorType) {
|
|
2192
|
+
CheckoutErrorType["PROVIDER_PREFERENCE_ERROR"] = "PROVIDER_PREFERENCE_ERROR";
|
|
2193
|
+
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
2194
|
+
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
2195
|
+
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
2196
|
+
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
2197
|
+
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
2198
|
+
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
2199
|
+
CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
|
|
2200
|
+
CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
|
|
2201
|
+
CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
|
|
2202
|
+
CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
|
|
2203
|
+
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
2204
|
+
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
2205
|
+
constructor(message, type, data){
|
|
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");
|
|
2219
|
+
this.type = type;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
|
|
2223
|
+
try {
|
|
2224
|
+
return await fn();
|
|
2225
|
+
} catch (error) {
|
|
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
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
|
|
2242
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2243
|
+
|
|
2244
|
+
var $497c134ecbc8a50f$exports = {};
|
|
2245
|
+
$497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":5},{"chainId":137}]');
|
|
2246
|
+
|
|
2247
|
+
|
|
2248
|
+
const $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE = 4902; // error code (MetaMask)
|
|
2249
|
+
async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
|
|
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
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(provider, chainId) {
|
|
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
|
+
});
|
|
2274
|
+
// WT-1146 - Refer to the README in this folder for explantion on the switch network flow
|
|
2275
|
+
try {
|
|
2276
|
+
await $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId);
|
|
2277
|
+
} catch (err) {
|
|
2278
|
+
if (err.code === $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE) try {
|
|
2279
|
+
await $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId);
|
|
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);
|
|
2282
|
+
} catch (err) {
|
|
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);
|
|
2285
|
+
}
|
|
2286
|
+
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2287
|
+
}
|
|
2288
|
+
// we can assume that if the above succeeds then user has successfully
|
|
2289
|
+
// switched to the network specified
|
|
2290
|
+
const newNetwork = ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId];
|
|
2291
|
+
return {
|
|
2292
|
+
network: {
|
|
2293
|
+
name: newNetwork.chainName,
|
|
2294
|
+
chainId: parseInt(newNetwork.chainIdHex, 16),
|
|
2295
|
+
nativeCurrency: newNetwork.nativeCurrency
|
|
2296
|
+
}
|
|
2297
|
+
};
|
|
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
|
+
}
|
|
2319
|
+
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
2320
|
+
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
2321
|
+
async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
|
|
2322
|
+
if (provider.provider?.request) return await provider.provider.request({
|
|
2323
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
|
|
2324
|
+
params: [
|
|
2325
|
+
{
|
|
2326
|
+
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
|
|
2327
|
+
}
|
|
2328
|
+
]
|
|
2329
|
+
});
|
|
2330
|
+
}
|
|
2331
|
+
async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
|
|
2332
|
+
if (provider.provider?.request) {
|
|
2333
|
+
const addNetwork = {
|
|
2334
|
+
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
|
|
2335
|
+
chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
|
|
2336
|
+
rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
|
|
2337
|
+
nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
|
|
2338
|
+
blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
|
|
2339
|
+
};
|
|
2340
|
+
return await provider.provider.request({
|
|
2341
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
|
|
2342
|
+
params: [
|
|
2343
|
+
addNetwork
|
|
2344
|
+
]
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
|
|
2350
|
+
|
|
2351
|
+
|
|
2352
|
+
|
|
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
|
+
});
|
|
2369
|
+
return {
|
|
2370
|
+
tokens: filteredTokenList
|
|
2371
|
+
};
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2374
|
+
|
|
2375
|
+
|
|
2376
|
+
|
|
2377
|
+
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
|
|
2378
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
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
|
+
});
|
|
2383
|
+
const balance = await provider.getBalance(walletAddress);
|
|
2384
|
+
return {
|
|
2385
|
+
balance: balance,
|
|
2386
|
+
formattedBalance: (utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
|
|
2387
|
+
token: networkInfo.nativeCurrency
|
|
2388
|
+
};
|
|
2389
|
+
}, {
|
|
2390
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
|
|
2391
|
+
});
|
|
2392
|
+
};
|
|
2393
|
+
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
|
|
2394
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2395
|
+
const contract = new (Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
|
|
2396
|
+
const name = await contract.name();
|
|
2397
|
+
const symbol = await contract.symbol();
|
|
2398
|
+
const balance = await contract.balanceOf(walletAddress);
|
|
2399
|
+
const decimals = await contract.decimals();
|
|
2400
|
+
const formattedBalance = (utils).formatUnits(balance, decimals);
|
|
2401
|
+
return {
|
|
2402
|
+
balance: balance,
|
|
2403
|
+
formattedBalance: formattedBalance,
|
|
2404
|
+
token: {
|
|
2405
|
+
name: name,
|
|
2406
|
+
symbol: symbol,
|
|
2407
|
+
decimals: decimals,
|
|
2408
|
+
address: contractAddress
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2411
|
+
}, {
|
|
2412
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
|
|
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);
|
|
2417
|
+
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
2418
|
+
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)({
|
|
2419
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
2420
|
+
chainId: chainId
|
|
2421
|
+
});
|
|
2422
|
+
const allBalancePromises = [];
|
|
2423
|
+
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
|
|
2424
|
+
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
|
|
2425
|
+
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
2426
|
+
const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
2427
|
+
return {
|
|
2428
|
+
balances: getBalanceResults
|
|
2429
|
+
};
|
|
2430
|
+
};
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2437
|
+
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
2441
|
+
const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
|
|
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}`
|
|
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
|
+
}
|
|
2456
|
+
// accounts[0] will have the active account if connected.
|
|
2457
|
+
return {
|
|
2458
|
+
isConnected: accounts && accounts.length > 0,
|
|
2459
|
+
walletAddress: accounts[0] ?? ""
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
|
|
2463
|
+
const web3Provider = await $c99672cf2294e839$var$getWalletProviderForPreference(params.providerPreference);
|
|
2464
|
+
await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
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
|
+
});
|
|
2468
|
+
// this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
|
|
2469
|
+
await web3Provider.provider.request({
|
|
2470
|
+
method: ($4f91c5f280efe242$export$a130407f3423b97d).CONNECT,
|
|
2471
|
+
params: []
|
|
2472
|
+
});
|
|
2473
|
+
}, {
|
|
2474
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR
|
|
2475
|
+
});
|
|
2476
|
+
return web3Provider;
|
|
2477
|
+
}
|
|
2478
|
+
async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
|
|
2479
|
+
let web3Provider = null;
|
|
2480
|
+
switch(providerPreference){
|
|
2481
|
+
case ($d176a05e966364ba$export$3bfad4d03ada24c4).METAMASK:
|
|
2482
|
+
web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
|
|
2483
|
+
break;
|
|
2484
|
+
default:
|
|
2485
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference is not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_PREFERENCE_ERROR);
|
|
2486
|
+
}
|
|
2487
|
+
return web3Provider;
|
|
2488
|
+
}
|
|
2489
|
+
async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
2490
|
+
const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2491
|
+
return await (detectEthereumProvider)();
|
|
2492
|
+
}, {
|
|
2493
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
|
|
2494
|
+
});
|
|
2495
|
+
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
2496
|
+
return new (Web3Provider)(provider);
|
|
2497
|
+
}
|
|
2498
|
+
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
|
|
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
|
+
|
|
2527
|
+
|
|
2528
|
+
const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
|
|
2529
|
+
const { provider: provider , transaction: transaction } = params;
|
|
2530
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2531
|
+
const transactionResponse = await provider.getSigner().sendTransaction(transaction);
|
|
2532
|
+
return {
|
|
2533
|
+
transactionResponse: transactionResponse
|
|
2534
|
+
};
|
|
2535
|
+
}, {
|
|
2536
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).TRANSACTION_ERROR
|
|
2537
|
+
});
|
|
2538
|
+
};
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2542
|
+
|
|
2543
|
+
class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
2544
|
+
async checkIsWalletConnected(params) {
|
|
2545
|
+
return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
|
|
2546
|
+
}
|
|
2547
|
+
async connect(params) {
|
|
2548
|
+
const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
|
|
2549
|
+
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider);
|
|
2550
|
+
return {
|
|
2551
|
+
provider: provider,
|
|
2552
|
+
network: networkInfo
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
async switchNetwork(params) {
|
|
2556
|
+
return await $de192de6ef100f9f$export$b827d9418aeb5dbd(params.provider, params.chainId);
|
|
2557
|
+
}
|
|
2558
|
+
async getBalance(params) {
|
|
2559
|
+
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
|
|
2560
|
+
return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
|
|
2561
|
+
}
|
|
2562
|
+
async getAllBalances(params) {
|
|
2563
|
+
return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
|
|
2564
|
+
}
|
|
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);
|
|
2573
|
+
}
|
|
2574
|
+
async sendTransaction(params) {
|
|
2575
|
+
return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
|
|
2576
|
+
}
|
|
2577
|
+
async getNetworkInfo(params) {
|
|
2578
|
+
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(params.provider);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
function $parcel$export(e, n, v, s) {
|
|
2583
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
2584
|
+
}
|
|
2585
|
+
var $88e4c575901cd68c$exports = {};
|
|
2586
|
+
|
|
2587
|
+
$parcel$export($88e4c575901cd68c$exports, "IMTBLWidgetEvents", () => $88e4c575901cd68c$export$5a0ace85cae72d45);
|
|
2588
|
+
let $88e4c575901cd68c$export$5a0ace85cae72d45;
|
|
2589
|
+
(function(IMTBLWidgetEvents) {
|
|
2590
|
+
IMTBLWidgetEvents["IMTBL_CONNECT_WIDGET_EVENT"] = "imtbl-connect-widget";
|
|
2591
|
+
IMTBLWidgetEvents["IMTBL_WALLET_WIDGET_EVENT"] = "imtbl-wallet-widget";
|
|
2592
|
+
IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
|
|
2593
|
+
IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
|
|
2594
|
+
IMTBLWidgetEvents["IMTBL_BUY_WIDGET_EVENT"] = "imtbl-buy-widget";
|
|
2595
|
+
})($88e4c575901cd68c$export$5a0ace85cae72d45 || ($88e4c575901cd68c$export$5a0ace85cae72d45 = {}));
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
var $d71a87afc3136184$exports = {};
|
|
2599
|
+
|
|
2600
|
+
$parcel$export($d71a87afc3136184$exports, "ConnectEventType", () => $d71a87afc3136184$export$e72e7f9969a47dd3);
|
|
2601
|
+
let $d71a87afc3136184$export$e72e7f9969a47dd3;
|
|
2602
|
+
(function(ConnectEventType) {
|
|
2603
|
+
ConnectEventType["SUCCESS"] = "success";
|
|
2604
|
+
ConnectEventType["FAILURE"] = "failure";
|
|
2605
|
+
ConnectEventType["CLOSE_WIDGET"] = "close-widget";
|
|
2606
|
+
})($d71a87afc3136184$export$e72e7f9969a47dd3 || ($d71a87afc3136184$export$e72e7f9969a47dd3 = {}));
|
|
2607
|
+
|
|
2608
|
+
|
|
2609
|
+
var $9d0f1783d4d36e8a$exports = {};
|
|
2610
|
+
|
|
2611
|
+
$parcel$export($9d0f1783d4d36e8a$exports, "WalletEventType", () => $9d0f1783d4d36e8a$export$d9be06b70b28c742);
|
|
2612
|
+
//wallet widget events
|
|
2613
|
+
let $9d0f1783d4d36e8a$export$d9be06b70b28c742;
|
|
2614
|
+
(function(WalletEventType) {
|
|
2615
|
+
WalletEventType["CLOSE_WIDGET"] = "close-widget";
|
|
2616
|
+
WalletEventType["NETWORK_SWITCH"] = "network-switch";
|
|
2617
|
+
})($9d0f1783d4d36e8a$export$d9be06b70b28c742 || ($9d0f1783d4d36e8a$export$d9be06b70b28c742 = {}));
|
|
2618
|
+
|
|
2619
|
+
|
|
2620
|
+
var $5d497088f13bb116$exports = {};
|
|
2621
|
+
|
|
2622
|
+
$parcel$export($5d497088f13bb116$exports, "SwapEventType", () => $5d497088f13bb116$export$140a49745ab55563);
|
|
2623
|
+
let $5d497088f13bb116$export$140a49745ab55563;
|
|
2624
|
+
(function(SwapEventType) {
|
|
2625
|
+
SwapEventType["SUCCESS"] = "success";
|
|
2626
|
+
SwapEventType["FAILURE"] = "failure";
|
|
2627
|
+
})($5d497088f13bb116$export$140a49745ab55563 || ($5d497088f13bb116$export$140a49745ab55563 = {}));
|
|
2628
|
+
|
|
2629
|
+
|
|
2630
|
+
var $28a5fdc2f5e6c742$exports = {};
|
|
2631
|
+
|
|
2632
|
+
$parcel$export($28a5fdc2f5e6c742$exports, "BridgeEventType", () => $28a5fdc2f5e6c742$export$d1bfa21f7c76447a);
|
|
2633
|
+
let $28a5fdc2f5e6c742$export$d1bfa21f7c76447a;
|
|
2634
|
+
(function(BridgeEventType) {
|
|
2635
|
+
BridgeEventType["CLOSE_WIDGET"] = "close-widget";
|
|
2636
|
+
BridgeEventType["SUCCESS"] = "success";
|
|
2637
|
+
BridgeEventType["FAILURE"] = "failure";
|
|
2638
|
+
})($28a5fdc2f5e6c742$export$d1bfa21f7c76447a || ($28a5fdc2f5e6c742$export$d1bfa21f7c76447a = {}));
|
|
2639
|
+
|
|
2640
|
+
|
|
2641
|
+
var $ede253beebe0de4a$exports = {};
|
|
2642
|
+
|
|
2643
|
+
$parcel$export($ede253beebe0de4a$exports, "BuyEventType", () => $ede253beebe0de4a$export$90db5fe1be5993c1);
|
|
2644
|
+
let $ede253beebe0de4a$export$90db5fe1be5993c1;
|
|
2645
|
+
(function(BuyEventType) {
|
|
2646
|
+
BuyEventType["SUCCESS"] = "success";
|
|
2647
|
+
BuyEventType["FAILURE"] = "failure";
|
|
2648
|
+
BuyEventType["NOT_CONNECTED"] = "not_connected";
|
|
2649
|
+
BuyEventType["CLOSE"] = "close";
|
|
2650
|
+
})($ede253beebe0de4a$export$90db5fe1be5993c1 || ($ede253beebe0de4a$export$90db5fe1be5993c1 = {}));
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
var $9234b4c577442a97$exports = {};
|
|
2654
|
+
|
|
2655
|
+
$parcel$export($9234b4c577442a97$exports, "Network", () => $9234b4c577442a97$export$95be4ae94445245a);
|
|
2656
|
+
$parcel$export($9234b4c577442a97$exports, "WidgetTheme", () => $9234b4c577442a97$export$c88931fdc51854eb);
|
|
2657
|
+
$parcel$export($9234b4c577442a97$exports, "ConnectionProviders", () => $d176a05e966364ba$export$3bfad4d03ada24c4);
|
|
2658
|
+
|
|
2659
|
+
let $9234b4c577442a97$export$95be4ae94445245a;
|
|
2660
|
+
(function(Network) {
|
|
2661
|
+
Network["ETHEREUM"] = "Ethereum";
|
|
2662
|
+
Network["GOERLI"] = "Goerli";
|
|
2663
|
+
Network["POLYGON"] = "Polygon";
|
|
2664
|
+
})($9234b4c577442a97$export$95be4ae94445245a || ($9234b4c577442a97$export$95be4ae94445245a = {}));
|
|
2665
|
+
let $9234b4c577442a97$export$c88931fdc51854eb;
|
|
2666
|
+
(function(WidgetTheme) {
|
|
2667
|
+
WidgetTheme["LIGHT"] = "light";
|
|
2668
|
+
WidgetTheme["DARK"] = "dark";
|
|
2669
|
+
WidgetTheme["CUSTOM"] = "custom";
|
|
2670
|
+
})($9234b4c577442a97$export$c88931fdc51854eb || ($9234b4c577442a97$export$c88931fdc51854eb = {}));
|
|
2671
|
+
|
|
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 };
|