Skip to content

Commit

Permalink
Tasks: Track time lock config (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: Facu Spagnuolo <[email protected]>
  • Loading branch information
PatricioHenderson and facuspagnuolo authored Aug 25, 2023
1 parent c010f73 commit 9dd5c1c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type Task @entity {
priorityFeeLimit: BigInt!
txCostLimitPct: BigInt!
txCostLimit: BigInt!
timeLockDelay: BigInt!
timeLockExecutionPeriod: BigInt!
timeLockExpiration: BigInt!
}

type Movement @entity {
Expand Down
3 changes: 3 additions & 0 deletions src/Deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export function handleTaskDeployed(event: TaskDeployed): void {
task.priorityFeeLimit = BigInt.zero()
task.txCostLimitPct = BigInt.zero()
task.txCostLimit = BigInt.zero()
task.timeLockDelay = BigInt.zero()
task.timeLockExecutionPeriod = BigInt.zero()
task.timeLockExpiration = BigInt.zero()
task.save()

TaskTemplate.create(event.params.instance)
Expand Down
28 changes: 28 additions & 0 deletions src/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import {
PriorityFeeLimitSet,
TxCostLimitPctSet,
TxCostLimitSet,
TimeLockDelaySet,
TimeLockExecutionPeriodSet,
TimeLockExpirationSet
} from '../types/templates/Task/Task'
import { Task as TaskContract } from '../types/templates/Task/Task'

Expand Down Expand Up @@ -52,6 +55,30 @@ export function handleTxCostLimitSet(event: TxCostLimitSet): void {
task.save()
}

export function handleTimeLockDelaySet(event : TimeLockDelaySet): void {
let task = Task.load(event.address.toHexString())
if (task == null) return log.warning('Missing task entity {}', [event.address.toHexString()])

task.timeLockDelay = event.params.delay
task.save()
}

export function handleTimeLockExecutionPeriodSet(event: TimeLockExecutionPeriodSet): void {
let task = Task.load(event.address.toHexString())
if (task == null) return log.warning('Missing task entity {}', [event.address.toHexString()])

task.timeLockExecutionPeriod = event.params.period
task.save()
}

export function handleTimeLockExpirationSet(event: TimeLockExpirationSet): void {
let task = Task.load(event.address.toHexString())
if (task == null) return log.warning('Missing task entity {}', [event.address.toHexString()])

task.timeLockExpiration = event.params.expiration
task.save()
}

export function getSmartVault(address: Address): Address {
let taskContract = TaskContract.bind(address)
let smartVaultCall = taskContract.try_smartVault()
Expand Down Expand Up @@ -87,3 +114,4 @@ export function getExecutionType(address: Address): Bytes {
log.warning('EXECUTION_TYPE() call reverted for task {}', [address.toHexString()])
return Bytes.fromUTF8('')
}

6 changes: 6 additions & 0 deletions subgraph.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,10 @@ templates:
handler: handleTxCostLimitPctSet
- event: TxCostLimitSet(uint256)
handler: handleTxCostLimitSet
- event: TimeLockDelaySet(uint256)
handler: handleTimeLockDelaySet
- event: TimeLockExecutionPeriodSet(uint256)
handler: handleTimeLockExecutionPeriodSet
- event: TimeLockExpirationSet(uint256)
handler: handleTimeLockExpirationSet
file: ./src/Task.ts

0 comments on commit 9dd5c1c

Please sign in to comment.