Skip to content

Commit 857be2b

Browse files
authored
Merge pull request #60 from Mint-Gold-Dust/develop
Develop
2 parents 2d56b51 + a521a3b commit 857be2b

8 files changed

+1021
-2190
lines changed

.openzeppelin/unknown-31337.json

+953-2,171
Large diffs are not rendered by default.

contracts/marketplace/MintGoldDustERC1155.sol

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pragma solidity 0.8.18;
44
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
55
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
66
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol";
7-
87
import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155URIStorageUpgradeable.sol";
98
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
109
import "./MintGoldDustCompany.sol";
@@ -60,7 +59,7 @@ contract MintGoldDustERC1155 is
6059
address to,
6160
uint256 tokenId,
6261
uint256 amount
63-
) public override {
62+
) public override whenNotPaused {
6463
safeTransferFrom(from, to, tokenId, amount, "");
6564
}
6665

contracts/marketplace/MintGoldDustERC721.sol

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ contract MintGoldDustERC721 is
4949
address _to,
5050
uint256 _tokenId,
5151
uint256 _amount
52-
) public override {
52+
) public override whenNotPaused {
5353
_transfer(_from, _to, _tokenId);
5454
}
5555

@@ -122,6 +122,7 @@ contract MintGoldDustERC721 is
122122
public
123123
view
124124
override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
125+
whenNotPaused
125126
returns (string memory)
126127
{
127128
return super.tokenURI(tokenId);

contracts/marketplace/MintGoldDustMarketplace.sol

+25-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import "@openzeppelin/contracts/utils/Counters.sol";
55
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
66
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
77
import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol";
8+
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
89
import "./MintGoldDustCompany.sol";
910
import "./MintGoldDustERC721.sol";
1011
import "./MintGoldDustNFT.sol";
@@ -29,7 +30,10 @@ error MintGoldDustCollectorMintDataNotMatch();
2930
/// and also a virtual function that each children should have a specif implementation.
3031
/// @author Mint Gold Dust LLC
3132
/// @custom:contact klvh@mintgolddust.io
32-
abstract contract MintGoldDustMarketplace is Initializable {
33+
abstract contract MintGoldDustMarketplace is
34+
Initializable,
35+
PausableUpgradeable
36+
{
3337
/**
3438
*
3539
* @notice MintGoldDustMarketplace is composed by other two contracts.
@@ -1098,7 +1102,9 @@ abstract contract MintGoldDustMarketplace is Initializable {
10981102
* - contractAddress: The MintGoldDustERC1155 or the MintGoldDustERC721 address.
10991103
* - seller: The seller of the marketItem.
11001104
*/
1101-
function purchaseNft(SaleDTO memory _saleDTO) external payable {
1105+
function purchaseNft(
1106+
SaleDTO memory _saleDTO
1107+
) external payable whenNotPaused {
11021108
executePurchaseNftFlow(_saleDTO, msg.sender, msg.value);
11031109
}
11041110

@@ -1480,6 +1486,23 @@ abstract contract MintGoldDustMarketplace is Initializable {
14801486
_;
14811487
}
14821488

1489+
/// @notice Pause the contract
1490+
function pauseContract() public isowner {
1491+
_pause();
1492+
}
1493+
1494+
/// @notice Unpause the contract
1495+
function unpauseContract() public isowner {
1496+
_unpause();
1497+
}
1498+
1499+
modifier isowner() {
1500+
if (msg.sender != mgdCompany.owner()) {
1501+
revert MGDCompanyUnauthorized();
1502+
}
1503+
_;
1504+
}
1505+
14831506
/// @notice Fallbacks will forward funds to Mint Gold Dust LLC
14841507
fallback() external payable {
14851508
payable(mgdCompany.owner()).transfer(msg.value);

contracts/marketplace/MintGoldDustMarketplaceAuction.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ contract MintGoldDustMarketplaceAuction is
160160
uint256 _amount,
161161
address _contractAddress,
162162
uint256 _price
163-
) public override {
163+
) public override whenNotPaused {
164164
SaleDTO memory _saleDTO = SaleDTO(
165165
_tokenId,
166166
_amount,
@@ -412,7 +412,7 @@ contract MintGoldDustMarketplaceAuction is
412412
* - contractAddress: is a MintGoldDustNFT address.
413413
* - seller: is the address of the seller of this tokenId.
414414
*/
415-
function placeBid(BidDTO memory _bidDTO) public payable {
415+
function placeBid(BidDTO memory _bidDTO) public payable whenNotPaused {
416416
/// @dev verifications
417417
isNotCreator(_bidDTO);
418418
isNotLastBidder(_bidDTO);
@@ -439,7 +439,7 @@ contract MintGoldDustMarketplaceAuction is
439439
* - contractAddress: is a MintGoldDustNFT address.
440440
* - seller: is the address of the seller of this tokenId.
441441
*/
442-
function endAuction(BidDTO memory _bidDTO) public {
442+
function endAuction(BidDTO memory _bidDTO) public whenNotPaused {
443443
isTokenIdListed(_bidDTO.tokenId, _bidDTO.contractAddress);
444444

445445
if (

contracts/marketplace/MintGoldDustNFT.sol

+29-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pragma solidity 0.8.18;
33

44
import "@openzeppelin/contracts/utils/Counters.sol";
55
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
6+
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
67
import "./MintGoldDustCompany.sol";
78
import "./MintGoldDustMemoir.sol";
89

@@ -11,7 +12,7 @@ error MGDnftUnauthorized();
1112
error NumberOfCollaboratorsAndPercentagesNotMatch();
1213
error TheTotalPercentageCantBeGreaterThan100();
1314

14-
abstract contract MintGoldDustNFT is Initializable {
15+
abstract contract MintGoldDustNFT is Initializable, PausableUpgradeable {
1516
// Add your custom code and functions here
1617
/**
1718
*
@@ -99,7 +100,13 @@ abstract contract MintGoldDustNFT is Initializable {
99100
uint256 _royaltyPercent,
100101
uint256 _amount,
101102
string calldata _memoir
102-
) public payable validPercentage(_royaltyPercent) returns (uint256) {
103+
)
104+
public
105+
payable
106+
validPercentage(_royaltyPercent)
107+
whenNotPaused
108+
returns (uint256)
109+
{
103110
uint256 newTokenId = executeMintFlow(
104111
_tokenURI,
105112
_royaltyPercent,
@@ -118,7 +125,7 @@ abstract contract MintGoldDustNFT is Initializable {
118125
uint256 _amount,
119126
address _sender,
120127
string calldata _memoir
121-
) public validPercentage(_royaltyPercent) returns (uint256) {
128+
) public validPercentage(_royaltyPercent) whenNotPaused returns (uint256) {
122129
uint256 newTokenId = executeMintFlow(
123130
_tokenURI,
124131
_royaltyPercent,
@@ -159,7 +166,7 @@ abstract contract MintGoldDustNFT is Initializable {
159166
uint256[] calldata _ownersPercentage,
160167
uint256 _amount,
161168
string calldata _memoir
162-
) external returns (uint256) {
169+
) external whenNotPaused returns (uint256) {
163170
if (_ownersPercentage.length != _newOwners.length + 1) {
164171
revert NumberOfCollaboratorsAndPercentagesNotMatch();
165172
}
@@ -176,7 +183,7 @@ abstract contract MintGoldDustNFT is Initializable {
176183
uint256 _amount,
177184
address _sender,
178185
string calldata _memoir
179-
) external returns (uint256) {
186+
) external whenNotPaused returns (uint256) {
180187
if (_ownersPercentage.length != _newOwners.length + 1) {
181188
revert NumberOfCollaboratorsAndPercentagesNotMatch();
182189
}
@@ -243,6 +250,23 @@ abstract contract MintGoldDustNFT is Initializable {
243250
);
244251
}
245252

253+
/// @notice Pause the contract
254+
function pauseContract() public isowner {
255+
_pause();
256+
}
257+
258+
/// @notice Unpause the contract
259+
function unpauseContract() public isowner {
260+
_unpause();
261+
}
262+
263+
modifier isowner() {
264+
if (msg.sender != mintGoldDustCompany.owner()) {
265+
revert MGDCompanyUnauthorized();
266+
}
267+
_;
268+
}
269+
246270
modifier validPercentage(uint256 percentage) {
247271
if (percentage > mintGoldDustCompany.maxRoyalty()) {
248272
revert MGDnftRoyaltyInvalidPercentage();

contracts/marketplace/MintGoldDustSetPrice.sol

+6-4
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ contract MintGoldDustSetPrice is
130130
uint256 _amount,
131131
address _contractAddress,
132132
uint256 _price
133-
) public override {
133+
) public override whenNotPaused {
134134
SaleDTO memory _saleDTO = SaleDTO(
135135
_tokenId,
136136
_amount,
@@ -165,7 +165,7 @@ contract MintGoldDustSetPrice is
165165
uint256 _price,
166166
address _contractAddress,
167167
address _seller
168-
) public {
168+
) public whenNotPaused {
169169
mustBeMintGoldDustERC721Or1155(_contractAddress);
170170
isTokenIdListed(_tokenId, _contractAddress);
171171
isSeller(_tokenId, _contractAddress, _seller);
@@ -208,7 +208,9 @@ contract MintGoldDustSetPrice is
208208
* - contractAddress: The MintGoldDustERC1155 or the MintGoldDustERC721 address.
209209
* - seller: The seller of the marketItem.
210210
*/
211-
function delistNft(DelistDTO memory _delistDTO) public nonReentrant {
211+
function delistNft(
212+
DelistDTO memory _delistDTO
213+
) public nonReentrant whenNotPaused {
212214
mustBeMintGoldDustERC721Or1155(_delistDTO.contractAddress);
213215
isTokenIdListed(_delistDTO.tokenId, _delistDTO.contractAddress);
214216
isSeller(_delistDTO.tokenId, _delistDTO.contractAddress, msg.sender);
@@ -269,7 +271,7 @@ contract MintGoldDustSetPrice is
269271
CollectorMintDTO memory _collectorMintDTO,
270272
bytes32 _messageHash,
271273
bytes memory _artistSignature
272-
) public payable {
274+
) public payable whenNotPaused {
273275
mustBeMintGoldDustERC721Or1155(_collectorMintDTO.contractAddress);
274276

275277
MintGoldDustNFT _mintGoldDustNFT;

test/MintGoldDustMarketplaceAuctionERC1155.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,14 @@ describe("\nMGDAuction.sol Smart Contract \n************___************\n \nThis
755755
)
756756
);
757757

758-
expect(parseFloat(fromWei(bidderBalanceBefore)).toFixed(4)).to.be.equal(
758+
expect(parseFloat(fromWei(bidderBalanceBefore)).toFixed(3)).to.be.equal(
759759
parseFloat(
760760
fromWei(
761761
ethers.BigNumber.from(bidderBalanceAfter)
762762
.add(toWei(priceToPurchase))
763763
.add(ethers.BigNumber.from(gasPrice).mul(gasLimit))
764764
)
765-
).toFixed(4)
765+
).toFixed(3)
766766
);
767767

768768
// Verify if the end time was set to 24 hours after the first bid greater than zero.

0 commit comments

Comments
 (0)