Skip to content

Make TransparentUpgradeableProxy work with existing ProxyAdmins #5855

@Arvolear

Description

@Arvolear

🧐 Motivation

Currently, the TransparentUpgradeableProxy deploys the ProxyAdmin every time in the constructor. It would be great if it were possible to pass the existing ProxyAdmin address for reuse.

📝 Details

The current constructor logic is the following:

contract TransparentUpgradeableProxy is ERC1967Proxy {
    ...

    constructor(address _logic, address initialOwner, bytes memory _data) payable ERC1967Proxy(_logic, _data) {
        _admin = address(new ProxyAdmin(initialOwner));

        ERC1967Utils.changeAdmin(_proxyAdmin());
    }

    ...
}

Propose a slight modification:

contract TransparentUpgradeableProxy is ERC1967Proxy {
    ...

    constructor(
        address _logic,
        address initialOwnerOrAdmin,
        bool isOwner,
        bytes memory _data
    ) payable ERC1967Proxy(_logic, _data) {
        if (isOwner) {
            _admin = address(new ProxyAdmin(initialOwnerOrAdmin));
        } else {
            _admin = initialOwnerOrAdmin;
        }

        ERC1967Utils.changeAdmin(_proxyAdmin());
    }

    ...
}

This would allow various transparent proxies to be used in factories when a single contract is responsible for their management.

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