Skip to content

Commit

Permalink
fix: snap homepage ui error due to goerli network deprecated (#230)
Browse files Browse the repository at this point in the history
* fix: snap ui error

* fix: remove markdown

* fix: reset snap homepage currentNetwork when it is goerli
  • Loading branch information
stanleyyconsensys authored Apr 5, 2024
1 parent b24afce commit 16ba5e9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/starknet-snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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));
}
}

Expand All @@ -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
Expand Down

0 comments on commit 16ba5e9

Please sign in to comment.