import { BigInt , Bytes , store } from '@graphprotocol/graph-ts' ; import { NewMultiCallProposal , ProposalCallExecuted , ProposalExecuted , } from '../../types/GenericSchemeMultiCall/GenericSchemeMultiCall' ; import * as domain from '../../domain' ; import { getProposal } from '../../domain/proposal' ; import { GenericSchemeMultiCallProposal , GenericSchemeParam , } from '../../types/schema' ; import { CLOSING_AT_TIME_DECREASE_GSMC , CLOSING_AT_TIME_INCREASE } from '../../utils' ; function insertNewProposal ( event ) { let ent = new GenericSchemeMultiCallProposal ( event . params . _proposalId . toHex ( ) ) ; ent . dao = event . params . _avatar . toHex ( ) ; ent . contractsToCall = event . params . _contractsToCall as Bytes [ ] ; ent . callsData = event . params . _callsData ; ent . values = event . params . _values ; ent . executed = false ; store . set ( 'GenericSchemeMultiCallProposal' , event . params . _proposalId . toHex ( ) , ent ) ; } export function handleNewMultiCallProposal ( event ) { domain . handleNewMultiCallProposal ( event . params . _avatar , event . params . _proposalId , event . block . timestamp , event . params . _descriptionHash , event . address ) ; insertNewProposal ( event ) ; } export function handleProposalCallExecuted ( event ) { let ent = store . get ( 'GenericSchemeMultiCallProposal' , event . params . _proposalId . toHex ( ) ) as GenericSchemeMultiCallProposal ; if ( ent != null ) { let returnValues = ent . returnValues ; if ( returnValues == null ) { returnValues = [ ] ; } returnValues . push ( event . params . _callDataReturnValue ) ; ent . returnValues = returnValues ; } store . set ( 'GenericSchemeMultiCallProposal' , event . params . _proposalId . toHex ( ) , ent ) ; } export function handleProposalExecuted ( event ) { let ent = store . get ( 'GenericSchemeMultiCallProposal' , event . params . _proposalId . toHex ( ) ) as GenericSchemeMultiCallProposal ; if ( ent != null ) { ent . executed = true ; let proposal = getProposal ( event . params . _proposalId . toHex ( ) ) ; proposal . closingAt = ( BigInt . fromI32 ( CLOSING_AT_TIME_INCREASE ) . minus ( proposal . closingAt . plus ( BigInt . fromI32 ( CLOSING_AT_TIME_DECREASE_GSMC ) ) ) ) . times ( BigInt . fromI32 ( 100 ) ) ; proposal . save ( ) ; } store . set ( 'GenericSchemeMultiCallProposal' , event . params . _proposalId . toHex ( ) , ent ) ; }