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

magicdrop v1.0.1 #161

Merged
merged 36 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
cb5fe13
v1.0.1
wolfy-nft Dec 6, 2024
9cc42e2
fix tsets
wolfy-nft Dec 6, 2024
61e0357
cleanup
wolfy-nft Dec 6, 2024
467e139
update cli
wolfy-nft Dec 6, 2024
bf8450a
lint
wolfy-nft Dec 6, 2024
382b518
fmt
wolfy-nft Dec 6, 2024
c38a823
add setup lock
wolfy-nft Dec 9, 2024
99ff684
update copy
wolfy-nft Dec 9, 2024
0fd4dc3
move func
wolfy-nft Dec 9, 2024
20d3908
move error
wolfy-nft Dec 9, 2024
3fbb354
add test
wolfy-nft Dec 9, 2024
94a5d43
considate transfer logic
wolfy-nft Dec 13, 2024
617ed7c
transfer blocks and tests
wolfy-nft Dec 16, 2024
beff71f
fmt
wolfy-nft Dec 16, 2024
d628282
fix
wolfy-nft Dec 16, 2024
96be7a4
update comments
wolfy-nft Dec 16, 2024
ca19397
fix version names
wolfy-nft Dec 17, 2024
cf6abbc
add TransferAlreadySet check
wolfy-nft Dec 17, 2024
473a0e4
fix tests
wolfy-nft Dec 17, 2024
1138377
update
wolfy-nft Dec 18, 2024
3a82e18
remove upgradeability
wolfy-nft Dec 18, 2024
959eac4
add doc
wolfy-nft Dec 18, 2024
d927b09
update
wolfy-nft Dec 18, 2024
f06f41c
fmt
wolfy-nft Dec 18, 2024
afedbf4
add emmy
wolfy-nft Jan 7, 2025
035890e
add tests
wolfy-nft Jan 13, 2025
e3d313a
tests
wolfy-nft Jan 13, 2025
6352389
test
wolfy-nft Jan 13, 2025
4c2e6fa
add getConfig
wolfy-nft Jan 13, 2025
1bb6f08
add royalty and contracturi
wolfy-nft Jan 13, 2025
6130518
test getConfig
wolfy-nft Jan 13, 2025
6c7875c
add totalminted
wolfy-nft Jan 13, 2025
fd296cd
burn tests
wolfy-nft Jan 13, 2025
a0e576f
fmt
wolfy-nft Jan 13, 2025
a45bf7f
remoe cosigned mints on 1155
wolfy-nft Jan 17, 2025
26bd40a
fmt
wolfy-nft Jan 18, 2025
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
56 changes: 22 additions & 34 deletions cli/cmds/contract
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,9 @@ freeze_thaw_contract() {

set_chain
set_contract_address
set_token_standard

print_signer_with_balance $chain_id

if [ -z "$is_icreatortoken" ]; then
supports_icreatortoken
is_icreatortoken=$?
fi

if [ -z "$tf_address" ] && [ $is_icreatortoken -eq 0 ]; then
tf_address=$(get_transfer_validator_address $chain_id)
fi


choice=$(gum choose "Freeze" "Thaw")
if [ "$choice" == "Freeze" ]; then
freeze_contract
Expand All @@ -153,46 +142,39 @@ freeze_thaw_contract() {
freeze_contract() {
echo "Freezing contract... this will take a moment."

if [ "$token_standard" == "ERC1155" ]; then
output=$(cast send $contract_address "setTransferable(bool)" true $password --rpc-url "$RPC_URL" --json)
elif [ "$token_standard" == "ERC721" ] && [ $is_icreatortoken -eq 0 ]; then
freeze_level=8 # https://erc721c.com/docs/integration-guide/creator-token-standards/v3/for-creators/transfer-security
output=$(cast send $tf_address "setTransferSecurityLevelOfCollection(address,uint8,bool,bool,bool)" $contract_address 8 false false false $password --rpc-url "$RPC_URL" --json)
else
echo "Contract does not support freezing."
exit 1
fi
output=$(cast send $contract_address "setTransferable(bool)" false $password --rpc-url "$RPC_URL" --json)

print_transaction_hash $output
echo "Contract frozen."
echo "Token transfers frozen."
echo ""
}

thaw_contract() {
echo "Thawing contract... this will take a moment."

if [ "$token_standard" == "ERC1155" ]; then
output=$(cast send $contract_address "setTransferable(bool)" true $password --rpc-url "$RPC_URL" --json)
elif [ "$token_standard" == "ERC721" ] && [ $is_icreatortoken -eq 0 ]; then
# level 3 is the default level of Magic Eden, which offers whitelisting and OTC trading
thaw_level=3 # https://erc721c.com/docs/integration-guide/creator-token-standards/v3/for-creators/transfer-security
output=$(cast send $tf_address "setTransferSecurityLevelOfCollection(address,uint8,bool,bool,bool)" $contract_address 3 false false false $password --rpc-url "$RPC_URL" --json)
else
echo "Contract does not support thawing."
exit 1
fi
output=$(cast send $contract_address "setTransferable(bool)" true $password --rpc-url "$RPC_URL" --json)

print_transaction_hash $output
echo "Contract thawed."
echo "Token transfers thawed."
echo ""
}

check_setup_locked() {
setup_locked=$(cast call $contract_address "isSetupLocked()" --rpc-url "$RPC_URL" $password)
if [ "$setup_locked" == "$TRUE_HEX" ]; then
echo "This contract has already been setup. Please use other commands from the 'Manage Contracts' menu to update the contract."
exit 1
fi
}

setup_contract() {
clear
trap "echo 'Exiting...'; exit 1" SIGINT

title="Setup an existing collection"

check_setup_locked

set_chain
set_contract_address
set_token_standard
Expand All @@ -201,7 +183,11 @@ setup_contract() {
if [ "$token_standard" == "ERC1155" ]; then
set_number_of_1155_tokens
set_1155_uri
else
token_uri_suffix=
base_uri=
wolfy-nft marked this conversation as resolved.
Show resolved Hide resolved
elif [ "$token_standard" == "ERC721" ]; then
set_base_uri
set_token_uri_suffix
uri=
fi

Expand All @@ -226,7 +212,7 @@ setup_contract() {
if [ "$token_standard" == "ERC1155" ]; then
setup_selector="setup(string,uint256[],uint256[],address,address,(uint80[],uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[],address,uint96)"
elif [ "$token_standard" == "ERC721" ]; then
setup_selector="setup(uint256,uint256,address,address,(uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
setup_selector="setup(string,string,uint256,uint256,address,address,(uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
else
echo "Unknown token standard"
exit 1
Expand All @@ -237,6 +223,8 @@ setup_contract() {
output=$(cast send $contract_address \
"$setup_selector" \
$uri \
$base_uri \
$token_uri_suffix \
"$max_mintable_supply" \
"$global_wallet_limit" \
"$mint_currency" \
Expand Down
12 changes: 7 additions & 5 deletions cli/cmds/getters
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

MAGIC_EDEN_DEFAULT_LIST_ID="1"
# We use list 3 for Polygon because list 1 was already taken.
MAGIC_EDEN_POLYGON_LIST_ID="3"


get_numeric_input() {
local prompt="$1"
local input
Expand Down Expand Up @@ -91,14 +96,11 @@ get_transfer_validator_address() {
get_transfer_validator_list_id() {
local network="$1"
case $network in
"33139"|"42161"|"8453"|"1")
echo "1"
;;
"137")
echo "3"
echo $MAGIC_EDEN_POLYGON_LIST_ID
;;
*)
echo "0" # default list id
echo $MAGIC_EDEN_DEFAULT_LIST_ID
;;
esac
}
Expand Down
4 changes: 4 additions & 0 deletions contracts/common/ErrorsAndEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ interface ErrorsAndEvents {
error NewSupplyLessThanTotalSupply();
error NotTransferable();
error InitialOwnerCannotBeZero();
error ContractAlreadySetup();
error TransferableAlreadySet();

event SetMintable(bool mintable);
event SetTransferable(bool transferable);
event SetActiveStage(uint256 activeStage);
event SetBaseURI(string baseURI);
event SetTokenURISuffix(string suffix);
Expand All @@ -34,4 +37,5 @@ interface ErrorsAndEvents {
event WithdrawERC20(address mintCurrency, uint256 value);
event DefaultRoyaltySet(address indexed receiver, uint96 feeNumerator);
event TokenRoyaltySet(uint256 indexed tokenId, address indexed receiver, uint96 feeNumerator);
event ContractURIUpdated();
}
22 changes: 22 additions & 0 deletions contracts/common/Structs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,25 @@ struct MintStageInfo1155 {
uint256 startTimeUnixSeconds;
uint256 endTimeUnixSeconds;
}

struct SetupConfig {
/// @dev The maximum number of tokens that can be minted.
/// - Can be decreased if current supply < new max supply
/// - Cannot be increased once set
uint256 maxSupply;
/// @dev The maximum number of tokens that can be minted per wallet
/// @notice A value of 0 indicates unlimited mints per wallet
uint256 walletLimit;
/// @dev The base URI of the token.
string baseURI;
/// @dev The contract URI of the token.
string contractURI;
/// @dev The mint stages of the token.
MintStageInfo[] stages;
/// @dev The payout recipient of the token.
address payoutRecipient;
/// @dev The royalty recipient of the token.
address royaltyRecipient;
/// @dev The royalty basis points of the token.
uint96 royaltyBps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
pragma solidity ^0.8.22;

import "@limitbreak/creator-token-standards/src/utils/CreatorTokenBase.sol";
import "erc721a-upgradeable/contracts/extensions/ERC721AQueryableUpgradeable.sol";
import "@limitbreak/creator-token-standards/src/utils/AutomaticValidatorTransferApproval.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

/**
* @title ERC721ACQueryableInitializable
* @dev This contract is not meant for use in Upgradeable Proxy contracts though it may base on Upgradeable contract. The purpose of this
* contract is for use with EIP-1167 Minimal Proxies (Clones).
*/
import {ERC721A, IERC721A} from "erc721a/contracts/ERC721A.sol";

import "contracts/nft/erc721m/clones/ERC721AConduitPreapprovedCloneable.sol";

/// @title ERC721ACQueryableInitializable
/// @notice An ERC721AC extension with queryable and initialization features.
/// @dev The purpose of this contract is for use with EIP-1167 Minimal Proxies (Clones).
abstract contract ERC721ACQueryableInitializable is
ERC721AQueryableUpgradeable,
ERC721AConduitPreapprovedCloneable,
CreatorTokenBase,
AutomaticValidatorTransferApproval,
Initializable
AutomaticValidatorTransferApproval
{
/// @notice Initializes the contract with the given name and symbol.
function __ERC721ACQueryableInitializable_init(string memory name_, string memory symbol_) public {
__ERC721A_init_unchained(name_, symbol_);
__ERC721AQueryable_init_unchained();
__ERC721ACloneable__init(name_, symbol_);

_emitDefaultTransferValidator();
_registerTokenType(getTransferValidator());
Expand All @@ -31,7 +29,7 @@ abstract contract ERC721ACQueryableInitializable is
public
view
virtual
override(ERC721AUpgradeable, IERC721AUpgradeable)
override(ERC721ACloneable, IERC721A)
returns (bool)
{
return interfaceId == type(ICreatorToken).interfaceId || interfaceId == type(ICreatorTokenLegacy).interfaceId
Expand All @@ -47,13 +45,7 @@ abstract contract ERC721ACQueryableInitializable is

/// @notice Overrides behavior of isApprovedFor all such that if an operator is not explicitly approved
/// @notice for all, the contract owner can optionally auto-approve the 721-C transfer validator for transfers.
function isApprovedForAll(address owner, address operator)
public
view
virtual
override(ERC721AUpgradeable, IERC721AUpgradeable)
returns (bool isApproved)
{
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool isApproved) {
isApproved = super.isApprovedForAll(owner, operator);

if (!isApproved) {
Expand Down Expand Up @@ -91,6 +83,10 @@ abstract contract ERC721ACQueryableInitializable is
}
}

function totalMinted() public view returns (uint256) {
return _totalMinted();
}

function _msgSenderERC721A() internal view virtual override returns (address) {
return _msgSender();
}
Expand Down
Loading
Loading