mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
added common.sol
This commit is contained in:
parent
f0220b5e44
commit
3372df9f98
61
contracts/common.sol
Normal file
61
contracts/common.sol
Normal file
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user