Skip to content

Workaround for testing Proxy Contracts using brownie Smart Contract Framework

License

Notifications You must be signed in to change notification settings

aekasitt/brownie-proxy-workaround

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Workaround for Proxy Contracts on eth-brownie

See tests/fixtures.py on how I did my Proxy Contract wrapping using other ContractContainers

The contracts in contracts/ directory is a simple-to-use Proxy Example by github/tagupta; If interested, check out her contract repo Proxy-Contract

TL;DR

The following snippet works.

from brownie import Proxy, Impl
from brownie.exceptions import ContractExists
from brownie.network.contract import ProjectContract, ContractContainer
from brownie.project.main import get_loaded_projects, Project

def wrap_proxy(contract_container: ContractContainer = Impl, contract_name: str = 'Impl') -> Impl:
  impl: Impl   = Impl.at('0x...')  # Deplyed Impl
  proxy: Proxy = Proxy.at('0x...') # Deployed Proxy
  impl_proxy: Impl
  try:
    impl_proxy = Impl.at(proxy.address)
  except ContractExists:
    project: Project = get_loaded_projects()[0]
    build: dict      = {'abi': contract_container.abi, 'contractName': contract_name}
    impl_proxy       = ProjectContract(project, build=build, address=proxy.address)
  return impl_proxy

Contributions

Clone the Repository to your local machine and set up your environment with poetry

pip install poetry
poetry install

Tests

To run tests;

pytest tests/*

License

This project is licensed under the terms of the MIT license.

About

Workaround for testing Proxy Contracts using brownie Smart Contract Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published