Skip to content

publish_source fails with deployed library #1996

@sschuldenzucker

Description

@sschuldenzucker

Environment information

  • brownie Version: 1.21.0
  • ganache-cli Version: x.x.x (irrelevant)
  • solc Version: 0.7.6
  • Python Version: 3.12.4
  • OS: osx

What was wrong?

I'm using a contract (say MyContract) that is deployed with the library also being deployed (not compiled into the contract). The library is in libraries/. When I want to verify this, I'm getting the following crash:

❯ brownie console --network bsc-main
Brownie v1.21.0 - Python development framework for Ethereum

VaultsDevProject is the active project.
Brownie environment is ready.
>>> cc = MyContract
>>> c = cc[-1]
>>> cc.publish_source(c)
  File "<console>", line 1, in <module>
  File "brownie/network/contract.py", line 335, in publish_source
    contract_info = self.get_verification_info()
  File "brownie/network/contract.py", line 305, in get_verification_info
    self._flattener = Flattener(source_fp, self._name, remaps, compiler_settings)
  File "brownie/project/flattener.py", line 32, in __init__
    self.traverse(primary_source_fp)
  File "brownie/project/flattener.py", line 74, in traverse
    self.sources[name] = IMPORT_PATTERN.sub(repl, source)
  File "brownie/project/flattener.py", line 71, in <lambda>
    + f'"{self.path_to_name(sanitize(m.group("path")))}"'
  File "brownie/project/flattener.py", line 44, in path_to_name
    return "contracts/" + pth.split("/contracts/")[1]
IndexError: list index out of range

Guessing from the code, it seems that brownie expects my library at contracts/, where it is not.

How can it be fixed?

Use a better method for tracing dependencies that hard-coding "/contracts/" as a separator. Actually include all the dirs where source files might be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions