Open iamdefinitelyahuman opened 4 years ago
Any updates on this?
I made a workaround for this;
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]
impl_proxy = ProjectContract(project, build={'abi': contract_container.abi, 'contractName': contract_name}, address=proxy.address)
return impl_proxy
See tests at this repo
Overview
When dealing with proxy contracts, it's sometimes required to have two different
ProjectContract
objects pointing at the same address. Currently this fails because "contract already exists".Specification
TBD - there must be an elegant solution to this though.