@@ -75,11 +75,14 @@ func (r *Reconciler1) GetStatements1(pos *types.AppPosition, trans *types.Transa
75
75
76
76
if r .opts .UseTraces || ! reconciled {
77
77
results = make ([]types.Statement , 0 , 20 ) /* reset this */
78
- if s , err := r .getStatementFromTraces (pos , trans , & s ); err != nil {
78
+ if stmt , err := r .getStatementFromTraces (pos , trans , & s ); err != nil {
79
79
logger .Warn (colors .Yellow + "Statement at " , fmt .Sprintf ("%d.%d" , trans .BlockNumber , trans .TransactionIndex ), " does not reconcile." + colors .Off )
80
80
} else {
81
- _ , _ = r .trialBalance (pos , trans , s )
82
- results = append (results , * s )
81
+ if _ , err = r .trialBalance (pos , trans , stmt ); err != nil {
82
+ return nil , err
83
+ } else {
84
+ results = append (results , * stmt )
85
+ }
83
86
}
84
87
}
85
88
}
@@ -109,31 +112,59 @@ func (r *Reconciler1) GetStatements1(pos *types.AppPosition, trans *types.Transa
109
112
results = append (results , receiptStatements ... )
110
113
}
111
114
}
112
-
113
115
return results , nil
114
116
}
115
117
118
+ func (r * Reconciler1 ) NewStatement (trans * types.Transaction ) * types.Statement {
119
+ sym := "WEI"
120
+ if r .opts .AsEther {
121
+ sym = "ETH"
122
+ }
123
+ to := trans .To
124
+ if trans .To .IsZero () && trans .Receipt != nil && ! trans .Receipt .ContractAddress .IsZero () {
125
+ to = trans .Receipt .ContractAddress
126
+ }
127
+
128
+ return & types.Statement {
129
+ AccountedFor : r .opts .AccountFor ,
130
+ Sender : trans .From ,
131
+ Recipient : to ,
132
+ BlockNumber : trans .BlockNumber ,
133
+ TransactionIndex : trans .TransactionIndex ,
134
+ TransactionHash : trans .Hash ,
135
+ Timestamp : trans .Timestamp ,
136
+ Asset : base .FAKE_ETH_ADDRESS ,
137
+ Symbol : sym ,
138
+ Decimals : 18 ,
139
+ PriceSource : "not-priced" ,
140
+ }
141
+ }
142
+
143
+ func (r * Reconciler1 ) getStatementFromTransaction (trans * types.Transaction ) * types.Statement {
144
+ return nil
145
+ }
146
+
116
147
func (r * Reconciler1 ) getStatementFromTraces (pos * types.AppPosition , trans * types.Transaction , s * types.Statement ) (* types.Statement , error ) {
117
148
118
- ret := * s
149
+ stmt := * s
119
150
// clear all the internal accounting values. Keeps AmountIn, AmountOut and GasOut because
120
151
// those are at the top level (both the transaction itself and trace '0' have them). We
121
152
// skip trace '0' because it's the same as the transaction.
122
- // ret .AmountIn.SetUint64(0)
123
- ret .InternalIn .SetUint64 (0 )
124
- ret .MinerBaseRewardIn .SetUint64 (0 )
125
- ret .MinerNephewRewardIn .SetUint64 (0 )
126
- ret .MinerTxFeeIn .SetUint64 (0 )
127
- ret .MinerUncleRewardIn .SetUint64 (0 )
128
- ret .CorrectingIn .SetUint64 (0 )
129
- ret .PrefundIn .SetUint64 (0 )
130
- ret .SelfDestructIn .SetUint64 (0 )
153
+ // stmt .AmountIn.SetUint64(0)
154
+ stmt .InternalIn .SetUint64 (0 )
155
+ stmt .MinerBaseRewardIn .SetUint64 (0 )
156
+ stmt .MinerNephewRewardIn .SetUint64 (0 )
157
+ stmt .MinerTxFeeIn .SetUint64 (0 )
158
+ stmt .MinerUncleRewardIn .SetUint64 (0 )
159
+ stmt .CorrectingIn .SetUint64 (0 )
160
+ stmt .PrefundIn .SetUint64 (0 )
161
+ stmt .SelfDestructIn .SetUint64 (0 )
131
162
132
- // ret .AmountOut.SetUint64(0)
133
- // ret .GasOut.SetUint64(0)
134
- ret .InternalOut .SetUint64 (0 )
135
- ret .CorrectingOut .SetUint64 (0 )
136
- ret .SelfDestructOut .SetUint64 (0 )
163
+ // stmt .AmountOut.SetUint64(0)
164
+ // stmt .GasOut.SetUint64(0)
165
+ stmt .InternalOut .SetUint64 (0 )
166
+ stmt .CorrectingOut .SetUint64 (0 )
167
+ stmt .SelfDestructOut .SetUint64 (0 )
137
168
138
169
if traces , err := r .opts .Connection .GetTracesByTransactionHash (trans .Hash .Hex (), trans ); err != nil {
139
170
return nil , err
@@ -157,59 +188,59 @@ func (r *Reconciler1) getStatementFromTraces(pos *types.AppPosition, trans *type
157
188
158
189
// Do not collapse, more than one of these can be true at the same time
159
190
if trace .Action .From == s .AccountedFor {
160
- ret .InternalOut = plusEq (& ret .InternalOut , & trace .Action .Value )
161
- ret .Sender = trace .Action .From
191
+ stmt .InternalOut = plusEq (& stmt .InternalOut , & trace .Action .Value )
192
+ stmt .Sender = trace .Action .From
162
193
if trace .Action .To .IsZero () {
163
194
if trace .Result != nil {
164
- ret .Recipient = trace .Result .Address
195
+ stmt .Recipient = trace .Result .Address
165
196
}
166
197
} else {
167
- ret .Recipient = trace .Action .To
198
+ stmt .Recipient = trace .Action .To
168
199
}
169
200
}
170
201
171
202
if trace .Action .To == s .AccountedFor {
172
- ret .InternalIn = plusEq (& ret .InternalIn , & trace .Action .Value )
173
- ret .Sender = trace .Action .From
174
- ret .Recipient = trace .Action .To
203
+ stmt .InternalIn = plusEq (& stmt .InternalIn , & trace .Action .Value )
204
+ stmt .Sender = trace .Action .From
205
+ stmt .Recipient = trace .Action .To
175
206
}
176
207
177
208
if trace .Action .SelfDestructed == s .AccountedFor {
178
- ret .SelfDestructOut = plusEq (& ret .SelfDestructOut , & trace .Action .Balance )
179
- ret .Sender = trace .Action .SelfDestructed
180
- if ret .Sender .IsZero () {
181
- ret .Sender = trace .Action .Address
209
+ stmt .SelfDestructOut = plusEq (& stmt .SelfDestructOut , & trace .Action .Balance )
210
+ stmt .Sender = trace .Action .SelfDestructed
211
+ if stmt .Sender .IsZero () {
212
+ stmt .Sender = trace .Action .Address
182
213
}
183
- ret .Recipient = trace .Action .RefundAddress
214
+ stmt .Recipient = trace .Action .RefundAddress
184
215
}
185
216
186
217
if trace .Action .RefundAddress == s .AccountedFor {
187
- ret .SelfDestructIn = plusEq (& ret .SelfDestructIn , & trace .Action .Balance )
188
- ret .Sender = trace .Action .SelfDestructed
189
- if ret .Sender .IsZero () {
190
- ret .Sender = trace .Action .Address
218
+ stmt .SelfDestructIn = plusEq (& stmt .SelfDestructIn , & trace .Action .Balance )
219
+ stmt .Sender = trace .Action .SelfDestructed
220
+ if stmt .Sender .IsZero () {
221
+ stmt .Sender = trace .Action .Address
191
222
}
192
- ret .Recipient = trace .Action .RefundAddress
223
+ stmt .Recipient = trace .Action .RefundAddress
193
224
}
194
225
195
226
if trace .Action .Address == s .AccountedFor && ! trace .Action .RefundAddress .IsZero () {
196
- ret .SelfDestructOut = plusEq (& ret .SelfDestructOut , & trace .Action .Balance )
227
+ stmt .SelfDestructOut = plusEq (& stmt .SelfDestructOut , & trace .Action .Balance )
197
228
// self destructed send
198
- ret .Sender = trace .Action .Address
199
- ret .Recipient = trace .Action .RefundAddress
229
+ stmt .Sender = trace .Action .Address
230
+ stmt .Recipient = trace .Action .RefundAddress
200
231
}
201
232
202
233
if trace .Result != nil {
203
234
if trace .Result .Address == s .AccountedFor {
204
- ret .InternalIn = plusEq (& ret .InternalIn , & trace .Action .Value )
205
- ret .Sender = trace .Action .From
206
- ret .Recipient = trace .Result .Address
235
+ stmt .InternalIn = plusEq (& stmt .InternalIn , & trace .Action .Value )
236
+ stmt .Sender = trace .Action .From
237
+ stmt .Recipient = trace .Result .Address
207
238
}
208
239
}
209
240
}
210
241
}
211
242
212
- return & ret , nil
243
+ return & stmt , nil
213
244
}
214
245
215
246
func (r * Reconciler1 ) getStatementsFromLogs (logs []types.Log ) ([]types.Statement , error ) {
0 commit comments