-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,713 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = false | ||
max_line_length = 120 | ||
|
||
[*.sol] | ||
indent_size = 4 | ||
|
||
[*.{js,ts}] | ||
indent_size = 2 | ||
|
||
[*.{adoc,md}] | ||
max_line_length = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,3 +128,10 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
|
||
# foundry args | ||
args | ||
|
||
# foundry cache | ||
forge-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
build | ||
coverage | ||
out | ||
/lib | ||
assets | ||
node_modules | ||
.next | ||
.idea | ||
.github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"plugins": ["prettier-plugin-solidity"], | ||
"useTabs": false, | ||
"printWidth": 120, | ||
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"semi": false, | ||
"singleQuote": false, | ||
"bracketSpacing": true, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.js"], | ||
"options": { | ||
"tabWidth": 2 | ||
} | ||
}, | ||
{ | ||
"files": "*.sol", | ||
"options": { | ||
"singleQuote": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"code-complexity": ["error", 8], | ||
"compiler-version": ["error", ">=0.8.23"], | ||
"const-name-snakecase": "off", | ||
"no-empty-blocks": "off", | ||
"constructor-syntax": "error", | ||
"func-visibility": ["error", { "ignoreConstructors": true }], | ||
"max-line-length": ["error", 120], | ||
"not-rely-on-time": "off", | ||
"reason-string": ["warn", { "maxLength": 64 }], | ||
"no-unused-import": "error", | ||
"no-unused-vars": "off", | ||
"no-inline-assembly": "off", | ||
"avoid-low-level-calls": "off", | ||
"no-global-import": "error", | ||
"prettier/prettier": "error", | ||
"private-vars-leading-underscore": "off", | ||
"func-name-mixedcase": "off", | ||
"var-name-mixedcase": "off", | ||
"modifier-name-mixedcase": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"solidity.compileUsingRemoteVersion": "v0.8.26+commit.8a97fa7a" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
-include .env | ||
|
||
.PHONY: all test clean | ||
|
||
all: clean install build | ||
|
||
clean :; yarn cache clean | ||
|
||
install :; yarn install | ||
|
||
update :; forge update | ||
|
||
build :; forge build | ||
|
||
test :; forge test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.23; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; | ||
|
||
contract AccessControl { | ||
using SafeERC20 for IERC20; | ||
|
||
address payable public owner; | ||
mapping(address => bool) public operators; | ||
|
||
event SetOperator(address indexed add, bool value); | ||
|
||
error OnlyOwnerAllowed(); | ||
error OnlyOperatorAllowed(); | ||
error ZeroAddressNotAllowed(); | ||
|
||
constructor(address _ownerAddress) { | ||
owner = payable(_ownerAddress); | ||
} | ||
|
||
modifier onlyOwner() { | ||
if (msg.sender != owner) { | ||
revert OnlyOwnerAllowed(); | ||
} | ||
_; | ||
} | ||
|
||
modifier onlyOperator() { | ||
if (!operators[msg.sender]) { | ||
revert OnlyOperatorAllowed(); | ||
} | ||
_; | ||
} | ||
|
||
function setOwner(address payable _newOwner) external onlyOwner { | ||
if (_newOwner == address(0)) { | ||
revert ZeroAddressNotAllowed(); | ||
} | ||
owner = _newOwner; | ||
} | ||
|
||
function setOperator(address _operator, bool _v) external onlyOwner { | ||
operators[_operator] = _v; | ||
emit SetOperator(_operator, _v); | ||
} | ||
|
||
function emergencyWithdraw(address _token, address payable _to, uint256 amount) external onlyOwner { | ||
if (_token == address(0x0)) { | ||
amount = amount != 0 ? amount : address(this).balance; | ||
payable(_to).transfer(amount); | ||
} | ||
else { | ||
amount = amount != 0 ? amount : IERC20(_token).balanceOf(address(this)); | ||
IERC20(_token).safeTransfer(_to, amount); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.23; | ||
|
||
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; | ||
|
||
contract MockERC721 is ERC721 { | ||
uint256 private _counter; | ||
|
||
constructor(string memory name) ERC721(name, name) { | ||
_counter = 0; | ||
} | ||
|
||
function mint(address to) public returns (uint256 tokenId) { | ||
tokenId = ++_counter; | ||
_safeMint(to, tokenId); | ||
return tokenId; | ||
} | ||
|
||
function mintId(address to, uint256 tokenId) public returns (uint256) { | ||
_safeMint(to, tokenId); | ||
return tokenId; | ||
} | ||
|
||
function burn(uint256 tokenId) public { | ||
_burn(tokenId); | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 tokenId) public override { | ||
_transfer(from, to, tokenId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import { IERC721Metadata } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; | ||
import { IERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; | ||
|
||
|
||
interface ILaunchpadNFT is IERC721Metadata, IERC721Enumerable { | ||
|
||
struct LaunchpadTokenMetadata { | ||
address licensorIpId; | ||
address licenseTemplate; | ||
uint256 licenseTermsId; | ||
bool transferable; | ||
} | ||
|
||
event LaunchpadNFTMinted(address indexed minter, address indexed receiver, uint256 indexed tokenId); | ||
|
||
function mintTokens(address _receiver, | ||
uint256 _amount // mint amount | ||
) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol"; | ||
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | ||
import {IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; | ||
|
||
interface ISPGNFT is IAccessControl, IERC721, IERC721Metadata { | ||
/// @dev Initializes the NFT collection. | ||
/// @dev If mint cost is non-zero, mint token must be set. | ||
/// @param name The name of the collection. | ||
/// @param symbol The symbol of the collection. | ||
/// @param maxSupply The maximum supply of the collection. | ||
/// @param mintFee The cost to mint an NFT from the collection. | ||
/// @param mintFeeToken The token to pay for minting. | ||
/// @param owner The owner of the collection. | ||
function initialize( | ||
string memory name, | ||
string memory symbol, | ||
uint32 maxSupply, | ||
uint256 mintFee, | ||
address mintFeeToken, | ||
address owner | ||
) external; | ||
|
||
/// @notice Returns the total minted supply of the collection. | ||
function totalSupply() external view returns (uint256); | ||
|
||
/// @notice Returns the current mint token of the collection. | ||
function mintFeeToken() external view returns (address); | ||
|
||
/// @notice Returns the current mint fee of the collection. | ||
function mintFee() external view returns (uint256); | ||
|
||
/// @notice Sets the mint token for the collection. | ||
/// @dev Only callable by the admin role. | ||
/// @param token The new mint token for mint payment. | ||
function setMintFeeToken(address token) external; | ||
|
||
/// @notice Sets the fee to mint an NFT from the collection. Payment is in the designated currency. | ||
/// @dev Only callable by the admin role. | ||
/// @param fee The new mint fee paid in the mint token. | ||
function setMintFee(uint256 fee) external; | ||
|
||
/// @notice Mints an NFT from the collection. Only callable by the minter role. | ||
/// @param to The address of the recipient of the minted NFT. | ||
/// @param nftMetadataURI OPTIONAL. The desired metadata for the newly minted NFT. | ||
/// @return tokenId The ID of the minted NFT. | ||
function mint( | ||
address to, | ||
string calldata nftMetadataURI | ||
) external returns (uint256 tokenId); | ||
|
||
/// @notice Mints an NFT from the collection. Only callable by the SPG. | ||
/// @param to The address of the recipient of the minted NFT. | ||
/// @param payer The address of the payer for the mint fee. | ||
/// @param nftMetadataURI OPTIONAL. The desired metadata for the newly minted NFT. | ||
/// @return tokenId The ID of the minted NFT. | ||
function mintBySPG( | ||
address to, | ||
address payer, | ||
string calldata nftMetadataURI | ||
) external returns (uint256 tokenId); | ||
|
||
/// @dev Withdraws the contract's token balance to the recipient. | ||
/// @param recipient The token to withdraw. | ||
/// @param recipient The address to receive the withdrawn balance. | ||
function withdrawToken(address token, address recipient) external; | ||
} |
Oops, something went wrong.