datatype

package
v0.0.0-...-c477d60 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BlockUnverified unverified status for block
	BlockUnverified = 0
	// BlockAccepted accepted status for block
	BlockAccepted = 1
	// BlockRejected rejected status for block
	BlockRejected = 2
)
View Source
const (
	// OraclePerson person oracle type
	OraclePerson = 0
	// OracleSensor sensor oracle type
	OracleSensor = 1
)
View Source
const (
	// DbTrue a tinyint true
	DbTrue = 1
	// DbFalse a tinyint False
	DbFalse = 0
)
View Source
const (
	// HOMETIMELINE home asset timeline
	HOMETIMELINE = 0
	// USERTIMELINE user asset timeline
	USERTIMELINE = 1
	// ASSETTIMELINE asset timeline
	ASSETTIMELINE = 2
)

Variables

View Source
var (
	//ErrInvalidRequest invalid request
	ErrInvalidRequest = errors.New("Invalid request")

	// ErrNotEnoughBalance not enough balance
	ErrNotEnoughBalance = errors.New("Not enough balance")

	// ErrServerError for any internal server error
	ErrServerError = errors.New("Server error")

	// ErrBadRequest send it when user tries to do something illegal
	ErrBadRequest = errors.New("Bad request")

	// ErrTryAgain for any try again error
	ErrTryAgain = errors.New("Can't complete this operation at the moment, please try again")

	// ErrMarketCantBeNil when required market is missing
	ErrMarketCantBeNil = errors.New("Market can't be nil")

	// ErrOrderCantBeNil when required order is missing
	ErrOrderCantBeNil = errors.New("Order can't be nil")

	//ErrOrderQuantityMustBeBiggerThanZero for when quantity is too little
	ErrOrderQuantityMustBeBiggerThanZero = errors.New("Quantity must be bigger than 0")

	//ErrOrderPriceMustBeBiggerThanZero for when quantity is too little
	ErrOrderPriceMustBeBiggerThanZero = errors.New("Price must be bigger than 0")

	ErrEmailInvalid           = errors.New("Email address is invalid")
	ErrEmailDoesntExist       = errors.New("Email doesn't exist")
	ErrEmailExists            = errors.New("Email is already registered")
	ErrPasswordTooShort       = errors.New("Password must be at least 6 characters long")
	ErrPasswordSameAsEmail    = errors.New("Password can not be the same as email")
	ErrAgreeToTerms           = errors.New("You must agree to site terms & privacy")
	ErrInvalidCurrentPassword = errors.New("Invalid current password")

	ErrOrderDeosntBelongToMarket = errors.New("Order doesn't belong to market")
)

Functions

This section is empty.

Types

type Action

type Action struct {
	ID          ID             `json:"id"`
	Description string         `json:"description"`
	CreatorID   ID             `json:"creatorID"`
	CreatorName string         `json:"creatorName"`
	Status      int            `json:"status"`
	LogoFile    sql.NullString `json:"logoFile"`
	StartsAt    time.Time      `json:"startsAt"`
	EndsAt      time.Time      `json:"endsAt"`
	CreatedAt   time.Time      `json:"createdAt"`
}

type Asset

type Asset struct {
	ID                         ID
	Name                       string
	Symbol                     string
	Description                string
	Supply                     int64
	CreatorID                  ID
	OracleType                 int
	CreatorName                string
	MinersCounter              int
	FavoritesCounter           int
	EthereumAddress            string
	EthereumTransactionAddress string
	DidUserLike                bool
	CreatedAt                  time.Time
	CreatedAtHuman             string
	LastOraclePing             time.Time
	LastOraclePingHuman        string
	IsConnected                bool
	AccessToken                string
}

Asset asset data type

type AssetService

type AssetService interface {
	FindAll(*User) ([]Asset, error)
	FindByID(id ID) (*Asset, error)
	FindBySymbol(symbol string) (*Asset, error)
	FindByName(name string) (*Asset, error)
	Create(
		sc ServiceContainer,
		userID ID,
		name string,
		symbol string,
		description string,
		isSensor bool,
		ethereumAddress string,
		ethereumTransactionAddress string,
	) (*Asset, error)
	ToggleFavorite(user *User, assetID ID) error
	ToggleFavoriteBlock(user *User, blockID ID) error
	FindUserFavoriteAssets(user *User) ([]Asset, error)
	DidUserLikeBlock(userID ID, blockID ID) bool
	CreateAssetBlock(
		userID ID,
		assetID ID,
		blockText string,
		images []string,
	) (*Block, error)
	GetAssetBlocks(assetID ID) ([]Block, error)
	VerifyAssetBlock(sc *ServiceContainer, user *User, blockID ID, status int) error
	SensorVerifyBlock(
		sc *ServiceContainer,
		status int,
		accessToken string,
	) error
	GetAssetMiners(assetID ID) ([]Miner, error)
	IsOracle(userID ID, assetID ID) bool
	GetAssetBlockImages(blockID ID) ([]string, error)
	FindUserBalance(userID ID, assetID ID) (
		decimaldt.Decimal,
		decimaldt.Decimal,
		error,
	)
	UpdateOraclePingTime(accessToken string) error
}

AssetService defines asset service interface

type Balance

type Balance struct {
	UserID            ID
	TokenID           ID
	Balance           decimaldt.Decimal
	Reserved          decimaldt.Decimal
	Mined             decimaldt.Decimal
	TokenName         string
	TokenSymbol       string
	LogoFile          string
	BlockchainAddress string
}

Balance balance type

type Block

