From 9ace8584670a6bcc0e61eb1864ae38202bc75726 Mon Sep 17 00:00:00 2001 From: Jennifer Echenim Date: Fri, 15 Dec 2023 13:31:33 +0400 Subject: [PATCH 1/4] fix: - no MM loading screen - fetch connected accounts on reload --- .../src/components/providers/wallet-provider.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx index 352106394d..32d09cf29c 100644 --- a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx +++ b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx @@ -43,8 +43,10 @@ export const WalletConnectionProvider = ({ const [accounts, setAccounts] = useState(null); const [provider, setProvider] = useState({} as ethers.providers.Web3Provider); - const initialize = async () => { - if (!provider) { + const initialize = async ( + providerInstance: ethers.providers.Web3Provider + ) => { + if (!providerInstance) { return showToast( ToastType.INFO, "Provider is required to initialize wallet connection." @@ -52,15 +54,15 @@ export const WalletConnectionProvider = ({ } try { - await ethService.checkIfMetamaskIsLoaded(provider); + await ethService.checkIfMetamaskIsLoaded(providerInstance); - const fetchedToken = await getToken(provider); + const fetchedToken = await getToken(providerInstance); setToken(fetchedToken); const status = await ethService.isUserConnectedToTenChain(fetchedToken); setWalletConnected(status); - const accounts = await ethService.getAccounts(provider); + const accounts = await ethService.getAccounts(providerInstance); setAccounts(accounts || null); setVersion(await fetchVersion()); } catch (error) { @@ -185,11 +187,13 @@ export const WalletConnectionProvider = ({ if (ethereum && ethereum.isMetaMask) { const providerInstance = new ethers.providers.Web3Provider(ethereum); setProvider(providerInstance); - initialize(); + initialize(providerInstance); ethereum.on("accountsChanged", () => { fetchUserAccounts(); }); + } else { + setLoading(false); } return () => { From 8a8558de7a6547427ac20bd22d256e3973bb3785 Mon Sep 17 00:00:00 2001 From: Jennifer Echenim Date: Fri, 15 Dec 2023 13:32:06 +0400 Subject: [PATCH 2/4] fix latest batch --- .../frontend/src/components/modules/dashboard/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx b/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx index f32bacfa08..a5b30c786f 100644 --- a/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx +++ b/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx @@ -46,7 +46,7 @@ export default function Dashboard() { }, { title: "Latest L2 Batch", - value: batches?.result?.Total || "N/A", + value: latestBatch || "N/A", // TODO: add change // change: "+20.1%", icon: LayersIcon, From f6b97817e145425aff7cdcdddb65c40d8b2d5dc1 Mon Sep 17 00:00:00 2001 From: Jennifer Echenim Date: Fri, 15 Dec 2023 13:39:16 +0400 Subject: [PATCH 3/4] update batch number --- .../frontend/src/components/modules/dashboard/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx b/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx index a5b30c786f..68727b370d 100644 --- a/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx +++ b/tools/obscuroscan_v3/frontend/src/components/modules/dashboard/index.tsx @@ -46,7 +46,9 @@ export default function Dashboard() { }, { title: "Latest L2 Batch", - value: latestBatch || "N/A", + value: latestBatch?.item?.number + ? Number(latestBatch?.item?.number) + : "N/A", // TODO: add change // change: "+20.1%", icon: LayersIcon, From 573def7c5153ce0404900560009d67ea92ba4872 Mon Sep 17 00:00:00 2001 From: Jennifer Echenim Date: Mon, 8 Jan 2024 14:10:59 +0400 Subject: [PATCH 4/4] rm redundant render check Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../tenscan/frontend/src/components/modules/dashboard/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tenscan/frontend/src/components/modules/dashboard/index.tsx b/tools/tenscan/frontend/src/components/modules/dashboard/index.tsx index 68727b370d..2cee6cfa43 100644 --- a/tools/tenscan/frontend/src/components/modules/dashboard/index.tsx +++ b/tools/tenscan/frontend/src/components/modules/dashboard/index.tsx @@ -47,7 +47,7 @@ export default function Dashboard() { { title: "Latest L2 Batch", value: latestBatch?.item?.number - ? Number(latestBatch?.item?.number) + ? Number(latestBatch.item.number) : "N/A", // TODO: add change // change: "+20.1%",