Skip to Content

Registry

A simple registry to handle eligibility for funding (or keeping track of project addresses for other purposes).

Metadata can be sent for both registration (Application) and approving (Review).

The first registration for an address becomes the registration for the project and the following registrations are applications.

This allows us to handle project details, applications, and reviews in one primitive.

event Register(address indexed project, uint256 indexed index, string metadataURI, bytes data); event Approve(address indexed project, uint256 indexed index, string metadataURI, bytes data); enum Status { pending, approved } struct Registration { Status status; address owner; bytes data; // Data can contain information that can be accessed later } mapping(address => mapping(uint256 => Registration)) public projects; function _register(address recipient, string calldata metadataURI, bytes calldata data) internal virtual {} function _approve(address recipient, string calldata metadataURI, bytes calldata data) internal virtual {}
Examples
// Only Strategy owner can approve projects contract ExampleStrategy is Registry, Ownable { function approve(address recipient, string calldata metadataURI, bytes calldata data) public override onlyOwner { _approve(recipient, metadataURI, data); } } // Auto-approve projects on registration contract SimpleGrants is Strategy, Allocator, Registry, Ownable { function register(address project, string memory metadataURI, bytes memory data) public override { _register(project, metadataURI, data); _approve(project, 0, "", ""); // Auto-approve projects } }

Indexer GraphQL Query

{ registrations(where: { strategy_in: ["0xYourContract"] }) { items { id index # 0 for initial project registration, >= 1 for applications isApproved # Status is updated on Approve event metadata # Contains the fetched metadataURI review # Contains the fetched metadataURI for the Approve event strategy { address name } } } }

Hooks

export function YourComponent() { const { YourStrategy } = useContracts(); const strategyAddress = YourContract?.address; // Register new Project or Application const register = useRegister({ strategyAddress }); // List Projects const projects = useRegistrations({ where: { strategy_in: [strategyAddress], index: 0, }, }); // List Applications to approve const applications = useRegistrations({ where: { strategy_in: [strategyAddress], index_not: 0, isApproved: false, }, }); // Approve Project or Application const approve = useRegistryApprove({ strategyAddress }); ... }

Components

RegistrationForm

The RegistrationForm component can be used to register projects or applications.

import { RegistrationForm } from "~/components/registration/registration-form"; export default function CreateProjectPage() { const router = useRouter(); const { YourStrategy } = useContracts(); return ( <RegistrationForm defaultValues={{}} strategyAddress={YourStrategy?.address} onSuccess={({ project }) => router.push(`/projects/${project}`)} /> ); }

ApplicationsList

ApplicationsList show incoming applications and a button to approve.

import { ApplicationsList } from "~/components/registration/applications-list"; export default function ApproveApplicationsPage() { const { YourStrategy } = useContracts(); return ( <ApplicationsList query={{ where: { strategy_in: [YourStrategy?.address], index_not: 0, isApproved: false, }, }} /> ); }

ProjectsList

ProjectsList show projects in a Grid view.

import { ProjectsList } from "~/components/registration/projects-list"; export default function ProjectsDiscoverPage() { return ( <ProjectsList query={{ where: { strategy_in: [YourStrategy?.address], index: 0, // Only Projects - not applications }, }} /> ); }

ApproveButton

import { RegistrationApproveButton } from "~/components/registration/registration-button"; export default function ApproveApplicationsPage() { const { registrationId } = useParams({ registrationId: string }); return <RegistrationApproveButton id={registrationId} />; }
Last updated on