Commit af1d9391 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat: add name field to IDripCheck (#10732)

Adds a new name function to IDripCheck. Makes monitoring simpler
because monitoring services can now scan for drips with specific
names.
parent 5db8adf0
......@@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
......
......@@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
......
......@@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
......
......@@ -17,5 +17,18 @@
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
]
\ No newline at end of file
[]
\ No newline at end of file
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
\ No newline at end of file
[]
\ No newline at end of file
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
\ No newline at end of file
[
{
"bytes": "32",
"label": "revealedSecrets",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
},
{
"bytes": "32",
"label": "revealedSecrets",
"offset": 0,
"slot": "1",
"type": "mapping(bytes32 => uint256)"
}
]
\ No newline at end of file
[]
\ No newline at end of file
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
\ No newline at end of file
......@@ -7,6 +7,10 @@ interface IDripCheck {
// possible to easily encode parameters on the client side. Solidity does not support generics
// so it's not possible to do this with explicit typing.
/// @notice Returns the name of the drip check.
/// @return name_ The name of the drip check.
function name() external view returns (string memory name_);
/// @notice Checks whether a drip should be executable.
/// @param _params Encoded parameters for the drip check.
/// @return execute_ Whether the drip should be executed.
......
......@@ -15,6 +15,9 @@ contract CheckBalanceLow is IDripCheck {
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/// @inheritdoc IDripCheck
string public name = "CheckBalanceLow";
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
......
......@@ -21,6 +21,9 @@ contract CheckGelatoLow is IDripCheck {
/// @param params Parameters to encode.
event _EventToExposeStructInABI__Params(Params params);
/// @inheritdoc IDripCheck
string public name = "CheckGelatoLow";
/// @inheritdoc IDripCheck
function check(bytes memory _params) external view returns (bool execute_) {
Params memory params = abi.decode(_params, (Params));
......
......@@ -21,6 +21,9 @@ contract CheckSecrets is IDripCheck {
/// @notice Event emitted when a secret is revealed.
event SecretRevealed(bytes32 indexed secretHash, bytes secret);
/// @inheritdoc IDripCheck
string public name = "CheckSecrets";
/// @notice Keeps track of when secrets were revealed.
mapping(bytes32 => uint256) public revealedSecrets;
......
......@@ -6,6 +6,9 @@ import { IDripCheck } from "../IDripCheck.sol";
/// @title CheckTrue
/// @notice DripCheck that always returns true.
contract CheckTrue is IDripCheck {
/// @inheritdoc IDripCheck
string public name = "CheckTrue";
/// @inheritdoc IDripCheck
function check(bytes memory) external pure returns (bool execute_) {
execute_ = true;
......
......@@ -16,6 +16,11 @@ contract CheckBalanceLowTest is Test {
c = new CheckBalanceLow();
}
/// @notice Test that the `name` function returns the correct value.
function test_name_succeeds() external {
assertEq(c.name(), "CheckBalanceLow");
}
/// @notice Fuzz the `check` function and assert that it always returns true
/// when the target's balance is smaller than the threshold.
function testFuzz_check_succeeds(address _target, uint256 _threshold) external view {
......
......@@ -41,6 +41,11 @@ contract CheckGelatoLowTest is Test {
gelato = new MockGelatoTreasury();
}
/// @notice Test that the `name` function returns the correct value.
function test_name_succeeds() external {
assertEq(c.name(), "CheckGelatoLow");
}
/// @notice Fuzz the `check` function and assert that it always returns true
/// when the user's balance in the treasury is less than the threshold.
function testFuzz_check_succeeds(uint256 _threshold, address _recipient) external view {
......
......@@ -26,6 +26,11 @@ contract CheckSecretsTest is Test {
c = new CheckSecrets();
}
/// @notice Test that the `name` function returns the correct value.
function test_name_succeeds() external {
assertEq(c.name(), "CheckSecrets");
}
/// @notice Test that basic secret revealing works.
function test_reveal_succeeds() external {
// Simple reveal and check assertions.
......
......@@ -15,6 +15,11 @@ contract CheckTrueTest is Test {
c = new CheckTrue();
}
/// @notice Test that the `name` function returns the correct value.
function test_name_succeeds() external {
assertEq(c.name(), "CheckTrue");
}
/// @notice Fuzz the `check` function and assert that it always returns true.
function testFuzz_always_true_succeeds(bytes memory input) external view {
assertEq(c.check(input), true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment