@@ -10,8 +10,10 @@ import (
10
10
"github.com/golang/protobuf/proto"
11
11
"github.com/iotexproject/go-pkgs/hash"
12
12
"github.com/iotexproject/iotex-proto/golang/iotextypes"
13
+ "go.uber.org/zap"
13
14
14
15
"github.com/iotexproject/iotex-core/action"
16
+ "github.com/iotexproject/iotex-core/pkg/log"
15
17
"github.com/iotexproject/iotex-core/pkg/util/byteutil"
16
18
)
17
19
@@ -154,15 +156,18 @@ func ReceiptTransactionLog(r *action.Receipt) *TransactionLog {
154
156
}
155
157
156
158
// LogTokenTxRecord generates token transaction record from log
157
- func LogTokenTxRecord (log * action.Log ) * TokenTxRecord {
158
- if log == nil || ! log .IsTransactionLog () {
159
+ func LogTokenTxRecord (l * action.Log ) * TokenTxRecord {
160
+ if l == nil || ! l .IsTransactionLog () {
159
161
return nil
160
162
}
163
+ if l .TransactionData .Amount .Sign () < 0 {
164
+ log .L ().Panic ("Negative amount transaction log." , zap .Any ("TransactionLog" , l .TransactionData ))
165
+ }
161
166
162
167
return & TokenTxRecord {
163
- sender : log .TransactionData .Sender ,
164
- recipient : log .TransactionData .Recipient ,
165
- amount : log .TransactionData .Amount .String (),
166
- typ : log .TransactionData .Type ,
168
+ sender : l .TransactionData .Sender ,
169
+ recipient : l .TransactionData .Recipient ,
170
+ amount : l .TransactionData .Amount .String (),
171
+ typ : l .TransactionData .Type ,
167
172
}
168
173
}
0 commit comments