This contract's source code is verified! Compiler
0.8.17+commit.8df45f5f
File 1 of 9: AbstractProxy.sol
pragma solidity >=0.8.11 <0.9.0;
abstract contract AbstractProxy {
fallback ( ) external payable {
_forward();
}
receive ( ) external payable {
_forward();
}
function _forward ( ) internal {
address implementation = _getImplementation();
assembly {
calldatacopy (0 , 0 , calldatasize ())
let result := delegatecall (gas (), implementation, 0 , calldatasize (), 0 , 0 )
returndatacopy (0 , 0 , returndatasize ())
switch result
case 0 {
revert (0 , returndatasize ())
}
default {
return (0 , returndatasize ())
}
}
}
function _getImplementation ( ) internal view virtual returns (address ) ;
}
File 2 of 9: AccessError.sol
pragma solidity >=0.8.11 <0.9.0;
library AccessError {
error Unauthorized (address addr ) ;
}
File 3 of 9: AddressError.sol
pragma solidity >=0.8.11 <0.9.0;
library AddressError {
error ZeroAddress ( ) ;
error NotAContract (address contr ) ;
}
File 4 of 9: AddressUtil.sol
pragma solidity >=0.8.11 <0.9.0;
library AddressUtil {
function isContract (address account ) internal view returns (bool ) {
uint256 size;
assembly {
size := extcodesize (account)
}
return size > 0 ;
}
}
File 5 of 9: OwnableStorage.sol
pragma solidity >=0.8.11 <0.9.0;
import "../errors/AccessError.sol" ;
library OwnableStorage {
bytes32 private constant _SLOT_OWNABLE_STORAGE =
keccak256 (abi .encode ("io.synthetix.core-contracts.Ownable" ));
struct Data {
address owner;
address nominatedOwner;
}
function load ( ) internal pure returns (Data storage store ) {
bytes32 s = _SLOT_OWNABLE_STORAGE;
assembly {
store.slot := s
}
}
function onlyOwner ( ) internal view {
if (msg .sender ! = getOwner()) {
revert AccessError.Unauthorized(msg .sender );
}
}
function getOwner ( ) internal view returns (address ) {
return OwnableStorage.load().owner;
}
}
File 6 of 9: Proxy.sol
pragma solidity >=0.8.11 <0.9.0;
import {UUPSProxyWithOwner } from "@synthetixio/core-contracts/contracts/proxy/UUPSProxyWithOwner.sol" ;
contract Proxy is UUPSProxyWithOwner {
constructor (
address firstImplementation,
address initialOwner
) UUPSProxyWithOwner (firstImplementation, initialOwner ) {}
}
File 7 of 9: ProxyStorage.sol
pragma solidity >=0.8.11 <0.9.0;
contract ProxyStorage {
bytes32 private constant _SLOT_PROXY_STORAGE =
keccak256 (abi .encode ("io.synthetix.core-contracts.Proxy" ));
struct ProxyStore {
address implementation;
bool simulatingUpgrade;
}
function _proxyStore ( ) internal pure returns (ProxyStore storage store ) {
bytes32 s = _SLOT_PROXY_STORAGE;
assembly {
store.slot := s
}
}
}
File 8 of 9: UUPSProxy.sol
pragma solidity >=0.8.11 <0.9.0;
import "./AbstractProxy.sol" ;
import "./ProxyStorage.sol" ;
import "../errors/AddressError.sol" ;
import "../utils/AddressUtil.sol" ;
contract UUPSProxy is AbstractProxy , ProxyStorage {
constructor (address firstImplementation ) {
if (firstImplementation = = address (0 )) {
revert AddressError.ZeroAddress();
}
if (! AddressUtil.isContract(firstImplementation)) {
revert AddressError.NotAContract(firstImplementation);
}
_proxyStore().implementation = firstImplementation;
}
function _getImplementation ( ) internal view virtual override returns (address ) {
return _proxyStore().implementation;
}
}
File 9 of 9: UUPSProxyWithOwner.sol
pragma solidity >=0.8.11 <0.9.0;
import {UUPSProxy } from "./UUPSProxy.sol" ;
import {OwnableStorage } from "../ownership/OwnableStorage.sol" ;
contract UUPSProxyWithOwner is UUPSProxy {
constructor (address firstImplementation, address initialOwner ) UUPSProxy (firstImplementation ) {
OwnableStorage.load().owner = initialOwner;
}
}
{
"compilationTarget" : {
"contracts/Proxy.sol" : "Proxy"
} ,
"evmVersion" : "london" ,
"libraries" : { } ,
"metadata" : {
"bytecodeHash" : "ipfs"
} ,
"optimizer" : {
"enabled" : false ,
"runs" : 200
} ,
"remappings" : [ ]
} [{"inputs":[{"internalType":"address","name":"firstImplementation","type":"address"},{"internalType":"address","name":"initialOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"contr","type":"address"}],"name":"NotAContract","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]