Commit 33065e82 authored by Kelvin Fichter's avatar Kelvin Fichter Committed by GitHub

cleanup: Proxy_EOA (#291)

parent 7bd8bbaa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
pragma solidity >0.5.0 <0.8.0; pragma solidity >0.5.0 <0.8.0;
/* Library Imports */ /* Library Imports */
import { Lib_BytesUtils } from "../../libraries/utils/Lib_BytesUtils.sol"; import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol";
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol"; import { Lib_ECDSAUtils } from "../../libraries/utils/Lib_ECDSAUtils.sol";
import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol";
...@@ -18,12 +18,20 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa ...@@ -18,12 +18,20 @@ import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_Sa
*/ */
contract OVM_ProxyEOA { contract OVM_ProxyEOA {
/*************
* Constants *
*************/
bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead; bytes32 constant IMPLEMENTATION_KEY = 0xdeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead;
/*************** /***************
* Constructor * * Constructor *
***************/ ***************/
/**
* @param _implementation Address of the initial implementation contract.
*/
constructor( constructor(
address _implementation address _implementation
) )
...@@ -62,6 +70,10 @@ contract OVM_ProxyEOA { ...@@ -62,6 +70,10 @@ contract OVM_ProxyEOA {
* Public Functions * * Public Functions *
********************/ ********************/
/**
* Changes the implementation address.
* @param _implementation New implementation address.
*/
function upgrade( function upgrade(
address _implementation address _implementation
) )
...@@ -75,19 +87,24 @@ contract OVM_ProxyEOA { ...@@ -75,19 +87,24 @@ contract OVM_ProxyEOA {
_setImplementation(_implementation); _setImplementation(_implementation);
} }
/**
* Gets the address of the current implementation.
* @return Current implementation address.
*/
function getImplementation() function getImplementation()
public public
returns ( returns (
address _implementation address
) )
{ {
return address(uint160(uint256( return Lib_Bytes32Utils.toAddress(
Lib_SafeExecutionManagerWrapper.safeSLOAD( Lib_SafeExecutionManagerWrapper.safeSLOAD(
IMPLEMENTATION_KEY IMPLEMENTATION_KEY
) )
))); );
} }
/********************** /**********************
* Internal Functions * * Internal Functions *
**********************/ **********************/
...@@ -99,7 +116,7 @@ contract OVM_ProxyEOA { ...@@ -99,7 +116,7 @@ contract OVM_ProxyEOA {
{ {
Lib_SafeExecutionManagerWrapper.safeSSTORE( Lib_SafeExecutionManagerWrapper.safeSSTORE(
IMPLEMENTATION_KEY, IMPLEMENTATION_KEY,
bytes32(uint256(uint160(_implementation))) Lib_Bytes32Utils.fromAddress(_implementation)
); );
} }
} }
\ No newline at end of file
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