usecases

package
v0.0.0-...-7c2ba20 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContractInput

type ContractInput struct {
	Blockchain common.Blockchain `json:"blockchain" validate:"required,oneof=ethereum polygon arbitrum optimism"`
	Address    string            `json:"address" validate:"required,eth_addr"`
	Interface  common.Interface  `` /* 176-byte string literal not displayed */
}

type CurrencyInput

type CurrencyInput struct {
	Blockchain common.Blockchain `json:"blockchain" validate:"required,oneof=ethereum polygon arbitrum optimism"`
}

type DisplayAchievementInput

type DisplayAchievementInput struct {
	Id    string                 `json:"id" validate:"required"`
	Index uint64                 `json:"index" validate:"gte=0"`
	Type  common.AchievementType `json:"type" validate:"required,oneof=interactions"`
}

type DisplayAchievementsInput

type DisplayAchievementsInput struct {
	Text  string                     `json:"text" validate:"max=30"`
	Items *[]DisplayAchievementInput `json:"items" validate:"required,dive"`
}

type DisplayColorsInput

type DisplayColorsInput struct {
	Primary       string `json:"primary" validate:"required,max=15"`
	Secondary     string `json:"secondary" validate:"required,max=15"`
	PrimaryText   string `json:"primary_text" validate:"required,max=15"`
	SecondaryText string `json:"secondary_text" validate:"required,max=15"`
	Shadow        string `json:"shadow" validate:"required,max=15"`
	Accent        string `json:"accent" validate:"required,max=15"`
}

type DisplayConfigInput

type DisplayConfigInput struct {
	Colors       *DisplayColorsInput       `json:"colors" validate:"required,dive"`
	Info         *DisplayInfoInput         `json:"info" validate:"required,dive"`
	Achievements *DisplayAchievementsInput `json:"achievements" validate:"required,dive"`
	Groups       *[]DisplayGroupInput      `json:"groups" validate:"required,dive"`
}

type DisplayGroupInput

type DisplayGroupInput struct {
	Id    string              `json:"id" validate:"required,max=30"`
	Text  string              `json:"text" validate:"max=30"`
	Items *[]DisplayItemInput `json:"items" validate:"required,dive"`
}

type DisplayInfoInput

type DisplayInfoInput struct {
	Title         string `json:"title" validate:"max=40"`
	Description   string `json:"description" validate:"max=1000"`
	TwitterHandle string `json:"twitter_handle" validate:"max=15"`
}

type DisplayItemInput

type DisplayItemInput struct {
	Id    string           `json:"id" validate:"required"`
	Index uint64           `json:"index" validate:"gte=0"`
	Type  common.BadgeType `json:"type" validate:"required,oneof=non_fungible_tokens fungible_tokens statistics currencies"`
}

type FungibleTokenInput

type FungibleTokenInput struct {
	Contract *ContractInput `json:"contract" validate:"required,dive"`
}

type GetAllCurrenciesInput

type GetAllCurrenciesInput struct {
	Currencies *[]GetCurrencyInput `validate:"required"`
}

type GetAllFungibleTokensInput

type GetAllFungibleTokensInput struct {
	Tokens *[]GetFungibleTokenInput `validate:"required"`
}

type GetAllInteractionsInput

type GetAllInteractionsInput struct {
	Interactions *[]GetInteractionInput `validate:"required"`
}

type GetAllNonFungibleTokensInput

type GetAllNonFungibleTokensInput struct {
	NonFungibleTokens *[]GetNonFungibleTokenInput `validate:"required"`
}

type GetAllStatisticsInput

type GetAllStatisticsInput struct {
	Stats *[]GetStatisticsInput `validate:"required"`
}

type GetChallengeInput

type GetChallengeInput struct {
	Address string `validate:"required,eth_addr"`
}

type GetCurrencyInput

