@imtbl/sdk 0.0.1-alpha → 0.0.1-alpha.2
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 +119 -14
- package/dist/base.js +20 -8
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +1 -33
- package/dist/checkout_sdk.js +63 -66
- package/dist/checkout_widgets.d.ts +1 -3
- package/dist/checkout_widgets.js +11 -16
- package/dist/index.cjs +216 -226
- package/dist/index.d.ts +39 -96
- package/dist/index.js +216 -227
- package/dist/passport.d.ts +14 -40
- package/dist/passport.js +91 -95
- package/dist/provider.d.ts +20 -36
- package/dist/provider.js +55 -66
- package/dist/starkex.d.ts +40 -6
- package/dist/starkex.js +1 -1
- package/package.json +2 -11
package/dist/index.cjs
CHANGED
|
@@ -33,21 +33,31 @@ var encUtils__namespace = /*#__PURE__*/_interopNamespaceDefault(encUtils);
|
|
|
33
33
|
|
|
34
34
|
exports.Environment = void 0;
|
|
35
35
|
(function (Environment) {
|
|
36
|
-
Environment["
|
|
36
|
+
Environment["DEVELOPMENT"] = "development";
|
|
37
37
|
Environment["SANDBOX"] = "sandbox";
|
|
38
|
+
Environment["PRODUCTION"] = "production";
|
|
38
39
|
})(exports.Environment || (exports.Environment = {}));
|
|
39
|
-
class
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
class Configuration {
|
|
41
|
+
starkExConfig;
|
|
42
|
+
constructor(config) {
|
|
43
|
+
this.starkExConfig = config;
|
|
44
|
+
}
|
|
45
|
+
getStarkExConfig() {
|
|
46
|
+
return this.starkExConfig;
|
|
45
47
|
}
|
|
46
48
|
}
|
|
49
|
+
const PRODUCTION = {
|
|
50
|
+
...coreSdk.Config.PRODUCTION,
|
|
51
|
+
env: exports.Environment.PRODUCTION,
|
|
52
|
+
};
|
|
53
|
+
const SANDBOX = {
|
|
54
|
+
...coreSdk.Config.SANDBOX,
|
|
55
|
+
env: exports.Environment.SANDBOX,
|
|
56
|
+
};
|
|
47
57
|
|
|
48
58
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
49
59
|
const StarkExAPIFactory = (config) => {
|
|
50
|
-
const imtblClient = new coreSdk.ImmutableX(config.
|
|
60
|
+
const imtblClient = new coreSdk.ImmutableX(config.getStarkExConfig());
|
|
51
61
|
const { deposit, registerOffchain, isRegisteredOnchain, prepareWithdrawal, completeWithdrawal, createOrder, cancelOrder, createTrade, transfer, batchNftTransfer, ...StarkEx } = imtblClient;
|
|
52
62
|
return { ...StarkEx };
|
|
53
63
|
};
|
|
@@ -132,9 +142,9 @@ async function validateChain(signer, config) {
|
|
|
132
142
|
}
|
|
133
143
|
|
|
134
144
|
async function transfer$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
135
|
-
await validateChain(ethSigner, config.
|
|
145
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
136
146
|
const ethAddress = await ethSigner.getAddress();
|
|
137
|
-
const transfersApi = new coreSdk.TransfersApi(config.
|
|
147
|
+
const transfersApi = new coreSdk.TransfersApi(config.getStarkExConfig().apiConfiguration);
|
|
138
148
|
const transferAmount = request.type === 'ERC721' ? '1' : request.amount;
|
|
139
149
|
const signableResult = await transfersApi.getSignableTransferV1({
|
|
140
150
|
getSignableTransferRequest: {
|
|
@@ -172,9 +182,9 @@ async function transfer$1({ signers: { ethSigner, starkExSigner }, request, conf
|
|
|
172
182
|
};
|
|
173
183
|
}
|
|
174
184
|
async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
175
|
-
await validateChain(ethSigner, config.
|
|
185
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
176
186
|
const ethAddress = await ethSigner.getAddress();
|
|
177
|
-
const transfersApi = new coreSdk.TransfersApi(config.
|
|
187
|
+
const transfersApi = new coreSdk.TransfersApi(config.getStarkExConfig().apiConfiguration);
|
|
178
188
|
const signableRequests = request.map((nftTransfer) => {
|
|
179
189
|
return {
|
|
180
190
|
amount: '1',
|
|
@@ -228,9 +238,9 @@ async function batchTransfer({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
228
238
|
}
|
|
229
239
|
|
|
230
240
|
async function createOrder$1({ signers, request, config, }) {
|
|
231
|
-
await validateChain(signers.ethSigner, config.
|
|
241
|
+
await validateChain(signers.ethSigner, config.getStarkExConfig());
|
|
232
242
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
233
|
-
const ordersApi = new coreSdk.OrdersApi(config.
|
|
243
|
+
const ordersApi = new coreSdk.OrdersApi(config.getStarkExConfig().apiConfiguration);
|
|
234
244
|
const amountSell = request.sell.type === 'ERC721' ? '1' : request.sell.amount;
|
|
235
245
|
const amountBuy = request.buy.type === 'ERC721' ? '1' : request.buy.amount;
|
|
236
246
|
const getSignableOrderRequest = {
|
|
@@ -273,7 +283,7 @@ async function createOrder$1({ signers, request, config, }) {
|
|
|
273
283
|
};
|
|
274
284
|
}
|
|
275
285
|
async function cancelOrder$1({ signers, request, config, }) {
|
|
276
|
-
const ordersApi = new coreSdk.OrdersApi(config.
|
|
286
|
+
const ordersApi = new coreSdk.OrdersApi(config.getStarkExConfig().apiConfiguration);
|
|
277
287
|
const getSignableCancelOrderResponse = await ordersApi.getSignableCancelOrder({
|
|
278
288
|
getSignableCancelOrderRequest: {
|
|
279
289
|
order_id: request.order_id,
|
|
@@ -299,8 +309,8 @@ async function cancelOrder$1({ signers, request, config, }) {
|
|
|
299
309
|
}
|
|
300
310
|
|
|
301
311
|
async function registerOffchain(signers, config) {
|
|
302
|
-
await validateChain(signers.ethSigner, config.
|
|
303
|
-
const usersApi = new coreSdk.UsersApi(config.
|
|
312
|
+
await validateChain(signers.ethSigner, config.getStarkExConfig());
|
|
313
|
+
const usersApi = new coreSdk.UsersApi(config.getStarkExConfig().apiConfiguration);
|
|
304
314
|
const userAddress = await signers.ethSigner.getAddress();
|
|
305
315
|
const starkPublicKey = await signers.starkExSigner.getAddress();
|
|
306
316
|
const signableResult = await usersApi.getSignableRegistrationOffchain({
|
|
@@ -323,8 +333,8 @@ async function registerOffchain(signers, config) {
|
|
|
323
333
|
return registeredUser.data;
|
|
324
334
|
}
|
|
325
335
|
async function isRegisteredOnChain(starkPublicKey, ethSigner, config) {
|
|
326
|
-
await validateChain(ethSigner, config.
|
|
327
|
-
const registrationContract = coreSdk.Contracts.Registration.connect(config.
|
|
336
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
337
|
+
const registrationContract = coreSdk.Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
|
|
328
338
|
try {
|
|
329
339
|
return await registrationContract.isRegistered(starkPublicKey);
|
|
330
340
|
}
|
|
@@ -399,10 +409,10 @@ async function getEncodeAssetInfo(assetType, tokenType, config, tokenData) {
|
|
|
399
409
|
|
|
400
410
|
async function executeRegisterAndWithdrawERC20({ ethSigner, assetType, starkPublicKey, config, }) {
|
|
401
411
|
const etherKey = await ethSigner.getAddress();
|
|
402
|
-
const starkExConfig = config.
|
|
412
|
+
const starkExConfig = config.getStarkExConfig();
|
|
403
413
|
const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
|
|
404
414
|
const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
|
|
405
|
-
const contract = coreSdk.Contracts.Registration.connect(config.
|
|
415
|
+
const contract = coreSdk.Contracts.Registration.connect(config.getStarkExConfig().ethConfiguration.registrationContractAddress, ethSigner);
|
|
406
416
|
const populatedTransaction = await contract.populateTransaction.registerAndWithdraw(etherKey, starkPublicKey, signableResult.operator_signature, assetType);
|
|
407
417
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
408
418
|
}
|
|
@@ -412,8 +422,8 @@ async function executeWithdrawERC20(ethSigner, assetType, starkPublicKey, config
|
|
|
412
422
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
413
423
|
}
|
|
414
424
|
async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
415
|
-
await validateChain(ethSigner, config.
|
|
416
|
-
const starkExConfig = config.
|
|
425
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
426
|
+
const starkExConfig = config.getStarkExConfig();
|
|
417
427
|
const assetType = await getEncodeAssetInfo('asset', 'ERC20', starkExConfig, {
|
|
418
428
|
token_address: token.tokenAddress,
|
|
419
429
|
});
|
|
@@ -450,7 +460,7 @@ function getMintingBlob(token) {
|
|
|
450
460
|
return encUtils__namespace.sanitizeHex(encUtils__namespace.utf8ToHex(`{${id}}:{${blueprint}}`));
|
|
451
461
|
}
|
|
452
462
|
async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
453
|
-
const starkExConfig = config.
|
|
463
|
+
const starkExConfig = config.getStarkExConfig();
|
|
454
464
|
const assetType = await getEncodeAssetInfo('mintable-asset', 'ERC721', starkExConfig, {
|
|
455
465
|
id: token.data.id,
|
|
456
466
|
token_address: token.data.tokenAddress,
|
|
@@ -479,7 +489,7 @@ async function executeWithdrawERC721(ethSigner, assetType, starkPublicKey, token
|
|
|
479
489
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
480
490
|
}
|
|
481
491
|
async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config) {
|
|
482
|
-
const starkExConfig = config.
|
|
492
|
+
const starkExConfig = config.getStarkExConfig();
|
|
483
493
|
const assetType = await getEncodeAssetInfo('asset', 'ERC721', starkExConfig, {
|
|
484
494
|
token_id: token.tokenId,
|
|
485
495
|
token_address: token.tokenAddress,
|
|
@@ -493,10 +503,10 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
|
|
|
493
503
|
}
|
|
494
504
|
}
|
|
495
505
|
async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
496
|
-
await validateChain(ethSigner, config.
|
|
506
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
497
507
|
const tokenAddress = token.tokenAddress;
|
|
498
508
|
const tokenId = token.tokenId;
|
|
499
|
-
const starkExConfig = config.
|
|
509
|
+
const starkExConfig = config.getStarkExConfig();
|
|
500
510
|
const mintsApi = new coreSdk.MintsApi(starkExConfig.apiConfiguration);
|
|
501
511
|
return await mintsApi
|
|
502
512
|
.getMintableTokenDetailsByClientTokenId({
|
|
@@ -534,8 +544,8 @@ async function executeWithdrawEth(ethSigner, assetType, starkPublicKey, config)
|
|
|
534
544
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
535
545
|
}
|
|
536
546
|
async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config, }) {
|
|
537
|
-
await validateChain(ethSigner, config.
|
|
538
|
-
const starkExConfig = config.
|
|
547
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
548
|
+
const starkExConfig = config.getStarkExConfig();
|
|
539
549
|
const assetType = await getEncodeAssetInfo('asset', 'ETH', starkExConfig);
|
|
540
550
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
541
551
|
if (!isRegistered) {
|
|
@@ -547,9 +557,10 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
|
|
|
547
557
|
}
|
|
548
558
|
|
|
549
559
|
async function prepareWithdrawal({ signers, withdrawal, config, }) {
|
|
560
|
+
const starkExConfig = config.getStarkExConfig();
|
|
550
561
|
return prepareWithdrawalAction({
|
|
551
562
|
signers,
|
|
552
|
-
config:
|
|
563
|
+
config: starkExConfig,
|
|
553
564
|
...withdrawal,
|
|
554
565
|
});
|
|
555
566
|
}
|
|
@@ -575,9 +586,9 @@ async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, toke
|
|
|
575
586
|
}
|
|
576
587
|
|
|
577
588
|
async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, config, }) {
|
|
578
|
-
await validateChain(ethSigner, config.
|
|
589
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
579
590
|
const ethAddress = await ethSigner.getAddress();
|
|
580
|
-
const tradesApi = new coreSdk.TradesApi(config.
|
|
591
|
+
const tradesApi = new coreSdk.TradesApi(config.getStarkExConfig().apiConfiguration);
|
|
581
592
|
const signableResult = await tradesApi.getSignableTrade({
|
|
582
593
|
getSignableTradeRequest: {
|
|
583
594
|
user: ethAddress,
|
|
@@ -612,13 +623,13 @@ async function createTrade$1({ signers: { ethSigner, starkExSigner }, request, c
|
|
|
612
623
|
}
|
|
613
624
|
|
|
614
625
|
async function depositEth({ signers: { ethSigner }, deposit, config, }) {
|
|
615
|
-
await validateChain(ethSigner, config.
|
|
626
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
616
627
|
const user = await ethSigner.getAddress();
|
|
617
628
|
const data = {
|
|
618
629
|
decimals: 18,
|
|
619
630
|
};
|
|
620
631
|
const amount = units.parseUnits(deposit.amount, 'wei');
|
|
621
|
-
const starkExConfig = config.
|
|
632
|
+
const starkExConfig = config.getStarkExConfig();
|
|
622
633
|
const depositsApi = new coreSdk.DepositsApi(starkExConfig.apiConfiguration);
|
|
623
634
|
const encodingApi = new coreSdk.EncodingApi(starkExConfig.apiConfiguration);
|
|
624
635
|
const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
|
|
@@ -666,8 +677,8 @@ async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, v
|
|
|
666
677
|
}
|
|
667
678
|
|
|
668
679
|
async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
669
|
-
await validateChain(ethSigner, config.
|
|
670
|
-
const { apiConfiguration, ethConfiguration } = config.
|
|
680
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
681
|
+
const { apiConfiguration, ethConfiguration } = config.getStarkExConfig();
|
|
671
682
|
const user = await ethSigner.getAddress();
|
|
672
683
|
const tokensApi = new coreSdk.TokensApi(apiConfiguration);
|
|
673
684
|
const depositsApi = new coreSdk.DepositsApi(apiConfiguration);
|
|
@@ -734,12 +745,12 @@ async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetT
|
|
|
734
745
|
}
|
|
735
746
|
|
|
736
747
|
async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
737
|
-
await validateChain(ethSigner, config.
|
|
748
|
+
await validateChain(ethSigner, config.getStarkExConfig());
|
|
738
749
|
const user = await ethSigner.getAddress();
|
|
739
|
-
const
|
|
740
|
-
const depositsApi = new coreSdk.DepositsApi(
|
|
741
|
-
const encodingApi = new coreSdk.EncodingApi(
|
|
742
|
-
const usersApi = new coreSdk.UsersApi(
|
|
750
|
+
const starkExConfig = config.getStarkExConfig();
|
|
751
|
+
const depositsApi = new coreSdk.DepositsApi(starkExConfig.apiConfiguration);
|
|
752
|
+
const encodingApi = new coreSdk.EncodingApi(starkExConfig.apiConfiguration);
|
|
753
|
+
const usersApi = new coreSdk.UsersApi(starkExConfig.apiConfiguration);
|
|
743
754
|
const data = {
|
|
744
755
|
token_address: deposit.tokenAddress,
|
|
745
756
|
token_id: deposit.tokenId,
|
|
@@ -775,18 +786,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
|
775
786
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
776
787
|
// Approve whether an amount of token from an account can be spent by a third-party account
|
|
777
788
|
const tokenContract = coreSdk.Contracts.IERC721.connect(deposit.tokenAddress, ethSigner);
|
|
778
|
-
const operator =
|
|
789
|
+
const operator = starkExConfig.ethConfiguration.coreContractAddress;
|
|
779
790
|
const isApprovedForAll = await tokenContract.isApprovedForAll(user, operator);
|
|
780
791
|
if (!isApprovedForAll) {
|
|
781
792
|
await tokenContract.setApprovalForAll(operator, true);
|
|
782
793
|
}
|
|
783
794
|
if (!isRegistered) {
|
|
784
795
|
const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
|
|
785
|
-
const coreContract = coreSdk.Contracts.Core.connect(
|
|
796
|
+
const coreContract = coreSdk.Contracts.Core.connect(starkExConfig.ethConfiguration.coreContractAddress, ethSigner);
|
|
786
797
|
// Note: proxy registration contract registerAndDepositNft method is not used as it currently fails erc721 transfer ownership check
|
|
787
798
|
await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
|
|
788
799
|
}
|
|
789
|
-
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId,
|
|
800
|
+
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, starkExConfig);
|
|
790
801
|
}
|
|
791
802
|
async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
|
|
792
803
|
const coreContract = coreSdk.Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
@@ -806,8 +817,8 @@ async function deposit({ signers, deposit, config }) {
|
|
|
806
817
|
}
|
|
807
818
|
|
|
808
819
|
async function exchangeTransfer$1({ signers, request, config, }) {
|
|
809
|
-
await validateChain(signers.ethSigner, config.
|
|
810
|
-
const exchangeApi = new coreSdk.ExchangesApi(config.
|
|
820
|
+
await validateChain(signers.ethSigner, config.getStarkExConfig());
|
|
821
|
+
const exchangeApi = new coreSdk.ExchangesApi(config.getStarkExConfig().apiConfiguration);
|
|
811
822
|
const ethAddress = await signers.ethSigner.getAddress();
|
|
812
823
|
const transferAmount = request.amount;
|
|
813
824
|
const signableResult = await exchangeApi.getExchangeSignableTransfer({
|
|
@@ -1030,6 +1041,7 @@ class ImxSigner {
|
|
|
1030
1041
|
|
|
1031
1042
|
const IMX_WALLET_IFRAME_ID = 'imx-wallet-app';
|
|
1032
1043
|
const IMX_WALLET_IFRAME_HOSTS = {
|
|
1044
|
+
[exports.Environment.DEVELOPMENT]: 'http://localhost:8080',
|
|
1033
1045
|
[exports.Environment.SANDBOX]: 'https://wallets.sandbox.immutable.com',
|
|
1034
1046
|
[exports.Environment.PRODUCTION]: 'https://wallets.immutable.com',
|
|
1035
1047
|
};
|
|
@@ -1127,11 +1139,12 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1127
1139
|
super(config, ethSigner, starkExSigner);
|
|
1128
1140
|
}
|
|
1129
1141
|
static async connect(config) {
|
|
1142
|
+
const starkExConfig = config.getStarkExConfig();
|
|
1130
1143
|
return await withProviderError(async () => {
|
|
1131
1144
|
const metaMaskProvider = await connect$1({
|
|
1132
|
-
chainID:
|
|
1145
|
+
chainID: starkExConfig.ethConfiguration.chainID,
|
|
1133
1146
|
});
|
|
1134
|
-
this.imxSigner = await connect(metaMaskProvider,
|
|
1147
|
+
this.imxSigner = await connect(metaMaskProvider, starkExConfig.env);
|
|
1135
1148
|
return new MetaMaskIMXProvider(config, metaMaskProvider.getSigner(), this.imxSigner);
|
|
1136
1149
|
}, { type: ProviderErrorType.WALLET_CONNECTION_ERROR });
|
|
1137
1150
|
}
|
|
@@ -1153,29 +1166,6 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
1153
1166
|
}
|
|
1154
1167
|
}
|
|
1155
1168
|
|
|
1156
|
-
class ProviderConfiguration {
|
|
1157
|
-
immutableXConfig;
|
|
1158
|
-
baseConfig;
|
|
1159
|
-
constructor({ baseConfig, overrides }) {
|
|
1160
|
-
this.baseConfig = baseConfig;
|
|
1161
|
-
if (overrides) {
|
|
1162
|
-
this.immutableXConfig = overrides.immutableXConfig;
|
|
1163
|
-
}
|
|
1164
|
-
else {
|
|
1165
|
-
switch (baseConfig.environment) {
|
|
1166
|
-
case exports.Environment.SANDBOX: {
|
|
1167
|
-
this.immutableXConfig = coreSdk.Config.SANDBOX;
|
|
1168
|
-
break;
|
|
1169
|
-
}
|
|
1170
|
-
case exports.Environment.PRODUCTION: {
|
|
1171
|
-
this.immutableXConfig = coreSdk.Config.PRODUCTION;
|
|
1172
|
-
break;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
1169
|
var PassportErrorType;
|
|
1180
1170
|
(function (PassportErrorType) {
|
|
1181
1171
|
PassportErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
|
|
@@ -1228,17 +1218,17 @@ const retryWithDelay = async (fn, options) => {
|
|
|
1228
1218
|
}
|
|
1229
1219
|
};
|
|
1230
1220
|
|
|
1231
|
-
const getAuthConfiguration = ({ oidcConfiguration,
|
|
1221
|
+
const getAuthConfiguration = ({ oidcConfiguration, }) => {
|
|
1232
1222
|
const baseConfiguration = {
|
|
1233
|
-
authority: authenticationDomain,
|
|
1223
|
+
authority: oidcConfiguration.authenticationDomain,
|
|
1234
1224
|
redirect_uri: oidcConfiguration.redirectUri,
|
|
1235
1225
|
popup_redirect_uri: oidcConfiguration.redirectUri,
|
|
1236
1226
|
client_id: oidcConfiguration.clientId,
|
|
1237
1227
|
metadata: {
|
|
1238
|
-
authorization_endpoint: `${authenticationDomain}/authorize`,
|
|
1239
|
-
token_endpoint: `${authenticationDomain}/oauth/token`,
|
|
1240
|
-
userinfo_endpoint: `${authenticationDomain}/userinfo`,
|
|
1241
|
-
end_session_endpoint: `${authenticationDomain}/v2/logout` +
|
|
1228
|
+
authorization_endpoint: `${oidcConfiguration.authenticationDomain}/authorize`,
|
|
1229
|
+
token_endpoint: `${oidcConfiguration.authenticationDomain}/oauth/token`,
|
|
1230
|
+
userinfo_endpoint: `${oidcConfiguration.authenticationDomain}/userinfo`,
|
|
1231
|
+
end_session_endpoint: `${oidcConfiguration.authenticationDomain}/v2/logout` +
|
|
1242
1232
|
`?returnTo=${encodeURIComponent(oidcConfiguration.logoutRedirectUri)}` +
|
|
1243
1233
|
`&client_id=${oidcConfiguration.clientId}`,
|
|
1244
1234
|
},
|
|
@@ -1276,10 +1266,7 @@ class AuthManager {
|
|
|
1276
1266
|
};
|
|
1277
1267
|
async login() {
|
|
1278
1268
|
return withPassportError(async () => {
|
|
1279
|
-
const
|
|
1280
|
-
const oidcUser = await this.userManager.signinPopup({
|
|
1281
|
-
popupWindowFeatures,
|
|
1282
|
-
});
|
|
1269
|
+
const oidcUser = await this.userManager.signinPopup();
|
|
1283
1270
|
return this.mapOidcUserToDomainModel(oidcUser);
|
|
1284
1271
|
}, PassportErrorType.AUTHENTICATION_ERROR);
|
|
1285
1272
|
}
|
|
@@ -1362,12 +1349,26 @@ var TransactionTypes;
|
|
|
1362
1349
|
const PassportEventType = 'imx_passport_confirmation';
|
|
1363
1350
|
|
|
1364
1351
|
const openPopupCenter = ({ url, title, width, height, }) => {
|
|
1365
|
-
|
|
1366
|
-
const
|
|
1352
|
+
// Fixes dual-screen position Most browsers Firefox
|
|
1353
|
+
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
|
|
1354
|
+
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
|
|
1355
|
+
const windowWidth = window.innerWidth
|
|
1356
|
+
? window.innerWidth
|
|
1357
|
+
: document.documentElement.clientWidth
|
|
1358
|
+
? document.documentElement.clientWidth
|
|
1359
|
+
: screen.width;
|
|
1360
|
+
const windowHeight = window.innerHeight
|
|
1361
|
+
? window.innerHeight
|
|
1362
|
+
: document.documentElement.clientHeight
|
|
1363
|
+
? document.documentElement.clientHeight
|
|
1364
|
+
: screen.height;
|
|
1365
|
+
const systemZoom = windowWidth / window.screen.availWidth;
|
|
1366
|
+
const left = (windowWidth - width) / 2 / systemZoom + dualScreenLeft;
|
|
1367
|
+
const top = (windowHeight - height) / 2 / systemZoom + dualScreenTop;
|
|
1367
1368
|
const newWindow = window.open(url, title, `
|
|
1368
1369
|
scrollbars=yes,
|
|
1369
|
-
width=${width},
|
|
1370
|
-
height=${height},
|
|
1370
|
+
width=${width / systemZoom},
|
|
1371
|
+
height=${height / systemZoom},
|
|
1371
1372
|
top=${top},
|
|
1372
1373
|
left=${left}
|
|
1373
1374
|
`);
|
|
@@ -1379,8 +1380,8 @@ const openPopupCenter = ({ url, title, width, height, }) => {
|
|
|
1379
1380
|
};
|
|
1380
1381
|
|
|
1381
1382
|
const ConfirmationWindowTitle = 'Confirm this transaction';
|
|
1382
|
-
const ConfirmationWindowHeight =
|
|
1383
|
-
const ConfirmationWindowWidth =
|
|
1383
|
+
const ConfirmationWindowHeight = 600;
|
|
1384
|
+
const ConfirmationWindowWidth = 600;
|
|
1384
1385
|
const ConfirmationWindowClosedPollingDuration = 1000;
|
|
1385
1386
|
class ConfirmationScreen {
|
|
1386
1387
|
config;
|
|
@@ -1394,7 +1395,7 @@ class ConfirmationScreen {
|
|
|
1394
1395
|
...message,
|
|
1395
1396
|
}, this.config.passportDomain);
|
|
1396
1397
|
}
|
|
1397
|
-
startTransaction(accessToken, transaction
|
|
1398
|
+
startTransaction(accessToken, transaction) {
|
|
1398
1399
|
return new Promise((resolve, reject) => {
|
|
1399
1400
|
const messageHandler = ({ data, origin }) => {
|
|
1400
1401
|
if (origin != this.config.passportDomain ||
|
|
@@ -1425,8 +1426,8 @@ class ConfirmationScreen {
|
|
|
1425
1426
|
const confirmationWindow = openPopupCenter({
|
|
1426
1427
|
url: `${this.config.passportDomain}/transaction-confirmation`,
|
|
1427
1428
|
title: ConfirmationWindowTitle,
|
|
1428
|
-
width:
|
|
1429
|
-
height:
|
|
1429
|
+
width: ConfirmationWindowWidth,
|
|
1430
|
+
height: ConfirmationWindowHeight,
|
|
1430
1431
|
});
|
|
1431
1432
|
// https://stackoverflow.com/questions/9388380/capture-the-close-event-of-popup-window-in-javascript/48240128#48240128
|
|
1432
1433
|
const timer = setInterval(function () {
|
|
@@ -1513,11 +1514,10 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
|
|
|
1513
1514
|
getSignableTransferRequestV2,
|
|
1514
1515
|
});
|
|
1515
1516
|
const confirmationScreen = new ConfirmationScreen(passportConfig);
|
|
1516
|
-
const popupWindowSize = { width: 480, height: 784 };
|
|
1517
1517
|
const confirmationResult = await confirmationScreen.startTransaction(user.accessToken, {
|
|
1518
1518
|
transactionType: TransactionTypes.CreateBatchTransfer,
|
|
1519
1519
|
transactionData: getSignableTransferRequestV2,
|
|
1520
|
-
}
|
|
1520
|
+
});
|
|
1521
1521
|
if (!confirmationResult.confirmed) {
|
|
1522
1522
|
throw new Error('Transaction rejected by user');
|
|
1523
1523
|
}
|
|
@@ -1746,7 +1746,7 @@ class PassportImxProvider {
|
|
|
1746
1746
|
this.starkSigner = starkSigner;
|
|
1747
1747
|
this.passportConfig = passportConfig;
|
|
1748
1748
|
const apiConfig = new coreSdk.Configuration({
|
|
1749
|
-
basePath: passportConfig.
|
|
1749
|
+
basePath: passportConfig.imxAPIConfiguration.basePath,
|
|
1750
1750
|
});
|
|
1751
1751
|
this.transfersApi = new coreSdk.TransfersApi(apiConfig);
|
|
1752
1752
|
this.ordersApi = new coreSdk.OrdersApi(apiConfig);
|
|
@@ -1838,75 +1838,67 @@ var Networks;
|
|
|
1838
1838
|
Networks["SANDBOX"] = "goerli";
|
|
1839
1839
|
})(Networks || (Networks = {}));
|
|
1840
1840
|
|
|
1841
|
-
const
|
|
1841
|
+
const Config = {
|
|
1842
|
+
PRODUCTION: {
|
|
1843
|
+
network: Networks.PRODUCTION,
|
|
1844
|
+
authenticationDomain: 'https://auth.immutable.com',
|
|
1845
|
+
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1846
|
+
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1847
|
+
baseIMXApiPath: 'https://api.x.immutable.com',
|
|
1848
|
+
passportDomain: 'https://passport.immutable.com',
|
|
1849
|
+
},
|
|
1850
|
+
SANDBOX: {
|
|
1851
|
+
network: Networks.SANDBOX,
|
|
1852
|
+
authenticationDomain: 'https://auth.immutable.com',
|
|
1853
|
+
magicPublishableApiKey: 'pk_live_10F423798A540ED7',
|
|
1854
|
+
magicProviderId: 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=',
|
|
1855
|
+
baseIMXApiPath: 'https://api.sandbox.x.immutable.com',
|
|
1856
|
+
passportDomain: 'https://passport.sandbox.immutable.com',
|
|
1857
|
+
},
|
|
1858
|
+
};
|
|
1859
|
+
const validateConfiguration = (configurationName, configuration, requiredKeys) => {
|
|
1860
|
+
if (!configuration) {
|
|
1861
|
+
throw new PassportError(`${configurationName} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
|
|
1862
|
+
}
|
|
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
|
-
|
|
1848
|
-
? `${prefix} - ${missingKeys} cannot be null`
|
|
1849
|
-
: `${missingKeys} cannot be null`;
|
|
1850
|
-
throw new PassportError(errorMessage, PassportErrorType.INVALID_CONFIGURATION);
|
|
1868
|
+
throw new PassportError(`${configurationName} - ${missingKeys} cannot be null`, PassportErrorType.INVALID_CONFIGURATION);
|
|
1851
1869
|
}
|
|
1852
1870
|
};
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
this.imxApiBasePath = overrides.imxApiBasePath;
|
|
1885
|
-
}
|
|
1886
|
-
else {
|
|
1887
|
-
switch (baseConfig.environment) {
|
|
1888
|
-
case exports.Environment.SANDBOX: {
|
|
1889
|
-
this.network = Networks.SANDBOX;
|
|
1890
|
-
this.authenticationDomain = 'https://auth.immutable.com';
|
|
1891
|
-
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
1892
|
-
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
1893
|
-
this.passportDomain = 'https://passport.immutable.com';
|
|
1894
|
-
this.imxApiBasePath = 'https://api.x.immutable.com';
|
|
1895
|
-
break;
|
|
1896
|
-
}
|
|
1897
|
-
case exports.Environment.PRODUCTION: {
|
|
1898
|
-
this.network = Networks.PRODUCTION;
|
|
1899
|
-
this.authenticationDomain = 'https://auth.immutable.com';
|
|
1900
|
-
this.magicPublishableApiKey = 'pk_live_10F423798A540ED7';
|
|
1901
|
-
this.magicProviderId = 'fSMzaRQ4O7p4fttl7pCyGVtJS_G70P8SNsLXtPPGHo0=';
|
|
1902
|
-
this.passportDomain = 'https://passport.sandbox.immutable.com';
|
|
1903
|
-
this.imxApiBasePath = 'https://api.sandbox.x.immutable.com';
|
|
1904
|
-
break;
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1871
|
+
const getPassportConfiguration = (environmentConfiguration, oidcConfiguration) => {
|
|
1872
|
+
validateConfiguration('EnvironmentConfiguration', environmentConfiguration, [
|
|
1873
|
+
'network',
|
|
1874
|
+
'authenticationDomain',
|
|
1875
|
+
'magicPublishableApiKey',
|
|
1876
|
+
'magicProviderId',
|
|
1877
|
+
'passportDomain',
|
|
1878
|
+
]);
|
|
1879
|
+
validateConfiguration('OidcConfiguration', oidcConfiguration, [
|
|
1880
|
+
'clientId',
|
|
1881
|
+
'logoutRedirectUri',
|
|
1882
|
+
'redirectUri',
|
|
1883
|
+
]);
|
|
1884
|
+
return {
|
|
1885
|
+
network: environmentConfiguration.network,
|
|
1886
|
+
oidcConfiguration: {
|
|
1887
|
+
authenticationDomain: environmentConfiguration.authenticationDomain,
|
|
1888
|
+
clientId: oidcConfiguration.clientId,
|
|
1889
|
+
logoutRedirectUri: oidcConfiguration.logoutRedirectUri,
|
|
1890
|
+
redirectUri: oidcConfiguration.redirectUri,
|
|
1891
|
+
scope: oidcConfiguration.scope,
|
|
1892
|
+
audience: oidcConfiguration.audience,
|
|
1893
|
+
},
|
|
1894
|
+
imxAPIConfiguration: {
|
|
1895
|
+
basePath: environmentConfiguration.baseIMXApiPath,
|
|
1896
|
+
},
|
|
1897
|
+
passportDomain: environmentConfiguration.passportDomain,
|
|
1898
|
+
magicPublishableApiKey: environmentConfiguration.magicPublishableApiKey,
|
|
1899
|
+
magicProviderId: environmentConfiguration.magicProviderId,
|
|
1900
|
+
};
|
|
1901
|
+
};
|
|
1910
1902
|
|
|
1911
1903
|
const getStarkSigner = async (signer) => {
|
|
1912
1904
|
return withPassportError(async () => {
|
|
@@ -1945,8 +1937,8 @@ class Passport {
|
|
|
1945
1937
|
authManager;
|
|
1946
1938
|
magicAdapter;
|
|
1947
1939
|
config;
|
|
1948
|
-
constructor(
|
|
1949
|
-
const passportConfiguration =
|
|
1940
|
+
constructor(environmentConfiguration, oidcConfiguration) {
|
|
1941
|
+
const passportConfiguration = getPassportConfiguration(environmentConfiguration, oidcConfiguration);
|
|
1950
1942
|
this.config = passportConfiguration;
|
|
1951
1943
|
this.authManager = new AuthManager(this.config);
|
|
1952
1944
|
this.magicAdapter = new MagicAdapter(this.config);
|
|
@@ -1994,7 +1986,7 @@ class Passport {
|
|
|
1994
1986
|
}
|
|
1995
1987
|
async registerUser(userAdminKeySigner, starkSigner, jwt) {
|
|
1996
1988
|
const configuration = new coreSdk.Configuration({
|
|
1997
|
-
basePath: this.config.
|
|
1989
|
+
basePath: this.config.imxAPIConfiguration.basePath,
|
|
1998
1990
|
});
|
|
1999
1991
|
const usersApi = new coreSdk.UsersApi(configuration);
|
|
2000
1992
|
await registerPassport({
|
|
@@ -2010,10 +2002,6 @@ class Passport {
|
|
|
2010
2002
|
}
|
|
2011
2003
|
}
|
|
2012
2004
|
|
|
2013
|
-
function $parcel$interopDefault(a) {
|
|
2014
|
-
return a && a.__esModule ? a.default : a;
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
2005
|
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
2018
2006
|
{
|
|
2019
2007
|
constant: true,
|
|
@@ -2136,12 +2124,6 @@ const $a47e48dd2c04791b$export$f61f4aaec62f6be9 = {
|
|
|
2136
2124
|
};
|
|
2137
2125
|
|
|
2138
2126
|
|
|
2139
|
-
exports.TokenFilterTypes = void 0;
|
|
2140
|
-
(function(TokenFilterTypes) {
|
|
2141
|
-
TokenFilterTypes["SWAP"] = "swap";
|
|
2142
|
-
TokenFilterTypes["BRIDGE"] = "bridge";
|
|
2143
|
-
TokenFilterTypes["ALL"] = "all";
|
|
2144
|
-
})(exports.TokenFilterTypes || (exports.TokenFilterTypes = {}));
|
|
2145
2127
|
|
|
2146
2128
|
|
|
2147
2129
|
|
|
@@ -2152,12 +2134,6 @@ const $4f91c5f280efe242$export$a130407f3423b97d = {
|
|
|
2152
2134
|
ADD_NETWORK: "wallet_addEthereumChain",
|
|
2153
2135
|
SWITCH_NETWORK: "wallet_switchEthereumChain"
|
|
2154
2136
|
};
|
|
2155
|
-
exports.WalletFilterTypes = void 0;
|
|
2156
|
-
(function(WalletFilterTypes) {
|
|
2157
|
-
WalletFilterTypes["ALL"] = "all";
|
|
2158
|
-
WalletFilterTypes["DESKTOP"] = "desktop";
|
|
2159
|
-
WalletFilterTypes["MOBILE"] = "mobile";
|
|
2160
|
-
})(exports.WalletFilterTypes || (exports.WalletFilterTypes = {}));
|
|
2161
2137
|
|
|
2162
2138
|
|
|
2163
2139
|
|
|
@@ -2267,24 +2243,67 @@ async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
|
|
|
2267
2243
|
|
|
2268
2244
|
|
|
2269
2245
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2246
|
+
let $efe60cea83bfc4e8$export$f04a61298a47a40f;
|
|
2247
|
+
(function(Icon) {
|
|
2248
|
+
Icon["ETH"] = "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";
|
|
2249
|
+
Icon["MATIC"] = "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";
|
|
2250
|
+
Icon["IMX"] = "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
|
+
})($efe60cea83bfc4e8$export$f04a61298a47a40f || ($efe60cea83bfc4e8$export$f04a61298a47a40f = {}));
|
|
2252
|
+
const $efe60cea83bfc4e8$export$3dbcce43073f40c7 = [
|
|
2253
|
+
{
|
|
2254
|
+
name: "Ethereum",
|
|
2255
|
+
symbol: "ETH",
|
|
2256
|
+
decimals: 18,
|
|
2257
|
+
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"
|
|
2258
|
+
},
|
|
2259
|
+
{
|
|
2260
|
+
name: "Matic",
|
|
2261
|
+
symbol: "MATIC",
|
|
2262
|
+
address: "0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0",
|
|
2263
|
+
decimals: 18,
|
|
2264
|
+
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"
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
name: "Immutable X",
|
|
2268
|
+
symbol: "IMX",
|
|
2269
|
+
address: "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF",
|
|
2270
|
+
decimals: 18,
|
|
2271
|
+
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"
|
|
2272
|
+
}
|
|
2273
|
+
];
|
|
2274
|
+
const $efe60cea83bfc4e8$var$goerliTokensList = [
|
|
2275
|
+
{
|
|
2276
|
+
name: "Ethereum",
|
|
2277
|
+
symbol: "ETH",
|
|
2278
|
+
decimals: 18,
|
|
2279
|
+
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"
|
|
2280
|
+
},
|
|
2281
|
+
{
|
|
2282
|
+
name: "Immutable X",
|
|
2283
|
+
symbol: "IMX",
|
|
2284
|
+
address: "0x1facdd0165489f373255a90304650e15481b2c85",
|
|
2285
|
+
decimals: 18,
|
|
2286
|
+
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"
|
|
2287
|
+
}
|
|
2288
|
+
];
|
|
2289
|
+
const $efe60cea83bfc4e8$var$polygonTokensList = [];
|
|
2290
|
+
const $efe60cea83bfc4e8$export$473cec51305fdae8 = (chainId)=>{
|
|
2291
|
+
let tokenList = [];
|
|
2292
|
+
switch(chainId){
|
|
2293
|
+
case (exports.ChainId).ETHEREUM:
|
|
2294
|
+
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
2295
|
+
break;
|
|
2296
|
+
case (exports.ChainId).GOERLI:
|
|
2297
|
+
tokenList = $efe60cea83bfc4e8$var$goerliTokensList;
|
|
2298
|
+
break;
|
|
2299
|
+
case (exports.ChainId).POLYGON:
|
|
2300
|
+
tokenList = $efe60cea83bfc4e8$var$polygonTokensList;
|
|
2301
|
+
break;
|
|
2302
|
+
default:
|
|
2303
|
+
tokenList = $efe60cea83bfc4e8$export$3dbcce43073f40c7;
|
|
2304
|
+
}
|
|
2286
2305
|
return {
|
|
2287
|
-
tokens:
|
|
2306
|
+
tokens: tokenList
|
|
2288
2307
|
};
|
|
2289
2308
|
};
|
|
2290
2309
|
|
|
@@ -2329,10 +2348,7 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress
|
|
|
2329
2348
|
const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
|
|
2330
2349
|
if (!Object.values((exports.ChainId)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
2331
2350
|
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
2332
|
-
const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)(
|
|
2333
|
-
type: (exports.TokenFilterTypes).ALL,
|
|
2334
|
-
chainId: chainId
|
|
2335
|
-
});
|
|
2351
|
+
const tokenList = ($efe60cea83bfc4e8$export$473cec51305fdae8)(chainId);
|
|
2336
2352
|
const allBalancePromises = [];
|
|
2337
2353
|
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
|
|
2338
2354
|
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
|
|
@@ -2403,30 +2419,6 @@ async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
|
2403
2419
|
|
|
2404
2420
|
|
|
2405
2421
|
|
|
2406
|
-
var $6f3c55a615003cbf$exports = {};
|
|
2407
|
-
$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"]}]');
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = (exports.WalletFilterTypes).ALL , exclude: exclude }) {
|
|
2411
|
-
// todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
|
|
2412
|
-
const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
|
|
2413
|
-
const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.connectionProvider).includes(wallet.connectionProvider);
|
|
2414
|
-
const allowAllWallets = type === (exports.WalletFilterTypes).ALL;
|
|
2415
|
-
const walletsAllowedForType = wallet.platform.includes(type);
|
|
2416
|
-
return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
|
|
2417
|
-
}).map((wallet)=>{
|
|
2418
|
-
const { platform: platform , ...walletInfo } = wallet;
|
|
2419
|
-
return walletInfo;
|
|
2420
|
-
});
|
|
2421
|
-
return {
|
|
2422
|
-
allowedWallets: filteredWalletsList
|
|
2423
|
-
};
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
2422
|
|
|
2431
2423
|
const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
|
|
2432
2424
|
const { provider: provider , transaction: transaction } = params;
|
|
@@ -2466,10 +2458,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
2466
2458
|
return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
|
|
2467
2459
|
}
|
|
2468
2460
|
getTokenAllowList(params) {
|
|
2469
|
-
return $efe60cea83bfc4e8$export$473cec51305fdae8(params);
|
|
2470
|
-
}
|
|
2471
|
-
async getWalletsAllowList(params) {
|
|
2472
|
-
return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
|
|
2461
|
+
return $efe60cea83bfc4e8$export$473cec51305fdae8(params.chainId);
|
|
2473
2462
|
}
|
|
2474
2463
|
async sendTransaction(params) {
|
|
2475
2464
|
return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
|
|
@@ -2566,11 +2555,12 @@ exports.WidgetTheme = void 0;
|
|
|
2566
2555
|
})(exports.WidgetTheme || (exports.WidgetTheme = {}));
|
|
2567
2556
|
|
|
2568
2557
|
exports.Checkout = $a8cb37a3fc8eb863$export$1f60ba4ec72508a0;
|
|
2558
|
+
exports.Config = Config;
|
|
2559
|
+
exports.Configuration = Configuration;
|
|
2569
2560
|
exports.GenericIMXProvider = GenericIMXProvider;
|
|
2570
|
-
exports.ImmutableConfiguration = ImmutableConfiguration;
|
|
2571
2561
|
exports.MetaMaskIMXProvider = MetaMaskIMXProvider;
|
|
2562
|
+
exports.PRODUCTION = PRODUCTION;
|
|
2572
2563
|
exports.Passport = Passport;
|
|
2573
|
-
exports.PassportConfiguration = PassportConfiguration;
|
|
2574
2564
|
exports.PassportError = PassportError;
|
|
2575
|
-
exports.
|
|
2565
|
+
exports.SANDBOX = SANDBOX;
|
|
2576
2566
|
exports.StarkExAPIFactory = StarkExAPIFactory;
|