Skip to content

Commit

Permalink
add token getter
Browse files Browse the repository at this point in the history
  • Loading branch information
spengrah committed Jul 3, 2024
1 parent 1340acd commit 882288d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/PublicLockV14Eligibility.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ contract PublicLockV14Eligibility is HatsEligibilityModule, ILockKeyPurchaseHook
revert NotTransferable();
}

/*//////////////////////////////////////////////////////////////
VIEW FUNCTIONS
//////////////////////////////////////////////////////////////*/

function keyPurchaseToken() public view returns (address) {
return lock.tokenAddress();
}

/*//////////////////////////////////////////////////////////////
INTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
Expand Down
20 changes: 20 additions & 0 deletions test/PublicLockEligibility.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 882288d

Please sign in to comment.