App
contract App
is Ownable
Contract for upgradeable applications. It handles the creation and upgrading of proxies.
Index
Reference
Events
PackageChanged
event PackageChanged(string providerName, address package, uint64[] version)
Emitted when a package dependency is changed in the application.
- Parameters:
providerName
- Name of the package that changed.package
- Address of the package associated to the name.version
- Version of the package in use.
ProxyCreated
event ProxyCreated(address proxy)
Emitted when a new proxy is created.
- Parameters:
proxy
- Address of the created proxy.
Functions
changeProxyAdmin
function changeProxyAdmin(AdminUpgradeabilityProxy proxy, address newAdmin) public
Changes the admin of a proxy.
- Modifiers:
- onlyOwner
- Parameters:
proxy
- Proxy to change admin.newAdmin
- Address to transfer proxy administration to.
create
function create(string packageName, string contractName, bytes data) public payable returns (AdminUpgradeabilityProxy)
Creates a new proxy for the given contract and forwards a function call to it. This is useful to initialize the proxied contract.
- Parameters:
packageName
- Name of the package where the contract is contained.contractName
- Name of the contract.data
- Data to send as msg.data to the corresponding implementation to initialize the proxied contract. It should include the signature and the parameters of the function to be called, as described in https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding. This parameter is optional, if no data is given the initialization call to proxied contract will be skipped.- Returns:
- Address of the new proxy.
fallback
function () public
Constructor function.
getImplementation
function getImplementation(string packageName, string contractName) public view returns (address)
Returns the implementation address for a given contract name, provided by the `ImplementationProvider`.
- Parameters:
packageName
- Name of the package where the contract is contained.contractName
- Name of the contract.- Returns:
- Address where the contract is implemented.
getPackage
function getPackage(string packageName) public view returns (Package, uint64[])
Returns information on a package given its name.
- Parameters:
packageName
- Name of the package to be queried.- Returns:
- A tuple with the package address and pinned version given a package name, or zero if not set
getProvider
function getProvider(string packageName) public view returns (ImplementationProvider)
Returns the provider for a given package name, or zero if not set.
- Parameters:
packageName
- Name of the package to be retrieved.- Returns:
- The provider.
getProxyAdmin
function getProxyAdmin(AdminUpgradeabilityProxy proxy) public view returns (address)
Returns the admin of a proxy. Only the admin can query it.
- Parameters:
proxy
- AdminUpgradeabilityProxy- Returns:
- The address of the current admin of the proxy.
getProxyImplementation
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address)
Returns the current implementation of a proxy. This is needed because only the proxy admin can query it.
- Parameters:
proxy
- AdminUpgradeabilityProxy- Returns:
- The address of the current implementation of the proxy.
setPackage
function setPackage(string packageName, Package package, uint64[] version) public
Sets a package in a specific version as a dependency for this application. Requires the version to be present in the package.
- Modifiers:
- onlyOwner
- Parameters:
packageName
- Name of the package to set or overwrite.package
- Address of the package to register.version
- Version of the package to use in this application.
unsetPackage
function unsetPackage(string packageName) public
Unsets a package given its name. Reverts if the package is not set in the application.
- Modifiers:
- onlyOwner
- Parameters:
packageName
- Name of the package to remove.
upgrade
function upgrade(AdminUpgradeabilityProxy proxy, string packageName, string contractName) public
Upgrades a proxy to the newest implementation of a contract.
- Modifiers:
- onlyOwner
- Parameters:
proxy
- Proxy to be upgraded.packageName
- Name of the package where the contract is contained.contractName
- Name of the contract.
upgradeAndCall
function upgradeAndCall(AdminUpgradeabilityProxy proxy, string packageName, string contractName, bytes data) public payable
Upgrades a proxy to the newest implementation of a contract and forwards a function call to it. This is useful to initialize the proxied contract.
- Modifiers:
- onlyOwner
- Parameters:
proxy
- Proxy to be upgraded.packageName
- Name of the package where the contract is contained.contractName
- Name of the contract.data
- Data to send as msg.data in the low level call. It should include the signature and the parameters of the function to be called, as described in https://solidity.readthedocs.io/en/v0.4.24/abi-spec.html#function-selector-and-argument-encoding.