type GetCurrencyInput struct {
	Address    string            `validate:"required,eth_addr"`
	Blockchain common.Blockchain `validate:"required,oneof=ethereum polygon arbitrum optimism"`
}

type GetDefaultProfileInput

type GetDefaultProfileInput struct {
	Address string `validate:"required,eth_addr"`
}

type GetFungibleTokenInput

type GetFungibleTokenInput struct {
	Address string              `validate:"required,eth_addr"`
	Token   *FungibleTokenInput `validate:"required,dive"`
}

type GetInteractionInput

type GetInteractionInput struct {
	Address     string            `validate:"required,eth_addr"`
	Interaction *InteractionInput `validate:"required,dive"`
}

type GetLightProfileInput

type GetLightProfileInput struct {
	Address string `validate:"required,eth_addr"`
}

type GetNonFungibleTokenInput

type GetNonFungibleTokenInput struct {
	Address          string                 `validate:"required,eth_addr"`
	NonFungibleToken *NonFungibleTokenInput `validate:"required,dive"`
}

type GetProfileInput

type GetProfileInput struct {
	Address string `validate:"required,eth_addr"`
}

type GetSpotlightProfilesInput

type GetSpotlightProfilesInput struct {
}

type GetStatisticsInput

type GetStatisticsInput struct {
	Address   string          `validate:"required,eth_addr"`
	Statistic *StatisticInput `validate:"required,dive"`
}

type GetTopProfilesInput

type GetTopProfilesInput struct {
}

type IGetAllCurrenciesUseCase

type IGetAllCurrenciesUseCase interface {
	// Get the balances for the given list of addresses and blockchains.
	// A nil balance will be returned for any invalid contracts
	Do(ctx context.Context, input *GetAllCurrenciesInput) *[]entities.Currency
}

func NewGetAllCurrenciesUseCase

func NewGetAllCurrenciesUseCase(
	logger common.ILogger,
	getCurrency IGetCurrencyUseCase,
) IGetAllCurrenciesUseCase

type IGetAllFungibleTokensUseCase

type IGetAllFungibleTokensUseCase interface {
	// Get a slice of fungible tokens for the given contracts/address.
	// Invalid contracts will return a token with a zeroed balance.
	Do(ctx context.Context, input *GetAllFungibleTokensInput) *[]entities.FungibleToken
}

func NewGetAllFungibleTokens

func NewGetAllFungibleTokens(
	logger common.ILogger,
	getFungibleToken IGetFungibleTokenUseCase,
) IGetAllFungibleTokensUseCase

type IGetAllInteractionsUseCase

type IGetAllInteractionsUseCase interface {
	// Get all interactions.
	// A non nil error will be returned if any interactions in the list are invalid
	Do(ctx context.Context, input *GetAllInteractionsInput) (*[]entities.Interaction, error)
}

func NewGetAllInteractionsUseCase

func NewGetAllInteractionsUseCase(
	logger common.ILogger,
	getInteraction IGetInteractionUseCase,
) IGetAllInteractionsUseCase

type IGetAllNonFungibleTokensUseCase

type IGetAllNonFungibleTokensUseCase interface {
	// Get the metadata and balance of a slice of nfts.
	// Invalid contracts have a zeroed balance and nil metadata returned.
	Do(ctx context.Context, input *GetAllNonFungibleTokensInput) *[]entities.NonFungibleToken
}

func NewGetAllNonFungibleTokens

func NewGetAllNonFungibleTokens(
	logger common.ILogger,
	getNonFungibleToken IGetNonFungibleTokenUseCase,
) IGetAllNonFungibleTokensUseCase

type IGetAllStatisticsUseCase

type IGetAllStatisticsUseCase interface {
	// Get all statistic data for a given slice of statistics.
	// Invalid contracts will return a statistic with nil Data.
	Do(ctx context.Context, input *GetAllStatisticsInput) *[]entities.Statistic
}

func NewGetAllStatistics

func NewGetAllStatistics(
	logger common.ILogger,
	getStatistic IGetStatisticUseCase,
) IGetAllStatisticsUseCase

