Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrExpired = errors.New("auction expired") ErrAuctionNotFound = errors.New("auction not found") ErrInvalidAuction = errors.New("invalid auction") )
View Source
var ( ErrInvalidBid = errors.New("invalid bid") ErrBidNotFound = errors.New("bid not found") )
View Source
var ( ErrInvalidContract = errors.New("invalid contract") ErrContractNotFound = errors.New("contract not found") )
View Source
var ( ErrInvalidOrder = errors.New("invalid order") ErrOrderNotFound = errors.New("order not found") )
View Source
var ( ErrInvalidStation = errors.New("invalid station") ErrStationNotFound = errors.New("station not found") )
View Source
var ( ErrInvalidUser = errors.New("invalid user") ErrUserNotFound = errors.New("user not found") )
Functions ¶
This section is empty.
Types ¶
type Auction ¶
type Auction struct { Id uint `json:"id" gorm:"primaryKey"` Credits custom_type.BigInt `json:"credits,omitempty" gorm:"type:bigint;not null"` PriceLimit custom_type.BigInt `json:"price_limit,omitempty" gorm:"type:bigint;not null"` State AuctionState `json:"state,omitempty" gorm:"type:text;not null"` Bids []*Bid `json:"bids,omitempty" gorm:"foreignKey:AuctionId;constraint:OnDelete:CASCADE"` ExpiresAt int64 `json:"expires_at,omitempty" gorm:"not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
func NewAuction ¶
func NewAuction(credits custom_type.BigInt, priceLimit custom_type.BigInt, expiresAt int64, createdAt int64) (*Auction, error)
type AuctionRepository ¶
type AuctionState ¶
type AuctionState string
const ( AuctionOngoing AuctionState = "ongoing" AuctionFinished AuctionState = "finished" AuctionCancelled AuctionState = "cancelled" )
type Bid ¶
type Bid struct { Id uint `json:"id" gorm:"primaryKey"` AuctionId uint `json:"auction_id" gorm:"not null;index"` Bidder custom_type.Address `json:"bidder,omitempty" gorm:"not null"` Credits custom_type.BigInt `json:"credits,omitempty" gorm:"type:bigint;not null"` Price custom_type.BigInt `json:"price,omitempty" gorm:"type:bigint;not null"` State BidState `json:"state,omitempty" gorm:"type:text;not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
func NewBid ¶
func NewBid(auctionId uint, bidder custom_type.Address, credits custom_type.BigInt, price custom_type.BigInt, createdAt int64) (*Bid, error)
type BidRepository ¶
type Contract ¶
type Contract struct { Id uint `json:"id" gorm:"primaryKey"` Symbol string `json:"symbol,omitempty" gorm:"uniqueIndex;not null"` Address custom_type.Address `json:"address,omitempty" gorm:"type:text;not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
func NewContract ¶
type ContractRepository ¶
type Order ¶
type Order struct { Id uint `json:"id" gorm:"primaryKey"` Buyer custom_type.Address `json:"buyer,omitempty" gorm:"type:text;not null"` Credits custom_type.BigInt `json:"credits,omitempty" gorm:"type:bigint;not null"` StationId string `json:"station_id,omitempty" gorm:"not null"` PricePerCredit custom_type.BigInt `json:"price_per_credit,omitempty" gorm:"type:bigint;not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
type OrderRepository ¶
type Station ¶
type Station struct { Id string `json:"id" gorm:"primaryKey"` Consumption custom_type.BigInt `json:"consumption,omitempty" gorm:"type:bigint;not null"` Owner custom_type.Address `json:"owner,omitempty" gorm:"not null"` State StationState `json:"state,omitempty" gorm:"type:text;not null"` Orders []*Order `json:"orders,omitempty" gorm:"foreignKey:StationId;constraint:OnDelete:CASCADE"` PricePerCredit custom_type.BigInt `json:"price_per_credit,omitempty" gorm:"type:bigint;not null"` Latitude float64 `json:"latitude,omitempty" gorm:"not null"` Longitude float64 `json:"longitude,omitempty" gorm:"not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
func NewStation ¶
func NewStation(id string, owner custom_type.Address, consumption custom_type.BigInt, pricePerCredit custom_type.BigInt, latitude float64, longitude float64, createdAt int64) (*Station, error)
type StationRepository ¶
type StationState ¶
type StationState string
const ( StationStateActive StationState = "active" StationStateInactive StationState = "inactive" )
type User ¶
type User struct { Id uint `json:"id" gorm:"primaryKey"` Role string `json:"role,omitempty" gorm:"not null"` Address custom_type.Address `json:"address,omitempty" gorm:"type:text;uniqueIndex;not null"` CreatedAt int64 `json:"created_at,omitempty" gorm:"not null"` UpdatedAt int64 `json:"updated_at,omitempty" gorm:"default:0"` }
type UserRepository ¶
type UserRepository interface { CreateUser(User *User) (*User, error) FindUserByRole(role string) (*User, error) FindUserByAddress(address custom_type.Address) (*User, error) UpdateUser(User *User) (*User, error) FindAllUsers() ([]*User, error) DeleteUserByAddress(address custom_type.Address) error }
Click to show internal directories.
Click to hide internal directories.