Skip to content

Commit 877baff

Browse files
authored
magicdrop v1.0.1 (#161)
* v1.0.1 Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fix tsets Signed-off-by: Adam Wolf <wolfynft@gmail.com> * cleanup Signed-off-by: Adam Wolf <wolfynft@gmail.com> * update cli Signed-off-by: Adam Wolf <wolfynft@gmail.com> * lint Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fmt Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add setup lock Signed-off-by: Adam Wolf <wolfynft@gmail.com> * update copy Signed-off-by: Adam Wolf <wolfynft@gmail.com> * move func Signed-off-by: Adam Wolf <wolfynft@gmail.com> * move error Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add test Signed-off-by: Adam Wolf <wolfynft@gmail.com> * considate transfer logic Signed-off-by: Adam Wolf <wolfynft@gmail.com> * transfer blocks and tests Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fmt Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fix Signed-off-by: Adam Wolf <wolfynft@gmail.com> * update comments Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fix version names Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add TransferAlreadySet check Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fix tests Signed-off-by: Adam Wolf <wolfynft@gmail.com> * update Signed-off-by: Adam Wolf <wolfynft@gmail.com> * remove upgradeability Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add doc Signed-off-by: Adam Wolf <wolfynft@gmail.com> * update Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fmt Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add emmy Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add tests Signed-off-by: Adam Wolf <wolfynft@gmail.com> * tests Signed-off-by: Adam Wolf <wolfynft@gmail.com> * test Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add getConfig Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add royalty and contracturi Signed-off-by: Adam Wolf <wolfynft@gmail.com> * test getConfig Signed-off-by: Adam Wolf <wolfynft@gmail.com> * add totalminted Signed-off-by: Adam Wolf <wolfynft@gmail.com> * burn tests Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fmt Signed-off-by: Adam Wolf <wolfynft@gmail.com> * remoe cosigned mints on 1155 Signed-off-by: Adam Wolf <wolfynft@gmail.com> * fmt Signed-off-by: Adam Wolf <wolfynft@gmail.com> --------- Signed-off-by: Adam Wolf <wolfynft@gmail.com>
1 parent 82eb1bf commit 877baff

25 files changed

+2806
-716
lines changed

cli/cmds/contract

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,9 @@ freeze_thaw_contract() {
128128

129129
set_chain
130130
set_contract_address
131-
set_token_standard
132131

133132
print_signer_with_balance $chain_id
134133

135-
if [ -z "$is_icreatortoken" ]; then
136-
supports_icreatortoken
137-
is_icreatortoken=$?
138-
fi
139-
140-
if [ -z "$tf_address" ] && [ $is_icreatortoken -eq 0 ]; then
141-
tf_address=$(get_transfer_validator_address $chain_id)
142-
fi
143-
144-
145134
choice=$(gum choose "Freeze" "Thaw")
146135
if [ "$choice" == "Freeze" ]; then
147136
freeze_contract
@@ -153,46 +142,39 @@ freeze_thaw_contract() {
153142
freeze_contract() {
154143
echo "Freezing contract... this will take a moment."
155144

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

166147
print_transaction_hash $output
167-
echo "Contract frozen."
148+
echo "Token transfers frozen."
168149
echo ""
169150
}
170151

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

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

185157
print_transaction_hash $output
186-
echo "Contract thawed."
158+
echo "Token transfers thawed."
187159
echo ""
188160
}
189161

162+
check_setup_locked() {
163+
setup_locked=$(cast call $contract_address "isSetupLocked()" --rpc-url "$RPC_URL" $password)
164+
if [ "$setup_locked" == "$TRUE_HEX" ]; then
165+
echo "This contract has already been setup. Please use other commands from the 'Manage Contracts' menu to update the contract."
166+
exit 1
167+
fi
168+
}
169+
190170
setup_contract() {
191171
clear
192172
trap "echo 'Exiting...'; exit 1" SIGINT
193173

194174
title="Setup an existing collection"
195175

176+
check_setup_locked
177+
196178
set_chain
197179
set_contract_address
198180
set_token_standard
@@ -201,7 +183,11 @@ setup_contract() {
201183
if [ "$token_standard" == "ERC1155" ]; then
202184
set_number_of_1155_tokens
203185
set_1155_uri
204-
else
186+
token_uri_suffix=
187+
base_uri=
188+
elif [ "$token_standard" == "ERC721" ]; then
189+
set_base_uri
190+
set_token_uri_suffix
205191
uri=
206192
fi
207193

@@ -226,7 +212,7 @@ setup_contract() {
226212
if [ "$token_standard" == "ERC1155" ]; then
227213
setup_selector="setup(string,uint256[],uint256[],address,address,(uint80[],uint80[],uint32[],bytes32[],uint24[],uint256,uint256)[],address,uint96)"
228214
elif [ "$token_standard" == "ERC721" ]; then
229-
setup_selector="setup(uint256,uint256,address,address,(uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
215+
setup_selector="setup(string,string,uint256,uint256,address,address,(uint80,uint80,uint32,bytes32,uint24,uint256,uint256)[],address,uint96)"
230216
else
231217
echo "Unknown token standard"
232218
exit 1
@@ -237,6 +223,8 @@ setup_contract() {
237223
output=$(cast send $contract_address \
238224
"$setup_selector" \
239225
$uri \
226+
$base_uri \
227+
$token_uri_suffix \
240228
"$max_mintable_supply" \
241229
"$global_wallet_limit" \
242230
"$mint_currency" \

cli/cmds/getters

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bash
22

3+
MAGIC_EDEN_DEFAULT_LIST_ID="1"
4+
# We use list 3 for Polygon because list 1 was already taken.
5+
MAGIC_EDEN_POLYGON_LIST_ID="3"
6+
7+
38
get_numeric_input() {
49
local prompt="$1"
510
local input
@@ -91,14 +96,11 @@ get_transfer_validator_address() {
9196
get_transfer_validator_list_id() {
9297
local network="$1"
9398
case $network in
94-
"33139"|"42161"|"8453"|"1")
95-
echo "1"
96-
;;
9799
"137")
98-
echo "3"
100+
echo $MAGIC_EDEN_POLYGON_LIST_ID
99101
;;
100102
*)
101-
echo "0" # default list id
103+
echo $MAGIC_EDEN_DEFAULT_LIST_ID
102104
;;
103105
esac
104106
}

contracts/common/ErrorsAndEvents.sol

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ interface ErrorsAndEvents {
2424
error NewSupplyLessThanTotalSupply();
2525
error NotTransferable();
2626
error InitialOwnerCannotBeZero();
27+
error ContractAlreadySetup();
28+
error TransferableAlreadySet();
2729

2830
event SetMintable(bool mintable);
31+
event SetTransferable(bool transferable);
2932
event SetActiveStage(uint256 activeStage);
3033
event SetBaseURI(string baseURI);
3134
event SetTokenURISuffix(string suffix);
@@ -34,4 +37,5 @@ interface ErrorsAndEvents {
3437
event WithdrawERC20(address mintCurrency, uint256 value);
3538
event DefaultRoyaltySet(address indexed receiver, uint96 feeNumerator);
3639
event TokenRoyaltySet(uint256 indexed tokenId, address indexed receiver, uint96 feeNumerator);
40+
event ContractURIUpdated();
3741
}

contracts/common/Structs.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,25 @@ struct MintStageInfo1155 {
2626
uint256 startTimeUnixSeconds;
2727
uint256 endTimeUnixSeconds;
2828
}
29+
30+
struct SetupConfig {
31+
/// @dev The maximum number of tokens that can be minted.
32+
/// - Can be decreased if current supply < new max supply
33+
/// - Cannot be increased once set
34+
uint256 maxSupply;
35+
/// @dev The maximum number of tokens that can be minted per wallet
36+
/// @notice A value of 0 indicates unlimited mints per wallet
37+
uint256 walletLimit;
38+
/// @dev The base URI of the token.
39+
string baseURI;
40+
/// @dev The contract URI of the token.
41+
string contractURI;
42+
/// @dev The mint stages of the token.
43+
MintStageInfo[] stages;
44+
/// @dev The payout recipient of the token.
45+
address payoutRecipient;
46+
/// @dev The royalty recipient of the token.
47+
address royaltyRecipient;
48+
/// @dev The royalty basis points of the token.
49+
uint96 royaltyBps;
50+
}

contracts/nft/creator-token-standards/ERC721ACQueryableInitializable.sol

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@
22
pragma solidity ^0.8.22;
33

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

9-
/**
10-
* @title ERC721ACQueryableInitializable
11-
* @dev This contract is not meant for use in Upgradeable Proxy contracts though it may base on Upgradeable contract. The purpose of this
12-
* contract is for use with EIP-1167 Minimal Proxies (Clones).
13-
*/
7+
import {ERC721A, IERC721A} from "erc721a/contracts/ERC721A.sol";
8+
9+
import "contracts/nft/erc721m/clones/ERC721AConduitPreapprovedCloneable.sol";
10+
11+
/// @title ERC721ACQueryableInitializable
12+
/// @notice An ERC721AC extension with queryable and initialization features.
13+
/// @dev The purpose of this contract is for use with EIP-1167 Minimal Proxies (Clones).
1414
abstract contract ERC721ACQueryableInitializable is
15-
ERC721AQueryableUpgradeable,
15+
ERC721AConduitPreapprovedCloneable,
1616
CreatorTokenBase,
17-
AutomaticValidatorTransferApproval,
18-
Initializable
17+
AutomaticValidatorTransferApproval
1918
{
2019
/// @notice Initializes the contract with the given name and symbol.
2120
function __ERC721ACQueryableInitializable_init(string memory name_, string memory symbol_) public {
22-
__ERC721A_init_unchained(name_, symbol_);
23-
__ERC721AQueryable_init_unchained();
21+
__ERC721ACloneable__init(name_, symbol_);
2422

2523
_emitDefaultTransferValidator();
2624
_registerTokenType(getTransferValidator());
@@ -31,7 +29,7 @@ abstract contract ERC721ACQueryableInitializable is
3129
public
3230
view
3331
virtual
34-
override(ERC721AUpgradeable, IERC721AUpgradeable)
32+
override(ERC721ACloneable, IERC721A)
3533
returns (bool)
3634
{
3735
return interfaceId == type(ICreatorToken).interfaceId || interfaceId == type(ICreatorTokenLegacy).interfaceId
@@ -47,13 +45,7 @@ abstract contract ERC721ACQueryableInitializable is
4745

4846
/// @notice Overrides behavior of isApprovedFor all such that if an operator is not explicitly approved
4947
/// @notice for all, the contract owner can optionally auto-approve the 721-C transfer validator for transfers.
50-
function isApprovedForAll(address owner, address operator)
51-
public
52-
view
53-
virtual
54-
override(ERC721AUpgradeable, IERC721AUpgradeable)
55-
returns (bool isApproved)
56-
{
48+
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool isApproved) {
5749
isApproved = super.isApprovedForAll(owner, operator);
5850

5951
if (!isApproved) {
@@ -91,6 +83,10 @@ abstract contract ERC721ACQueryableInitializable is
9183
}
9284
}
9385

86+
function totalMinted() public view returns (uint256) {
87+
return _totalMinted();
88+
}
89+
9490
function _msgSenderERC721A() internal view virtual override returns (address) {
9591
return _msgSender();
9692
}

0 commit comments

Comments
 (0)