8000 Fix role for lazyMint by kumaryash90 · Pull Request #253 · thirdweb-dev/contracts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix role for lazyMint #253

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

Merged
merged 3 commits into from
Sep 26, 2022
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
4 changes: 2 additions & 2 deletions contracts/signature-drop/SignatureDrop.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ contract SignatureDrop is
uint256 _amount,
string calldata _baseURIForTokens,
bytes calldata _data
) public override onlyRole(minterRole) returns (uint256 batchId) {
) public override returns (uint256 batchId) {
if (_data.length > 0) {
(bytes memory encryptedURI, bytes32 provenanceHash) = abi.decode(_data, (bytes, bytes32));
if (encryptedURI.length != 0 && provenanceHash != "") {
Expand Down Expand Up @@ -306,7 +306,7 @@ contract SignatureDrop is

/// @dev Returns whether lazy minting can be done in the given execution context.
function _canLazyMint() internal view virtual override returns (bool) {
return hasRole(DEFAULT_ADMIN_ROLE, _msgSender());
return hasRole(minterRole, _msgSender());
}

/*///////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
16 changes: 9 additions & 7 deletions src/test/SignatureDrop.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -462,14 +462,16 @@ contract SignatureDropTest is BaseTest {
* note: Testing revert condition; an address without MINTER_ROLE calls lazyMint function.
*/
function test_revert_lazyMint_MINTER_ROLE() public {
bytes memory errorMessage = abi.encodePacked(
"Permissions: account ",
Strings.toHexString(uint160(address(this)), 20),
" is missing role ",
Strings.toHexString(uint256(keccak256("MINTER_ROLE")), 32)
);
bytes32 _minterRole = keccak256("MINTER_ROLE");

vm.expectRevert(errorMessage);
vm.prank(deployerSigner);
sigdrop.grantRole(_minterRole, address(0x345));

vm.prank(address(0x345));
sigdrop.lazyMint(100, "ipfs://", emptyEncodedBytes);

vm.prank(address(0x567));
vm.expectRevert("Not authorized");
sigdrop.lazyMint(100, "ipfs://", emptyEncodedBytes);
}

Expand Down
0