mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
modified mock.sol and readme
This commit is contained in:
parent
379ac709b8
commit
52fbe1baad
|
@ -14,10 +14,11 @@ Connectors are standardized modules that let Smart Account interact with various
|
|||
|
||||
- The contracts should not have `selfdestruct()`.
|
||||
- The contracts should not have `delegatecall()`.
|
||||
- Use `uint(-1)` for maximum amount everywhere ([example](/)).
|
||||
- Import `contracts/common` files ([example](/)).
|
||||
- Add `getId` & `setId`, two additional parameter for external public facing functions ([example](/)).
|
||||
- Use `getUint()` or `setUint()` functions to fetch or store values ([example](/)).
|
||||
- Use `uint(-1)` for maximum amount everywhere.
|
||||
- Import files from common directory.
|
||||
- If needed, add `getId` & `setId`, two additional parameter for external public facing functions to fetch or store values.
|
||||
- Use `getUint()` or `setUint()` functions to fetch or store values.
|
||||
- Call `emitEvent()` after every external public facing functions to follow a common event standard for better analytics.
|
||||
|
||||
## Support
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
pragma solidity ^0.6.0;
|
||||
|
||||
// import files from common directory
|
||||
import { DSMath } from "../common/math.sol";
|
||||
import { Stores } from "../common/stores.sol";
|
||||
|
||||
|
@ -7,9 +8,19 @@ contract MockProtocol is Stores, DSMath {
|
|||
|
||||
event LogMock(uint mockOne, uint mockTwo, uint getId, uint setId);
|
||||
|
||||
// added two additional parameter (getId & setId) for external public facing functions
|
||||
function mockFunction(uint mockNumber, uint getId, uint setId) external payable {
|
||||
uint mockBalance = mockNumber == uint(-1) ? address(this).balance : mockNumber;
|
||||
|
||||
// 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
|
||||
emit LogMock(mockNumber, mockBalance, getId, setId);
|
||||
bytes32 eventCode = keccak256("LogMock(uint256,uint256,uint256,uint256)");
|
||||
bytes memory eventData = abi.encode(mockNumber, mockBalance, getId, setId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user