Skip to content

Commit

Permalink
nit(viem): remove Mainnet as a suffix for exported chains (#624)
Browse files Browse the repository at this point in the history
* remove Mainnet as a chain export suffix

* changeset

* lint
  • Loading branch information
hamdiallam authored Jan 21, 2025
1 parent 416a103 commit 7b8ae33
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 46 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-terms-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@eth-optimism/viem": minor
---

removed Mainnet as a suffix for exported chains
10 changes: 8 additions & 2 deletions packages/viem/scripts/chaingen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createPublicClient, erc20Abi, http } from 'viem'
import { mainnet, sepolia } from 'viem/chains'

// Hardcoded. Can take a more elaborate approach if needed.
const NETWORKS = ['mainnet', 'sepolia']
const NETWORKS: Array<'mainnet' | 'sepolia'> = ['mainnet', 'sepolia']
const SUPERCHAIN_REGISTRY_PATH = path.join(
'..',
'..',
Expand Down Expand Up @@ -131,9 +131,15 @@ async function main() {
.replace('.toml', '')
.replace('-testnet', '')

// Apply a suffix if a network other than mainnet
const exportName =
network === 'mainnet'
? normalizedName
: `${normalizedName}-${network}`

return {
chainName: chainConfig.name as string,
exportName: camelCase(`${normalizedName}-${network}`),
exportName: camelCase(exportName),
chainId: chainConfig.chain_id as number,
sourceChainId: network === 'mainnet' ? 1 : 11155111,
rpc: chainConfig.public_rpc as string,
Expand Down
88 changes: 44 additions & 44 deletions packages/viem/src/chains/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { chainConfig } from 'viem/op-stack'
/**
* Chain Definition for arena-z
*/
export const arenaZMainnet = /*#__PURE__*/ defineChain({
export const arenaZ = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'arena-z',
id: 7897,
Expand Down Expand Up @@ -64,7 +64,7 @@ export const arenaZMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Automata Mainnet
*/
export const automataMainnet = /*#__PURE__*/ defineChain({
export const automata = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Automata Mainnet',
id: 65536,
Expand Down Expand Up @@ -128,7 +128,7 @@ export const automataMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Base
*/
export const baseMainnet = /*#__PURE__*/ defineChain({
export const base = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Base',
id: 8453,
Expand Down Expand Up @@ -192,7 +192,7 @@ export const baseMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Cyber Mainnet
*/
export const cyberMainnet = /*#__PURE__*/ defineChain({
export const cyber = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Cyber Mainnet',
id: 7560,
Expand Down Expand Up @@ -256,7 +256,7 @@ export const cyberMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Ethernity
*/
export const ethernityMainnet = /*#__PURE__*/ defineChain({
export const ethernity = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Ethernity',
id: 183,
Expand Down Expand Up @@ -320,7 +320,7 @@ export const ethernityMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Funki
*/
export const funkiMainnet = /*#__PURE__*/ defineChain({
export const funki = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Funki',
id: 33979,
Expand Down Expand Up @@ -384,7 +384,7 @@ export const funkiMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Ink
*/
export const inkMainnet = /*#__PURE__*/ defineChain({
export const ink = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Ink',
id: 57073,
Expand Down Expand Up @@ -443,7 +443,7 @@ export const inkMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Lisk
*/
export const liskMainnet = /*#__PURE__*/ defineChain({
export const lisk = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Lisk',
id: 1135,
Expand Down Expand Up @@ -507,7 +507,7 @@ export const liskMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Lyra Chain
*/
export const lyraMainnet = /*#__PURE__*/ defineChain({
export const lyra = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Lyra Chain',
id: 957,
Expand Down Expand Up @@ -566,7 +566,7 @@ export const lyraMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Metal L2
*/
export const metalMainnet = /*#__PURE__*/ defineChain({
export const metal = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Metal L2',
id: 1750,
Expand Down Expand Up @@ -625,7 +625,7 @@ export const metalMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Mode
*/
export const modeMainnet = /*#__PURE__*/ defineChain({
export const mode = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Mode',
id: 34443,
Expand Down Expand Up @@ -684,7 +684,7 @@ export const modeMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for OP Mainnet
*/
export const opMainnet = /*#__PURE__*/ defineChain({
export const op = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'OP Mainnet',
id: 10,
Expand Down Expand Up @@ -743,7 +743,7 @@ export const opMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Orderly Mainnet
*/
export const orderlyMainnet = /*#__PURE__*/ defineChain({
export const orderly = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Orderly Mainnet',
id: 291,
Expand Down Expand Up @@ -802,7 +802,7 @@ export const orderlyMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for RACE Mainnet
*/
export const raceMainnet = /*#__PURE__*/ defineChain({
export const race = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'RACE Mainnet',
id: 6805,
Expand Down Expand Up @@ -861,7 +861,7 @@ export const raceMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Redstone
*/
export const redstoneMainnet = /*#__PURE__*/ defineChain({
export const redstone = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Redstone',
id: 690,
Expand Down Expand Up @@ -925,7 +925,7 @@ export const redstoneMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Shape
*/
export const shapeMainnet = /*#__PURE__*/ defineChain({
export const shape = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Shape',
id: 360,
Expand Down Expand Up @@ -989,7 +989,7 @@ export const shapeMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Superseed
*/
export const sseedMainnet = /*#__PURE__*/ defineChain({
export const sseed = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Superseed',
id: 5330,
Expand Down Expand Up @@ -1053,7 +1053,7 @@ export const sseedMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Swan Chain Mainnet
*/
export const swanMainnet = /*#__PURE__*/ defineChain({
export const swan = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Swan Chain Mainnet',
id: 254,
Expand Down Expand Up @@ -1117,7 +1117,7 @@ export const swanMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Swellchain
*/
export const swellMainnet = /*#__PURE__*/ defineChain({
export const swell = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Swellchain',
id: 1923,
Expand Down Expand Up @@ -1176,7 +1176,7 @@ export const swellMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Binary Mainnet
*/
export const tbnMainnet = /*#__PURE__*/ defineChain({
export const tbn = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Binary Mainnet',
id: 624,
Expand Down Expand Up @@ -1240,7 +1240,7 @@ export const tbnMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for World Chain
*/
export const worldchainMainnet = /*#__PURE__*/ defineChain({
export const worldchain = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'World Chain',
id: 480,
Expand Down Expand Up @@ -1304,7 +1304,7 @@ export const worldchainMainnet = /*#__PURE__*/ defineChain({
/**
* Chain Definition for Zora
*/
export const zoraMainnet = /*#__PURE__*/ defineChain({
export const zora = /*#__PURE__*/ defineChain({
...chainConfig,
name: 'Zora',
id: 7777777,
Expand Down Expand Up @@ -1361,26 +1361,26 @@ export const zoraMainnet = /*#__PURE__*/ defineChain({
})

export const mainnetChains = [
arenaZMainnet,
automataMainnet,
baseMainnet,
cyberMainnet,
ethernityMainnet,
funkiMainnet,
inkMainnet,
liskMainnet,
lyraMainnet,
metalMainnet,
modeMainnet,
opMainnet,
orderlyMainnet,
raceMainnet,
redstoneMainnet,
shapeMainnet,
sseedMainnet,
swanMainnet,
swellMainnet,
tbnMainnet,
worldchainMainnet,
zoraMainnet,
arenaZ,
automata,
base,
cyber,
ethernity,
funki,
ink,
lisk,
lyra,
metal,
mode,
op,
orderly,
race,
redstone,
shape,
sseed,
swan,
swell,
tbn,
worldchain,
zora,
]

0 comments on commit 7b8ae33

Please sign in to comment.