Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom entitlement factory to enable POAP gating #905

Closed
wants to merge 15 commits into from

Conversation

brianathere
Copy link
Contributor

@brianathere brianathere commented Aug 27, 2024

Simple ICustomEntitlement deployer that enables creation of a Custom Entitlement per eventId that can be used to gate by POAP Event ID on Gnosis.

@giuseppecrj and I have discussed making it a BeaconProxy so we can change the implementation of isEntitled. I can see both sides of that given the simplicity of this contract and the use case.

Would be nice after using this in anger to improve the ICustomEntitlement interface to also return more information to make the UI in Towns better when people select this contract. @giuseppecrj has another PR to at least add support for detecting contracts claim to implement ICustomEntitlement instead of just evm_call isEntitled to see if the selector is handled. We should consider also a call to return some metadata so the UI can show what the custom entitlement claims, in this case it could have the POAP Event Name.

Still, this is a functional path forward to gating by POAP on Gnosis (and other chains)


import {ICustomEntitlement} from "contracts/src/spaces/entitlements/ICustomEntitlement.sol";

interface IPOAP {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to a different file IPoapEntitlement.sol

) external view returns (uint256 eventId, uint256 tokenId);
}

IPOAP constant poapContract = IPOAP(0x22C1f6050E56d2876009903609a2cC3fEf83B415);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this inside the contract

uint256 public immutable eventId;

constructor(uint256 _eventId) {
require(_eventId > 0, "Invalid event ID");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if with custom error

function isEntitled(
address[] calldata wallets
) external view override returns (bool) {
for (uint256 i = 0; i < wallets.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache wallet length

// Check if the contract is already deployed
uint32 size;
assembly {
size := extcodesize(predictedAddress)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use predictedAddress.code.length instead of assembly

import {Factory} from "contracts/src/utils/Factory.sol";
import {PoapEntitlement} from "./PoapEntitlement.sol";

contract PoapEntitlementFactory is Factory {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide an interface for PoapEntitlementFactory in separate file

}
}

function getEntitlementAddress(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we need this function if we have predictEntitlementAddress or replace with this one

return predictEntitlementAddress(eventId);
}

function getSalt(uint256 eventId) public pure returns (bytes32) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make internal


contract DeployPoapEntitlementFactory is Deployer {
function versionName() public pure override returns (string memory) {
return "DeployPoapEntitlementFactory";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the version name is the name of the contract you're deploying poapEntitlementFactory

address deployment = _deploy(initCode, salt);
if (deployment != predictedAddress) {
revert("Deployment failed");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an event that emits the deployed address

giuseppecrj and others added 14 commits August 28, 2024 15:47
we don’t use it any more and all telemetry is captured in app
…ssed (#767)

#769 

Moves the data inline where appropriate and marks it incompressible.
Doesn't vacuum the miniblocks table because that will take a long time,
need to revisit how/when to do that.

---------

Signed-off-by: Brian Meek <[email protected]>
commit 11fd807
Author: GitHub Action Bot <[email protected]>
Date:   Wed Aug 28 00:20:14 2024 +0000

    sdk-ebcdf9a-0.0.51
Previously, the Myself model was extending a Member model, which
required some special treatment to avoid creating it twice.

Now, the `Myself` model is wrapping a Member with some set actions,
removing the cognitive overhead when changing the `Members` model, since
we dont need to keep the special myself case in mind when doing changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants