@@ -73,9 +73,19 @@ func finalizeBlockResponse(
73
73
) (* abci.FinalizeBlockResponse , error ) {
74
74
allEvents := append (in .BeginBlockEvents , in .EndBlockEvents ... )
75
75
76
+ events , err := intoABCIEvents (allEvents , indexSet )
77
+ if err != nil {
78
+ return nil , err
79
+ }
80
+
81
+ txResults , err := intoABCITxResults (in .TxResults , indexSet )
82
+ if err != nil {
83
+ return nil , err
84
+ }
85
+
76
86
resp := & abci.FinalizeBlockResponse {
77
- Events : intoABCIEvents ( allEvents , indexSet ) ,
78
- TxResults : intoABCITxResults ( in . TxResults , indexSet ) ,
87
+ Events : events ,
88
+ TxResults : txResults ,
79
89
ValidatorUpdates : intoABCIValidatorUpdates (in .ValidatorUpdates ),
80
90
AppHash : appHash ,
81
91
ConsensusParamUpdates : cp ,
@@ -97,7 +107,7 @@ func intoABCIValidatorUpdates(updates []appmodulev2.ValidatorUpdate) []abci.Vali
97
107
return valsetUpdates
98
108
}
99
109
100
- func intoABCITxResults (results []server.TxResult , indexSet map [string ]struct {}) []* abci.ExecTxResult {
110
+ func intoABCITxResults (results []server.TxResult , indexSet map [string ]struct {}) ( []* abci.ExecTxResult , error ) {
101
111
res := make ([]* abci.ExecTxResult , len (results ))
102
112
for i := range results {
103
113
if results [i ].Error != nil {
@@ -110,29 +120,36 @@ func intoABCITxResults(results []server.TxResult, indexSet map[string]struct{})
110
120
111
121
continue
112
122
}
113
-
123
+ events , err := intoABCIEvents (results [i ].Events , indexSet )
124
+ if err != nil {
125
+ return nil , err
126
+ }
114
127
res [i ] = responseExecTxResultWithEvents (
115
128
results [i ].Error ,
116
129
results [i ].GasWanted ,
117
130
results [i ].GasUsed ,
118
- intoABCIEvents ( results [ i ]. Events , indexSet ) ,
131
+ events ,
119
132
false ,
120
133
)
121
134
}
122
135
123
- return res
136
+ return res , nil
124
137
}
125
138
126
- func intoABCIEvents (events []event.Event , indexSet map [string ]struct {}) []abci.Event {
139
+ func intoABCIEvents (events []event.Event , indexSet map [string ]struct {}) ( []abci.Event , error ) {
127
140
indexAll := len (indexSet ) == 0
128
141
abciEvents := make ([]abci.Event , len (events ))
129
142
for i , e := range events {
143
+ attributes , err := e .Attributes ()
144
+ if err != nil {
145
+ return nil , err
146
+ }
130
147
abciEvents [i ] = abci.Event {
131
148
Type : e .Type ,
132
- Attributes : make ([]abci.EventAttribute , len (e . Attributes )),
149
+ Attributes : make ([]abci.EventAttribute , len (attributes )),
133
150
}
134
151
135
- for j , attr := range e . Attributes {
152
+ for j , attr := range attributes {
136
153
_ , index := indexSet [fmt .Sprintf ("%s.%s" , e .Type , attr .Key )]
137
154
abciEvents [i ].Attributes [j ] = abci.EventAttribute {
138
155
Key : attr .Key ,
@@ -141,19 +158,23 @@ func intoABCIEvents(events []event.Event, indexSet map[string]struct{}) []abci.E
141
158
}
142
159
}
143
160
}
144
- return abciEvents
161
+ return abciEvents , nil
145
162
}
146
163
147
164
func intoABCISimulationResponse (txRes server.TxResult , indexSet map [string ]struct {}) ([]byte , error ) {
148
165
indexAll := len (indexSet ) == 0
149
166
abciEvents := make ([]abci.Event , len (txRes .Events ))
150
167
for i , e := range txRes .Events {
168
+ attributes , err := e .Attributes ()
169
+ if err != nil {
170
+ return nil , err
171
+ }
151
172
abciEvents [i ] = abci.Event {
152
173
Type : e .Type ,
153
- Attributes : make ([]abci.EventAttribute , len (e . Attributes )),
174
+ Attributes : make ([]abci.EventAttribute , len (attributes )),
154
175
}
155
176
156
- for j , attr := range e . Attributes {
177
+ for j , attr := range attributes {
157
178
_ , index := indexSet [fmt .Sprintf ("%s.%s" , e .Type , attr .Key )]
158
179
abciEvents [i ].Attributes [j ] = abci.EventAttribute {
159
180
Key : attr .Key ,
0 commit comments