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 refactor and contract factory #152

Merged
merged 147 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
a58852b
chore: forge init
wolfy-nft Sep 19, 2024
5cc74a3
forge install: forge-std
wolfy-nft Sep 19, 2024
104f328
cleanup gitignore
wolfy-nft Sep 19, 2024
f0ec3b8
cleanup
wolfy-nft Sep 19, 2024
7918e61
forge install: openzeppelin-contracts
wolfy-nft Sep 19, 2024
f5e0d5e
forge install: openzeppelin-contracts-upgradeable
wolfy-nft Sep 19, 2024
cf9feac
forge install: solmate
wolfy-nft Sep 19, 2024
a3e85f7
forge install: solady
wolfy-nft Sep 19, 2024
aea9eec
update gitmodules
wolfy-nft Sep 19, 2024
352ab91
forge install: operator-filter-registry
wolfy-nft Sep 19, 2024
73bc80d
forge install: ERC721A
wolfy-nft Sep 19, 2024
3261350
update remappings
wolfy-nft Sep 19, 2024
fca2b83
forge install: ERC721A-Upgradeable
wolfy-nft Sep 19, 2024
a03e964
update remappings
wolfy-nft Sep 19, 2024
d9c2531
forge install: creator-token-standards
wolfy-nft Sep 19, 2024
c2aa6a5
remaining foundry setup / fix build issues
wolfy-nft Sep 19, 2024
50d3912
revert readme change
wolfy-nft Sep 19, 2024
eed84e5
update readme
wolfy-nft Sep 19, 2024
e5b300a
contract factory
wolfy-nft Sep 19, 2024
541be9c
cleanup
wolfy-nft Sep 20, 2024
f2bc427
project restructuring
wolfy-nft Sep 20, 2024
4c2c2f9
test initializable v2
wolfy-nft Sep 20, 2024
c514e1f
consolidate errors and events
wolfy-nft Sep 20, 2024
b451da6
organize tests
wolfy-nft Sep 21, 2024
5ec5ed1
organize scripts
wolfy-nft Sep 21, 2024
0ac96d6
replace OwnableInitializable
wolfy-nft Sep 22, 2024
a85822d
cleanup
wolfy-nft Sep 27, 2024
8021d02
remove old factory, and add authorized minters
wolfy-nft Sep 27, 2024
923f613
rename
wolfy-nft Sep 27, 2024
27e709d
add erc1155 initializable
wolfy-nft Sep 27, 2024
ca21094
update solidity versions
wolfy-nft Sep 27, 2024
41f4208
cleanup
wolfy-nft Sep 27, 2024
abd9123
cleanup
wolfy-nft Sep 27, 2024
28ed36d
split cosignable
wolfy-nft Sep 27, 2024
9f79738
add authorizedmintercontrol
wolfy-nft Sep 27, 2024
68e26f5
Merge branch 'main' of https://github.com/wolfy-nft/magicdrop into ad…
wolfy-nft Oct 3, 2024
d00310c
use solady
wolfy-nft Oct 3, 2024
2668ab5
fixing tests
wolfy-nft Oct 3, 2024
46e724f
fix
wolfy-nft Oct 4, 2024
568ac48
cleanup
wolfy-nft Oct 4, 2024
36a9eb8
lint
wolfy-nft Oct 4, 2024
2d4c39f
fix tests
wolfy-nft Oct 4, 2024
73a2ebb
forge fmt
wolfy-nft Oct 4, 2024
bd8ff94
cleanup
wolfy-nft Oct 6, 2024
6b76fe2
tests
wolfy-nft Oct 6, 2024
8086579
cleanup
wolfy-nft Oct 6, 2024
59f6bb8
refactoring
wolfy-nft Oct 6, 2024
3aeaf35
remove mint with limit
wolfy-nft Oct 6, 2024
3fd8ca0
update mint funcs
wolfy-nft Oct 6, 2024
fcba0c3
fix tests
wolfy-nft Oct 6, 2024
0674ce1
cosignable optimizations
wolfy-nft Oct 7, 2024
94da4be
fix timestamps
wolfy-nft Oct 7, 2024
d3e4d06
remove crossmint in favor of authorized minter
wolfy-nft Oct 7, 2024
3e7184d
add erc721M storage
wolfy-nft Oct 7, 2024
82e8f8f
721m cleanup
wolfy-nft Oct 7, 2024
8151b89
721m natspec
wolfy-nft Oct 7, 2024
ded7052
cleanup 721m
wolfy-nft Oct 7, 2024
fae0553
cleanup
wolfy-nft Oct 7, 2024
3429b5b
fix tests
wolfy-nft Oct 7, 2024
45ac457
cleanup 1155m
wolfy-nft Oct 7, 2024
ff01121
fix tests
wolfy-nft Oct 7, 2024
c1b4016
deploy scripts
wolfy-nft Oct 8, 2024
5e999c5
registry + deprecate scripts
wolfy-nft Oct 8, 2024
8a5585b
deploy new implementation
wolfy-nft Oct 8, 2024
8404d10
forge install: openzeppelin-contracts
wolfy-nft Oct 8, 2024
04e196d
fix versions
wolfy-nft Oct 8, 2024
492c259
forge install: openzeppelin-contracts-upgradeable
wolfy-nft Oct 8, 2024
5cea8e0
fix tests
wolfy-nft Oct 8, 2024
e3a132c
update / fix scripts
wolfy-nft Oct 8, 2024
36756da
updates
wolfy-nft Oct 10, 2024
9f87b6a
remove deployments
wolfy-nft Oct 10, 2024
bd123ce
remove
wolfy-nft Oct 10, 2024
0d11b72
deprecate -> unregister
wolfy-nft Oct 11, 2024
fdac6bc
tests
wolfy-nft Oct 11, 2024
fa393fc
tewt
wolfy-nft Oct 11, 2024
7d31193
cleanup scripts
wolfy-nft Oct 11, 2024
6e03a82
cleanup
wolfy-nft Oct 11, 2024
4549302
refactor
wolfy-nft Oct 14, 2024
d7980c4
PR changes
wolfy-nft Oct 14, 2024
757d3c5
add magicdrop functions
wolfy-nft Oct 14, 2024
7b2a33e
cleanup
wolfy-nft Oct 14, 2024
2bbc261
owner mint
wolfy-nft Oct 14, 2024
36241b7
more scripts
wolfy-nft Oct 14, 2024
e351225
install
wolfy-nft Oct 14, 2024
2a994fa
install
wolfy-nft Oct 14, 2024
a0d3b18
install
wolfy-nft Oct 14, 2024
a79b09f
install
wolfy-nft Oct 14, 2024
ddba14d
add defaults
wolfy-nft Oct 14, 2024
c7d7b97
refactor
wolfy-nft Oct 15, 2024
81db23a
fix
wolfy-nft Oct 15, 2024
c504af6
fix
wolfy-nft Oct 15, 2024
3685470
cleanup
wolfy-nft Oct 15, 2024
1323b08
fix
wolfy-nft Oct 15, 2024
76b8405
add tx urls
wolfy-nft Oct 15, 2024
89f0ac1
fix
wolfy-nft Oct 15, 2024
cb71885
cleanup clone factory
wolfy-nft Oct 19, 2024
698c93d
fmt
wolfy-nft Oct 19, 2024
bdbcde7
refactor cli
wolfy-nft Oct 30, 2024
ba85903
cleanup
wolfy-nft Oct 30, 2024
600e82b
revert
wolfy-nft Oct 30, 2024
4e94e89
update getStagesData for 1155
wolfy-nft Oct 30, 2024
3ecc171
1155 fixes
wolfy-nft Oct 31, 2024
cba2227
f
wolfy-nft Oct 31, 2024
77a5494
revert
wolfy-nft Oct 31, 2024
7177131
remaining 1155
wolfy-nft Nov 1, 2024
3c35a44
cleanup
wolfy-nft Nov 1, 2024
de7b7dc
fix
wolfy-nft Nov 1, 2024
88ee6f2
update apechain rpc
wolfy-nft Nov 5, 2024
3aeb6b7
refactors
wolfy-nft Nov 5, 2024
32c362c
setup tf
wolfy-nft Nov 5, 2024
96c4193
cleanup
wolfy-nft Nov 5, 2024
19f1504
t
wolfy-nft Nov 5, 2024
d56a94e
reformat file with comments
wolfy-nft Nov 5, 2024
64e7edd
add deployment fee
wolfy-nft Nov 5, 2024
3c12f08
test
wolfy-nft Nov 5, 2024
129cccf
deployment fee cli
wolfy-nft Nov 5, 2024
5256c34
fix
wolfy-nft Nov 5, 2024
3a30da4
cleanup
wolfy-nft Nov 5, 2024
4da6364
add freeze/thaw
wolfy-nft Nov 8, 2024
bca5d10
update version, add 721m initializable
adamkwolf Nov 22, 2024
3568266
loader
adamkwolf Nov 22, 2024
a7536b9
examples
adamkwolf Nov 22, 2024
db68728
fix
adamkwolf Nov 22, 2024
88427b7
fix
adamkwolf Nov 23, 2024
85ec9d3
update examples
adamkwolf Nov 25, 2024
201535b
fix
adamkwolf Nov 26, 2024
e1af34a
fix
adamkwolf Nov 26, 2024
3a16b06
audit
adamkwolf Nov 26, 2024
0a748ff
f
adamkwolf Nov 27, 2024
abb28cd
t
adamkwolf Nov 27, 2024
1dd8e8c
Merge branch 'main' of https://github.com/wolfy-nft/magicdrop into ad…
wolfy-nft Nov 28, 2024
8167c84
fmt
wolfy-nft Dec 2, 2024
369f820
update lockfile
wolfy-nft Dec 2, 2024
007076c
remove magicdrop types
wolfy-nft Dec 2, 2024
9513d5a
ci
wolfy-nft Dec 2, 2024
da6bcf1
fix
wolfy-nft Dec 2, 2024
a6b543d
fix
wolfy-nft Dec 2, 2024
15c54c9
lint
wolfy-nft Dec 2, 2024
3a2233c
fmt
wolfy-nft Dec 2, 2024
0627070
lint
wolfy-nft Dec 2, 2024
88dec09
fix
wolfy-nft Dec 2, 2024
b9aa418
fix
wolfy-nft Dec 2, 2024
2ae071e
fix
wolfy-nft Dec 2, 2024
155ff49
t
wolfy-nft Dec 2, 2024
4fe96a3
ci
wolfy-nft Dec 2, 2024
ef92d95
ci
wolfy-nft Dec 2, 2024
7a7e391
ci
wolfy-nft Dec 2, 2024
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
73 changes: 73 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Environment variables and configuration files
.env*
*.env
config.json
*.config
*.cfg

