-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
7a3929f
to
ee681d0
Compare
ee681d0
to
a6e0c3a
Compare
769b9dc
to
50f6bfe
Compare
f2449bc
to
4ae7c2f
Compare
56d890f
to
fc2331f
Compare
{ | ||
return | ||
Base64.encode( | ||
abi.encodePacked( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: String exceeds 32 bytes
); | ||
|
||
string memory json = string( | ||
abi.encodePacked( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: String exceeds 32 bytes
11a8480
to
3dc7fbc
Compare
a9cb9b8
to
86fc450
Compare
3bd3a71
to
15a83fe
Compare
544afe0
to
eae8c9e
Compare
/// @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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: String exceeds 32 bytes
uint8 v_, | ||
SaleData calldata saleData_ | ||
) external payable override { | ||
require(_selling, "FeralfileExhibitionV4: sale is not started"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: Use Custom Errors instead of require statements
|
||
saleData_.payByVaultContract | ||
? vault.payForSale(r_, s_, v_, saleData_) | ||
: require( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message for require is too long: 45 counted / 32 allowed
contracts/FeralfileArtworkV4_2.sol
Outdated
// 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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: String exceeds 32 bytes
contracts/FeralfileArtworkV4_2.sol
Outdated
// 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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: Use Custom Errors instead of require statements
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed"); | ||
} | ||
|
||
require( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message for require is too long: 44 counted / 32 allowed
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed"); | ||
} | ||
|
||
require( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: String exceeds 32 bytes
require(success, "FeralfileExhibitionV4: FeralfileToken transfer failed"); | ||
} | ||
|
||
require( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: Use Custom Errors instead of require statements
contracts/FeralfileArtworkV4_2.sol
Outdated
uint256 mintAmount = coinAmount - tokenInfo.coinAmount; | ||
if (mintAmount > 0) { | ||
address owner = ownerOf(tokenId); | ||
_erc20Token.mint(owner, mintAmount * 10**18); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
contracts/FeralfileArtworkV4_2.sol
Outdated
} | ||
|
||
// Call the transfer function of the ERC20 contract | ||
if (coinsTransferAmount > 0 && _erc20Token.balanceOf(address(this)) > coinsTransferAmount * 10**18) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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?
13c94ac
to
e1b774e
Compare
/// @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( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC: Use Custom Errors instead of require statements
8007707
to
7bf26c7
Compare
Story link: https://github.com/bitmark-inc/feral-file/issues/2273