Proxies
How Proxies Work
Example Proxy Contract
contract ClaimTopicsRegistryProxy is AbstractProxy {
constructor(address implementationAuthority) {
require(implementationAuthority != address(0), "invalid argument - zero address");
_storeImplementationAuthority(implementationAuthority);
emit ImplementationAuthoritySet(implementationAuthority);
address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getCTRImplementation();
(bool success, ) = logic.delegatecall(abi.encodeWithSignature("init()"));
require(success, "Initialization failed.");
}
fallback() external payable {
address logic = (ITREXImplementationAuthority(getImplementationAuthority())).getCTRImplementation();
assembly {
calldatacopy(0x0, 0x0, calldatasize())
let success := delegatecall(sub(gas(), 10000), logic, 0x0, calldatasize(), 0, 0)
let retSz := returndatasize()
returndatacopy(0, 0, retSz)
switch success
case 0 {
revert(0, retSz)
}
default {
return(0, retSz)
}
}
}
}Abstract Proxy Contract
Last updated