From 16ba5e9a94e7639670a138279db1ee8c22bc70a6 Mon Sep 17 00:00:00 2001 From: Stanley Yuen <102275989+stanleyyconsensys@users.noreply.github.com> Date: Fri, 5 Apr 2024 10:12:19 +0800 Subject: [PATCH] fix: snap homepage ui error due to goerli network deprecated (#230) * fix: snap ui error * fix: remove markdown * fix: reset snap homepage currentNetwork when it is goerli --- packages/starknet-snap/src/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/starknet-snap/src/index.ts b/packages/starknet-snap/src/index.ts index 498cfc4a..2dce482a 100644 --- a/packages/starknet-snap/src/index.ts +++ b/packages/starknet-snap/src/index.ts @@ -248,7 +248,7 @@ export const onInstall: OnInstallHandler = async () => { export const onUpdate: OnUpdateHandler = async () => { const component = panel([ text('Features released with this update:'), - text('- Deprecation of the Starknet Goerli Testnet'), + text('Deprecation of the Starknet Goerli Testnet'), ]); await snap.request({ @@ -273,10 +273,14 @@ export const onHomePage: OnHomePageHandler = async () => { // Account may not exist if the recover account process has not executed. let accContract: AccContract; if (state) { - if (state.currentNetwork) { - accContract = state.accContracts.find((n) => n.chainId == state.currentNetwork.chainId); - } else if (state.accContracts && state.accContracts.length > 0) { - accContract = state.accContracts[0]; + let chainId = STARKNET_SEPOLIA_TESTNET_NETWORK.chainId; + + if (state.currentNetwork && state.currentNetwork.chainId !== STARKNET_TESTNET_NETWORK.chainId) { + chainId = state.currentNetwork.chainId; + } + + if (state.accContracts && state.accContracts.length > 0) { + accContract = state.accContracts.find((n) => isSameChainId(n.chainId, chainId)); } } @@ -288,7 +292,7 @@ export const onHomePage: OnHomePageHandler = async () => { panelItems.push(row('Network', text(`${network.name}`))); const ercToken = state.erc20Tokens.find( - (t) => t.symbol.toLowerCase() == 'eth' && isSameChainId(t.chainId, chainId), + (t) => t.symbol.toLowerCase() === 'eth' && isSameChainId(t.chainId, chainId), ); if (ercToken) { // eslint-disable-next-line @typescript-eslint/no-explicit-any