|
| 1 | +import { useEffect } from "react"; |
1 | 2 | import { AlertInline, Button, Spinner } from "@aragon/ods"; |
2 | 3 | import { useWeb3Modal } from "@web3modal/wagmi/react"; |
3 | 4 | import { type Hex } from "viem"; |
4 | 5 | import { useAccount, useSwitchChain } from "wagmi"; |
5 | 6 | import { PUB_TAIKO_BRIDGE_ADDRESS, TAIKO_L2_CHAIN_ID } from "@/constants"; |
| 7 | +import { useWalletChainPolicy } from "@/context/WalletChainPolicy"; |
6 | 8 | import { useL2AnchorSync } from "@/hooks/useL2AnchorSync"; |
7 | 9 | import { useL2LegExecution } from "@/hooks/useL2LegExecution"; |
8 | 10 | import { shouldRenderL2ExecutionCard } from "@/utils/l2-execution"; |
@@ -37,6 +39,7 @@ export function ProposalL2Execution({ |
37 | 39 | const { isConnected, chain } = useAccount(); |
38 | 40 | const { open } = useWeb3Modal(); |
39 | 41 | const { switchChain } = useSwitchChain(); |
| 42 | + const { setAllowedSecondaryChainIds } = useWalletChainPolicy(); |
40 | 43 |
|
41 | 44 | const l1BlockNumber = executionBlockNumber ? BigInt(executionBlockNumber) : undefined; |
42 | 45 | const l1TxHash = executorTxHash as Hex | undefined; |
@@ -69,6 +72,15 @@ export function ProposalL2Execution({ |
69 | 72 | const detectedFromTx = !!message; |
70 | 73 |
|
71 | 74 | const hasL2Leg = detectedFromActions || detectedFromTx; |
| 75 | + const shouldAllowTaikoL2 = executed && shouldCheckL2 && !isL2Confirmed; |
| 76 | + |
| 77 | + useEffect(() => { |
| 78 | + setAllowedSecondaryChainIds(shouldAllowTaikoL2 ? [TAIKO_L2_CHAIN_ID] : []); |
| 79 | + |
| 80 | + return () => { |
| 81 | + setAllowedSecondaryChainIds([]); |
| 82 | + }; |
| 83 | + }, [setAllowedSecondaryChainIds, shouldAllowTaikoL2]); |
72 | 84 |
|
73 | 85 | // Don't render if no L2 leg detected (and not still checking) |
74 | 86 | if (!shouldRenderL2ExecutionCard({ hasL2Leg, isExtracting, shouldCheckExecutedProposal: shouldCheckL2 })) { |
|
0 commit comments