Skip to content

Commit

Permalink
add proxies
Browse files Browse the repository at this point in the history
  • Loading branch information
mihanix committed Dec 2, 2023
1 parent cd3101f commit 374f330
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
26 changes: 26 additions & 0 deletions contracts/AutIDProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract LocalReputationProxy is Proxy, Ownable {
bytes32 private constant _IMPLEMENTATION_SLOT = bytes32(uint256(keccak256("id.aut.os.autid.proxy.implementation")) - 1);

constructor(address implementation_) Ownable() {
upgrade(implementation_);
}

function implementation() external view returns (address) {
return _implementation();
}

function upgrade(address to) public onlyOwner {
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = to;
}

function _implementation() internal view override returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}
22 changes: 22 additions & 0 deletions contracts/LocalReputationProxy.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import "@openzeppelin/contracts/proxy/Proxy.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract LocalReputationProxy is Proxy, Ownable {
bytes32 private constant _IMPLEMENTATION_SLOT = bytes32(uint256(keccak256("id.aut.os.lr.proxy.implementation")) - 1);

constructor(address implementation) Ownable() {
upgrade(implementation);
}

function upgrade(address to) public onlyOwner {
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = to;
}

function _implementation() internal view override returns (address) {
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
}

0 comments on commit 374f330

Please sign in to comment.