Skip to content

Commit

Permalink
Merge branch 'qualimetry/remove-pausing-mecanism' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Sep 5, 2023
2 parents c01709b + 8d37446 commit 7a91590
Show file tree
Hide file tree
Showing 27 changed files with 202 additions and 558 deletions.
259 changes: 120 additions & 139 deletions .gas-snapshot

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions .github/workflows/security-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: 🔒️ Security analysis

on:
workflow_dispatch:
pull_request:
push:
branches: ["main"]
# pull_request:
# push:
# branches: ["main"]

# Cancel previous runs on the same PR
concurrency:
Expand Down
10 changes: 4 additions & 6 deletions contracts/fraktions/FraktionTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable {
external
payable
onlyRole(FrakRoles.MINTER)
whenNotPaused
returns (ContentId id)
{
uint256 creatorTokenId;
Expand Down Expand Up @@ -188,7 +187,7 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable {
/**
* @dev Set the supply for the given fraktion id
*/
function setSupply(uint256 id, uint256 supply) external payable onlyRole(FrakRoles.MINTER) whenNotPaused {
function setSupply(uint256 id, uint256 supply) external payable onlyRole(FrakRoles.MINTER) {
assembly {
// Ensure we got valid data
if iszero(supply) {
Expand Down Expand Up @@ -227,17 +226,17 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable {
}

/// @dev Register a new transaction callback
function registerNewCallback(address callbackAddr) external onlyRole(FrakRoles.ADMIN) whenNotPaused {
function registerNewCallback(address callbackAddr) external onlyRole(FrakRoles.ADMIN) {
transferCallback = FraktionTransferCallback(callbackAddr);
}

/// @dev Mint a new fraktion of a nft
function mint(address to, uint256 id, uint256 amount) external payable onlyRole(FrakRoles.MINTER) whenNotPaused {
function mint(address to, uint256 id, uint256 amount) external payable onlyRole(FrakRoles.MINTER) {
_mint(to, id, amount, "");
}

/// @dev Burn a fraktion of a nft
function burn(uint256 id, uint256 amount) external payable whenNotPaused {
function burn(uint256 id, uint256 amount) external payable {
_burn(msg.sender, id, amount);
}

Expand Down Expand Up @@ -316,7 +315,6 @@ contract FraktionTokens is FrakAccessControlUpgradeable, ERC1155Upgradeable {
)
internal
override
whenNotPaused
{
assembly {
// Base offset to access array element's
Expand Down
7 changes: 3 additions & 4 deletions contracts/minter/IMinter.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// SPDX-License-Identifier: GNU GPLv3
pragma solidity 0.8.21;

import { IPausable } from "../utils/IPausable.sol";
import { ContentId } from "../libs/ContentId.sol";
import { FraktionId } from "../libs/FraktionId.sol";

/// @author @KONFeature
/// @title IMinter
/// @notice Interface for the Minter contract
/// @custom:security-contact [email protected]
interface IMinter is IPausable {
interface IMinter {
/* -------------------------------------------------------------------------- */
/* Error's */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -96,15 +95,15 @@ interface IMinter is IPausable {
* @param id Id of the free fraktion
* @param to Address of the user
*/
function mintFreeFraktionForUser(FraktionId id, address to) external payable;
function mintFreeFraktionForUser(FraktionId id, address to) external;

/**
* @notice Mint a free fraktion for the given user
* @dev Will mint a new free FraktionToken for the user, by first ensuring the user doesn't have any fraktion,
* only performed when contract not paused and by the right person
* @param id Id of the free fraktion
*/
function mintFreeFraktion(FraktionId id) external payable;
function mintFreeFraktion(FraktionId id) external;

/**
* @notice Increase the total supply for the given fraktion id
Expand Down
44 changes: 9 additions & 35 deletions contracts/minter/Minter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { IFrakToken } from "../tokens/IFrakToken.sol";
import { FrakAccessControlUpgradeable } from "../roles/FrakAccessControlUpgradeable.sol";
import { InvalidAddress } from "../utils/FrakErrors.sol";
import { Multicallable } from "solady/utils/Multicallable.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";

/// @author @KONFeature
/// @title Minter
/// @notice This contract will mint new content on the ecosytem, and mint fraktions for the user
/// @custom:security-contact [email protected]
contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Multicallable {
using SafeTransferLib for address;

/* -------------------------------------------------------------------------- */
/* Error's */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -124,7 +127,6 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
payable
override
onlyRole(FrakRoles.MINTER)
whenNotPaused
returns (ContentId contentId)
{
assembly {
Expand Down Expand Up @@ -196,7 +198,6 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
external
payable
onlyRole(FrakRoles.MINTER)
whenNotPaused
{
_mintFraktionForUser(id, to, deadline, v, r, s);
}
Expand All @@ -211,17 +212,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
* @param r Signature spec secp256k1
* @param s Signature spec secp256k1
*/
function mintFraktion(
FraktionId id,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
)
external
payable
whenNotPaused
{
function mintFraktion(FraktionId id, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable {
_mintFraktionForUser(id, msg.sender, deadline, v, r, s);
}

Expand All @@ -232,16 +223,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
* @param id Id of the free fraktion
* @param to Address of the user
*/
function mintFreeFraktionForUser(
FraktionId id,
address to
)
external
payable
override
onlyRole(FrakRoles.MINTER)
whenNotPaused
{
function mintFreeFraktionForUser(FraktionId id, address to) external override {
_mintFreeFraktionForUser(id, to);
}

Expand All @@ -251,7 +233,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
* only performed when contract not paused and by the right person
* @param id Id of the free fraktion
*/
function mintFreeFraktion(FraktionId id) external payable override whenNotPaused {
function mintFreeFraktion(FraktionId id) external override {
_mintFreeFraktionForUser(id, msg.sender);
}

Expand All @@ -262,7 +244,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
* @param id The id of the fraktion for which we want to increase the supply
* @param newSupply The supply we wan't to append for this fraktion
*/
function increaseSupply(FraktionId id, uint256 newSupply) external onlyRole(FrakRoles.MINTER) whenNotPaused {
function increaseSupply(FraktionId id, uint256 newSupply) external onlyRole(FrakRoles.MINTER) {
// Update the supply
fraktionTokens.setSupply(FraktionId.unwrap(id), newSupply);
}
Expand All @@ -274,15 +256,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
* @param fraktionId The id of the fraktion we will update the badge
* @param badge The new badge for the fraktion
*/
function updateCostBadge(
FraktionId fraktionId,
uint96 badge
)
external
override
onlyRole(FrakRoles.BADGE_UPDATER)
whenNotPaused
{
function updateCostBadge(FraktionId fraktionId, uint96 badge) external override onlyRole(FrakRoles.BADGE_UPDATER) {
_updateCostBadge(fraktionId, badge);
}

Expand Down Expand Up @@ -318,7 +292,7 @@ contract Minter is IMinter, FrakAccessControlUpgradeable, FraktionCostBadges, Mu
// Call the permit functions
frakToken.permit(to, address(this), cost, deadline, v, r, s);
// Transfer the tokens
frakToken.transferFrom(to, foundationWallet, cost);
address(frakToken).safeTransferFrom(to, foundationWallet, cost);
// Mint his fraktion
fraktionTokens.mint(to, FraktionId.unwrap(id), 1);
}
Expand Down
3 changes: 1 addition & 2 deletions contracts/reward/IRewarder.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
// SPDX-License-Identifier: GNU GPLv3
pragma solidity 0.8.21;

import { IPausable } from "../utils/IPausable.sol";
import { ContentId } from "../libs/ContentId.sol";

/// @author @KONFeature
/// @title IRewarder
/// @notice Interface for the rewarder contract
/// @custom:security-contact [email protected]
interface IRewarder is IPausable {
interface IRewarder {
/// @dev Error throwned when the reward is invalid
error InvalidReward();

Expand Down
37 changes: 10 additions & 27 deletions contracts/reward/Rewarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ContentBadges } from "./badges/ContentBadges.sol";
import { ListenerBadges } from "./badges/ListenerBadges.sol";
import { IContentPool } from "./contentPool/IContentPool.sol";
import { IReferralPool } from "./referralPool/IReferralPool.sol";
import { ArrayLib } from "../libs/ArrayLib.sol";
import { ContentId } from "../libs/ContentId.sol";
import { FraktionId } from "../libs/FraktionId.sol";
import { FrakRoles } from "../roles/FrakRoles.sol";
Expand All @@ -17,6 +16,7 @@ import { FrakAccessControlUpgradeable } from "../roles/FrakAccessControlUpgradea
import { InvalidAddress, InvalidArray, RewardTooLarge } from "../utils/FrakErrors.sol";
import { PushPullReward } from "../utils/PushPullReward.sol";
import { Multicallable } from "solady/utils/Multicallable.sol";
import { SafeTransferLib } from "solady/utils/SafeTransferLib.sol";

/// @author @KONFeature
/// @title Rewarder
Expand All @@ -30,6 +30,8 @@ contract Rewarder is
PushPullReward,
Multicallable
{
using SafeTransferLib for address;

/* -------------------------------------------------------------------------- */
/* Constant's */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -153,15 +155,7 @@ contract Rewarder is
/* -------------------------------------------------------------------------- */

/// @dev Directly pay a `listener` for the given frk `amount` (used for offchain to onchain wallet migration)
function payUserDirectly(
address listener,
uint256 amount
)
external
payable
onlyRole(FrakRoles.REWARDER)
whenNotPaused
{
function payUserDirectly(address listener, uint256 amount) external payable onlyRole(FrakRoles.REWARDER) {
assembly {
// Ensure the param are valid and not too much
if iszero(listener) {
Expand All @@ -184,7 +178,7 @@ contract Rewarder is
}

// Mint the reward for the user
token.transfer(listener, amount);
token.safeTransfer(listener, amount);
}

/// @dev Directly pay all the creators owner of `contentIds` for each given frk `amounts` (used for offchain reward
Expand All @@ -196,7 +190,6 @@ contract Rewarder is
external
payable
onlyRole(FrakRoles.REWARDER)
whenNotPaused
{
assembly {
// Ensure we got valid data
Expand Down Expand Up @@ -256,7 +249,6 @@ contract Rewarder is
external
payable
onlyRole(FrakRoles.REWARDER)
whenNotPaused
{
// Ensure we got valid data
assembly {
Expand Down Expand Up @@ -308,20 +300,20 @@ contract Rewarder is

// If we got reward for the pool, transfer them
if (rewardsAccounter.content > 0) {
token.transfer(address(contentPool), rewardsAccounter.content);
token.safeTransfer(address(contentPool), rewardsAccounter.content);
}
/*if (rewardsAccounter.referral > 0) {
token.transfer(address(referralPool), rewardsAccounter.referral);
token.safeTransfer(address(referralPool), rewardsAccounter.referral);
}*/
}

/// @dev Withdraw the pending founds of the caller
function withdrawFounds() external override whenNotPaused {
function withdrawFounds() external override {
_withdrawWithFee(msg.sender, FEE_PERCENT, foundationWallet);
}

/// @dev Withdraw the pending founds of `user`
function withdrawFounds(address user) external override onlyRole(FrakRoles.ADMIN) whenNotPaused {
function withdrawFounds(address user) external override {
_withdrawWithFee(user, FEE_PERCENT, foundationWallet);
}

Expand All @@ -338,21 +330,12 @@ contract Rewarder is
external
override
onlyRole(FrakRoles.BADGE_UPDATER)
whenNotPaused
{
_updateContentBadge(contentId, badge);
}

/// @dev Update the 'listener' 'badge'
function updateListenerBadge(
address listener,
uint256 badge
)
external
override
onlyRole(FrakRoles.BADGE_UPDATER)
whenNotPaused
{
function updateListenerBadge(address listener, uint256 badge) external override onlyRole(FrakRoles.BADGE_UPDATER) {
_updateListenerBadge(listener, badge);
}

Expand Down
16 changes: 4 additions & 12 deletions contracts/reward/contentPool/ContentPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,7 @@ contract ContentPool is IContentPool, FrakAccessControlUpgradeable, PushPullRewa
/* -------------------------------------------------------------------------- */

/// @dev Add a new `rewardAmount` to the pool for the content `contentId`
function addReward(
ContentId contentId,
uint256 rewardAmount
)
external
payable
onlyRole(FrakRoles.REWARDER)
whenNotPaused
{
function addReward(ContentId contentId, uint256 rewardAmount) external payable onlyRole(FrakRoles.REWARDER) {
// Ensure reward is specified
assembly ("memory-safe") {
if or(iszero(rewardAmount), gt(rewardAmount, MAX_REWARD)) {
Expand Down Expand Up @@ -165,18 +157,18 @@ contract ContentPool is IContentPool, FrakAccessControlUpgradeable, PushPullRewa
}

/// @dev Compute all the pools balance of the user
function computeAllPoolsBalance(address user) external payable onlyRole(FrakRoles.ADMIN) whenNotPaused {
function computeAllPoolsBalance(address user) external {
_computeAndSaveAllForUser(user);
}

/// @dev Withdraw the pending founds for the current caller
function withdrawFounds() external virtual override whenNotPaused {
function withdrawFounds() external virtual override {
_computeAndSaveAllForUser(msg.sender);
_tryWithdraw(msg.sender);
}

/// @dev Withdraw the pending founds for a `user`
function withdrawFounds(address user) external virtual override onlyRole(FrakRoles.ADMIN) whenNotPaused {
function withdrawFounds(address user) external virtual override {
_computeAndSaveAllForUser(user);
_tryWithdraw(user);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/reward/contentPool/IContentPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface IContentPool is FraktionTransferCallback {
function addReward(ContentId contentId, uint256 rewardAmount) external payable;

/// @dev Compute all the pools balance of the user
function computeAllPoolsBalance(address user) external payable;
function computeAllPoolsBalance(address user) external;

/* -------------------------------------------------------------------------- */
/* External view function's */
Expand Down
Loading

0 comments on commit 7a91590

Please sign in to comment.