mirror of
https://github.com/placeholder-soft/gifted-contracts-v2.git
synced 2026-01-12 22:28:55 +08:00
chore: rename to Claimer
This commit is contained in:
@@ -31,7 +31,7 @@ contract GiftedBox is
|
||||
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
|
||||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
|
||||
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
|
||||
bytes32 public constant CLAIM_ADMIN_ROLE = keccak256("CLAIM_ADMIN_ROLE");
|
||||
bytes32 public constant CLAIMER_ROLE = keccak256("CLAIMER_ROLE");
|
||||
|
||||
event GiftedBoxSentToVault(
|
||||
address indexed from,
|
||||
@@ -102,7 +102,7 @@ contract GiftedBox is
|
||||
_grantRole(PAUSER_ROLE, defaultAdmin);
|
||||
_grantRole(MINTER_ROLE, defaultAdmin);
|
||||
_grantRole(UPGRADER_ROLE, defaultAdmin);
|
||||
_grantRole(CLAIM_ADMIN_ROLE, defaultAdmin);
|
||||
_grantRole(CLAIMER_ROLE, defaultAdmin);
|
||||
}
|
||||
|
||||
function pause() public onlyRole(PAUSER_ROLE) {
|
||||
@@ -341,10 +341,10 @@ contract GiftedBox is
|
||||
emit GiftedBoxClaimed(tokenId, role, record.sender, record.recipient, record.operator);
|
||||
}
|
||||
|
||||
function claimGiftByAdmin(
|
||||
function claimGiftByClaimer(
|
||||
uint256 tokenId,
|
||||
GiftingRole role
|
||||
) public onlyRole(CLAIM_ADMIN_ROLE) {
|
||||
) public onlyRole(CLAIMER_ROLE) {
|
||||
GiftingRecord memory record = giftingRecords[tokenId];
|
||||
if (role == GiftingRole.SENDER) {
|
||||
require(record.sender != address(0), "!invalid-sender");
|
||||
|
||||
@@ -142,7 +142,7 @@ contract GiftedBoxTest is Test, TestEvents {
|
||||
assertEq(operator, address(0));
|
||||
}
|
||||
|
||||
function testClaimGiftByAdmin() public {
|
||||
function testclaimGiftByClaimer() public {
|
||||
uint256 tokenId = 0;
|
||||
address giftSender = vm.addr(1);
|
||||
address giftRecipient = vm.addr(2);
|
||||
@@ -150,7 +150,7 @@ contract GiftedBoxTest is Test, TestEvents {
|
||||
|
||||
vm.prank(giftOperator);
|
||||
giftedBox.sendGift(giftSender, giftRecipient);
|
||||
giftedBox.claimGiftByAdmin(tokenId, GiftingRole.SENDER);
|
||||
giftedBox.claimGiftByClaimer(tokenId, GiftingRole.SENDER);
|
||||
|
||||
assertEq(giftSender, IERC721(giftedBox).ownerOf(tokenId));
|
||||
{
|
||||
@@ -166,7 +166,7 @@ contract GiftedBoxTest is Test, TestEvents {
|
||||
vm.prank(giftOperator);
|
||||
giftedBox.sendGift(giftSender, giftRecipient);
|
||||
|
||||
giftedBox.claimGiftByAdmin(tokenId, GiftingRole.RECIPIENT);
|
||||
giftedBox.claimGiftByClaimer(tokenId, GiftingRole.RECIPIENT);
|
||||
assertEq(giftRecipient, IERC721(giftedBox).ownerOf(tokenId));
|
||||
{
|
||||
(address sender, address recipient, address operator) = giftedBox
|
||||
@@ -182,7 +182,7 @@ contract GiftedBoxTest is Test, TestEvents {
|
||||
giftedBox.sendGift(giftSender, giftRecipient);
|
||||
|
||||
vm.expectRevert("!invalid-role");
|
||||
giftedBox.claimGiftByAdmin(tokenId, GiftingRole.OPERATOR);
|
||||
giftedBox.claimGiftByClaimer(tokenId, GiftingRole.OPERATOR);
|
||||
}
|
||||
|
||||
// endregion Gifting Actions
|
||||
|
||||
Reference in New Issue
Block a user