services

package
v0.0.0-...-76fd6e2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Try to remove EmitEvent() and SubcribeEvent()

Index

Constants

View Source
const (
	ADMIN_ROLE_ID     = 1
	MODERATOR_ROLE_ID = 2
	USER_ROLE_ID      = 3
)
View Source
const ListingLimit = 10

Variables

This section is empty.

Functions

func FromInterfaceString2String

func FromInterfaceString2String(bstr interface{}) string

func ToBigInt

func ToBigInt(str string) *big.Int

func ToNullString

func ToNullString(s Stringer) (ns sql.NullString)

Types

type AuthenticationService

type AuthenticationService interface {
	GetUserNonce(ctx context.Context, address string) (string, error)
	Login(ctx context.Context, address string, messageStr string, sigHex string) (string, time.Time, error)
}

type CollectionService

type CollectionService interface {
	CreateCollection(ctx context.Context, collection entities.Collection) (entities.Collection, error)
	GetListCollection(ctx context.Context, query entities.Collection, offset int, limit int) ([]entities.Collection, error)
	GetListCollectionWithCategory(ctx context.Context, categogy string, offset int, limit int) ([]entities.Collection, error)
	UpdateCollectionLastSyncBlock(ctx context.Context, token common.Address, block uint64) error
	GetCollectionLastSyncBlock(ctx context.Context, token common.Address) (uint64, error)
}

type EventService

type EventService interface {
	CreateEvent(ctx context.Context, event entities.Event) (entities.Event, error)
	CreateEventsByOrder(ctx context.Context, order entities.Order) ([]entities.Event, error)
	CreateEventsByFulfilledOrder(ctx context.Context, order entities.Order, txHash string) ([]entities.Event, error)
	GetListEvent(ctx context.Context, query entities.EventRead) ([]entities.Event, error)
}

type MarketplaceService

type MarketplaceService interface {
	UpdateMarketplaceLastSyncBlock(ctx context.Context, block uint64) error
	GetMarketplaceLastSyncBlock(ctx context.Context) (uint64, error)
	GetMarketplaceSettings(ctx context.Context, marketplaceAddress common.Address) (*entities.MarketplaceSettings, error)
	UpdateMarketplaceSettings(ctx context.Context, marketplace common.Address, beneficiary common.Address, royalty float64) (*entities.MarketplaceSettings, error)
}

type NftNewService

type NftNewService interface {
	UpdateNftStatus(ctx context.Context, token common.Address, identifier *big.Int, isHidden bool) error
	ListNftsWithListings(
		ctx context.Context,
		token common.Address,
		identifier *big.Int,
		owner common.Address,
		isHidden *bool,
		offset int32,
		limit int32,
	) ([]*entities.NftRead, error)
	GetNft(
		ctx context.Context,
		token common.Address,
		identifier *big.Int,
	) (*entities.Nft, error)
}

type NotificationService

type NotificationService interface {
	CreateNotification(ctx context.Context, notification entities.NotificationPost) error
	GetListNotification(ctx context.Context, address common.Address, isViewed *bool) ([]entities.NotificationGet, error)
	UpdateNotification(ctx context.Context, notification entities.NotificationUpdate) error
}

type OrderService

type OrderService interface {
	CreateOrder(ctx context.Context, order entities.Order) error
	FulFillOrder(ctx context.Context, order entities.Order) error
	GetOrder(
		ctx context.Context,
		offer entities.OfferItem,
		consideration entities.ConsiderationItem,
		orderHash common.Hash,
		offerer common.Address,
		IsFulfilled *bool,
		IsCancelled *bool,
		IsInvalid *bool,
	) ([]entities.Order, error)
	RemoveInvalidOrder(ctx context.Context, offerer common.Address, token common.Address, identifier *big.Int) error
	HandleOrderCancelled(ctx context.Context, orderHash common.Hash) error
	HandleCounterIncremented(ctx context.Context, offerer common.Address) error
	GetExpiredOrder(ctx context.Context) ([]entities.ExpiredOrder, error)
}

type ProfileService

type ProfileService interface {
	GetProfile(ctx context.Context, address string) (entities.Profile, error)
	UpsertProfile(ctx context.Context, profile entities.Profile) (entities.Profile, error)
	DeleteProfile(ctx context.Context, address common.Address) error
	GetOffer(ctx context.Context, owner common.Address, from common.Address) ([]entities.Event, error)
}

type RoleService

type RoleService interface {
	GetRoles(ctx context.Context) ([]*entities.Role, error)
}

type SearchService

type SearchService interface {
	SearchNFTsWithListings(ctx context.Context, token common.Address, owner common.Address, q string, isHidden *bool, offset int32, limit int32) ([]*entities.NftRead, error)
}

type Servicer

