dsa-connectors-old/contracts/connectors/mock.sol

37 lines
1.2 KiB
Solidity
Raw Normal View History

2020-05-02 09:40:50 +00:00
pragma solidity ^0.6.0;
2020-05-02 12:18:39 +00:00
// import files from common directory
2020-05-03 21:26:10 +00:00
import { TokenInterface , MemoryInterface, EventInterface} from "../common/interfaces.sol";
2020-05-02 09:40:50 +00:00
import { Stores } from "../common/stores.sol";
2020-05-02 17:25:27 +00:00
import { DSMath } from "../common/math.sol";
2020-05-02 09:40:50 +00:00
contract MockProtocol is Stores, DSMath {
2020-05-02 11:52:06 +00:00
event LogMock(uint mockOne, uint mockTwo, uint getId, uint setId);
2020-05-02 12:18:39 +00:00
// added two additional parameter (getId & setId) for external public facing functions
2020-05-02 11:52:06 +00:00
function mockFunction(uint mockNumber, uint getId, uint setId) external payable {
// protocol specific logics goes here
2020-05-02 12:18:39 +00:00
// fetch value of specific id
uint mockBalance = getUint(getId, mockNumber);
// uses uint(-1)
mockBalance = mockBalance == uint(-1) ? address(this).balance : mockNumber;
// store new value for specific id
setUint(setId, mockNumber);
// common event standard
2020-05-02 11:52:06 +00:00
emit LogMock(mockNumber, mockBalance, getId, setId);
bytes32 eventCode = keccak256("LogMock(uint256,uint256,uint256,uint256)");
bytes memory eventData = abi.encode(mockNumber, mockBalance, getId, setId);
emitEvent(eventCode, eventData);
}
}
contract ConnectMock is MockProtocol {
string public name = "Mock-v1";
2020-05-02 09:40:50 +00:00
}