Skip to content

Commit 62343f1

Browse files
Fix chain switch error blocking L2→L1 withdrawal claims (#3646)
* Disable L2→L1 claim when the parent chain is missing from the wallet. Prevents the opaque switch-chain toast on Claim and points the hpp preset at explorer.hpp.io for repro. Co-authored-by: Cursor <cursoragent@cursor.com> * fix test --------- Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent b779051 commit 62343f1

5 files changed

Lines changed: 55 additions & 15 deletions

File tree

src/config/test-utils/env-presets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const ENVS_MAP: Record<string, Array<[string, string]>> = {
1818
],
1919
arbitrumRollup: [
2020
[ 'NEXT_PUBLIC_ROLLUP_TYPE', 'arbitrum' ],
21-
[ 'NEXT_PUBLIC_ROLLUP_PARENT_CHAIN', '{"name":"DuckChain","baseUrl":"https://localhost:3101"}' ],
21+
[ 'NEXT_PUBLIC_ROLLUP_PARENT_CHAIN', '{"name":"DuckChain","baseUrl":"https://localhost:3101","id":11155111,"rpcUrls":["https://localhost:3101"],"currency":{"name":"Ether","symbol":"ETH","decimals":18},"isTestnet":true}' ],
2222
[ 'NEXT_PUBLIC_ROLLUP_DA_CELESTIA_NAMESPACE', '0x1234' ],
2323
[ 'NEXT_PUBLIC_ROLLUP_DA_CELESTIA_CELENIUM_URL', 'https://mocha.celenium.io/blob' ],
2424
],

src/features/rollup/arbitrum/pages/txn-withdrawals/ArbitrumL2TxnWithdrawalsClaimButton.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { ResourceError } from 'src/api/resources';
1212

1313
import Web3Boundary from 'src/features/connect-wallet/components/Web3Boundary';
1414
import useWallet from 'src/features/connect-wallet/hooks/useWallet';
15+
import WithdrawalClaimButton from 'src/features/rollup/common/components/WithdrawalClaimButton';
1516

1617
import config from 'src/config';
1718
import getErrorMessage from 'src/shared/errors/get-error-message';
@@ -20,7 +21,6 @@ import getErrorProp from 'src/shared/errors/get-error-prop';
2021
import capitalizeFirstLetter from 'src/shared/texts/capitalize-first-letter';
2122

2223
import { Button } from 'src/toolkit/chakra/button';
23-
import { Skeleton } from 'src/toolkit/chakra/skeleton';
2424
import { toaster } from 'src/toolkit/chakra/toaster';
2525

2626
import ArbitrumL2TxnWithdrawalsClaimTx from './ArbitrumL2TxnWithdrawalsClaimTx';
@@ -128,17 +128,13 @@ const ArbitrumL2TxnWithdrawalsClaimButtonContent = ({ messageId, txHash, complet
128128
const isLoading = isPending || web3Wallet.isOpen;
129129

130130
return (
131-
<Skeleton loading={ isDataLoading }>
132-
<Button
133-
size="sm"
134-
variant="outline"
135-
onClick={ handleClaimClick }
136-
loading={ isLoading }
137-
loadingText="Claim"
138-
>
139-
Claim
140-
</Button>
141-
</Skeleton>
131+
<WithdrawalClaimButton
132+
onClick={ handleClaimClick }
133+
loading={ isLoading }
134+
loadingSkeleton={ isDataLoading }
135+
>
136+
Claim
137+
</WithdrawalClaimButton>
142138
);
143139
};
144140

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: LicenseRef-Blockscout
2+
3+
import React from 'react';
4+
5+
import { chains } from 'src/features/connect-wallet/utils/chains';
6+
import { useMultichainContext } from 'src/features/multichain/context';
7+
8+
import config from 'src/config';
9+
import { getFeaturePayload } from 'src/config/utils/features';
10+
11+
import type { ButtonProps } from 'src/toolkit/chakra/button';
12+
import { Button } from 'src/toolkit/chakra/button';
13+
import { Tooltip } from 'src/toolkit/chakra/tooltip';
14+
15+
const WithdrawalClaimButton = (props: ButtonProps) => {
16+
17+
const multichainContext = useMultichainContext();
18+
const parentChain = getFeaturePayload((multichainContext?.chain.app_config ?? config).features.rollup)?.parentChain;
19+
const isParentChainConfigured = Boolean(parentChain?.id && chains.some(chain => chain.id === parentChain.id));
20+
21+
return (
22+
<Tooltip
23+
content="The direct claim flow is not available because the parent chain is not configured. Please contact the project team to report this issue."
24+
disabled={ isParentChainConfigured }
25+
>
26+
<Button
27+
variant="outline"
28+
size="sm"
29+
disabled={ !isParentChainConfigured }
30+
{ ...props }
31+
>
32+
Claim
33+
</Button>
34+
</Tooltip>
35+
);
36+
};
37+
38+
export default React.memo(WithdrawalClaimButton);

src/features/rollup/optimism/components/OptimisticL2ClaimButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import { Button } from 'src/toolkit/chakra/button';
1414
import { Link } from 'src/toolkit/chakra/link';
1515
import { useDisclosure } from 'src/toolkit/hooks/useDisclosure';
1616

17+
import WithdrawalClaimButton from '../../common/components/WithdrawalClaimButton';
18+
1719
const rollupFeature = config.features.rollup;
1820

1921
export const canClaimDirectlyGuard = (data: Omit<schemas['OptimismTransactionWithdrawal'], 'nonce'>) => {
@@ -57,7 +59,11 @@ const OptimisticL2ClaimButton = ({ data, from, onSuccess, source }: Props) => {
5759
/>
5860
</Web3Boundary>
5961
) }
60-
<Button variant="outline" size="sm" onClick={ modal.onOpen }>Claim</Button>
62+
<WithdrawalClaimButton
63+
onClick={ modal.onOpen }
64+
>
65+
Claim
66+
</WithdrawalClaimButton>
6167
</>
6268
);
6369
}

tools/dev-server/registry.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"garnet": "https://explorer.garnetchain.com",
1313
"gnosis": "https://gnosis.blockscout.com",
1414
"gnosis_chiado": "https://gnosis-chiado.blockscout.com",
15-
"hpp": "https://hpp.blockscout.com",
15+
"hpp": "https://explorer.hpp.io",
1616
"immutable": "https://explorer.immutable.com",
1717
"mega_eth": "https://megaeth.blockscout.com",
1818
"multichain": "https://explorer.blockscout.com",

0 commit comments

Comments
 (0)