Skip to content

Instantly share code, notes, and snippets.

@juanigallo
Created March 7, 2022 16:20
Show Gist options
  • Save juanigallo/5da4e97902c62c50dd6b3312dde3daca to your computer and use it in GitHub Desktop.
Save juanigallo/5da4e97902c62c50dd6b3312dde3daca to your computer and use it in GitHub Desktop.
import {
AddSubmission,
VouchAdded,
VouchRemoved
} from "../generated/ProofOfHumanity/ProofOfHumanity";
import { User } from "../generated/schema";
export function handleVouchAdded(event: VouchAdded): void {
let user = User.load(event.transaction.from.toHex());
if (user == null) return;
let vouches = user.vouches;
vouches.push(event.params._submissionID.toHex());
user.vouches = vouches;
user.save();
}
export function handleAddSubmission(event: AddSubmission): void {
let user = new User(event.params._submissionID.toHex());
user.vouches = new Array<string>();
user.registerDate = event.block.timestamp;
user.save();
}
type User @entity {
id: ID!
vouches: [User!]!
registerDate: BigInt!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment