forked from joshstevens19/rindexer
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrindexer.yaml
More file actions
102 lines (96 loc) · 2.94 KB
/
Copy pathrindexer.yaml
File metadata and controls
102 lines (96 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Governance Voting Example
# Tracks votes per proposal with compound primary keys
name: GovernanceExample
description: Track governance votes per proposal and voter
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: https://mainnet.gateway.tenderly.co
storage:
postgres:
enabled: true
drop_each_run: true
contracts:
# Compound Governor Bravo
- name: CompoundGovernor
details:
- network: ethereum
address: "0xc0Da02939E1441F497fd74F78cE7Decb17B66529"
start_block: "18600000"
end_block: "18700000" # ~100k blocks for testing
abi: ./abis/Governor.abi.json
tables:
# Individual votes with compound key (proposal_id, voter)
- name: votes
columns:
- name: proposal_id
- name: voter
- name: support # 0 = against, 1 = for, 2 = abstain
type: uint8
- name: voting_power
default: "0"
events:
- event: VoteCast
operations:
- type: upsert
where:
proposal_id: $proposalId
voter: $voter
set:
- column: support
action: set
value: $support
- column: voting_power
action: set
value: $votes
# Aggregated totals per proposal
- name: proposal_totals
columns:
- name: proposal_id
- name: for_votes
default: "0"
- name: against_votes
default: "0"
- name: abstain_votes
default: "0"
- name: total_votes
type: uint64
default: "0"
events:
- event: VoteCast
operations:
# For votes (support == 1)
- type: upsert
where:
proposal_id: $proposalId
if: "$support == 1"
set:
- column: for_votes
action: add
value: $votes
- column: total_votes
action: increment
# Against votes (support == 0)
- type: upsert
where:
proposal_id: $proposalId
if: "$support == 0"
set:
- column: against_votes
action: add
value: $votes
- column: total_votes
action: increment
# Abstain votes (support == 2)
- type: upsert
where:
proposal_id: $proposalId
if: "$support == 2"
set:
- column: abstain_votes
action: add
value: $votes
- column: total_votes
action: increment