Skip to content

Commit

Permalink
fix: rename in GATING_BADGE_TOKEN_ID to be more general
Browse files Browse the repository at this point in the history
  • Loading branch information
yum0e committed Jan 12, 2023
1 parent c0dd999 commit 55c54a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions contracts/tests/zk-drop/ZKBadgeboundERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {Context} from '@openzeppelin/contracts/utils/Context.sol';
*/

contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pausable {
uint256 public immutable MERGOOOR_PASS_BADGE_TOKEN_ID;
uint256 public immutable GATING_BADGE_TOKEN_ID;

string private _baseTokenURI;

Expand All @@ -36,9 +36,9 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
string memory name,
string memory symbol,
string memory baseTokenURI,
uint256 passTokenId
uint256 gatingBadgeTokenId
) {
MERGOOOR_PASS_BADGE_TOKEN_ID = passTokenId;
GATING_BADGE_TOKEN_ID = gatingBadgeTokenId;
initialize(name, symbol, baseTokenURI);
}

Expand All @@ -56,7 +56,7 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
* @dev Mints a NFT and transfers it to the account that holds the ZK Badge
* @notice The account that calls this function must hold a ZK Badge with the id MERGOOOR_PASS_BADGE_TOKEN_ID
*/
function claim() public onlyBadgeHolders(MERGOOOR_PASS_BADGE_TOKEN_ID) {
function claim() public onlyBadgeHolders(GATING_BADGE_TOKEN_ID) {
uint256 nullifier = _getNulliferOfBadge(_msgSender());

_mint(_msgSender(), nullifier);
Expand All @@ -68,7 +68,7 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
* @notice The address `to` must hold a ZK Badge with the id MERGOOOR_PASS_BADGE_TOKEN_ID
*/
function claimTo(address to) public {
_requireBadge(to, MERGOOOR_PASS_BADGE_TOKEN_ID);
_requireBadge(to, GATING_BADGE_TOKEN_ID);
uint256 badgeNullifier = _getNulliferOfBadge(to);
if (badgeNullifier == 0) {
revert BadgeNullifierZeroNotAllowed();
Expand Down Expand Up @@ -99,7 +99,7 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
address to,
uint256 tokenId
) public override(ERC721Upgradeable) {
_requireBadge(to, MERGOOOR_PASS_BADGE_TOKEN_ID);
_requireBadge(to, GATING_BADGE_TOKEN_ID);
uint256 badgeNullifier = _getNulliferOfBadge(to);
if (badgeNullifier == 0) {
revert BadgeNullifierZeroNotAllowed();
Expand All @@ -116,7 +116,7 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
address to,
uint256 tokenId
) public override(ERC721Upgradeable) {
_requireBadge(to, MERGOOOR_PASS_BADGE_TOKEN_ID);
_requireBadge(to, GATING_BADGE_TOKEN_ID);
uint256 badgeNullifier = _getNulliferOfBadge(to);
if (badgeNullifier == 0) {
revert BadgeNullifierZeroNotAllowed();
Expand Down Expand Up @@ -175,7 +175,7 @@ contract ZKBadgeboundERC721 is ERC721Upgradeable, UsingSismo, AccessControl, Pau
* @param to destination address referenced in the proof with this nullifier
*/
function _getNulliferOfBadge(address to) internal view returns (uint256) {
bytes memory extraData = BADGES.getBadgeExtraData(to, MERGOOOR_PASS_BADGE_TOKEN_ID);
bytes memory extraData = BADGES.getBadgeExtraData(to, GATING_BADGE_TOKEN_ID);
return HYDRA_S1_ACCOUNTBOUND_ATTESTER.getNullifierFromExtraData(extraData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function deploymentAction(
name: 'Ziki Pass',
symbol: 'ZKP',
tokenURI: 'https://metadata-zikies.zkdrop.io/ziki-pass/123',
passTokenId: '515',
gatingBadgeTokenId: '515',
options,
})) as DeployedZkBadgeboundERC721;

Expand Down
8 changes: 4 additions & 4 deletions tasks/deploy-tasks/tests/deploy-zk-badgebound-erc721.task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface DeployZKBadgeboundERC721Args {
name: string;
symbol: string;
tokenURI: string;
passTokenId: number;
gatingBadgeTokenId: number;
options?: DeployOptions;
}

Expand All @@ -26,12 +26,12 @@ export interface DeployedZkBadgeboundERC721 {
const CONTRACT_NAME = 'ZKBadgeboundERC721';

async function deploymentAction(
{ name, symbol, tokenURI, passTokenId, options }: DeployZKBadgeboundERC721Args,
{ name, symbol, tokenURI, gatingBadgeTokenId, options }: DeployZKBadgeboundERC721Args,
hre: HardhatRuntimeEnvironment
) {
const deployer = await getDeployer(hre);
const deploymentName = buildDeploymentName(CONTRACT_NAME, options?.deploymentNamePrefix);
const deploymentArgs = [name, symbol, tokenURI, passTokenId];
const deploymentArgs = [name, symbol, tokenURI, gatingBadgeTokenId];

await beforeDeployment(hre, deployer, CONTRACT_NAME, deploymentArgs, options);

Expand Down Expand Up @@ -59,5 +59,5 @@ task('deploy-zk-badgebound-erc721')
.addParam('name', 'Name of the token')
.addParam('symbol', 'Symbol of the token')
.addParam('tokenURI', 'Token URI')
.addParam('passTokenId', 'Token ID of the pass token')
.addParam('gatingBadgeTokenId', 'gatingBadgeTokenId')
.setAction(wrapCommonDeployOptions(deploymentAction));
6 changes: 3 additions & 3 deletions test/unit/periphery/zk-drop/zk-badgebound-erc721.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('Test ZK Badgebound ERC721 Contract', async () => {
name: 'Ziki Pass',
symbol: 'ZKP',
tokenURI: 'https://test.com/zikipass',
passTokenId: badgeId.toString(),
gatingBadgeTokenId: badgeId.toString(),
options: { deploymentNamePrefix: 'zk-badgebound-erc721' },
}));

Expand Down Expand Up @@ -155,7 +155,7 @@ describe('Test ZK Badgebound ERC721 Contract', async () => {
it('should check the contract configuration', async () => {
expect(await zkBadgeboundERC721.name()).to.be.eql('Ziki Pass');
expect(await zkBadgeboundERC721.symbol()).to.equal('ZKP');
expect(await zkBadgeboundERC721.MERGOOOR_PASS_BADGE_TOKEN_ID()).to.be.eql(badgeId);
expect(await zkBadgeboundERC721.GATING_BADGE_TOKEN_ID()).to.be.eql(badgeId);
});
});

Expand Down Expand Up @@ -986,7 +986,7 @@ describe('Test ZK Badgebound ERC721 Contract', async () => {
name: 'Ziki Pass',
symbol: 'ZKP',
tokenURI: 'https://test.com/zikipass',
passTokenId: badgeId.toString(),
gatingBadgeTokenId: badgeId.toString(),
options: { deploymentNamePrefix: 'zk-badgebound-erc721-new-implem', behindProxy: false },
}
);
Expand Down

0 comments on commit 55c54a6

Please sign in to comment.