Skip to content

Commit

Permalink
Upgrade dependencies and minor clean up (#580)
Browse files Browse the repository at this point in the history
* Update dependency and solc version

* package-lock and yarn.lock

* Fix prettier

* Update lib dependencies
- oz 4.9.3
- chainlink 2.7.1
- forge-std 1.7.3

* fix tests

* prettier

* Remove unused echidna and manticore

* AirdropClaimable: Improve Code Quality
- Rename confusing state variable to be more explicit
- Remove unnecessary states and functions for deployment
- Fix tests

* Remove TW prefix for libs

* Prettier 120 width

---------

Co-authored-by: Yash <kumaryashcse@gmail.com>
Co-authored-by: Yash <72552910+kumaryash90@users.noreply.github.com>
Co-authored-by: nkrishang <62195808+nkrishang@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 23, 2023
1 parent 791e8df commit ef6a072
Show file tree
Hide file tree
Showing 377 changed files with 9,944 additions and 8,034 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ deployArgs.json
/notes.txt
.yalc/
yalc.lock
package-lock.json
yarn.lock

# Forge
#/lib
Expand All @@ -58,4 +56,4 @@ corpus/
# IDES
.idea

*.DS_Store
*.DS_Store
2 changes: 0 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
[submodule "lib/ERC721A-Upgradeable"]
path = lib/ERC721A-Upgradeable
url = https://github.com/chiru-labs/ERC721A-Upgradeable
branch = v3.3.0
[submodule "lib/ERC721A"]
path = lib/ERC721A
url = https://github.com/chiru-labs/ERC721A
branch = v3.3.0
[submodule "lib/dynamic-contracts"]
path = lib/dynamic-contracts
url = https://github.com/thirdweb-dev/dynamic-contracts
3 changes: 1 addition & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
{
"files": "*.sol",
"options": {
"tabWidth": 4,
"explicitTypes": "always"
"tabWidth": 4
}
}
]
Expand Down
23 changes: 5 additions & 18 deletions contracts/base/ERC1155Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "../extension/Ownable.sol";
import "../extension/Royalty.sol";

Check warning on line 11 in contracts/base/ERC1155Base.sol

View workflow job for this annotation

GitHub Actions / lint

global import of path ../extension/Royalty.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)
import "../extension/BatchMintMetadata.sol";

Check warning on line 12 in contracts/base/ERC1155Base.sol

View workflow job for this annotation

GitHub Actions / lint

global import of path ../extension/BatchMintMetadata.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

import "../lib/TWStrings.sol";
import "../lib/Strings.sol";

Check warning on line 14 in contracts/base/ERC1155Base.sol

View workflow job for this annotation

GitHub Actions / lint

global import of path ../lib/Strings.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

/**
* The `ERC1155Base` smart contract implements the ERC1155 NFT standard.
Expand All @@ -31,7 +31,7 @@ import "../lib/TWStrings.sol";
*/

contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall, BatchMintMetadata {
using TWStrings for uint256;
using Strings for uint256;

/*//////////////////////////////////////////////////////////////
State variables
Expand Down Expand Up @@ -97,12 +97,7 @@ contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall,
* @param _tokenURI The full metadata URI for the NFTs minted (if a new NFT is being minted).
* @param _amount The amount of the same NFT to mint.
*/
function mintTo(
address _to,
uint256 _tokenId,
string memory _tokenURI,
uint256 _amount
) public virtual {
function mintTo(address _to, uint256 _tokenId, string memory _tokenURI, uint256 _amount) public virtual {
require(_canMint(), "Not authorized to mint.");

Check warning on line 101 in contracts/base/ERC1155Base.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements

uint256 tokenIdToMint;
Expand Down Expand Up @@ -173,11 +168,7 @@ contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall,
* @param _tokenId The tokenId of the NFT to burn.
* @param _amount The amount of the NFT to burn.
*/
function burn(
address _owner,
uint256 _tokenId,
uint256 _amount
) external virtual {
function burn(address _owner, uint256 _tokenId, uint256 _amount) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand All @@ -193,11 +184,7 @@ contract ERC1155Base is ERC1155, ContractMetadata, Ownable, Royalty, Multicall,
* @param _tokenIds The tokenIds of the NFTs to burn.
* @param _amounts The amounts of the NFTs to burn.
*/
function burnBatch(
address _owner,
uint256[] memory _tokenIds,
uint256[] memory _amounts
) external virtual {
function burnBatch(address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/ERC1155DelayedReveal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import "../extension/DelayedReveal.sol";
*/

contract ERC1155DelayedReveal is ERC1155LazyMint, DelayedReveal {
using TWStrings for uint256;
using Strings for uint256;

/*//////////////////////////////////////////////////////////////
Constructor
Expand Down
18 changes: 5 additions & 13 deletions contracts/base/ERC1155Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import "../extension/DropSinglePhase1155.sol";
import "../extension/LazyMint.sol";
import "../extension/DelayedReveal.sol";

import "../lib/CurrencyTransferLib.sol";
import "../lib/TWStrings.sol";
import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol";
import "../lib/Strings.sol";

/**
* BASE: ERC1155Base
Expand Down Expand Up @@ -53,7 +53,7 @@ contract ERC1155Drop is
DelayedReveal,
DropSinglePhase1155
{
using TWStrings for uint256;
using Strings for uint256;

/*//////////////////////////////////////////////////////////////
Mappings
Expand Down Expand Up @@ -119,11 +119,7 @@ contract ERC1155Drop is
* @param _tokenId The tokenId of the NFT to burn.
* @param _amount The amount of the NFT to burn.
*/
function burn(
address _owner,
uint256 _tokenId,
uint256 _amount
) external virtual {
function burn(address _owner, uint256 _tokenId, uint256 _amount) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand All @@ -139,11 +135,7 @@ contract ERC1155Drop is
* @param _tokenIds The tokenIds of the NFTs to burn.
* @param _amounts The amounts of the NFTs to burn.
*/
function burnBatch(
address _owner,
uint256[] memory _tokenIds,
uint256[] memory _amounts
) external virtual {
function burnBatch(address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand Down
34 changes: 7 additions & 27 deletions contracts/base/ERC1155LazyMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../extension/BatchMintMetadata.sol";
import "../extension/LazyMint.sol";
import "../extension/interface/IClaimableERC1155.sol";

import "../lib/TWStrings.sol";
import "../lib/Strings.sol";
import "../external-deps/openzeppelin/security/ReentrancyGuard.sol";

/**
Expand Down Expand Up @@ -59,7 +59,7 @@ contract ERC1155LazyMint is
IClaimableERC1155,
ReentrancyGuard
{
using TWStrings for uint256;
using Strings for uint256;

/*//////////////////////////////////////////////////////////////
Mappings
Expand Down Expand Up @@ -130,11 +130,7 @@ contract ERC1155LazyMint is
* @param _tokenId The tokenId of the lazy minted NFT to mint.
* @param _quantity The number of tokens to mint.
*/
function claim(
address _receiver,
uint256 _tokenId,
uint256 _quantity
) public payable virtual nonReentrant {
function claim(address _receiver, uint256 _tokenId, uint256 _quantity) public payable virtual nonReentrant {
require(_tokenId < nextTokenIdToMint(), "invalid id");
verifyClaim(msg.sender, _tokenId, _quantity); // Add your claim verification logic by overriding this function.

Expand All @@ -152,11 +148,7 @@ contract ERC1155LazyMint is
* @param _tokenId The tokenId of the lazy minted NFT to mint.
* @param _quantity The number of NFTs being claimed.
*/
function verifyClaim(
address _claimer,
uint256 _tokenId,
uint256 _quantity
) public view virtual {}
function verifyClaim(address _claimer, uint256 _tokenId, uint256 _quantity) public view virtual {}

/**
* @notice Lets an owner or approved operator burn NFTs of the given tokenId.
Expand All @@ -165,11 +157,7 @@ contract ERC1155LazyMint is
* @param _tokenId The tokenId of the NFT to burn.
* @param _amount The amount of the NFT to burn.
*/
function burn(
address _owner,
uint256 _tokenId,
uint256 _amount
) external virtual {
function burn(address _owner, uint256 _tokenId, uint256 _amount) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand All @@ -185,11 +173,7 @@ contract ERC1155LazyMint is
* @param _tokenIds The tokenIds of the NFTs to burn.
* @param _amounts The amounts of the NFTs to burn.
*/
function burnBatch(
address _owner,
uint256[] memory _tokenIds,
uint256[] memory _amounts
) external virtual {
function burnBatch(address _owner, uint256[] memory _tokenIds, uint256[] memory _amounts) external virtual {
address caller = msg.sender;

require(caller == _owner || isApprovedForAll[_owner][caller], "Unapproved caller");
Expand Down Expand Up @@ -243,11 +227,7 @@ contract ERC1155LazyMint is
* @param _tokenId The tokenId of the lazy minted NFT to mint.
* @param _quantity The number of tokens to mint.
*/
function _transferTokensOnClaim(
address _receiver,
uint256 _tokenId,
uint256 _quantity
) internal virtual {
function _transferTokensOnClaim(address _receiver, uint256 _tokenId, uint256 _quantity) internal virtual {
_mint(_receiver, _tokenId, _quantity, "");
}

Expand Down
13 changes: 5 additions & 8 deletions contracts/base/ERC1155SignatureMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "./ERC1155Base.sol";
import "../extension/PrimarySale.sol";
import "../extension/SignatureMintERC1155.sol";

import "../lib/CurrencyTransferLib.sol";
import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol";

/**
* BASE: ERC1155Base
Expand Down Expand Up @@ -49,13 +49,10 @@ contract ERC1155SignatureMint is ERC1155Base, PrimarySale, SignatureMintERC1155
* @param _req The payload / mint request.
* @param _signature The signature produced by an account signing the mint request.
*/
function mintWithSignature(MintRequest calldata _req, bytes calldata _signature)
external
payable
virtual
override
returns (address signer)
{
function mintWithSignature(
MintRequest calldata _req,
bytes calldata _signature
) external payable virtual override returns (address signer) {
require(_req.quantity > 0, "Minting zero tokens.");

uint256 tokenIdToMint;
Expand Down
6 changes: 1 addition & 5 deletions contracts/base/ERC20Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ contract ERC20Base is ContractMetadata, Multicall, Ownable, ERC20Permit, IMintab
Constructor
//////////////////////////////////////////////////////////////*/

constructor(
address _defaultAdmin,
string memory _name,
string memory _symbol
) ERC20Permit(_name, _symbol) {
constructor(address _defaultAdmin, string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) {
_setupOwner(_defaultAdmin);
}

Expand Down
12 changes: 5 additions & 7 deletions contracts/base/ERC20Drop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "../extension/PrimarySale.sol";
import "../extension/DropSinglePhase.sol";
import "../extension/interface/IBurnableERC20.sol";

import "../lib/CurrencyTransferLib.sol";
import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol";

/**
* BASE: ERC20
Expand Down Expand Up @@ -112,12 +112,10 @@ contract ERC20Drop is ContractMetadata, Multicall, Ownable, ERC20Permit, Primary
}

/// @dev Transfers the tokens being claimed.
function _transferTokensOnClaim(address _to, uint256 _quantityBeingClaimed)
internal
virtual
override
returns (uint256)
{
function _transferTokensOnClaim(
address _to,
uint256 _quantityBeingClaimed
) internal virtual override returns (uint256) {
_mint(_to, _quantityBeingClaimed);
return 0;
}
Expand Down
12 changes: 5 additions & 7 deletions contracts/base/ERC20DropVote.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "../extension/Ownable.sol";
import "../extension/PrimarySale.sol";
import "../extension/DropSinglePhase.sol";

import "../lib/CurrencyTransferLib.sol";
import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol";

/**
* BASE: ERC20Votes
Expand Down Expand Up @@ -95,12 +95,10 @@ contract ERC20DropVote is ContractMetadata, Multicall, Ownable, ERC20Votes, Prim
}

/// @dev Transfers the tokens being claimed.
function _transferTokensOnClaim(address _to, uint256 _quantityBeingClaimed)
internal
virtual
override
returns (uint256)
{
function _transferTokensOnClaim(
address _to,
uint256 _quantityBeingClaimed
) internal virtual override returns (uint256) {
_mint(_to, _quantityBeingClaimed);
return 0;
}
Expand Down
18 changes: 6 additions & 12 deletions contracts/base/ERC20SignatureMint.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import "./ERC20Base.sol";
import "../extension/PrimarySale.sol";
import { SignatureMintERC20 } from "../extension/SignatureMintERC20.sol";

import "../lib/CurrencyTransferLib.sol";
import { CurrencyTransferLib } from "../lib/CurrencyTransferLib.sol";

/**
* BASE: ERC20
Expand Down Expand Up @@ -47,12 +47,10 @@ contract ERC20SignatureMint is ERC20Base, PrimarySale, SignatureMintERC20 {
* @param _req The payload / mint request.
* @param _signature The signature produced by an account signing the mint request.
*/
function mintWithSignature(MintRequest calldata _req, bytes calldata _signature)
external
payable
virtual
returns (address signer)
{
function mintWithSignature(
MintRequest calldata _req,
bytes calldata _signature
) external payable virtual returns (address signer) {
require(_req.quantity > 0, "Minting zero tokens.");

// Verify and process payload.
Expand Down Expand Up @@ -84,11 +82,7 @@ contract ERC20SignatureMint is ERC20Base, PrimarySale, SignatureMintERC20 {
}

/// @dev Collects and distributes the primary sale value of tokens being claimed.
function _collectPriceOnClaim(
address _primarySaleRecipient,
address _currency,
uint256 _price
) internal virtual {
function _collectPriceOnClaim(address _primarySaleRecipient, address _currency, uint256 _price) internal virtual {
if (_price == 0) {
require(msg.value == 0, "!Value");
return;
Expand Down
Loading

0 comments on commit ef6a072

Please sign in to comment.