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/syn14 #196

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 19 additions & 1 deletion src/JBERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ import {IJBToken} from "./interfaces/IJBToken.sol";
/// `JBController.deployERC20For(...)` or `JBController.setTokenFor(...)`, credits can be redeemed to claim tokens.
/// @dev `JBController.deployERC20For(...)` deploys a `JBERC20` contract and sets it as the project's token.
contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken {
//*********************************************************************//
// ---------------- public immutable stored properties --------------- //
//*********************************************************************//

/// @notice The project ID.
uint256 public immutable override projectId;

//*********************************************************************//
// --------------------- internal stored properties ------------------ //
//*********************************************************************//
Expand Down Expand Up @@ -92,14 +99,25 @@ contract JBERC20 is ERC20Votes, ERC20Permit, Ownable, IJBToken {
/// @notice Initializes the token.
/// @param name_ The token's name.
/// @param symbol_ The token's symbol.
/// @param projectId_ The project ID.
/// @param owner The token contract's owner.
function initialize(string memory name_, string memory symbol_, address owner) public override {
function initialize(
string memory name_,
string memory symbol_,
uint256 projectId_,
address owner
)
public
override
{
// Prevent re-initialization by reverting if a name is already set or if the provided name is empty.
if (bytes(_name).length != 0 || bytes(name_).length == 0) revert();

_name = name_;
_symbol = symbol_;

projectId = projectId_;

// Transfer ownership to the owner.
_transferOwnership(owner);
}
Expand Down
4 changes: 4 additions & 0 deletions src/JBTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ contract JBTokens is JBControlled, IJBTokens {
error JBTokens_InsufficientTokensToBurn(uint256 count, uint256 tokenBalance);
error JBTokens_OverflowAlert(uint256 value, uint256 limit);
error JBTokens_ProjectAlreadyHasToken(IJBToken token);
error JBTokens_TokenProjectIdMismatch(uint256 tokenProjectId, uint256 projectId);
error JBTokens_RecipientZeroAddress();
error JBTokens_TokenAlreadyBeingUsed(uint256 projectId);
error JBTokens_TokenNotFound();
Expand Down Expand Up @@ -317,6 +318,9 @@ contract JBTokens is JBControlled, IJBTokens {
// Can't set to the zero address.
if (token == IJBToken(address(0))) revert JBTokens_EmptyToken();

// The token's project ID must match the project ID.
if (token.projectId() != projectId) revert JBTokens_TokenProjectIdMismatch(token.projectId(), projectId);

// Can't set a token if the project is already associated with another token.
if (tokenOf[projectId] != IJBToken(address(0))) revert JBTokens_ProjectAlreadyHasToken(tokenOf[projectId]);

Expand Down
1 change: 1 addition & 0 deletions src/interfaces/IJBToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.0;
interface IJBToken {
function balanceOf(address account) external view returns (uint256);
function decimals() external view returns (uint8);
function projectId() external view returns (uint256);
function totalSupply() external view returns (uint256);

function initialize(string memory name, string memory symbol, address owner) external;
Expand Down
Loading