Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/solidity 8 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ before_script:
- ganache-cli -p 7545 -e 1000000 -l 8000000 > /dev/null 2> /dev/null &
- while ! echo exit | nc localhost 7545; do sleep 1; done > /dev/null 2> /dev/null
after_script:
- npm run coverage && cat coverage/lcov.info | coveralls
- npx truffle run coverage --network coverage
- npx lcov-guard --lines 100 --path coverage/lcov.info
139 changes: 35 additions & 104 deletions contracts/EternalStorage.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pragma solidity ^0.5.0;
pragma solidity >=0.8.0 <0.9.0;
// SPDX-License-Identifier: Apache-2.0

import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./IEternalStorage.sol";


Expand All @@ -9,17 +10,12 @@ contract EternalStorage is IEternalStorage, Ownable {
address public latestVersion;

mapping(bytes32 => bool) internal boolStorage;
mapping(bytes32 => uint8) internal uInt8Storage;
mapping(bytes32 => uint128) internal uInt128Storage;
mapping(bytes32 => uint256) internal uInt256Storage;
mapping(bytes32 => int8) internal int8Storage;
mapping(bytes32 => int128) internal int128Storage;
mapping(bytes32 => int256) internal int256Storage;
mapping(bytes32 => address) internal addressStorage;
mapping(bytes32 => bytes8) internal bytes8Storage;
mapping(bytes32 => bytes16) internal bytes16Storage;
mapping(bytes32 => bytes32) internal bytes32Storage;
mapping(bytes32 => string) internal stringStorage;
mapping(bytes32 => bytes) internal bytesStorage;

modifier onlyLatestVersion() {
require(msg.sender == latestVersion, "only the latest version of the contract can call setters");
Expand All @@ -37,158 +33,93 @@ contract EternalStorage is IEternalStorage, Ownable {
}

// *** Bool ***
function getBool(bytes32 _key) public view returns (bool) {
function getBool(bytes32 _key) public override view returns (bool) {
return boolStorage[_key];
}

function setBool(bytes32 _key, bool _value) public onlyLatestVersion {
function setBool(bytes32 _key, bool _value) public override onlyLatestVersion {
boolStorage[_key] = _value;
}

function deleteBool(bytes32 _key) public onlyLatestVersion {
function deleteBool(bytes32 _key) public override onlyLatestVersion {
delete boolStorage[_key];
}

// *** UInt8 ***
function getUInt8(bytes32 _key) public view returns (uint8) {
return uInt8Storage[_key];
}

function setUInt8(bytes32 _key, uint8 _value) public onlyLatestVersion {
uInt8Storage[_key] = _value;
}

function deleteUInt8(bytes32 _key) public onlyLatestVersion {
delete uInt8Storage[_key];
}

// *** UInt128 ***
function getUInt128(bytes32 _key) public view returns (uint128) {
return uInt128Storage[_key];
}

function setUInt128(bytes32 _key, uint128 _value) public onlyLatestVersion {
uInt128Storage[_key] = _value;
}

function deleteUInt128(bytes32 _key) public onlyLatestVersion {
delete uInt128Storage[_key];
}

// *** UInt256 ***
function getUInt256(bytes32 _key) public view returns (uint256) {
function getUInt256(bytes32 _key) public override view returns (uint256) {
return uInt256Storage[_key];
}

function setUInt256(bytes32 _key, uint256 _value) public onlyLatestVersion {
function setUInt256(bytes32 _key, uint256 _value) public override onlyLatestVersion {
uInt256Storage[_key] = _value;
}

function deleteUInt256(bytes32 _key) public onlyLatestVersion {
function deleteUInt256(bytes32 _key) public override onlyLatestVersion {
delete uInt256Storage[_key];
}

// *** Int8 ***
function getInt8(bytes32 _key) public view returns (int8) {
return int8Storage[_key];
}

function setInt8(bytes32 _key, int8 _value) public onlyLatestVersion {
int8Storage[_key] = _value;
}

function deleteInt8(bytes32 _key) public onlyLatestVersion {
delete int8Storage[_key];
}

// *** Int128 ***
function getInt128(bytes32 _key) public view returns (int128) {
return int128Storage[_key];
}

function setInt128(bytes32 _key, int128 _value) public onlyLatestVersion {
int128Storage[_key] = _value;
}

function deleteInt128(bytes32 _key) public onlyLatestVersion {
delete int128Storage[_key];
}

// *** Int256 ***
function getInt256(bytes32 _key) public view returns (int256) {
function getInt256(bytes32 _key) public override view returns (int256) {
return int256Storage[_key];
}

function setInt256(bytes32 _key, int256 _value) public onlyLatestVersion {
function setInt256(bytes32 _key, int256 _value) public override onlyLatestVersion {
int256Storage[_key] = _value;
}

function deleteInt256(bytes32 _key) public onlyLatestVersion {
function deleteInt256(bytes32 _key) public override onlyLatestVersion {
delete int256Storage[_key];
}

// *** Address ***
function getAddress(bytes32 _key) public view returns (address) {
function getAddress(bytes32 _key) public override view returns (address) {
return addressStorage[_key];
}

function setAddress(bytes32 _key, address _value) public onlyLatestVersion {
function setAddress(bytes32 _key, address _value) public override onlyLatestVersion {
addressStorage[_key] = _value;
}

function deleteAddress(bytes32 _key) public onlyLatestVersion {
function deleteAddress(bytes32 _key) public override onlyLatestVersion {
delete addressStorage[_key];
}

// *** Bytes8 ***
function getBytes8(bytes32 _key) public view returns (bytes8) {
return bytes8Storage[_key];
}

function setBytes8(bytes32 _key, bytes8 _value) public onlyLatestVersion {
bytes8Storage[_key] = _value;
}

function deleteBytes8(bytes32 _key) public onlyLatestVersion {
delete bytes8Storage[_key];
}

// *** Bytes16 ***
function getBytes16(bytes32 _key) public view returns (bytes16) {
return bytes16Storage[_key];
}

function setBytes16(bytes32 _key, bytes16 _value) public onlyLatestVersion {
bytes16Storage[_key] = _value;
}

function deleteBytes16(bytes32 _key) public onlyLatestVersion {
delete bytes16Storage[_key];
}

// *** Bytes32 ***
function getBytes32(bytes32 _key) public view returns (bytes32) {
function getBytes32(bytes32 _key) public override view returns (bytes32) {
return bytes32Storage[_key];
}

function setBytes32(bytes32 _key, bytes32 _value) public onlyLatestVersion {
function setBytes32(bytes32 _key, bytes32 _value) public override onlyLatestVersion {
bytes32Storage[_key] = _value;
}

function deleteBytes32(bytes32 _key) public onlyLatestVersion {
function deleteBytes32(bytes32 _key) public override onlyLatestVersion {
delete bytes32Storage[_key];
}

// *** String ***
function getString(bytes32 _key) public view returns (string memory) {
function getString(bytes32 _key) public override view returns (string memory) {
return stringStorage[_key];
}

function setString(bytes32 _key, string memory _value) public onlyLatestVersion {
function setString(bytes32 _key, string memory _value) public override onlyLatestVersion {
stringStorage[_key] = _value;
}

function deleteString(bytes32 _key) public onlyLatestVersion {
function deleteString(bytes32 _key) public override onlyLatestVersion {
delete stringStorage[_key];
}

// *** bytes ***
function getBytes(bytes32 _key) public override view returns (bytes memory) {
return bytesStorage[_key];
}

function setBytes(bytes32 _key, bytes memory _value) public override onlyLatestVersion {
bytesStorage[_key] = _value;
}

function deleteBytes(bytes32 _key) public override onlyLatestVersion {
delete bytesStorage[_key];
}
}
76 changes: 26 additions & 50 deletions contracts/IEternalStorage.sol
Original file line number Diff line number Diff line change
@@ -1,64 +1,40 @@
pragma solidity ^0.5.0;
pragma solidity >=0.8.0 <0.9.0;
// SPDX-License-Identifier: Apache-2.0


contract IEternalStorage {
interface IEternalStorage {
// *** Bool ***
function getBool(bytes32 _key) public view returns (bool);
function setBool(bytes32 _key, bool _value) public;
function deleteBool(bytes32 _key) public;

// *** UInt8 ***
function getUInt8(bytes32 _key) public view returns (uint8);
function setUInt8(bytes32 _key, uint8 _value) public;
function deleteUInt8(bytes32 _key) public;

// *** UInt128 ***
function getUInt128(bytes32 _key) public view returns (uint128);
function setUInt128(bytes32 _key, uint128 _value) public;
function deleteUInt128(bytes32 _key) public;
function getBool(bytes32 _key) external view returns (bool);
function setBool(bytes32 _key, bool _value) external;
function deleteBool(bytes32 _key) external;

// *** UInt256 ***
function getUInt256(bytes32 _key) public view returns (uint256);
function setUInt256(bytes32 _key, uint256 _value) public;
function deleteUInt256(bytes32 _key) public;

// *** Int8 ***
function getInt8(bytes32 _key) public view returns (int8);
function setInt8(bytes32 _key, int8 _value) public;
function deleteInt8(bytes32 _key) public;

// *** Int128 ***
function getInt128(bytes32 _key) public view returns (int128);
function setInt128(bytes32 _key, int128 _value) public;
function deleteInt128(bytes32 _key) public;
function getUInt256(bytes32 _key) external view returns (uint256);
function setUInt256(bytes32 _key, uint256 _value) external;
function deleteUInt256(bytes32 _key) external;

// *** Int256 ***
function getInt256(bytes32 _key) public view returns (int256);
function setInt256(bytes32 _key, int256 _value) public;
function deleteInt256(bytes32 _key) public;
function getInt256(bytes32 _key) external view returns (int256);
function setInt256(bytes32 _key, int256 _value) external;
function deleteInt256(bytes32 _key) external;

// *** Address ***
function getAddress(bytes32 _key) public view returns (address);
function setAddress(bytes32 _key, address _value) public;
function deleteAddress(bytes32 _key) public;

// *** Bytes8 ***
function getBytes8(bytes32 _key) public view returns (bytes8);
function setBytes8(bytes32 _key, bytes8 _value) public;
function deleteBytes8(bytes32 _key) public;

// *** Bytes16 ***
function getBytes16(bytes32 _key) public view returns (bytes16);
function setBytes16(bytes32 _key, bytes16 _value) public;
function deleteBytes16(bytes32 _key) public;
function getAddress(bytes32 _key) external view returns (address);
function setAddress(bytes32 _key, address _value) external;
function deleteAddress(bytes32 _key) external;

// *** Bytes32 ***
function getBytes32(bytes32 _key) public view returns (bytes32);
function setBytes32(bytes32 _key, bytes32 _value) public;
function deleteBytes32(bytes32 _key) public;
function getBytes32(bytes32 _key) external view returns (bytes32);
function setBytes32(bytes32 _key, bytes32 _value) external;
function deleteBytes32(bytes32 _key) external;

// *** String ***
function getString(bytes32 _key) public view returns (string memory);
function setString(bytes32 _key, string memory _value) public;
function deleteString(bytes32 _key) public;
function getString(bytes32 _key) external view returns (string memory);
function setString(bytes32 _key, string memory _value) external;
function deleteString(bytes32 _key) external;

// *** bytes ***
function getBytes(bytes32 _key) external view returns (bytes memory);
function setBytes(bytes32 _key, bytes memory _value) external;
function deleteBytes(bytes32 _key) external;
}
Loading