View Source: contracts/TestContracts/DappSys/proxy.sol
↗ Extends: DSAuthEvents
DSNote
Constants & Variables
//public members
contract DSAuthority public authority;
address public owner;
contract DSProxyCache public cache;
mapping(address => bool) public isProxy;
contract DSProxyCache public cache;
//internal members
mapping(bytes32 => address) internal cache;
Events
event LogSetAuthority(address indexed authority);
event LogSetOwner(address indexed owner);
event LogNote(bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 indexed bar, uint256 wad, bytes fax);
event Created(address indexed sender, address indexed owner, address proxy, address cache);
modifier auth() internal
modifier note() internal
- canCall(address src, address dst, bytes4 sig)
- constructor()
- setOwner(address owner_)
- setAuthority(DSAuthority authority_)
- isAuthorized(address src, bytes4 sig)
- constructor(address _cacheAddr)
- constructor()
- constructor()
- execute(bytes _code, bytes _data)
- execute(address _target, bytes _data)
- setCache(address _cacheAddr)
- build()
- build(address owner)
- read(bytes _code)
- write(bytes _code)
function canCall(address src, address dst, bytes4 sig) public view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
src | address | |
dst | address | |
sig | bytes4 |
Source Code
function canCall(
address src, address dst, bytes4 sig
) virtual public view returns (bool);
function () public nonpayable
Source Code
constructor() public {
owner = msg.sender;
emit LogSetOwner(msg.sender);
}
function setOwner(address owner_) public nonpayable auth
Arguments
Name | Type | Description |
---|---|---|
owner_ | address |
Source Code
function setOwner(address owner_)
public
auth
{
owner = owner_;
emit LogSetOwner(owner);
}
function setAuthority(DSAuthority authority_) public nonpayable auth
Arguments
Name | Type | Description |
---|---|---|
authority_ | DSAuthority |
Source Code
function setAuthority(DSAuthority authority_)
public
auth
{
authority = authority_;
emit LogSetAuthority(address(authority));
}
function isAuthorized(address src, bytes4 sig) internal view
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
src | address | |
sig | bytes4 |
Source Code
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == DSAuthority(0)) {
return false;
} else {
return authority.canCall(src, address(this), sig);
}
}
function (address _cacheAddr) public nonpayable
Arguments
Name | Type | Description |
---|---|---|
_cacheAddr | address |
Source Code
constructor(address _cacheAddr) public {
require(setCache(_cacheAddr));
}
function () external payable
Source Code
fallback() external payable {
}
function () external payable
Source Code
receive() external payable {
}
function execute(bytes _code, bytes _data) public payable
returns(target address, response bytes32)
Arguments
Name | Type | Description |
---|---|---|
_code | bytes | |
_data | bytes |
Source Code
function execute(bytes calldata _code, bytes calldata _data)
public
payable
returns (address target, bytes32 response)
{
target = cache.read(_code);
if (target == address(0x0)) {
// deploy contract & store its address in cache
target = cache.write(_code);
}
response = execute(target, _data);
}
function execute(address _target, bytes _data) public payable auth note
returns(response bytes32)
Arguments
Name | Type | Description |
---|---|---|
_target | address | |
_data | bytes |
Source Code
function execute(address _target, bytes memory _data)
public
auth
note
payable
returns (bytes32 response)
{
require(_target != address(0x0));
// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas(), 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
response := mload(0) // load delegatecall output
switch iszero(succeeded)
case 1 {
// throw if delegatecall failed
revert(0, 0)
}
}
}
function setCache(address _cacheAddr) internal nonpayable auth note
returns(bool)
Arguments
Name | Type | Description |
---|---|---|
_cacheAddr | address |
Source Code
function setCache(address _cacheAddr)
internal
auth
note
returns (bool)
{
require(_cacheAddr != address(0x0)); // invalid cache address
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}
function build() public nonpayable
returns(proxy contract DSProxy)
Source Code
function build() public returns (DSProxy proxy) {
proxy = build(msg.sender);
}
function build(address owner) public nonpayable
returns(proxy contract DSProxy)
Arguments
Name | Type | Description |
---|---|---|
owner | address |
Source Code
function build(address owner) public returns (DSProxy proxy) {
proxy = new DSProxy(address(cache));
emit Created(msg.sender, owner, address(proxy), address(cache));
proxy.setOwner(owner);
isProxy[address(proxy)] = true;
}
function read(bytes _code) public view
returns(address)
Arguments
Name | Type | Description |
---|---|---|
_code | bytes |
Source Code
function read(bytes calldata _code) public view returns (address) {
bytes32 hash = keccak256(_code);
return cache[hash];
}
function write(bytes _code) public nonpayable
returns(target address)
Arguments
Name | Type | Description |
---|---|---|
_code | bytes |
Source Code
function write(bytes memory _code) public returns (address target) {
assembly {
target := create(0, add(_code, 0x20), mload(_code))
switch iszero(extcodesize(target))
case 1 {
// throw if contract failed to deploy
revert(0, 0)
}
}
bytes32 hash = keccak256(_code);
cache[hash] = target;
}
- ActivePool
- ActivePoolStorage
- BaseMath
- BorrowerOperations
- BorrowerOperationsScript
- BorrowerOperationsStorage
- BorrowerWrappersScript
- CheckContract
- CollSurplusPool
- CollSurplusPoolStorage
- console
- Context
- DefaultPool
- DefaultPoolStorage
- DocsCover
- DSAuth
- DSAuthEvents
- DSAuthority
- DSNote
- DSProxy
- DSProxyCache
- DSProxyFactory
- ERC20
- ETHTransferScript
- FeeDistributor
- FeeDistributorStorage
- GasPool
- HintHelpers
- HintHelpersStorage
- IActivePool
- IBalanceRedirectPresale
- IBorrowerOperations
- ICollSurplusPool
- IDefaultPool
- IERC20
- IERC2612
- IExternalPriceFeed
- IFeeDistributor
- IFeeSharingProxy
- ILiquityBase
- ILiquityBaseParams
- IMasset
- IMoCBaseOracle
- Initializable
- IPool
- IPriceFeed
- IRSKOracle
- ISortedTroves
- IStabilityPool
- ITroveManager
- IWrbtc
- IZUSDToken
- LiquityBase
- LiquityBaseParams
- LiquityMath
- LiquitySafeMath128
- MoCMedianizer
- MultiTroveGetter
- MultiTroveGetterStorage
- NueToken
- Ownable
- PriceFeed
- PriceFeedStorage
- ProxiableContract
- ProxiableContract2
- Proxy
- RskOracle
- SafeMath
- SortedTroves
- SortedTrovesStorage
- StabilityPool
- StabilityPoolScript
- StabilityPoolStorage
- Storage
- Storage2
- TokenScript
- TroveManager
- TroveManagerBase
- TroveManagerBase1MinuteBootstrap
- TroveManagerRedeemOps
- TroveManagerScript
- TroveManagerStorage
- UpgradableProxy
- ZUSDToken
- ZUSDTokenStorage