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

Commit

Permalink
Fix an edge case in saving flattened source files (#141)
Browse files Browse the repository at this point in the history
* Fix an edge case in saving flattened source files

Suppose there are two contracts in a project. Both named "ContractA". If
we override the name of the contract #1 with "ContractB" its name is
going to be "ContractB" but its derived name is going to be equal to
"ContractA". SourceCodeService while generating sources does not reach
into overrides so the source name is always going to be the
"derivedName". We should always choose the derived name (if present, if
it's not, the name is equal to the derived name).

The edge case we've hit is that in the above example, while checking for
contract clashes we had an array that looked like `[ContractA,
ContractB]` instead of `[ContractA, ContractA]`.

* changeset

* format
  • Loading branch information
mateuszradomski authored Feb 28, 2024
1 parent 99bcb5a commit c32520c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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.43.6

### Patch Changes

- Fix edge case in saving flattened sources

## 0.43.5

### Patch 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.43.5",
"version": "0.43.6",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async function saveFlatSources(
const flatSourcesFolder = `.flat${options.sourcesFolder ?? ''}`
const flatSourcesPath = posix.join(rootPath, flatSourcesFolder)
const allContractNames = results.map((c) =>
c.type !== 'EOA' ? c.name : 'EOA',
c.type !== 'EOA' ? c.derivedName ?? c.name : 'EOA',
)

await rimraf(flatSourcesPath)
Expand Down

0 comments on commit c32520c

Please sign in to comment.