Skip to content

Commit

Permalink
magicdrop refactor and contract factory (#152)
Browse files Browse the repository at this point in the history
* chore: forge init

* forge install: forge-std

v1.9.2

* cleanup gitignore

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* forge install: openzeppelin-contracts

v5.0.2

* forge install: openzeppelin-contracts-upgradeable

v5.0.2

* forge install: solmate

* forge install: solady

v0.0.243

* update gitmodules

Signed-off-by: Wolfy <[email protected]>

* forge install: operator-filter-registry

v1.4.2

* forge install: ERC721A

v4.3.0

* update remappings

Signed-off-by: Wolfy <[email protected]>

* forge install: ERC721A-Upgradeable

v4.3.0

* update remappings

Signed-off-by: Wolfy <[email protected]>

* forge install: creator-token-standards

v3.0.0

* remaining foundry setup / fix build issues

Signed-off-by: Wolfy <[email protected]>

* revert readme change

Signed-off-by: Wolfy <[email protected]>

* update readme

Signed-off-by: Wolfy <[email protected]>

* contract factory

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* project restructuring

Signed-off-by: Wolfy <[email protected]>

* test initializable v2

Signed-off-by: Wolfy <[email protected]>

* consolidate errors and events

Signed-off-by: Wolfy <[email protected]>

* organize tests

Signed-off-by: Wolfy <[email protected]>

* organize scripts

Signed-off-by: Wolfy <[email protected]>

* replace OwnableInitializable

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* remove old factory, and add authorized minters

Signed-off-by: Wolfy <[email protected]>

* rename

Signed-off-by: Wolfy <[email protected]>

* add erc1155 initializable

Signed-off-by: Wolfy <[email protected]>

* update solidity versions

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* split cosignable

Signed-off-by: Wolfy <[email protected]>

* add authorizedmintercontrol

Signed-off-by: Wolfy <[email protected]>

* use solady

Signed-off-by: Wolfy <[email protected]>

* fixing tests

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* lint

Signed-off-by: Wolfy <[email protected]>

* fix tests

Signed-off-by: Wolfy <[email protected]>

* forge fmt

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* tests

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* refactoring

Signed-off-by: Wolfy <[email protected]>

* remove mint with limit

Signed-off-by: Wolfy <[email protected]>

* update mint funcs

Signed-off-by: Wolfy <[email protected]>

* fix tests

Signed-off-by: Wolfy <[email protected]>

* cosignable optimizations

Signed-off-by: Wolfy <[email protected]>

* fix timestamps

Signed-off-by: Wolfy <[email protected]>

* remove crossmint in favor of authorized minter

Signed-off-by: Wolfy <[email protected]>

* add erc721M storage

Signed-off-by: Wolfy <[email protected]>

* 721m cleanup

Signed-off-by: Wolfy <[email protected]>

* 721m natspec

Signed-off-by: Wolfy <[email protected]>

* cleanup 721m

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* fix tests

Signed-off-by: Wolfy <[email protected]>

* cleanup 1155m

Signed-off-by: Wolfy <[email protected]>

* fix tests

Signed-off-by: Wolfy <[email protected]>

* deploy scripts

Signed-off-by: Wolfy <[email protected]>

* registry + deprecate scripts

Signed-off-by: Wolfy <[email protected]>

* deploy new implementation

Signed-off-by: Wolfy <[email protected]>

* forge install: openzeppelin-contracts

v4.8.3

* fix versions

Signed-off-by: Wolfy <[email protected]>

* forge install: openzeppelin-contracts-upgradeable

v4.8.3

* fix tests

Signed-off-by: Wolfy <[email protected]>

* update / fix scripts

Signed-off-by: Wolfy <[email protected]>

* updates

Signed-off-by: Wolfy <[email protected]>

* remove deployments

Signed-off-by: Wolfy <[email protected]>

* remove

Signed-off-by: Wolfy <[email protected]>

* deprecate -> unregister

Signed-off-by: Wolfy <[email protected]>

* tests

Signed-off-by: Wolfy <[email protected]>

* tewt

Signed-off-by: Wolfy <[email protected]>

* cleanup scripts

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* refactor

Signed-off-by: Wolfy <[email protected]>

* PR changes

Signed-off-by: Wolfy <[email protected]>

* add magicdrop functions

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* owner mint

Signed-off-by: Wolfy <[email protected]>

* more scripts

Signed-off-by: Wolfy <[email protected]>

* install

Signed-off-by: Wolfy <[email protected]>

* install

Signed-off-by: Wolfy <[email protected]>

* install

Signed-off-by: Wolfy <[email protected]>

* install

Signed-off-by: Wolfy <[email protected]>

* add defaults

Signed-off-by: Wolfy <[email protected]>

* refactor

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* add tx urls

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* cleanup clone factory

Signed-off-by: Wolfy <[email protected]>

* fmt

Signed-off-by: Wolfy <[email protected]>

* refactor cli

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* revert

Signed-off-by: Wolfy <[email protected]>

* update getStagesData for 1155

Signed-off-by: Wolfy <[email protected]>

* 1155 fixes

Signed-off-by: Wolfy <[email protected]>

* f

Signed-off-by: Wolfy <[email protected]>

* revert

Signed-off-by: Wolfy <[email protected]>

* remaining 1155

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* update apechain rpc

Signed-off-by: Wolfy <[email protected]>

* refactors

Signed-off-by: Wolfy <[email protected]>

* setup tf

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* t

Signed-off-by: Wolfy <[email protected]>

* reformat file with comments

Signed-off-by: Wolfy <[email protected]>

* add deployment fee

Signed-off-by: Wolfy <[email protected]>

* test

Signed-off-by: Wolfy <[email protected]>

* deployment fee cli

Signed-off-by: Wolfy <[email protected]>

* fix

Signed-off-by: Wolfy <[email protected]>

* cleanup

Signed-off-by: Wolfy <[email protected]>

* add freeze/thaw

Signed-off-by: Wolfy <[email protected]>

* update version, add 721m initializable

* loader

* examples

* fix

* fix

* update examples

* fix

* fix

* audit

* f

* t

* fmt

Signed-off-by: Adam Wolf <[email protected]>

* update lockfile

Signed-off-by: Adam Wolf <[email protected]>

* remove magicdrop types

Signed-off-by: Adam Wolf <[email protected]>

* ci

Signed-off-by: Adam Wolf <[email protected]>

* fix

Signed-off-by: Adam Wolf <[email protected]>

* fix

Signed-off-by: Adam Wolf <[email protected]>

* lint

Signed-off-by: Adam Wolf <[email protected]>

* fmt

Signed-off-by: Adam Wolf <[email protected]>

* lint

Signed-off-by: Adam Wolf <[email protected]>

* fix

Signed-off-by: Adam Wolf <[email protected]>

* fix

Signed-off-by: Adam Wolf <[email protected]>

* fix

Signed-off-by: Adam Wolf <[email protected]>

* t

Signed-off-by: Adam Wolf <[email protected]>

* ci

Signed-off-by: Adam Wolf <[email protected]>

* ci

Signed-off-by: Adam Wolf <[email protected]>

* ci

Signed-off-by: Adam Wolf <[email protected]>

---------

Signed-off-by: Wolfy <[email protected]>
Signed-off-by: Adam Wolf <[email protected]>
Co-authored-by: adamkwolf <[email protected]>
  • Loading branch information
wolfy-nft and adamkwolf authored Dec 2, 2024
1 parent dcd115e commit 693134f
Show file tree
Hide file tree
Showing 164 changed files with 18,569 additions and 39,292 deletions.
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

0 comments on commit 693134f

Please sign in to comment.