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

Add magicdrop-types package and set up CI #155

Merged
merged 10 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 15 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ on:
jobs:
unit_test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js '18.x'
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: cd cosign-server && npm ci
- run: npm run build
- run: npm run lint
node-version: "18.x"
- name: Install dependencies
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
run: npm run lint
- name: Run Coverage and Upload to CodeCov
run: |
npm run coverage; \
Expand Down
42 changes: 36 additions & 6 deletions .github/workflows/deploy_npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,48 @@ on:
release:
types: [published]
jobs:
build:
publish_magicdrop_types:
environment: publish
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./magicdrop-types
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Use Node.js '18.x'
uses: actions/setup-node@v2
with:
node-version: "16.x"
node-version: "18.x"
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm run build
- run: npm publish --access public
- 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
defaults:
run:
working-directory: ./
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 }}
26 changes: 20 additions & 6 deletions contracts/ERC1155M.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/access/Ownable2Step.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "./utils/Constants.sol";

import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "./IERC1155M.sol";
import "../magicdrop-types/contracts/IERC1155M.sol";

/**
* @title ERC1155M
Expand Down Expand Up @@ -162,7 +161,7 @@ contract ERC1155M is
function getCosignNonce(
address minter,
uint256 tokenId
) public view returns (uint256) {
) public view override returns (uint256) {
return totalMintedByAddress(minter)[tokenId];
}

Expand Down Expand Up @@ -352,6 +351,21 @@ contract ERC1155M is
return totalMinted;
}

function totalSupply()
public
view
override(ERC1155Supply, IERC1155M)
returns (uint256)
{
return ERC1155Supply.totalSupply();
}

function totalSupply(
uint256 tokenId
) public view override(ERC1155Supply, IERC1155M) returns (uint256) {
return ERC1155Supply.totalSupply(tokenId);
}

/**
* @dev Returns number of stages.
*/
Expand Down
6 changes: 4 additions & 2 deletions contracts/ERC721CM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import "./creator-token-standards/ERC721ACQueryable.sol";
import "./IERC721M.sol";
import "./utils/Constants.sol";
import "../magicdrop-types/contracts/IERC721M.sol";

/**
* @title ERC721CM
Expand Down Expand Up @@ -127,7 +127,9 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
/**
* @dev Returns cosign nonce.
*/
function getCosignNonce(address minter) public view returns (uint256) {
function getCosignNonce(
address minter
) public view override returns (uint256) {
return _numberMinted(minter);
}

Expand Down
6 changes: 4 additions & 2 deletions contracts/ERC721CMInitializable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "./creator-token-standards/ERC721ACQueryableInitializable.sol";
import "./access/OwnableInitializable.sol";
import "./IERC721MInitializable.sol";
import "./utils/Constants.sol";
import "../magicdrop-types/contracts/IERC721MInitializable.sol";

/**
* @title ERC721CMInitializable
Expand Down Expand Up @@ -113,7 +113,9 @@ abstract contract ERC721CMInitializable is
/**
* @dev Returns cosign nonce.
*/
function getCosignNonce(address minter) public view returns (uint256) {
function getCosignNonce(
address minter
) public view override returns (uint256) {
return _numberMinted(minter);
}

Expand Down
6 changes: 4 additions & 2 deletions contracts/ERC721M.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";
import "./IERC721M.sol";
import "./utils/Constants.sol";
import "../magicdrop-types/contracts/IERC721M.sol";

/**
* @title ERC721M
Expand Down Expand Up @@ -126,7 +126,9 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
/**
* @dev Returns cosign nonce.
*/
function getCosignNonce(address minter) public view returns (uint256) {
function getCosignNonce(
address minter
) public view override returns (uint256) {
return _numberMinted(minter);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;


interface IERC1155M {
error CannotIncreaseMaxMintableSupply();
error CosignerNotSet();
Expand Down Expand Up @@ -50,23 +49,53 @@ interface IERC1155M {
);

event SetCosigner(address cosigner);
event SetMaxMintableSupply(uint256 indexed tokenId, uint256 maxMintableSupply);
event SetGlobalWalletLimit(uint256 indexed tokenId, uint256 globalWalletLimit);
event SetMaxMintableSupply(
uint256 indexed tokenId,
uint256 maxMintableSupply
);
event SetGlobalWalletLimit(
uint256 indexed tokenId,
uint256 globalWalletLimit
);
event Withdraw(uint256 value);
event WithdrawERC20(address indexed mintCurrency, uint256 value);
event SetTransferable(bool transferable);
event DefaultRoyaltySet(address receiver, uint96 feeNumerator);
event TokenRoyaltySet(uint256 indexed tokenId, address receiver, uint96 feeNumerator);
event TokenRoyaltySet(
uint256 indexed tokenId,
address receiver,
uint96 feeNumerator
);

function getNumberStages() external view returns (uint256);

function getGlobalWalletLimit(uint256 tokenId) external view returns (uint256);
function totalSupply() external view returns (uint256);

function totalSupply(uint256 tokenId) external view returns (uint256);

function getGlobalWalletLimit(
uint256 tokenId
) external view returns (uint256);

function getMaxMintableSupply(
uint256 tokenId
) external view returns (uint256);

function getMaxMintableSupply(uint256 tokenId) external view returns (uint256);
function totalMintedByAddress(
address account
) external view returns (uint256[] memory);

function totalMintedByAddress(address account) external view returns (uint256[] memory);
function getCosignNonce(
address minter,
uint256 tokenId
) external view returns (uint256);

function getStageInfo(uint256 stage) external view returns (MintStageInfo memory, uint256[] memory, uint256[] memory);
function getStageInfo(
uint256 stage
)
external
view
returns (MintStageInfo memory, uint256[] memory, uint256[] memory);

function mint(
uint256 tokenId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ interface IERC721M is IERC721AQueryable {

function totalMintedByAddress(address a) external view returns (uint256);

function getCosignNonce(address minter) external view returns (uint256);

function getStageInfo(
uint256 index
) external view returns (MintStageInfo memory, uint32, uint256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ interface IERC721MInitializable is IERC721AQueryableUpgradeable {

function totalMintedByAddress(address a) external view returns (uint256);

function getCosignNonce(address minter) external view returns (uint256);

function getStageInfo(
uint256 index
) external view returns (MintStageInfo memory, uint32, uint256);
Expand Down
30 changes: 30 additions & 0 deletions magicdrop-types/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

import '@typechain/hardhat';
import { HardhatUserConfig } from 'hardhat/config';

const config: HardhatUserConfig = {
solidity: {
version: '0.8.20',
settings: {
viaIR: true,
optimizer: {
enabled: true,
runs: 20,
details: {
yulDetails: {
optimizerSteps: "dhfoD[xarrscLMcCTU]uljmul",
},
},
},
},
},
paths: {
artifacts: './artifacts',
cache: './cache',
sources: './contracts',
tests: './test',
},
};


export default config;
Loading
Loading