Skip to content

Proxyable

Description

This contract is designed to operate in tandem with Proxy. In fact, in order to function properly, every contract operating behind a CALL-style proxy must inherit Proxyable to ensure that the message sender is set and that events are correctly emitted.

This contract can support two proxies simultaneously. Events can be emitted independently from each proxy, but it is sensible to restrict event emission to a single proxy in most cases.

Source: Proxyable.sol

Architecture


Inheritance Graph

Proxyable inheritance graph


Variables


proxy

The address of the main proxy that this contract operates underneath. It is this address that events should be emitted from using Proxy._emit.

Type: Proxy public


integrationProxy

The address of an additional proxy which can be used to forward contract calls to this contract. Generally speaking, events should not be passed to the integrationProxy.

In the case of the Synthetix contract, this integrationProxy is an instance of the ERC20 proxy.

Type: Proxy public


messageSender

The caller of the proxy in the current invocation. This variable is set to the value of msg.sender visible to the proxy before every function call by that Proxy to this Proxyable. Once set, messageSender should be used in place of msg.sender wherever it is used in contracts inheriting Proxyable.

All functions which make use of messageSender should have one of the modifiers provided by the Proxyable interface, otherwise users who call the contract directly rather than through the proxy will be executing with stale values of messageSender.

Functions which do not require messageSender need not apply any of the proxy modifiers, but care must be taken when applying other function modifiers within a proxyable contract. For example, see optionalProxy_onlyOwner.

Type: address


Functions


constructor

Initialises this contract's proxy and the inherited Owned instance.

Details

Signature

constructor(address _proxy, address _owner) public

Superconstructors

Emits


setProxy

Sets this contract's primary proxy. setProxy cannot be called through a proxy.

Details

Signature

setProxy(address _proxy) external

Modifiers

Emits


setIntegrationProxy

Sets this contract's secondary proxy. setIntegrationProxy cannot be called through a proxy.

Details

Signature

setIntegrationProxy(address _IntegrationProxy) external

Modifiers


setMessageSender

This is used by proxies to set messageSender before forwarding a function call. This is only callable by the proxy or integrationProxy.

Details

Signature

setMessageSender(address sender) external

Modifiers


Modifiers


onlyProxy

Reverts the transaction if the actual msg.sender (not messageSender) is not the proxy or the integration proxy.


optionalProxy

This modifier allows a function to be called through the proxies, or alternatively to be called directly for a small gas savings.

It operates simply: if the caller is not either the proxy or the integration proxy, then overwrite messageSender with msg.sender, otherwise use whatever it was set to by the proxy.


optionalProxy_onlyOwner

This modifier is largely the same as optionalProxy, but it disallow callers who are not the contract owner. This modifier exists because Owned.onlyOwner checks msg.sender, and not messageSender.


Events


ProxyUpdated

proxyAddress has been set as the new proxy.

Signature: ProxyUpdated(address proxyAddress)