@imtbl/sdk 0.1.8 → 0.1.9-alpha
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/blockchain-data.d.ts +1890 -0
- package/dist/blockchain-data.js +2725 -0
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +1062 -0
- package/dist/checkout_sdk.js +1107 -0
- package/dist/checkout_widgets.d.ts +15335 -0
- package/dist/checkout_widgets.js +221 -0
- package/dist/erc20.d.ts +296 -0
- package/dist/erc20.js +371 -0
- package/dist/erc721-permissioned-mintable.d.ts +435 -0
- package/dist/erc721-permissioned-mintable.js +1165 -0
- package/dist/immutablex_client.js +1 -1
- package/dist/index.cjs +13365 -2534
- package/dist/index.d.ts +24118 -6352
- package/dist/index.js +13359 -2543
- package/dist/orderbook.d.ts +64 -0
- package/dist/orderbook.js +2020 -0
- package/dist/passport.d.ts +3 -4
- package/dist/passport.js +3681 -436
- package/package.json +30 -1
|
@@ -0,0 +1,1107 @@
|
|
|
1
|
+
import { utils, Contract, ethers, BigNumber as BigNumber$1 } from 'ethers';
|
|
2
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
+
import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
|
|
4
|
+
import { BigNumber, utils as utils$1 } from 'ethers/lib/ethers';
|
|
5
|
+
import { BridgeConfiguration, ETH_MAINNET_TO_ZKEVM_MAINNET, ETH_SEPOLIA_TO_ZKEVM_DEVNET, TokenBridge } from '@imtbl/bridge-sdk';
|
|
6
|
+
import { Exchange, ExchangeConfiguration } from '@imtbl/dex-sdk';
|
|
7
|
+
|
|
8
|
+
var Environment;
|
|
9
|
+
(function (Environment) {
|
|
10
|
+
Environment["PRODUCTION"] = "production";
|
|
11
|
+
Environment["SANDBOX"] = "sandbox";
|
|
12
|
+
})(Environment || (Environment = {}));
|
|
13
|
+
class ImmutableConfiguration {
|
|
14
|
+
environment;
|
|
15
|
+
apiKey;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.environment = options.environment;
|
|
18
|
+
this.apiKey = options.apiKey;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function $parcel$interopDefault(a) {
|
|
23
|
+
return a && a.__esModule ? a.default : a;
|
|
24
|
+
}
|
|
25
|
+
/* eslint-disable class-methods-use-this */
|
|
26
|
+
const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
27
|
+
{
|
|
28
|
+
constant: true,
|
|
29
|
+
inputs: [],
|
|
30
|
+
name: "name",
|
|
31
|
+
outputs: [
|
|
32
|
+
{
|
|
33
|
+
name: "",
|
|
34
|
+
type: "string"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
payable: false,
|
|
38
|
+
type: "function"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
constant: true,
|
|
42
|
+
inputs: [],
|
|
43
|
+
name: "decimals",
|
|
44
|
+
outputs: [
|
|
45
|
+
{
|
|
46
|
+
name: "",
|
|
47
|
+
type: "uint8"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
payable: false,
|
|
51
|
+
type: "function"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
constant: true,
|
|
55
|
+
inputs: [
|
|
56
|
+
{
|
|
57
|
+
name: "_owner",
|
|
58
|
+
type: "address"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
name: "balanceOf",
|
|
62
|
+
outputs: [
|
|
63
|
+
{
|
|
64
|
+
name: "balance",
|
|
65
|
+
type: "uint256"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
payable: false,
|
|
69
|
+
type: "function"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
constant: true,
|
|
73
|
+
inputs: [],
|
|
74
|
+
name: "symbol",
|
|
75
|
+
outputs: [
|
|
76
|
+
{
|
|
77
|
+
name: "",
|
|
78
|
+
type: "string"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
payable: false,
|
|
82
|
+
type: "function"
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Enum representing the supported chains with their corresponding IDs.
|
|
89
|
+
*/ var $baec09ddc3013323$export$c06e1e7429de6283;
|
|
90
|
+
(function(ChainId) {
|
|
91
|
+
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
92
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13372] = "IMTBL_ZKEVM_TESTNET";
|
|
93
|
+
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
94
|
+
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13383] = "IMTBL_ZKEVM_DEVNET";
|
|
95
|
+
})($baec09ddc3013323$export$c06e1e7429de6283 || ($baec09ddc3013323$export$c06e1e7429de6283 = {}));
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
const $bc2bfebf768286d3$export$6a2ba3c3bd042990 = {
|
|
100
|
+
baseConfig: {
|
|
101
|
+
environment: (Environment).SANDBOX
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
var $d176a05e966364ba$export$3bfad4d03ada24c4;
|
|
107
|
+
(function(ConnectionProviders) {
|
|
108
|
+
ConnectionProviders["METAMASK"] = "metamask";
|
|
109
|
+
})($d176a05e966364ba$export$3bfad4d03ada24c4 || ($d176a05e966364ba$export$3bfad4d03ada24c4 = {}));
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
var $de275b98d2b651c3$export$788b1fd17f3dad84;
|
|
113
|
+
(function(GasEstimateType) {
|
|
114
|
+
GasEstimateType["BRIDGE_TO_L2"] = "BRIDGE_TO_L2";
|
|
115
|
+
GasEstimateType["SWAP"] = "SWAP";
|
|
116
|
+
})($de275b98d2b651c3$export$788b1fd17f3dad84 || ($de275b98d2b651c3$export$788b1fd17f3dad84 = {}));
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
const $a47e48dd2c04791b$export$345c852d0dc8f1df = new Map([
|
|
121
|
+
[
|
|
122
|
+
($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM,
|
|
123
|
+
"https://checkout-api.dev.immutable.com/v1/rpc/eth-mainnet"
|
|
124
|
+
],
|
|
125
|
+
[
|
|
126
|
+
($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET,
|
|
127
|
+
"https://zkevm-rpc.sandbox.x.immutable.com"
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA,
|
|
131
|
+
"https://checkout-api.dev.immutable.com/v1/rpc/eth-sepolia"
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET,
|
|
135
|
+
"https://zkevm-rpc.dev.x.immutable.com"
|
|
136
|
+
]
|
|
137
|
+
]);
|
|
138
|
+
const $a47e48dd2c04791b$export$6f24f3cef7d501c4 = new Map([
|
|
139
|
+
[
|
|
140
|
+
($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM,
|
|
141
|
+
{
|
|
142
|
+
chainIdHex: "0x1",
|
|
143
|
+
chainName: "Ethereum",
|
|
144
|
+
rpcUrls: [
|
|
145
|
+
$a47e48dd2c04791b$export$345c852d0dc8f1df.get(($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM)
|
|
146
|
+
],
|
|
147
|
+
nativeCurrency: {
|
|
148
|
+
name: "Ethereum",
|
|
149
|
+
symbol: "ETH",
|
|
150
|
+
decimals: 18
|
|
151
|
+
},
|
|
152
|
+
blockExplorerUrls: [
|
|
153
|
+
"https://etherscan.io/"
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
[
|
|
158
|
+
($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET,
|
|
159
|
+
{
|
|
160
|
+
chainIdHex: "0x343C",
|
|
161
|
+
chainName: "Immutable zkEVM Testnet",
|
|
162
|
+
rpcUrls: [
|
|
163
|
+
$a47e48dd2c04791b$export$345c852d0dc8f1df.get(($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET)
|
|
164
|
+
],
|
|
165
|
+
nativeCurrency: {
|
|
166
|
+
name: "IMX",
|
|
167
|
+
symbol: "IMX",
|
|
168
|
+
decimals: 18
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
]);
|
|
173
|
+
const $a47e48dd2c04791b$export$3e81fc0987227f10 = new Map([
|
|
174
|
+
[
|
|
175
|
+
($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA,
|
|
176
|
+
{
|
|
177
|
+
chainIdHex: "0xaa36a7",
|
|
178
|
+
chainName: "Sepolia",
|
|
179
|
+
rpcUrls: [
|
|
180
|
+
$a47e48dd2c04791b$export$345c852d0dc8f1df.get(($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA)
|
|
181
|
+
],
|
|
182
|
+
nativeCurrency: {
|
|
183
|
+
name: "Sep Eth",
|
|
184
|
+
symbol: "ETH",
|
|
185
|
+
decimals: 18
|
|
186
|
+
},
|
|
187
|
+
blockExplorerUrls: [
|
|
188
|
+
"https://sepolia.etherscan.io/"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
[
|
|
193
|
+
($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET,
|
|
194
|
+
{
|
|
195
|
+
chainIdHex: "0x3447",
|
|
196
|
+
chainName: "Immutable zkEVM Devnet",
|
|
197
|
+
rpcUrls: [
|
|
198
|
+
$a47e48dd2c04791b$export$345c852d0dc8f1df.get(($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET)
|
|
199
|
+
],
|
|
200
|
+
nativeCurrency: {
|
|
201
|
+
name: "IMX",
|
|
202
|
+
symbol: "IMX",
|
|
203
|
+
decimals: 18
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
]);
|
|
208
|
+
var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
209
|
+
(function(NetworkFilterTypes) {
|
|
210
|
+
NetworkFilterTypes["ALL"] = "all";
|
|
211
|
+
})($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
217
|
+
(function(TokenFilterTypes) {
|
|
218
|
+
TokenFilterTypes["SWAP"] = "swap";
|
|
219
|
+
TokenFilterTypes["BRIDGE"] = "bridge";
|
|
220
|
+
TokenFilterTypes["ALL"] = "all";
|
|
221
|
+
})($08d5ddc39acd6833$export$fd9b17d87f4121d2 || ($08d5ddc39acd6833$export$fd9b17d87f4121d2 = {}));
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Interface representing token information.
|
|
226
|
+
* @property {string} name - The token name.
|
|
227
|
+
* @property {string} symbol - The token symbol.
|
|
228
|
+
* @property {number} decimals - The token decimals.
|
|
229
|
+
* @property {string} [address] - The token contract address.
|
|
230
|
+
* @property {string} [icon] - The token icon URL/data:image.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
var $4f91c5f280efe242$export$35b06f0d33f57e26;
|
|
236
|
+
(function(WalletAction) {
|
|
237
|
+
WalletAction["CHECK_CONNECTION"] = "eth_accounts";
|
|
238
|
+
WalletAction["CONNECT"] = "eth_requestAccounts";
|
|
239
|
+
WalletAction["ADD_NETWORK"] = "wallet_addEthereumChain";
|
|
240
|
+
WalletAction["SWITCH_NETWORK"] = "wallet_switchEthereumChain";
|
|
241
|
+
WalletAction["GET_CHAINID"] = "eth_chainId";
|
|
242
|
+
})($4f91c5f280efe242$export$35b06f0d33f57e26 || ($4f91c5f280efe242$export$35b06f0d33f57e26 = {}));
|
|
243
|
+
var $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
244
|
+
(function(WalletFilterTypes) {
|
|
245
|
+
WalletFilterTypes["ALL"] = "all";
|
|
246
|
+
WalletFilterTypes["DESKTOP"] = "desktop";
|
|
247
|
+
WalletFilterTypes["MOBILE"] = "mobile";
|
|
248
|
+
})($4f91c5f280efe242$export$a75605c67ea83a5a || ($4f91c5f280efe242$export$a75605c67ea83a5a = {}));
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
var $e768639828688ca3$export$2d7a51a18d87e21d;
|
|
252
|
+
(function(WalletProviderName) {
|
|
253
|
+
WalletProviderName["METAMASK"] = "metamask";
|
|
254
|
+
})($e768639828688ca3$export$2d7a51a18d87e21d || ($e768639828688ca3$export$2d7a51a18d87e21d = {}));
|
|
255
|
+
const $e768639828688ca3$export$44dde05038008549 = {
|
|
256
|
+
allowMistmatchedChainId: false,
|
|
257
|
+
allowUnsupportedProvider: false
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* The different types of errors that can be returned by the checkout process.
|
|
265
|
+
*/ var $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
|
|
266
|
+
(function(CheckoutErrorType) {
|
|
267
|
+
CheckoutErrorType["WEB3_PROVIDER_ERROR"] = "WEB3_PROVIDER_ERROR";
|
|
268
|
+
CheckoutErrorType["PROVIDER_ERROR"] = "PROVIDER_ERROR";
|
|
269
|
+
CheckoutErrorType["DEFAULT_PROVIDER_ERROR"] = "DEFAULT_PROVIDER_ERROR";
|
|
270
|
+
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
271
|
+
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
272
|
+
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
273
|
+
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
274
|
+
CheckoutErrorType["METAMASK_PROVIDER_ERROR"] = "METAMASK_PROVIDER_ERROR";
|
|
275
|
+
CheckoutErrorType["CHAIN_NOT_SUPPORTED_ERROR"] = "CHAIN_NOT_SUPPORTED_ERROR";
|
|
276
|
+
CheckoutErrorType["PROVIDER_REQUEST_MISSING_ERROR"] = "PROVIDER_REQUEST_MISSING_ERROR";
|
|
277
|
+
CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
|
|
278
|
+
CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
|
|
279
|
+
CheckoutErrorType["TRANSACTION_FAILED"] = "TRANSACTION_FAILED";
|
|
280
|
+
CheckoutErrorType["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
281
|
+
CheckoutErrorType["UNPREDICTABLE_GAS_LIMIT"] = "UNPREDICTABLE_GAS_LIMIT";
|
|
282
|
+
CheckoutErrorType["INVALID_GAS_ESTIMATE_TYPE"] = "INVALID_GAS_ESTIMATE_TYPE";
|
|
283
|
+
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
284
|
+
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
285
|
+
message;
|
|
286
|
+
type;
|
|
287
|
+
data;
|
|
288
|
+
constructor(message, type, data){
|
|
289
|
+
super(message);
|
|
290
|
+
this.message = message;
|
|
291
|
+
this.type = type;
|
|
292
|
+
this.data = data;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
var $a8bc256d81a5e2c1$export$a22d4e0719ee6def;
|
|
296
|
+
(function(CheckoutInternalErrorType) {
|
|
297
|
+
CheckoutInternalErrorType["REJECTED_SWITCH_AFTER_ADDING_NETWORK"] = "REJECTED_SWITCH_AFTER_ADDING_NETWORK";
|
|
298
|
+
})($a8bc256d81a5e2c1$export$a22d4e0719ee6def || ($a8bc256d81a5e2c1$export$a22d4e0719ee6def = {}));
|
|
299
|
+
const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
|
|
300
|
+
try {
|
|
301
|
+
return await fn();
|
|
302
|
+
} catch (error) {
|
|
303
|
+
const cause = `${error.message}` || "UnknownError";
|
|
304
|
+
const errorMessage = customError.message ? `[${customError.type}]:${customError.message}. Cause:${cause}` : `[${customError.type}] Cause:${cause}`;
|
|
305
|
+
if (error instanceof $a8bc256d81a5e2c1$export$b722478a3cbfa3bc) throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
|
|
306
|
+
...customError.data,
|
|
307
|
+
innerErrorType: error.type,
|
|
308
|
+
...error.data
|
|
309
|
+
});
|
|
310
|
+
throw new $a8bc256d81a5e2c1$export$b722478a3cbfa3bc(errorMessage, customError.type, {
|
|
311
|
+
...customError.data
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
var $497c134ecbc8a50f$exports = {};
|
|
323
|
+
$497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":11155111},{"chainId":13372},{"chainId":13383}]');
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
// this function needs to be in a separate file to prevent circular dependencies with ./network
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
async function $a1555a1d2c8d059b$export$c3ba3e93a9fee972(web3Provider) {
|
|
330
|
+
if (!web3Provider.provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Parsed provider is not a valid Web3Provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
331
|
+
const chainId = await web3Provider.provider.request({
|
|
332
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).GET_CHAINID,
|
|
333
|
+
params: []
|
|
334
|
+
});
|
|
335
|
+
return parseInt(chainId, 16);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
const $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE = 4902; // error code (MetaMask)
|
|
340
|
+
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
341
|
+
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
342
|
+
// eslint-disable-next-line consistent-return
|
|
343
|
+
async function $de192de6ef100f9f$var$switchNetworkInWallet(networkMap, web3Provider, chainId) {
|
|
344
|
+
if (web3Provider.provider?.request) return await web3Provider.provider.request({
|
|
345
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).SWITCH_NETWORK,
|
|
346
|
+
params: [
|
|
347
|
+
{
|
|
348
|
+
chainId: networkMap.get(chainId)?.chainIdHex
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
// TODO: Should these functions always return something?
|
|
354
|
+
// eslint-disable-next-line consistent-return
|
|
355
|
+
async function $de192de6ef100f9f$var$addNetworkToWallet(networkMap, web3Provider, chainId) {
|
|
356
|
+
if (web3Provider.provider?.request) {
|
|
357
|
+
const networkDetails = networkMap.get(chainId);
|
|
358
|
+
const addNetwork = {
|
|
359
|
+
chainId: networkDetails?.chainIdHex,
|
|
360
|
+
chainName: networkDetails?.chainName,
|
|
361
|
+
rpcUrls: networkDetails?.rpcUrls,
|
|
362
|
+
nativeCurrency: networkDetails?.nativeCurrency,
|
|
363
|
+
blockExplorerUrls: networkDetails?.blockExplorerUrls
|
|
364
|
+
};
|
|
365
|
+
return await web3Provider.provider.request({
|
|
366
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).ADD_NETWORK,
|
|
367
|
+
params: [
|
|
368
|
+
addNetwork
|
|
369
|
+
]
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async function $de192de6ef100f9f$export$3043f6442a9ef563(config, { type: type = ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL , exclude: exclude }) {
|
|
374
|
+
const { networkMap: networkMap } = config;
|
|
375
|
+
const list = ((/*@__PURE__*/$parcel$interopDefault($497c134ecbc8a50f$exports))).filter((network)=>{
|
|
376
|
+
const allowAllTokens = type === ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL;
|
|
377
|
+
const networkNotExcluded = !(exclude || []).map((exc)=>exc.chainId).includes(network.chainId);
|
|
378
|
+
return allowAllTokens && networkNotExcluded;
|
|
379
|
+
});
|
|
380
|
+
const allowedNetworks = [];
|
|
381
|
+
list.forEach((element)=>{
|
|
382
|
+
const newNetwork = networkMap.get(element.chainId);
|
|
383
|
+
if (newNetwork) allowedNetworks.push({
|
|
384
|
+
name: newNetwork.chainName,
|
|
385
|
+
chainId: parseInt(newNetwork.chainIdHex, 16),
|
|
386
|
+
nativeCurrency: newNetwork.nativeCurrency,
|
|
387
|
+
isSupported: true
|
|
388
|
+
});
|
|
389
|
+
});
|
|
390
|
+
return {
|
|
391
|
+
networks: allowedNetworks
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(config, web3Provider) {
|
|
395
|
+
const { networkMap: networkMap } = config;
|
|
396
|
+
return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
397
|
+
try {
|
|
398
|
+
const network = await web3Provider.getNetwork();
|
|
399
|
+
if (Array.from(networkMap.keys()).includes(network.chainId)) {
|
|
400
|
+
const chainIdNetworkInfo = networkMap.get(network.chainId);
|
|
401
|
+
return {
|
|
402
|
+
name: chainIdNetworkInfo.chainName,
|
|
403
|
+
chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
|
|
404
|
+
nativeCurrency: chainIdNetworkInfo.nativeCurrency,
|
|
405
|
+
isSupported: true
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
return {
|
|
409
|
+
chainId: network.chainId,
|
|
410
|
+
name: network.name,
|
|
411
|
+
isSupported: false
|
|
412
|
+
};
|
|
413
|
+
} catch (err) {
|
|
414
|
+
const chainId = await ($a1555a1d2c8d059b$export$c3ba3e93a9fee972)(web3Provider);
|
|
415
|
+
const isSupported = Array.from(networkMap.keys()).includes(chainId);
|
|
416
|
+
return {
|
|
417
|
+
chainId: chainId,
|
|
418
|
+
isSupported: isSupported
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}, {
|
|
422
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_NETWORK_INFO_ERROR
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, web3Provider, chainId) {
|
|
426
|
+
const { networkMap: networkMap } = config;
|
|
427
|
+
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
428
|
+
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
429
|
+
});
|
|
430
|
+
if (!allowedNetworks.networks.some((network)=>network.chainId === chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
431
|
+
// WT-1146 - Refer to the README in this folder for explantion on the switch network flow
|
|
432
|
+
try {
|
|
433
|
+
await $de192de6ef100f9f$var$switchNetworkInWallet(networkMap, web3Provider, chainId);
|
|
434
|
+
} catch (err) {
|
|
435
|
+
if (err.code === $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE) try {
|
|
436
|
+
await $de192de6ef100f9f$var$addNetworkToWallet(networkMap, web3Provider, chainId);
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
438
|
+
} catch (err) {
|
|
439
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
440
|
+
}
|
|
441
|
+
else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
442
|
+
}
|
|
443
|
+
const newProvider = new (Web3Provider)(web3Provider.provider);
|
|
444
|
+
const newProviderNetwork = await newProvider.getNetwork();
|
|
445
|
+
if (newProviderNetwork.chainId !== chainId) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
446
|
+
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(config, newProvider);
|
|
447
|
+
return {
|
|
448
|
+
network: networkInfo,
|
|
449
|
+
provider: newProvider
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
var $cda6003506e4182e$exports = {};
|
|
458
|
+
$cda6003506e4182e$exports = JSON.parse("[{\"chainId\":13383,\"name\":\"IMX\",\"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\"]},{\"chainId\":13383,\"name\":\"FUN token\",\"address\":\"0xFEa9FF93DC0C6DC73F8Be009Fe7a22Bb9dcE8A2d\",\"symbol\":\"FUN\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":13383,\"name\":\"USDC\",\"address\":\"0x5893A5c7bc615Dfd36D7383366d00FFFca5f7178\",\"symbol\":\"USDC\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":13383,\"name\":\"WETH\",\"address\":\"0xD6d9321DCC42377C1fa8cFec665182c463b2392C\",\"symbol\":\"WETH\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":1,\"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\",\"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\"]},{\"chainId\":11155111,\"name\":\"Sep Eth\",\"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\",\"tokenFeatures\":[\"swap\"]},{\"chainId\":11155111,\"name\":\"Immutable Test token\",\"address\":\"0xd1da7e9b2Ce1a4024DaD52b3D37F4c5c91a525C1\",\"symbol\":\"TEST\",\"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\"]},{\"chainId\":11155111,\"name\":\"FUN token\",\"address\":\"0x741185AEFC3E539c1F42c1d6eeE8bFf1c89D70FE\",\"symbol\":\"FUN\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":11155111,\"name\":\"US Dollar Coin\",\"address\":\"0x1836E16b2036088490C2CFe4d11970Fc8e5884C4\",\"symbol\":\"USDC\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":13383,\"name\":\"DEX\",\"address\":\"0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e\",\"symbol\":\"DEX\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":11155111,\"name\":\"DEX\",\"address\":\"0xaC953a0d7B67Fae17c87abf79f09D0f818AC66A2\",\"symbol\":\"DEX\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"chainId\":1442,\"name\":\"WETH\",\"address\":\"0x4F062A3EAeC3730560aB89b5CE5aC0ab2C5517aE\",\"symbol\":\"WETH\",\"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\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x72958b06abdF2701AcE6ceb3cE0B8B1CE11E0851\",\"chainId\":1442,\"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\"]}]");
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
const $efe60cea83bfc4e8$var$filterTokenList = ({ type: type , chainId: chainId , exclude: exclude })=>((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
|
|
462
|
+
const skipChainIdCheck = !chainId;
|
|
463
|
+
const chainIdMatches = token.chainId === chainId;
|
|
464
|
+
const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
|
|
465
|
+
const allowAllTokens = type === ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL;
|
|
466
|
+
const tokenAllowedForType = token.tokenFeatures.includes(type);
|
|
467
|
+
return (skipChainIdCheck || chainIdMatches) && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
|
|
468
|
+
});
|
|
469
|
+
const $efe60cea83bfc4e8$export$473cec51305fdae8 = async ({ type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL , chainId: chainId , exclude: exclude })=>{
|
|
470
|
+
const filteredTokenList = $efe60cea83bfc4e8$var$filterTokenList({
|
|
471
|
+
type: type,
|
|
472
|
+
chainId: chainId,
|
|
473
|
+
exclude: exclude
|
|
474
|
+
}).map((token)=>({
|
|
475
|
+
name: token.name,
|
|
476
|
+
symbol: token.symbol,
|
|
477
|
+
decimals: token.decimals,
|
|
478
|
+
address: token.address,
|
|
479
|
+
icon: token.icon
|
|
480
|
+
}));
|
|
481
|
+
return {
|
|
482
|
+
tokens: filteredTokenList
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
490
|
+
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
|
|
491
|
+
if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
|
|
492
|
+
chainName: networkInfo.name
|
|
493
|
+
});
|
|
494
|
+
const balance = await web3Provider.getBalance(walletAddress);
|
|
495
|
+
return {
|
|
496
|
+
balance: balance,
|
|
497
|
+
formattedBalance: (utils).formatUnits(balance, networkInfo.nativeCurrency.decimals),
|
|
498
|
+
token: networkInfo.nativeCurrency
|
|
499
|
+
};
|
|
500
|
+
}, {
|
|
501
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
|
|
502
|
+
});
|
|
503
|
+
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, contractAddress) {
|
|
504
|
+
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
505
|
+
const contract = new (Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), web3Provider);
|
|
506
|
+
const name = await contract.name();
|
|
507
|
+
const symbol = await contract.symbol();
|
|
508
|
+
const balance = await contract.balanceOf(walletAddress);
|
|
509
|
+
const decimals = await contract.decimals();
|
|
510
|
+
const formattedBalance = (utils).formatUnits(balance, decimals);
|
|
511
|
+
return {
|
|
512
|
+
balance: balance,
|
|
513
|
+
formattedBalance: formattedBalance,
|
|
514
|
+
token: {
|
|
515
|
+
name: name,
|
|
516
|
+
symbol: symbol,
|
|
517
|
+
decimals: decimals,
|
|
518
|
+
address: contractAddress
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
}, {
|
|
522
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, walletAddress, chainId)=>{
|
|
526
|
+
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)({
|
|
527
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
528
|
+
chainId: chainId
|
|
529
|
+
});
|
|
530
|
+
const allBalancePromises = [];
|
|
531
|
+
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, web3Provider, walletAddress));
|
|
532
|
+
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAddress, token.address ?? "")));
|
|
533
|
+
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
534
|
+
const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
535
|
+
return {
|
|
536
|
+
balances: getBalanceResults
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
545
|
+
|
|
546
|
+
async function $c99672cf2294e839$export$2d040992269b4717(web3Provider) {
|
|
547
|
+
if (!web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Check wallet connection request failed", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_FAILED_ERROR, {
|
|
548
|
+
rpcMethod: ($4f91c5f280efe242$export$35b06f0d33f57e26).CHECK_CONNECTION
|
|
549
|
+
});
|
|
550
|
+
let accounts = [];
|
|
551
|
+
try {
|
|
552
|
+
accounts = await web3Provider.provider.request({
|
|
553
|
+
method: (0, $4f91c5f280efe242$export$35b06f0d33f57e26).CHECK_CONNECTION,
|
|
554
|
+
params: []
|
|
555
|
+
});
|
|
556
|
+
} catch (err) {
|
|
557
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Check wallet connection request failed", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_FAILED_ERROR, {
|
|
558
|
+
rpcMethod: ($4f91c5f280efe242$export$35b06f0d33f57e26).CHECK_CONNECTION
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
// accounts[0] will have the active account if connected.
|
|
562
|
+
return {
|
|
563
|
+
isConnected: accounts && accounts.length > 0,
|
|
564
|
+
walletAddress: accounts[0] ?? ""
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
async function $c99672cf2294e839$export$43f7168eb392a88c(web3Provider) {
|
|
568
|
+
await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
569
|
+
if (!web3Provider || !web3Provider?.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
570
|
+
details: "Attempting to connect with an incompatible provider"
|
|
571
|
+
});
|
|
572
|
+
// this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
|
|
573
|
+
await web3Provider.provider.request({
|
|
574
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).CONNECT,
|
|
575
|
+
params: []
|
|
576
|
+
});
|
|
577
|
+
}, {
|
|
578
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR
|
|
579
|
+
});
|
|
580
|
+
return web3Provider;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
587
|
+
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
async function $5c763be0b0b81038$var$getMetaMaskProvider() {
|
|
591
|
+
const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>await ($7v2Z6$metamaskdetectprovider)(), {
|
|
592
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
|
|
593
|
+
});
|
|
594
|
+
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
595
|
+
return new (Web3Provider)(provider);
|
|
596
|
+
}
|
|
597
|
+
async function $5c763be0b0b81038$export$500fbc0cd14cdbaa(defaultProvider) {
|
|
598
|
+
let web3Provider = null;
|
|
599
|
+
switch(defaultProvider){
|
|
600
|
+
case ($e768639828688ca3$export$2d7a51a18d87e21d).METAMASK:
|
|
601
|
+
web3Provider = await $5c763be0b0b81038$var$getMetaMaskProvider();
|
|
602
|
+
break;
|
|
603
|
+
default:
|
|
604
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).DEFAULT_PROVIDER_ERROR);
|
|
605
|
+
}
|
|
606
|
+
return web3Provider;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
// this function needs to be in a separate file to prevent circular dependencies with ./network
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
|
|
615
|
+
|
|
616
|
+
function $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider) {
|
|
617
|
+
if (web3Provider && web3Provider instanceof (Web3Provider) && web3Provider.provider?.request) return true;
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, validateProviderOptions) {
|
|
621
|
+
return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
622
|
+
if (!$bb88265fe45a0393$export$ebe4804963e71f98(web3Provider)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Parsed provider is not a valid Web3Provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
623
|
+
// this sets the default options and overrides them with any parsed options
|
|
624
|
+
const options = {
|
|
625
|
+
...($e768639828688ca3$export$44dde05038008549),
|
|
626
|
+
...validateProviderOptions
|
|
627
|
+
};
|
|
628
|
+
const underlyingChainId = await ($a1555a1d2c8d059b$export$c3ba3e93a9fee972)(web3Provider);
|
|
629
|
+
let web3ChainId = web3Provider.network?.chainId;
|
|
630
|
+
try {
|
|
631
|
+
web3ChainId = web3Provider.network?.chainId;
|
|
632
|
+
if (!web3ChainId) web3ChainId = (await web3Provider.getNetwork()).chainId;
|
|
633
|
+
} catch (err) {
|
|
634
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unable to detect the web3Provider network", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
635
|
+
}
|
|
636
|
+
if (web3ChainId !== underlyingChainId && !options.allowMistmatchedChainId) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Your wallet has changed network, please switch to a supported network", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
637
|
+
const allowedNetworks = await ($de192de6ef100f9f$export$3043f6442a9ef563)(config, {
|
|
638
|
+
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
639
|
+
});
|
|
640
|
+
const isAllowed = allowedNetworks.networks.some((network)=>network.chainId === underlyingChainId);
|
|
641
|
+
if (!isAllowed && !options.allowUnsupportedProvider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Your wallet is connected to an unsupported network, please switch to a supported network", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR);
|
|
642
|
+
return web3Provider;
|
|
643
|
+
}, {
|
|
644
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).WEB3_PROVIDER_ERROR
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
var $6f3c55a615003cbf$exports = {};
|
|
653
|
+
$6f3c55a615003cbf$exports = JSON.parse('[{"providerName":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["desktop"]},{"providerName":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile","desktop"]},{"providerName":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["mobile"]}]');
|
|
654
|
+
|
|
655
|
+
|
|
656
|
+
async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL , exclude: exclude }) {
|
|
657
|
+
// todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
|
|
658
|
+
const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
|
|
659
|
+
const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.providerName).includes(wallet.providerName);
|
|
660
|
+
const allowAllWallets = type === ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL;
|
|
661
|
+
const walletsAllowedForType = wallet.platform.includes(type);
|
|
662
|
+
return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
|
|
663
|
+
}).map((wallet)=>{
|
|
664
|
+
const { platform: platform , ...walletInfo } = wallet;
|
|
665
|
+
return walletInfo;
|
|
666
|
+
});
|
|
667
|
+
return {
|
|
668
|
+
wallets: filteredWalletsList
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (web3Provider, transaction)=>{
|
|
679
|
+
try {
|
|
680
|
+
const transactionResponse = await web3Provider.getSigner().sendTransaction(transaction);
|
|
681
|
+
return {
|
|
682
|
+
transactionResponse: transactionResponse
|
|
683
|
+
};
|
|
684
|
+
} catch (err) {
|
|
685
|
+
if (err.code === (ethers).errors.INSUFFICIENT_FUNDS) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).INSUFFICIENT_FUNDS);
|
|
686
|
+
if (err.code === (ethers).errors.ACTION_REJECTED) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
687
|
+
if (err.code === (ethers).errors.UNPREDICTABLE_GAS_LIMIT) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNPREDICTABLE_GAS_LIMIT);
|
|
688
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).TRANSACTION_FAILED);
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
const $570856c68db0bd36$var$GAS_LIMIT = 140000;
|
|
703
|
+
async function $570856c68db0bd36$var$getTokenInfoByAddress(tokenAddress, chainId) {
|
|
704
|
+
return (await $efe60cea83bfc4e8$export$473cec51305fdae8({
|
|
705
|
+
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL,
|
|
706
|
+
chainId: chainId
|
|
707
|
+
})).tokens.find((token)=>(token.address || "NATIVE") === tokenAddress);
|
|
708
|
+
}
|
|
709
|
+
const $570856c68db0bd36$var$doesChainSupportEIP1559 = (feeData)=>!!feeData.maxFeePerGas && !!feeData.maxPriorityFeePerGas;
|
|
710
|
+
const $570856c68db0bd36$var$getGasPriceInWei = (feeData)=>$570856c68db0bd36$var$doesChainSupportEIP1559(feeData) ? (BigNumber$1).from(feeData.maxFeePerGas).add((BigNumber$1).from(feeData.maxPriorityFeePerGas)) : feeData.gasPrice && (BigNumber$1).from(feeData.gasPrice);
|
|
711
|
+
const $570856c68db0bd36$var$getGasEstimates = async (provider)=>{
|
|
712
|
+
const txnGasLimitInWei = $570856c68db0bd36$var$GAS_LIMIT; // todo: fetch gasLimit from bridgeSDK when they add new fn
|
|
713
|
+
const feeData = await provider.getFeeData();
|
|
714
|
+
const gasPriceInWei = $570856c68db0bd36$var$getGasPriceInWei(feeData);
|
|
715
|
+
if (!gasPriceInWei) return undefined;
|
|
716
|
+
return gasPriceInWei.mul(txnGasLimitInWei);
|
|
717
|
+
};
|
|
718
|
+
async function $570856c68db0bd36$export$51010590edbe56a6(provider, chainId, isApproveTxnRequired, gasTokenAddress) {
|
|
719
|
+
const token = await $570856c68db0bd36$var$getTokenInfoByAddress(gasTokenAddress || "NATIVE", chainId);
|
|
720
|
+
let estimatedAmount = await $570856c68db0bd36$var$getGasEstimates(provider);
|
|
721
|
+
if (!estimatedAmount) return {
|
|
722
|
+
estimatedAmount: undefined,
|
|
723
|
+
token: token
|
|
724
|
+
};
|
|
725
|
+
if (isApproveTxnRequired) estimatedAmount = estimatedAmount.add(estimatedAmount);
|
|
726
|
+
const result = {
|
|
727
|
+
estimatedAmount: estimatedAmount,
|
|
728
|
+
token: token
|
|
729
|
+
};
|
|
730
|
+
return result;
|
|
731
|
+
}
|
|
732
|
+
async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddress, destinationChainId) {
|
|
733
|
+
const bridgeFeeReq = {
|
|
734
|
+
token: tokenAddress
|
|
735
|
+
};
|
|
736
|
+
const bridgeFeeResponse = await tokenBridge.getFee(bridgeFeeReq);
|
|
737
|
+
const tokenInfo = await $570856c68db0bd36$var$getTokenInfoByAddress(tokenAddress, destinationChainId);
|
|
738
|
+
return {
|
|
739
|
+
bridgeFee: {
|
|
740
|
+
estimatedAmount: bridgeFeeResponse.feeAmount,
|
|
741
|
+
token: tokenInfo
|
|
742
|
+
},
|
|
743
|
+
bridgeable: bridgeFeeResponse.bridgeable
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
752
|
+
const $be6f32539b5e2cc9$var$chainId = 13383;
|
|
753
|
+
const $be6f32539b5e2cc9$var$commonRoutingTokens = [
|
|
754
|
+
{
|
|
755
|
+
chainId: $be6f32539b5e2cc9$var$chainId,
|
|
756
|
+
address: "0xFEa9FF93DC0C6DC73F8Be009Fe7a22Bb9dcE8A2d",
|
|
757
|
+
decimals: 18,
|
|
758
|
+
symbol: "FUN",
|
|
759
|
+
name: "The Fungibles Token"
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
chainId: $be6f32539b5e2cc9$var$chainId,
|
|
763
|
+
address: "0x12739A8f1A8035F439092D016DAE19A2874F30d2",
|
|
764
|
+
decimals: 18,
|
|
765
|
+
symbol: "USDC",
|
|
766
|
+
name: "US Dollar Coin"
|
|
767
|
+
},
|
|
768
|
+
{
|
|
769
|
+
chainId: $be6f32539b5e2cc9$var$chainId,
|
|
770
|
+
address: "0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e",
|
|
771
|
+
decimals: 18,
|
|
772
|
+
symbol: "DEX",
|
|
773
|
+
name: "Dex"
|
|
774
|
+
}
|
|
775
|
+
];
|
|
776
|
+
const $be6f32539b5e2cc9$var$contractOverrides = {
|
|
777
|
+
multicall: "0x7b19942581c9462D54155801fCA4a17edf3fD135",
|
|
778
|
+
coreFactory: "0xD17c98b38bA28c7eA1080317EB9AB2b9663BEd92",
|
|
779
|
+
quoterV2: "0x786ec643F231960D4C1A4E336990F8E7bF8f1277",
|
|
780
|
+
peripheryRouter: "0x0d44bB14Cc1dD999255aBB1576b4964D0439C63D",
|
|
781
|
+
migrator: "0x0Afe6F5f4DC34461A801420634239FFaD50A2e44",
|
|
782
|
+
nonfungiblePositionManager: "0xF674847fBcca5C80315e3AE37043Dce99F6CC529",
|
|
783
|
+
tickLens: "0x38034F18D38b74bdE496bdF60CCdBcb25B879e8d"
|
|
784
|
+
};
|
|
785
|
+
const $be6f32539b5e2cc9$export$3e9a43ac784794d5 = ()=>({
|
|
786
|
+
rpcURL: "https://zkevm-rpc.dev.x.immutable.com",
|
|
787
|
+
exchangeContracts: $be6f32539b5e2cc9$var$contractOverrides,
|
|
788
|
+
commonRoutingTokens: $be6f32539b5e2cc9$var$commonRoutingTokens,
|
|
789
|
+
nativeToken: {
|
|
790
|
+
chainId: $be6f32539b5e2cc9$var$chainId,
|
|
791
|
+
address: "",
|
|
792
|
+
decimals: 18,
|
|
793
|
+
symbol: "IMX",
|
|
794
|
+
name: "Immutable X Token"
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, environment) {
|
|
800
|
+
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
801
|
+
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
802
|
+
if (!rootChainProvider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${fromChainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
803
|
+
if (!childChainProvider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${toChainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
804
|
+
const bridgeConfig = new (BridgeConfiguration)({
|
|
805
|
+
baseConfig: new (ImmutableConfiguration)({
|
|
806
|
+
environment: environment
|
|
807
|
+
}),
|
|
808
|
+
bridgeInstance: environment === (Environment).PRODUCTION ? (ETH_MAINNET_TO_ZKEVM_MAINNET) : (ETH_SEPOLIA_TO_ZKEVM_DEVNET),
|
|
809
|
+
rootProvider: rootChainProvider,
|
|
810
|
+
childProvider: childChainProvider
|
|
811
|
+
});
|
|
812
|
+
return new (TokenBridge)(bridgeConfig);
|
|
813
|
+
}
|
|
814
|
+
async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, environment) {
|
|
815
|
+
const exchange = new (Exchange)(new (ExchangeConfiguration)({
|
|
816
|
+
chainId: chainId,
|
|
817
|
+
baseConfig: new (ImmutableConfiguration)({
|
|
818
|
+
environment: environment
|
|
819
|
+
}),
|
|
820
|
+
overrides: ($be6f32539b5e2cc9$export$3e9a43ac784794d5)()
|
|
821
|
+
}));
|
|
822
|
+
return exchange;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
|
|
828
|
+
var $d7b15ec974df6f92$exports = {};
|
|
829
|
+
$d7b15ec974df6f92$exports = JSON.parse('{"11155111":{"bridgeToL2Addresses":{"gasTokenAddress":"NATIVE","fromAddress":"0xd1da7e9b2Ce1a4024DaD52b3D37F4c5c91a525C1"},"swapAddresses":{"inAddress":"0xFEa9FF93DC0C6DC73F8Be009Fe7a22Bb9dcE8A2d","outAddress":"0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e"}}}');
|
|
830
|
+
|
|
831
|
+
|
|
832
|
+
const $2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
833
|
+
const $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS = 18;
|
|
834
|
+
const $2e7bf45a7c9a9570$var$getL1ChainId = (environment)=>{
|
|
835
|
+
if (environment === (Environment).PRODUCTION) return ($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA;
|
|
836
|
+
return ($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA;
|
|
837
|
+
};
|
|
838
|
+
const $2e7bf45a7c9a9570$var$getL2ChainId = (environment)=>{
|
|
839
|
+
if (environment === (Environment).PRODUCTION) return ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET;
|
|
840
|
+
return ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET;
|
|
841
|
+
};
|
|
842
|
+
async function $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, environment, isSpendingCapApprovalRequired, tokenAddress) {
|
|
843
|
+
const fromChainId = $2e7bf45a7c9a9570$var$getL1ChainId(environment);
|
|
844
|
+
const toChainId = $2e7bf45a7c9a9570$var$getL2ChainId(environment);
|
|
845
|
+
const tokenAddresses = environment === (Environment).PRODUCTION ? ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA] : ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA];
|
|
846
|
+
const { gasTokenAddress: gasTokenAddress , fromAddress: fromAddress } = tokenAddresses.bridgeToL2Addresses;
|
|
847
|
+
const provider = readOnlyProviders.get(fromChainId);
|
|
848
|
+
try {
|
|
849
|
+
const { estimatedAmount: estimatedAmount , token: token } = await (0, $570856c68db0bd36$export$51010590edbe56a6)(provider, fromChainId, isSpendingCapApprovalRequired, tokenAddress ?? gasTokenAddress);
|
|
850
|
+
const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, environment);
|
|
851
|
+
const { bridgeFee: bridgeFee , bridgeable: bridgeable } = await (0, $570856c68db0bd36$export$9e73e22953cebcfc)(tokenBridge, fromAddress, toChainId);
|
|
852
|
+
return {
|
|
853
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
854
|
+
gasFee: {
|
|
855
|
+
estimatedAmount: estimatedAmount,
|
|
856
|
+
token: token
|
|
857
|
+
},
|
|
858
|
+
bridgeFee: {
|
|
859
|
+
estimatedAmount: bridgeFee?.estimatedAmount,
|
|
860
|
+
token: bridgeFee?.token
|
|
861
|
+
},
|
|
862
|
+
bridgeable: bridgeable
|
|
863
|
+
};
|
|
864
|
+
} catch {
|
|
865
|
+
// In the case of an error, just return an empty gas & bridge fee estimate
|
|
866
|
+
return {
|
|
867
|
+
gasEstimateType: ($de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
868
|
+
gasFee: {},
|
|
869
|
+
bridgeFee: {},
|
|
870
|
+
bridgeable: false
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
async function $2e7bf45a7c9a9570$var$swapGasEstimator(environment) {
|
|
875
|
+
const tokenAddresses = environment === (Environment).PRODUCTION ? ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA] : ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA];
|
|
876
|
+
const { inAddress: inAddress , outAddress: outAddress } = tokenAddresses.swapAddresses;
|
|
877
|
+
const chainId = $2e7bf45a7c9a9570$var$getL2ChainId(environment);
|
|
878
|
+
try {
|
|
879
|
+
const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, environment);
|
|
880
|
+
// Create a fake transaction to get the gas from the quote
|
|
881
|
+
const { info: info } = await exchange.getUnsignedSwapTxFromAmountIn($2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS, inAddress, outAddress, (0, BigNumber).from((0, utils$1).parseUnits("1", $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS)));
|
|
882
|
+
if (info.gasFeeEstimate === null) return {
|
|
883
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).SWAP,
|
|
884
|
+
gasFee: {}
|
|
885
|
+
};
|
|
886
|
+
let estimatedAmount;
|
|
887
|
+
if (info.gasFeeEstimate.amount) estimatedAmount = (0, BigNumber).from(info.gasFeeEstimate.amount);
|
|
888
|
+
return {
|
|
889
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).SWAP,
|
|
890
|
+
gasFee: {
|
|
891
|
+
estimatedAmount: estimatedAmount,
|
|
892
|
+
token: {
|
|
893
|
+
address: info.gasFeeEstimate?.token.address,
|
|
894
|
+
symbol: info.gasFeeEstimate?.token.symbol ?? "",
|
|
895
|
+
name: info.gasFeeEstimate?.token.name ?? "",
|
|
896
|
+
decimals: info.gasFeeEstimate?.token.decimals ?? $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
} catch {
|
|
901
|
+
// In the case of an error, just return an empty gas fee estimate
|
|
902
|
+
return {
|
|
903
|
+
gasEstimateType: ($de275b98d2b651c3$export$788b1fd17f3dad84).SWAP,
|
|
904
|
+
gasFee: {}
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProviders, environment) {
|
|
909
|
+
switch(params.gasEstimateType){
|
|
910
|
+
case ($de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2:
|
|
911
|
+
return await $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, environment, params.isSpendingCapApprovalRequired, params.tokenAddress);
|
|
912
|
+
case ($de275b98d2b651c3$export$788b1fd17f3dad84).SWAP:
|
|
913
|
+
return await $2e7bf45a7c9a9570$var$swapGasEstimator(environment);
|
|
914
|
+
default:
|
|
915
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Invalid type provided for gasEstimateType", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).INVALID_GAS_ESTIMATE_TYPE);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
class $4013c5c91bb535f6$export$47a4ed4a38b9eecf extends Error {
|
|
927
|
+
message;
|
|
928
|
+
constructor(message){
|
|
929
|
+
super(message);
|
|
930
|
+
this.message = message;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
934
|
+
environment;
|
|
935
|
+
networkMap;
|
|
936
|
+
constructor(config){
|
|
937
|
+
// validate input
|
|
938
|
+
if (!Object.values((Environment)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$47a4ed4a38b9eecf("Invalid checkout configuration of environment");
|
|
939
|
+
this.environment = config.baseConfig.environment;
|
|
940
|
+
this.networkMap = config.baseConfig.environment === (Environment).PRODUCTION ? ($a47e48dd2c04791b$export$6f24f3cef7d501c4) : ($a47e48dd2c04791b$export$3e81fc0987227f10);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
952
|
+
if (config.environment === (Environment).PRODUCTION && existingReadOnlyProviders?.has(($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM) || config.environment === (Environment).SANDBOX && existingReadOnlyProviders?.has(($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
953
|
+
const readOnlyProviders = new Map();
|
|
954
|
+
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
955
|
+
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
956
|
+
});
|
|
957
|
+
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
958
|
+
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
959
|
+
const provider = new (ethers).providers.JsonRpcProvider(rpcUrl);
|
|
960
|
+
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
961
|
+
});
|
|
962
|
+
return readOnlyProviders;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
967
|
+
config;
|
|
968
|
+
readOnlyProviders;
|
|
969
|
+
constructor(config = ($bc2bfebf768286d3$export$6a2ba3c3bd042990)){
|
|
970
|
+
this.config = new ($4013c5c91bb535f6$export$4823433c4a67bbc6)(config);
|
|
971
|
+
this.readOnlyProviders = new Map();
|
|
972
|
+
}
|
|
973
|
+
/**
|
|
974
|
+
* Create a provider object which can be used within the Checkout class methods.
|
|
975
|
+
* @param {CreateProviderParams} params The data required to create a provider
|
|
976
|
+
* @returns A new provider object
|
|
977
|
+
* @throws {@link ErrorType}
|
|
978
|
+
*/ async createProvider(params) {
|
|
979
|
+
const web3Provider = await $5c763be0b0b81038$export$500fbc0cd14cdbaa(params.walletProvider);
|
|
980
|
+
return {
|
|
981
|
+
provider: web3Provider
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Check if a wallet is connected to the current application
|
|
986
|
+
* without requesting permission from the wallet and hence triggering a connect popup.
|
|
987
|
+
* @param {CheckConnectionParams} params - The necessary data required to verify a wallet connection status.
|
|
988
|
+
* @returns Wallet connection status details.
|
|
989
|
+
* @throws {@link ErrorType}
|
|
990
|
+
*/ async checkIsWalletConnected(params) {
|
|
991
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider, {
|
|
992
|
+
allowUnsupportedProvider: true
|
|
993
|
+
});
|
|
994
|
+
return $c99672cf2294e839$export$2d040992269b4717(web3Provider);
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Establish a connection with a wallet provider such as MetaMask and returns the provider object and the current network details.
|
|
998
|
+
* @param {ConnectParams} params - The necessary data required to establish a connection with a wallet provider.
|
|
999
|
+
* @returns Wallet provider and current network information.
|
|
1000
|
+
* @throws {@link ErrorType}
|
|
1001
|
+
*/ async connect(params) {
|
|
1002
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider, {
|
|
1003
|
+
allowUnsupportedProvider: true
|
|
1004
|
+
});
|
|
1005
|
+
await $c99672cf2294e839$export$43f7168eb392a88c(web3Provider);
|
|
1006
|
+
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, web3Provider);
|
|
1007
|
+
return {
|
|
1008
|
+
provider: web3Provider,
|
|
1009
|
+
network: networkInfo
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Switch the currently connected wallet to a new network.
|
|
1014
|
+
* @param {SwitchNetworkParams} params - The necessary data required to switch network.
|
|
1015
|
+
* @returns The new network information.
|
|
1016
|
+
* @throws {@link ErrorType}
|
|
1017
|
+
*/ async switchNetwork(params) {
|
|
1018
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider, {
|
|
1019
|
+
allowUnsupportedProvider: true,
|
|
1020
|
+
allowMistmatchedChainId: true
|
|
1021
|
+
});
|
|
1022
|
+
const switchNetworkRes = await $de192de6ef100f9f$export$b827d9418aeb5dbd(this.config, web3Provider, params.chainId);
|
|
1023
|
+
return switchNetworkRes;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Fetch the balance of the native token of the current connected network or,
|
|
1027
|
+
* if a contract address is provided, it will return the balance of that ERC20 token. For example,
|
|
1028
|
+
* if the wallet is connected to the Ethereum Mainnet then the function gets the wallet ETH L1 balance.
|
|
1029
|
+
* @param {GetBalanceParams} params - The necessary data required to fetch the wallet balance.
|
|
1030
|
+
* @returns Native token balance for the given wallet.
|
|
1031
|
+
* @throws {@link ErrorType}
|
|
1032
|
+
*/ async getBalance(params) {
|
|
1033
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
1034
|
+
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(this.config, web3Provider, params.walletAddress);
|
|
1035
|
+
return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, params.walletAddress, params.contractAddress);
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Fetch all available balances (ERC20 & Native) of the current connected network of the given wallet.
|
|
1039
|
+
* It will loop through the list of allowed tokens and check for balance on each one.
|
|
1040
|
+
* @param {GetAllBalancesParams} params - The necessary data required to fetch all the wallet balances.
|
|
1041
|
+
* @returns List of tokens balance for the given wallet.
|
|
1042
|
+
* @throws {@link ErrorType}
|
|
1043
|
+
*/ async getAllBalances(params) {
|
|
1044
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
1045
|
+
return $1564e43dde50bb61$export$fee49741664a4d7e(this.config, web3Provider, params.walletAddress, params.chainId);
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Fetch the list of available networks that a wallet can add or/and switch to.
|
|
1049
|
+
* @param {GetNetworkAllowListParams} params - The necessary data required to fetch the list of available networks.
|
|
1050
|
+
* @returns List of networks.
|
|
1051
|
+
* @throws {@link ErrorType}
|
|
1052
|
+
*/ async getNetworkAllowList(params) {
|
|
1053
|
+
return await $de192de6ef100f9f$export$3043f6442a9ef563(this.config, params);
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Get the list of tokens which are allowed to be used with the product.
|
|
1057
|
+
* @param {GetTokenAllowListParams} params - The necessary data required to fetch the list of allowed tokens.
|
|
1058
|
+
* @returns List of allowed tokens.
|
|
1059
|
+
* @throws {@link ErrorType}
|
|
1060
|
+
*/ async getTokenAllowList(params) {
|
|
1061
|
+
return await $efe60cea83bfc4e8$export$473cec51305fdae8(params);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Fetch the list of wallets which are available to connect with.
|
|
1065
|
+
* @param {GetWalletAllowListParams} params - The necessary data required to fetch the list of allowed wallets.
|
|
1066
|
+
* @returns List of allowed wallets.
|
|
1067
|
+
* @throws {@link ErrorType}
|
|
1068
|
+
*/ async getWalletAllowList(params) {
|
|
1069
|
+
return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Send a generic transaction to the provider.
|
|
1073
|
+
* @param {SendTransactionParams} params - The necessary data required to send a transaction.
|
|
1074
|
+
* @returns Transaction response.
|
|
1075
|
+
* @throws {@link ErrorType}
|
|
1076
|
+
* @remarks
|
|
1077
|
+
* Further documenation can be found at [MetaMask | Sending Transactions](https://docs.metamask.io/guide/sending-transactions.html).
|
|
1078
|
+
*/ async sendTransaction(params) {
|
|
1079
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
1080
|
+
return await $dbe95599a4661140$export$8e0e7ffc78696d30(web3Provider, params.transaction);
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Get network information about the currently selected network.
|
|
1084
|
+
* @param {GetNetworkParams} params - The necessary data required to get the current network information.
|
|
1085
|
+
* @returns Network details.
|
|
1086
|
+
* @throws {@link ErrorType}
|
|
1087
|
+
*/ async getNetworkInfo(params) {
|
|
1088
|
+
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider, {
|
|
1089
|
+
allowUnsupportedProvider: true,
|
|
1090
|
+
allowMistmatchedChainId: true
|
|
1091
|
+
});
|
|
1092
|
+
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, web3Provider);
|
|
1093
|
+
}
|
|
1094
|
+
static isWeb3Provider(web3Provider) {
|
|
1095
|
+
return $bb88265fe45a0393$export$ebe4804963e71f98(web3Provider);
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Estimates the gas to perform an action.
|
|
1099
|
+
* @param {GasEstimateParams} params - The params required to calculate a gas estimate
|
|
1100
|
+
* @returns The gas estimate for the given action.
|
|
1101
|
+
*/ async gasEstimate(params) {
|
|
1102
|
+
this.readOnlyProviders = await ($0e0060cb42e136d2$export$339cb2be73677b30)(this.config, this.readOnlyProviders);
|
|
1103
|
+
return await $2e7bf45a7c9a9570$export$942c8de7174809fc(params, this.readOnlyProviders, this.config.environment);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
export { $baec09ddc3013323$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $a47e48dd2c04791b$export$345c852d0dc8f1df as RPC_URL_MAP, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
|