Skip to content

Commit b812213

Browse files
committed
feat: add more chains
Adds Linea, Arbitrum Nova, Celo, Avalanche, Avalanche Fuji, Gnosis
1 parent b2e720c commit b812213

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

src/routes/contract/controller.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@ import {
1616
toEventSelector,
1717
toFunctionSelector,
1818
} from 'viem';
19-
import { mode, modeTestnet } from 'viem/chains';
19+
import { celo, linea, mode, modeTestnet } from 'viem/chains';
2020

2121
import EtherscanService from '@/services/etherscan';
2222
import MinioService, { type ContractSource } from '@/services/minio';
23-
import { ChainId, getChainData, MODE, MODE_SEPOLIA } from '@/utils/chains';
23+
import {
24+
ChainId,
25+
getChainData,
26+
MODE,
27+
MODE_SEPOLIA,
28+
LINEA,
29+
CELO,
30+
} from '@/utils/chains';
2431
import { Deployment, SourceCode } from '@/utils/contracts';
2532
import { toErrorSelector } from '@/utils/evm';
2633
import { getImplementation } from '@/utils/proxy';
@@ -88,6 +95,12 @@ function getClient(chain: ChainId, alchemyKey: string): PublicClient {
8895
if (chain === MODE_SEPOLIA) {
8996
return modeTestnet.rpcUrls.default.http[0];
9097
}
98+
if (chain === LINEA) {
99+
return linea.rpcUrls.default.http[0];
100+
}
101+
if (chain === CELO) {
102+
return celo.rpcUrls.default.http[0];
103+
}
91104
return alchemy(chain, alchemyKey);
92105
}
93106

src/routes/label/utils.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import {
1414
SEPOLIA,
1515
MODE,
1616
MODE_SEPOLIA,
17+
LINEA,
18+
ARBITRUM_NOVA,
19+
CELO,
20+
AVALANCHE,
21+
AVALANCHE_FUJI,
22+
GNOSIS,
1723
} from '@/utils/chains';
1824
import {
1925
LabelType,
@@ -175,6 +181,18 @@ function getErc20Icon(chain: ChainId, address: string): string | undefined {
175181
return null;
176182
case MODE_SEPOLIA:
177183
return null;
184+
case LINEA:
185+
return 'linea';
186+
case ARBITRUM_NOVA:
187+
return null;
188+
case CELO:
189+
return 'celo';
190+
case AVALANCHE:
191+
return 'avalanchec';
192+
case AVALANCHE_FUJI:
193+
return 'avalanchecfuji';
194+
case GNOSIS:
195+
return 'xdai';
178196
}
179197
}
180198
const chainName = getChainName(chain);

src/utils/chains.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import {
1313
arbitrumSepolia,
1414
mode,
1515
modeTestnet,
16+
linea,
17+
arbitrumNova,
18+
celo,
19+
avalanche,
20+
avalancheFuji,
21+
gnosis,
1622
} from 'viem/chains';
1723

1824
const ETHEREUM = mainnet.id;
@@ -27,6 +33,12 @@ const ARBITRUM = arbitrum.id;
2733
const ARBITRUM_SEPOLIA = arbitrumSepolia.id;
2834
const MODE = mode.id;
2935
const MODE_SEPOLIA = modeTestnet.id;
36+
const LINEA = linea.id;
37+
const ARBITRUM_NOVA = arbitrumNova.id;
38+
const CELO = celo.id;
39+
const AVALANCHE = avalanche.id;
40+
const AVALANCHE_FUJI = avalancheFuji.id;
41+
const GNOSIS = gnosis.id;
3042

3143
const CHAINS: ChainId[] = [
3244
ETHEREUM,
@@ -41,6 +53,12 @@ const CHAINS: ChainId[] = [
4153
ARBITRUM_SEPOLIA,
4254
MODE,
4355
MODE_SEPOLIA,
56+
LINEA,
57+
ARBITRUM_NOVA,
58+
CELO,
59+
AVALANCHE,
60+
AVALANCHE_FUJI,
61+
GNOSIS,
4462
];
4563

4664
const chainSchema = v.union([
@@ -57,6 +75,12 @@ const chainSchema = v.union([
5775
v.literal(ARBITRUM_SEPOLIA.toString()),
5876
v.literal(MODE.toString()),
5977
v.literal(MODE_SEPOLIA.toString()),
78+
v.literal(LINEA.toString()),
79+
v.literal(ARBITRUM_NOVA.toString()),
80+
v.literal(CELO.toString()),
81+
v.literal(AVALANCHE.toString()),
82+
v.literal(AVALANCHE_FUJI.toString()),
83+
v.literal(GNOSIS.toString()),
6084
]);
6185

6286
type ChainId =
@@ -71,7 +95,13 @@ type ChainId =
7195
| typeof ARBITRUM
7296
| typeof ARBITRUM_SEPOLIA
7397
| typeof MODE
74-
| typeof MODE_SEPOLIA;
98+
| typeof MODE_SEPOLIA
99+
| typeof LINEA
100+
| typeof ARBITRUM_NOVA
101+
| typeof CELO
102+
| typeof AVALANCHE
103+
| typeof AVALANCHE_FUJI
104+
| typeof GNOSIS;
75105

76106
function getChainData(chain: ChainId): ChainData {
77107
switch (chain) {
@@ -99,6 +129,18 @@ function getChainData(chain: ChainId): ChainData {
99129
return mode;
100130
case MODE_SEPOLIA:
101131
return modeTestnet;
132+
case LINEA:
133+
return linea;
134+
case ARBITRUM_NOVA:
135+
return arbitrumNova;
136+
case CELO:
137+
return celo;
138+
case AVALANCHE:
139+
return avalanche;
140+
case AVALANCHE_FUJI:
141+
return avalancheFuji;
142+
case GNOSIS:
143+
return gnosis;
102144
}
103145
}
104146

@@ -120,6 +162,12 @@ export {
120162
ARBITRUM_SEPOLIA,
121163
MODE,
122164
MODE_SEPOLIA,
165+
LINEA,
166+
ARBITRUM_NOVA,
167+
CELO,
168+
AVALANCHE,
169+
AVALANCHE_FUJI,
170+
GNOSIS,
123171
getChainData,
124172
parseChainId,
125173
chainSchema,

0 commit comments

Comments
 (0)