From 0d9dfcd1d22d82e995abc4a23fb86614244faa54 Mon Sep 17 00:00:00 2001 From: Danijel Radakovic <129277218+danijelTxFusion@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:08:53 +0100 Subject: [PATCH] feat(zksync): add zksync local hyperchain networks (#3081) --- .changeset/eighty-wolves-tie.md | 5 ++++ .../zksyncLocalCustomHyperchain.ts | 25 +++++++++++++++++++ .../definitions/zksyncLocalHyperchain.ts | 25 +++++++++++++++++++ .../definitions/zksyncLocalHyperchainL1.ts | 22 ++++++++++++++++ src/chains/index.ts | 3 +++ src/zksync/chains.ts | 3 +++ src/zksync/index.ts | 3 +++ 7 files changed, 86 insertions(+) create mode 100644 .changeset/eighty-wolves-tie.md create mode 100644 src/chains/definitions/zksyncLocalCustomHyperchain.ts create mode 100644 src/chains/definitions/zksyncLocalHyperchain.ts create mode 100644 src/chains/definitions/zksyncLocalHyperchainL1.ts diff --git a/.changeset/eighty-wolves-tie.md b/.changeset/eighty-wolves-tie.md new file mode 100644 index 0000000000..ab8b786e57 --- /dev/null +++ b/.changeset/eighty-wolves-tie.md @@ -0,0 +1,5 @@ +--- +"viem": minor +--- + +Added `ZKsync` local hyperchain networks diff --git a/src/chains/definitions/zksyncLocalCustomHyperchain.ts b/src/chains/definitions/zksyncLocalCustomHyperchain.ts new file mode 100644 index 0000000000..b26f1261d8 --- /dev/null +++ b/src/chains/definitions/zksyncLocalCustomHyperchain.ts @@ -0,0 +1,25 @@ +import { defineChain } from '../../utils/chain/defineChain.js' +import { chainConfig } from '../../zksync/chainConfig.js' + +// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml + +export const zksyncLocalCustomHyperchain = /*#__PURE__*/ defineChain({ + ...chainConfig, + id: 272, + name: 'ZKsync CLI Local Custom Hyperchain', + nativeCurrency: { name: 'BAT', symbol: 'BAT', decimals: 18 }, + rpcUrls: { + default: { + http: ['http://localhost:15200'], + webSocket: ['ws://localhost:15201'], + }, + }, + blockExplorers: { + default: { + name: 'ZKsync explorer', + url: 'http://localhost:15005/', + apiUrl: 'http://localhost:15005/api', + }, + }, + testnet: true, +}) diff --git a/src/chains/definitions/zksyncLocalHyperchain.ts b/src/chains/definitions/zksyncLocalHyperchain.ts new file mode 100644 index 0000000000..faa6f5a17e --- /dev/null +++ b/src/chains/definitions/zksyncLocalHyperchain.ts @@ -0,0 +1,25 @@ +import { defineChain } from '../../utils/chain/defineChain.js' +import { chainConfig } from '../../zksync/chainConfig.js' + +// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml + +export const zksyncLocalHyperchain = /*#__PURE__*/ defineChain({ + ...chainConfig, + id: 270, + name: 'ZKsync CLI Local Hyperchain', + nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { + default: { + http: ['http://localhost:15100'], + webSocket: ['ws://localhost:15101'], + }, + }, + blockExplorers: { + default: { + name: 'ZKsync explorer', + url: 'http://localhost:15005/', + apiUrl: 'http://localhost:15005/api', + }, + }, + testnet: true, +}) diff --git a/src/chains/definitions/zksyncLocalHyperchainL1.ts b/src/chains/definitions/zksyncLocalHyperchainL1.ts new file mode 100644 index 0000000000..edeaf087c7 --- /dev/null +++ b/src/chains/definitions/zksyncLocalHyperchainL1.ts @@ -0,0 +1,22 @@ +import { defineChain } from '../../utils/chain/defineChain.js' + +// The local hyperchain setup: https://github.com/matter-labs/local-setup/blob/main/zk-chains-docker-compose.yml + +export const zksyncLocalHyperchainL1 = /*#__PURE__*/ defineChain({ + id: 9, + name: 'ZKsync CLI Local Hyperchain L1', + nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 }, + rpcUrls: { + default: { + http: ['http://localhost:15045'], + }, + }, + blockExplorers: { + default: { + name: 'Blockscout', + url: 'http://localhost:15001/', + apiUrl: 'http://localhost:15001/api/v2', + }, + }, + testnet: true, +}) diff --git a/src/chains/index.ts b/src/chains/index.ts index 780bb9a899..142de3f574 100644 --- a/src/chains/index.ts +++ b/src/chains/index.ts @@ -477,6 +477,9 @@ export { zksyncInMemoryNode as zkSyncInMemoryNode, zksyncInMemoryNode, } from './definitions/zksyncInMemoryNode.js' +export { zksyncLocalCustomHyperchain } from './definitions/zksyncLocalCustomHyperchain.js' +export { zksyncLocalHyperchain } from './definitions/zksyncLocalHyperchain.js' +export { zksyncLocalHyperchainL1 } from './definitions/zksyncLocalHyperchainL1.js' export { /** @deprecated Use `zksync` instead */ zksyncLocalNode as zkSyncLocalNode, diff --git a/src/zksync/chains.ts b/src/zksync/chains.ts index a9cb36fcd0..880fb85085 100644 --- a/src/zksync/chains.ts +++ b/src/zksync/chains.ts @@ -1,5 +1,8 @@ // biome-ignore lint/performance/noBarrelFile: entrypoint module export { zksync } from '../chains/definitions/zksync.js' export { zksyncInMemoryNode } from '../chains/definitions/zksyncInMemoryNode.js' +export { zksyncLocalCustomHyperchain } from '../chains/definitions/zksyncLocalCustomHyperchain.js' +export { zksyncLocalHyperchain } from '../chains/definitions/zksyncLocalHyperchain.js' +export { zksyncLocalHyperchainL1 } from '../chains/definitions/zksyncLocalHyperchainL1.js' export { zksyncLocalNode } from '../chains/definitions/zksyncLocalNode.js' export { zksyncSepoliaTestnet } from '../chains/definitions/zksyncSepoliaTestnet.js' diff --git a/src/zksync/index.ts b/src/zksync/index.ts index 99754b75f3..dfec3a3451 100644 --- a/src/zksync/index.ts +++ b/src/zksync/index.ts @@ -126,6 +126,9 @@ export { zksync, /** @deprecated Use `zksync` instead */ zksyncInMemoryNode as zkSyncInMemoryNode, + zksyncLocalCustomHyperchain, + zksyncLocalHyperchain, + zksyncLocalHyperchainL1, zksyncInMemoryNode, /** @deprecated Use `zksync` instead */ zksyncLocalNode as zkSyncLocalNode,