type IGetChallengeUseCase

type IGetChallengeUseCase interface {
	// Get a new challenge message for the provided address
	Do(ctx context.Context, input *GetChallengeInput) (*entities.Challenge, error)
}

func NewGetChallenge

func NewGetChallenge(cacheGateway gateways.ICacheGateway) IGetChallengeUseCase

type IGetCurrencyUseCase

type IGetCurrencyUseCase interface {
	// Get the balance for a given address and blockchain
	Do(ctx context.Context, input *GetCurrencyInput) (*entities.Currency, error)
}

func NewGetCurrency

func NewGetCurrency(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
) IGetCurrencyUseCase

type IGetDefaultProfileUseCase

type IGetDefaultProfileUseCase interface {
	// Get a default profile for the provided address
	Do(ctx context.Context, input *GetDefaultProfileInput) (*entities.Profile, error)
}

func NewGetDefaultProfile

func NewGetDefaultProfile(
	logger common.ILogger,
	settings settings.ISettings,
	blockchainGateway gateways.IBlockchainGateway,
	blochchainIndexGateway gateways.IBlockchainIndexGateway,
	offchainGateway gateways.IOffchainGateway,
	getAllFungibleTokens IGetAllFungibleTokensUseCase,
	getAllStatistics IGetAllStatisticsUseCase,
	getAllCurrencies IGetAllCurrenciesUseCase,
	resolveENSName IResolveENSNameUseCase,
) IGetDefaultProfileUseCase

type IGetFungibleTokenUseCase

type IGetFungibleTokenUseCase interface {
	// Get the metadata and balance of an nft
	Do(ctx context.Context, input *GetFungibleTokenInput) (*entities.FungibleToken, error)
}

func NewGetFungibleToken

func NewGetFungibleToken(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
	cacheGateway gateways.ICacheGateway,
	offchainGateway gateways.IOffchainGateway,
) IGetFungibleTokenUseCase

type IGetInteractionUseCase

type IGetInteractionUseCase interface {
	// Get the transaction data for a given interaction input
	// Validate transaction against interaction type
	Do(ctx context.Context, input *GetInteractionInput) (*entities.Interaction, error)
}

func NewGetInteractionUseCase

func NewGetInteractionUseCase(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
) IGetInteractionUseCase

type IGetLightProfileUseCase

type IGetLightProfileUseCase interface {
	// get a minimaly hydrated version of the profile that will be faster to fetch
	Do(ctx context.Context, input *GetLightProfileInput) (*entities.Profile, error)
}

func NewGetLightProfile

func NewGetLightProfile(
	logger common.ILogger,
	cacheGateway gateways.ICacheGateway,
	blockchainGateway gateways.IBlockchainGateway,
	databaseGateway gateways.IDatabaseGateway,
	resolveENSName IResolveENSNameUseCase,
	getNonFungibleToken IGetNonFungibleTokenUseCase,
	offchainGateway gateways.IOffchainGateway,
) IGetLightProfileUseCase

type IGetNonFungibleTokenUseCase

type IGetNonFungibleTokenUseCase interface {
	// Get the metadata and balance of an nft.
	// Metadata doesnt change so we cache it.
	// Metadata is an optional implementation in ERC721 and ERC1155 and may not exist.
	// Its also possible that we simply have issues following the uri.
	// In these scenarios we will return nil metadata and not bubble up an err.
	Do(ctx context.Context, input *GetNonFungibleTokenInput) (*entities.NonFungibleToken, error)
}

func NewGetNonFungibleToken

func NewGetNonFungibleToken(
	logger common.ILogger,
	settings settings.ISettings,
	blockchainGateway gateways.IBlockchainGateway,
	offchainGateway gateways.IOffchainGateway,
	cacheGateway gateways.ICacheGateway,
) IGetNonFungibleTokenUseCase

type IGetProfileUseCase

type IGetProfileUseCase interface {
	// get the profile for the provided address
	Do(ctx context.Context, input *GetProfileInput) (*entities.Profile, error)
}

func NewGetProfile

func NewGetProfile(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
	cacheGateway gateways.ICacheGateway,
	databaseGateway gateways.IDatabaseGateway,
	getDefaultProfile IGetDefaultProfileUseCase,
	getNonFungibleToken IGetNonFungibleTokenUseCase,
	getAllNonFungibleTokens IGetAllNonFungibleTokensUseCase,
	getAllFungibleTokens IGetAllFungibleTokensUseCase,
	getAllStatistics IGetAllStatisticsUseCase,
	getAllCurrencies IGetAllCurrenciesUseCase,
	resolveENSName IResolveENSNameUseCase,
) IGetProfileUseCase

type IGetSpotlightProfilesUseCase

type IGetSpotlightProfilesUseCase interface {
	Do(ctx context.Context, input *GetSpotlightProfilesInput) *[]entities.Profile
}

func NewGetSpotlightProfilesUseCase

func NewGetSpotlightProfilesUseCase(
	logger common.ILogger,
	settings settings.ISettings,
	getLightProfile IGetLightProfileUseCase,
	cacheGateway gateways.ICacheGateway,
) IGetSpotlightProfilesUseCase

type IGetStatisticUseCase

type IGetStatisticUseCase interface {
	// Get the statistic for a given address and contract
	Do(ctx context.Context, input *GetStatisticsInput) (*entities.Statistic, error)
}

func NewGetStatistic

func NewGetStatistic(
	logger common.ILogger,
	blockchainIndexGateway gateways.IBlockchainIndexGateway,
) IGetStatisticUseCase

type IGetTopProfilesUseCase

type IGetTopProfilesUseCase interface {
	Do(ctx context.Context, input *GetTopProfilesInput) *[]entities.Profile
}

func NewGetTopProfilesUseCase

func NewGetTopProfilesUseCase(
	logger common.ILogger,
	cacheGateway gateways.ICacheGateway,
	getLightProfile IGetLightProfileUseCase,
) IGetTopProfilesUseCase

type IRecordProfileViewUseCase

type IRecordProfileViewUseCase interface {
	Do(ctx context.Context, input *RecordProfileViewInput) error
}

func NewRecordProfileViewUseCase

func NewRecordProfileViewUseCase(logger common.ILogger, cacheGateway gateways.ICacheGateway) IRecordProfileViewUseCase

type IRefreshProfileUseCase

type IRefreshProfileUseCase interface {
	// Refresh any relevant transient info that is currently cached.
	// Info that is currently refreshed:
	//
	// - Store Assets
	Do(ctx context.Context, input *RefreshProfileInput) error
}

func NewRefreshProfileUseCase

func NewRefreshProfileUseCase(logger common.ILogger, cacheGateway gateways.ICacheGateway, blockchainGateway gateways.IBlockchainGateway) IRefreshProfileUseCase

type IResolveAddressUseCase

type IResolveAddressUseCase interface {
	// Resolve an address from an ens name
	Do(ctx context.Context, input *ResolveAddressInput) (string, error)
}

func NewResolveENSAddress

func NewResolveENSAddress(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
	cacheGateway gateways.ICacheGateway,
) IResolveAddressUseCase

type IResolveENSNameUseCase

type IResolveENSNameUseCase interface {
	// Resolve an ens name for an address
	Do(ctx context.Context, input *ResolveENSNameInput) (name string, err error)
}

func NewResolveENSName

func NewResolveENSName(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
	cacheGateway gateways.ICacheGateway,
) IResolveENSNameUseCase

type ISaveProfileUseCase

type ISaveProfileUseCase interface {
	// Validate the non transient info being submitted (interactions).
	// Save the profile to the database.
	// Remove the cached profile.
	//
	// TODO: can fetch interactions and premium balance concurrently.
	Do(ctx context.Context, input *SaveProfileInput) error
}

