add IsMine property to transaction

This commit is contained in:
Laurent Le Houerou 2021-12-06 13:49:50 +04:00
parent 38b90fa65c
commit b92fbf5880

View File

@ -29,19 +29,23 @@ type Transaction struct {
Score float64 Score float64
Url string Url string
TimeDescription string TimeDescription string
IsMine bool
} }
type TransactionService struct { type TransactionService struct {
graphClient *graphql.Client graphClient *graphql.Client
squadservice *SquadService squadservice *SquadService
floorService *FloorService floorService *FloorService
bscaddress string
} }
func NewTransactionService(graphClient *graphql.Client, squadservice *SquadService, floorService *FloorService) *TransactionService { func NewTransactionService(graphClient *graphql.Client, squadservice *SquadService, floorService *FloorService, bscaddress string) *TransactionService {
return &TransactionService{ return &TransactionService{
graphClient: graphClient, graphClient: graphClient,
squadservice: squadservice, squadservice: squadservice,
floorService: floorService, floorService: floorService,
bscaddress: bscaddress,
} }
} }
@ -101,6 +105,7 @@ func (s *TransactionService) GetLightPageByLimit(ctx context.Context, pagenumber
sort.Slice(transaction.Nft.TransactionHistory, func(i, j int) bool { sort.Slice(transaction.Nft.TransactionHistory, func(i, j int) bool {
return transaction.Nft.TransactionHistory[i].Timestamp > transaction.Nft.TransactionHistory[j].Timestamp return transaction.Nft.TransactionHistory[i].Timestamp > transaction.Nft.TransactionHistory[j].Timestamp
}) })
transaction.IsMine = transaction.Buyer.Address == s.bscaddress || transaction.Seller.Address == s.bscaddress
} }
var res []Transaction var res []Transaction