import { Address , BigInt , store } from '@graphprotocol/graph-ts' ; import { ProposalStake } from '../types/schema' ; import { addStakeEvent } from './event' ; export function getStake ( id ) { let stake = store . get ( 'ProposalStake' , id ) as ProposalStake ; if ( stake == null ) { stake = new ProposalStake ( id ) ; } return stake ; } export function saveStake ( stake ) { store . set ( 'ProposalStake' , stake . id , stake ) ; } export function insertStake ( eventId , timestamp , staker , amount , proposalId , daoId , outcome ) { let stake = getStake ( eventId ) ; stake . createdAt = timestamp ; stake . staker = staker ; stake . amount = amount ; stake . proposal = proposalId ; stake . dao = daoId ; stake . outcome = outcome ; saveStake ( stake ) ; addStakeEvent ( eventId , proposalId , outcome , amount , staker , daoId , timestamp ) ; }