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 16 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
2 changes: 2 additions & 0 deletions contracts/common/ErrorsAndEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ interface ErrorsAndEvents {
error NewSupplyLessThanTotalSupply();
error NotTransferable();
error InitialOwnerCannotBeZero();
error ContractAlreadySetup();

event SetMintable(bool mintable);
event SetTransferable(bool transferable);
event SetActiveStage(uint256 activeStage);
event SetBaseURI(string baseURI);
event SetTokenURISuffix(string suffix);
Expand Down
1 change: 0 additions & 1 deletion contracts/nft/erc1155m/ERC1155MErrorsAndEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ interface ERC1155MErrorsAndEvents is ErrorsAndEvents {
);
event SetMaxMintableSupply(uint256 indexed tokenId, uint256 maxMintableSupply);
event SetGlobalWalletLimit(uint256 indexed tokenId, uint256 globalWalletLimit);
event SetTransferable(bool transferable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {ERC1155MStorage} from "./ERC1155MStorage.sol";
import {Cosignable} from "../../common/Cosignable.sol";
import {AuthorizedMinterControl} from "../../common/AuthorizedMinterControl.sol";

/// @title ERC1155MInitializableV1_0_0
/// @title ERC1155MInitializableV1_0_1
/// @notice An initializable ERC1155 contract with multi-stage minting, royalties, and authorized minters
/// @dev Implements ERC1155, ERC2981, Ownable, ReentrancyGuard, and custom minting logic
contract ERC1155MInitializableV1_0_0 is
contract ERC1155MInitializableV1_0_1 is
wolfy-nft marked this conversation as resolved.
Show resolved Hide resolved
IERC1155M,
ERC1155SupplyUpgradeable,
wolfy-nft marked this conversation as resolved.
Show resolved Hide resolved
Ownable,
Expand Down Expand Up @@ -62,7 +62,7 @@ contract ERC1155MInitializableV1_0_0 is
/// @notice Returns the contract name and version
/// @return The contract name and version as strings
function contractNameAndVersion() public pure returns (string memory, string memory) {
return ("ERC1155MInitializable", "1.0.0");
return ("ERC1155MInitializable", "1.0.1");
}

/*==============================================================
Expand Down Expand Up @@ -196,6 +196,18 @@ contract ERC1155MInitializableV1_0_0 is
return totalMinted;
}

/// @notice Checks if the contract is setup locked
/// @return Whether the contract is setup locked
function isSetupLocked() external view returns (bool) {
return _setupLocked;
}

/// @notice Checks if the contract is transferable
/// @return Whether the contract is transferable
function isTransferable() public view returns (bool) {
return _transferable;
}

/// @notice Checks if the contract supports a given interface
/// @param interfaceId The interface identifier
/// @return True if the contract supports the interface, false otherwise
Expand Down Expand Up @@ -232,6 +244,10 @@ contract ERC1155MInitializableV1_0_0 is
address royaltyReceiver,
uint96 royaltyFeeNumerator
) external onlyOwner {
if (_setupLocked) {
revert ContractAlreadySetup();
}

if (maxMintableSupply.length != globalWalletLimit.length) {
revert InvalidLimitArgsLength();
}
Expand All @@ -242,6 +258,7 @@ contract ERC1155MInitializableV1_0_0 is
}
}

_setupLocked = true;
_numTokens = globalWalletLimit.length;
_maxMintableSupply = maxMintableSupply;
_globalWalletLimit = globalWalletLimit;
Expand Down Expand Up @@ -581,14 +598,15 @@ contract ERC1155MInitializableV1_0_0 is
uint256[] memory amounts,
bytes memory data
) internal virtual override {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

bool fromZeroAddress = from == address(0);
bool toZeroAddress = to == address(0);

// If the transfer is not from a mint or burn, revert if not transferable
if (!fromZeroAddress && !toZeroAddress && !_transferable) {
revert NotTransferable();
}

ERC1155SupplyUpgradeable._beforeTokenTransfer(operator, from, to, ids, amounts, data);
wolfy-nft marked this conversation as resolved.
Show resolved Hide resolved
}

/// @dev Overriden to prevent double-initialization of the owner.
Expand Down
33 changes: 28 additions & 5 deletions contracts/nft/erc1155m/ERC1155MStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,42 @@ pragma solidity ^0.8.22;
import {MintStageInfo1155} from "../../common/Structs.sol";

contract ERC1155MStorage {
// Mint stage information. See MintStageInfo for details.
// Mint stage information. See MintStageInfo1155 for details.
MintStageInfo1155[] internal _mintStages;

// The name of the token
string public name;

// The symbol of the token
string public symbol;
bool internal _transferable; // Whether the token can be transferred.
uint256[] internal _maxMintableSupply; // The total mintable supply per token.
uint256[] internal _globalWalletLimit; // Global wallet limit, across all stages, per token.

// Whether the token can be transferred.
bool internal _transferable;

// The total mintable supply per token.
uint256[] internal _maxMintableSupply;

// Global wallet limit, across all stages, per token.
uint256[] internal _globalWalletLimit;

// Total mint fee
uint256 internal _totalMintFee;
address internal _mintCurrency; // If 0 address, use native currency.

// Address of ERC-20 token used to pay for minting. If 0 address, use native currency.
address internal _mintCurrency;

// Number of tokens
uint256 internal _numTokens;

// Fund receiver
address internal _fundReceiver;

// Whether the contract has been setup.
bool internal _setupLocked;

// Minted count per stage per token per wallet.
mapping(uint256 => mapping(uint256 => mapping(address => uint32))) internal _stageMintedCountsPerTokenPerWallet;

// Minted count per stage per token.
mapping(uint256 => mapping(uint256 => uint256)) internal _stageMintedCountsPerToken;
}
Loading
Loading