@@ -51,25 +51,26 @@ func (h Handler) GetEvent(ctx context.Context, params oas.GetEventParams) (oas.G
51
51
if err != nil {
52
52
return & oas.InternalError {Error : err .Error ()}, nil
53
53
}
54
- b := bath .FromTrace (trace )
55
- bath .MergeAllBubbles (b , bath .DefaultStraws )
56
- actions , fees := bath .CollectActions (b , nil )
54
+ result , err := bath .FindActions (trace )
55
+ if err != nil {
56
+ return nil , err
57
+ }
57
58
event := oas.Event {
58
59
EventID : trace .Hash .Hex (),
59
60
Timestamp : trace .Utime ,
60
- Actions : make ([]oas.Action , len (actions )),
61
- Fees : make ([]oas.Fee , len (fees )),
61
+ Actions : make ([]oas.Action , len (result . Actions )),
62
+ ValueFlow : make ([]oas.ValueFlow , 0 , len (result . ValueFlow . Accounts )),
62
63
IsScam : false ,
63
64
Lt : int64 (trace .Lt ),
64
65
InProgress : trace .InProgress (),
65
66
}
66
- for i , a := range actions {
67
+ for i , a := range result . Actions {
67
68
convertedAction , spamDetected := h .convertAction (ctx , a )
68
69
event .IsScam = event .IsScam || spamDetected
69
70
event .Actions [i ] = convertedAction
70
71
}
71
- for i , f := range fees {
72
- event .Fees [ i ] = convertFees ( f , h .addressBook )
72
+ for accountID , flow := range result . ValueFlow . Accounts {
73
+ event .ValueFlow = append ( event . ValueFlow , convertAccountValueFlow ( accountID , flow , h .addressBook ) )
73
74
}
74
75
return & event , nil
75
76
}
@@ -90,9 +91,10 @@ func (h Handler) GetEventsByAccount(ctx context.Context, params oas.GetEventsByA
90
91
if err != nil {
91
92
return & oas.InternalError {Error : err .Error ()}, nil
92
93
}
93
- b := bath .FromTrace (trace )
94
- bath .MergeAllBubbles (b , bath .DefaultStraws )
95
- actions , fees := bath .CollectActions (b , & account )
94
+ result , err := bath .FindActions (trace )
95
+ if err != nil {
96
+ return & oas.InternalError {Error : err .Error ()}, nil
97
+ }
96
98
e := oas.AccountEvent {
97
99
EventID : trace .Hash .Hex (),
98
100
Account : convertAccountAddress (account , h .addressBook ),
@@ -102,13 +104,10 @@ func (h Handler) GetEventsByAccount(ctx context.Context, params oas.GetEventsByA
102
104
Lt : int64 (trace .Lt ),
103
105
InProgress : trace .InProgress (),
104
106
}
105
- for _ , f := range fees {
106
- if f .WhoPay == account {
107
- e .Fee = convertFees (f , h .addressBook )
108
- break
109
- }
107
+ if flow , ok := result .ValueFlow .Accounts [account ]; ok {
108
+ e .ValueFlow = convertAccountValueFlow (account , flow , h .addressBook )
110
109
}
111
- for _ , a := range actions {
110
+ for _ , a := range result . Actions {
112
111
convertedAction , spamDetected := h .convertAction (ctx , a )
113
112
if ! e .IsScam && spamDetected {
114
113
e .IsScam = true
0 commit comments