initial commit

This commit is contained in:
Laurent Le Houerou 2021-11-25 11:06:40 +04:00
parent 5410033aa9
commit 17977c0c27

10
nft.go
View File

@ -56,18 +56,22 @@ type MarketService struct {
squadservice *SquadService squadservice *SquadService
floorService *FloorService floorService *FloorService
bscaddress string
nfts []Nft nfts []Nft
floor float64 floor float64
nftslock *sync.RWMutex nftslock *sync.RWMutex
} }
func NewMarketService(collection string, graphClient *graphql.Client, squadservice *SquadService, floorService *FloorService) *MarketService { func NewMarketService(collection string, graphClient *graphql.Client, squadservice *SquadService, floorService *FloorService, bscadress string) *MarketService {
return &MarketService{ return &MarketService{
collection: collection, collection: collection,
graphClient: graphClient, graphClient: graphClient,
squadservice: squadservice, squadservice: squadservice,
floorService: floorService, floorService: floorService,
bscaddress: bscadress,
nfts: nil, nfts: nil,
floor: 0, floor: 0,
nftslock: &sync.RWMutex{}, nftslock: &sync.RWMutex{},
@ -199,7 +203,7 @@ func (s *MarketService) GetNft(ctx context.Context, collection string, tokenId i
res.UpdatedTimeString = humanize.Time(time.Unix(res.UpdatedAt, 0)) res.UpdatedTimeString = humanize.Time(time.Unix(res.UpdatedAt, 0))
res.IsRecent = time.Unix(res.UpdatedAt, 0).After(time.Now().Add(-1 * time.Hour)) res.IsRecent = time.Unix(res.UpdatedAt, 0).After(time.Now().Add(-1 * time.Hour))
res.IsVeryRecent = time.Unix(res.UpdatedAt, 0).After(time.Now().Add(-5 * time.Minute)) res.IsVeryRecent = time.Unix(res.UpdatedAt, 0).After(time.Now().Add(-5 * time.Minute))
res.IsNotMine = res.CurrentSeller != "0x73d74055cc40ee8c62978a37a3b938f6e62739ed" res.IsNotMine = res.CurrentSeller != s.bscaddress
return res, nil return res, nil
} }
@ -260,7 +264,7 @@ func (s *MarketService) getPage(ctx context.Context, collection string, pagenum
if floor == 0 || nft.CurrentAskPrice < floor { if floor == 0 || nft.CurrentAskPrice < floor {
floor = nft.CurrentAskPrice floor = nft.CurrentAskPrice
} }
nft.IsNotMine = nft.CurrentSeller != "0x73d74055cc40ee8c62978a37a3b938f6e62739ed" nft.IsNotMine = nft.CurrentSeller != s.bscaddress
res = append(res, nft) res = append(res, nft)
} }