diff --git a/contracts/common.sol b/contracts/common.sol new file mode 100644 index 0000000..17f2ba9 --- /dev/null +++ b/contracts/common.sol @@ -0,0 +1,61 @@ +pragma solidity ^0.6.0; + +interface MemoryInterface { + function getUint(uint _id) external returns (uint _num); + function setUint(uint _id, uint _val) external; +} + +interface EventInterface { + function emitEvent(uint _connectorType, uint _connectorID, bytes32 _eventCode, bytes calldata _eventData) external; +} + + +contract Memory { + + /** + * @dev ETH Address. + */ + function getEthAddr() public pure returns (address) { + return 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; + } + + /** + * @dev Return InstaMemory Address. + */ + function getMemoryAddr() public pure returns (address) { + return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address + } + + /** + * @dev Return InstaEvent Address. + */ + function getEventAddr() public pure returns (address) { + return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address + } + + /** + * @dev Get Stored Uint Value From InstaMemory. + * @param getId Storage ID. + * @param val if any value. + */ + 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. + */ + function setUint(uint setId, uint val) internal { + if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val); + } + + /** + * @dev Connector ID and Type. + */ + function connectorID() public pure returns(uint _type, uint _id) { + (_type, _id) = (1, 2); + } + +} \ No newline at end of file