Skip to content

Commit

Permalink
Open zep to v4.9, delete slither report
Browse files Browse the repository at this point in the history
  • Loading branch information
mireynolds committed Jul 15, 2023
1 parent cd9325a commit 4217bc3
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/slither-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: forge build --build-info --skip test --skip script

- name: Generate slither report
run: slither . --compile-force-framework "foundry" --foundry-out-directory "out" --ignore-compile --fail-medium --skip-clean --filter-paths "lib" --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/ > slitherReport.md
run: slither . --compile-force-framework "foundry" --foundry-out-directory "out" --ignore-compile --skip-clean --filter-paths "lib" --checklist --markdown-root ${{ github.server_url }}/${{ github.repository }}/blob/${{ github.sha }}/ > slitherReport.md

- name: Check slither report
run: |
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ cache/
out/
broadcast/
Makefile
.vscode
remappings.txt
abi.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = master
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
branch = release-v4.9 # Master branch is not safe to use
[submodule "lib/murky"]
path = lib/murky
url = https://github.com/dmfxyz/murky
branch = main
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"editor.formatOnSave": true,
"[solidity]": {
"editor.defaultFormatter": "NomicFoundation.hardhat-solidity"
},
"[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml"
},
"solidity.formatter": "forge"
}
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
6 changes: 6 additions & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ds-test/=lib/forge-std/lib/ds-test/src/
erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/
forge-std/=lib/forge-std/src/
murky/=lib/murky/src/
openzeppelin-contracts/=lib/openzeppelin-contracts/
openzeppelin/=lib/openzeppelin-contracts/contracts/
123 changes: 0 additions & 123 deletions slitherReport.md

This file was deleted.

13 changes: 5 additions & 8 deletions src/examples/Airdrop.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

import {Merkle} from "murky/Merkle.sol";
import {ERC20} from "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol";
import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol";
import {MerkleProof} from "openzeppelin/utils/cryptography/MerkleProof.sol";
import {ERC20} from "openzeppelin/token/ERC20/ERC20.sol";
import {Math} from "openzeppelin/utils/math/Math.sol";
import {DelegateClaim} from "src/examples/DelegateClaim.sol";

/**
Expand All @@ -12,7 +12,6 @@ import {DelegateClaim} from "src/examples/DelegateClaim.sol";
* @dev Inherits the DelegateClaim contract to allow delegates to claim on behalf of vaults.
*/
contract Airdrop is ERC20, DelegateClaim {
Merkle public immutable merkle;
bytes32 public immutable merkleRoot;
mapping(address vault => uint256 claimed) public claimed;

Expand All @@ -22,15 +21,13 @@ contract Airdrop is ERC20, DelegateClaim {
* @param referenceToken_ The address of the reference token used by delegateClaimable inherited from DelegateClaim.
* @param totalSupply_ The total supply of the airdrop token.
* @param merkleRoot_ The root hash of the merkle tree representing the airdrop.
* @param merkle_ The address of the murky Merkle contract used for proof verification.
*/
constructor(address registry_, address referenceToken_, bytes32 airdropRight, uint256 totalSupply_, bytes32 merkleRoot_, address merkle_)
constructor(address registry_, address referenceToken_, bytes32 airdropRight, uint256 totalSupply_, bytes32 merkleRoot_)
ERC20("Airdrop", "Air")
DelegateClaim(registry_, referenceToken_, airdropRight)
{
_mint(address(this), totalSupply_);
merkleRoot = merkleRoot_;
merkle = Merkle(merkle_);
}

/**
Expand All @@ -43,7 +40,7 @@ contract Airdrop is ERC20, DelegateClaim {
*/
function claim(address vault, uint256 claimAmount, uint256 airdropSize, bytes32[] calldata merkleProof) external {
// First verify that airdrop for vault of amount airdropSize exists
require(merkle.verifyProof(merkleRoot, merkleProof, keccak256(abi.encodePacked(vault, airdropSize))), "Invalid Proof");
require(MerkleProof.verifyCalldata(merkleProof, merkleRoot, keccak256(abi.encodePacked(vault, airdropSize))), "Invalid Proof");
// Set claimable to the minimum of claimAmount and the maximum remaining airdrop tokens that can be claimed by
// the vault
uint256 claimable = Math.min(claimAmount, airdropSize - claimed[vault]);
Expand Down
7 changes: 3 additions & 4 deletions test/examples/Airdrop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {console2} from "forge-std/console2.sol";
import {Merkle} from "murky/Merkle.sol";
import {Airdrop} from "src/examples/Airdrop.sol";
import {DelegateRegistry} from "src/DelegateRegistry.sol";
import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol";
import {Math} from "openzeppelin/utils/math/Math.sol";

contract AirdropTest is Test {
Merkle public merkle;
Expand Down Expand Up @@ -97,9 +97,8 @@ contract AirdropTest is Test {
totalSupply_ += airdropData[i].amount;
}
// Create airdrop token
airdrop = new Airdrop(address(registry), referenceToken, acceptableRight, totalSupply_, merkleRoot, address(merkle));
airdrop = new Airdrop(address(registry), referenceToken, acceptableRight, totalSupply_, merkleRoot);
// Check data is stored correctly in token
assertEq(address(merkle), address(airdrop.merkle()));
assertEq(address(registry), address(airdrop.delegateRegistry()));
assertEq(merkleRoot, airdrop.merkleRoot());
assertEq(referenceToken, airdrop.referenceToken());
Expand Down Expand Up @@ -155,7 +154,7 @@ contract AirdropTest is Test {
totalSupply_ += airdropData[i].amount;
}
// Create airdrop token
airdrop = new Airdrop(address(registry), referenceToken, acceptableRight, totalSupply_, merkleRoot, address(merkle));
airdrop = new Airdrop(address(registry), referenceToken, acceptableRight, totalSupply_, merkleRoot);
// Create delegates
_createDelegates(delegateSeed, allowanceSeed, n);
// Try to claim with delegate
Expand Down

0 comments on commit 4217bc3

Please sign in to comment.