Commit 68b240cc authored by Kelvin Fichter's avatar Kelvin Fichter

Light comments for proxy contracts

parent b1c90b74
......@@ -8,49 +8,67 @@ import { Proxy_Manager } from "./Proxy_Manager.sol";
* @title Proxy_Forwarder
*/
contract Proxy_Forwarder {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
Proxy_Manager private proxyManager;
/***************
* Constructor *
***************/
/**
* @param _proxyManager Address of the Proxy_Manager.
*/
constructor(
address _proxyManager
) {
proxyManager = Proxy_Manager(_proxyManager);
}
/********************
* Public Functions *
********************/
/**
* Forwards calls to the appropriate target.
*/
fallback()
external
{
address target = _getTarget();
bytes memory data = msg.data;
require(
target != address(0),
"Proxy does not have a target."
);
assembly {
let success := call(
gas(),
target,
0,
add(data, 0x20),
mload(data),
0,
0
)
let size := returndatasize()
let returndata := mload(0x40)
mstore(0x40, add(returndata, add(size, 0x20)))
returndatacopy(add(returndata, 0x20), 0, size)
if iszero(success) {
revert(add(returndata, 0x20), size)
}
(bool success, bytes memory returndata) = target.call(msg.data);
return(add(returndata, 0x20), size)
if (success == true) {
assembly {
return(add(returndata, 0x20), mload(returndata))
}
} else {
assembly {
revert(add(returndata, 0x20), mload(returndata))
}
}
}
/**********************
* Internal Functions *
**********************/
/**
* Determines the appropriate target.
* @return Target to forward requests to.
*/
function _getTarget()
internal
view
......
......@@ -5,12 +5,21 @@ pragma solidity ^0.7.0;
* @title Proxy_Manager
*/
contract Proxy_Manager {
/*******************************************
* Contract Variables: Internal Accounting *
*******************************************/
mapping (bytes32 => address) private proxyByName;
mapping (bytes32 => address) private targetByName;
mapping (address => bytes32) private nameByProxy;
mapping (address => bytes32) private nameByTarget;
/********************
* Public Functions *
********************/
function setProxy(
string memory _name,
address _proxy
......@@ -152,6 +161,10 @@ contract Proxy_Manager {
}
/**********************
* Internal Functions *
**********************/
function _getNameHash(
string memory _name
)
......
......@@ -8,14 +8,32 @@ import { Proxy_Manager } from "./Proxy_Manager.sol";
* @title Proxy_Resolver
*/
contract Proxy_Resolver {
/*******************************************
* Contract Variables: Contract References *
*******************************************/
Proxy_Manager internal proxyManager;
/***************
* Constructor *
***************/
/**
* @param _proxyManager Address of the Proxy_Manager.
*/
constructor(
address _proxyManager
) {
proxyManager = Proxy_Manager(_proxyManager);
}
/********************
* Public Functions *
********************/
function resolve(
string memory _name
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment