Created
March 7, 2022 16:20
-
-
Save juanigallo/5da4e97902c62c50dd6b3312dde3daca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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