Skip to content

Commit

Permalink
all pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Jul 23, 2024
1 parent e74be58 commit e097caf
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 56 deletions.
2 changes: 1 addition & 1 deletion slither-ci.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"detectors_to_exclude": "timestamp,uninitialized-local",
"detectors_to_exclude": "timestamp,uninitialized-local,naming-convention,solc-version,shadowing-local",
"exclude_informational": true,
"exclude_low": false,
"exclude_medium": false,
Expand Down
25 changes: 18 additions & 7 deletions src/JBController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
returns (uint256 projectId)
{
// Mint the project ERC-721 into the owner's wallet.
// slither-disable-next-line reentrancy-benign
projectId = PROJECTS.createFor(owner);

// If provided, set the project's metadata URI.
Expand All @@ -366,6 +367,7 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
_configureTerminals(projectId, terminalConfigurations);

// Queue the rulesets.
// slither-disable-next-line reentrancy-events
uint256 rulesetId = _queueRulesets(projectId, rulesetConfigurations);

emit LaunchProject(rulesetId, projectId, projectUri, memo, _msgSender());
Expand Down Expand Up @@ -419,6 +421,7 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
_configureTerminals(projectId, terminalConfigurations);

// Queue the first ruleset.
// slither-disable-next-line reentrancy-events
rulesetId = _queueRulesets(projectId, rulesetConfigurations);

emit LaunchRulesets(rulesetId, projectId, memo, _msgSender());
Expand Down Expand Up @@ -451,6 +454,7 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
});

// Queue the rulesets.
// slither-disable-next-line reentrancy-events
rulesetId = _queueRulesets(projectId, rulesetConfigurations);

emit QueueRulesets(rulesetId, projectId, memo, _msgSender());
Expand Down Expand Up @@ -515,15 +519,16 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
mulDiv(tokenCount, JBConstants.MAX_RESERVED_PERCENT - reservedPercent, JBConstants.MAX_RESERVED_PERCENT);

// Mint the tokens.
// slither-disable-next-line reentrancy-benign,reentrancy-events
TOKENS.mintFor(beneficiary, projectId, beneficiaryTokenCount);
}

emit MintTokens(beneficiary, projectId, tokenCount, beneficiaryTokenCount, memo, reservedPercent, _msgSender());

// Add any reserved tokens to the pending reserved token balance.
if (reservedPercent > 0) {
pendingReservedTokenBalanceOf[projectId] += tokenCount - beneficiaryTokenCount;
}

emit MintTokens(beneficiary, projectId, tokenCount, beneficiaryTokenCount, memo, reservedPercent, _msgSender());
}

/// @notice Burns a project's tokens or credits from the specific holder's balance.
Expand Down Expand Up @@ -553,10 +558,10 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
// There must be tokens to burn.
if (tokenCount == 0) revert NO_BURNABLE_TOKENS();

emit BurnTokens(holder, projectId, tokenCount, memo, _msgSender());

// Burn the tokens.
TOKENS.burnFrom(holder, projectId, tokenCount);

emit BurnTokens(holder, projectId, tokenCount, memo, _msgSender());
}

/// @notice Sends a project's pending reserved tokens to its reserved token splits.
Expand Down Expand Up @@ -589,6 +594,8 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
// Make sure this is being called by the directory.
if (msg.sender != address(DIRECTORY)) revert UNAUTHORIZED();

emit Migrate(projectId, to, msg.sender);

// Mint any pending reserved tokens before migrating.
if (pendingReservedTokenBalanceOf[projectId] != 0) {
_sendReservedTokensToSplitsOf(projectId);
Expand All @@ -598,8 +605,6 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
if (to.supportsInterface(type(IJBMigratable).interfaceId)) {
IJBMigratable(address(to)).receiveMigrationFrom(IERC165(this), projectId);
}

emit Migrate(projectId, to, msg.sender);
}

/// @notice Set a project's metadata URI.
Expand Down Expand Up @@ -924,12 +929,14 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
// If the split has a hook, call its `processSplitWith` function.
if (split.hook != IJBSplitHook(address(0))) {
// Mint the tokens for the split hook.
// slither-disable-next-line reentrancy-events
TOKENS.mintFor(address(split.hook), projectId, splitAmount);

// Get a reference to the project token address. If the project doesn't have a token, this will
// return the 0 address.
IJBToken token = TOKENS.tokenOf(projectId);

// slither-disable-next-line reentrancy-events
split.hook.processSplitWith(
JBSplitHookContext({
token: address(token),
Expand Down Expand Up @@ -960,12 +967,15 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
// which accepts the token, send the tokens to the beneficiary.
if (address(token) == address(0) || address(terminal) == address(0)) {
// Mint the tokens to the beneficiary.
// slither-disable-next-line reentrancy-events
TOKENS.mintFor(beneficiary, projectId, splitAmount);
} else {
// Mint the tokens to this contract.
// slither-disable-next-line reentrancy-events
TOKENS.mintFor(address(this), projectId, splitAmount);

// Use the `projectId` in the pay metadata.
// slither-disable-next-line reentrancy-events
bytes memory metadata = bytes(abi.encodePacked(projectId));

// Try to fulfill the payment.
Expand All @@ -977,9 +987,10 @@ contract JBController is JBPermissioned, ERC2771Context, IJBController, IJBMigra
beneficiary: beneficiary,
metadata: metadata
}) {} catch (bytes memory reason) {
emit ReservedDistributionReverted(projectId, split, splitAmount, reason, _msgSender());

// If it fails, transfer the tokens from this contract to the beneficiary.
IERC20(address(token)).safeTransfer(beneficiary, splitAmount);
emit ReservedDistributionReverted(projectId, split, splitAmount, reason, _msgSender());
}
}
} else {
Expand Down
2 changes: 0 additions & 2 deletions src/JBDeadline.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ contract JBDeadline is IJBRulesetApprovalHook {
override
returns (JBApprovalStatus)
{
projectId; // Prevents unused var compiler and natspec complaints.

// The ruleset ID is the timestamp at which the ruleset was queued.
// If the provided `rulesetId` timestamp is after the start timestamp, the ruleset has `Failed`.
if (rulesetId > start) return JBApprovalStatus.Failed;
Expand Down
5 changes: 3 additions & 2 deletions src/JBDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ contract JBDirectory is JBPermissioned, Ownable, IJBDirectory {
IJBTerminal terminal = _terminalsOf[projectId][i];

// If the terminal accepts the specified token, return it.
// slither-disable-next-line calls-loop
if (terminal.accountingContextForTokenOf(projectId, token).token != address(0)) {
return terminal;
}
Expand Down Expand Up @@ -188,15 +189,15 @@ contract JBDirectory is JBPermissioned, Ownable, IJBDirectory {
// Set the new controller.
controllerOf[projectId] = controller;

emit SetController(projectId, controller, msg.sender);

// Migrate if needed.
if (
address(currentController) != address(0)
&& currentController.supportsInterface(type(IJBMigratable).interfaceId)
) {
IJBMigratable(address(currentController)).migrate(projectId, controller);
}

emit SetController(projectId, controller, msg.sender);
}

/// @notice Set a project's terminals.
Expand Down
2 changes: 2 additions & 0 deletions src/JBERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken {
//*********************************************************************//

/// @notice The token's name.
// slither-disable-next-line shadowing-state
string private _name;

/// @notice The token's symbol.
// slither-disable-next-line shadowing-state
string private _symbol;

//*********************************************************************//
Expand Down
Loading

0 comments on commit e097caf

Please sign in to comment.