From faae9421a949ad9a8bdf9b50827786231e8b434d Mon Sep 17 00:00:00 2001 From: gzeon Date: Fri, 13 Oct 2023 17:42:45 +0800 Subject: [PATCH 1/4] fix: local rpc issue --- src/utils/getL1TxnReceipt.ts | 24 ++++++++++++++---------- src/utils/getL2ToL1Messages.ts | 6 ++++++ src/utils/network.ts | 3 ++- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/utils/getL1TxnReceipt.ts b/src/utils/getL1TxnReceipt.ts index dc70228..915e05d 100644 --- a/src/utils/getL1TxnReceipt.ts +++ b/src/utils/getL1TxnReceipt.ts @@ -12,16 +12,20 @@ export const getL1TxnReceipt = async ( safeAddDefaultLocalNetwork(); const promises = Object.entries(supportedL1Networks).map( async ([chainID, rpcURL]) => { - const l1Network = await getL1Network(+chainID); - const l1Provider = new StaticJsonRpcProvider(rpcURL); - - const rec = await l1Provider.getTransactionReceipt(txnHash); - if (rec) { - return { - l1TxnReceipt: new L1TransactionReceipt(rec), - l1Network, - l1Provider, - }; + try { + const l1Network = await getL1Network(+chainID); + const l1Provider = new StaticJsonRpcProvider(rpcURL); + + const rec = await l1Provider.getTransactionReceipt(txnHash); + if (rec) { + return { + l1TxnReceipt: new L1TransactionReceipt(rec), + l1Network, + l1Provider, + }; + } + } catch (e) { + console.warn(rpcURL, "not working") } }, ); diff --git a/src/utils/getL2ToL1Messages.ts b/src/utils/getL2ToL1Messages.ts index 8a84287..4c770a2 100644 --- a/src/utils/getL2ToL1Messages.ts +++ b/src/utils/getL2ToL1Messages.ts @@ -25,6 +25,12 @@ export const getL2ToL1Messages = async ( // TODO const l1ChainID = l2Network.partnerChainID as 1 | 5; const l1Provider = new JsonRpcProvider(supportedL1Networks[l1ChainID]); + try { + await l1Provider.getBlockNumber(); + } catch (e) { + console.warn(supportedL1Networks[l1ChainID], "not working") + return null + } const [l1Network, l1BlogNumber, receipt] = await Promise.all([ getL1Network(l1ChainID), l1Provider.getBlockNumber(), diff --git a/src/utils/network.ts b/src/utils/network.ts index edf9c35..c6a5185 100644 --- a/src/utils/network.ts +++ b/src/utils/network.ts @@ -10,6 +10,7 @@ const MAINNET_INFURA_RPC_URL = `https://mainnet.infura.io/v3/${INFURA_KEY}`; const GOERLI_INFURA_RPC_URL = `https://goerli.infura.io/v3/${INFURA_KEY}`; const ARBITRUM_INFURA_RPC_URL = `https://arbitrum-mainnet.infura.io/v3/${INFURA_KEY}`; const ARBITRUM_GOERLI_INFURA_RPC_URL = `https://arbitrum-goerli.infura.io/v3/${INFURA_KEY}`; +const LOCAL_GETH_RPC_URL = `http://localhost:8545`; export enum ChainId { // L1 @@ -39,7 +40,7 @@ export const rpcURLs: RpcMap = { }), [ChainId.Local]: loadEnvironmentVariableWithFallback({ env: process.env.NEXT_PUBLIC_LOCAL_ETHEREUM_RPC_URL, - fallback: MAINNET_INFURA_RPC_URL, + fallback: LOCAL_GETH_RPC_URL, }), // L2 [ChainId.ArbitrumOne]: loadEnvironmentVariableWithFallback({ From f72b1c15b5ad095a9437871a2f1c1a79ecff9b7f Mon Sep 17 00:00:00 2001 From: gzeon Date: Fri, 13 Oct 2023 19:32:38 +0800 Subject: [PATCH 2/4] fix: multiple withdrawal in 1 tx --- src/app/tx/[tx]/L2ToL1MsgsDisplay.tsx | 7 +++++-- src/app/tx/[tx]/page.tsx | 4 +++- src/types.ts | 1 + src/utils/getL2ToL1Messages.ts | 13 ++++++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/app/tx/[tx]/L2ToL1MsgsDisplay.tsx b/src/app/tx/[tx]/L2ToL1MsgsDisplay.tsx index 23e4371..1cbf4ad 100644 --- a/src/app/tx/[tx]/L2ToL1MsgsDisplay.tsx +++ b/src/app/tx/[tx]/L2ToL1MsgsDisplay.tsx @@ -38,6 +38,7 @@ export type L2ToL1MessageDataLike = Pick< deadlineBlock: string; etaSeconds: number; } | null; + l2ToL1EventIndex: number; }; type Props = { l2ToL1Messages: L2ToL1MessageDataLike[]; @@ -81,7 +82,9 @@ function L2ToL1MsgsDisplay({ l2ToL1Messages }: Props) {