Refactored files and code

This commit is contained in:
Sowmay Jain 2020-05-02 19:40:50 +10:00
parent 3372df9f98
commit c3031849df
11 changed files with 50 additions and 27 deletions

View File

@ -3,11 +3,10 @@
## Requirements
- The contracts should not have delegate call in it.
- - The contracts should not have `SelfDestruct()` function.
- The contracts should not have `selfdestruct()`.
- The contracts should not have `delegatecall()`.
- Use `uint(-1)` for maximum amount everywhere.
- Import `contracts/common` files.
```javascript
contract Sample {

23
contracts/common/math.sol Normal file
View File

@ -0,0 +1,23 @@
pragma solidity ^0.6.0;
contract DSMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, "math-not-safe");
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, "math-not-safe");
}
uint constant WAD = 10 ** 18;
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
}

View File

@ -5,57 +5,48 @@ interface MemoryInterface {
function setUint(uint _id, uint _val) external;
}
interface EventInterface {
function emitEvent(uint _connectorType, uint _connectorID, bytes32 _eventCode, bytes calldata _eventData) external;
}
contract Memory {
contract Stores {
/**
* @dev ETH Address.
* @dev Return ethereum address
*/
function getEthAddr() public pure returns (address) {
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
function getAddressETH() internal pure returns (address) {
return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; // ETH Address
}
/**
* @dev Return InstaMemory Address.
* @dev Return Memory Variable Address
*/
function getMemoryAddr() public pure returns (address) {
function getMemoryAddr() internal pure returns (address) {
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address
}
/**
* @dev Return InstaEvent Address.
*/
function getEventAddr() public pure returns (address) {
function getEventAddr() internal pure returns (address) {
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address
}
/**
* @dev Get Stored Uint Value From InstaMemory.
* @param getId Storage ID.
* @param val if any value.
*/
* @dev Get Uint value from InstaMemory Contract.
*/
function getUint(uint getId, uint val) internal returns (uint returnVal) {
returnVal = getId == 0 ? val : MemoryInterface(getMemoryAddr()).getUint(getId);
}
/**
* @dev Store Uint Value In InstaMemory.
* @param setId Storage ID.
* @param val Value To store.
*/
* @dev Set Uint value in InstaMemory Contract.
*/
function setUint(uint setId, uint val) internal {
if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val);
}
/**
* @dev Connector ID and Type.
*/
* @dev Connector Details
*/
function connectorID() public pure returns(uint _type, uint _id) {
(_type, _id) = (1, 2);
(_type, _id) = (1, 3);
}
}

View File

@ -0,0 +1,8 @@
pragma solidity ^0.6.0;
import { DSMath } from "../common/math.sol";
import { Stores } from "../common/stores.sol";
contract MockProtocol is Stores, DSMath {
//
}

2
todo.md Normal file
View File

@ -0,0 +1,2 @@
- add the static connectors in "contracts/static" folder
- why ^ in ^0.6.0? Do we need it?