Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Mermaid EOA name (#86)
Browse files Browse the repository at this point in the history
* Add name to EAO nodes in mermaid diagram
Ref L2B-2385

* Add changesets

* Update changelog

* Bumped package.json version
  • Loading branch information
aminlatifi authored Oct 26, 2023
1 parent 68f246e commit 8e8c35a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
.vscode
dist

**/.DS_Store
6 changes: 6 additions & 0 deletions packages/discovery/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @l2beat/discovery

## 0.19.1

### Patch Changes

- b34f1df: Use config.json names entry in naming EOAs in the mermaid diagram

## 0.19.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/discovery/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@l2beat/discovery",
"description": "L2Beat discovery - engine & tooling utilized for keeping an eye on L2s",
"version": "0.19.0",
"version": "0.19.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
Expand Down
4 changes: 4 additions & 0 deletions packages/discovery/src/discovery/config/DiscoveryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class DiscoveryConfig {
return this.config.name
}

get names(): Record<string, string> {
return this.config.names ?? {}
}

get chainId(): ChainId {
return this.config.chain
}
Expand Down
10 changes: 7 additions & 3 deletions packages/discovery/src/inversion/runInversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { mkdir, writeFile } from 'fs/promises'
import { isObject } from 'lodash'

import { ConfigReader } from '../discovery/config/ConfigReader'
import { DiscoveryConfig } from '../discovery/config/DiscoveryConfig'
import { ChainId } from '../utils/ChainId'
import { EthereumAddress } from '../utils/EthereumAddress'

Expand All @@ -30,7 +31,8 @@ export async function runInversion(
chain: ChainId,
): Promise<void> {
const discovery = await configReader.readDiscovery(project, chain)
const addresses = calculateInversion(discovery)
const config = await configReader.readConfig(project, chain)
const addresses = calculateInversion(discovery, config)

if (useMermaidMarkup) {
const mermaid = createMermaid(addresses)
Expand Down Expand Up @@ -60,6 +62,7 @@ export async function runInversion(

export function calculateInversion(
discovery: DiscoveryOutput,
config: DiscoveryConfig,
): InvertedAddresses {
const addresses = new Map<string, AddressDetails>()

Expand All @@ -74,8 +77,9 @@ export function calculateInversion(
let details = addresses.get(address)
if (!details) {
details = {
name: discovery.contracts.find((x) => x.address.toString() === address)
?.name,
name:
discovery.contracts.find((x) => x.address.toString() === address)
?.name ?? config.names[address],
address,
roles: [],
}
Expand Down

0 comments on commit 8e8c35a

Please sign in to comment.