From 882288db49d6a7cf859af68427f55fe1b08f2648 Mon Sep 17 00:00:00 2001 From: spengrah Date: Wed, 3 Jul 2024 16:23:18 -0500 Subject: [PATCH] add token getter --- src/PublicLockV14Eligibility.sol | 8 ++++++++ test/PublicLockEligibility.t.sol | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/PublicLockV14Eligibility.sol b/src/PublicLockV14Eligibility.sol index 02a7835..7ee5f55 100644 --- a/src/PublicLockV14Eligibility.sol +++ b/src/PublicLockV14Eligibility.sol @@ -245,6 +245,14 @@ contract PublicLockV14Eligibility is HatsEligibilityModule, ILockKeyPurchaseHook revert NotTransferable(); } + /*////////////////////////////////////////////////////////////// + VIEW FUNCTIONS + //////////////////////////////////////////////////////////////*/ + + function keyPurchaseToken() public view returns (address) { + return lock.tokenAddress(); + } + /*////////////////////////////////////////////////////////////// INTERNAL FUNCTIONS //////////////////////////////////////////////////////////////*/ diff --git a/test/PublicLockEligibility.t.sol b/test/PublicLockEligibility.t.sol index e41b527..3cffcb9 100644 --- a/test/PublicLockEligibility.t.sol +++ b/test/PublicLockEligibility.t.sol @@ -475,3 +475,23 @@ contract Transfers is WithInstanceTest { lock.transferFrom(wearer, nonWearer, tokenId); } } + +contract KeyPurchaseToken is WithInstanceTest { + function test_ETH() public view { + assertEq(instance.keyPurchaseToken(), address(0)); + } + + function test_ERC20() public { + lock = _getLock(); + + // use a token that definitely has a non-zero total supply + address token = 0x6B175474E89094C44Da98b954EedeAC495271d0F; // dai on mainnet + + // update the token address + vm.prank(lockManager); + lock.updateKeyPricing(lockConfig.keyPrice, token); + + // the new token should be returned + assertEq(instance.keyPurchaseToken(), token); + } +}