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

Fix the audit report issue #25

Merged
merged 5 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions contracts/FeralfileArtworkV4.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ contract FeralfileExhibitionV4 is

// initialize max supply map
for (uint256 i = 0; i < seriesIds_.length; i++) {
// Check duplicate with others
for (uint256 j = i + 1; j < seriesIds_.length; j++) {
if (seriesIds_[i] == seriesIds_[j]) {
revert("FeralfileExhibitionV4: duplicate seriesId");
}
}
require(
seriesMaxSupplies_[i] > 0,
"FeralfileExhibitionV4: zero max supply"
Expand Down Expand Up @@ -440,6 +446,11 @@ contract FeralfileExhibitionV4 is
) {
uint256 rev = (itemRevenue *
saleData_.revenueShares[i][j].bps) / 10000;
if (
saleData_.revenueShares[i][j].recipient == costReceiver
) {
continue;
}
distributedRevenue += rev;
payable(saleData_.revenueShares[i][j].recipient).transfer(
rev
Expand All @@ -450,10 +461,10 @@ contract FeralfileExhibitionV4 is
emit BuyArtwork(saleData_.destination, saleData_.tokenIds[i]);
}

// Transfer cost and remaining funds
uint256 cost = saleData_.price - distributedRevenue;
if (cost > 0) {
payable(costReceiver).transfer(cost);
// Transfer cost, platform revenue and remaining funds
uint256 leftOver = saleData_.price - distributedRevenue;
if (leftOver > 0) {
payable(costReceiver).transfer(leftOver);
}
}

Expand Down Expand Up @@ -596,11 +607,6 @@ contract FeralfileExhibitionV4 is
);
}

/// @notice withdraw all fund
function withdrawFunds() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}

/// @notice Event emitted when new Artwork has been minted
event NewArtwork(
address indexed owner,
Expand Down
26 changes: 26 additions & 0 deletions test/feralfile_exhibition_v4.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@ contract("FeralfileExhibitionV4_0", async (accounts) => {
assert.equal(seriesTotalSupply1, 0);
});

it("test duplicate series in constructor", async function () {
// Deploy contract with duplicate series defined
let seriesIds = [0, 1, 2, 3, 1];
let seriesMaxSupply = [1, 1, 100, 1000, 10000];
try {
await FeralfileExhibitionV4.new(
"Feral File V4 Test",
"FFv4",
true,
true,
this.signer,
this.vault.address,
COST_RECEIVER,
CONTRACT_URI,
seriesIds,
seriesMaxSupply
);
} catch (error) {
assert.ok(
error.message.includes(
"FeralfileExhibitionV4: duplicate seriesId"
)
);
}
})

it("test mint artwork", async function () {
const contract = this.contracts[0];

Expand Down