From f58cb8f92d986ae424d71de823413f6fdb869f08 Mon Sep 17 00:00:00 2001 From: Vasyl Ivanchuk Date: Thu, 22 Aug 2024 13:50:47 +0300 Subject: [PATCH] fix: hyperchain base address (#276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ Adding missing baseTokenAddress to the hyperchain configuration. Adding a fallback to use the default L2 base token address if it's not specified in the config. ## Why ❔ When configuring the block explorer using npm run hyperchain:configure, the resulting configuration was missing the baseTokenAddress value. This absence was causing an error [here](https://github.com/matter-labs/block-explorer/blob/main/packages/app/src/composables/useEnvironmentConfig.ts#L31). As a result of this error, the system was defaulting to Sepolia (which I assume is not the intended behavior for your hyperchain setup). ## Checklist - [X] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [X] Tests for the changes have been added / updated. - [X] Documentation comments have been added / updated. --------- Signed-off-by: Vasyl Ivanchuk Co-authored-by: Alexander Melnikov --- .github/workflows/api-e2e.yml | 4 ++-- packages/app/src/composables/useEnvironmentConfig.ts | 3 ++- packages/app/src/utils/constants.ts | 1 + scripts/setup-hyperchain-config.ts | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/api-e2e.yml b/.github/workflows/api-e2e.yml index 7879184d36..eee3bb60e2 100644 --- a/.github/workflows/api-e2e.yml +++ b/.github/workflows/api-e2e.yml @@ -29,7 +29,7 @@ jobs: - name: Start docker containers run: | - docker-compose -f "docker-compose.e2e.yaml" up -d --build + docker compose -f "docker-compose.e2e.yaml" up -d --build - name: Setup Node.js uses: actions/setup-node@v3 @@ -56,4 +56,4 @@ jobs: - name: Stop containers if: always() - run: docker-compose -f "docker-compose.e2e.yaml" down \ No newline at end of file + run: docker compose -f "docker-compose.e2e.yaml" down \ No newline at end of file diff --git a/packages/app/src/composables/useEnvironmentConfig.ts b/packages/app/src/composables/useEnvironmentConfig.ts index 30c4dbd8ae..1133f179e8 100644 --- a/packages/app/src/composables/useEnvironmentConfig.ts +++ b/packages/app/src/composables/useEnvironmentConfig.ts @@ -2,6 +2,7 @@ import { computed, ref } from "vue"; import type { EnvironmentConfig, NetworkConfig, RuntimeConfig } from "@/configs"; +import { BASE_TOKEN_L2_ADDRESS } from "@/utils/constants"; import { checksumAddress } from "@/utils/formatters"; const config = ref(null); @@ -28,7 +29,7 @@ export async function loadEnvironmentConfig(runtimeConfig: RuntimeConfig): Promi } envConfig.networks?.forEach((networkConfig) => { - networkConfig.baseTokenAddress = checksumAddress(networkConfig.baseTokenAddress); + networkConfig.baseTokenAddress = checksumAddress(networkConfig.baseTokenAddress || BASE_TOKEN_L2_ADDRESS); }); config.value = envConfig; diff --git a/packages/app/src/utils/constants.ts b/packages/app/src/utils/constants.ts index 7048c3c0ef..8e8c9c72c8 100644 --- a/packages/app/src/utils/constants.ts +++ b/packages/app/src/utils/constants.ts @@ -1,3 +1,4 @@ +export const BASE_TOKEN_L2_ADDRESS = "0x000000000000000000000000000000000000800A"; export const PROXY_CONTRACT_IMPLEMENTATION_ABI = [ { inputs: [], diff --git a/scripts/setup-hyperchain-config.ts b/scripts/setup-hyperchain-config.ts index 56652b485e..f2137ad191 100644 --- a/scripts/setup-hyperchain-config.ts +++ b/scripts/setup-hyperchain-config.ts @@ -18,6 +18,7 @@ const buildAppConfig = (zkSyncEnvs: { [key: string]: string }) => ({ name: zkSyncEnvs.CHAIN_ETH_ZKSYNC_NETWORK || "", published: true, rpcUrl: zkSyncEnvs.API_WEB3_JSON_RPC_HTTP_URL || "", + baseTokenAddress: zkSyncEnvs.ETH_TOKEN_L2_ADDRESS || "0x000000000000000000000000000000000000800A", }] });