@imtbl/checkout-widgets 2.2.0 → 2.2.1-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/{AddTokensWidget-Ma98Dqwh.js → AddTokensWidget-CIX9CQkm.js} +26 -26
- package/dist/browser/{BridgeWidget-tDPVxvTK.js → BridgeWidget-DZoglU1Z.js} +52 -52
- package/dist/browser/{CommerceWidget-DnB5h5DA.js → CommerceWidget-D8k1Bk8v.js} +180 -186
- package/dist/browser/{FeesBreakdown-SMMmNxU-.js → FeesBreakdown-Bj9eD-6N.js} +1 -1
- package/dist/browser/{OnRampWidget-B3cnjDkJ.js → OnRampWidget-Cish1sa7.js} +8 -8
- package/dist/browser/{SaleWidget-C7tDRhvp.js → SaleWidget-B84V0S1J.js} +61 -61
- package/dist/browser/{SpendingCapHero-Do-mkYwB.js → SpendingCapHero-0giZEKem.js} +1 -1
- package/dist/browser/{SwapWidget-QxW4xOa_.js → SwapWidget-EpPSGKqD.js} +21 -21
- package/dist/browser/{TokenImage-lDWfoU2b.js → TokenImage-DkervDKQ.js} +1 -1
- package/dist/browser/{TopUpView-DPkqr-YC.js → TopUpView-DwRBmzvI.js} +5 -5
- package/dist/browser/{WalletApproveHero-Di02Phe4.js → WalletApproveHero-XianIJAQ.js} +4 -4
- package/dist/browser/{WalletWidget-BozZjliU.js → WalletWidget-DxQcP7sk.js} +18 -18
- package/dist/browser/{auto-track-CG4Bs1kg.js → auto-track-DeLnQQ5M.js} +1 -1
- package/dist/browser/{index-BrDACMtQ.js → index-BwNgGaGH.js} +1 -1
- package/dist/browser/{index-DygDkU2e.js → index-ByDgwiba.js} +1 -1
- package/dist/browser/{index-CqT6H9W-.js → index-CVAaj9Qm.js} +334 -357
- package/dist/browser/{index-BO9ARDoY.js → index-D18hBbWb.js} +1 -1
- package/dist/browser/{index-R2dpGmlF.js → index-DpNna0MG.js} +2 -2
- package/dist/browser/{index-ByPgvc_F.js → index-Dpv6KyQF.js} +1 -1
- package/dist/browser/{index-qkgda0uC.js → index-lgFyRHj_.js} +1 -1
- package/dist/browser/{index-B92IZgyS.js → index-qgsQUTip.js} +1 -1
- package/dist/browser/index.js +1 -1
- package/dist/browser/{index.umd-B82ymo2S.js → index.umd-BwrkBBu0.js} +1 -1
- package/dist/browser/{useInterval-Dp4GWqSc.js → useInterval-BE4Wp_87.js} +1 -1
- package/dist/types/lib/index.d.ts +0 -1
- package/package.json +7 -7
- package/src/components/NetworkSwitchDrawer/NetworkSwitchDrawer.tsx +1 -2
- package/src/components/Transactions/Transactions.tsx +6 -8
- package/src/lib/index.ts +0 -1
- package/src/lib/utils.ts +4 -5
- package/src/widgets/add-tokens/components/TokenDrawerMenu.tsx +1 -2
- package/src/widgets/add-tokens/views/AddTokens.tsx +1 -2
- package/src/widgets/bridge/BridgeWidget.tsx +2 -3
- package/src/widgets/bridge/components/BridgeReviewSummary.tsx +2 -4
- package/src/widgets/bridge/components/WalletAndNetworkSelector.tsx +2 -3
- package/src/widgets/bridge/views/ClaimWithdrawal.tsx +3 -3
- package/src/widgets/connect/components/WalletList.tsx +2 -2
- package/src/widgets/connect/views/SwitchNetworkEth.tsx +2 -3
- package/src/widgets/connect/views/SwitchNetworkZkEVM.tsx +5 -5
- package/src/widgets/immutable-commerce/functions/getConnectLoaderParams.ts +9 -17
- package/src/widgets/on-ramp/OnRampWidgetRoot.tsx +1 -2
- package/src/widgets/sale/SaleWidgetRoot.tsx +1 -2
- package/src/widgets/sale/components/FundingRouteExecute/FundingRouteExecute.tsx +2 -3
- package/src/widgets/swap/SwapWidget.tsx +2 -2
- package/src/widgets/swap/SwapWidgetRoot.tsx +1 -2
- package/src/widgets/swap/components/SwapForm.tsx +2 -3
- package/src/widgets/transfer/TransferWidget.tsx +1 -2
- package/src/widgets/wallet/WalletWidgetRoot.tsx +1 -2
- package/src/widgets/wallet/components/BalanceItem/BalanceItem.tsx +6 -7
- package/src/widgets/wallet/views/WalletBalances.tsx +1 -2
- package/dist/types/lib/networkUtils.d.ts +0 -3
- package/src/lib/networkUtils.ts +0 -22
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e4 as __awaiter, e5 as __generator, e6 as loadScript, e7 as getNextIntegrationsURL, e8 as unloadScript, e9 as __spreadArray, ea as isOffline, eb as __assign, ec as ContextCancelation, ed as applyDestinationMiddleware, ee as dist, ef as isServer, eg as mergedOptions, eh as isPlainObject, ei as pWhile, ej as PriorityQueue, ek as PersistedPriorityQueue, el as attempt, em as isOnline, en as Context } from './index-CVAaj9Qm.js';
|
|
2
2
|
import { i as isPlanEventEnabled } from './is-plan-event-enabled-mXX0dwl-.js';
|
|
3
3
|
|
|
4
4
|
function normalizeName(name) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e4 as __awaiter, e5 as __generator } from './index-CVAaj9Qm.js';
|
|
2
2
|
|
|
3
3
|
function loadLegacyVideoPlugins(analytics) {
|
|
4
4
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -7,7 +7,7 @@ function loadLegacyVideoPlugins(analytics) {
|
|
|
7
7
|
switch (_a.label) {
|
|
8
8
|
case 0: return [4 /*yield*/, import(
|
|
9
9
|
// @ts-expect-error
|
|
10
|
-
'./index.umd-
|
|
10
|
+
'./index.umd-BwrkBBu0.js').then(function (n) { return n.i; })
|
|
11
11
|
// This is super gross, but we need to support the `window.analytics.plugins` namespace
|
|
12
12
|
// that is linked in the segment docs in order to be backwards compatible with ajs-classic
|
|
13
13
|
// @ts-expect-error
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dW as se$1, dX as T$2, dY as oe$1, dZ as R$1, d_ as a$2, d$ as te$1, e0 as p$1, e1 as ne$1, e2 as y$1 } from './index-CVAaj9Qm.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
package/dist/browser/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { eq as WidgetsFactory } from './index-CVAaj9Qm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as reactExports, dV as useBrowserLayoutEffect } from './index-CVAaj9Qm.js';
|
|
2
2
|
|
|
3
3
|
// Inspired by https://usehooks-ts.com/react-hook/use-interval
|
|
4
4
|
function useInterval(callback, delay) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/checkout-widgets",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1-alpha.1",
|
|
4
4
|
"browserslist": {
|
|
5
5
|
"production": [
|
|
6
6
|
">0.2%",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
"@biom3/design-tokens": "^0.4.5",
|
|
19
19
|
"@biom3/react": "^0.29.4",
|
|
20
20
|
"@emotion/react": "^11.11.3",
|
|
21
|
-
"@imtbl/bridge-sdk": "2.2.
|
|
22
|
-
"@imtbl/checkout-sdk": "2.2.
|
|
23
|
-
"@imtbl/config": "2.2.
|
|
24
|
-
"@imtbl/cryptofiat": "2.2.
|
|
25
|
-
"@imtbl/dex-sdk": "2.2.
|
|
26
|
-
"@imtbl/passport": "2.2.
|
|
21
|
+
"@imtbl/bridge-sdk": "2.2.1-alpha.1",
|
|
22
|
+
"@imtbl/checkout-sdk": "2.2.1-alpha.1",
|
|
23
|
+
"@imtbl/config": "2.2.1-alpha.1",
|
|
24
|
+
"@imtbl/cryptofiat": "2.2.1-alpha.1",
|
|
25
|
+
"@imtbl/dex-sdk": "2.2.1-alpha.1",
|
|
26
|
+
"@imtbl/passport": "2.2.1-alpha.1",
|
|
27
27
|
"@imtbl/react-analytics": "0.3.2-alpha",
|
|
28
28
|
"@rive-app/react-canvas-lite": "^4.9.0",
|
|
29
29
|
"@walletconnect/ethereum-provider": "^2.11.1",
|
|
@@ -14,7 +14,6 @@ import { useTranslation } from 'react-i18next';
|
|
|
14
14
|
import { ChainId, Checkout, WrappedBrowserProvider } from '@imtbl/checkout-sdk';
|
|
15
15
|
import { Environment } from '@imtbl/config';
|
|
16
16
|
import { FooterLogo } from '../Footer/FooterLogo';
|
|
17
|
-
import { getL1ChainId } from '../../lib';
|
|
18
17
|
import { getChainNameById } from '../../lib/chains';
|
|
19
18
|
import {
|
|
20
19
|
isMetaMaskProvider,
|
|
@@ -51,7 +50,7 @@ export function NetworkSwitchDrawer({
|
|
|
51
50
|
);
|
|
52
51
|
|
|
53
52
|
const targetChainName = getChainNameById(targetChainId);
|
|
54
|
-
const showEthImage = targetChainId ===
|
|
53
|
+
const showEthImage = targetChainId === checkout.config.l1ChainId;
|
|
55
54
|
|
|
56
55
|
const handleSwitchNetwork = useCallback(async () => {
|
|
57
56
|
if (!checkout) return;
|
|
@@ -22,8 +22,6 @@ import {
|
|
|
22
22
|
} from '../../lib/provider';
|
|
23
23
|
import {
|
|
24
24
|
DEFAULT_TRANSACTIONS_RETRY_POLICY,
|
|
25
|
-
getL1ChainId,
|
|
26
|
-
getL2ChainId,
|
|
27
25
|
} from '../../lib';
|
|
28
26
|
import { CheckoutApi, Transaction, TransactionType } from '../../lib/clients';
|
|
29
27
|
import { retry } from '../../lib/retry';
|
|
@@ -94,7 +92,7 @@ export function Transactions({
|
|
|
94
92
|
const rootChainTokensHashmap = useCallback(async () => {
|
|
95
93
|
if (!checkout) return {};
|
|
96
94
|
|
|
97
|
-
const rootChainId =
|
|
95
|
+
const rootChainId = checkout.config.l1ChainId;
|
|
98
96
|
try {
|
|
99
97
|
const tokens = (
|
|
100
98
|
await checkout.getTokenAllowList({
|
|
@@ -123,7 +121,7 @@ export function Transactions({
|
|
|
123
121
|
|
|
124
122
|
if (!from?.walletAddress) return {};
|
|
125
123
|
|
|
126
|
-
const childChainId =
|
|
124
|
+
const childChainId = checkout.config.l2ChainId;
|
|
127
125
|
|
|
128
126
|
try {
|
|
129
127
|
const data = await checkout.getAllBalances({
|
|
@@ -146,8 +144,8 @@ export function Transactions({
|
|
|
146
144
|
const getTokensDetails = async (tokensWithChainSlug: {
|
|
147
145
|
[p: string]: string;
|
|
148
146
|
}) => {
|
|
149
|
-
const rootChainName = getChainSlugById(
|
|
150
|
-
const childChainName = getChainSlugById(
|
|
147
|
+
const rootChainName = getChainSlugById(checkout.config.l1ChainId);
|
|
148
|
+
const childChainName = getChainSlugById(checkout.config.l2ChainId);
|
|
151
149
|
|
|
152
150
|
const [rootData, childData] = await Promise.all([
|
|
153
151
|
rootChainTokensHashmap(),
|
|
@@ -164,12 +162,12 @@ export function Transactions({
|
|
|
164
162
|
});
|
|
165
163
|
// Root provider is always L1
|
|
166
164
|
const rootProvider = new JsonRpcProvider(
|
|
167
|
-
checkout.config.networkMap.get(
|
|
165
|
+
checkout.config.networkMap.get(checkout.config.l1ChainId)?.rpcUrls[0],
|
|
168
166
|
);
|
|
169
167
|
|
|
170
168
|
// Child provider is always L2
|
|
171
169
|
const childProvider = new JsonRpcProvider(
|
|
172
|
-
checkout.config.networkMap.get(
|
|
170
|
+
checkout.config.networkMap.get(checkout.config.l2ChainId)?.rpcUrls[0],
|
|
173
171
|
);
|
|
174
172
|
|
|
175
173
|
const rootTokenInfoPromises: Promise<TokenInfo | undefined>[] = [];
|
package/src/lib/index.ts
CHANGED
package/src/lib/utils.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
import { Environment } from '@imtbl/config';
|
|
6
6
|
import { Contract, formatUnits } from 'ethers';
|
|
7
7
|
import { TransactionResponse } from '@imtbl/dex-sdk';
|
|
8
|
-
import { getL1ChainId, getL2ChainId } from './networkUtils';
|
|
9
8
|
import {
|
|
10
9
|
CHECKOUT_CDN_BASE_URL,
|
|
11
10
|
DEFAULT_GT_ONE_TOKEN_FORMATTING_DECIMALS,
|
|
@@ -25,7 +24,7 @@ export const sortTokensByAmount = (
|
|
|
25
24
|
) => tokens.sort((a, b) => {
|
|
26
25
|
// make sure IMX is at the top of the list
|
|
27
26
|
if (
|
|
28
|
-
chainId ===
|
|
27
|
+
chainId === config.l2ChainId
|
|
29
28
|
&& a.token.symbol.toLowerCase() === 'imx'
|
|
30
29
|
&& b.token.symbol.toLowerCase() !== 'imx'
|
|
31
30
|
) {
|
|
@@ -33,7 +32,7 @@ export const sortTokensByAmount = (
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
if (
|
|
36
|
-
chainId ===
|
|
35
|
+
chainId === config.l2ChainId
|
|
37
36
|
&& b.token.symbol.toLowerCase() === 'imx'
|
|
38
37
|
&& a.token.symbol.toLowerCase() !== 'imx'
|
|
39
38
|
) {
|
|
@@ -57,10 +56,10 @@ export const sortNetworksCompareFn = (
|
|
|
57
56
|
config: CheckoutConfiguration,
|
|
58
57
|
) => {
|
|
59
58
|
// make sure zkEVM at start of the list then L1
|
|
60
|
-
if (Number(a.chainId) ===
|
|
59
|
+
if (Number(a.chainId) === config.l2ChainId) {
|
|
61
60
|
return -1;
|
|
62
61
|
}
|
|
63
|
-
if (Number(a.chainId) ===
|
|
62
|
+
if (Number(a.chainId) === config.l1ChainId) {
|
|
64
63
|
return 0;
|
|
65
64
|
}
|
|
66
65
|
return 1;
|
|
@@ -36,7 +36,6 @@ import {
|
|
|
36
36
|
useAnalytics,
|
|
37
37
|
UserJourney,
|
|
38
38
|
} from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
39
|
-
import { getL2ChainId } from '../../../lib';
|
|
40
39
|
import { AddTokensErrorTypes } from '../types';
|
|
41
40
|
import { TokenImage } from '../../../components/TokenImage/TokenImage';
|
|
42
41
|
import { PULSE_SHADOW } from '../utils/animation';
|
|
@@ -133,7 +132,7 @@ export function TokenDrawerMenu({
|
|
|
133
132
|
try {
|
|
134
133
|
const tokenResponse = await checkout.getTokenAllowList({
|
|
135
134
|
type: TokenFilterTypes.SWAP,
|
|
136
|
-
chainId:
|
|
135
|
+
chainId: checkout.config.l2ChainId,
|
|
137
136
|
});
|
|
138
137
|
|
|
139
138
|
if (tokenResponse?.tokens.length > 0) {
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
ViewActions,
|
|
38
38
|
ViewContext,
|
|
39
39
|
} from '../../../context/view-context/ViewContext';
|
|
40
|
-
import { getL2ChainId } from '../../../lib';
|
|
41
40
|
import { orchestrationEvents } from '../../../lib/orchestrationEvents';
|
|
42
41
|
import {
|
|
43
42
|
AddTokensActions,
|
|
@@ -410,7 +409,7 @@ export function AddTokens({
|
|
|
410
409
|
try {
|
|
411
410
|
const tokenResponse = await checkout.getTokenAllowList({
|
|
412
411
|
type: TokenFilterTypes.ONRAMP,
|
|
413
|
-
chainId:
|
|
412
|
+
chainId: checkout.config.l2ChainId,
|
|
414
413
|
});
|
|
415
414
|
|
|
416
415
|
if (tokenResponse?.tokens.length > 0) {
|
|
@@ -25,7 +25,6 @@ import { StrongCheckoutWidgetsConfig } from '../../lib/withDefaultWidgetConfig';
|
|
|
25
25
|
import { CryptoFiatProvider } from '../../context/crypto-fiat-context/CryptoFiatProvider';
|
|
26
26
|
import { StatusView } from '../../components/Status/StatusView';
|
|
27
27
|
import { StatusType } from '../../components/Status/StatusType';
|
|
28
|
-
import { getL1ChainId, getL2ChainId } from '../../lib';
|
|
29
28
|
import { Transactions } from '../../components/Transactions/Transactions';
|
|
30
29
|
import { UserJourney, useAnalytics } from '../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
31
30
|
import { TopUpView } from '../../views/top-up/TopUpView';
|
|
@@ -114,12 +113,12 @@ export default function BridgeWidget({
|
|
|
114
113
|
|
|
115
114
|
// Root provider is always L1
|
|
116
115
|
const rootProvider = new JsonRpcProvider(
|
|
117
|
-
checkout.config.networkMap.get(
|
|
116
|
+
checkout.config.networkMap.get(checkout.config.l1ChainId)?.rpcUrls[0],
|
|
118
117
|
);
|
|
119
118
|
|
|
120
119
|
// Child provider is always L2
|
|
121
120
|
const childProvider = new JsonRpcProvider(
|
|
122
|
-
checkout.config.networkMap.get(
|
|
121
|
+
checkout.config.networkMap.get(checkout.config.l2ChainId)?.rpcUrls[0],
|
|
123
122
|
);
|
|
124
123
|
const bridgeConfiguration = new BridgeConfiguration({
|
|
125
124
|
baseConfig: new ImmutableConfiguration({ environment: checkout.config.environment }),
|
|
@@ -29,8 +29,6 @@ import {
|
|
|
29
29
|
IMX_TOKEN_SYMBOL,
|
|
30
30
|
NATIVE,
|
|
31
31
|
addChainChangedListener,
|
|
32
|
-
getL1ChainId,
|
|
33
|
-
getL2ChainId,
|
|
34
32
|
networkName,
|
|
35
33
|
removeChainChangedListener,
|
|
36
34
|
} from '../../../lib';
|
|
@@ -119,7 +117,7 @@ export function BridgeReviewSummary() {
|
|
|
119
117
|
|
|
120
118
|
const isTransfer = useMemo(() => from?.network === to?.network, [from, to]);
|
|
121
119
|
const isDeposit = useMemo(
|
|
122
|
-
() => (
|
|
120
|
+
() => (checkout.config.l2ChainId === to?.network),
|
|
123
121
|
[from, to, checkout],
|
|
124
122
|
);
|
|
125
123
|
const insufficientFundsForGas = useMemo(() => {
|
|
@@ -637,7 +635,7 @@ export function BridgeReviewSummary() {
|
|
|
637
635
|
onCloseDrawer={() => setShowNotEnoughGasDrawer(false)}
|
|
638
636
|
walletAddress={from?.walletAddress || ''}
|
|
639
637
|
tokenSymbol={
|
|
640
|
-
from?.network ===
|
|
638
|
+
from?.network === checkout.config.l1ChainId
|
|
641
639
|
? ETH_TOKEN_SYMBOL
|
|
642
640
|
: IMX_TOKEN_SYMBOL
|
|
643
641
|
}
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
isPassportProvider,
|
|
23
23
|
isWalletConnectProvider,
|
|
24
24
|
} from '../../../lib/provider';
|
|
25
|
-
import { getL1ChainId, getL2ChainId } from '../../../lib';
|
|
26
25
|
import { getChainNameById } from '../../../lib/chains';
|
|
27
26
|
import { ViewActions, ViewContext } from '../../../context/view-context/ViewContext';
|
|
28
27
|
import { abbreviateAddress } from '../../../lib/addressUtils';
|
|
@@ -85,9 +84,9 @@ export function WalletAndNetworkSelector() {
|
|
|
85
84
|
} as unknown as WalletChangeEvent : null;
|
|
86
85
|
|
|
87
86
|
// calculating l1/l2 chains to work with based on Checkout environment
|
|
88
|
-
const l1NetworkChainId =
|
|
87
|
+
const l1NetworkChainId = checkout.config.l1ChainId;
|
|
89
88
|
const l1NetworkName = getChainNameById(l1NetworkChainId);
|
|
90
|
-
const imtblZkEvmNetworkChainId =
|
|
89
|
+
const imtblZkEvmNetworkChainId = checkout.config.l2ChainId;
|
|
91
90
|
const imtblZkEvmNetworkName = getChainNameById(imtblZkEvmNetworkChainId);
|
|
92
91
|
|
|
93
92
|
/** From wallet and from network local state */
|
|
@@ -12,7 +12,7 @@ import { FeeData } from 'ethers';
|
|
|
12
12
|
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
13
13
|
import { Transaction } from '../../../lib/clients';
|
|
14
14
|
import { getChainNameById } from '../../../lib/chains';
|
|
15
|
-
import { WITHDRAWAL_CLAIM_GAS_LIMIT
|
|
15
|
+
import { WITHDRAWAL_CLAIM_GAS_LIMIT } from '../../../lib';
|
|
16
16
|
import { isPassportProvider } from '../../../lib/provider';
|
|
17
17
|
import { isNativeToken } from '../../../lib/utils';
|
|
18
18
|
import { NotEnoughEthToWithdraw } from '../../../components/Transactions/NotEnoughEthToWithdraw';
|
|
@@ -95,7 +95,7 @@ export function ClaimWithdrawal({ transaction }: ClaimWithdrawalProps) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
let providerToUse = from?.browserProvider;
|
|
98
|
-
const l1ChainId =
|
|
98
|
+
const { l1ChainId } = checkout.config;
|
|
99
99
|
|
|
100
100
|
setTxProcessing(true);
|
|
101
101
|
|
|
@@ -263,7 +263,7 @@ export function ClaimWithdrawal({ transaction }: ClaimWithdrawalProps) {
|
|
|
263
263
|
>
|
|
264
264
|
<SimpleTextBody
|
|
265
265
|
heading={
|
|
266
|
-
`${t('views.CLAIM_WITHDRAWAL.content.heading')} ${getChainNameById(
|
|
266
|
+
`${t('views.CLAIM_WITHDRAWAL.content.heading')} ${getChainNameById(checkout.config.l1ChainId)}`
|
|
267
267
|
}
|
|
268
268
|
>
|
|
269
269
|
<Box sx={{ display: 'flex', flexWrap: 'wrap', pb: 'base.spacing.x1' }}>
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
getProviderSlugFromRdns,
|
|
39
39
|
isPassportProvider,
|
|
40
40
|
} from '../../../lib/provider';
|
|
41
|
-
import { addProviderListenersForWidgetRoot
|
|
41
|
+
import { addProviderListenersForWidgetRoot } from '../../../lib';
|
|
42
42
|
import {
|
|
43
43
|
listItemVariants,
|
|
44
44
|
listVariants,
|
|
@@ -96,7 +96,7 @@ export function WalletList(props: WalletListProps) {
|
|
|
96
96
|
|
|
97
97
|
// Don't allow Passport if targetChainId is L1
|
|
98
98
|
const passportProviderDetail = useMemo(
|
|
99
|
-
() => targetChainId !==
|
|
99
|
+
() => targetChainId !== checkout!.config.l1ChainId
|
|
100
100
|
&& providers
|
|
101
101
|
.filter((provider) => !blocklistWalletRdns.includes(provider.info.rdns))
|
|
102
102
|
.find((provider) => provider.info.rdns === WalletProviderRdns.PASSPORT),
|
|
@@ -10,7 +10,6 @@ import { EthereumPlanetHero } from '../../../components/Hero/EthereumPlanetHero'
|
|
|
10
10
|
import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
11
11
|
import { ConnectWidgetViews } from '../../../context/view-context/ConnectViewContextTypes';
|
|
12
12
|
import { ConnectActions, ConnectContext } from '../context/ConnectContext';
|
|
13
|
-
import { getL1ChainId } from '../../../lib/networkUtils';
|
|
14
13
|
import {
|
|
15
14
|
ViewContext,
|
|
16
15
|
ViewActions,
|
|
@@ -45,7 +44,7 @@ export function SwitchNetworkEth() {
|
|
|
45
44
|
try {
|
|
46
45
|
const switchRes = await checkout.switchNetwork({
|
|
47
46
|
provider,
|
|
48
|
-
chainId:
|
|
47
|
+
chainId: checkout.config.l1ChainId,
|
|
49
48
|
});
|
|
50
49
|
|
|
51
50
|
connectDispatch({
|
|
@@ -88,7 +87,7 @@ export function SwitchNetworkEth() {
|
|
|
88
87
|
>
|
|
89
88
|
<SimpleTextBody
|
|
90
89
|
heading={t('views.SWITCH_NETWORK.eth.heading', {
|
|
91
|
-
networkName: getChainNameById(
|
|
90
|
+
networkName: getChainNameById(checkout!.config.l1ChainId),
|
|
92
91
|
})}
|
|
93
92
|
>
|
|
94
93
|
{t('views.SWITCH_NETWORK.eth.body')}
|
|
@@ -10,7 +10,7 @@ import { SimpleLayout } from '../../../components/SimpleLayout/SimpleLayout';
|
|
|
10
10
|
import { ConnectWidgetViews } from '../../../context/view-context/ConnectViewContextTypes';
|
|
11
11
|
import { ConnectActions, ConnectContext } from '../context/ConnectContext';
|
|
12
12
|
import { ViewContext, ViewActions } from '../../../context/view-context/ViewContext';
|
|
13
|
-
import { addChainChangedListener,
|
|
13
|
+
import { addChainChangedListener, removeChainChangedListener } from '../../../lib';
|
|
14
14
|
import { ImmutablePlanetHero } from '../../../components/Hero/ImmutablePlanetHero';
|
|
15
15
|
import { UserJourney, useAnalytics } from '../../../context/analytics-provider/SegmentAnalyticsProvider';
|
|
16
16
|
|
|
@@ -36,7 +36,7 @@ export function SwitchNetworkZkEVM() {
|
|
|
36
36
|
const currentChainId = await provider.send('eth_chainId', []);
|
|
37
37
|
// eslint-disable-next-line radix
|
|
38
38
|
const parsedChainId = Number(currentChainId.toString());
|
|
39
|
-
if (parsedChainId ===
|
|
39
|
+
if (parsedChainId === checkout.config.l2ChainId) {
|
|
40
40
|
connectDispatch({
|
|
41
41
|
payload: {
|
|
42
42
|
type: ConnectActions.SET_PROVIDER,
|
|
@@ -79,7 +79,7 @@ export function SwitchNetworkZkEVM() {
|
|
|
79
79
|
// eslint-disable-next-line radix
|
|
80
80
|
const parsedChainId = Number(currentChainId.toString());
|
|
81
81
|
|
|
82
|
-
if (parsedChainId ===
|
|
82
|
+
if (parsedChainId === checkout.config.l2ChainId) {
|
|
83
83
|
connectDispatch({
|
|
84
84
|
payload: {
|
|
85
85
|
type: ConnectActions.SET_PROVIDER,
|
|
@@ -108,7 +108,7 @@ export function SwitchNetworkZkEVM() {
|
|
|
108
108
|
try {
|
|
109
109
|
await checkout.addNetwork({
|
|
110
110
|
provider,
|
|
111
|
-
chainId:
|
|
111
|
+
chainId: checkout.config.l2ChainId,
|
|
112
112
|
});
|
|
113
113
|
connectDispatch({
|
|
114
114
|
payload: {
|
|
@@ -134,7 +134,7 @@ export function SwitchNetworkZkEVM() {
|
|
|
134
134
|
|
|
135
135
|
const switchRes = await checkout.switchNetwork({
|
|
136
136
|
provider,
|
|
137
|
-
chainId:
|
|
137
|
+
chainId: checkout.config.l2ChainId,
|
|
138
138
|
});
|
|
139
139
|
connectDispatch({
|
|
140
140
|
payload: {
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Checkout, CommerceFlowType, WrappedBrowserProvider,
|
|
3
3
|
} from '@imtbl/checkout-sdk';
|
|
4
4
|
import { ConnectLoaderParams } from '../../../components/ConnectLoader/ConnectLoader';
|
|
5
|
-
import { getL1ChainId, getL2ChainId } from '../../../lib/networkUtils';
|
|
6
5
|
import { View } from '../../../context/view-context/ViewContext';
|
|
7
6
|
|
|
8
|
-
/**
|
|
9
|
-
* Get the chain id for the checkout
|
|
10
|
-
*/
|
|
11
|
-
const getChainId = (checkout: Checkout) => (checkout.config.isProduction
|
|
12
|
-
? ChainId.IMTBL_ZKEVM_MAINNET
|
|
13
|
-
: ChainId.IMTBL_ZKEVM_TESTNET);
|
|
14
|
-
|
|
15
7
|
/**
|
|
16
8
|
* Get the connect loader params for the widget
|
|
17
9
|
*/
|
|
@@ -27,10 +19,10 @@ export function getConnectLoaderParams(
|
|
|
27
19
|
return {
|
|
28
20
|
checkout,
|
|
29
21
|
browserProvider,
|
|
30
|
-
targetChainId:
|
|
22
|
+
targetChainId: checkout.config.l2ChainId,
|
|
31
23
|
allowedChains: [
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
checkout.config.l1ChainId,
|
|
25
|
+
checkout.config.l2ChainId,
|
|
34
26
|
],
|
|
35
27
|
};
|
|
36
28
|
case CommerceFlowType.ONRAMP:
|
|
@@ -38,10 +30,10 @@ export function getConnectLoaderParams(
|
|
|
38
30
|
return {
|
|
39
31
|
checkout,
|
|
40
32
|
browserProvider,
|
|
41
|
-
targetChainId:
|
|
33
|
+
targetChainId: checkout.config.l2ChainId,
|
|
42
34
|
allowedChains: [
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
checkout.config.l1ChainId,
|
|
36
|
+
checkout.config.l2ChainId,
|
|
45
37
|
],
|
|
46
38
|
};
|
|
47
39
|
case CommerceFlowType.SALE:
|
|
@@ -50,8 +42,8 @@ export function getConnectLoaderParams(
|
|
|
50
42
|
return {
|
|
51
43
|
checkout,
|
|
52
44
|
browserProvider,
|
|
53
|
-
targetChainId:
|
|
54
|
-
allowedChains: [
|
|
45
|
+
targetChainId: checkout.config.l2ChainId,
|
|
46
|
+
allowedChains: [checkout.config.l2ChainId],
|
|
55
47
|
};
|
|
56
48
|
default:
|
|
57
49
|
return {} as ConnectLoaderParams;
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@imtbl/checkout-sdk';
|
|
11
11
|
import { Base } from '../BaseWidgetRoot';
|
|
12
12
|
import { ConnectLoader, ConnectLoaderParams } from '../../components/ConnectLoader/ConnectLoader';
|
|
13
|
-
import { getL1ChainId, getL2ChainId } from '../../lib';
|
|
14
13
|
import { isValidAddress, isValidAmount } from '../../lib/validations/widgetValidators';
|
|
15
14
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
16
15
|
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
@@ -82,7 +81,7 @@ export class OnRamp extends Base<WidgetType.ONRAMP> {
|
|
|
82
81
|
walletProviderName: this.parameters.walletProviderName,
|
|
83
82
|
browserProvider: this.browserProvider,
|
|
84
83
|
checkout: this.checkout,
|
|
85
|
-
allowedChains: [
|
|
84
|
+
allowedChains: [this.checkout.config.l1ChainId, this.checkout.config.l2ChainId],
|
|
86
85
|
};
|
|
87
86
|
|
|
88
87
|
this.reactRoot.render(
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
ConnectLoader,
|
|
16
16
|
ConnectLoaderParams,
|
|
17
17
|
} from '../../components/ConnectLoader/ConnectLoader';
|
|
18
|
-
import { getL2ChainId } from '../../lib';
|
|
19
18
|
import { isValidWalletProvider } from '../../lib/validations/widgetValidators';
|
|
20
19
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
21
20
|
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
@@ -124,7 +123,7 @@ export class Sale extends Base<WidgetType.SALE> {
|
|
|
124
123
|
: ChainId.IMTBL_ZKEVM_TESTNET,
|
|
125
124
|
browserProvider: this.browserProvider,
|
|
126
125
|
checkout: this.checkout,
|
|
127
|
-
allowedChains: [
|
|
126
|
+
allowedChains: [this.checkout.config.l2ChainId],
|
|
128
127
|
};
|
|
129
128
|
const config = this.strongConfig();
|
|
130
129
|
|
|
@@ -46,7 +46,6 @@ import {
|
|
|
46
46
|
ViewActions,
|
|
47
47
|
ViewContext,
|
|
48
48
|
} from '../../../../context/view-context/ViewContext';
|
|
49
|
-
import { getL1ChainId, getL2ChainId } from '../../../../lib/networkUtils';
|
|
50
49
|
import { LoadingView } from '../../../../views/loading/LoadingView';
|
|
51
50
|
import ConnectWidget from '../../../connect/ConnectWidget';
|
|
52
51
|
import SwapWidget from '../../../swap/SwapWidget';
|
|
@@ -142,7 +141,7 @@ export function FundingRouteExecute({
|
|
|
142
141
|
tokenAddress: step.fundingItem.token.address,
|
|
143
142
|
amount: step.fundingItem.fundsRequired.formattedAmount,
|
|
144
143
|
});
|
|
145
|
-
if (Number(network.chainId) ===
|
|
144
|
+
if (Number(network.chainId) === checkout!.config.l1ChainId) {
|
|
146
145
|
setView(FundingRouteExecuteViews.EXECUTE_BRIDGE);
|
|
147
146
|
return;
|
|
148
147
|
}
|
|
@@ -158,7 +157,7 @@ export function FundingRouteExecute({
|
|
|
158
157
|
toTokenAddress: requiredTokenAddress,
|
|
159
158
|
autoProceed: true,
|
|
160
159
|
});
|
|
161
|
-
if (Number(network.chainId) ===
|
|
160
|
+
if (Number(network.chainId) === checkout!.config.l2ChainId) {
|
|
162
161
|
setView(FundingRouteExecuteViews.EXECUTE_SWAP);
|
|
163
162
|
return;
|
|
164
163
|
}
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
SwapWidgetViews,
|
|
35
35
|
} from '../../context/view-context/SwapViewContextTypes';
|
|
36
36
|
import { StrongCheckoutWidgetsConfig } from '../../lib/withDefaultWidgetConfig';
|
|
37
|
-
import { DEFAULT_BALANCE_RETRY_POLICY
|
|
37
|
+
import { DEFAULT_BALANCE_RETRY_POLICY } from '../../lib';
|
|
38
38
|
import { StatusView } from '../../components/Status/StatusView';
|
|
39
39
|
import { StatusType } from '../../components/Status/StatusType';
|
|
40
40
|
import { ErrorView } from '../../views/error/ErrorView';
|
|
@@ -176,7 +176,7 @@ export default function SwapWidget({
|
|
|
176
176
|
|
|
177
177
|
// If the provider's network is not the correct network, return out of this and let the
|
|
178
178
|
// connect loader handle the switch network functionality
|
|
179
|
-
if (Number(network.chainId) !==
|
|
179
|
+
if (Number(network.chainId) !== checkout.config.l2ChainId) return;
|
|
180
180
|
|
|
181
181
|
swapDispatch({
|
|
182
182
|
payload: {
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from '@imtbl/checkout-sdk';
|
|
12
12
|
import { Base } from '../BaseWidgetRoot';
|
|
13
13
|
import { ConnectLoader, ConnectLoaderParams } from '../../components/ConnectLoader/ConnectLoader';
|
|
14
|
-
import { getL2ChainId } from '../../lib';
|
|
15
14
|
import { isValidAddress, isValidAmount, isValidWalletProvider } from '../../lib/validations/widgetValidators';
|
|
16
15
|
import { ThemeProvider } from '../../components/ThemeProvider/ThemeProvider';
|
|
17
16
|
import { CustomAnalyticsProvider } from '../../context/analytics-provider/CustomAnalyticsProvider';
|
|
@@ -84,7 +83,7 @@ export class Swap extends Base<WidgetType.SWAP> {
|
|
|
84
83
|
walletProviderName: this.parameters.walletProviderName,
|
|
85
84
|
browserProvider: this.browserProvider,
|
|
86
85
|
checkout: this.checkout,
|
|
87
|
-
allowedChains: [
|
|
86
|
+
allowedChains: [this.checkout.config.l2ChainId],
|
|
88
87
|
};
|
|
89
88
|
|
|
90
89
|
this.reactRoot!.render(
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
NATIVE,
|
|
27
27
|
DEFAULT_TOKEN_VALIDATION_DECIMALS,
|
|
28
28
|
ESTIMATE_DEBOUNCE,
|
|
29
|
-
getL2ChainId,
|
|
30
29
|
} from '../../../lib';
|
|
31
30
|
import { SelectInput } from '../../../components/FormComponents/SelectInput/SelectInput';
|
|
32
31
|
import {
|
|
@@ -844,7 +843,7 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
844
843
|
const currentChainId = await (provider.provider as any).send('eth_chainId', []);
|
|
845
844
|
// eslint-disable-next-line radix
|
|
846
845
|
const parsedChainId = parseInt(currentChainId.toString());
|
|
847
|
-
if (parsedChainId !==
|
|
846
|
+
if (parsedChainId !== checkout.config.l2ChainId) {
|
|
848
847
|
setShowNetworkSwitchDrawer(true);
|
|
849
848
|
return;
|
|
850
849
|
}
|
|
@@ -1126,7 +1125,7 @@ export function SwapForm({ data, theme, cancelAutoProceed }: SwapFromProps) {
|
|
|
1126
1125
|
/>
|
|
1127
1126
|
<NetworkSwitchDrawer
|
|
1128
1127
|
visible={showNetworkSwitchDrawer}
|
|
1129
|
-
targetChainId={
|
|
1128
|
+
targetChainId={checkout?.config.l2ChainId!}
|
|
1130
1129
|
provider={provider!}
|
|
1131
1130
|
checkout={checkout!}
|
|
1132
1131
|
onCloseDrawer={() => setShowNetworkSwitchDrawer(false)}
|
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
} from '../../context/crypto-fiat-context/CryptoFiatContext';
|
|
23
23
|
import { CryptoFiatProvider } from '../../context/crypto-fiat-context/CryptoFiatProvider';
|
|
24
24
|
import { sendTokens, loadBalances } from './functions';
|
|
25
|
-
import { getL2ChainId } from '../../lib';
|
|
26
25
|
import { TransferComplete } from './TransferComplete';
|
|
27
26
|
import { SendingTokens } from './SendingTokens';
|
|
28
27
|
import { AwaitingApproval } from './AwaitingApproval';
|
|
@@ -154,7 +153,7 @@ function TransferWidgetInner(props: TransferWidgetInputs) {
|
|
|
154
153
|
setViewState({
|
|
155
154
|
type: 'COMPLETE',
|
|
156
155
|
receipt,
|
|
157
|
-
chainId:
|
|
156
|
+
chainId: viewState.checkout.config.l2ChainId,
|
|
158
157
|
checkout: viewState.checkout,
|
|
159
158
|
provider: viewState.provider,
|
|
160
159
|
allowedBalances: viewState.allowedBalances,
|