# Secret keys and credentials
*secret*
*key*
*password*
*credential*

# Database files
*.db
*.sqlite
*.sqlite3

# Log files
*.log
log/
logs/

# Backup files
*.bak
*.backup
*~

# Private keys and certificates
*.pem
*.key
*.crt
*.cer
*.p12
*.pfx

# Personal or sensitive documents
*.doc
*.docx
*.pdf
*.xls
*.xlsx
*.csv

# API tokens and access files
.netrc
.npmrc
.yarnrc
.pypirc

# IDE and editor specific files that might contain sensitive information
.vscode/
.idea/
*.swp
*.swo

# OS generated files
.DS_Store
Thumbs.db

# Dependency directories that might contain sensitive data
node_modules/
vendor/

# Any file or directory starting with a dot (hidden files/folders)
.*

# Specific sensitive file names
id_rsa
id_dsa
known_hosts
authorized_keys
cli/defaults.json
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ gasReporterOutput.json
dist
rollup.cache
docs
lib/
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
run: npm ci
- name: Install Cosign Server dependencies
run: cd cosign-server && npm ci
- name: Build magicdrop-types
run: cd magicdrop-types && npm ci && npm run build
- name: Build magicdrop
run: npm run build
- name: Run lint
Expand All @@ -42,6 +40,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: workspace
- uses: crytic/slither-action@35510b34cfdfb137d9816d27378ee8c217f1fa1c
with:
fail-on: low
Expand Down
23 changes: 0 additions & 23 deletions .github/workflows/deploy_npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,6 @@ on:
release:
types: [published]
jobs:
publish_magicdrop_types:
environment: publish
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./magicdrop-types
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js '18.x'
uses: actions/setup-node@v2
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish_magicdrop:
environment: publish
runs-on: ubuntu-latest
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Show Forge version
run: |
forge --version

- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Forge build
run: |
forge build --via-ir --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
13 changes: 10 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
node_modules
.env
.env
coverage
converage/
coverage.json
typechain
typechain-types
Expand All @@ -12,3 +9,13 @@ artifacts
.vscode
dist
.DS_Store
out/
lcov.info
lcov.info.pruned
coverage/
broadcast/
*deployments*
*collections*
*whitelist*
*invalid*
*.tmp
27 changes: 27 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/operator-filter-registry"]
path = lib/operator-filter-registry
url = https://github.com/ProjectOpenSea/operator-filter-registry
[submodule "lib/ERC721A"]
path = lib/ERC721A
url = https://github.com/chiru-labs/ERC721A
[submodule "lib/ERC721A-Upgradeable"]
path = lib/ERC721A-Upgradeable
url = https://github.com/chiru-labs/ERC721A-Upgradeable
[submodule "lib/creator-token-standards"]
path = lib/creator-token-standards
url = https://github.com/limitbreakinc/creator-token-standards
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
hardhat.config.ts
scripts
test
lib
scripts
80 changes: 45 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![MIT License][license-shield]][license-url]
[![Coverage][coverage-shield]][coverage-url]

MagicDrop is a collection of EVM minting protocols that enable the multi stage minting, per stage WL management, per stage supply limit, and crossmint support.
MagicDrop is a collection of EVM minting protocols that enable the multi stage minting, per stage WL management, per stage supply limit, and authorized minter support.

