Skip to content

Commit

Permalink
add convenience view funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
spengrah committed Jul 4, 2024
1 parent 882288d commit 310c30f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/PublicLockV14Eligibility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,21 @@ contract PublicLockV14Eligibility is HatsEligibilityModule, ILockKeyPurchaseHook
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/

function keyPurchaseToken() public view returns (address) {
/// @notice Convenience function to get the key purchase token address from the lock
function keyPurchaseToken() external view returns (address) {
return lock.tokenAddress();
}

/// @notice Convenience function to get the expiration duration from the lock
function expirationDuration() external view returns (uint256) {
return lock.expirationDuration();
}

/// @notice Convenience function to get the max number of keys from the lock
function maxNumberOfKeys() external view returns (uint256) {
return lock.maxNumberOfKeys();
}

/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
Expand Down
32 changes: 32 additions & 0 deletions test/PublicLockEligibility.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,35 @@ contract KeyPurchaseToken is WithInstanceTest {
assertEq(instance.keyPurchaseToken(), token);
}
}

contract ExpirationDuration is WithInstanceTest {
function test_happy() public {
lock = _getLock();

assertEq(instance.expirationDuration(), lockConfig.expirationDuration);

// change the expiration duration
uint256 newDuration = lockConfig.expirationDuration + 1;
vm.prank(lockManager);
lock.updateLockConfig(newDuration, lockConfig.maxNumberOfKeys, 1);

// the new duration should be returned
assertEq(instance.expirationDuration(), newDuration);
}
}

contract MaxNumberOfKeys is WithInstanceTest {
function test_happy() public {
lock = _getLock();

assertEq(instance.maxNumberOfKeys(), lockConfig.maxNumberOfKeys);

// change the max number of keys
uint256 newMaxNumberOfKeys = lockConfig.maxNumberOfKeys + 1;
vm.prank(lockManager);
lock.updateLockConfig(lockConfig.expirationDuration, newMaxNumberOfKeys, 1);

// the new max number of keys should be returned
assertEq(instance.maxNumberOfKeys(), newMaxNumberOfKeys);
}
}

0 comments on commit 310c30f

Please sign in to comment.