Skip to content

Commit

Permalink
fix: hyperchain base address (#276)
Browse files Browse the repository at this point in the history
# 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

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [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 <[email protected]>
Co-authored-by: Alexander Melnikov <[email protected]>
  • Loading branch information
vasyl-ivanchuk and sanekmelnikov authored Aug 22, 2024
1 parent cd679cf commit f58cb8f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/api-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -56,4 +56,4 @@ jobs:

- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.e2e.yaml" down
run: docker compose -f "docker-compose.e2e.yaml" down
3 changes: 2 additions & 1 deletion packages/app/src/composables/useEnvironmentConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnvironmentConfig | null>(null);
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const BASE_TOKEN_L2_ADDRESS = "0x000000000000000000000000000000000000800A";
export const PROXY_CONTRACT_IMPLEMENTATION_ABI = [
{
inputs: [],
Expand Down
1 change: 1 addition & 0 deletions scripts/setup-hyperchain-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}]
});

Expand Down

0 comments on commit f58cb8f

Please sign in to comment.