## Motivation

Expand Down Expand Up @@ -38,58 +38,68 @@ The composability of the stages is generic enough to enable flexible and complic
- Per-stage whitelist Merkle Tree
- Per-stage Max Supply
- Global and Per-stage Limit
- Crossmint support
- Authorized minter support
- Native TypeScript and Typechain-Types Support

## Contracts
| Contract | Description |
|-------------------------|---------------------------------------------------------------------------------------|
| ERC721M | The basic minting contract based on ERC721A. |
| ERC721CM | The basic minting contract based on ERC721C and ERC721M. |
| ERC721CMRoyalties | Based on ERC721CM, implementing ERC2981 for on-chain royalty. |
| ERC721MOperatorFilterer | ERC721M with OpenSea Operator Filterer |
| BucketAuction | Bucket auction style minting contract. The contract is on beta. Use at your own risk. |

Please read [ERC721M Contract Usage Guide](./docs/ContractUsageGuide.md) for more details.

## Installation
Provide step by step series of examples and explanations about how to get a development env running.

| Contract | Description |
|-----------------------------|------------------------------------------------------------------------------------|
| ERC721M | The basic minting contract based on ERC721A. |
| ERC721CM | The basic minting contract based on ERC721C and ERC721M. |
| ERC1155M | The basic minting contract based on ERC1155. |
| MagicDropTokenImplRegistry | The implementation registry for MagicDrop contracts. |
| MagicDropCloneFactory | The factory contract for cloning MagicDrop contracts. |
| ERC721MInitializableV1_0_0 | The initializable implementation for ERC721M. |
| ERC721CMInitializableV1_0_0 | The initializable implementation for ERC721CM. |
| ERC1155MInitializableV1_0_0 | The initializable implementation for ERC1155M. |

## Deployment Address & Salts
| Name | Address | Salt |
|-----------------------------|-------------------------------------------|-----------------------------------------|
| MagicDropTokenImplRegistry | 0x00000000caF1E3978e291c5Fb53FeedB957eC146 |0x78c643228c532b1aee1930fedd4a4b0e6d3d8723987c0809d76a222b0d59b461 |
| MagicDropCloneFactory | 0x000000009e44eBa131196847C685F20Cd4b68aC4 | 0xd8c5a3057ccf31c5fd5cee4e4a5ad9005d0a9a7f4983365010b8785805b44eb1
| ERC721MInitializableV1_0_0 | 0x00000000b55a1126458841Cc756E565C50759484 | 0x4ca859ec4f4daad3d92dcc2959e01718def5eb520350e3e93bd31fc8d2b3beff
| ERC721CMInitializableV1_0_0 | 0x00000000760644De6b7b40362288e944f4154121 | 0x8ae63539ad30ece1889c0999c70b900ffaf0e10ee23b777924c310ad548b6266
| ERC1155MInitializableV1_0_0 | 0x000000009B3dC659D26BD2f3D38136E2b270C28d | 0x8b72ee316ce281e983b3694fc794164ce2eac8c3b8d7751c42edfc89310c6665

### Supported Chains
- Polygon
- Base
- Sei
- Arbitrum
- Apechain

## Using Foundry

### Install Foundry

```bash
npm add @magiceden-oss/erc721m
curl -L https://foundry.paradigm.xyz | bash
```

## Code Example
### Install Dependencies

```typescript
import { ERC721M, ERC721M__factory } from '@magiceden-oss/erc721m';

const contract = ERC721M__factory.connect(
contractAddress,
signerOrProvider,
);
```bash
forge install
```

## API Reference
### Build Contracts

```bash
# Compile the contract
npm run build

# Get the auto generated typechain-types
./typechain-types
forge build
```

## Tests
### Run Tests

```bash
npm run test
forge test
```

We are targeting 100% lines coverage.

![](https://bafkreic3dyzp5i2fi7co2fekkbgmyxgv342irjy5zfiuhvjqic6fuu53ju.ipfs.nftstorage.link/)
### Generate Coverage Report
This project includes a script to generate and view a test coverage report. The script is located at `test/generate-coverage-report.sh`.
```bash
./test/generate-coverage-report.sh
```

## Security
- [ERC721M Kudelski Security Audit](./docs/AUDIT-PUBLIC-RELEASE-MagicEden-ERC721M1.pdf)
Expand Down
Loading
Loading