Skip to content

Commit

Permalink
feat: add name field to IDripCheck (#10732)
Browse files Browse the repository at this point in the history
Adds a new name function to IDripCheck. Makes monitoring simpler
because monitoring services can now scan for drips with specific
names.
  • Loading branch information
smartcontracts committed Jun 4, 2024
1 parent 5db8adf commit af1d939
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 4 deletions.
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/CheckBalanceLow.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
Expand Down
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/CheckGelatoLow.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"anonymous": false,
"inputs": [
Expand Down
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/CheckSecrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
Expand Down
13 changes: 13 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/CheckTrue.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,18 @@
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
[]
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
[]
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[
{
"bytes": "32",
"label": "revealedSecrets",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
},
{
"bytes": "32",
"label": "revealedSecrets",
"offset": 0,
"slot": "1",
"type": "mapping(bytes32 => uint256)"
}
]
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
[]
[
{
"bytes": "32",
"label": "name",
"offset": 0,
"slot": "0",
"type": "string"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit af1d939

Please sign in to comment.