Skip to content

Commit b7cd554

Browse files
Add magicdrop-types package and set up CI (#155)
* Add cosigner in 1155M * update signature * Conditionally enforcing mint fee * Update cosigner service and bump version * Add magicdrop-types package and setup CI * Fix per lint * update * fix * Update IERC721 and IERC1155 to support ME LP
1 parent 2cce35c commit b7cd554

File tree

17 files changed

+4563
-39
lines changed

17 files changed

+4563
-39
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ on:
1515
jobs:
1616
unit_test:
1717
runs-on: ubuntu-latest
18-
strategy:
19-
matrix:
20-
node-version: [18.x]
2118
steps:
22-
- uses: actions/checkout@v2
23-
- uses: actions/setup-node@v2
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Use Node.js '18.x'
22+
uses: actions/setup-node@v2
2423
with:
25-
node-version: ${{ matrix.node-version }}
26-
- run: npm ci
27-
- run: cd cosign-server && npm ci
28-
- run: npm run build
29-
- run: npm run lint
24+
node-version: "18.x"
25+
- name: Install dependencies
26+
run: npm ci
27+
- name: Install Cosign Server dependencies
28+
run: cd cosign-server && npm ci
29+
- name: Build magicdrop-types
30+
run: cd magicdrop-types && npm ci && npm run build
31+
- name: Build magicdrop
32+
run: npm run build
33+
- name: Run lint
34+
run: npm run lint
3035
- name: Run Coverage and Upload to CodeCov
3136
run: |
3237
npm run coverage; \

.github/workflows/deploy_npm.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,48 @@ on:
33
release:
44
types: [published]
55
jobs:
6-
build:
6+
publish_magicdrop_types:
77
environment: publish
88
runs-on: ubuntu-latest
9+
defaults:
10+
run:
11+
working-directory: ./magicdrop-types
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@v2
12-
- uses: actions/setup-node@v2
15+
- name: Use Node.js '18.x'
16+
uses: actions/setup-node@v2
1317
with:
14-
node-version: "16.x"
18+
node-version: "18.x"
1519
registry-url: "https://registry.npmjs.org"
16-
- run: npm ci
17-
- run: npm run build
18-
- run: npm publish --access public
20+
- name: Install dependencies
21+
run: npm ci
22+
- name: Build
23+
run: npm run build
24+
- name: Publish
25+
run: npm publish --access public
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28+
29+
publish_magicdrop:
30+
environment: publish
31+
runs-on: ubuntu-latest
32+
defaults:
33+
run:
34+
working-directory: ./
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v2
38+
- name: Use Node.js '18.x'
39+
uses: actions/setup-node@v2
40+
with:
41+
node-version: "18.x"
42+
registry-url: "https://registry.npmjs.org"
43+
- name: Install dependencies
44+
run: npm ci
45+
- name: Build
46+
run: npm run build
47+
- name: Publish
48+
run: npm publish --access public
1949
env:
2050
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

contracts/ERC1155M.sol

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
pragma solidity ^0.8.20;
44

55
import "@openzeppelin/contracts/access/Ownable2Step.sol";
6-
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
7-
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
86
import "@openzeppelin/contracts/token/common/ERC2981.sol";
97
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
8+
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
9+
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
10+
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
1011
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
1112
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
1213
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1314
import "./utils/Constants.sol";
14-
15-
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
16-
import "./IERC1155M.sol";
15+
import "../magicdrop-types/contracts/IERC1155M.sol";
1716

1817
/**
1918
* @title ERC1155M
@@ -162,7 +161,7 @@ contract ERC1155M is
162161
function getCosignNonce(
163162
address minter,
164163
uint256 tokenId
165-
) public view returns (uint256) {
164+
) public view override returns (uint256) {
166165
return totalMintedByAddress(minter)[tokenId];
167166
}
168167

@@ -352,6 +351,21 @@ contract ERC1155M is
352351
return totalMinted;
353352
}
354353

354+
function totalSupply()
355+
public
356+
view
357+
override(ERC1155Supply, IERC1155M)
358+
returns (uint256)
359+
{
360+
return ERC1155Supply.totalSupply();
361+
}
362+
363+
function totalSupply(
364+
uint256 tokenId
365+
) public view override(ERC1155Supply, IERC1155M) returns (uint256) {
366+
return ERC1155Supply.totalSupply(tokenId);
367+
}
368+
355369
/**
356370
* @dev Returns number of stages.
357371
*/

contracts/ERC721CM.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
1111
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
1212
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
1313
import "./creator-token-standards/ERC721ACQueryable.sol";
14-
import "./IERC721M.sol";
1514
import "./utils/Constants.sol";
15+
import "../magicdrop-types/contracts/IERC721M.sol";
1616

1717
/**
1818
* @title ERC721CM
@@ -127,7 +127,9 @@ contract ERC721CM is IERC721M, ERC721ACQueryable, Ownable, ReentrancyGuard {
127127
/**
128128
* @dev Returns cosign nonce.
129129
*/
130-
function getCosignNonce(address minter) public view returns (uint256) {
130+
function getCosignNonce(
131+
address minter
132+
) public view override returns (uint256) {
131133
return _numberMinted(minter);
132134
}
133135

contracts/ERC721CMInitializable.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1111
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
1212
import "./creator-token-standards/ERC721ACQueryableInitializable.sol";
1313
import "./access/OwnableInitializable.sol";
14-
import "./IERC721MInitializable.sol";
1514
import "./utils/Constants.sol";
15+
import "../magicdrop-types/contracts/IERC721MInitializable.sol";
1616

1717
/**
1818
* @title ERC721CMInitializable
@@ -113,7 +113,9 @@ abstract contract ERC721CMInitializable is
113113
/**
114114
* @dev Returns cosign nonce.
115115
*/
116-
function getCosignNonce(address minter) public view returns (uint256) {
116+
function getCosignNonce(
117+
address minter
118+
) public view override returns (uint256) {
117119
return _numberMinted(minter);
118120
}
119121

contracts/ERC721M.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
1010
import "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
1111
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
1212
import "erc721a/contracts/extensions/ERC721AQueryable.sol";
13-
import "./IERC721M.sol";
1413
import "./utils/Constants.sol";
14+
import "../magicdrop-types/contracts/IERC721M.sol";
1515

1616
/**
1717
* @title ERC721M
@@ -126,7 +126,9 @@ contract ERC721M is IERC721M, ERC721AQueryable, Ownable, ReentrancyGuard {
126126
/**
127127
* @dev Returns cosign nonce.
128128
*/
129-
function getCosignNonce(address minter) public view returns (uint256) {
129+
function getCosignNonce(
130+
address minter
131+
) public view override returns (uint256) {
130132
return _numberMinted(minter);
131133
}
132134

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.20;
33

4-
54
interface IERC1155M {
65
error CannotIncreaseMaxMintableSupply();
76
error CosignerNotSet();
@@ -50,23 +49,53 @@ interface IERC1155M {
5049
);
5150

5251
event SetCosigner(address cosigner);
53-
event SetMaxMintableSupply(uint256 indexed tokenId, uint256 maxMintableSupply);
54-
event SetGlobalWalletLimit(uint256 indexed tokenId, uint256 globalWalletLimit);
52+
event SetMaxMintableSupply(
53+
uint256 indexed tokenId,
54+
uint256 maxMintableSupply
55+
);
56+
event SetGlobalWalletLimit(
57+
uint256 indexed tokenId,
58+
uint256 globalWalletLimit
59+
);
5560
event Withdraw(uint256 value);
5661
event WithdrawERC20(address indexed mintCurrency, uint256 value);
5762
event SetTransferable(bool transferable);
5863
event DefaultRoyaltySet(address receiver, uint96 feeNumerator);
59-
event TokenRoyaltySet(uint256 indexed tokenId, address receiver, uint96 feeNumerator);
64+
event TokenRoyaltySet(
65+
uint256 indexed tokenId,
66+
address receiver,
67+
uint96 feeNumerator
68+
);
6069

6170
function getNumberStages() external view returns (uint256);
6271

63-
function getGlobalWalletLimit(uint256 tokenId) external view returns (uint256);
72+
function totalSupply() external view returns (uint256);
73+
74+
function totalSupply(uint256 tokenId) external view returns (uint256);
75+
76+
function getGlobalWalletLimit(
77+
uint256 tokenId
78+
) external view returns (uint256);
79+
80+
function getMaxMintableSupply(
81+
uint256 tokenId
82+
) external view returns (uint256);
6483

65-
function getMaxMintableSupply(uint256 tokenId) external view returns (uint256);
84+
function totalMintedByAddress(
85+
address account
86+
) external view returns (uint256[] memory);
6687

67-
function totalMintedByAddress(address account) external view returns (uint256[] memory);
88+
function getCosignNonce(
89+
address minter,
90+
uint256 tokenId
91+
) external view returns (uint256);
6892

69-
function getStageInfo(uint256 stage) external view returns (MintStageInfo memory, uint256[] memory, uint256[] memory);
93+
function getStageInfo(
94+
uint256 stage
95+
)
96+
external
97+
view
98+
returns (MintStageInfo memory, uint256[] memory, uint256[] memory);
7099

71100
function mint(
72101
uint256 tokenId,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ interface IERC721M is IERC721AQueryable {
7070

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

73+
function getCosignNonce(address minter) external view returns (uint256);
74+
7375
function getStageInfo(
7476
uint256 index
7577
) external view returns (MintStageInfo memory, uint32, uint256);

contracts/IERC721MInitializable.sol renamed to magicdrop-types/contracts/IERC721MInitializable.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ interface IERC721MInitializable is IERC721AQueryableUpgradeable {
7373

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

76+
function getCosignNonce(address minter) external view returns (uint256);
77+
7678
function getStageInfo(
7779
uint256 index
7880
) external view returns (MintStageInfo memory, uint32, uint256);

magicdrop-types/hardhat.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
import '@typechain/hardhat';
3+
import { HardhatUserConfig } from 'hardhat/config';
4+
5+
const config: HardhatUserConfig = {
6+
solidity: {
7+
version: '0.8.20',
8+
settings: {
9+
viaIR: true,
10+
optimizer: {
11+
enabled: true,
12+
runs: 20,
13+
details: {
14+
yulDetails: {
15+
optimizerSteps: "dhfoD[xarrscLMcCTU]uljmul",
16+
},
17+
},
18+
},
19+
},
20+
},
21+
paths: {
22+
artifacts: './artifacts',
23+
cache: './cache',
24+
sources: './contracts',
25+
tests: './test',
26+
},
27+
};
28+
29+
30+
export default config;

0 commit comments

Comments
 (0)