Update community solidity contracts (#4166)

This commit is contained in:
Cuteivist 2023-10-19 08:17:54 +02:00 committed by GitHub
parent 831feb3dcd
commit 9b44cf65ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -27,11 +27,14 @@ contract CommunityERC20 is Context, Ownable, ERC20, CommunityOwnable {
uint8 private immutable customDecimals;
string public baseTokenURI;
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals,
uint256 _maxSupply,
string memory _baseTokenURI,
address _ownerToken,
address _masterToken
)
@ -40,6 +43,7 @@ contract CommunityERC20 is Context, Ownable, ERC20, CommunityOwnable {
{
maxSupply = _maxSupply;
customDecimals = _decimals;
baseTokenURI = _baseTokenURI;
}
// Events

View File

@ -0,0 +1,33 @@
// SPDX-License-Identifier: Mozilla Public License 2.0
pragma solidity ^0.8.17;
import { IERC721 } from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
contract CommunityOwnable {
error CommunityOwnable_InvalidTokenAddress();
error CommunityOwnable_NotAuthorized();
address public immutable ownerToken;
address public immutable masterToken;
constructor(address _ownerToken, address _masterToken) {
ownerToken = _ownerToken;
masterToken = _masterToken;
if (ownerToken == address(0) && masterToken == address(0)) {
revert CommunityOwnable_InvalidTokenAddress();
}
}
/// @dev Reverts if the msg.sender does not possess either an OwnerToken or a MasterToken.
modifier onlyCommunityOwnerOrTokenMaster() {
if (
(ownerToken != address(0) && IERC721(ownerToken).balanceOf(msg.sender) == 0)
&& (masterToken != address(0) && IERC721(masterToken).balanceOf(msg.sender) == 0)
) {
revert CommunityOwnable_NotAuthorized();
}
_;
}
}

View File

@ -306,6 +306,7 @@ func (api *API) DeployAssets(ctx context.Context, chainID uint64, deploymentPara
const decimals = 18
address, tx, _, err := assets.DeployAssets(transactOpts, ethClient, deploymentParameters.Name,
deploymentParameters.Symbol, decimals, deploymentParameters.GetSupply(),
deploymentParameters.TokenURI,
common.HexToAddress(deploymentParameters.OwnerTokenAddress),
common.HexToAddress(deploymentParameters.MasterTokenAddress))
if err != nil {