@@ -4,9 +4,11 @@ import (
4
4
"context"
5
5
"encoding/hex"
6
6
"fmt"
7
+ "go.uber.org/zap"
7
8
"math/big"
8
9
"sort"
9
10
"strings"
11
+ "sync"
10
12
11
13
"github.com/tonkeeper/tongo/ton"
12
14
@@ -84,12 +86,24 @@ func (h *Handler) convertRisk(ctx context.Context, risk wallet.Risk, walletAddre
84
86
oasRisk .Jettons = append (oasRisk .Jettons , jettonQuantity )
85
87
}
86
88
if len (risk .Nfts ) > 0 {
89
+ var wg sync.WaitGroup
90
+ wg .Add (1 )
91
+ var nftsScamData map [ton.AccountID ]core.TrustType
92
+ var err error
93
+ go func () {
94
+ defer wg .Done ()
95
+ nftsScamData , err = h .spamFilter .GetNftsScamData (ctx , risk .Nfts )
96
+ if err != nil {
97
+ h .logger .Warn ("error getting nft scam data" , zap .Error (err ))
98
+ }
99
+ }()
87
100
items , err := h .storage .GetNFTs (ctx , risk .Nfts )
101
+ wg .Wait ()
88
102
if err != nil {
89
103
return oas.Risk {}, err
90
104
}
91
105
for _ , item := range items {
92
- nft := h .convertNFT (ctx , item , h .addressBook , h .metaCache )
106
+ nft := h .convertNFT (ctx , item , h .addressBook , h .metaCache , nftsScamData [ item . Address ] )
93
107
oasRisk .Nfts = append (oasRisk .Nfts , nft )
94
108
}
95
109
}
@@ -562,7 +576,7 @@ func (h *Handler) convertAction(ctx context.Context, viewer *tongo.AccountID, a
562
576
var name string
563
577
if len (items ) == 1 {
564
578
// opentonapi doesn't implement GetNFTs() now
565
- nft = h .convertNFT (ctx , items [0 ], h .addressBook , h .metaCache )
579
+ nft = h .convertNFT (ctx , items [0 ], h .addressBook , h .metaCache , "" )
566
580
if len (nft .Previews ) > 0 {
567
581
nftImage = nft .Previews [0 ].URL
568
582
}
@@ -700,7 +714,7 @@ func (h *Handler) convertAction(ctx context.Context, viewer *tongo.AccountID, a
700
714
if a .AuctionBid .Nft == nil {
701
715
return oas.Action {}, fmt .Errorf ("nft is nil" )
702
716
}
703
- nft .SetTo (h .convertNFT (ctx , * a .AuctionBid .Nft , h .addressBook , h .metaCache ))
717
+ nft .SetTo (h .convertNFT (ctx , * a .AuctionBid .Nft , h .addressBook , h .metaCache , "" ))
704
718
action .AuctionBid .SetTo (oas.AuctionBidAction {
705
719
Amount : oas.Price {
706
720
Value : fmt .Sprintf ("%v" , a .AuctionBid .Amount ),
@@ -805,7 +819,7 @@ func (h *Handler) toEvent(ctx context.Context, trace *core.Trace, result *bath.A
805
819
}
806
820
event .Actions [i ] = convertedAction
807
821
}
808
- event .IsScam = h .spamFilter .IsScamEvent (event .EventID , event . Actions , nil , trace .Account )
822
+ event .IsScam = h .spamFilter .IsScamEvent (event .Actions , nil , trace .Account , false )
809
823
previews := make (map [tongo.AccountID ]oas.JettonPreview )
810
824
for _ , flow := range result .ValueFlow .Accounts {
811
825
for jettonMaster := range flow .Jettons {
@@ -886,7 +900,7 @@ func (h *Handler) toAccountEvent(ctx context.Context, account tongo.AccountID, t
886
900
e .Actions = append (e .Actions , convertedAction )
887
901
}
888
902
if h .spamFilter != nil {
889
- e .IsScam = h .spamFilter .IsScamEvent (e .EventID , e . Actions , & account , trace .Account )
903
+ e .IsScam = h .spamFilter .IsScamEvent (e .Actions , & account , trace .Account , false )
890
904
}
891
905
if len (e .Actions ) == 0 {
892
906
e .Actions = []oas.Action {
0 commit comments