type Block struct {
	ID                         ID
	UserID                     ID
	UserName                   string
	AssetID                    ID
	Text                       string
	Images                     []string
	Status                     int
	YtVideoID                  string
	FavoritesCounter           int
	EthereumTransactionAddress string
	CreatedAt                  time.Time
	CreatedAtHuman             string
}

Block asset block data type

type Claim

type Claim struct {
	ID         ID
	UserID     ID
	UserName   string
	TokenID    ID
	Text       string
	IsApproved bool
	LogoFile   string
}

Balance balance type

type Config

type Config struct {
	Environment        string
	DataSourceName     string
	TestDataSourceName string
	AwsSesKey          string
	AwsSesSecret       string
	AwsEmailFrom       string
	SlackWebhookURL    string
	DBMigrationPath    string
	ServerPort         string
	BaseURL            string
}

Config defines config type

type DB

type DB interface {
}

DB db interface data type

type DbBool

type DbBool int8

DbBool TINYINT

type EmailChangeConfirmation

type EmailChangeConfirmation struct {
	UserID ID
	Email  string
	Token  string
}

EmailChangeConfirmation email change confirmation

type FileStorage

type FileStorage interface {
	Put(path string, contentType string, content []byte, acl string) error
}

FileStorage interface for FileStorage

type ID

type ID uint64

ID Database id type

type Liker

type Liker struct {
	UserID   ID
	UserName string
}

Liker Liker data type

type Miner

type Miner struct {
	ID               ID
	UserName         string
	Mined            decimaldt.Decimal
	MiningPercentage string
}

Miner user type

type Person

type Person struct {
	ID          ID
	Name        string
	Email       string
	MinedTokens []Balance
}

Person Person data type

type ServiceContainer

type ServiceContainer struct {
	Config          Config
	AssetService    AssetService
	TimelineService TimelineService
	UserService     UserService
	FileStorage     FileStorage
	Ethereum        *ethereum.Ethereum
}

ServiceContainer defines our service container type

type TimelineEntry

type TimelineEntry struct {
	BlockID                    ID
	UserID                     ID
	UserName                   string
	UserProfileImageURL        string
	AssetID                    ID
	AssetName                  string
	AssetSymbol                string
	OracleID                   ID
	OracleName                 string
	OracleType                 int
	Text                       string
	EthereumTransactionAddress string
	Status                     int
	YtVideoID                  string
	FavoritesCount             int
	DidUserLike                bool
	CreatedAt                  time.Time
	CreatedAtHuman             string
	Images                     []string
}

TimelineEntry timeline entry data type

type TimelineFilter

type TimelineFilter struct {
	Type    TimelineType
	UserID  ID
	AssetID ID
}

TimelineFilter timeline entry data type

type TimelineService

type TimelineService interface {
	FindAll(
		sc ServiceContainer,
		user *User,
		timelineFilter TimelineFilter,
		offset int,
		limit int,
	) ([]TimelineEntry, bool, error) // entries, hasMore, error
}

TimelineService defines timeline service interface

type TimelineType

type TimelineType uint8

TimelineType a data type representing timeline type (SELL, BUY)

type Token

type Token struct {
	ID                ID
	CreatorID         ID
	CreatorName       string
	Name              string
	Symbol            string
	BlockchainAddress string
	TotalSupply       string
	Purpose           string
	TxAddress         string
	FavouriteCount    int
	DidUserLike       bool
	Claims            []Claim
	Miners            []Miner
	Likers            []Liker
}

Token Token data type

type User

type User struct {
	ID              ID        `json:"id"`
	Email           string    `json:"email"`
	Name            string    `json:"name"`
	ProfileImageURL string    `json:"profileImageURL"`
	Password        string    `json:"-"`
	Salt            string    `json:"-"`
	CreatedAt       time.Time `json:"createdAt"`
	UpdatedAt       time.Time `json:"updatedAt"`
	AgreeToTerms    DbBool    `json:"agreeToTerms"`
	IsDeleted       DbBool    `json:"-"`
	EthereumAddress string    `json:"ethereumAddress"`
}

User user type

func NewUser

func NewUser() *User

NewUser creates a new user

func (*User) IsPassword

func (user *User) IsPassword(password string) bool

IsPassword compares given unencrypted-password to user password

type UserResetToken

type UserResetToken struct {
	ID        ID
	UserID    ID
	Token     string
	CreatedAt time.Time
}

UserResetToken reset token struct

func NewUserResetToken

func NewUserResetToken(userID ID) *UserResetToken

NewUserResetToken creates a new reset password token

type UserService

type UserService interface {
	Register(
		email string,
		name string,
		ethereumAddress string,
		password string,
		agreeToTerms bool,
	) (*User, error)
	Validate(string, string) error
	FindByID(ID) (*User, error)
	FindByEmail(string) (*User, error)
	IsEmailRegistered(string) bool
	FindUserBalances(userID ID) ([]Balance, error)
	FindUserBalance(userID ID, assetID ID) (
		availableBalance decimaldt.Decimal,
		reserved decimaldt.Decimal,
		err error,
	)
	NewPassResetTokenByEmail(email string) (*UserResetToken, error)
	ConfirmPassResetToken(userID ID, token, newPassword string) error
	ChangePassword(*User, string, string) error
	CreateChangeEmailConfirmation(*User, string, string) (*EmailChangeConfirmation, error)
	ConfirmUserEmailChange(ID, string) bool
	GetBalances(userID ID) ([]Balance, error)
	GetPerson(userID ID) (*Person, error)
	UpdateProfileImage(user *User, imageURL string) error
}

UserService defines user service interface

Jump to

Keyboard shortcuts

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