Skip to main content

ImplementationRepository

ImplementationRepository​

INVALID_IMPL​

address INVALID_IMPL

INVALID_LINEAGE_ID​

uint256 INVALID_LINEAGE_ID

upgradeDataFor​

mapping(address => bytes) upgradeDataFor

returns data that will be delegatedCalled when the given implementation is upgraded to

_nextImplementationOf​

mapping(address => address) _nextImplementationOf

mapping from one implementation to the succeeding implementation

lineageIdOf​

mapping(address => uint256) lineageIdOf

Returns the id of the lineage a given implementation belongs to

_currentOfLineage​

mapping(uint256 => address) _currentOfLineage

internal because we expose this through the currentImplementation(uint256) api

currentLineageId​

uint256 currentLineageId

Returns the id of the most recently created lineage

initialize​

function initialize(address _owner, address implementation) external

initialize the repository's state

reverts if _owner is the null address reverts if implementation is not a contract

Parameters​

NameTypeDescription
_owneraddressowner of the repository
implementationaddressinitial implementation in the repository

setUpgradeDataFor​

function setUpgradeDataFor(address implementation, bytes data) external

set data that will be delegate called when a proxy upgrades to the given implementation

reverts when caller is not an admin reverts when the contract is paused reverts if the given implementation isn't registered

createLineage​

function createLineage(address implementation) external returns (uint256)

Create a new lineage of implementations.

This creates a new "root" of a new lineage

reverts if implementation is not a contract

Parameters​

NameTypeDescription
implementationaddressimplementation that will be the first implementation in the lineage

Return Values​

NameTypeDescription
[0]uint256newly created lineage's id

append​

function append(address implementation) external

add a new implementation and set it as the current implementation

reverts if the sender is not an owner reverts if the contract is paused reverts if implementation is not a contract

Parameters​

NameTypeDescription
implementationaddressimplementation to append

append​

function append(address implementation, uint256 lineageId) external

Append an implementation to a specified lineage

reverts if the contract is paused reverts if the sender is not an owner reverts if implementation is not a contract

Parameters​

NameTypeDescription
implementationaddressimplementation to append
lineageIduint256id of lineage to append to

remove​

function remove(address toRemove, address previous) external

Remove an implementation from the chain and "stitch" together its neighbors

If you have a chain of A -> B -> C and I call remove(B, C) it will result in A -> C reverts if previos is not the ancestor of toRemove we need to provide the previous implementation here to be able to successfully "stitch" the chain back together. Because this is an admin action, we can source what the previous version is from events.

Parameters​

NameTypeDescription
toRemoveaddressImplementation to remove
previousaddressImplementation that currently has toRemove as its successor

hasNext​

function hasNext(address implementation) external view returns (bool)

Returns true if an implementation has a next implementation set

Parameters​

NameTypeDescription
implementationaddressimplementation to check

Return Values​

NameTypeDescription
[0]boolThe implementation following the given implementation

has​

function has(address implementation) external view returns (bool)

Returns true if an implementation has already been added

Parameters​

NameTypeDescription
implementationaddressImplementation to check existence of

Return Values​

NameTypeDescription
[0]booltrue if the implementation has already been added

nextImplementationOf​

function nextImplementationOf(address implementation) external view returns (address)

Get the next implementation for a given implementation or address(0) if it doesn't exist

reverts when contract is paused

Parameters​

NameTypeDescription
implementationaddressimplementation to get the upgraded implementation for

Return Values​

NameTypeDescription
[0]addressNext Implementation

lineageExists​

function lineageExists(uint256 lineageId) external view returns (bool)

Returns true if a given lineageId exists

currentImplementation​

function currentImplementation(uint256 lineageId) external view returns (address)

Return the current implementation of a lineage with the given lineageId

currentImplementation​

function currentImplementation() external view returns (address)

return current implementaton of the current lineage

_setUpgradeDataFor​

function _setUpgradeDataFor(address implementation, bytes data) internal

_createLineage​

function _createLineage(address implementation) internal virtual returns (uint256)

_currentImplementation​

function _currentImplementation(uint256 lineageId) internal view returns (address)

_has​

function _has(address implementation) internal view virtual returns (bool)

Returns true if an implementation has already been added

Parameters​

NameTypeDescription
implementationaddressimplementation to check for

Return Values​

NameTypeDescription
[0]booltrue if the implementation has already been added

_append​

function _append(address implementation, uint256 lineageId) internal virtual

Set an implementation to the current implementation

Parameters​

NameTypeDescription
implementationaddressimplementation to set as current implementation
lineageIduint256id of lineage to append to

_remove​

function _remove(address toRemove, address previous) internal virtual

_lineageExists​

function _lineageExists(uint256 lineageId) internal view returns (bool)

Added​

event Added(uint256 lineageId, address newImplementation, address oldImplementation)

Removed​

event Removed(uint256 lineageId, address implementation)

UpgradeDataSet​

event UpgradeDataSet(address implementation, bytes data)