func NewSaveProfile

func NewSaveProfile(
	logger common.ILogger,
	blockchainGateway gateways.IBlockchainGateway,
	databaseGateway gateways.IDatabaseGateway,
	cacheGateway gateways.ICacheGateway,
	getAllInteractions IGetAllInteractionsUseCase,
) ISaveProfileUseCase

type IVerifyChallengeUseCase

type IVerifyChallengeUseCase interface {
	// verify if the provided signature was signed with the correct address and signed the correct challenge message
	Do(ctx context.Context, input *VerifyChallengeInput) error
}

func NewVerifyChallenge

func NewVerifyChallenge(cacheGateway gateways.ICacheGateway) IVerifyChallengeUseCase

type IVerifyRateLimitUseCase

type IVerifyRateLimitUseCase interface {
	// Verify that the provided IpAddress is not rate limited
	Do(ctx context.Context, input *VerifyRateLimitInput) error
}

func NewVerifyRateLimit

func NewVerifyRateLimit(
	logger common.ILogger,
	cacheGateway gateways.ICacheGateway,
) IVerifyRateLimitUseCase

type InteractionInput

type InteractionInput struct {
	Transaction *TransactionInput  `json:"transaction" validate:"required,dive"`
	Type        common.Interaction `json:"type" validate:"required,oneof=CONTRACT_CREATION SEND_ETHER"`
}

type NonFungibleTokenInput

type NonFungibleTokenInput struct {
	Contract *ContractInput `json:"contract" validate:"required,dive"`
	TokenId  string         `json:"token_id" validate:"required,numeric"`
}

type ProfileInput

type ProfileInput struct {
	Address           string                   `json:"-" validate:"required,eth_addr"`
	DisplayConfig     *DisplayConfigInput      `json:"display_config" validate:"required,dive"`
	ProfilePicture    *NonFungibleTokenInput   `json:"profile_picture" validate:"omitempty,dive"`
	NonFungibleTokens *[]NonFungibleTokenInput `json:"non_fungible_tokens" validate:"required,dive"`
	FungibleTokens    *[]FungibleTokenInput    `json:"fungible_tokens" validate:"required,dive"`
	Statistics        *[]StatisticInput        `json:"statistics" validate:"required,dive"`
	Interactions      *[]InteractionInput      `json:"interactions" validate:"required,dive"`
	Currencies        *[]CurrencyInput         `json:"currencies" validate:"required,dive"`
}

type RecordProfileViewInput

type RecordProfileViewInput struct {
	Address   string `validate:"required,eth_addr"`
	IpAddress string `validate:"required,ip"`
}

type RefreshProfileInput

type RefreshProfileInput struct {
	Address string `validate:"required,eth_addr"`
}

type ResolveAddressInput

type ResolveAddressInput struct {
	Value string `validate:"required"`
}

type ResolveENSNameInput

type ResolveENSNameInput struct {
	Address string `validate:"required,eth_addr"`
}

type SaveProfileInput

type SaveProfileInput struct {
	Profile *ProfileInput `validate:"required,dive"`
}

type StatisticInput

type StatisticInput struct {
	Contract *ContractInput       `json:"contract" validate:"required,dive"`
	Type     common.StatisticType `json:"type" validate:"required,oneof=SWAP STAKE"`
}

type TransactionInput

type TransactionInput struct {
	Id         string            `json:"id" validate:"required"`
	Blockchain common.Blockchain `json:"blockchain" validate:"required,oneof=ethereum polygon arbitrum optimism"`
}

type VerifyChallengeInput

type VerifyChallengeInput struct {
	Address string `validate:"required,eth_addr"`
	SigHex  string `validate:"required"`
}

type VerifyRateLimitInput

type VerifyRateLimitInput struct {
	IpAddress string `validate:"required,ip"`
}

Jump to

Keyboard shortcuts

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