type Servicer interface {
	OrderService
	NftNewService
	ProfileService
	CollectionService
	MarketplaceService
	EventService
	SearchService
	NotificationService
	AuthenticationService
	UserService
	RoleService

	EmitTask(ctx context.Context, event models.EnumTask, value []byte) error
	SubcribeTask(ctx context.Context, event models.EnumTask, handler asynq.HandlerFunc) error

	MintedNft(
		ctx context.Context,
		token common.Address,
		identifier *big.Int,
		to common.Address,
		token_uri string,
		blockNumber uint64,
		txIndex uint,
	) error
	TransferNft(ctx context.Context, transfer models.NftTransfer, blockNumber uint64, txIndex uint) error
	UpdateNftMetadata(ctx context.Context, token common.Address, identifier *big.Int, metadata map[string]any) (err error)

	Close() error
}

type Services

type Services struct {
	// contains filtered or unexported fields
}

func New

func New(
	redisUrl string,
	redisPass string,

	nftReader infrastructure.NftReader,
	nftWriter infrastructure.NftWriter,

	orderReader infrastructure.OrderReader,
	orderWriter infrastructure.OrderWritter,

	collectionReader infrastructure.CollectionReader,
	collectionWriter infrastructure.CollectionWriter,

	eventReader infrastructure.EventReader,
	eventWriter infrastructure.EventWriter,

	notificationReader infrastructure.NotificationReader,
	notificationWriter infrastructure.NotificationWriter,

	marketplaceReader infrastructure.MarketplaceReader,
	marketplaceWriter infrastructure.MarketplaceWriter,

	searcher infrastructure.Searcher,

	profileReader infrastructure.ProfileReader,
	profileWriter infrastructure.ProfileWriter,

	userReader infrastructure.UserReader,
	userWriter infrastructure.UserWriter,
) *Services

func (*Services) Close

func (s *Services) Close() error

func (*Services) CreateCollection

func (s *Services) CreateCollection(ctx context.Context, collection entities.Collection) (ec entities.Collection, err error)

func (*Services) CreateEvent

func (s *Services) CreateEvent(ctx context.Context, event entities.Event) (ee entities.Event, err error)

Add event to database

func (*Services) CreateEventsByFulfilledOrder

func (s *Services) CreateEventsByFulfilledOrder(ctx context.Context, order entities.Order, txHash string) (ees []entities.Event, err error)

Add event sale to database

func (*Services) CreateEventsByOrder

func (s *Services) CreateEventsByOrder(ctx context.Context, order entities.Order) (ees []entities.Event, err error)

Add event listing or offer to database

func (*Services) CreateNotification

func (s *Services) CreateNotification(ctx context.Context, notification entities.NotificationPost) error

func (*Services) CreateOrder

func (s *Services) CreateOrder(ctx context.Context, order entities.Order) (err error)

func (*Services) DeleteProfile

func (s *Services) DeleteProfile(ctx context.Context, address common.Address) error

func (*Services) DeleteUserRole

func (s *Services) DeleteUserRole(ctx context.Context, address string, roleId int32) error

func (*Services) EmitTask

func (s *Services) EmitTask(ctx context.Context, event models.EnumTask, value []byte) error

func (*Services) FulFillOrder

func (s *Services) FulFillOrder(ctx context.Context, order entities.Order) error

func (*Services) GenerateJWTToken

func (s *Services) GenerateJWTToken(user *entities.User) (string, time.Time, error)

func (*Services) GetCollectionLastSyncBlock

func (s *Services) GetCollectionLastSyncBlock(ctx context.Context, token common.Address) (uint64, error)

func (*Services) GetExpiredOrder

func (s *Services) GetExpiredOrder(ctx context.Context) (expiredOrderList []entities.ExpiredOrder, err error)

func (*Services) GetListCollection

func (s *Services) GetListCollection(ctx context.Context, query entities.Collection, offset int, limit int) (ecs []entities.Collection, err error)

func (*Services) GetListCollectionWithCategory

func (s *Services) GetListCollectionWithCategory(ctx context.Context, categogy string, offset int, limit int) (ecs []entities.Collection, err error)

func (*Services) GetListEvent

func (s *Services) GetListEvent(ctx context.Context, query entities.EventRead) (events []entities.Event, err error)

func (*Services) GetListNotification

func (s *Services) GetListNotification(ctx context.Context, address common.Address, isViewed *bool) (ns []entities.NotificationGet, err error)

func (*Services) GetMarketplaceLastSyncBlock

func (s *Services) GetMarketplaceLastSyncBlock(ctx context.Context) (uint64, error)

func (*Services) GetMarketplaceSettings

func (s *Services) GetMarketplaceSettings(ctx context.Context, marketplaceAddress common.Address) (*entities.MarketplaceSettings, error)

func (*Services) GetNft

func (s *Services) GetNft(
	ctx context.Context,
	token common.Address,
	identifier *big.Int,
) (*entities.Nft, error)

func (*Services) GetOffer

func (s *Services) GetOffer(ctx context.Context, owner common.Address, from common.Address) (offers []entities.Event, err error)

func (*Services) GetOrder

