Skip to content

Commit

Permalink
prettier (#179)
Browse files Browse the repository at this point in the history
* prettier

* fix test

* always enable ffi
  • Loading branch information
jakeloo authored Jun 18, 2022
1 parent 23b57e6 commit 3b5f0ad
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 30 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ jobs:
version: nightly
- name: Run tests
run: |
forge test --no-match-contract SignatureDrop
forge test --match-contract SignatureDrop --ffi
forge test
3 changes: 2 additions & 1 deletion contracts/drop/DropERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ contract DropERC1155 is
// Verify claim validity. If not valid, revert.
// when there's allowlist present --> verifyClaimMerkleProof will verify the _proofMaxQuantityPerTransaction value with hashed leaf in the allowlist
// when there's no allowlist, this check is true --> verifyClaim will check for _quantity being less/equal than the limit
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 || claimCondition[_tokenId].phases[activeConditionId].merkleRoot == bytes32(0);
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 ||
claimCondition[_tokenId].phases[activeConditionId].merkleRoot == bytes32(0);
verifyClaim(
activeConditionId,
_msgSender(),
Expand Down
10 changes: 3 additions & 7 deletions contracts/drop/DropERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ contract DropERC20 is
// Verify claim validity. If not valid, revert.
// when there's allowlist present --> verifyClaimMerkleProof will verify the _proofMaxQuantityPerTransaction value with hashed leaf in the allowlist
// when there's no allowlist, this check is true --> verifyClaim will check for _quantity being less/equal than the limit
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 || claimCondition.phases[activeConditionId].merkleRoot == bytes32(0);
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 ||
claimCondition.phases[activeConditionId].merkleRoot == bytes32(0);
verifyClaim(
activeConditionId,
_msgSender(),
Expand Down Expand Up @@ -320,12 +321,7 @@ contract DropERC20 is
}

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
primarySaleRecipient,
totalPrice - platformFees
);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), primarySaleRecipient, totalPrice - platformFees);
}

/// @dev Transfers the tokens being claimed.
Expand Down
10 changes: 3 additions & 7 deletions contracts/drop/DropERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ contract DropERC721 is
// Verify claim validity. If not valid, revert.
// when there's allowlist present --> verifyClaimMerkleProof will verify the _proofMaxQuantityPerTransaction value with hashed leaf in the allowlist
// when there's no allowlist, this check is true --> verifyClaim will check for _quantity being less/equal than the limit
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 || claimCondition.phases[activeConditionId].merkleRoot == bytes32(0);
bool toVerifyMaxQuantityPerTransaction = _proofMaxQuantityPerTransaction == 0 ||
claimCondition.phases[activeConditionId].merkleRoot == bytes32(0);
verifyClaim(
activeConditionId,
_msgSender(),
Expand Down Expand Up @@ -460,12 +461,7 @@ contract DropERC721 is
}

CurrencyTransferLib.transferCurrency(_currency, _msgSender(), platformFeeRecipient, platformFees);
CurrencyTransferLib.transferCurrency(
_currency,
_msgSender(),
primarySaleRecipient,
totalPrice - platformFees
);
CurrencyTransferLib.transferCurrency(_currency, _msgSender(), primarySaleRecipient, totalPrice - platformFees);
}

/// @dev Transfers the NFTs being claimed.
Expand Down
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ src = 'contracts'
test = 'src/test'
verbosity = 0
#ignored_error_codes = []
fuzz_runs = 100
#ffi = false
#fuzz_runs = 100
ffi = true
#sender = '0x00a329c0648769a73afac7f9381e08fb43dbea72'
#tx_origin = '0x00a329c0648769a73afac7f9381e08fb43dbea72'
#initial_balance = '0xffffffffffffffffffffffff'
Expand Down
13 changes: 7 additions & 6 deletions src/test/drop/DropERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../utils/BaseTest.sol";
contract SubExploitContract is ERC721Holder, ERC1155Holder {
DropERC721 internal drop;
address payable internal master;

// using Strings for uint256;

constructor(address _drop) {
Expand Down Expand Up @@ -267,15 +268,15 @@ contract DropERC721Test is BaseTest {
inputs[0] = "node";
inputs[1] = "src/test/scripts/generateRoot.ts";
inputs[2] = Strings.toString(x);

bytes memory result = vm.ffi(inputs);
// revert();
bytes32 root = abi.decode(result, (bytes32));

inputs[1] = "src/test/scripts/getProof.ts";
result = vm.ffi(inputs);
bytes32[] memory proofs = abi.decode(result, (bytes32[]));

vm.warp(1);

address receiver = address(0x92Bb439374a091c7507bE100183d8D1Ed2c9dAD3);
Expand Down Expand Up @@ -310,15 +311,15 @@ contract DropERC721Test is BaseTest {
inputs[0] = "node";
inputs[1] = "src/test/scripts/generateRoot.ts";
inputs[2] = Strings.toString(x);

bytes memory result = vm.ffi(inputs);
// revert();
bytes32 root = abi.decode(result, (bytes32));

inputs[1] = "src/test/scripts/getProof.ts";
result = vm.ffi(inputs);
bytes32[] memory proofs = abi.decode(result, (bytes32[]));

vm.warp(1);

address receiver = address(0x92Bb439374a091c7507bE100183d8D1Ed2c9dAD3);
Expand Down
2 changes: 1 addition & 1 deletion src/test/scripts/generateRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MerkleTree } = require("merkletreejs");
const keccak256 = require("keccak256");
const { ethers } = require("ethers");

const process = require('process');
const process = require("process");

const members = [
"0x92Bb439374a091c7507bE100183d8D1Ed2c9dAD3",
Expand Down
2 changes: 1 addition & 1 deletion src/test/scripts/getProof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { MerkleTree } = require("merkletreejs");
const keccak256 = require("keccak256");
const { ethers } = require("ethers");

const process = require('process');
const process = require("process");

const members = [
"0x92Bb439374a091c7507bE100183d8D1Ed2c9dAD3",
Expand Down
6 changes: 3 additions & 3 deletions src/test/utils/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ abstract contract BaseTest is DSTest, Test {
TWFactory(factory).addImplementation(address(new TokenERC20(fee)));
TWFactory(factory).addImplementation(address(new TokenERC721(fee)));
TWFactory(factory).addImplementation(address(new TokenERC1155(fee)));
TWFactory(factory).addImplementation(address(new DropERC20(fee)));
TWFactory(factory).addImplementation(address(new DropERC20()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("DropERC721"), 1)));
TWFactory(factory).addImplementation(address(new DropERC721(fee)));
TWFactory(factory).addImplementation(address(new DropERC721()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("DropERC1155"), 1)));
TWFactory(factory).addImplementation(address(new DropERC1155(fee)));
TWFactory(factory).addImplementation(address(new DropERC1155()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("SignatureDrop"), 1)));
TWFactory(factory).addImplementation(address(new SignatureDrop()));
TWFactory(factory).addImplementation(address(new MockContract(bytes32("Marketplace"), 1)));
Expand Down

0 comments on commit 3b5f0ad

Please sign in to comment.