Skip to content

Commit eb8d90f

Browse files
committed
refactor: streamline network settings and remove unused code
- Removed unused deposit types and network order arrays from NetworkSettings. - Simplified the Wagmi component by eliminating the sorting logic for chains, enhancing readability and maintainability.
1 parent 8491dbd commit eb8d90f

2 files changed

Lines changed: 1 addition & 69 deletions

File tree

apps/app/components/WalletProviders/Wagmi.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { useSettingsState } from "../../context/settings";
22
import resolveChain from "../../lib/resolveChain";
33
import React, { useMemo } from "react";
4-
import NetworkSettings from "../../lib/NetworkSettings";
5-
import { WagmiProvider, createConfig, Config, usePublicClient, useWalletClient } from 'wagmi'
4+
import { WagmiProvider, createConfig, Config } from 'wagmi'
65
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
76
import { Chain, http, fallback, Transport } from 'viem';
87
import { useEvmConnectors } from "../../context/evmConnectorsContext";
@@ -36,10 +35,6 @@ function WagmiComponent({ children }: Props) {
3635
if (cachedConfig) return cachedConfig
3736

3837
const chains = settings?.networks
39-
.sort((a, b) =>
40-
(NetworkSettings.KnownSettings[a.caip2Id]?.ChainOrder || Number(a.chainId))
41-
- (NetworkSettings.KnownSettings[b.caip2Id]?.ChainOrder || Number(b.chainId))
42-
)
4338
.filter(net =>
4439
net.type?.name === NetworkTypes.EVM
4540
&& !isNaN(Number(net.chainId))

apps/app/lib/NetworkSettings.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,18 @@
11
import KnownInternalNames from "./knownIds";
22

3-
export enum DepositType {
4-
Manual = 'manual',
5-
Wallet = 'wallet'
6-
}
7-
83
export enum GasCalculation {
94
Classic = 'classic',
105
OptimismType = 'optimismType'
116
}
127

13-
const destinationOrder = [
14-
KnownInternalNames.Networks.StarkNetMainnet,
15-
KnownInternalNames.Networks.ZksyncEraMainnet,
16-
KnownInternalNames.Networks.ZksyncMainnet,
17-
KnownInternalNames.Networks.ArbitrumNova,
18-
KnownInternalNames.Networks.ArbitrumMainnet,
19-
KnownInternalNames.Networks.OptimismMainnet,
20-
KnownInternalNames.Networks.PolygonZkMainnet,
21-
KnownInternalNames.Networks.EthereumMainnet,
22-
KnownInternalNames.Networks.PolygonMainnet,
23-
KnownInternalNames.Networks.AvalancheMainnet,
24-
KnownInternalNames.Networks.LoopringMainnet,
25-
KnownInternalNames.Networks.BNBChainMainnet,
26-
KnownInternalNames.Networks.MantleMainnet,
27-
KnownInternalNames.Networks.PGNMainnet,
28-
KnownInternalNames.Networks.BaseMainnet,
29-
KnownInternalNames.Networks.OsmosisMainnet,
30-
KnownInternalNames.Networks.ZkspaceMainnet,
31-
KnownInternalNames.Networks.RhinoFiMainnet,
32-
];
33-
34-
const sourceOrder = [
35-
KnownInternalNames.Networks.LineaMainnet,
36-
KnownInternalNames.Networks.ArbitrumMainnet,
37-
KnownInternalNames.Networks.EthereumMainnet,
38-
KnownInternalNames.Networks.StarkNetMainnet,
39-
KnownInternalNames.Networks.BNBChainMainnet,
40-
KnownInternalNames.Networks.OptimismMainnet,
41-
KnownInternalNames.Networks.SolanaMainnet,
42-
KnownInternalNames.Networks.SolanaDevnet,
43-
KnownInternalNames.Networks.ZksyncEraMainnet,
44-
KnownInternalNames.Networks.PolygonMainnet,
45-
KnownInternalNames.Networks.AvalancheMainnet,
46-
KnownInternalNames.Networks.ZksyncMainnet,
47-
KnownInternalNames.Networks.ArbitrumNova,
48-
KnownInternalNames.Networks.PolygonZkMainnet,
49-
KnownInternalNames.Networks.KCCMainnet,
50-
KnownInternalNames.Networks.LoopringMainnet,
51-
KnownInternalNames.Networks.BaseMainnet,
52-
];
53-
548
export default class NetworkSettings {
559
ChainId?: number | string;
5610
DefaultPriorityFee?: number;
5711
BaseFeeMultiplier?: number;
58-
AddressPlaceholder?: string;
59-
OrderInDestination?: number;
60-
OrderInSource?: number;
6112
AccountExplorerTemplate?: string;
6213
TransactionExplorerTemplate?: string;
6314
GasCalculationType?: GasCalculation
6415
isFeatured?: boolean
65-
ChainOrder?: number
6616

6717
public static KnownSettings: { [network: string]: NetworkSettings } = {};
6818

@@ -83,15 +33,13 @@ export default class NetworkSettings {
8333
BaseFeeMultiplier: 1.7
8434
};
8535
NetworkSettings.KnownSettings[KnownInternalNames.Networks.EthereumMainnet] = {
86-
ChainId: 1,
8736
isFeatured: true,
8837
AccountExplorerTemplate: 'https://etherscan.io/address/{0}',
8938
TransactionExplorerTemplate: 'https://etherscan.io/tx/{0}"',
9039
DefaultPriorityFee: 0.3,
9140
BaseFeeMultiplier: 1.7
9241
};
9342
NetworkSettings.KnownSettings[KnownInternalNames.Networks.EthereumSepolia] = {
94-
ChainOrder: 1,
9543
TransactionExplorerTemplate: 'https://sepolia.etherscan.io/tx/{0}',
9644
AccountExplorerTemplate: 'https://sepolia.etherscan.io/address/{0}'
9745
};
@@ -128,17 +76,6 @@ export default class NetworkSettings {
12876
AccountExplorerTemplate: 'https://sepolia.voyager.online/contract/{0}',
12977
};
13078

131-
132-
for (var k in NetworkSettings.KnownSettings) {
133-
let networkSetting = NetworkSettings.KnownSettings[k];
134-
if (networkSetting) {
135-
let destOrder = destinationOrder.indexOf(k);
136-
let srcOrder = sourceOrder.indexOf(k);
137-
138-
networkSetting.OrderInDestination = destOrder < 0 ? destinationOrder.length : destOrder;
139-
networkSetting.OrderInSource = srcOrder < 0 ? destinationOrder.length : srcOrder;
140-
}
141-
}
14279
}
14380
}
14481

0 commit comments

Comments
 (0)