func (s *Services) GetOrder(
	ctx context.Context,
	offer entities.OfferItem,
	consideration entities.ConsiderationItem,
	orderHash common.Hash,
	offerer common.Address,
	IsFulfilled *bool,
	IsCancelled *bool,
	IsInvalid *bool,
) ([]entities.Order, error)

func (*Services) GetProfile

func (s *Services) GetProfile(ctx context.Context, address string) (entities.Profile, error)

func (*Services) GetRoles

func (s *Services) GetRoles(ctx context.Context) ([]*entities.Role, error)

func (*Services) GetUserByAddress

func (s *Services) GetUserByAddress(ctx context.Context, address string) (*entities.User, error)

func (*Services) GetUserNonce

func (s *Services) GetUserNonce(ctx context.Context, address string) (string, error)

func (*Services) GetUsers

func (s *Services) GetUsers(ctx context.Context, isBlock *bool, role string, offset int32, limit int32) ([]*entities.User, error)

func (*Services) HandleCounterIncremented

func (s *Services) HandleCounterIncremented(ctx context.Context, offerer common.Address) error

func (*Services) HandleOrderCancelled

func (s *Services) HandleOrderCancelled(ctx context.Context, orderHash common.Hash) error

func (*Services) InsertUser

func (s *Services) InsertUser(ctx context.Context, user *entities.User) (*entities.User, error)

func (*Services) InsertUserRole

func (s *Services) InsertUserRole(ctx context.Context, address string, roleId int32) (*entities.Role, error)

func (*Services) ListNftsWithListings

func (s *Services) ListNftsWithListings(
	ctx context.Context,
	token common.Address,
	identifier *big.Int,
	owner common.Address,
	isHidden *bool,
	offset int32,
	limit int32,
) ([]*entities.NftRead, error)

func (*Services) Login

func (s *Services) Login(ctx context.Context, address string, messageStr string, sigHex string) (string, time.Time, error)

func (*Services) MintedNft

func (s *Services) MintedNft(
	ctx context.Context,
	token common.Address,
	identifier *big.Int,
	to common.Address,
	token_uri string,
	blockNumber uint64,
	txIndex uint,
) error

func (*Services) RemoveInvalidOrder

func (s *Services) RemoveInvalidOrder(
	ctx context.Context,
	offerer common.Address,
	token common.Address,
	identifier *big.Int,
) error

func (*Services) SearchNFTsWithListings

func (s *Services) SearchNFTsWithListings(
	ctx context.Context,
	token common.Address,
	owner common.Address,
	q string,
	isHidden *bool,
	offset int32,
	limit int32,
) ([]*entities.NftRead, error)

func (*Services) SubcribeTask

func (s *Services) SubcribeTask(ctx context.Context, event models.EnumTask, handler asynq.HandlerFunc) error

func (*Services) TransferAdminRole

func (s *Services) TransferAdminRole(ctx context.Context, maker string, taker string) (*entities.Role, error)

func (*Services) TransferNft

func (s *Services) TransferNft(
	ctx context.Context,
	transfer models.NftTransfer,
	blockNumber uint64,
	txIndex uint,
) error

func (*Services) UpdateCollectionLastSyncBlock

func (s *Services) UpdateCollectionLastSyncBlock(ctx context.Context, token common.Address, block uint64) error

func (*Services) UpdateMarketplaceLastSyncBlock

func (s *Services) UpdateMarketplaceLastSyncBlock(ctx context.Context, block uint64) error

func (*Services) UpdateMarketplaceSettings

func (s *Services) UpdateMarketplaceSettings(ctx context.Context, marketplace common.Address, beneficiary common.Address, royalty float64) (*entities.MarketplaceSettings, error)

func (*Services) UpdateNftMetadata

func (s *Services) UpdateNftMetadata(
	ctx context.Context,
	token common.Address,
	identifier *big.Int,
	metadata map[string]any,
) (err error)

func (*Services) UpdateNftStatus

func (s *Services) UpdateNftStatus(
	ctx context.Context,
	token common.Address,
	identifier *big.Int,
	isHidden bool,
) error

func (*Services) UpdateNotification

func (s *Services) UpdateNotification(ctx context.Context, notification entities.NotificationUpdate) error

func (*Services) UpdateUserBlockState

func (s *Services) UpdateUserBlockState(ctx context.Context, address string, isBlock bool) error

func (*Services) UpsertProfile

func (s *Services) UpsertProfile(ctx context.Context, profile entities.Profile) (entities.Profile, error)

type Stringer

type Stringer interface {
	String() string
}

type UserService

type UserService interface {
	GetUserByAddress(ctx context.Context, address string) (*entities.User, error)
	GetUsers(ctx context.Context, isBlock *bool, role string, offset int32, limit int32) ([]*entities.User, error)
	UpdateUserBlockState(ctx context.Context, address string, isBlock bool) error
	InsertUserRole(ctx context.Context, address string, roleId int32) (*entities.Role, error)
	DeleteUserRole(ctx context.Context, address string, roleID int32) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL