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

Commit

Permalink
Dont discover fnunctions with no output (#89)
Browse files Browse the repository at this point in the history
* Don't discover contract functions with no output

* Bump version
  • Loading branch information
adamiak authored Oct 26, 2023
1 parent ff95ab9 commit 6b72e66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 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.21.0

### Minor Changes

- Skip functions with no outputs during discovery

## 0.20.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.20.0",
"version": "0.21.0",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
Expand Down
12 changes: 12 additions & 0 deletions packages/discovery/src/discovery/handlers/getHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ describe(getHandlers.name, () => {
expect(handlers).toEqual([])
})

it("ignores methods that don't return anything", () => {
const handlers = getHandlers(
[
'function requireUnresolved(uint256 nodeNum) view',
'function requireUnresolvedExists() view',
],
undefined,
DiscoveryLogger.SILENT,
)
expect(handlers).toEqual([])
})

it('ignores write methods', () => {
const handlers = getHandlers(
['function write()'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export function getSystemHandlers(
const arrayHandlers: Handler[] = []

for (const fn of Object.values(abi.functions)) {
if (!fn.constant) {
// function is neither pure nor view
if (!fn.constant || (fn.outputs?.length ?? 0) === 0) {
// function is neither pure nor view, or simply doesn't return anything
continue
} else if (overrides?.ignoreMethods?.includes(fn.name)) {
logger.log(` Skipping ${fn.name}`)
Expand Down

0 comments on commit 6b72e66

Please sign in to comment.