@imtbl/sdk 0.1.6-alpha → 0.1.7-alpha.1
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/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +61 -61
- package/dist/checkout_sdk.js +272 -164
- package/dist/checkout_widgets.d.ts +1011 -879
- package/dist/checkout_widgets.js +46 -45
- package/dist/immutablex_client.js +2 -2
- package/dist/index.cjs +2256 -319
- package/dist/index.d.ts +1666 -346
- package/dist/index.js +2256 -322
- package/dist/orderbook.d.ts +57 -0
- package/dist/orderbook.js +1833 -0
- package/dist/passport.d.ts +1154 -1
- package/dist/passport.js +18 -13
- package/dist/provider.d.ts +0 -1
- package/dist/provider.js +80 -76
- package/package.json +15 -2
package/dist/index.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { ImmutableX, Config, generateLegacyStarkPrivateKey, createStarkSigner, TransfersApi, OrdersApi, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi } from '@imtbl/core-sdk';
|
|
2
2
|
export { createStarkSigner as imxClientCreateStarkSigner, generateLegacyStarkPrivateKey as imxClientGenerateLegacyStarkPrivateKey } from '@imtbl/core-sdk';
|
|
3
|
+
import * as guardian from '@imtbl/guardian';
|
|
4
|
+
export { guardian };
|
|
3
5
|
import { UserManager } from 'oidc-client-ts';
|
|
4
|
-
import { ethers, utils, Contract } from 'ethers';
|
|
6
|
+
import { ethers, utils, Contract, BigNumber, constants } from 'ethers';
|
|
5
7
|
import { Magic } from 'magic-sdk';
|
|
6
8
|
import { OpenIdExtension } from '@magic-ext/oidc';
|
|
7
9
|
import BN from 'bn.js';
|
|
8
10
|
import * as encUtils from 'enc-utils';
|
|
11
|
+
import { ItemType, SEAPORT_CONTRACT_NAME, SEAPORT_CONTRACT_VERSION_V1_4, EIP_712_ORDER_TYPE, OrderType } from '@opensea/seaport-js/lib/constants';
|
|
12
|
+
import FormData from 'form-data';
|
|
13
|
+
import fetch, { Headers } from 'node-fetch';
|
|
14
|
+
import { Seaport as Seaport$1 } from '@opensea/seaport-js';
|
|
9
15
|
import { parseUnits } from '@ethersproject/units';
|
|
10
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
16
|
+
import { BigNumber as BigNumber$1 } from '@ethersproject/bignumber';
|
|
11
17
|
import detectEthereumProvider from '@metamask/detect-provider';
|
|
12
18
|
import { Web3Provider } from '@ethersproject/providers';
|
|
13
19
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -35,7 +41,7 @@ const production = () => Config.createConfig({
|
|
|
35
41
|
chainID: 1,
|
|
36
42
|
coreContractAddress: '0x5FDCCA53617f4d2b9134B29090C87D01058e27e9',
|
|
37
43
|
registrationContractAddress: '0x72a06bf2a1CE5e39cBA06c0CAb824960B587d64c',
|
|
38
|
-
sdkVersion: 'ts-immutable-sdk-0.1.
|
|
44
|
+
sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.1',
|
|
39
45
|
});
|
|
40
46
|
/**
|
|
41
47
|
* Set `sdkVersion` on config
|
|
@@ -45,7 +51,7 @@ const sandbox = () => Config.createConfig({
|
|
|
45
51
|
chainID: 5,
|
|
46
52
|
coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
|
|
47
53
|
registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
|
|
48
|
-
sdkVersion: 'ts-immutable-sdk-0.1.
|
|
54
|
+
sdkVersion: 'ts-immutable-sdk-0.1.7-alpha.1',
|
|
49
55
|
});
|
|
50
56
|
class ImxConfiguration {
|
|
51
57
|
immutableXConfig;
|
|
@@ -534,24 +540,25 @@ class ImmutableXClient {
|
|
|
534
540
|
function serializeEthSignature(sig) {
|
|
535
541
|
// This is because golang appends a recovery param
|
|
536
542
|
// https://github.com/ethers-io/ethers.js/issues/823
|
|
537
|
-
return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
|
|
538
|
-
encUtils.padLeft(sig.s.toString(16), 64)
|
|
539
|
-
encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
|
|
543
|
+
return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
|
|
544
|
+
+ encUtils.padLeft(sig.s.toString(16), 64)
|
|
545
|
+
+ encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
|
|
540
546
|
}
|
|
541
547
|
function importRecoveryParam(v) {
|
|
548
|
+
const isValidBigNumber = new BN(v, 16).cmp(new BN(27)) !== -1
|
|
549
|
+
? new BN(v, 16).sub(new BN(27)).toNumber()
|
|
550
|
+
: new BN(v, 16).toNumber();
|
|
542
551
|
return v.trim()
|
|
543
|
-
?
|
|
544
|
-
? new BN(v, 16).sub(new BN(27)).toNumber()
|
|
545
|
-
: new BN(v, 16).toNumber()
|
|
552
|
+
? isValidBigNumber
|
|
546
553
|
: undefined;
|
|
547
554
|
}
|
|
548
555
|
// used chained with serializeEthSignature. serializeEthSignature(deserializeSignature(...))
|
|
549
556
|
function deserializeSignature(sig, size = 64) {
|
|
550
|
-
|
|
557
|
+
const removedHexPrefixSig = encUtils.removeHexPrefix(sig);
|
|
551
558
|
return {
|
|
552
|
-
r: new BN(
|
|
553
|
-
s: new BN(
|
|
554
|
-
recoveryParam: importRecoveryParam(
|
|
559
|
+
r: new BN(removedHexPrefixSig.substring(0, size), 'hex'),
|
|
560
|
+
s: new BN(removedHexPrefixSig.substring(size, size * 2), 'hex'),
|
|
561
|
+
recoveryParam: importRecoveryParam(removedHexPrefixSig.substring(size * 2, size * 2 + 2)),
|
|
555
562
|
};
|
|
556
563
|
}
|
|
557
564
|
async function signRaw(payload, signer) {
|
|
@@ -591,6 +598,7 @@ function convertToSignableToken(token) {
|
|
|
591
598
|
},
|
|
592
599
|
};
|
|
593
600
|
case 'ETH':
|
|
601
|
+
default:
|
|
594
602
|
return {
|
|
595
603
|
type: 'ETH',
|
|
596
604
|
data: {
|
|
@@ -1004,12 +1012,12 @@ async function batchNftTransfer({ user, starkSigner, request, transfersApi, pass
|
|
|
1004
1012
|
}, PassportErrorType.TRANSFER_ERROR);
|
|
1005
1013
|
}
|
|
1006
1014
|
|
|
1007
|
-
const ERC721 = 'ERC721';
|
|
1015
|
+
const ERC721$2 = 'ERC721';
|
|
1008
1016
|
async function createOrder$1({ starkSigner, user, request, ordersApi, passportConfig, }) {
|
|
1009
1017
|
return withPassportError(async () => {
|
|
1010
1018
|
const ethAddress = user.etherKey;
|
|
1011
|
-
const amountSell = request.sell.type === ERC721 ? '1' : request.sell.amount;
|
|
1012
|
-
const amountBuy = request.buy.type === ERC721 ? '1' : request.buy.amount;
|
|
1019
|
+
const amountSell = request.sell.type === ERC721$2 ? '1' : request.sell.amount;
|
|
1020
|
+
const amountBuy = request.buy.type === ERC721$2 ? '1' : request.buy.amount;
|
|
1013
1021
|
const getSignableOrderRequestV3 = {
|
|
1014
1022
|
user: ethAddress,
|
|
1015
1023
|
amount_buy: amountBuy,
|
|
@@ -1285,7 +1293,7 @@ class PassportImxProvider {
|
|
|
1285
1293
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
1286
1294
|
}
|
|
1287
1295
|
getAddress() {
|
|
1288
|
-
return Promise.resolve(this.
|
|
1296
|
+
return Promise.resolve(this.user.etherKey);
|
|
1289
1297
|
}
|
|
1290
1298
|
}
|
|
1291
1299
|
|
|
@@ -1395,6 +1403,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
|
|
|
1395
1403
|
}
|
|
1396
1404
|
|
|
1397
1405
|
// TODO: Remove this once the dependency has been added
|
|
1406
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
1398
1407
|
class Passport {
|
|
1399
1408
|
authManager;
|
|
1400
1409
|
magicAdapter;
|
|
@@ -1438,51 +1447,1878 @@ class Passport {
|
|
|
1438
1447
|
if (!user) {
|
|
1439
1448
|
return null;
|
|
1440
1449
|
}
|
|
1441
|
-
return this.getImxProvider(user);
|
|
1442
|
-
}
|
|
1443
|
-
async connectImx() {
|
|
1444
|
-
const user = await this.authManager.login();
|
|
1445
|
-
return this.getImxProvider(user);
|
|
1446
|
-
}
|
|
1447
|
-
async loginCallback() {
|
|
1448
|
-
return this.authManager.loginCallback();
|
|
1450
|
+
return this.getImxProvider(user);
|
|
1451
|
+
}
|
|
1452
|
+
async connectImx() {
|
|
1453
|
+
const user = await this.authManager.login();
|
|
1454
|
+
return this.getImxProvider(user);
|
|
1455
|
+
}
|
|
1456
|
+
async loginCallback() {
|
|
1457
|
+
return this.authManager.loginCallback();
|
|
1458
|
+
}
|
|
1459
|
+
async logout() {
|
|
1460
|
+
return this.authManager.logout();
|
|
1461
|
+
}
|
|
1462
|
+
async getUserInfo() {
|
|
1463
|
+
const user = await this.authManager.getUser();
|
|
1464
|
+
return user?.profile;
|
|
1465
|
+
}
|
|
1466
|
+
async getIdToken() {
|
|
1467
|
+
const user = await this.authManager.getUser();
|
|
1468
|
+
return user?.idToken;
|
|
1469
|
+
}
|
|
1470
|
+
async getAccessToken() {
|
|
1471
|
+
const user = await this.authManager.getUser();
|
|
1472
|
+
return user?.accessToken;
|
|
1473
|
+
}
|
|
1474
|
+
async registerUser(userAdminKeySigner, starkSigner, jwt) {
|
|
1475
|
+
await registerPassport({
|
|
1476
|
+
ethSigner: userAdminKeySigner,
|
|
1477
|
+
starkSigner,
|
|
1478
|
+
usersApi: this.immutableXClient.usersApi,
|
|
1479
|
+
}, jwt);
|
|
1480
|
+
const updatedUser = await this.authManager.requestRefreshTokenAfterRegistration();
|
|
1481
|
+
if (!updatedUser) {
|
|
1482
|
+
throw new PassportError('Failed to get refresh token', PassportErrorType.REFRESH_TOKEN_ERROR);
|
|
1483
|
+
}
|
|
1484
|
+
return updatedUser;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
class BaseHttpRequest {
|
|
1489
|
+
config;
|
|
1490
|
+
constructor(config) {
|
|
1491
|
+
this.config = config;
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
class ApiError extends Error {
|
|
1496
|
+
url;
|
|
1497
|
+
status;
|
|
1498
|
+
statusText;
|
|
1499
|
+
body;
|
|
1500
|
+
request;
|
|
1501
|
+
constructor(request, response, message) {
|
|
1502
|
+
super(message);
|
|
1503
|
+
this.name = 'ApiError';
|
|
1504
|
+
this.url = response.url;
|
|
1505
|
+
this.status = response.status;
|
|
1506
|
+
this.statusText = response.statusText;
|
|
1507
|
+
this.body = response.body;
|
|
1508
|
+
this.request = request;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
|
|
1512
|
+
/* istanbul ignore file */
|
|
1513
|
+
/* tslint:disable */
|
|
1514
|
+
/* eslint-disable */
|
|
1515
|
+
class CancelError extends Error {
|
|
1516
|
+
constructor(message) {
|
|
1517
|
+
super(message);
|
|
1518
|
+
this.name = 'CancelError';
|
|
1519
|
+
}
|
|
1520
|
+
get isCancelled() {
|
|
1521
|
+
return true;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
class CancelablePromise {
|
|
1525
|
+
[Symbol.toStringTag];
|
|
1526
|
+
_isResolved;
|
|
1527
|
+
_isRejected;
|
|
1528
|
+
_isCancelled;
|
|
1529
|
+
_cancelHandlers;
|
|
1530
|
+
_promise;
|
|
1531
|
+
_resolve;
|
|
1532
|
+
_reject;
|
|
1533
|
+
constructor(executor) {
|
|
1534
|
+
this._isResolved = false;
|
|
1535
|
+
this._isRejected = false;
|
|
1536
|
+
this._isCancelled = false;
|
|
1537
|
+
this._cancelHandlers = [];
|
|
1538
|
+
this._promise = new Promise((resolve, reject) => {
|
|
1539
|
+
this._resolve = resolve;
|
|
1540
|
+
this._reject = reject;
|
|
1541
|
+
const onResolve = (value) => {
|
|
1542
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
this._isResolved = true;
|
|
1546
|
+
this._resolve?.(value);
|
|
1547
|
+
};
|
|
1548
|
+
const onReject = (reason) => {
|
|
1549
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
this._isRejected = true;
|
|
1553
|
+
this._reject?.(reason);
|
|
1554
|
+
};
|
|
1555
|
+
const onCancel = (cancelHandler) => {
|
|
1556
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
this._cancelHandlers.push(cancelHandler);
|
|
1560
|
+
};
|
|
1561
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
1562
|
+
get: () => this._isResolved,
|
|
1563
|
+
});
|
|
1564
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
1565
|
+
get: () => this._isRejected,
|
|
1566
|
+
});
|
|
1567
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
1568
|
+
get: () => this._isCancelled,
|
|
1569
|
+
});
|
|
1570
|
+
return executor(onResolve, onReject, onCancel);
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
then(onFulfilled, onRejected) {
|
|
1574
|
+
return this._promise.then(onFulfilled, onRejected);
|
|
1575
|
+
}
|
|
1576
|
+
catch(onRejected) {
|
|
1577
|
+
return this._promise.catch(onRejected);
|
|
1578
|
+
}
|
|
1579
|
+
finally(onFinally) {
|
|
1580
|
+
return this._promise.finally(onFinally);
|
|
1581
|
+
}
|
|
1582
|
+
cancel() {
|
|
1583
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
this._isCancelled = true;
|
|
1587
|
+
if (this._cancelHandlers.length) {
|
|
1588
|
+
try {
|
|
1589
|
+
for (const cancelHandler of this._cancelHandlers) {
|
|
1590
|
+
cancelHandler();
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
catch (error) {
|
|
1594
|
+
console.warn('Cancellation threw an error', error);
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
this._cancelHandlers.length = 0;
|
|
1599
|
+
this._reject?.(new CancelError('Request aborted'));
|
|
1600
|
+
}
|
|
1601
|
+
get isCancelled() {
|
|
1602
|
+
return this._isCancelled;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
/* istanbul ignore file */
|
|
1607
|
+
/* tslint:disable */
|
|
1608
|
+
/* eslint-disable */
|
|
1609
|
+
const isDefined = (value) => {
|
|
1610
|
+
return value !== undefined && value !== null;
|
|
1611
|
+
};
|
|
1612
|
+
const isString = (value) => {
|
|
1613
|
+
return typeof value === 'string';
|
|
1614
|
+
};
|
|
1615
|
+
const isStringWithValue = (value) => {
|
|
1616
|
+
return isString(value) && value !== '';
|
|
1617
|
+
};
|
|
1618
|
+
const isBlob = (value) => {
|
|
1619
|
+
return (typeof value === 'object' &&
|
|
1620
|
+
typeof value.type === 'string' &&
|
|
1621
|
+
typeof value.stream === 'function' &&
|
|
1622
|
+
typeof value.arrayBuffer === 'function' &&
|
|
1623
|
+
typeof value.constructor === 'function' &&
|
|
1624
|
+
typeof value.constructor.name === 'string' &&
|
|
1625
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
1626
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag]));
|
|
1627
|
+
};
|
|
1628
|
+
const isFormData = (value) => {
|
|
1629
|
+
return value instanceof FormData;
|
|
1630
|
+
};
|
|
1631
|
+
const base64 = (str) => {
|
|
1632
|
+
try {
|
|
1633
|
+
return btoa(str);
|
|
1634
|
+
}
|
|
1635
|
+
catch (err) {
|
|
1636
|
+
// @ts-ignore
|
|
1637
|
+
return Buffer.from(str).toString('base64');
|
|
1638
|
+
}
|
|
1639
|
+
};
|
|
1640
|
+
const getQueryString = (params) => {
|
|
1641
|
+
const qs = [];
|
|
1642
|
+
const append = (key, value) => {
|
|
1643
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
1644
|
+
};
|
|
1645
|
+
const process = (key, value) => {
|
|
1646
|
+
if (isDefined(value)) {
|
|
1647
|
+
if (Array.isArray(value)) {
|
|
1648
|
+
value.forEach(v => {
|
|
1649
|
+
process(key, v);
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
else if (typeof value === 'object') {
|
|
1653
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
1654
|
+
process(`${key}[${k}]`, v);
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
else {
|
|
1658
|
+
append(key, value);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
};
|
|
1662
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
1663
|
+
process(key, value);
|
|
1664
|
+
});
|
|
1665
|
+
if (qs.length > 0) {
|
|
1666
|
+
return `?${qs.join('&')}`;
|
|
1667
|
+
}
|
|
1668
|
+
return '';
|
|
1669
|
+
};
|
|
1670
|
+
const getUrl = (config, options) => {
|
|
1671
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
1672
|
+
const path = options.url
|
|
1673
|
+
.replace('{api-version}', config.VERSION)
|
|
1674
|
+
.replace(/{(.*?)}/g, (substring, group) => {
|
|
1675
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
1676
|
+
return encoder(String(options.path[group]));
|
|
1677
|
+
}
|
|
1678
|
+
return substring;
|
|
1679
|
+
});
|
|
1680
|
+
const url = `${config.BASE}${path}`;
|
|
1681
|
+
if (options.query) {
|
|
1682
|
+
return `${url}${getQueryString(options.query)}`;
|
|
1683
|
+
}
|
|
1684
|
+
return url;
|
|
1685
|
+
};
|
|
1686
|
+
const getFormData = (options) => {
|
|
1687
|
+
if (options.formData) {
|
|
1688
|
+
const formData = new FormData();
|
|
1689
|
+
const process = (key, value) => {
|
|
1690
|
+
if (isString(value) || isBlob(value)) {
|
|
1691
|
+
formData.append(key, value);
|
|
1692
|
+
}
|
|
1693
|
+
else {
|
|
1694
|
+
formData.append(key, JSON.stringify(value));
|
|
1695
|
+
}
|
|
1696
|
+
};
|
|
1697
|
+
Object.entries(options.formData)
|
|
1698
|
+
.filter(([_, value]) => isDefined(value))
|
|
1699
|
+
.forEach(([key, value]) => {
|
|
1700
|
+
if (Array.isArray(value)) {
|
|
1701
|
+
value.forEach(v => process(key, v));
|
|
1702
|
+
}
|
|
1703
|
+
else {
|
|
1704
|
+
process(key, value);
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
return formData;
|
|
1708
|
+
}
|
|
1709
|
+
return undefined;
|
|
1710
|
+
};
|
|
1711
|
+
const resolve = async (options, resolver) => {
|
|
1712
|
+
if (typeof resolver === 'function') {
|
|
1713
|
+
return resolver(options);
|
|
1714
|
+
}
|
|
1715
|
+
return resolver;
|
|
1716
|
+
};
|
|
1717
|
+
const getHeaders = async (config, options) => {
|
|
1718
|
+
const token = await resolve(options, config.TOKEN);
|
|
1719
|
+
const username = await resolve(options, config.USERNAME);
|
|
1720
|
+
const password = await resolve(options, config.PASSWORD);
|
|
1721
|
+
const additionalHeaders = await resolve(options, config.HEADERS);
|
|
1722
|
+
const headers = Object.entries({
|
|
1723
|
+
Accept: 'application/json',
|
|
1724
|
+
...additionalHeaders,
|
|
1725
|
+
...options.headers,
|
|
1726
|
+
})
|
|
1727
|
+
.filter(([_, value]) => isDefined(value))
|
|
1728
|
+
.reduce((headers, [key, value]) => ({
|
|
1729
|
+
...headers,
|
|
1730
|
+
[key]: String(value),
|
|
1731
|
+
}), {});
|
|
1732
|
+
if (isStringWithValue(token)) {
|
|
1733
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
1734
|
+
}
|
|
1735
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
1736
|
+
const credentials = base64(`${username}:${password}`);
|
|
1737
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
1738
|
+
}
|
|
1739
|
+
if (options.body) {
|
|
1740
|
+
if (options.mediaType) {
|
|
1741
|
+
headers['Content-Type'] = options.mediaType;
|
|
1742
|
+
}
|
|
1743
|
+
else if (isBlob(options.body)) {
|
|
1744
|
+
headers['Content-Type'] = 'application/octet-stream';
|
|
1745
|
+
}
|
|
1746
|
+
else if (isString(options.body)) {
|
|
1747
|
+
headers['Content-Type'] = 'text/plain';
|
|
1748
|
+
}
|
|
1749
|
+
else if (!isFormData(options.body)) {
|
|
1750
|
+
headers['Content-Type'] = 'application/json';
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
return new Headers(headers);
|
|
1754
|
+
};
|
|
1755
|
+
const getRequestBody = (options) => {
|
|
1756
|
+
if (options.body) {
|
|
1757
|
+
if (options.mediaType?.includes('/json')) {
|
|
1758
|
+
return JSON.stringify(options.body);
|
|
1759
|
+
}
|
|
1760
|
+
else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
1761
|
+
return options.body;
|
|
1762
|
+
}
|
|
1763
|
+
else {
|
|
1764
|
+
return JSON.stringify(options.body);
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
return undefined;
|
|
1768
|
+
};
|
|
1769
|
+
const sendRequest = async (options, url, body, formData, headers, onCancel) => {
|
|
1770
|
+
const controller = new AbortController();
|
|
1771
|
+
const request = {
|
|
1772
|
+
headers,
|
|
1773
|
+
method: options.method,
|
|
1774
|
+
body: body ?? formData,
|
|
1775
|
+
signal: controller.signal,
|
|
1776
|
+
};
|
|
1777
|
+
onCancel(() => controller.abort());
|
|
1778
|
+
return await fetch(url, request);
|
|
1779
|
+
};
|
|
1780
|
+
const getResponseHeader = (response, responseHeader) => {
|
|
1781
|
+
if (responseHeader) {
|
|
1782
|
+
const content = response.headers.get(responseHeader);
|
|
1783
|
+
if (isString(content)) {
|
|
1784
|
+
return content;
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
return undefined;
|
|
1788
|
+
};
|
|
1789
|
+
const getResponseBody = async (response) => {
|
|
1790
|
+
if (response.status !== 204) {
|
|
1791
|
+
try {
|
|
1792
|
+
const contentType = response.headers.get('Content-Type');
|
|
1793
|
+
if (contentType) {
|
|
1794
|
+
const isJSON = contentType.toLowerCase().startsWith('application/json');
|
|
1795
|
+
if (isJSON) {
|
|
1796
|
+
return await response.json();
|
|
1797
|
+
}
|
|
1798
|
+
else {
|
|
1799
|
+
return await response.text();
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
catch (error) {
|
|
1804
|
+
console.error(error);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
return undefined;
|
|
1808
|
+
};
|
|
1809
|
+
const catchErrorCodes = (options, result) => {
|
|
1810
|
+
const errors = {
|
|
1811
|
+
400: 'Bad Request',
|
|
1812
|
+
401: 'Unauthorized',
|
|
1813
|
+
403: 'Forbidden',
|
|
1814
|
+
404: 'Not Found',
|
|
1815
|
+
500: 'Internal Server Error',
|
|
1816
|
+
502: 'Bad Gateway',
|
|
1817
|
+
503: 'Service Unavailable',
|
|
1818
|
+
...options.errors,
|
|
1819
|
+
};
|
|
1820
|
+
const error = errors[result.status];
|
|
1821
|
+
if (error) {
|
|
1822
|
+
throw new ApiError(options, result, error);
|
|
1823
|
+
}
|
|
1824
|
+
if (!result.ok) {
|
|
1825
|
+
throw new ApiError(options, result, 'Generic Error');
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
/**
|
|
1829
|
+
* Request method
|
|
1830
|
+
* @param config The OpenAPI configuration object
|
|
1831
|
+
* @param options The request options from the service
|
|
1832
|
+
* @returns CancelablePromise<T>
|
|
1833
|
+
* @throws ApiError
|
|
1834
|
+
*/
|
|
1835
|
+
const request = (config, options) => {
|
|
1836
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
1837
|
+
try {
|
|
1838
|
+
const url = getUrl(config, options);
|
|
1839
|
+
const formData = getFormData(options);
|
|
1840
|
+
const body = getRequestBody(options);
|
|
1841
|
+
const headers = await getHeaders(config, options);
|
|
1842
|
+
if (!onCancel.isCancelled) {
|
|
1843
|
+
const response = await sendRequest(options, url, body, formData, headers, onCancel);
|
|
1844
|
+
const responseBody = await getResponseBody(response);
|
|
1845
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
1846
|
+
const result = {
|
|
1847
|
+
url,
|
|
1848
|
+
ok: response.ok,
|
|
1849
|
+
status: response.status,
|
|
1850
|
+
statusText: response.statusText,
|
|
1851
|
+
body: responseHeader ?? responseBody,
|
|
1852
|
+
};
|
|
1853
|
+
catchErrorCodes(options, result);
|
|
1854
|
+
resolve(result.body);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
catch (error) {
|
|
1858
|
+
reject(error);
|
|
1859
|
+
}
|
|
1860
|
+
});
|
|
1861
|
+
};
|
|
1862
|
+
|
|
1863
|
+
class NodeHttpRequest extends BaseHttpRequest {
|
|
1864
|
+
constructor(config) {
|
|
1865
|
+
super(config);
|
|
1866
|
+
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Request method
|
|
1869
|
+
* @param options The request options from the service
|
|
1870
|
+
* @returns CancelablePromise<T>
|
|
1871
|
+
* @throws ApiError
|
|
1872
|
+
*/
|
|
1873
|
+
request(options) {
|
|
1874
|
+
return request(this.config, options);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
class OrdersService {
|
|
1879
|
+
httpRequest;
|
|
1880
|
+
constructor(httpRequest) {
|
|
1881
|
+
this.httpRequest = httpRequest;
|
|
1882
|
+
}
|
|
1883
|
+
/**
|
|
1884
|
+
* List all orders
|
|
1885
|
+
* List all orders
|
|
1886
|
+
* @returns Orders OK response.
|
|
1887
|
+
* @throws ApiError
|
|
1888
|
+
*/
|
|
1889
|
+
listOrders({ chainId, pageSize = 100, sortBy, sortDirection, pageCursor, }) {
|
|
1890
|
+
return this.httpRequest.request({
|
|
1891
|
+
method: 'GET',
|
|
1892
|
+
url: '/v1/chains/{chain_id}/orders',
|
|
1893
|
+
path: {
|
|
1894
|
+
'chain_id': chainId,
|
|
1895
|
+
},
|
|
1896
|
+
query: {
|
|
1897
|
+
'page_size': pageSize,
|
|
1898
|
+
'sort_by': sortBy,
|
|
1899
|
+
'sort_direction': sortDirection,
|
|
1900
|
+
'page_cursor': pageCursor,
|
|
1901
|
+
},
|
|
1902
|
+
errors: {
|
|
1903
|
+
404: `not_found: Resource not found`,
|
|
1904
|
+
500: `internal_error: Internal server error`,
|
|
1905
|
+
},
|
|
1906
|
+
});
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Create an order
|
|
1910
|
+
* Create an order
|
|
1911
|
+
* @returns Order Created response.
|
|
1912
|
+
* @throws ApiError
|
|
1913
|
+
*/
|
|
1914
|
+
createOrder({ chainId, requestBody, }) {
|
|
1915
|
+
return this.httpRequest.request({
|
|
1916
|
+
method: 'POST',
|
|
1917
|
+
url: '/v1/chains/{chain_id}/orders',
|
|
1918
|
+
path: {
|
|
1919
|
+
'chain_id': chainId,
|
|
1920
|
+
},
|
|
1921
|
+
body: requestBody,
|
|
1922
|
+
mediaType: 'application/json',
|
|
1923
|
+
errors: {
|
|
1924
|
+
400: `bad_request: Bad Request`,
|
|
1925
|
+
404: `not_found: Resource not found`,
|
|
1926
|
+
500: `internal_error: Internal server error`,
|
|
1927
|
+
},
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Get a single order by ID
|
|
1932
|
+
* Get a single order by ID
|
|
1933
|
+
* @returns Order OK response.
|
|
1934
|
+
* @throws ApiError
|
|
1935
|
+
*/
|
|
1936
|
+
getOrder({ chainId, orderId, }) {
|
|
1937
|
+
return this.httpRequest.request({
|
|
1938
|
+
method: 'GET',
|
|
1939
|
+
url: '/v1/chains/{chain_id}/orders/{order_id}',
|
|
1940
|
+
path: {
|
|
1941
|
+
'chain_id': chainId,
|
|
1942
|
+
'order_id': orderId,
|
|
1943
|
+
},
|
|
1944
|
+
errors: {
|
|
1945
|
+
404: `not_found: Resource not found`,
|
|
1946
|
+
500: `internal_error: Internal server error`,
|
|
1947
|
+
},
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
|
|
1952
|
+
class OrderBookClient {
|
|
1953
|
+
orders;
|
|
1954
|
+
request;
|
|
1955
|
+
constructor(config, HttpRequest = NodeHttpRequest) {
|
|
1956
|
+
this.request = new HttpRequest({
|
|
1957
|
+
BASE: config?.BASE ?? 'https://order-book-mr.dev.imtbl.com',
|
|
1958
|
+
VERSION: config?.VERSION ?? '1.0.0',
|
|
1959
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
1960
|
+
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
1961
|
+
TOKEN: config?.TOKEN,
|
|
1962
|
+
USERNAME: config?.USERNAME,
|
|
1963
|
+
PASSWORD: config?.PASSWORD,
|
|
1964
|
+
HEADERS: config?.HEADERS,
|
|
1965
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
1966
|
+
});
|
|
1967
|
+
this.orders = new OrdersService(this.request);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
/* istanbul ignore file */
|
|
1972
|
+
/* tslint:disable */
|
|
1973
|
+
/* eslint-disable */
|
|
1974
|
+
var BuyItem;
|
|
1975
|
+
(function (BuyItem) {
|
|
1976
|
+
(function (item_type) {
|
|
1977
|
+
item_type["ERC20"] = "ERC20";
|
|
1978
|
+
item_type["IMX"] = "IMX";
|
|
1979
|
+
})(BuyItem.item_type || (BuyItem.item_type = {}));
|
|
1980
|
+
})(BuyItem || (BuyItem = {}));
|
|
1981
|
+
|
|
1982
|
+
/* istanbul ignore file */
|
|
1983
|
+
/* tslint:disable */
|
|
1984
|
+
/* eslint-disable */
|
|
1985
|
+
var CreateOrderProtocolData;
|
|
1986
|
+
(function (CreateOrderProtocolData) {
|
|
1987
|
+
(function (order_type) {
|
|
1988
|
+
order_type["FULL_OPEN"] = "FULL_OPEN";
|
|
1989
|
+
})(CreateOrderProtocolData.order_type || (CreateOrderProtocolData.order_type = {}));
|
|
1990
|
+
})(CreateOrderProtocolData || (CreateOrderProtocolData = {}));
|
|
1991
|
+
|
|
1992
|
+
/* istanbul ignore file */
|
|
1993
|
+
/* tslint:disable */
|
|
1994
|
+
/* eslint-disable */
|
|
1995
|
+
var Fee;
|
|
1996
|
+
(function (Fee) {
|
|
1997
|
+
(function (fee_type) {
|
|
1998
|
+
fee_type["ROYALTY"] = "ROYALTY";
|
|
1999
|
+
})(Fee.fee_type || (Fee.fee_type = {}));
|
|
2000
|
+
})(Fee || (Fee = {}));
|
|
2001
|
+
|
|
2002
|
+
/* istanbul ignore file */
|
|
2003
|
+
/* tslint:disable */
|
|
2004
|
+
/* eslint-disable */
|
|
2005
|
+
var Order;
|
|
2006
|
+
(function (Order) {
|
|
2007
|
+
(function (status) {
|
|
2008
|
+
status["PENDING"] = "PENDING";
|
|
2009
|
+
status["ACTIVE"] = "ACTIVE";
|
|
2010
|
+
status["CANCELLED"] = "CANCELLED";
|
|
2011
|
+
status["INACTIVE"] = "INACTIVE";
|
|
2012
|
+
status["REJECTED"] = "REJECTED";
|
|
2013
|
+
status["FILLED"] = "FILLED";
|
|
2014
|
+
status["EXPIRED"] = "EXPIRED";
|
|
2015
|
+
})(Order.status || (Order.status = {}));
|
|
2016
|
+
})(Order || (Order = {}));
|
|
2017
|
+
|
|
2018
|
+
/* istanbul ignore file */
|
|
2019
|
+
/* tslint:disable */
|
|
2020
|
+
/* eslint-disable */
|
|
2021
|
+
var SellItem;
|
|
2022
|
+
(function (SellItem) {
|
|
2023
|
+
(function (item_type) {
|
|
2024
|
+
item_type["ERC721"] = "ERC721";
|
|
2025
|
+
})(SellItem.item_type || (SellItem.item_type = {}));
|
|
2026
|
+
})(SellItem || (SellItem = {}));
|
|
2027
|
+
|
|
2028
|
+
class ImmutableApiClient {
|
|
2029
|
+
orderbookService;
|
|
2030
|
+
chainId;
|
|
2031
|
+
constructor(orderbookService, chainId) {
|
|
2032
|
+
this.orderbookService = orderbookService;
|
|
2033
|
+
this.chainId = chainId;
|
|
2034
|
+
}
|
|
2035
|
+
async getOrder(orderId) {
|
|
2036
|
+
return this.orderbookService.getOrder({ chainId: this.chainId, orderId });
|
|
2037
|
+
}
|
|
2038
|
+
async createOrder({ orderHash, orderComponents, offerer, orderSignature, }) {
|
|
2039
|
+
if (orderComponents.offer.length !== 1) {
|
|
2040
|
+
throw new Error('Only one item can be listed at a time');
|
|
2041
|
+
}
|
|
2042
|
+
if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
|
|
2043
|
+
throw new Error('Only ERC721 tokens can be listed');
|
|
2044
|
+
}
|
|
2045
|
+
const considerationItemTypeTheSame = new Set([...orderComponents.consideration.map((c) => c.itemType)]).size === 1;
|
|
2046
|
+
if (!considerationItemTypeTheSame) {
|
|
2047
|
+
throw new Error('All consideration items must be of the same type');
|
|
2048
|
+
}
|
|
2049
|
+
return this.orderbookService.createOrder({
|
|
2050
|
+
chainId: this.chainId,
|
|
2051
|
+
requestBody: {
|
|
2052
|
+
order_hash: orderHash,
|
|
2053
|
+
account_address: offerer,
|
|
2054
|
+
buy: [
|
|
2055
|
+
{
|
|
2056
|
+
item_type: Number(orderComponents.consideration[0].itemType) === ItemType.NATIVE
|
|
2057
|
+
? BuyItem.item_type.IMX
|
|
2058
|
+
: BuyItem.item_type.ERC20,
|
|
2059
|
+
start_amount: orderComponents.consideration[0].startAmount,
|
|
2060
|
+
}
|
|
2061
|
+
],
|
|
2062
|
+
buy_fees: orderComponents.consideration.length > 1
|
|
2063
|
+
? [
|
|
2064
|
+
{
|
|
2065
|
+
amount: orderComponents.consideration[1].startAmount,
|
|
2066
|
+
recipient: orderComponents.consideration[1].recipient,
|
|
2067
|
+
fee_type: Fee.fee_type.ROYALTY,
|
|
2068
|
+
},
|
|
2069
|
+
]
|
|
2070
|
+
: [],
|
|
2071
|
+
end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
|
|
2072
|
+
protocol_data: {
|
|
2073
|
+
order_type: CreateOrderProtocolData.order_type.FULL_OPEN,
|
|
2074
|
+
zone_address: orderComponents.zone,
|
|
2075
|
+
},
|
|
2076
|
+
salt: orderComponents.salt,
|
|
2077
|
+
sell: [{
|
|
2078
|
+
contract_address: orderComponents.offer[0].token,
|
|
2079
|
+
token_id: orderComponents.offer[0].identifierOrCriteria,
|
|
2080
|
+
item_type: SellItem.item_type.ERC721,
|
|
2081
|
+
}],
|
|
2082
|
+
signature: orderSignature,
|
|
2083
|
+
start_time: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
|
|
2084
|
+
},
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
}
|
|
2088
|
+
|
|
2089
|
+
class ImmutableApiClientFactory {
|
|
2090
|
+
chainId;
|
|
2091
|
+
orderbookClient;
|
|
2092
|
+
constructor(apiEndpoint, chainId) {
|
|
2093
|
+
this.chainId = chainId;
|
|
2094
|
+
this.orderbookClient = new OrderBookClient({
|
|
2095
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2096
|
+
BASE: apiEndpoint,
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
create() {
|
|
2100
|
+
return new ImmutableApiClient(this.orderbookClient.orders, this.chainId);
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
class ERC721 {
|
|
2105
|
+
erc721;
|
|
2106
|
+
constructor(erc721) {
|
|
2107
|
+
this.erc721 = erc721;
|
|
2108
|
+
}
|
|
2109
|
+
async royaltyInfo(tokenId, salePrice) {
|
|
2110
|
+
const [recipient, royaltyRequired] = await this.erc721.royaltyInfo(tokenId, salePrice);
|
|
2111
|
+
return { recipient, amountRequired: royaltyRequired.toString() };
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
/* Autogenerated file. Do not edit manually. */
|
|
2116
|
+
/* tslint:disable */
|
|
2117
|
+
/* eslint-disable */
|
|
2118
|
+
const _abi = [
|
|
2119
|
+
{
|
|
2120
|
+
inputs: [
|
|
2121
|
+
{
|
|
2122
|
+
internalType: "address",
|
|
2123
|
+
name: "owner_",
|
|
2124
|
+
type: "address",
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
internalType: "string",
|
|
2128
|
+
name: "name_",
|
|
2129
|
+
type: "string",
|
|
2130
|
+
},
|
|
2131
|
+
{
|
|
2132
|
+
internalType: "string",
|
|
2133
|
+
name: "symbol_",
|
|
2134
|
+
type: "string",
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
internalType: "string",
|
|
2138
|
+
name: "baseURI_",
|
|
2139
|
+
type: "string",
|
|
2140
|
+
},
|
|
2141
|
+
{
|
|
2142
|
+
internalType: "string",
|
|
2143
|
+
name: "contractURI_",
|
|
2144
|
+
type: "string",
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
internalType: "address",
|
|
2148
|
+
name: "_receiver",
|
|
2149
|
+
type: "address",
|
|
2150
|
+
},
|
|
2151
|
+
{
|
|
2152
|
+
internalType: "uint96",
|
|
2153
|
+
name: "_feeNumerator",
|
|
2154
|
+
type: "uint96",
|
|
2155
|
+
},
|
|
2156
|
+
],
|
|
2157
|
+
stateMutability: "nonpayable",
|
|
2158
|
+
type: "constructor",
|
|
2159
|
+
},
|
|
2160
|
+
{
|
|
2161
|
+
inputs: [
|
|
2162
|
+
{
|
|
2163
|
+
internalType: "address",
|
|
2164
|
+
name: "target",
|
|
2165
|
+
type: "address",
|
|
2166
|
+
},
|
|
2167
|
+
],
|
|
2168
|
+
name: "ApproveTargetNotInAllowlist",
|
|
2169
|
+
type: "error",
|
|
2170
|
+
},
|
|
2171
|
+
{
|
|
2172
|
+
inputs: [
|
|
2173
|
+
{
|
|
2174
|
+
internalType: "address",
|
|
2175
|
+
name: "caller",
|
|
2176
|
+
type: "address",
|
|
2177
|
+
},
|
|
2178
|
+
],
|
|
2179
|
+
name: "CallerNotInAllowlist",
|
|
2180
|
+
type: "error",
|
|
2181
|
+
},
|
|
2182
|
+
{
|
|
2183
|
+
anonymous: false,
|
|
2184
|
+
inputs: [
|
|
2185
|
+
{
|
|
2186
|
+
indexed: true,
|
|
2187
|
+
internalType: "address",
|
|
2188
|
+
name: "owner",
|
|
2189
|
+
type: "address",
|
|
2190
|
+
},
|
|
2191
|
+
{
|
|
2192
|
+
indexed: true,
|
|
2193
|
+
internalType: "address",
|
|
2194
|
+
name: "approved",
|
|
2195
|
+
type: "address",
|
|
2196
|
+
},
|
|
2197
|
+
{
|
|
2198
|
+
indexed: true,
|
|
2199
|
+
internalType: "uint256",
|
|
2200
|
+
name: "tokenId",
|
|
2201
|
+
type: "uint256",
|
|
2202
|
+
},
|
|
2203
|
+
],
|
|
2204
|
+
name: "Approval",
|
|
2205
|
+
type: "event",
|
|
2206
|
+
},
|
|
2207
|
+
{
|
|
2208
|
+
anonymous: false,
|
|
2209
|
+
inputs: [
|
|
2210
|
+
{
|
|
2211
|
+
indexed: true,
|
|
2212
|
+
internalType: "address",
|
|
2213
|
+
name: "owner",
|
|
2214
|
+
type: "address",
|
|
2215
|
+
},
|
|
2216
|
+
{
|
|
2217
|
+
indexed: true,
|
|
2218
|
+
internalType: "address",
|
|
2219
|
+
name: "operator",
|
|
2220
|
+
type: "address",
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
indexed: false,
|
|
2224
|
+
internalType: "bool",
|
|
2225
|
+
name: "approved",
|
|
2226
|
+
type: "bool",
|
|
2227
|
+
},
|
|
2228
|
+
],
|
|
2229
|
+
name: "ApprovalForAll",
|
|
2230
|
+
type: "event",
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
anonymous: false,
|
|
2234
|
+
inputs: [
|
|
2235
|
+
{
|
|
2236
|
+
indexed: true,
|
|
2237
|
+
internalType: "bytes32",
|
|
2238
|
+
name: "role",
|
|
2239
|
+
type: "bytes32",
|
|
2240
|
+
},
|
|
2241
|
+
{
|
|
2242
|
+
indexed: true,
|
|
2243
|
+
internalType: "bytes32",
|
|
2244
|
+
name: "previousAdminRole",
|
|
2245
|
+
type: "bytes32",
|
|
2246
|
+
},
|
|
2247
|
+
{
|
|
2248
|
+
indexed: true,
|
|
2249
|
+
internalType: "bytes32",
|
|
2250
|
+
name: "newAdminRole",
|
|
2251
|
+
type: "bytes32",
|
|
2252
|
+
},
|
|
2253
|
+
],
|
|
2254
|
+
name: "RoleAdminChanged",
|
|
2255
|
+
type: "event",
|
|
2256
|
+
},
|
|
2257
|
+
{
|
|
2258
|
+
anonymous: false,
|
|
2259
|
+
inputs: [
|
|
2260
|
+
{
|
|
2261
|
+
indexed: true,
|
|
2262
|
+
internalType: "bytes32",
|
|
2263
|
+
name: "role",
|
|
2264
|
+
type: "bytes32",
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
indexed: true,
|
|
2268
|
+
internalType: "address",
|
|
2269
|
+
name: "account",
|
|
2270
|
+
type: "address",
|
|
2271
|
+
},
|
|
2272
|
+
{
|
|
2273
|
+
indexed: true,
|
|
2274
|
+
internalType: "address",
|
|
2275
|
+
name: "sender",
|
|
2276
|
+
type: "address",
|
|
2277
|
+
},
|
|
2278
|
+
],
|
|
2279
|
+
name: "RoleGranted",
|
|
2280
|
+
type: "event",
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
anonymous: false,
|
|
2284
|
+
inputs: [
|
|
2285
|
+
{
|
|
2286
|
+
indexed: true,
|
|
2287
|
+
internalType: "bytes32",
|
|
2288
|
+
name: "role",
|
|
2289
|
+
type: "bytes32",
|
|
2290
|
+
},
|
|
2291
|
+
{
|
|
2292
|
+
indexed: true,
|
|
2293
|
+
internalType: "address",
|
|
2294
|
+
name: "account",
|
|
2295
|
+
type: "address",
|
|
2296
|
+
},
|
|
2297
|
+
{
|
|
2298
|
+
indexed: true,
|
|
2299
|
+
internalType: "address",
|
|
2300
|
+
name: "sender",
|
|
2301
|
+
type: "address",
|
|
2302
|
+
},
|
|
2303
|
+
],
|
|
2304
|
+
name: "RoleRevoked",
|
|
2305
|
+
type: "event",
|
|
2306
|
+
},
|
|
2307
|
+
{
|
|
2308
|
+
anonymous: false,
|
|
2309
|
+
inputs: [
|
|
2310
|
+
{
|
|
2311
|
+
indexed: false,
|
|
2312
|
+
internalType: "address",
|
|
2313
|
+
name: "oldRegistry",
|
|
2314
|
+
type: "address",
|
|
2315
|
+
},
|
|
2316
|
+
{
|
|
2317
|
+
indexed: false,
|
|
2318
|
+
internalType: "address",
|
|
2319
|
+
name: "newRegistry",
|
|
2320
|
+
type: "address",
|
|
2321
|
+
},
|
|
2322
|
+
],
|
|
2323
|
+
name: "RoyaltytAllowlistRegistryUpdated",
|
|
2324
|
+
type: "event",
|
|
2325
|
+
},
|
|
2326
|
+
{
|
|
2327
|
+
anonymous: false,
|
|
2328
|
+
inputs: [
|
|
2329
|
+
{
|
|
2330
|
+
indexed: true,
|
|
2331
|
+
internalType: "address",
|
|
2332
|
+
name: "from",
|
|
2333
|
+
type: "address",
|
|
2334
|
+
},
|
|
2335
|
+
{
|
|
2336
|
+
indexed: true,
|
|
2337
|
+
internalType: "address",
|
|
2338
|
+
name: "to",
|
|
2339
|
+
type: "address",
|
|
2340
|
+
},
|
|
2341
|
+
{
|
|
2342
|
+
indexed: true,
|
|
2343
|
+
internalType: "uint256",
|
|
2344
|
+
name: "tokenId",
|
|
2345
|
+
type: "uint256",
|
|
2346
|
+
},
|
|
2347
|
+
],
|
|
2348
|
+
name: "Transfer",
|
|
2349
|
+
type: "event",
|
|
2350
|
+
},
|
|
2351
|
+
{
|
|
2352
|
+
inputs: [],
|
|
2353
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
2354
|
+
outputs: [
|
|
2355
|
+
{
|
|
2356
|
+
internalType: "bytes32",
|
|
2357
|
+
name: "",
|
|
2358
|
+
type: "bytes32",
|
|
2359
|
+
},
|
|
2360
|
+
],
|
|
2361
|
+
stateMutability: "view",
|
|
2362
|
+
type: "function",
|
|
2363
|
+
},
|
|
2364
|
+
{
|
|
2365
|
+
inputs: [],
|
|
2366
|
+
name: "MINTER_ROLE",
|
|
2367
|
+
outputs: [
|
|
2368
|
+
{
|
|
2369
|
+
internalType: "bytes32",
|
|
2370
|
+
name: "",
|
|
2371
|
+
type: "bytes32",
|
|
2372
|
+
},
|
|
2373
|
+
],
|
|
2374
|
+
stateMutability: "view",
|
|
2375
|
+
type: "function",
|
|
2376
|
+
},
|
|
2377
|
+
{
|
|
2378
|
+
inputs: [
|
|
2379
|
+
{
|
|
2380
|
+
internalType: "address",
|
|
2381
|
+
name: "to",
|
|
2382
|
+
type: "address",
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
internalType: "uint256",
|
|
2386
|
+
name: "tokenId",
|
|
2387
|
+
type: "uint256",
|
|
2388
|
+
},
|
|
2389
|
+
],
|
|
2390
|
+
name: "approve",
|
|
2391
|
+
outputs: [],
|
|
2392
|
+
stateMutability: "nonpayable",
|
|
2393
|
+
type: "function",
|
|
2394
|
+
},
|
|
2395
|
+
{
|
|
2396
|
+
inputs: [
|
|
2397
|
+
{
|
|
2398
|
+
internalType: "address",
|
|
2399
|
+
name: "owner",
|
|
2400
|
+
type: "address",
|
|
2401
|
+
},
|
|
2402
|
+
],
|
|
2403
|
+
name: "balanceOf",
|
|
2404
|
+
outputs: [
|
|
2405
|
+
{
|
|
2406
|
+
internalType: "uint256",
|
|
2407
|
+
name: "",
|
|
2408
|
+
type: "uint256",
|
|
2409
|
+
},
|
|
2410
|
+
],
|
|
2411
|
+
stateMutability: "view",
|
|
2412
|
+
type: "function",
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
inputs: [],
|
|
2416
|
+
name: "baseURI",
|
|
2417
|
+
outputs: [
|
|
2418
|
+
{
|
|
2419
|
+
internalType: "string",
|
|
2420
|
+
name: "",
|
|
2421
|
+
type: "string",
|
|
2422
|
+
},
|
|
2423
|
+
],
|
|
2424
|
+
stateMutability: "view",
|
|
2425
|
+
type: "function",
|
|
2426
|
+
},
|
|
2427
|
+
{
|
|
2428
|
+
inputs: [
|
|
2429
|
+
{
|
|
2430
|
+
internalType: "uint256",
|
|
2431
|
+
name: "tokenId",
|
|
2432
|
+
type: "uint256",
|
|
2433
|
+
},
|
|
2434
|
+
],
|
|
2435
|
+
name: "burn",
|
|
2436
|
+
outputs: [],
|
|
2437
|
+
stateMutability: "nonpayable",
|
|
2438
|
+
type: "function",
|
|
2439
|
+
},
|
|
2440
|
+
{
|
|
2441
|
+
inputs: [],
|
|
2442
|
+
name: "contractURI",
|
|
2443
|
+
outputs: [
|
|
2444
|
+
{
|
|
2445
|
+
internalType: "string",
|
|
2446
|
+
name: "",
|
|
2447
|
+
type: "string",
|
|
2448
|
+
},
|
|
2449
|
+
],
|
|
2450
|
+
stateMutability: "view",
|
|
2451
|
+
type: "function",
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
inputs: [],
|
|
2455
|
+
name: "getAdmins",
|
|
2456
|
+
outputs: [
|
|
2457
|
+
{
|
|
2458
|
+
internalType: "address[]",
|
|
2459
|
+
name: "",
|
|
2460
|
+
type: "address[]",
|
|
2461
|
+
},
|
|
2462
|
+
],
|
|
2463
|
+
stateMutability: "view",
|
|
2464
|
+
type: "function",
|
|
2465
|
+
},
|
|
2466
|
+
{
|
|
2467
|
+
inputs: [
|
|
2468
|
+
{
|
|
2469
|
+
internalType: "uint256",
|
|
2470
|
+
name: "tokenId",
|
|
2471
|
+
type: "uint256",
|
|
2472
|
+
},
|
|
2473
|
+
],
|
|
2474
|
+
name: "getApproved",
|
|
2475
|
+
outputs: [
|
|
2476
|
+
{
|
|
2477
|
+
internalType: "address",
|
|
2478
|
+
name: "",
|
|
2479
|
+
type: "address",
|
|
2480
|
+
},
|
|
2481
|
+
],
|
|
2482
|
+
stateMutability: "view",
|
|
2483
|
+
type: "function",
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
inputs: [
|
|
2487
|
+
{
|
|
2488
|
+
internalType: "bytes32",
|
|
2489
|
+
name: "role",
|
|
2490
|
+
type: "bytes32",
|
|
2491
|
+
},
|
|
2492
|
+
],
|
|
2493
|
+
name: "getRoleAdmin",
|
|
2494
|
+
outputs: [
|
|
2495
|
+
{
|
|
2496
|
+
internalType: "bytes32",
|
|
2497
|
+
name: "",
|
|
2498
|
+
type: "bytes32",
|
|
2499
|
+
},
|
|
2500
|
+
],
|
|
2501
|
+
stateMutability: "view",
|
|
2502
|
+
type: "function",
|
|
2503
|
+
},
|
|
2504
|
+
{
|
|
2505
|
+
inputs: [
|
|
2506
|
+
{
|
|
2507
|
+
internalType: "bytes32",
|
|
2508
|
+
name: "role",
|
|
2509
|
+
type: "bytes32",
|
|
2510
|
+
},
|
|
2511
|
+
{
|
|
2512
|
+
internalType: "uint256",
|
|
2513
|
+
name: "index",
|
|
2514
|
+
type: "uint256",
|
|
2515
|
+
},
|
|
2516
|
+
],
|
|
2517
|
+
name: "getRoleMember",
|
|
2518
|
+
outputs: [
|
|
2519
|
+
{
|
|
2520
|
+
internalType: "address",
|
|
2521
|
+
name: "",
|
|
2522
|
+
type: "address",
|
|
2523
|
+
},
|
|
2524
|
+
],
|
|
2525
|
+
stateMutability: "view",
|
|
2526
|
+
type: "function",
|
|
2527
|
+
},
|
|
2528
|
+
{
|
|
2529
|
+
inputs: [
|
|
2530
|
+
{
|
|
2531
|
+
internalType: "bytes32",
|
|
2532
|
+
name: "role",
|
|
2533
|
+
type: "bytes32",
|
|
2534
|
+
},
|
|
2535
|
+
],
|
|
2536
|
+
name: "getRoleMemberCount",
|
|
2537
|
+
outputs: [
|
|
2538
|
+
{
|
|
2539
|
+
internalType: "uint256",
|
|
2540
|
+
name: "",
|
|
2541
|
+
type: "uint256",
|
|
2542
|
+
},
|
|
2543
|
+
],
|
|
2544
|
+
stateMutability: "view",
|
|
2545
|
+
type: "function",
|
|
2546
|
+
},
|
|
2547
|
+
{
|
|
2548
|
+
inputs: [
|
|
2549
|
+
{
|
|
2550
|
+
internalType: "address",
|
|
2551
|
+
name: "user",
|
|
2552
|
+
type: "address",
|
|
2553
|
+
},
|
|
2554
|
+
],
|
|
2555
|
+
name: "grantMinterRole",
|
|
2556
|
+
outputs: [],
|
|
2557
|
+
stateMutability: "nonpayable",
|
|
2558
|
+
type: "function",
|
|
2559
|
+
},
|
|
2560
|
+
{
|
|
2561
|
+
inputs: [
|
|
2562
|
+
{
|
|
2563
|
+
internalType: "bytes32",
|
|
2564
|
+
name: "role",
|
|
2565
|
+
type: "bytes32",
|
|
2566
|
+
},
|
|
2567
|
+
{
|
|
2568
|
+
internalType: "address",
|
|
2569
|
+
name: "account",
|
|
2570
|
+
type: "address",
|
|
2571
|
+
},
|
|
2572
|
+
],
|
|
2573
|
+
name: "grantRole",
|
|
2574
|
+
outputs: [],
|
|
2575
|
+
stateMutability: "nonpayable",
|
|
2576
|
+
type: "function",
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
inputs: [
|
|
2580
|
+
{
|
|
2581
|
+
internalType: "bytes32",
|
|
2582
|
+
name: "role",
|
|
2583
|
+
type: "bytes32",
|
|
2584
|
+
},
|
|
2585
|
+
{
|
|
2586
|
+
internalType: "address",
|
|
2587
|
+
name: "account",
|
|
2588
|
+
type: "address",
|
|
2589
|
+
},
|
|
2590
|
+
],
|
|
2591
|
+
name: "hasRole",
|
|
2592
|
+
outputs: [
|
|
2593
|
+
{
|
|
2594
|
+
internalType: "bool",
|
|
2595
|
+
name: "",
|
|
2596
|
+
type: "bool",
|
|
2597
|
+
},
|
|
2598
|
+
],
|
|
2599
|
+
stateMutability: "view",
|
|
2600
|
+
type: "function",
|
|
2601
|
+
},
|
|
2602
|
+
{
|
|
2603
|
+
inputs: [
|
|
2604
|
+
{
|
|
2605
|
+
internalType: "address",
|
|
2606
|
+
name: "owner",
|
|
2607
|
+
type: "address",
|
|
2608
|
+
},
|
|
2609
|
+
{
|
|
2610
|
+
internalType: "address",
|
|
2611
|
+
name: "operator",
|
|
2612
|
+
type: "address",
|
|
2613
|
+
},
|
|
2614
|
+
],
|
|
2615
|
+
name: "isApprovedForAll",
|
|
2616
|
+
outputs: [
|
|
2617
|
+
{
|
|
2618
|
+
internalType: "bool",
|
|
2619
|
+
name: "",
|
|
2620
|
+
type: "bool",
|
|
2621
|
+
},
|
|
2622
|
+
],
|
|
2623
|
+
stateMutability: "view",
|
|
2624
|
+
type: "function",
|
|
2625
|
+
},
|
|
2626
|
+
{
|
|
2627
|
+
inputs: [
|
|
2628
|
+
{
|
|
2629
|
+
internalType: "address",
|
|
2630
|
+
name: "to",
|
|
2631
|
+
type: "address",
|
|
2632
|
+
},
|
|
2633
|
+
{
|
|
2634
|
+
internalType: "uint256",
|
|
2635
|
+
name: "amount",
|
|
2636
|
+
type: "uint256",
|
|
2637
|
+
},
|
|
2638
|
+
],
|
|
2639
|
+
name: "mint",
|
|
2640
|
+
outputs: [],
|
|
2641
|
+
stateMutability: "nonpayable",
|
|
2642
|
+
type: "function",
|
|
2643
|
+
},
|
|
2644
|
+
{
|
|
2645
|
+
inputs: [],
|
|
2646
|
+
name: "name",
|
|
2647
|
+
outputs: [
|
|
2648
|
+
{
|
|
2649
|
+
internalType: "string",
|
|
2650
|
+
name: "",
|
|
2651
|
+
type: "string",
|
|
2652
|
+
},
|
|
2653
|
+
],
|
|
2654
|
+
stateMutability: "view",
|
|
2655
|
+
type: "function",
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
inputs: [
|
|
2659
|
+
{
|
|
2660
|
+
internalType: "uint256",
|
|
2661
|
+
name: "tokenId",
|
|
2662
|
+
type: "uint256",
|
|
2663
|
+
},
|
|
2664
|
+
],
|
|
2665
|
+
name: "ownerOf",
|
|
2666
|
+
outputs: [
|
|
2667
|
+
{
|
|
2668
|
+
internalType: "address",
|
|
2669
|
+
name: "",
|
|
2670
|
+
type: "address",
|
|
2671
|
+
},
|
|
2672
|
+
],
|
|
2673
|
+
stateMutability: "view",
|
|
2674
|
+
type: "function",
|
|
2675
|
+
},
|
|
2676
|
+
{
|
|
2677
|
+
inputs: [
|
|
2678
|
+
{
|
|
2679
|
+
internalType: "bytes32",
|
|
2680
|
+
name: "role",
|
|
2681
|
+
type: "bytes32",
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
internalType: "address",
|
|
2685
|
+
name: "account",
|
|
2686
|
+
type: "address",
|
|
2687
|
+
},
|
|
2688
|
+
],
|
|
2689
|
+
name: "renounceRole",
|
|
2690
|
+
outputs: [],
|
|
2691
|
+
stateMutability: "nonpayable",
|
|
2692
|
+
type: "function",
|
|
2693
|
+
},
|
|
2694
|
+
{
|
|
2695
|
+
inputs: [
|
|
2696
|
+
{
|
|
2697
|
+
internalType: "address",
|
|
2698
|
+
name: "user",
|
|
2699
|
+
type: "address",
|
|
2700
|
+
},
|
|
2701
|
+
],
|
|
2702
|
+
name: "revokeMinterRole",
|
|
2703
|
+
outputs: [],
|
|
2704
|
+
stateMutability: "nonpayable",
|
|
2705
|
+
type: "function",
|
|
2706
|
+
},
|
|
2707
|
+
{
|
|
2708
|
+
inputs: [
|
|
2709
|
+
{
|
|
2710
|
+
internalType: "bytes32",
|
|
2711
|
+
name: "role",
|
|
2712
|
+
type: "bytes32",
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
internalType: "address",
|
|
2716
|
+
name: "account",
|
|
2717
|
+
type: "address",
|
|
2718
|
+
},
|
|
2719
|
+
],
|
|
2720
|
+
name: "revokeRole",
|
|
2721
|
+
outputs: [],
|
|
2722
|
+
stateMutability: "nonpayable",
|
|
2723
|
+
type: "function",
|
|
2724
|
+
},
|
|
2725
|
+
{
|
|
2726
|
+
inputs: [],
|
|
2727
|
+
name: "royaltyAllowlist",
|
|
2728
|
+
outputs: [
|
|
2729
|
+
{
|
|
2730
|
+
internalType: "contract IRoyaltyAllowlist",
|
|
2731
|
+
name: "",
|
|
2732
|
+
type: "address",
|
|
2733
|
+
},
|
|
2734
|
+
],
|
|
2735
|
+
stateMutability: "view",
|
|
2736
|
+
type: "function",
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
inputs: [
|
|
2740
|
+
{
|
|
2741
|
+
internalType: "uint256",
|
|
2742
|
+
name: "_tokenId",
|
|
2743
|
+
type: "uint256",
|
|
2744
|
+
},
|
|
2745
|
+
{
|
|
2746
|
+
internalType: "uint256",
|
|
2747
|
+
name: "_salePrice",
|
|
2748
|
+
type: "uint256",
|
|
2749
|
+
},
|
|
2750
|
+
],
|
|
2751
|
+
name: "royaltyInfo",
|
|
2752
|
+
outputs: [
|
|
2753
|
+
{
|
|
2754
|
+
internalType: "address",
|
|
2755
|
+
name: "",
|
|
2756
|
+
type: "address",
|
|
2757
|
+
},
|
|
2758
|
+
{
|
|
2759
|
+
internalType: "uint256",
|
|
2760
|
+
name: "",
|
|
2761
|
+
type: "uint256",
|
|
2762
|
+
},
|
|
2763
|
+
],
|
|
2764
|
+
stateMutability: "view",
|
|
2765
|
+
type: "function",
|
|
2766
|
+
},
|
|
2767
|
+
{
|
|
2768
|
+
inputs: [
|
|
2769
|
+
{
|
|
2770
|
+
internalType: "address",
|
|
2771
|
+
name: "from",
|
|
2772
|
+
type: "address",
|
|
2773
|
+
},
|
|
2774
|
+
{
|
|
2775
|
+
internalType: "address",
|
|
2776
|
+
name: "to",
|
|
2777
|
+
type: "address",
|
|
2778
|
+
},
|
|
2779
|
+
{
|
|
2780
|
+
internalType: "uint256",
|
|
2781
|
+
name: "tokenId",
|
|
2782
|
+
type: "uint256",
|
|
2783
|
+
},
|
|
2784
|
+
],
|
|
2785
|
+
name: "safeTransferFrom",
|
|
2786
|
+
outputs: [],
|
|
2787
|
+
stateMutability: "nonpayable",
|
|
2788
|
+
type: "function",
|
|
2789
|
+
},
|
|
2790
|
+
{
|
|
2791
|
+
inputs: [
|
|
2792
|
+
{
|
|
2793
|
+
internalType: "address",
|
|
2794
|
+
name: "from",
|
|
2795
|
+
type: "address",
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
internalType: "address",
|
|
2799
|
+
name: "to",
|
|
2800
|
+
type: "address",
|
|
2801
|
+
},
|
|
2802
|
+
{
|
|
2803
|
+
internalType: "uint256",
|
|
2804
|
+
name: "tokenId",
|
|
2805
|
+
type: "uint256",
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
internalType: "bytes",
|
|
2809
|
+
name: "data",
|
|
2810
|
+
type: "bytes",
|
|
2811
|
+
},
|
|
2812
|
+
],
|
|
2813
|
+
name: "safeTransferFrom",
|
|
2814
|
+
outputs: [],
|
|
2815
|
+
stateMutability: "nonpayable",
|
|
2816
|
+
type: "function",
|
|
2817
|
+
},
|
|
2818
|
+
{
|
|
2819
|
+
inputs: [
|
|
2820
|
+
{
|
|
2821
|
+
internalType: "address",
|
|
2822
|
+
name: "operator",
|
|
2823
|
+
type: "address",
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
internalType: "bool",
|
|
2827
|
+
name: "approved",
|
|
2828
|
+
type: "bool",
|
|
2829
|
+
},
|
|
2830
|
+
],
|
|
2831
|
+
name: "setApprovalForAll",
|
|
2832
|
+
outputs: [],
|
|
2833
|
+
stateMutability: "nonpayable",
|
|
2834
|
+
type: "function",
|
|
2835
|
+
},
|
|
2836
|
+
{
|
|
2837
|
+
inputs: [
|
|
2838
|
+
{
|
|
2839
|
+
internalType: "string",
|
|
2840
|
+
name: "baseURI_",
|
|
2841
|
+
type: "string",
|
|
2842
|
+
},
|
|
2843
|
+
],
|
|
2844
|
+
name: "setBaseURI",
|
|
2845
|
+
outputs: [],
|
|
2846
|
+
stateMutability: "nonpayable",
|
|
2847
|
+
type: "function",
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
inputs: [
|
|
2851
|
+
{
|
|
2852
|
+
internalType: "string",
|
|
2853
|
+
name: "_contractURI",
|
|
2854
|
+
type: "string",
|
|
2855
|
+
},
|
|
2856
|
+
],
|
|
2857
|
+
name: "setContractURI",
|
|
2858
|
+
outputs: [],
|
|
2859
|
+
stateMutability: "nonpayable",
|
|
2860
|
+
type: "function",
|
|
2861
|
+
},
|
|
2862
|
+
{
|
|
2863
|
+
inputs: [
|
|
2864
|
+
{
|
|
2865
|
+
internalType: "address",
|
|
2866
|
+
name: "_royaltyAllowlist",
|
|
2867
|
+
type: "address",
|
|
2868
|
+
},
|
|
2869
|
+
],
|
|
2870
|
+
name: "setRoyaltyAllowlistRegistry",
|
|
2871
|
+
outputs: [],
|
|
2872
|
+
stateMutability: "nonpayable",
|
|
2873
|
+
type: "function",
|
|
2874
|
+
},
|
|
2875
|
+
{
|
|
2876
|
+
inputs: [
|
|
2877
|
+
{
|
|
2878
|
+
internalType: "bytes4",
|
|
2879
|
+
name: "interfaceId",
|
|
2880
|
+
type: "bytes4",
|
|
2881
|
+
},
|
|
2882
|
+
],
|
|
2883
|
+
name: "supportsInterface",
|
|
2884
|
+
outputs: [
|
|
2885
|
+
{
|
|
2886
|
+
internalType: "bool",
|
|
2887
|
+
name: "",
|
|
2888
|
+
type: "bool",
|
|
2889
|
+
},
|
|
2890
|
+
],
|
|
2891
|
+
stateMutability: "view",
|
|
2892
|
+
type: "function",
|
|
2893
|
+
},
|
|
2894
|
+
{
|
|
2895
|
+
inputs: [],
|
|
2896
|
+
name: "symbol",
|
|
2897
|
+
outputs: [
|
|
2898
|
+
{
|
|
2899
|
+
internalType: "string",
|
|
2900
|
+
name: "",
|
|
2901
|
+
type: "string",
|
|
2902
|
+
},
|
|
2903
|
+
],
|
|
2904
|
+
stateMutability: "view",
|
|
2905
|
+
type: "function",
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
inputs: [
|
|
2909
|
+
{
|
|
2910
|
+
internalType: "uint256",
|
|
2911
|
+
name: "index",
|
|
2912
|
+
type: "uint256",
|
|
2913
|
+
},
|
|
2914
|
+
],
|
|
2915
|
+
name: "tokenByIndex",
|
|
2916
|
+
outputs: [
|
|
2917
|
+
{
|
|
2918
|
+
internalType: "uint256",
|
|
2919
|
+
name: "",
|
|
2920
|
+
type: "uint256",
|
|
2921
|
+
},
|
|
2922
|
+
],
|
|
2923
|
+
stateMutability: "view",
|
|
2924
|
+
type: "function",
|
|
2925
|
+
},
|
|
2926
|
+
{
|
|
2927
|
+
inputs: [
|
|
2928
|
+
{
|
|
2929
|
+
internalType: "address",
|
|
2930
|
+
name: "owner",
|
|
2931
|
+
type: "address",
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
internalType: "uint256",
|
|
2935
|
+
name: "index",
|
|
2936
|
+
type: "uint256",
|
|
2937
|
+
},
|
|
2938
|
+
],
|
|
2939
|
+
name: "tokenOfOwnerByIndex",
|
|
2940
|
+
outputs: [
|
|
2941
|
+
{
|
|
2942
|
+
internalType: "uint256",
|
|
2943
|
+
name: "",
|
|
2944
|
+
type: "uint256",
|
|
2945
|
+
},
|
|
2946
|
+
],
|
|
2947
|
+
stateMutability: "view",
|
|
2948
|
+
type: "function",
|
|
2949
|
+
},
|
|
2950
|
+
{
|
|
2951
|
+
inputs: [
|
|
2952
|
+
{
|
|
2953
|
+
internalType: "uint256",
|
|
2954
|
+
name: "tokenId",
|
|
2955
|
+
type: "uint256",
|
|
2956
|
+
},
|
|
2957
|
+
],
|
|
2958
|
+
name: "tokenURI",
|
|
2959
|
+
outputs: [
|
|
2960
|
+
{
|
|
2961
|
+
internalType: "string",
|
|
2962
|
+
name: "",
|
|
2963
|
+
type: "string",
|
|
2964
|
+
},
|
|
2965
|
+
],
|
|
2966
|
+
stateMutability: "view",
|
|
2967
|
+
type: "function",
|
|
2968
|
+
},
|
|
2969
|
+
{
|
|
2970
|
+
inputs: [],
|
|
2971
|
+
name: "totalSupply",
|
|
2972
|
+
outputs: [
|
|
2973
|
+
{
|
|
2974
|
+
internalType: "uint256",
|
|
2975
|
+
name: "",
|
|
2976
|
+
type: "uint256",
|
|
2977
|
+
},
|
|
2978
|
+
],
|
|
2979
|
+
stateMutability: "view",
|
|
2980
|
+
type: "function",
|
|
2981
|
+
},
|
|
2982
|
+
{
|
|
2983
|
+
inputs: [
|
|
2984
|
+
{
|
|
2985
|
+
internalType: "address",
|
|
2986
|
+
name: "from",
|
|
2987
|
+
type: "address",
|
|
2988
|
+
},
|
|
2989
|
+
{
|
|
2990
|
+
internalType: "address",
|
|
2991
|
+
name: "to",
|
|
2992
|
+
type: "address",
|
|
2993
|
+
},
|
|
2994
|
+
{
|
|
2995
|
+
internalType: "uint256",
|
|
2996
|
+
name: "tokenId",
|
|
2997
|
+
type: "uint256",
|
|
2998
|
+
},
|
|
2999
|
+
],
|
|
3000
|
+
name: "transferFrom",
|
|
3001
|
+
outputs: [],
|
|
3002
|
+
stateMutability: "nonpayable",
|
|
3003
|
+
type: "function",
|
|
3004
|
+
},
|
|
3005
|
+
];
|
|
3006
|
+
class ImmutableERC721Base__factory {
|
|
3007
|
+
static abi = _abi;
|
|
3008
|
+
static createInterface() {
|
|
3009
|
+
return new utils.Interface(_abi);
|
|
3010
|
+
}
|
|
3011
|
+
static connect(address, signerOrProvider) {
|
|
3012
|
+
return new Contract(address, _abi, signerOrProvider);
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
|
|
3016
|
+
class ERC721Factory {
|
|
3017
|
+
erc721;
|
|
3018
|
+
constructor(contractAddress, provider) {
|
|
3019
|
+
this.erc721 = ImmutableERC721Base__factory.connect(contractAddress, provider);
|
|
3020
|
+
}
|
|
3021
|
+
create() {
|
|
3022
|
+
return new ERC721(this.erc721);
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
function getOrderComponentsFromMessage(orderMessage) {
|
|
3027
|
+
const data = JSON.parse(orderMessage);
|
|
3028
|
+
const orderComponents = data.message;
|
|
3029
|
+
orderComponents.salt = BigNumber.from(orderComponents.salt).toHexString();
|
|
3030
|
+
return orderComponents;
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
// Add 20% more gas than estimate to prevent out of gas errors
|
|
3034
|
+
// This can always be overwritten by the user signing the transaction
|
|
3035
|
+
async function prepareTransaction(transactionMethods) {
|
|
3036
|
+
const transaction = await transactionMethods.buildTransaction();
|
|
3037
|
+
transaction.gasLimit = await transactionMethods.estimateGas();
|
|
3038
|
+
transaction.gasLimit = transaction.gasLimit
|
|
3039
|
+
.add(transaction.gasLimit.div(5));
|
|
3040
|
+
return transaction;
|
|
3041
|
+
}
|
|
3042
|
+
|
|
3043
|
+
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
3044
|
+
const considerationItems = order.buy.map((buyItem) => ({
|
|
3045
|
+
startAmount: buyItem.start_amount,
|
|
3046
|
+
endAmount: buyItem.start_amount,
|
|
3047
|
+
itemType: buyItem.item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
3048
|
+
recipient: order.account_address,
|
|
3049
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
3050
|
+
identifierOrCriteria: '0',
|
|
3051
|
+
}));
|
|
3052
|
+
const fees = order.buy_fees.map((fee) => ({
|
|
3053
|
+
startAmount: fee.amount,
|
|
3054
|
+
endAmount: fee.amount,
|
|
3055
|
+
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
3056
|
+
recipient: fee.recipient,
|
|
3057
|
+
token: order.buy[0].contract_address || constants.AddressZero,
|
|
3058
|
+
identifierOrCriteria: '0',
|
|
3059
|
+
}));
|
|
3060
|
+
return {
|
|
3061
|
+
conduitKey: constants.HashZero,
|
|
3062
|
+
consideration: [...considerationItems, ...fees],
|
|
3063
|
+
offer: order.sell.map((sellItem) => ({
|
|
3064
|
+
startAmount: '1',
|
|
3065
|
+
endAmount: '1',
|
|
3066
|
+
itemType: ItemType.ERC721,
|
|
3067
|
+
token: sellItem.contract_address,
|
|
3068
|
+
identifierOrCriteria: sellItem.token_id,
|
|
3069
|
+
})),
|
|
3070
|
+
counter,
|
|
3071
|
+
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
|
|
3072
|
+
startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
|
|
3073
|
+
salt: order.salt,
|
|
3074
|
+
offerer: order.account_address,
|
|
3075
|
+
zone: zoneAddress,
|
|
3076
|
+
totalOriginalConsiderationItems: 2,
|
|
3077
|
+
orderType: OrderType.FULL_RESTRICTED,
|
|
3078
|
+
zoneHash: constants.HashZero,
|
|
3079
|
+
};
|
|
3080
|
+
}
|
|
3081
|
+
|
|
3082
|
+
class Seaport {
|
|
3083
|
+
seaport;
|
|
3084
|
+
provider;
|
|
3085
|
+
seaportContractAddress;
|
|
3086
|
+
zoneContractAddress;
|
|
3087
|
+
constructor(seaport, provider, seaportContractAddress, zoneContractAddress) {
|
|
3088
|
+
this.seaport = seaport;
|
|
3089
|
+
this.provider = provider;
|
|
3090
|
+
this.seaportContractAddress = seaportContractAddress;
|
|
3091
|
+
this.zoneContractAddress = zoneContractAddress;
|
|
3092
|
+
}
|
|
3093
|
+
async prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
3094
|
+
const { actions } = await this.createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry);
|
|
3095
|
+
let approvalTransaction;
|
|
3096
|
+
const approvalAction = actions
|
|
3097
|
+
.find((action) => action.type === 'approval');
|
|
3098
|
+
if (approvalAction) {
|
|
3099
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
3100
|
+
}
|
|
3101
|
+
const createAction = actions
|
|
3102
|
+
.find((action) => action.type === 'create');
|
|
3103
|
+
if (!createAction) {
|
|
3104
|
+
throw new Error('No create order action found');
|
|
3105
|
+
}
|
|
3106
|
+
const orderMessageToSign = await createAction.getMessageToSign();
|
|
3107
|
+
const orderComponents = getOrderComponentsFromMessage(orderMessageToSign);
|
|
3108
|
+
return {
|
|
3109
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
3110
|
+
typedOrderMessageForSigning: await this.getTypedDataFromOrderComponents(orderComponents),
|
|
3111
|
+
orderComponents,
|
|
3112
|
+
orderHash: await this.seaport.getOrderHash(orderComponents),
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
async fulfilOrder(order, account) {
|
|
3116
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
3117
|
+
const { actions } = await this.seaport.fulfillOrders({
|
|
3118
|
+
accountAddress: account,
|
|
3119
|
+
fulfillOrderDetails: [{
|
|
3120
|
+
order: {
|
|
3121
|
+
parameters: orderComponents,
|
|
3122
|
+
signature: order.signature,
|
|
3123
|
+
},
|
|
3124
|
+
}],
|
|
3125
|
+
});
|
|
3126
|
+
let approvalTransaction;
|
|
3127
|
+
const approvalAction = actions
|
|
3128
|
+
.find((action) => action.type === 'approval');
|
|
3129
|
+
if (approvalAction) {
|
|
3130
|
+
approvalTransaction = await prepareTransaction(approvalAction.transactionMethods);
|
|
3131
|
+
}
|
|
3132
|
+
const fulfillmentAction = actions
|
|
3133
|
+
.find((action) => action.type === 'exchange');
|
|
3134
|
+
if (!fulfillmentAction) {
|
|
3135
|
+
throw new Error('No exchange action found');
|
|
3136
|
+
}
|
|
3137
|
+
const fulfillmentTransaction = await prepareTransaction(fulfillmentAction.transactionMethods);
|
|
3138
|
+
return {
|
|
3139
|
+
unsignedApprovalTransaction: approvalTransaction,
|
|
3140
|
+
unsignedFulfillmentTransaction: fulfillmentTransaction,
|
|
3141
|
+
};
|
|
3142
|
+
}
|
|
3143
|
+
async cancelOrder(order, account) {
|
|
3144
|
+
const orderComponents = await this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
3145
|
+
const cancellationTransaction = await this.seaport.cancelOrders([orderComponents], account);
|
|
3146
|
+
return prepareTransaction(cancellationTransaction);
|
|
3147
|
+
}
|
|
3148
|
+
async mapImmutableOrderToSeaportOrderComponents(order) {
|
|
3149
|
+
const counterForOfferer = await this.seaport.getCounter(order.account_address);
|
|
3150
|
+
return mapImmutableOrderToSeaportOrderComponents(order, counterForOfferer.toString(), this.zoneContractAddress);
|
|
3151
|
+
}
|
|
3152
|
+
createSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo, orderStart, orderExpiry) {
|
|
3153
|
+
return this.seaport.createOrder({
|
|
3154
|
+
allowPartialFills: false,
|
|
3155
|
+
offer: [
|
|
3156
|
+
{
|
|
3157
|
+
itemType: ItemType.ERC721,
|
|
3158
|
+
token: listingItem.contractAddress,
|
|
3159
|
+
identifier: listingItem.tokenId,
|
|
3160
|
+
},
|
|
3161
|
+
],
|
|
3162
|
+
consideration: [
|
|
3163
|
+
{
|
|
3164
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
3165
|
+
amount: considerationItem.amount,
|
|
3166
|
+
recipient: offerer,
|
|
3167
|
+
},
|
|
3168
|
+
{
|
|
3169
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
3170
|
+
amount: royaltyInfo.amountRequired,
|
|
3171
|
+
recipient: royaltyInfo.recipient,
|
|
3172
|
+
},
|
|
3173
|
+
],
|
|
3174
|
+
startTime: (orderStart.getTime() / 1000).toFixed(0),
|
|
3175
|
+
endTime: (orderExpiry.getTime() / 1000).toFixed(0),
|
|
3176
|
+
zone: this.zoneContractAddress,
|
|
3177
|
+
restrictedByZone: true,
|
|
3178
|
+
}, offerer);
|
|
3179
|
+
}
|
|
3180
|
+
async getTypedDataFromOrderComponents(orderComponents) {
|
|
3181
|
+
const { chainId } = await this.provider.getNetwork();
|
|
3182
|
+
const domainData = {
|
|
3183
|
+
name: SEAPORT_CONTRACT_NAME,
|
|
3184
|
+
version: SEAPORT_CONTRACT_VERSION_V1_4,
|
|
3185
|
+
chainId,
|
|
3186
|
+
verifyingContract: this.seaportContractAddress,
|
|
3187
|
+
};
|
|
3188
|
+
return {
|
|
3189
|
+
domain: domainData,
|
|
3190
|
+
types: EIP_712_ORDER_TYPE,
|
|
3191
|
+
value: orderComponents,
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
class SeaportFactory {
|
|
3197
|
+
seaportContractAddress;
|
|
3198
|
+
zoneContractAddress;
|
|
3199
|
+
provider;
|
|
3200
|
+
seaport;
|
|
3201
|
+
constructor(seaportContractAddress, zoneContractAddress, provider) {
|
|
3202
|
+
this.seaportContractAddress = seaportContractAddress;
|
|
3203
|
+
this.zoneContractAddress = zoneContractAddress;
|
|
3204
|
+
this.provider = provider;
|
|
3205
|
+
this.seaport = new Seaport$1(provider, {
|
|
3206
|
+
seaportVersion: '1.4',
|
|
3207
|
+
balanceAndApprovalChecksOnOrderCreation: true,
|
|
3208
|
+
overrides: {
|
|
3209
|
+
contractAddress: seaportContractAddress,
|
|
3210
|
+
},
|
|
3211
|
+
});
|
|
3212
|
+
}
|
|
3213
|
+
create() {
|
|
3214
|
+
return new Seaport(this.seaport, this.provider, this.seaportContractAddress, this.zoneContractAddress);
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
/**
|
|
3219
|
+
* zkEVM orderbook SDK
|
|
3220
|
+
* @constructor
|
|
3221
|
+
* @param {OrderbookModuleConfiguration} config - Configuration for Immutable services.
|
|
3222
|
+
*/
|
|
3223
|
+
class Orderbook {
|
|
3224
|
+
config;
|
|
3225
|
+
apiClient;
|
|
3226
|
+
seaport;
|
|
3227
|
+
constructor(config) {
|
|
3228
|
+
this.config = config;
|
|
3229
|
+
// TODO: Move endpoint lookup to a map based on env. Just using override to get dev started
|
|
3230
|
+
const apiEndpoint = config.overrides?.apiEndpoint;
|
|
3231
|
+
if (!apiEndpoint) {
|
|
3232
|
+
throw new Error('API endpoint must be provided as an override');
|
|
3233
|
+
}
|
|
3234
|
+
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
3235
|
+
const chainId = config.overrides?.chainId;
|
|
3236
|
+
if (!chainId) {
|
|
3237
|
+
throw new Error('ChainID must be provided as an override');
|
|
3238
|
+
}
|
|
3239
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainId).create();
|
|
3240
|
+
this.seaport = new SeaportFactory(this.config.seaportContractAddress, this.config.zoneContractAddress, this.config.provider).create();
|
|
1449
3241
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
3242
|
+
/**
|
|
3243
|
+
* Get an order by ID
|
|
3244
|
+
* @param {string} orderId - The orderId to find.
|
|
3245
|
+
* @return {Order} The returned order.
|
|
3246
|
+
*/
|
|
3247
|
+
getOrder(orderId) {
|
|
3248
|
+
return this.apiClient.getOrder(orderId);
|
|
1452
3249
|
}
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
3250
|
+
/**
|
|
3251
|
+
* Get required transactions and messages for signing prior to creating a listing
|
|
3252
|
+
* through the createOrder method
|
|
3253
|
+
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
3254
|
+
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
3255
|
+
* the unsigned approval transaction, the typed order message for signing and
|
|
3256
|
+
* the order components that can be submitted to `createOrder` with a signature.
|
|
3257
|
+
*/
|
|
3258
|
+
async prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }) {
|
|
3259
|
+
const erc721 = new ERC721Factory(listingItem.contractAddress, this.config.provider).create();
|
|
3260
|
+
const royaltyInfo = await erc721.royaltyInfo(listingItem.tokenId, considerationItem.amount);
|
|
3261
|
+
return this.seaport.prepareSeaportOrder(offerer, listingItem, considerationItem, royaltyInfo,
|
|
3262
|
+
// Default order start to now
|
|
3263
|
+
new Date(),
|
|
3264
|
+
// Default order expiry to 2 years from now
|
|
3265
|
+
orderExpiry || new Date(Date.now() + 1000 * 60 * 60 * 24 * 365 * 2));
|
|
1456
3266
|
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
3267
|
+
/**
|
|
3268
|
+
* Create an order
|
|
3269
|
+
* @param {CreateOrderParams} createOrderParams - create an order with the given params.
|
|
3270
|
+
* @return {Order} The order created in the Immutable services.
|
|
3271
|
+
*/
|
|
3272
|
+
createOrder(createOrderParams) {
|
|
3273
|
+
return this.apiClient.createOrder(createOrderParams);
|
|
1460
3274
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
3275
|
+
/**
|
|
3276
|
+
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
3277
|
+
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
3278
|
+
* transaction can be submitted or it will be reverted.
|
|
3279
|
+
* @param {string} orderId - The orderId to fulfil.
|
|
3280
|
+
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
3281
|
+
* @return {FulfilOrderResponse} Approval and fulfilment transactions.
|
|
3282
|
+
*/
|
|
3283
|
+
async fulfillOrder(orderId, fulfillerAddress) {
|
|
3284
|
+
const order = await this.apiClient.getOrder(orderId);
|
|
3285
|
+
if (order.status !== Order.status.ACTIVE) {
|
|
3286
|
+
throw new Error(`Cannot fulfil order that is not active. Current status: ${order.status}`);
|
|
3287
|
+
}
|
|
3288
|
+
return this.seaport.fulfilOrder(order, fulfillerAddress);
|
|
1464
3289
|
}
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
3290
|
+
/**
|
|
3291
|
+
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
3292
|
+
* the account that created them.
|
|
3293
|
+
* @param {string} orderId - The orderId to cancel.
|
|
3294
|
+
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
3295
|
+
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
3296
|
+
*/
|
|
3297
|
+
async cancelOrder(orderId, accountAddress) {
|
|
3298
|
+
const order = await this.apiClient.getOrder(orderId);
|
|
3299
|
+
if (order.status !== Order.status.ACTIVE
|
|
3300
|
+
&& order.status !== Order.status.INACTIVE
|
|
3301
|
+
&& order.status !== Order.status.PENDING) {
|
|
3302
|
+
throw new Error(`Cannot cancel order with status ${order.status}`);
|
|
1474
3303
|
}
|
|
1475
|
-
|
|
3304
|
+
if (order.account_address !== accountAddress.toLowerCase()) {
|
|
3305
|
+
throw new Error(`Only account ${order.account_address} can cancel order ${orderId}`);
|
|
3306
|
+
}
|
|
3307
|
+
const cancelOrderTransaction = await this.seaport.cancelOrder(order, accountAddress);
|
|
3308
|
+
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
|
1476
3309
|
}
|
|
1477
3310
|
}
|
|
1478
3311
|
|
|
3312
|
+
const module = 'orderbook';
|
|
3313
|
+
|
|
1479
3314
|
function isChainValid(chainID, config) {
|
|
1480
3315
|
return chainID === config.ethConfiguration.chainID;
|
|
1481
3316
|
}
|
|
1482
3317
|
async function validateChain(signer, config) {
|
|
1483
3318
|
const chainID = await signer.getChainId();
|
|
1484
|
-
if (!isChainValid(chainID, config))
|
|
3319
|
+
if (!isChainValid(chainID, config)) {
|
|
1485
3320
|
throw new Error('The wallet used for this operation is not connected to the correct network.');
|
|
3321
|
+
}
|
|
1486
3322
|
}
|
|
1487
3323
|
|
|
1488
3324
|
async function transfer({ signers: { ethSigner, starkSigner }, request, config, }) {
|
|
@@ -1529,17 +3365,15 @@ async function batchTransfer({ signers: { ethSigner, starkSigner }, request, con
|
|
|
1529
3365
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
1530
3366
|
const ethAddress = await ethSigner.getAddress();
|
|
1531
3367
|
const transfersApi = new TransfersApi(config.immutableXConfig.apiConfiguration);
|
|
1532
|
-
const signableRequests = request.map((nftTransfer) => {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
};
|
|
1542
|
-
});
|
|
3368
|
+
const signableRequests = request.map((nftTransfer) => ({
|
|
3369
|
+
amount: '1',
|
|
3370
|
+
token: convertToSignableToken({
|
|
3371
|
+
type: 'ERC721',
|
|
3372
|
+
tokenId: nftTransfer.tokenId,
|
|
3373
|
+
tokenAddress: nftTransfer.tokenAddress,
|
|
3374
|
+
}),
|
|
3375
|
+
receiver: nftTransfer.receiver,
|
|
3376
|
+
}));
|
|
1543
3377
|
const signableResult = await transfersApi.getSignableTransfer({
|
|
1544
3378
|
getSignableTransferRequestV2: {
|
|
1545
3379
|
sender_ether_key: ethAddress,
|
|
@@ -1553,6 +3387,8 @@ async function batchTransfer({ signers: { ethSigner, starkSigner }, request, con
|
|
|
1553
3387
|
const ethSignature = await signRaw(signableMessage, ethSigner);
|
|
1554
3388
|
const requests = [];
|
|
1555
3389
|
for (const resp of signableResult.data.signable_responses) {
|
|
3390
|
+
// TODO: remove once fixed
|
|
3391
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1556
3392
|
const starkSignature = await starkSigner.signMessage(resp.payload_hash);
|
|
1557
3393
|
const req = {
|
|
1558
3394
|
sender_vault_id: resp.sender_vault_id,
|
|
@@ -1780,9 +3616,7 @@ async function completeERC20WithdrawalAction({ ethSigner, starkPublicKey, token,
|
|
|
1780
3616
|
config,
|
|
1781
3617
|
});
|
|
1782
3618
|
}
|
|
1783
|
-
|
|
1784
|
-
return executeWithdrawERC20(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
|
|
1785
|
-
}
|
|
3619
|
+
return executeWithdrawERC20(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
|
|
1786
3620
|
}
|
|
1787
3621
|
|
|
1788
3622
|
async function executeWithdrawMintableERC721(ethSigner, assetType, starkPublicKey, mintingBlob, config) {
|
|
@@ -1799,7 +3633,7 @@ async function executeRegisterAndWithdrawMintableERC721(ethSigner, assetType, st
|
|
|
1799
3633
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
1800
3634
|
}
|
|
1801
3635
|
function getMintingBlob(token) {
|
|
1802
|
-
const id = token.data
|
|
3636
|
+
const { id } = token.data;
|
|
1803
3637
|
const blueprint = token.data.blueprint || '';
|
|
1804
3638
|
return encUtils.sanitizeHex(encUtils.utf8ToHex(`{${id}}:{${blueprint}}`));
|
|
1805
3639
|
}
|
|
@@ -1815,9 +3649,7 @@ async function completeMintableERC721Withdrawal(ethSigner, starkPublicKey, token
|
|
|
1815
3649
|
if (!isRegistered) {
|
|
1816
3650
|
return executeRegisterAndWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
|
|
1817
3651
|
}
|
|
1818
|
-
|
|
1819
|
-
return executeWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
|
|
1820
|
-
}
|
|
3652
|
+
return executeWithdrawMintableERC721(ethSigner, assetType.asset_type, starkPublicKey, mintingBlob, imxConfig);
|
|
1821
3653
|
}
|
|
1822
3654
|
async function executeRegisterAndWithdrawERC721(ethSigner, assetType, starkPublicKey, tokenId, config) {
|
|
1823
3655
|
const etherKey = await ethSigner.getAddress();
|
|
@@ -1842,14 +3674,12 @@ async function completeERC721Withdrawal(ethSigner, starkPublicKey, token, config
|
|
|
1842
3674
|
if (!isRegistered) {
|
|
1843
3675
|
return executeRegisterAndWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
|
|
1844
3676
|
}
|
|
1845
|
-
|
|
1846
|
-
return executeWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
|
|
1847
|
-
}
|
|
3677
|
+
return executeWithdrawERC721(ethSigner, assetType.asset_type, starkPublicKey, token.tokenId, imxConfig);
|
|
1848
3678
|
}
|
|
1849
3679
|
async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token, config, }) {
|
|
1850
3680
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
1851
|
-
const tokenAddress = token
|
|
1852
|
-
const tokenId = token
|
|
3681
|
+
const { tokenAddress } = token;
|
|
3682
|
+
const { tokenId } = token;
|
|
1853
3683
|
const imxConfig = config.immutableXConfig;
|
|
1854
3684
|
const mintsApi = new MintsApi(imxConfig.apiConfiguration);
|
|
1855
3685
|
return await mintsApi
|
|
@@ -1861,7 +3691,7 @@ async function completeERC721WithdrawalAction({ ethSigner, starkPublicKey, token
|
|
|
1861
3691
|
type: 'ERC721',
|
|
1862
3692
|
data: {
|
|
1863
3693
|
id: tokenId,
|
|
1864
|
-
tokenAddress
|
|
3694
|
+
tokenAddress,
|
|
1865
3695
|
blueprint: mintableToken.data.blueprint,
|
|
1866
3696
|
},
|
|
1867
3697
|
}, config))
|
|
@@ -1895,9 +3725,7 @@ async function completeEthWithdrawalAction({ ethSigner, starkPublicKey, config,
|
|
|
1895
3725
|
if (!isRegistered) {
|
|
1896
3726
|
return executeRegisterAndWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
|
|
1897
3727
|
}
|
|
1898
|
-
|
|
1899
|
-
return executeWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
|
|
1900
|
-
}
|
|
3728
|
+
return executeWithdrawEth(ethSigner, assetType.asset_type, starkPublicKey, imxConfig);
|
|
1901
3729
|
}
|
|
1902
3730
|
|
|
1903
3731
|
async function prepareWithdrawal({ signers, withdrawal, config, }) {
|
|
@@ -1907,7 +3735,11 @@ async function prepareWithdrawal({ signers, withdrawal, config, }) {
|
|
|
1907
3735
|
...withdrawal,
|
|
1908
3736
|
});
|
|
1909
3737
|
}
|
|
3738
|
+
// TODO: remove once fixed
|
|
3739
|
+
// eslint-disable-next-line consistent-return
|
|
1910
3740
|
async function completeWithdrawal({ signers: { ethSigner }, starkPublicKey, token, config, }) {
|
|
3741
|
+
// TODO: please add a reasonable default here
|
|
3742
|
+
// eslint-disable-next-line default-case
|
|
1911
3743
|
switch (token.type) {
|
|
1912
3744
|
case 'ETH':
|
|
1913
3745
|
return completeEthWithdrawalAction({ ethSigner, starkPublicKey, config });
|
|
@@ -1965,6 +3797,18 @@ async function createTrade({ signers: { ethSigner, starkSigner }, request, confi
|
|
|
1965
3797
|
return createTradeResponse.data;
|
|
1966
3798
|
}
|
|
1967
3799
|
|
|
3800
|
+
async function executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config, usersApi) {
|
|
3801
|
+
const etherKey = await ethSigner.getAddress();
|
|
3802
|
+
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
3803
|
+
const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
|
|
3804
|
+
const populatedTransaction = await coreContract.populateTransaction.registerAndDepositEth(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId);
|
|
3805
|
+
return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
|
|
3806
|
+
}
|
|
3807
|
+
async function executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, config) {
|
|
3808
|
+
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
3809
|
+
const populatedTransaction = await coreContract.populateTransaction['deposit(uint256,uint256,uint256)'](starkPublicKey, assetType, vaultId);
|
|
3810
|
+
return ethSigner.sendTransaction({ ...populatedTransaction, value: amount });
|
|
3811
|
+
}
|
|
1968
3812
|
async function depositEth({ signers: { ethSigner }, deposit, config, }) {
|
|
1969
3813
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
1970
3814
|
const user = await ethSigner.getAddress();
|
|
@@ -2002,23 +3846,21 @@ async function depositEth({ signers: { ethSigner }, deposit, config, }) {
|
|
|
2002
3846
|
if (!isRegistered) {
|
|
2003
3847
|
return executeRegisterAndDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig, usersApi);
|
|
2004
3848
|
}
|
|
2005
|
-
|
|
2006
|
-
return executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig);
|
|
2007
|
-
}
|
|
3849
|
+
return executeDepositEth(ethSigner, amount, assetType, starkPublicKey, vaultId, imxConfig);
|
|
2008
3850
|
}
|
|
2009
|
-
|
|
3851
|
+
|
|
3852
|
+
async function executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config, usersApi) {
|
|
2010
3853
|
const etherKey = await ethSigner.getAddress();
|
|
2011
|
-
const coreContract = Contracts.Core.connect(config.
|
|
3854
|
+
const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
|
|
2012
3855
|
const signableResult = await getSignableRegistrationOnchain(etherKey, starkPublicKey, usersApi);
|
|
2013
|
-
const populatedTransaction = await coreContract.populateTransaction.
|
|
2014
|
-
return ethSigner.sendTransaction(
|
|
3856
|
+
const populatedTransaction = await coreContract.populateTransaction.registerAndDepositERC20(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId, quantizedAmount);
|
|
3857
|
+
return ethSigner.sendTransaction(populatedTransaction);
|
|
2015
3858
|
}
|
|
2016
|
-
async function
|
|
2017
|
-
const coreContract = Contracts.Core.connect(config.
|
|
2018
|
-
const populatedTransaction = await coreContract.populateTransaction
|
|
2019
|
-
return ethSigner.sendTransaction(
|
|
3859
|
+
async function executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config) {
|
|
3860
|
+
const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
|
|
3861
|
+
const populatedTransaction = await coreContract.populateTransaction.depositERC20(starkPublicKey, assetType, vaultId, quantizedAmount);
|
|
3862
|
+
return ethSigner.sendTransaction(populatedTransaction);
|
|
2020
3863
|
}
|
|
2021
|
-
|
|
2022
3864
|
async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
2023
3865
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
2024
3866
|
const { apiConfiguration, ethConfiguration } = config.immutableXConfig;
|
|
@@ -2029,6 +3871,8 @@ async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
|
2029
3871
|
const usersApi = new UsersApi(apiConfiguration);
|
|
2030
3872
|
// Get decimals for this specific ERC20
|
|
2031
3873
|
const token = await tokensApi.getToken({ address: deposit.tokenAddress });
|
|
3874
|
+
// TODO: remove once fixed
|
|
3875
|
+
// eslint-disable-next-line radix
|
|
2032
3876
|
const decimals = parseInt(token.data.decimals);
|
|
2033
3877
|
const data = {
|
|
2034
3878
|
decimals,
|
|
@@ -2065,28 +3909,19 @@ async function depositERC20({ signers: { ethSigner }, deposit, config, }) {
|
|
|
2065
3909
|
const assetType = encodingResult.data.asset_type;
|
|
2066
3910
|
const starkPublicKey = signableDepositResult.data.stark_key;
|
|
2067
3911
|
const vaultId = signableDepositResult.data.vault_id;
|
|
2068
|
-
const quantizedAmount = BigNumber.from(signableDepositResult.data.amount);
|
|
3912
|
+
const quantizedAmount = BigNumber$1.from(signableDepositResult.data.amount);
|
|
2069
3913
|
const isRegistered = await isRegisteredOnChain(starkPublicKey, ethSigner, config);
|
|
2070
3914
|
if (!isRegistered) {
|
|
2071
3915
|
return executeRegisterAndDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration, usersApi);
|
|
2072
3916
|
}
|
|
2073
|
-
|
|
2074
|
-
return executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration);
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
async function executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, config) {
|
|
2078
|
-
const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
|
|
2079
|
-
const populatedTransaction = await coreContract.populateTransaction.depositERC20(starkPublicKey, assetType, vaultId, quantizedAmount);
|
|
2080
|
-
return ethSigner.sendTransaction(populatedTransaction);
|
|
3917
|
+
return executeDepositERC20(ethSigner, quantizedAmount, assetType, starkPublicKey, vaultId, ethConfiguration);
|
|
2081
3918
|
}
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
const coreContract = Contracts.Core.connect(config.coreContractAddress, ethSigner);
|
|
2085
|
-
const
|
|
2086
|
-
const populatedTransaction = await coreContract.populateTransaction.registerAndDepositERC20(etherKey, starkPublicKey, signableResult.operator_signature, assetType, vaultId, quantizedAmount);
|
|
3919
|
+
|
|
3920
|
+
async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
|
|
3921
|
+
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
3922
|
+
const populatedTransaction = await coreContract.populateTransaction.depositNft(starkPublicKey, assetType, vaultId, tokenId);
|
|
2087
3923
|
return ethSigner.sendTransaction(populatedTransaction);
|
|
2088
3924
|
}
|
|
2089
|
-
|
|
2090
3925
|
async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
2091
3926
|
await validateChain(ethSigner, config.immutableXConfig);
|
|
2092
3927
|
const user = await ethSigner.getAddress();
|
|
@@ -2137,18 +3972,18 @@ async function depositERC721({ signers: { ethSigner }, deposit, config, }) {
|
|
|
2137
3972
|
if (!isRegistered) {
|
|
2138
3973
|
const signableResult = await getSignableRegistrationOnchain(user, starkPublicKey, usersApi);
|
|
2139
3974
|
const coreContract = Contracts.Core.connect(immutableXConfig.ethConfiguration.coreContractAddress, ethSigner);
|
|
2140
|
-
// Note: proxy registration contract registerAndDepositNft method is not used as
|
|
3975
|
+
// Note: proxy registration contract registerAndDepositNft method is not used as
|
|
3976
|
+
// it currently fails erc721 transfer ownership check
|
|
2141
3977
|
await coreContract.registerUser(user, starkPublicKey, signableResult.operator_signature);
|
|
2142
3978
|
}
|
|
2143
3979
|
return executeDepositERC721(ethSigner, deposit.tokenId, assetType, starkPublicKey, vaultId, immutableXConfig);
|
|
2144
3980
|
}
|
|
2145
|
-
async function executeDepositERC721(ethSigner, tokenId, assetType, starkPublicKey, vaultId, config) {
|
|
2146
|
-
const coreContract = Contracts.Core.connect(config.ethConfiguration.coreContractAddress, ethSigner);
|
|
2147
|
-
const populatedTransaction = await coreContract.populateTransaction.depositNft(starkPublicKey, assetType, vaultId, tokenId);
|
|
2148
|
-
return ethSigner.sendTransaction(populatedTransaction);
|
|
2149
|
-
}
|
|
2150
3981
|
|
|
3982
|
+
// TODO: remove once fixed deposit variable shadowing
|
|
3983
|
+
// eslint-disable-next-line consistent-return, @typescript-eslint/no-shadow
|
|
2151
3984
|
async function deposit({ signers, deposit, config }) {
|
|
3985
|
+
// TODO: please add a reasonable default here
|
|
3986
|
+
// eslint-disable-next-line default-case
|
|
2152
3987
|
switch (deposit.type) {
|
|
2153
3988
|
case 'ETH':
|
|
2154
3989
|
return depositEth({ signers, deposit, config });
|
|
@@ -2286,7 +4121,10 @@ class GenericIMXProvider {
|
|
|
2286
4121
|
}
|
|
2287
4122
|
|
|
2288
4123
|
const WALLET_ACTION = {
|
|
4124
|
+
// TODO: remove once fixed - consider using an enum
|
|
4125
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2289
4126
|
SWITCH_CHAIN: 'wallet_switchEthereumChain',
|
|
4127
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2290
4128
|
CONNECT: 'eth_requestAccounts',
|
|
2291
4129
|
};
|
|
2292
4130
|
function isRequestableProvider(provider) {
|
|
@@ -2303,6 +4141,8 @@ async function connectProvider(provider, chainID) {
|
|
|
2303
4141
|
}
|
|
2304
4142
|
|
|
2305
4143
|
const ERRORS = {
|
|
4144
|
+
// TODO: remove once fixed - consider using something in line with the naming convention
|
|
4145
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2306
4146
|
PROVIDER_NOT_FOUND: 'The Metamask provider was not found',
|
|
2307
4147
|
};
|
|
2308
4148
|
async function connect$1({ chainID, }) {
|
|
@@ -2477,9 +4317,6 @@ const withProviderError = async (fn, customError) => {
|
|
|
2477
4317
|
|
|
2478
4318
|
class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
2479
4319
|
static imxSigner;
|
|
2480
|
-
constructor(config, ethSigner, starkSigner) {
|
|
2481
|
-
super(config, ethSigner, starkSigner);
|
|
2482
|
-
}
|
|
2483
4320
|
static async connect(config) {
|
|
2484
4321
|
return await withProviderError(async () => {
|
|
2485
4322
|
const metaMaskProvider = await connect$1({
|
|
@@ -2501,9 +4338,7 @@ class MetaMaskIMXProvider extends GenericIMXProvider {
|
|
|
2501
4338
|
if (!this.imxSigner) {
|
|
2502
4339
|
throw new ProviderError('Attempted to sign a message with the MetaMask IMX provider without an established connection', ProviderErrorType.PROVIDER_CONNECTION_ERROR);
|
|
2503
4340
|
}
|
|
2504
|
-
return withProviderError(async () => {
|
|
2505
|
-
return await this.imxSigner.signMessage(message);
|
|
2506
|
-
}, { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
|
|
4341
|
+
return withProviderError(async () => await this.imxSigner.signMessage(message), { type: ProviderErrorType.PROVIDER_CONNECTION_ERROR });
|
|
2507
4342
|
}
|
|
2508
4343
|
}
|
|
2509
4344
|
|
|
@@ -2516,6 +4351,8 @@ class ProviderConfiguration {
|
|
|
2516
4351
|
this.immutableXConfig = overrides.immutableXConfig;
|
|
2517
4352
|
}
|
|
2518
4353
|
else {
|
|
4354
|
+
// TODO: remove once a sensible default is chosen
|
|
4355
|
+
// eslint-disable-next-line default-case
|
|
2519
4356
|
switch (baseConfig.environment) {
|
|
2520
4357
|
case Environment.SANDBOX: {
|
|
2521
4358
|
this.immutableXConfig = Config.SANDBOX;
|
|
@@ -2595,6 +4432,14 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
2595
4432
|
];
|
|
2596
4433
|
|
|
2597
4434
|
|
|
4435
|
+
|
|
4436
|
+
const $bc2bfebf768286d3$export$6a2ba3c3bd042990 = {
|
|
4437
|
+
baseConfig: {
|
|
4438
|
+
environment: (Environment).SANDBOX
|
|
4439
|
+
}
|
|
4440
|
+
};
|
|
4441
|
+
|
|
4442
|
+
|
|
2598
4443
|
let $d176a05e966364ba$export$3bfad4d03ada24c4;
|
|
2599
4444
|
(function(ConnectionProviders) {
|
|
2600
4445
|
ConnectionProviders["METAMASK"] = "metamask";
|
|
@@ -2604,62 +4449,126 @@ let $d176a05e966364ba$export$3bfad4d03ada24c4;
|
|
|
2604
4449
|
let $a47e48dd2c04791b$export$c06e1e7429de6283;
|
|
2605
4450
|
(function(ChainId) {
|
|
2606
4451
|
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
2607
|
-
ChainId[ChainId["
|
|
2608
|
-
ChainId[ChainId["
|
|
4452
|
+
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
|
4453
|
+
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13373] = "IMTBL_ZKEVM_DEVNET";
|
|
4454
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13372] = "IMTBL_ZKEVM_TESTNET";
|
|
4455
|
+
ChainId[ChainId["POLYGON_ZKEVM_TESTNET"] = 1442] = "POLYGON_ZKEVM_TESTNET";
|
|
4456
|
+
ChainId[ChainId["POLYGON_ZKEVM"] = 137] = "POLYGON_ZKEVM";
|
|
2609
4457
|
})($a47e48dd2c04791b$export$c06e1e7429de6283 || ($a47e48dd2c04791b$export$c06e1e7429de6283 = {}));
|
|
2610
|
-
const $a47e48dd2c04791b$export$
|
|
2611
|
-
[
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
"
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
}
|
|
4458
|
+
const $a47e48dd2c04791b$export$6f24f3cef7d501c4 = new Map([
|
|
4459
|
+
[
|
|
4460
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.ETHEREUM,
|
|
4461
|
+
{
|
|
4462
|
+
chainIdHex: "0x1",
|
|
4463
|
+
chainName: "Ethereum",
|
|
4464
|
+
rpcUrls: [
|
|
4465
|
+
"https://mainnet.infura.io/v3/"
|
|
4466
|
+
],
|
|
4467
|
+
nativeCurrency: {
|
|
4468
|
+
name: "Ethereum",
|
|
4469
|
+
symbol: "ETH",
|
|
4470
|
+
decimals: 18
|
|
4471
|
+
},
|
|
4472
|
+
blockExplorerUrls: [
|
|
4473
|
+
"https://etherscan.io/"
|
|
4474
|
+
]
|
|
4475
|
+
}
|
|
4476
|
+
],
|
|
4477
|
+
[
|
|
4478
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.IMTBL_ZKEVM_TESTNET,
|
|
4479
|
+
{
|
|
4480
|
+
chainIdHex: "0x343C",
|
|
4481
|
+
chainName: "Immutable zkEVM Testnet",
|
|
4482
|
+
rpcUrls: [
|
|
4483
|
+
"https://zkevm-rpc.sandbox.x.immutable.com"
|
|
4484
|
+
],
|
|
4485
|
+
nativeCurrency: {
|
|
4486
|
+
name: "IMX",
|
|
4487
|
+
symbol: "IMX",
|
|
4488
|
+
decimals: 18
|
|
4489
|
+
}
|
|
4490
|
+
}
|
|
4491
|
+
],
|
|
4492
|
+
[
|
|
4493
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.POLYGON_ZKEVM,
|
|
4494
|
+
{
|
|
4495
|
+
chainIdHex: "0x89",
|
|
4496
|
+
chainName: "Polygon zkEVM",
|
|
4497
|
+
rpcUrls: [
|
|
4498
|
+
"https://polygon-rpc.com"
|
|
4499
|
+
],
|
|
4500
|
+
nativeCurrency: {
|
|
4501
|
+
name: "MATIC",
|
|
4502
|
+
symbol: "MATIC",
|
|
4503
|
+
decimals: 18
|
|
4504
|
+
},
|
|
4505
|
+
blockExplorerUrls: [
|
|
4506
|
+
"https://polygonscan.com/"
|
|
4507
|
+
]
|
|
4508
|
+
}
|
|
4509
|
+
]
|
|
4510
|
+
]);
|
|
4511
|
+
const $a47e48dd2c04791b$export$3e81fc0987227f10 = new Map([
|
|
4512
|
+
[
|
|
4513
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.SEPOLIA,
|
|
4514
|
+
{
|
|
4515
|
+
chainIdHex: "0xaa36a7",
|
|
4516
|
+
chainName: "Sepolia",
|
|
4517
|
+
rpcUrls: [
|
|
4518
|
+
"https://sepolia.infura.io/v3/"
|
|
4519
|
+
],
|
|
4520
|
+
nativeCurrency: {
|
|
4521
|
+
name: "Sep Eth",
|
|
4522
|
+
symbol: "ETH",
|
|
4523
|
+
decimals: 18
|
|
4524
|
+
},
|
|
4525
|
+
blockExplorerUrls: [
|
|
4526
|
+
"https://sepolia.etherscan.io/"
|
|
4527
|
+
]
|
|
4528
|
+
}
|
|
4529
|
+
],
|
|
4530
|
+
[
|
|
4531
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.IMTBL_ZKEVM_DEVNET,
|
|
4532
|
+
{
|
|
4533
|
+
chainIdHex: "0x343D",
|
|
4534
|
+
chainName: "Immutable zkEVM Devnet",
|
|
4535
|
+
rpcUrls: [
|
|
4536
|
+
"https://zkevm-rpc.dev.x.immutable.com/"
|
|
4537
|
+
],
|
|
4538
|
+
nativeCurrency: {
|
|
4539
|
+
name: "IMX",
|
|
4540
|
+
symbol: "IMX",
|
|
4541
|
+
decimals: 18
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
],
|
|
4545
|
+
[
|
|
4546
|
+
$a47e48dd2c04791b$export$c06e1e7429de6283.POLYGON_ZKEVM_TESTNET,
|
|
4547
|
+
{
|
|
4548
|
+
chainIdHex: "0x5A2",
|
|
4549
|
+
chainName: "Polygon zkEVM Testnet",
|
|
4550
|
+
rpcUrls: [
|
|
4551
|
+
"https://rpc.public.zkevm-test.net"
|
|
4552
|
+
],
|
|
4553
|
+
nativeCurrency: {
|
|
4554
|
+
name: "MATIC",
|
|
4555
|
+
symbol: "MATIC",
|
|
4556
|
+
decimals: 18
|
|
4557
|
+
},
|
|
4558
|
+
blockExplorerUrls: [
|
|
4559
|
+
"https://testnet-zkevm.polygonscan.com"
|
|
4560
|
+
]
|
|
4561
|
+
}
|
|
4562
|
+
]
|
|
4563
|
+
]);
|
|
2657
4564
|
let $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
2658
4565
|
(function(NetworkFilterTypes) {
|
|
2659
4566
|
NetworkFilterTypes["ALL"] = "all";
|
|
2660
4567
|
})($a47e48dd2c04791b$export$1f05a55fe0680cc7 || ($a47e48dd2c04791b$export$1f05a55fe0680cc7 = {}));
|
|
2661
4568
|
|
|
2662
4569
|
|
|
4570
|
+
// TODO: fix circular dependency
|
|
4571
|
+
// eslint-disable-next-line import/no-cycle
|
|
2663
4572
|
let $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
2664
4573
|
(function(TokenFilterTypes) {
|
|
2665
4574
|
TokenFilterTypes["SWAP"] = "swap";
|
|
@@ -2670,12 +4579,15 @@ let $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
|
2670
4579
|
|
|
2671
4580
|
|
|
2672
4581
|
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
4582
|
+
// TODO: fix circular dependency
|
|
4583
|
+
// eslint-disable-next-line import/no-cycle
|
|
4584
|
+
let $4f91c5f280efe242$export$35b06f0d33f57e26;
|
|
4585
|
+
(function(WalletAction) {
|
|
4586
|
+
WalletAction["CHECK_CONNECTION"] = "eth_accounts";
|
|
4587
|
+
WalletAction["CONNECT"] = "eth_requestAccounts";
|
|
4588
|
+
WalletAction["ADD_NETWORK"] = "wallet_addEthereumChain";
|
|
4589
|
+
WalletAction["SWITCH_NETWORK"] = "wallet_switchEthereumChain";
|
|
4590
|
+
})($4f91c5f280efe242$export$35b06f0d33f57e26 || ($4f91c5f280efe242$export$35b06f0d33f57e26 = {}));
|
|
2679
4591
|
let $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
2680
4592
|
(function(WalletFilterTypes) {
|
|
2681
4593
|
WalletFilterTypes["ALL"] = "all";
|
|
@@ -2684,12 +4596,6 @@ let $4f91c5f280efe242$export$a75605c67ea83a5a;
|
|
|
2684
4596
|
})($4f91c5f280efe242$export$a75605c67ea83a5a || ($4f91c5f280efe242$export$a75605c67ea83a5a = {}));
|
|
2685
4597
|
|
|
2686
4598
|
|
|
2687
|
-
let $090d3502d165f17d$export$c5ab8fbcabac8c11;
|
|
2688
|
-
(function(SupportedFiatCurrencies) {
|
|
2689
|
-
SupportedFiatCurrencies["USD"] = "USD";
|
|
2690
|
-
})($090d3502d165f17d$export$c5ab8fbcabac8c11 || ($090d3502d165f17d$export$c5ab8fbcabac8c11 = {}));
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
4599
|
|
|
2694
4600
|
|
|
2695
4601
|
/**
|
|
@@ -2707,9 +4613,6 @@ let $090d3502d165f17d$export$c5ab8fbcabac8c11;
|
|
|
2707
4613
|
CheckoutErrorType["PROVIDER_REQUEST_FAILED_ERROR"] = "PROVIDER_REQUEST_FAILED_ERROR";
|
|
2708
4614
|
CheckoutErrorType["USER_REJECTED_REQUEST_ERROR"] = "USER_REJECTED_REQUEST_ERROR";
|
|
2709
4615
|
CheckoutErrorType["TRANSACTION_ERROR"] = "TRANSACTION_ERROR";
|
|
2710
|
-
CheckoutErrorType["FIAT_CONVERSION_ERROR"] = "FIAT_CONVERSION_ERROR";
|
|
2711
|
-
CheckoutErrorType["TOKEN_NOT_SUPPORTED_ERROR"] = "TOKEN_NOT_SUPPORTED_ERROR";
|
|
2712
|
-
CheckoutErrorType["FIAT_CURRENCY_NOT_SUPPORTED_ERROR"] = "FIAT_CURRENCY_NOT_SUPPORTED_ERROR";
|
|
2713
4616
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
2714
4617
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
2715
4618
|
constructor(message, type, data){
|
|
@@ -2749,6 +4652,24 @@ const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
|
|
|
2749
4652
|
|
|
2750
4653
|
|
|
2751
4654
|
|
|
4655
|
+
async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
4656
|
+
const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>await (detectEthereumProvider)(), {
|
|
4657
|
+
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
|
|
4658
|
+
});
|
|
4659
|
+
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
4660
|
+
return new (Web3Provider)(provider);
|
|
4661
|
+
}
|
|
4662
|
+
async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
|
|
4663
|
+
let web3Provider = null;
|
|
4664
|
+
switch(providerPreference){
|
|
4665
|
+
case ($d176a05e966364ba$export$3bfad4d03ada24c4).METAMASK:
|
|
4666
|
+
web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
|
|
4667
|
+
break;
|
|
4668
|
+
default:
|
|
4669
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference is not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_PREFERENCE_ERROR);
|
|
4670
|
+
}
|
|
4671
|
+
return web3Provider;
|
|
4672
|
+
}
|
|
2752
4673
|
async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
2753
4674
|
const provider = await $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference);
|
|
2754
4675
|
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
@@ -2757,12 +4678,12 @@ async function $c99672cf2294e839$export$2d040992269b4717(providerPreference) {
|
|
|
2757
4678
|
let accounts = [];
|
|
2758
4679
|
try {
|
|
2759
4680
|
accounts = await provider.provider.request({
|
|
2760
|
-
method: (0, $4f91c5f280efe242$export$
|
|
4681
|
+
method: (0, $4f91c5f280efe242$export$35b06f0d33f57e26).CHECK_CONNECTION,
|
|
2761
4682
|
params: []
|
|
2762
4683
|
});
|
|
2763
4684
|
} catch (err) {
|
|
2764
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(
|
|
2765
|
-
rpcMethod: ($4f91c5f280efe242$export$
|
|
4685
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Check wallet connection request failed", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_FAILED_ERROR, {
|
|
4686
|
+
rpcMethod: ($4f91c5f280efe242$export$35b06f0d33f57e26).CHECK_CONNECTION
|
|
2766
4687
|
});
|
|
2767
4688
|
}
|
|
2768
4689
|
// accounts[0] will have the active account if connected.
|
|
@@ -2779,7 +4700,7 @@ async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
|
|
|
2779
4700
|
});
|
|
2780
4701
|
// this makes the request to the wallet to connect i.e request eth accounts ('eth_requestAccounts')
|
|
2781
4702
|
await web3Provider.provider.request({
|
|
2782
|
-
method: ($4f91c5f280efe242$export$
|
|
4703
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).CONNECT,
|
|
2783
4704
|
params: []
|
|
2784
4705
|
});
|
|
2785
4706
|
}, {
|
|
@@ -2787,43 +4708,57 @@ async function $c99672cf2294e839$export$fba2f6c3656e07c1(params) {
|
|
|
2787
4708
|
});
|
|
2788
4709
|
return web3Provider;
|
|
2789
4710
|
}
|
|
2790
|
-
async function $c99672cf2294e839$var$getWalletProviderForPreference(providerPreference) {
|
|
2791
|
-
let web3Provider = null;
|
|
2792
|
-
switch(providerPreference){
|
|
2793
|
-
case ($d176a05e966364ba$export$3bfad4d03ada24c4).METAMASK:
|
|
2794
|
-
web3Provider = await $c99672cf2294e839$var$getMetaMaskProvider();
|
|
2795
|
-
break;
|
|
2796
|
-
default:
|
|
2797
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider preference is not supported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_PREFERENCE_ERROR);
|
|
2798
|
-
}
|
|
2799
|
-
return web3Provider;
|
|
2800
|
-
}
|
|
2801
|
-
async function $c99672cf2294e839$var$getMetaMaskProvider() {
|
|
2802
|
-
const provider = await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2803
|
-
return await (detectEthereumProvider)();
|
|
2804
|
-
}, {
|
|
2805
|
-
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR
|
|
2806
|
-
});
|
|
2807
|
-
if (!provider || !provider.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No MetaMask provider installed.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).METAMASK_PROVIDER_ERROR);
|
|
2808
|
-
return new (Web3Provider)(provider);
|
|
2809
|
-
}
|
|
2810
4711
|
|
|
2811
4712
|
|
|
2812
4713
|
var $497c134ecbc8a50f$exports = {};
|
|
2813
|
-
$497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":137}]');
|
|
4714
|
+
$497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":11155111},{"chainId":13372},{"chainId":13373},{"chainId":1442},{"chainId":137}]');
|
|
2814
4715
|
|
|
2815
4716
|
|
|
2816
4717
|
const $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE = 4902; // error code (MetaMask)
|
|
2817
|
-
|
|
4718
|
+
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
4719
|
+
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
4720
|
+
// eslint-disable-next-line consistent-return
|
|
4721
|
+
async function $de192de6ef100f9f$var$switchNetworkInWallet(networkMap, provider, chainId) {
|
|
4722
|
+
if (provider.provider?.request) return await provider.provider.request({
|
|
4723
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).SWITCH_NETWORK,
|
|
4724
|
+
params: [
|
|
4725
|
+
{
|
|
4726
|
+
chainId: networkMap.get(chainId)?.chainIdHex
|
|
4727
|
+
}
|
|
4728
|
+
]
|
|
4729
|
+
});
|
|
4730
|
+
}
|
|
4731
|
+
// TODO: Should these functions always return something?
|
|
4732
|
+
// eslint-disable-next-line consistent-return
|
|
4733
|
+
async function $de192de6ef100f9f$var$addNetworkToWallet(networkMap, provider, chainId) {
|
|
4734
|
+
if (provider.provider?.request) {
|
|
4735
|
+
const networkDetails = networkMap.get(chainId);
|
|
4736
|
+
const addNetwork = {
|
|
4737
|
+
chainId: networkDetails?.chainIdHex,
|
|
4738
|
+
chainName: networkDetails?.chainName,
|
|
4739
|
+
rpcUrls: networkDetails?.rpcUrls,
|
|
4740
|
+
nativeCurrency: networkDetails?.nativeCurrency,
|
|
4741
|
+
blockExplorerUrls: networkDetails?.blockExplorerUrls
|
|
4742
|
+
};
|
|
4743
|
+
return await provider.provider.request({
|
|
4744
|
+
method: ($4f91c5f280efe242$export$35b06f0d33f57e26).ADD_NETWORK,
|
|
4745
|
+
params: [
|
|
4746
|
+
addNetwork
|
|
4747
|
+
]
|
|
4748
|
+
});
|
|
4749
|
+
}
|
|
4750
|
+
}
|
|
4751
|
+
async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(config, provider) {
|
|
4752
|
+
const { networkMap: networkMap } = config;
|
|
2818
4753
|
return ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2819
4754
|
const network = await provider.getNetwork();
|
|
2820
|
-
if (!
|
|
4755
|
+
if (!Array.from(networkMap.keys()).includes(network.chainId)) // return empty details
|
|
2821
4756
|
return {
|
|
2822
4757
|
chainId: network.chainId,
|
|
2823
4758
|
name: network.name,
|
|
2824
4759
|
isSupported: false
|
|
2825
4760
|
};
|
|
2826
|
-
const chainIdNetworkInfo = (
|
|
4761
|
+
const chainIdNetworkInfo = networkMap.get(network.chainId);
|
|
2827
4762
|
return {
|
|
2828
4763
|
name: chainIdNetworkInfo.chainName,
|
|
2829
4764
|
chainId: parseInt(chainIdNetworkInfo.chainIdHex, 16),
|
|
@@ -2834,18 +4769,20 @@ async function $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider) {
|
|
|
2834
4769
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_NETWORK_INFO_ERROR
|
|
2835
4770
|
});
|
|
2836
4771
|
}
|
|
2837
|
-
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(providerPreference, provider, chainId) {
|
|
4772
|
+
async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, providerPreference, provider, chainId) {
|
|
2838
4773
|
let currentProvider = provider;
|
|
4774
|
+
const { networkMap: networkMap } = config;
|
|
2839
4775
|
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
2840
4776
|
if (!currentProvider || !currentProvider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Incompatible provider", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR, {
|
|
2841
|
-
details:
|
|
4777
|
+
details: "Unsupported provider"
|
|
2842
4778
|
});
|
|
2843
4779
|
// WT-1146 - Refer to the README in this folder for explantion on the switch network flow
|
|
2844
4780
|
try {
|
|
2845
|
-
await $de192de6ef100f9f$var$switchNetworkInWallet(currentProvider, chainId);
|
|
4781
|
+
await $de192de6ef100f9f$var$switchNetworkInWallet(networkMap, currentProvider, chainId);
|
|
2846
4782
|
} catch (err) {
|
|
2847
4783
|
if (err.code === $de192de6ef100f9f$var$UNRECOGNISED_CHAIN_ERROR_CODE) try {
|
|
2848
|
-
await $de192de6ef100f9f$var$addNetworkToWallet(currentProvider, chainId);
|
|
4784
|
+
await $de192de6ef100f9f$var$addNetworkToWallet(networkMap, currentProvider, chainId);
|
|
4785
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
2849
4786
|
} catch (err) {
|
|
2850
4787
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled add network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2851
4788
|
}
|
|
@@ -2858,17 +4795,18 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(providerPreference, pro
|
|
|
2858
4795
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("User cancelled switch network request", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).USER_REJECTED_REQUEST_ERROR);
|
|
2859
4796
|
// we can assume that if the above succeeds then user has successfully
|
|
2860
4797
|
// switched to the network specified
|
|
2861
|
-
const newNetwork = (
|
|
4798
|
+
const newNetwork = networkMap.get(chainId);
|
|
2862
4799
|
return {
|
|
2863
4800
|
network: {
|
|
2864
|
-
name: newNetwork
|
|
2865
|
-
chainId: parseInt(newNetwork
|
|
2866
|
-
nativeCurrency: newNetwork
|
|
4801
|
+
name: newNetwork?.chainName,
|
|
4802
|
+
chainId: parseInt(newNetwork?.chainIdHex ?? "", 16),
|
|
4803
|
+
nativeCurrency: newNetwork?.nativeCurrency
|
|
2867
4804
|
},
|
|
2868
4805
|
provider: currentProvider
|
|
2869
4806
|
};
|
|
2870
4807
|
}
|
|
2871
|
-
async function $de192de6ef100f9f$export$3043f6442a9ef563({ type: type = ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL , exclude: exclude }) {
|
|
4808
|
+
async function $de192de6ef100f9f$export$3043f6442a9ef563(config, { type: type = ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL , exclude: exclude }) {
|
|
4809
|
+
const { networkMap: networkMap } = config;
|
|
2872
4810
|
const list = ((/*@__PURE__*/$parcel$interopDefault($497c134ecbc8a50f$exports))).filter((network)=>{
|
|
2873
4811
|
const allowAllTokens = type === ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL;
|
|
2874
4812
|
const networkNotExcluded = !(exclude || []).map((exc)=>exc.chainId).includes(network.chainId);
|
|
@@ -2876,8 +4814,8 @@ async function $de192de6ef100f9f$export$3043f6442a9ef563({ type: type = ($a47e48
|
|
|
2876
4814
|
});
|
|
2877
4815
|
const allowedNetworks = [];
|
|
2878
4816
|
list.forEach((element)=>{
|
|
2879
|
-
const newNetwork = (
|
|
2880
|
-
allowedNetworks.push({
|
|
4817
|
+
const newNetwork = networkMap.get(element.chainId);
|
|
4818
|
+
if (newNetwork) allowedNetworks.push({
|
|
2881
4819
|
name: newNetwork.chainName,
|
|
2882
4820
|
chainId: parseInt(newNetwork.chainIdHex, 16),
|
|
2883
4821
|
nativeCurrency: newNetwork.nativeCurrency,
|
|
@@ -2888,64 +4826,35 @@ async function $de192de6ef100f9f$export$3043f6442a9ef563({ type: type = ($a47e48
|
|
|
2888
4826
|
networks: allowedNetworks
|
|
2889
4827
|
};
|
|
2890
4828
|
}
|
|
2891
|
-
// these functions should not be exported. These functions should be used as part of an exported function e.g switchWalletNetwork() above.
|
|
2892
|
-
// make sure to check if(provider.provider?.request) in the exported function and throw an error
|
|
2893
|
-
async function $de192de6ef100f9f$var$switchNetworkInWallet(provider, chainId) {
|
|
2894
|
-
if (provider.provider?.request) return await provider.provider.request({
|
|
2895
|
-
method: ($4f91c5f280efe242$export$a130407f3423b97d).SWITCH_NETWORK,
|
|
2896
|
-
params: [
|
|
2897
|
-
{
|
|
2898
|
-
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex
|
|
2899
|
-
}
|
|
2900
|
-
]
|
|
2901
|
-
});
|
|
2902
|
-
}
|
|
2903
|
-
async function $de192de6ef100f9f$var$addNetworkToWallet(provider, chainId) {
|
|
2904
|
-
if (provider.provider?.request) {
|
|
2905
|
-
const addNetwork = {
|
|
2906
|
-
chainId: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainIdHex,
|
|
2907
|
-
chainName: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].chainName,
|
|
2908
|
-
rpcUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].rpcUrls,
|
|
2909
|
-
nativeCurrency: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].nativeCurrency,
|
|
2910
|
-
blockExplorerUrls: ($a47e48dd2c04791b$export$f61f4aaec62f6be9)[chainId].blockExplorerUrls
|
|
2911
|
-
};
|
|
2912
|
-
return await provider.provider.request({
|
|
2913
|
-
method: ($4f91c5f280efe242$export$a130407f3423b97d).ADD_NETWORK,
|
|
2914
|
-
params: [
|
|
2915
|
-
addNetwork
|
|
2916
|
-
]
|
|
2917
|
-
});
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
4829
|
|
|
2921
4830
|
|
|
2922
4831
|
|
|
2923
4832
|
|
|
2924
4833
|
|
|
2925
4834
|
var $cda6003506e4182e$exports = {};
|
|
2926
|
-
$cda6003506e4182e$exports = JSON.parse("[{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":137,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":1,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF\",\"chainId\":1,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0\",\"chainId\":1,\"name\":\"Matic\",\"symbol\":\"MATIC\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 38.4 33.5' style='enable-background:new 0 0 38.4 33.5;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bfill:%238247E5;%7D%0A%3C/style%3E%3Cg%3E%3Cpath class='st0' d='M29,10.2c-0.7-0.4-1.6-0.4-2.4,0L21,13.5l-3.8,2.1l-5.5,3.3c-0.7,0.4-1.6,0.4-2.4,0L5,16.3 c-0.7-0.4-1.2-1.2-1.2-2.1v-5c0-0.8,0.4-1.6,1.2-2.1l4.3-2.5c0.7-0.4,1.6-0.4,2.4,0L16,7.2c0.7,0.4,1.2,1.2,1.2,2.1v3.3l3.8-2.2V7 c0-0.8-0.4-1.6-1.2-2.1l-8-4.7c-0.7-0.4-1.6-0.4-2.4,0L1.2,5C0.4,5.4,0,6.2,0,7v9.4c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l5.5-3.2l3.8-2.2l5.5-3.2c0.7-0.4,1.6-0.4,2.4,0l4.3,2.5c0.7,0.4,1.2,1.2,1.2,2.1v5c0,0.8-0.4,1.6-1.2,2.1 L29,28.8c-0.7,0.4-1.6,0.4-2.4,0l-4.3-2.5c-0.7-0.4-1.2-1.2-1.2-2.1V21l-3.8,2.2v3.3c0,0.8,0.4,1.6,1.2,2.1l8.1,4.7 c0.7,0.4,1.6,0.4,2.4,0l8.1-4.7c0.7-0.4,1.2-1.2,1.2-2.1V17c0-0.8-0.4-1.6-1.2-2.1L29,10.2z'/%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"name\":\"Ethereum\",\"symbol\":\"ETH\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg xmlns='http://www.w3.org/2000/svg' xml:space='preserve' width='100%25' height='100%25' version='1.1' shape-rendering='geometricPrecision' text-rendering='geometricPrecision' image-rendering='optimizeQuality' fill-rule='evenodd' clip-rule='evenodd'%0AviewBox='0 0 784.37 1277.39' xmlns:xlink='http://www.w3.org/1999/xlink' xmlns:xodm='http://www.corel.com/coreldraw/odm/2003'%3E%3Cg id='Layer_x0020_1'%3E%3Cmetadata id='CorelCorpID_0Corel-Layer'/%3E%3Cg id='_1421394342400'%3E%3Cg%3E%3Cpolygon fill='%23343434' fill-rule='nonzero' points='392.07,0 383.5,29.11 383.5,873.74 392.07,882.29 784.13,650.54 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,0 -0,650.54 392.07,882.29 392.07,472.33 '/%3E%3Cpolygon fill='%233C3C3B' fill-rule='nonzero' points='392.07,956.52 387.24,962.41 387.24,1263.28 392.07,1277.38 784.37,724.89 '/%3E%3Cpolygon fill='%238C8C8C' fill-rule='nonzero' points='392.07,1277.38 392.07,956.52 -0,724.89 '/%3E%3Cpolygon fill='%23141414' fill-rule='nonzero' points='392.07,882.29 784.13,650.54 392.07,472.33 '/%3E%3Cpolygon fill='%23393939' fill-rule='nonzero' points='0,650.54 392.07,882.29 392.07,472.33 '/%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"chainId\":5,\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x1facdd0165489f373255a90304650e15481b2c85\",\"chainId\":5,\"name\":\"Immutable X\",\"symbol\":\"IMX\",\"decimals\":18,\"icon\":\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 139 113' style='enable-background:new 0 0 139 113;' xml:space='preserve'%3E%3Cstyle type='text/css'%3E .st0%7Bclip-path:url(%23SVGID_00000053504646934646330740000009134454895836103350_);%7D .st1%7Bfill:%2317B5CB;%7D%0A%3C/style%3E%3Cg%3E%3Cdefs%3E%3Crect id='SVGID_1_' width='139' height='113'/%3E%3C/defs%3E%3CclipPath id='SVGID_00000035518931339590433170000002358037249938198420_'%3E%3Cuse xlink:href='%23SVGID_1_' style='overflow:visible;'/%3E%3C/clipPath%3E%3Cg style='clip-path:url(%23SVGID_00000035518931339590433170000002358037249938198420_);'%3E%3Cpath class='st1' d='M124.1,0h14.6L79.5,67.6c-1.5,1.7-1.6,4.3-0.1,6.1l34.1,39.7H98.3L66.8,76.6l-1.6-2c-1.5-1.7-1.4-4.4,0.1-6.1 L124.1,0z'/%3E%3Cpath class='st1' d='M91.2,73.7c-1-1.1-1.3-2.7-1-4.1c0.3-0.8,0.8-1.6,1.4-2.2l3.9-4.3l43.5,50.3h-13.8 C125.2,113.4,99.7,83.6,91.2,73.7z'/%3E%3Cpath class='st1' d='M15.2,113.4H0l46.6-53.9c1.5-1.7,1.5-4.3,0-6L0.4,0H15l46.5,53.9c1.2,1.6,1.4,3.9,0.1,5.4 C49.4,73.4,15.2,113.4,15.2,113.4z'/%3E%3Cpath class='st1' d='M40.6,0h-14l43.1,49.9c0,0,0.1-0.1,4.9-5.8c1.3-1.5,1.6-3.4,0.1-4.9C65.7,30,40.6,0,40.6,0z'/%3E%3Cpath class='st1' d='M82.6,34.8L112.5,0H98.3L82.7,18.2l-4.5,5.3c-1.5,1.7-1.6,4.3-0.1,6.1C79.2,30.9,82.6,34.8,82.6,34.8z'/%3E%3Cpath class='st1' d='M56.6,78.6l-29.9,34.8h14.1l15.6-18.2l4.5-5.3c1.5-1.7,1.6-4.3,0.1-6.1C59.9,82.5,56.6,78.6,56.6,78.6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A\",\"tokenFeatures\":[\"swap\",\"bridge\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Swap Coin\",\"symbol\":\"SWC\",\"decimals\":18,\"tokenFeatures\":[\"swap\",\"fakeFeature\"]},{\"address\":\"0x123456789\",\"chainId\":5,\"name\":\"Bridge Coin\",\"symbol\":\"BDC\",\"decimals\":18,\"tokenFeatures\":[\"bridge\",\"fakeFeature\"]}]");
|
|
4835
|
+
$cda6003506e4182e$exports = JSON.parse("[{\"chainId\":13373,\"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\":13373,\"name\":\"FUN token\",\"address\":\"0xd8f1D29a1572FbCeF0B0C9541E50637Ad8804F21\",\"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\":13373,\"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\":13373,\"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\",\"bridge\"]},{\"chainId\":11155111,\"name\":\"Immutable Test token\",\"address\":\"0x40cAdc2BC5d25B9c669B8E09c68eCcb9B80873f7\",\"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\":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\"]}]");
|
|
2927
4836
|
|
|
2928
4837
|
|
|
2929
|
-
const $efe60cea83bfc4e8$var$filterTokenList =
|
|
2930
|
-
return ((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
|
|
4838
|
+
const $efe60cea83bfc4e8$var$filterTokenList = ({ type: type , chainId: chainId , exclude: exclude })=>((/*@__PURE__*/$parcel$interopDefault($cda6003506e4182e$exports))).filter((token)=>{
|
|
2931
4839
|
const skipChainIdCheck = !chainId;
|
|
2932
|
-
const chainIdMatches = token.chainId
|
|
4840
|
+
const chainIdMatches = token.chainId === chainId;
|
|
2933
4841
|
const tokenNotExcluded = !exclude?.map((excludeToken)=>excludeToken.address).includes(token.address || "");
|
|
2934
4842
|
const allowAllTokens = type === ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL;
|
|
2935
4843
|
const tokenAllowedForType = token.tokenFeatures.includes(type);
|
|
2936
4844
|
return (skipChainIdCheck || chainIdMatches) && tokenNotExcluded && (allowAllTokens || tokenAllowedForType);
|
|
2937
4845
|
});
|
|
2938
|
-
}
|
|
2939
|
-
const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL , chainId: chainId , exclude: exclude }) {
|
|
2940
|
-
// todo:For API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
|
|
4846
|
+
const $efe60cea83bfc4e8$export$473cec51305fdae8 = async ({ type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL , chainId: chainId , exclude: exclude })=>{
|
|
2941
4847
|
const filteredTokenList = $efe60cea83bfc4e8$var$filterTokenList({
|
|
2942
4848
|
type: type,
|
|
2943
4849
|
chainId: chainId,
|
|
2944
4850
|
exclude: exclude
|
|
2945
|
-
}).map((token)=>{
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
4851
|
+
}).map((token)=>({
|
|
4852
|
+
name: token.name,
|
|
4853
|
+
symbol: token.symbol,
|
|
4854
|
+
decimals: token.decimals,
|
|
4855
|
+
address: token.address,
|
|
4856
|
+
icon: token.icon
|
|
4857
|
+
}));
|
|
2949
4858
|
return {
|
|
2950
4859
|
tokens: filteredTokenList
|
|
2951
4860
|
};
|
|
@@ -2954,9 +4863,8 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async function({ type: type =
|
|
|
2954
4863
|
|
|
2955
4864
|
|
|
2956
4865
|
|
|
2957
|
-
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress)=>{
|
|
2958
|
-
|
|
2959
|
-
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(provider);
|
|
4866
|
+
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
4867
|
+
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, provider);
|
|
2960
4868
|
if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
|
|
2961
4869
|
chainName: networkInfo.name
|
|
2962
4870
|
});
|
|
@@ -2969,7 +4877,6 @@ const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (provider, walletAddress
|
|
|
2969
4877
|
}, {
|
|
2970
4878
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR
|
|
2971
4879
|
});
|
|
2972
|
-
};
|
|
2973
4880
|
async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, contractAddress) {
|
|
2974
4881
|
return await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
2975
4882
|
const contract = new (Contract)(contractAddress, JSON.stringify(($762782b6c862d954$export$db5daa1b5156ccfe)), provider);
|
|
@@ -2992,7 +4899,7 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress
|
|
|
2992
4899
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
2993
4900
|
});
|
|
2994
4901
|
}
|
|
2995
|
-
const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress, chainId)=>{
|
|
4902
|
+
const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, provider, walletAddress, chainId)=>{
|
|
2996
4903
|
if (!Object.values(($a47e48dd2c04791b$export$c06e1e7429de6283)).includes(chainId)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`ChainId ${chainId} is not supported`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR);
|
|
2997
4904
|
if (!provider.provider?.request) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("provider object is missing request function", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_REQUEST_MISSING_ERROR);
|
|
2998
4905
|
const tokenList = await ($efe60cea83bfc4e8$export$473cec51305fdae8)({
|
|
@@ -3000,7 +4907,7 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (provider, walletAddress
|
|
|
3000
4907
|
chainId: chainId
|
|
3001
4908
|
});
|
|
3002
4909
|
const allBalancePromises = [];
|
|
3003
|
-
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(provider, walletAddress));
|
|
4910
|
+
allBalancePromises.push($1564e43dde50bb61$export$df96cd8d56be0ab1(config, provider, walletAddress));
|
|
3004
4911
|
tokenList.tokens.filter((token)=>token.address).forEach((token)=>allBalancePromises.push($1564e43dde50bb61$export$60e0fe116a0e6ed0(provider, walletAddress, token.address ?? "")));
|
|
3005
4912
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
3006
4913
|
const getBalanceResults = balanceResults.filter((result)=>result.status === "fulfilled").map((fulfilledResult)=>fulfilledResult.value);
|
|
@@ -3058,13 +4965,39 @@ const $dbe95599a4661140$export$8e0e7ffc78696d30 = async (params)=>{
|
|
|
3058
4965
|
|
|
3059
4966
|
|
|
3060
4967
|
|
|
4968
|
+
|
|
4969
|
+
|
|
4970
|
+
|
|
4971
|
+
class $4013c5c91bb535f6$export$47a4ed4a38b9eecf extends Error {
|
|
4972
|
+
constructor(message){
|
|
4973
|
+
super(message);
|
|
4974
|
+
this.message = message;
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
|
|
4978
|
+
constructor(config){
|
|
4979
|
+
// validate input
|
|
4980
|
+
if (!Object.values((Environment)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$47a4ed4a38b9eecf("Invalid checkout configuration of environment");
|
|
4981
|
+
this.environment = config.baseConfig.environment;
|
|
4982
|
+
this.networkMap = config.baseConfig.environment === (Environment).PRODUCTION ? ($a47e48dd2c04791b$export$6f24f3cef7d501c4) : ($a47e48dd2c04791b$export$3e81fc0987227f10);
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
|
|
4986
|
+
|
|
4987
|
+
|
|
4988
|
+
|
|
3061
4989
|
class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
4990
|
+
constructor(config = ($bc2bfebf768286d3$export$6a2ba3c3bd042990)){
|
|
4991
|
+
this.config = new ($4013c5c91bb535f6$export$4823433c4a67bbc6)(config);
|
|
4992
|
+
}
|
|
3062
4993
|
/**
|
|
3063
|
-
* Check if a wallet is connected to the current application
|
|
4994
|
+
* Check if a wallet is connected to the current application
|
|
4995
|
+
* without requesting permission from the wallet and hence triggering a connect popup.
|
|
3064
4996
|
* @param {CheckConnectionParams} params - The necessary data required to verify a wallet connection status.
|
|
3065
4997
|
* @returns Wallet connection status details.
|
|
3066
4998
|
* @throws {@link ErrorType}
|
|
3067
|
-
*/
|
|
4999
|
+
*/ // eslint-disable-next-line class-methods-use-this
|
|
5000
|
+
async checkIsWalletConnected(params) {
|
|
3068
5001
|
return $c99672cf2294e839$export$2d040992269b4717(params.providerPreference);
|
|
3069
5002
|
}
|
|
3070
5003
|
/**
|
|
@@ -3075,7 +5008,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3075
5008
|
*/ async connect(params) {
|
|
3076
5009
|
this.providerPreference = params.providerPreference;
|
|
3077
5010
|
const provider = await $c99672cf2294e839$export$fba2f6c3656e07c1(params);
|
|
3078
|
-
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(provider);
|
|
5011
|
+
const networkInfo = await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, provider);
|
|
3079
5012
|
return {
|
|
3080
5013
|
provider: provider,
|
|
3081
5014
|
network: networkInfo
|
|
@@ -3087,25 +5020,28 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3087
5020
|
* @returns The new network information.
|
|
3088
5021
|
* @throws {@link ErrorType}
|
|
3089
5022
|
*/ async switchNetwork(params) {
|
|
3090
|
-
if (!this.providerPreference) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(
|
|
3091
|
-
return await $de192de6ef100f9f$export$b827d9418aeb5dbd(this.providerPreference, params.provider, params.chainId);
|
|
5023
|
+
if (!this.providerPreference) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("connect should be called before switchNetwork to set the provider preference", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_PREFERENCE_ERROR);
|
|
5024
|
+
return await $de192de6ef100f9f$export$b827d9418aeb5dbd(this.config, this.providerPreference, params.provider, params.chainId);
|
|
3092
5025
|
}
|
|
3093
5026
|
/**
|
|
3094
|
-
* Fetch the balance of the native token of the current connected network or,
|
|
5027
|
+
* Fetch the balance of the native token of the current connected network or,
|
|
5028
|
+
* if a contract address is provided, it will return the balance of that ERC20 token. For example,
|
|
5029
|
+
* if the wallet is connected to the Ethereum Mainnet then the function gets the wallet ETH L1 balance.
|
|
3095
5030
|
* @param {GetBalanceParams} params - The necessary data required to fetch the wallet balance.
|
|
3096
5031
|
* @returns Native token balance for the given wallet.
|
|
3097
5032
|
* @throws {@link ErrorType}
|
|
3098
5033
|
*/ async getBalance(params) {
|
|
3099
|
-
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(params.provider, params.walletAddress);
|
|
5034
|
+
if (!params.contractAddress || params.contractAddress === "") return await $1564e43dde50bb61$export$df96cd8d56be0ab1(this.config, params.provider, params.walletAddress);
|
|
3100
5035
|
return await $1564e43dde50bb61$export$60e0fe116a0e6ed0(params.provider, params.walletAddress, params.contractAddress);
|
|
3101
5036
|
}
|
|
3102
5037
|
/**
|
|
3103
|
-
* Fetch all available balances (ERC20 & Native) of the current connected network of the given wallet.
|
|
5038
|
+
* Fetch all available balances (ERC20 & Native) of the current connected network of the given wallet.
|
|
5039
|
+
* It will loop through the list of allowed tokens and check for balance on each one.
|
|
3104
5040
|
* @param {GetAllBalancesParams} params - The necessary data required to fetch all the wallet balances.
|
|
3105
5041
|
* @returns List of tokens balance for the given wallet.
|
|
3106
5042
|
* @throws {@link ErrorType}
|
|
3107
5043
|
*/ async getAllBalances(params) {
|
|
3108
|
-
return $1564e43dde50bb61$export$fee49741664a4d7e(params.provider, params.walletAddress, params.chainId);
|
|
5044
|
+
return $1564e43dde50bb61$export$fee49741664a4d7e(this.config, params.provider, params.walletAddress, params.chainId);
|
|
3109
5045
|
}
|
|
3110
5046
|
/**
|
|
3111
5047
|
* Fetch the list of available networks that a wallet can add or/and switch to.
|
|
@@ -3113,14 +5049,15 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3113
5049
|
* @returns List of networks.
|
|
3114
5050
|
* @throws {@link ErrorType}
|
|
3115
5051
|
*/ async getNetworkAllowList(params) {
|
|
3116
|
-
return await $de192de6ef100f9f$export$3043f6442a9ef563(params);
|
|
5052
|
+
return await $de192de6ef100f9f$export$3043f6442a9ef563(this.config, params);
|
|
3117
5053
|
}
|
|
3118
5054
|
/**
|
|
3119
5055
|
* Get the list of tokens which are allowed to be used with the product.
|
|
3120
5056
|
* @param {GetTokenAllowListParams} params - The necessary data required to fetch the list of allowed tokens.
|
|
3121
5057
|
* @returns List of allowed tokens.
|
|
3122
5058
|
* @throws {@link ErrorType}
|
|
3123
|
-
*/
|
|
5059
|
+
*/ // eslint-disable-next-line class-methods-use-this
|
|
5060
|
+
async getTokenAllowList(params) {
|
|
3124
5061
|
return await $efe60cea83bfc4e8$export$473cec51305fdae8(params);
|
|
3125
5062
|
}
|
|
3126
5063
|
/**
|
|
@@ -3128,7 +5065,8 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3128
5065
|
* @param {GetWalletAllowListParams} params - The necessary data required to fetch the list of allowed wallets.
|
|
3129
5066
|
* @returns List of allowed wallets.
|
|
3130
5067
|
* @throws {@link ErrorType}
|
|
3131
|
-
*/
|
|
5068
|
+
*/ // eslint-disable-next-line class-methods-use-this
|
|
5069
|
+
async getWalletAllowList(params) {
|
|
3132
5070
|
return await $5cdde2ffe6360fec$export$a822caa90d7eef09(params);
|
|
3133
5071
|
}
|
|
3134
5072
|
/**
|
|
@@ -3138,7 +5076,8 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3138
5076
|
* @throws {@link ErrorType}
|
|
3139
5077
|
* @remarks
|
|
3140
5078
|
* Further documenation can be found at [MetaMask | Sending Transactions](https://docs.metamask.io/guide/sending-transactions.html).
|
|
3141
|
-
*/
|
|
5079
|
+
*/ // eslint-disable-next-line class-methods-use-this
|
|
5080
|
+
async sendTransaction(params) {
|
|
3142
5081
|
return await $dbe95599a4661140$export$8e0e7ffc78696d30(params);
|
|
3143
5082
|
}
|
|
3144
5083
|
/**
|
|
@@ -3147,13 +5086,14 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
3147
5086
|
* @returns Network details.
|
|
3148
5087
|
* @throws {@link ErrorType}
|
|
3149
5088
|
*/ async getNetworkInfo(params) {
|
|
3150
|
-
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(params.provider);
|
|
5089
|
+
return await $de192de6ef100f9f$export$79f13b4cfaaf0d09(this.config, params.provider);
|
|
3151
5090
|
}
|
|
3152
5091
|
}
|
|
3153
5092
|
|
|
3154
5093
|
function $parcel$export(e, n, v, s) {
|
|
3155
5094
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
3156
5095
|
}
|
|
5096
|
+
// Definitions | Events
|
|
3157
5097
|
var $207ed853f11d19d5$exports = {};
|
|
3158
5098
|
|
|
3159
5099
|
$parcel$export($207ed853f11d19d5$exports, "IMTBLWidgetEvents", () => $207ed853f11d19d5$export$5a0ace85cae72d45);
|
|
@@ -3192,6 +5132,7 @@ let $77b6aac5c353d4a9$export$d9be06b70b28c742;
|
|
|
3192
5132
|
WalletEventType["REQUEST_SWAP"] = "request-swap";
|
|
3193
5133
|
WalletEventType["REQUEST_BRIDGE"] = "request-bridge";
|
|
3194
5134
|
WalletEventType["REQUEST_ONRAMP"] = "request-onramp";
|
|
5135
|
+
WalletEventType["DISCONNECT_WALLET"] = "disconnect-wallet";
|
|
3195
5136
|
})($77b6aac5c353d4a9$export$d9be06b70b28c742 || ($77b6aac5c353d4a9$export$d9be06b70b28c742 = {}));
|
|
3196
5137
|
|
|
3197
5138
|
|
|
@@ -3206,6 +5147,7 @@ $parcel$export($53d219e7f6bf0cd6$exports, "SwapEventType", () => $53d219e7f6bf0c
|
|
|
3206
5147
|
(function(SwapEventType) {
|
|
3207
5148
|
SwapEventType["SUCCESS"] = "success";
|
|
3208
5149
|
SwapEventType["FAILURE"] = "failure";
|
|
5150
|
+
SwapEventType["CLOSE_WIDGET"] = "close-widget";
|
|
3209
5151
|
})($53d219e7f6bf0cd6$export$140a49745ab55563 || ($53d219e7f6bf0cd6$export$140a49745ab55563 = {}));
|
|
3210
5152
|
|
|
3211
5153
|
|
|
@@ -3245,21 +5187,23 @@ var $66ceef112c0ee49e$exports = {};
|
|
|
3245
5187
|
$parcel$export($66ceef112c0ee49e$exports, "OnRampEventType", () => $66ceef112c0ee49e$export$66ec39c0924078d8);
|
|
3246
5188
|
let $66ceef112c0ee49e$export$66ec39c0924078d8;
|
|
3247
5189
|
$66ceef112c0ee49e$export$66ec39c0924078d8 || ($66ceef112c0ee49e$export$66ec39c0924078d8 = {});
|
|
3248
|
-
|
|
5190
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3249
5191
|
|
|
3250
5192
|
var $14d7a2bbb79e0dae$exports = {};
|
|
3251
5193
|
|
|
3252
5194
|
$parcel$export($14d7a2bbb79e0dae$exports, "Network", () => $14d7a2bbb79e0dae$export$95be4ae94445245a);
|
|
3253
5195
|
$parcel$export($14d7a2bbb79e0dae$exports, "WidgetTheme", () => $14d7a2bbb79e0dae$export$c88931fdc51854eb);
|
|
3254
|
-
$parcel$export($14d7a2bbb79e0dae$exports, "WidgetConnectionProviders", () => $14d7a2bbb79e0dae$export$2f61dde3bdc320cb);
|
|
3255
5196
|
$parcel$export($14d7a2bbb79e0dae$exports, "CheckoutWidgetTagNames", () => $14d7a2bbb79e0dae$export$75be0f6af9650f2c);
|
|
3256
5197
|
/**
|
|
3257
5198
|
* Enum representing the networks supported by Checkout.
|
|
3258
5199
|
*/ let $14d7a2bbb79e0dae$export$95be4ae94445245a;
|
|
3259
5200
|
(function(Network) {
|
|
3260
5201
|
Network["ETHEREUM"] = "Ethereum";
|
|
3261
|
-
Network["
|
|
3262
|
-
Network["
|
|
5202
|
+
Network["SEPOLIA"] = "Sepolia";
|
|
5203
|
+
Network["IMTBL_ZKEVM_TESTNET"] = "Immutable zkEVM Testnet";
|
|
5204
|
+
Network["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Devnet";
|
|
5205
|
+
Network["POLYGON_ZKEVM_TESTNET"] = "Polygon zkEVM Testnet";
|
|
5206
|
+
Network["POLYGON_ZKEVM"] = "Polygon zkEVM";
|
|
3263
5207
|
})($14d7a2bbb79e0dae$export$95be4ae94445245a || ($14d7a2bbb79e0dae$export$95be4ae94445245a = {}));
|
|
3264
5208
|
let $14d7a2bbb79e0dae$export$c88931fdc51854eb;
|
|
3265
5209
|
(function(WidgetTheme) {
|
|
@@ -3267,10 +5211,6 @@ let $14d7a2bbb79e0dae$export$c88931fdc51854eb;
|
|
|
3267
5211
|
WidgetTheme["DARK"] = "dark";
|
|
3268
5212
|
WidgetTheme["CUSTOM"] = "custom";
|
|
3269
5213
|
})($14d7a2bbb79e0dae$export$c88931fdc51854eb || ($14d7a2bbb79e0dae$export$c88931fdc51854eb = {}));
|
|
3270
|
-
let $14d7a2bbb79e0dae$export$2f61dde3bdc320cb;
|
|
3271
|
-
(function(WidgetConnectionProviders) {
|
|
3272
|
-
WidgetConnectionProviders["METAMASK"] = "metamask";
|
|
3273
|
-
})($14d7a2bbb79e0dae$export$2f61dde3bdc320cb || ($14d7a2bbb79e0dae$export$2f61dde3bdc320cb = {}));
|
|
3274
5214
|
let $14d7a2bbb79e0dae$export$75be0f6af9650f2c;
|
|
3275
5215
|
(function(CheckoutWidgetTagNames) {
|
|
3276
5216
|
CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
|
|
@@ -3287,13 +5227,12 @@ var $1f969328e5988c99$exports = {};
|
|
|
3287
5227
|
$parcel$export($1f969328e5988c99$exports, "BridgeReact", () => $1f969328e5988c99$export$30f61ebf204c69f6);
|
|
3288
5228
|
|
|
3289
5229
|
|
|
3290
|
-
|
|
3291
5230
|
function $1f969328e5988c99$export$30f61ebf204c69f6(props) {
|
|
3292
5231
|
const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , fromNetwork: fromNetwork } = props;
|
|
3293
5232
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
3294
5233
|
return /*#__PURE__*/ (jsx)("imtbl-bridge", {
|
|
3295
|
-
|
|
3296
|
-
|
|
5234
|
+
widgetConfig: config,
|
|
5235
|
+
providerPreference: providerPreference,
|
|
3297
5236
|
fromContractAddress: fromContractAddress ?? "",
|
|
3298
5237
|
fromNetwork: fromNetwork ?? "",
|
|
3299
5238
|
amount: amount ?? ""
|
|
@@ -3306,13 +5245,12 @@ var $f22931ca9e2f35b6$exports = {};
|
|
|
3306
5245
|
$parcel$export($f22931ca9e2f35b6$exports, "BuyReact", () => $f22931ca9e2f35b6$export$d13582032b79b401);
|
|
3307
5246
|
|
|
3308
5247
|
|
|
3309
|
-
|
|
3310
5248
|
function $f22931ca9e2f35b6$export$d13582032b79b401(props) {
|
|
3311
5249
|
const { providerPreference: providerPreference , orderId: orderId } = props;
|
|
3312
5250
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
3313
5251
|
return /*#__PURE__*/ (jsx)("imtbl-buy", {
|
|
3314
|
-
|
|
3315
|
-
|
|
5252
|
+
widgetConfig: config,
|
|
5253
|
+
providerPreference: providerPreference,
|
|
3316
5254
|
orderId: orderId
|
|
3317
5255
|
});
|
|
3318
5256
|
}
|
|
@@ -3323,13 +5261,12 @@ var $f2083cd30e2f5c56$exports = {};
|
|
|
3323
5261
|
$parcel$export($f2083cd30e2f5c56$exports, "ConnectReact", () => $f2083cd30e2f5c56$export$49d62957f420a1e2);
|
|
3324
5262
|
|
|
3325
5263
|
|
|
3326
|
-
|
|
3327
5264
|
function $f2083cd30e2f5c56$export$49d62957f420a1e2(props) {
|
|
3328
5265
|
const { providerPreference: providerPreference } = props;
|
|
3329
5266
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
3330
5267
|
return /*#__PURE__*/ (jsx)("imtbl-connect", {
|
|
3331
|
-
|
|
3332
|
-
|
|
5268
|
+
widgetConfig: config,
|
|
5269
|
+
providerPreference: providerPreference ?? "metamask"
|
|
3333
5270
|
});
|
|
3334
5271
|
}
|
|
3335
5272
|
|
|
@@ -3337,15 +5274,14 @@ function $f2083cd30e2f5c56$export$49d62957f420a1e2(props) {
|
|
|
3337
5274
|
var $a4fbb8e3a6aeff58$exports = {};
|
|
3338
5275
|
|
|
3339
5276
|
$parcel$export($a4fbb8e3a6aeff58$exports, "SwapReact", () => $a4fbb8e3a6aeff58$export$971e031379577f4);
|
|
3340
|
-
|
|
3341
|
-
|
|
5277
|
+
/* eslint-disable max-len */
|
|
3342
5278
|
|
|
3343
5279
|
function $a4fbb8e3a6aeff58$export$971e031379577f4(props) {
|
|
3344
5280
|
const { providerPreference: providerPreference , fromContractAddress: fromContractAddress , amount: amount , toContractAddress: toContractAddress } = props;
|
|
3345
5281
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
3346
5282
|
return /*#__PURE__*/ (jsx)("imtbl-swap", {
|
|
3347
|
-
|
|
3348
|
-
|
|
5283
|
+
widgetConfig: config,
|
|
5284
|
+
providerPreference: providerPreference,
|
|
3349
5285
|
fromContractAddress: fromContractAddress ?? "",
|
|
3350
5286
|
toContractAddress: toContractAddress ?? "",
|
|
3351
5287
|
amount: amount ?? ""
|
|
@@ -3358,18 +5294,13 @@ var $89d55ace0f8f1c07$exports = {};
|
|
|
3358
5294
|
$parcel$export($89d55ace0f8f1c07$exports, "WalletReact", () => $89d55ace0f8f1c07$export$ceaac94f34dba154);
|
|
3359
5295
|
|
|
3360
5296
|
|
|
3361
|
-
|
|
3362
5297
|
function $89d55ace0f8f1c07$export$ceaac94f34dba154(props) {
|
|
3363
|
-
const { providerPreference: providerPreference ,
|
|
5298
|
+
const { providerPreference: providerPreference , useConnectWidget: useConnectWidget } = props;
|
|
3364
5299
|
const config = window.ImtblCheckoutWidgetConfig;
|
|
3365
|
-
// isOnRampEnabled, isBridgeEnabled, isSwapEnabled is a boolean type for better devExp
|
|
3366
|
-
// converting them to string for compatible webComponent properties
|
|
3367
5300
|
return /*#__PURE__*/ (jsx)("imtbl-wallet", {
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
isSwapEnabled: isSwapEnabled?.toString(),
|
|
3372
|
-
isOnRampEnabled: isOnRampEnabled?.toString()
|
|
5301
|
+
widgetConfig: config,
|
|
5302
|
+
useConnectWidget: useConnectWidget?.toString(),
|
|
5303
|
+
providerPreference: providerPreference ?? "metamask"
|
|
3373
5304
|
});
|
|
3374
5305
|
}
|
|
3375
5306
|
|
|
@@ -3381,31 +5312,33 @@ $parcel$export($d087956fd1002f80$exports, "ExampleReact", () => $d087956fd1002f8
|
|
|
3381
5312
|
|
|
3382
5313
|
|
|
3383
5314
|
function $d087956fd1002f80$export$fa517eee6594d26c(props) {
|
|
3384
|
-
const { providerPreference:
|
|
3385
|
-
|
|
5315
|
+
const { providerPreference: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5316
|
+
providerPreference , environment: environment , theme: theme } = props;
|
|
3386
5317
|
return /*#__PURE__*/ (jsx)("imtbl-example", {
|
|
3387
|
-
|
|
3388
|
-
theme:
|
|
5318
|
+
environment: environment ?? (Environment).SANDBOX,
|
|
5319
|
+
theme: theme ?? "dark",
|
|
5320
|
+
providerPreference: providerPreference
|
|
3389
5321
|
});
|
|
3390
5322
|
}
|
|
3391
5323
|
|
|
3392
5324
|
|
|
3393
|
-
var $
|
|
5325
|
+
var $430e3eda76fa4d5f$exports = {};
|
|
3394
5326
|
|
|
3395
|
-
$parcel$export($
|
|
3396
|
-
$parcel$export($
|
|
3397
|
-
$parcel$export($
|
|
3398
|
-
function $
|
|
3399
|
-
|
|
5327
|
+
$parcel$export($430e3eda76fa4d5f$exports, "CheckoutWidgets", () => $430e3eda76fa4d5f$export$af210a0808087845);
|
|
5328
|
+
$parcel$export($430e3eda76fa4d5f$exports, "UpdateConfig", () => $430e3eda76fa4d5f$export$bf1548ba7e61c17f);
|
|
5329
|
+
$parcel$export($430e3eda76fa4d5f$exports, "SetProvider", () => $430e3eda76fa4d5f$export$931068bc678f0d73);
|
|
5330
|
+
function $430e3eda76fa4d5f$export$af210a0808087845(config) {
|
|
5331
|
+
const checkoutWidgetJS = document.createElement("script");
|
|
3400
5332
|
checkoutWidgetJS.setAttribute("src", "http://localhost:3000/lib/js/imtbl-checkout.js");
|
|
3401
5333
|
document.head.appendChild(checkoutWidgetJS);
|
|
3402
|
-
window.ImtblCheckoutWidgetConfig = config;
|
|
5334
|
+
window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
|
|
3403
5335
|
}
|
|
3404
|
-
function $
|
|
3405
|
-
window.ImtblCheckoutWidgetConfig = config;
|
|
5336
|
+
function $430e3eda76fa4d5f$export$bf1548ba7e61c17f(config) {
|
|
5337
|
+
window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
|
|
3406
5338
|
}
|
|
3407
|
-
function $
|
|
5339
|
+
function $430e3eda76fa4d5f$export$931068bc678f0d73(tagName, provider) {
|
|
3408
5340
|
if (!provider) {
|
|
5341
|
+
// eslint-disable-next-line no-console
|
|
3409
5342
|
console.error("no provider parsed");
|
|
3410
5343
|
return;
|
|
3411
5344
|
}
|
|
@@ -3422,6 +5355,7 @@ function $fa90757d8d7a0962$export$931068bc678f0d73(tagName, provider) {
|
|
|
3422
5355
|
attempts++;
|
|
3423
5356
|
if (attempts >= maxAttempts) {
|
|
3424
5357
|
window.clearInterval(timer);
|
|
5358
|
+
// eslint-disable-next-line no-console
|
|
3425
5359
|
console.error("failed to set the provider");
|
|
3426
5360
|
}
|
|
3427
5361
|
}
|
|
@@ -3430,4 +5364,4 @@ function $fa90757d8d7a0962$export$931068bc678f0d73(tagName, provider) {
|
|
|
3430
5364
|
attemptToSetProvider();
|
|
3431
5365
|
}
|
|
3432
5366
|
|
|
3433
|
-
export { $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $98cbcca465beec95$export$90db5fe1be5993c1 as BuyEventType, $f22931ca9e2f35b6$export$d13582032b79b401 as BuyReact, $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $14d7a2bbb79e0dae$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $
|
|
5367
|
+
export { $15cc9e120aa6f3bf$export$d1bfa21f7c76447a as BridgeEventType, $1f969328e5988c99$export$30f61ebf204c69f6 as BridgeReact, $98cbcca465beec95$export$90db5fe1be5993c1 as BuyEventType, $f22931ca9e2f35b6$export$d13582032b79b401 as BuyReact, $a47e48dd2c04791b$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $14d7a2bbb79e0dae$export$75be0f6af9650f2c as CheckoutWidgetTagNames, $430e3eda76fa4d5f$export$af210a0808087845 as CheckoutWidgets, $a85ecdbd885c58ad$export$e72e7f9969a47dd3 as ConnectEventType, $f2083cd30e2f5c56$export$49d62957f420a1e2 as ConnectReact, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, Environment, $d087956fd1002f80$export$fa517eee6594d26c as ExampleReact, GenericIMXProvider, $207ed853f11d19d5$export$5a0ace85cae72d45 as IMTBLWidgetEvents, ImmutableConfiguration, ImmutableXClient, MetaMaskIMXProvider, $14d7a2bbb79e0dae$export$95be4ae94445245a as Network, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $66ceef112c0ee49e$export$66ec39c0924078d8 as OnRampEventType, Orderbook, Passport, PassportError, ProviderConfiguration, $430e3eda76fa4d5f$export$931068bc678f0d73 as SetProvider, $53d219e7f6bf0cd6$export$140a49745ab55563 as SwapEventType, $a4fbb8e3a6aeff58$export$971e031379577f4 as SwapReact, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $430e3eda76fa4d5f$export$bf1548ba7e61c17f as UpdateConfig, $77b6aac5c353d4a9$export$d9be06b70b28c742 as WalletEventType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $89d55ace0f8f1c07$export$ceaac94f34dba154 as WalletReact, $14d7a2bbb79e0dae$export$c88931fdc51854eb as WidgetTheme, module };
|