Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add feralfile exhibition v4_2 & feralfile token contracts #41

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

hvthhien
Copy link
Contributor

@hvthhien hvthhien commented May 21, 2024

contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 7a3929f to ee681d0 Compare May 21, 2024 07:18
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from ee681d0 to a6e0c3a Compare May 21, 2024 07:20
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 769b9dc to 50f6bfe Compare May 22, 2024 03:19
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileToken.sol Outdated Show resolved Hide resolved
contracts/FeralfileArtworkV4_2.sol Show resolved Hide resolved
contracts/FeralfileArtworkV4_2.sol Show resolved Hide resolved
contracts/FeralfileArtworkV4_2.sol Outdated Show resolved Hide resolved
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from f2449bc to 4ae7c2f Compare May 22, 2024 08:38
github-actions bot pushed a commit that referenced this pull request May 23, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 56d890f to fc2331f Compare May 23, 2024 02:58
{
return
Base64.encode(
abi.encodePacked(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

);

string memory json = string(
abi.encodePacked(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

github-actions bot pushed a commit that referenced this pull request May 23, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 11a8480 to 3dc7fbc Compare May 23, 2024 09:05
github-actions bot pushed a commit that referenced this pull request May 23, 2024
Makefile Outdated Show resolved Hide resolved
github-actions bot pushed a commit that referenced this pull request May 24, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from a9cb9b8 to 86fc450 Compare May 24, 2024 09:48
github-actions bot pushed a commit that referenced this pull request May 24, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 3bd3a71 to 15a83fe Compare May 28, 2024 02:30
github-actions bot pushed a commit that referenced this pull request May 28, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 544afe0 to eae8c9e Compare May 28, 2024 10:05
/// @param s_ - part of signature for validating parameters integrity
/// @param v_ - part of signature for validating parameters integrity
/// @param saleData_ - the sale data
function buyArtworks(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Function has cyclomatic complexity 10 but allowed no more than 7

uint8 v_,
SaleData calldata saleData_
) external payable override {
require(_selling, "FeralfileExhibitionV4: sale is not started");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Error message for require is too long: 42 counted / 32 allowed

uint8 v_,
SaleData calldata saleData_
) external payable override {
require(_selling, "FeralfileExhibitionV4: sale is not started");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

uint8 v_,
SaleData calldata saleData_
) external payable override {
require(_selling, "FeralfileExhibitionV4: sale is not started");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: Use Custom Errors instead of require statements


saleData_.payByVaultContract
? vault.payForSale(r_, s_, v_, saleData_)
: require(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Error message for require is too long: 45 counted / 32 allowed

// Call the transfer function of the ERC20 contract
if (coinsTransferAmount > 0 && _erc20Token.balanceOf(address(this)) > coinsTransferAmount * 10**18) {
bool success = _erc20Token.transfer(saleData_.destination, coinsTransferAmount * 10**18);
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

// Call the transfer function of the ERC20 contract
if (coinsTransferAmount > 0 && _erc20Token.balanceOf(address(this)) > coinsTransferAmount * 10**18) {
bool success = _erc20Token.transfer(saleData_.destination, coinsTransferAmount * 10**18);
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: Use Custom Errors instead of require statements

require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");
}

require(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Error message for require is too long: 44 counted / 32 allowed

require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");
}

require(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");
}

require(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: Use Custom Errors instead of require statements

github-actions bot pushed a commit that referenced this pull request May 28, 2024
uint256 mintAmount = coinAmount - tokenInfo.coinAmount;
if (mintAmount > 0) {
address owner = ownerOf(tokenId);
_erc20Token.mint(owner, mintAmount * 10**18);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call decimal() from token contract instead of hard-coding the 18 decimals.

// mint token for the owner
uint256 mintAmount = coinAmount - tokenInfo.coinAmount;
if (mintAmount > 0) {
address owner = ownerOf(tokenId);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confirming with Sean if we should mint to the current NFT owner or the first owner.

uint8 v_,
SaleData calldata saleData_
) external payable override {
require(_selling, "FeralfileExhibitionV4: sale is not started");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just call super.buyArtwork instead? The coin transfer part could be done after that, it's OK to do them separately.
I know using the same loop could reduce a bit gas fee but it would be just a little bit. Copy the code from the parent contract would make it harder to maintain the shared logic between those contracts. Please consider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot call super.buyArtwork since the function was defined as external in the base contract. To do this we might need to change the access modifier in the base contract.

}

// Call the transfer function of the ERC20 contract
if (coinsTransferAmount > 0 && _erc20Token.balanceOf(address(this)) > coinsTransferAmount * 10**18) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if possible, please create a private function to get exact amount of coin instead of putting multiple magic values.
Reference here.

Copy link
Member

@jollyjoker992 jollyjoker992 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you ask some more test for the coin balance after purchasing and update token info?

@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 13c94ac to e1b774e Compare May 29, 2024 02:17
/// @param s_ - part of signature for validating parameters integrity
/// @param v_ - part of signature for validating parameters integrity
/// @param saleData_ - the sale data
function buyArtworks(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Function has cyclomatic complexity 11 but allowed no more than 7

uint256 coinUnits = _convertToTokenUnits(coinsTransferAmount);
if (_erc20Token.balanceOf(address(this)) > coinUnits) {
bool success = _erc20Token.transfer(saleData_.destination, coinUnits);
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
Error message for require is too long: 53 counted / 32 allowed

uint256 coinUnits = _convertToTokenUnits(coinsTransferAmount);
if (_erc20Token.balanceOf(address(this)) > coinUnits) {
bool success = _erc20Token.transfer(saleData_.destination, coinUnits);
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: String exceeds 32 bytes

uint256 coinUnits = _convertToTokenUnits(coinsTransferAmount);
if (_erc20Token.balanceOf(address(this)) > coinUnits) {
bool success = _erc20Token.transfer(saleData_.destination, coinUnits);
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [solhint] reported by reviewdog 🐶
GC: Use Custom Errors instead of require statements

github-actions bot pushed a commit that referenced this pull request May 29, 2024
@hvthhien hvthhien force-pushed the add_feralfil_token_contract branch from 8007707 to 7bf26c7 Compare May 29, 2024 04:26
@hvthhien hvthhien changed the title add feralfile token contract add feralfile exhibition v4_2 contract May 29, 2024
@hvthhien hvthhien changed the title add feralfile exhibition v4_2 contract add feralfile exhibition v4_2 & feralfile token contracts May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants