store

package
v0.0.0-...-44f1c0e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alien

type Alien struct {
	ID           int            `db:"id"`
	FightID      sql.NullInt64  `db:"fight_id"`
	Ipfs         sql.NullString `db:"ipfs_hash"`
	Name         string         `db:"name"`
	ReadableName string         `db:"readable_name"`
	Background   string         `db:"background"`
	Skin         string         `db:"skin"`
	Clothes      string         `db:"clothes"`
	Eyes         string         `db:"eyes"`
	Mouth        string         `db:"mouth"`
	Hand         string         `db:"hand"`
	Hat          string         `db:"hat"`
	Collection   string         `db:"collection"`
	Site         string         `db:"site"`
	Twitter      string         `db:"twitter"`
	Copyright    string         `db:"copyright"`
}

Alient struct for zfc alien

type FightDb

type FightDb struct {
	ID                    int            `db:"id"`
	ZombieName            string         `db:"zombie_name"`
	HunterName            string         `db:"hunter_name"`
	Status                string         `db:"status"`
	CreatedDate           time.Time      `db:"created_date"`
	MintedDate            sql.NullTime   `db:"minted_date"`
	PaymentAmountLovelace int64          `db:"payment_amount_lovelace"`
	PaymentAddress        string         `db:"payment_address"`
	IncomingUtxo          sql.NullString `db:"incoming_utxo"`
	IncomingUtxoInt       sql.NullInt64  `db:"incoming_utxo_index"`
	IPFS                  sql.NullString `db:"ipfs_fight"`
	IPFSAlien             sql.NullString `db:"ipfs_alien"`
	Background            sql.NullString `db:"background"`
	ZombieLifeBar         sql.NullInt64  `db:"zclifebar"`
	HunterLifeBar         sql.NullInt64  `db:"zhlifebar"`
	ZombieRecord          sql.NullString `db:"zombie_record"`
	HunterRecord          sql.NullString `db:"hunter_record"`
	ZombieKo              sql.NullBool   `db:"zombie_ko"`
	HunterKo              sql.NullBool   `db:"hunter_ko"`
	Collection            string         `db:"collection"`
	Site                  string         `db:"site"`
	Twitter               string         `db:"twitter"`
	Copyright             string         `db:"copyright"`
	HunterAmountAda       int            `db:"hunter_amount_ada"`
	HunterSendAddress     sql.NullString `db:"hunter_send_address"`
	ZombieAmountAda       int            `db:"zombie_amount_ada"`
	ZombieSendAddress     sql.NullString `db:"zombie_send_address"`
	TxID                  sql.NullString `db:"tx_id"`
	TweetID               sql.NullString `db:"tweet_id"`
}

FightDb struct for fight db

type FightDto

type FightDto struct {
	ID                    int
	ZombieName            string     `json:"zombieName"`
	HunterName            string     `json:"hunterName"`
	PaymentAmountLovelace int64      `json:"paymentAmountLovelace"`
	PaymentAmountAda      string     `json:"paymentAmountAda"`
	PaymentAddress        string     `json:"paymentAddress"`
	Status                string     `json:"status"`
	CreatedDate           *time.Time `json:"createdDate"`
	MintedDate            *time.Time `json:"mintedDate,omitempty"`
	FightIPFS             string     `json:"fightIPFS,omitempty"`
	AlienIPFS             string     `json:"alienIPFS,omitempty"`
	MinutesUntilExpired   int        `json:"minutesUntilExpired,omitempty"`
	Winner                string     `json:"winner"`
	Loser                 string     `json:"loser"`
	TweetLink             string     `json:"tweetLink"`
	HunterSendAddress     string
	ZombieSendAddress     string
}

FightDto dto for fight

type Nft

type Nft struct {
	ID      int             `db:"id"`
	NftName string          `db:"name"`
	NftType string          `db:"nft_type"`
	Wins    int             `db:"wins"`
	Loses   int             `db:"loses"`
	Percent sql.NullFloat64 `db:"winpercent"`
}

type Store

type Store struct {
	Db *sqlx.DB
}

Store struct to store Db

func (Store) CreateFight

func (s Store) CreateFight(fight FightDto, hunterUser UserNfts, zombieUser UserNfts, mintingUser User) (int, error)

CreateFight persist a new fight

func (Store) GetAlienByFightId

func (s Store) GetAlienByFightId(fightId int) (*Alien, error)

GetAlienByFightId get alient by fight id

func (Store) GetFightForPaymentLastFifteen

func (s Store) GetFightForPaymentLastFifteen(lovelace int64) (*FightDb, error)

GetFightForPaymentLastFifteen get fight for utxo and index

func (Store) GetFightForUtxo

func (s Store) GetFightForUtxo(utxo string, index int) ([]FightDb, error)

GetFightForUtxo get fight for utxo and index

func (Store) GetFightsForUser

func (s Store) GetFightsForUser(user User) ([]FightDb, error)

GetFightsForUser get fights for user

func (Store) GetFightsForUserAndId

func (s Store) GetFightsForUserAndId(user User, fightId int) ([]FightDb, error)

GetFightsForUserAndId get fights for user and id

func (Store) GetListedNftByName

func (s Store) GetListedNftByName(name string) ([]UserNfts, error)

GetListedNftByName get nft by name

func (Store) GetListedNfts

func (s Store) GetListedNfts(nftType string, limit int, random bool) ([]UserNfts, error)

GetListedNfts get all nfts listed

func (Store) GetListedNftsByName

func (s Store) GetListedNftsByName(nftType string, name string) ([]UserNfts, error)

func (Store) GetMintedFights

func (s Store) GetMintedFights() ([]FightDb, error)

GetMintedFights get minted fights

func (Store) GetNextAvailableAlien

func (s Store) GetNextAvailableAlien() (*Alien, error)

GetNextAvailableAlien get next available alien

func (Store) GetNftByName

func (s Store) GetNftByName(name string) (*Nft, error)

func (Store) GetNftHighestPercentMinimum

func (s Store) GetNftHighestPercentMinimum(minimum int, limit int) ([]Nft, error)

func (Store) GetNftMostLoses

func (s Store) GetNftMostLoses(limit int) ([]Nft, error)

func (Store) GetNftMostWins

func (s Store) GetNftMostWins(limit int) ([]Nft, error)

func (Store) GetNftsOwnedByUser

func (s Store) GetNftsOwnedByUser(userID int) ([]UserNfts, error)

GetNftsOwnedByUser Gets owned nfts by user

func (Store) GetQueuedFight

func (s Store) GetQueuedFight() ([]FightDb, error)

GetQueuedFight get fight for utxo and index

func (Store) GetStagedFights

func (s Store) GetStagedFights() ([]FightDb, error)

GetStagedFights get fight for utxo and index

func (Store) GetUserByID

func (s Store) GetUserByID(userID int) (*User, error)

GetUserByNftkeyID Gets a user using their nftkey id

func (Store) GetUserByNftkeyID

func (s Store) GetUserByNftkeyID(nftKeyUserID string) (*User, error)

GetUserByNftkeyID Gets a user using their nftkey id

func (Store) InsertUser

func (s Store) InsertUser(nftkeyID, accessToken, refreshToken string) error

InsertUser inserts a new user into the db

func (Store) InsertZcNftOwnedByUser

func (s Store) InsertZcNftOwnedByUser(userID int, nftID int) error

InsertZcNftOwnedByUser inserts nft owned by user

func (Store) MoveFightFromMintedToConfirmed

func (s Store) MoveFightFromMintedToConfirmed(ctx context.Context, fightID int) error

func (Store) MoveFightFromPendingToQueued

func (s Store) MoveFightFromPendingToQueued(ctx context.Context, fightID int, alienID int, utxo string, utxoIndex int) error

func (Store) MoveFightFromQueuedToStaged

func (s Store) MoveFightFromQueuedToStaged(ctx context.Context, alienID int, alienIpfs string, fightID int, fightIpfs, background, zombieRecord, hunterRecord string, zcLifeBar, zhLifeBar int, zombieKo, hunterKo, zombieBeahup, hunterBeatup bool, winningNft string, losingNft string) error

func (Store) MoveFightFromStagedToMinted

func (s Store) MoveFightFromStagedToMinted(ctx context.Context, fightID int, txHash string) error

func (Store) RemoveZcNftNotOwnedByUser

func (s Store) RemoveZcNftNotOwnedByUser(userID int, nftID int) error

RemoveZcNftNotOwnedByUser removes nft not owned by user

func (Store) RemoveZcNftOwnedByUser

func (s Store) RemoveZcNftOwnedByUser(userID int, nftID int) error

RemoveZcNftOwnedByUser remove nft owned by user

func (Store) SetLastAssetCheckTime

func (s Store) SetLastAssetCheckTime(nftkeyID string, now time.Time) error

SetLastAssetCheckTime updates last asset check time

func (Store) UpdateNftListPrice

func (s Store) UpdateNftListPrice(listPrice *int16, userID, nftID int) error

UpdateNftListPrice update list price

func (Store) UpdateTweetID

func (s Store) UpdateTweetID(ctx context.Context, fightID int, tweetID string) error

func (Store) UpdatedUser

func (s Store) UpdatedUser(nftkeyID, accessToken, refreshToken string) error

UpdatedUser updates a new user in the db

type User

type User struct {
	ID                   int          `db:"id"`
	NftkeymeID           string       `db:"nftkeyme_id"`
	NftkeymeAccessToken  string       `db:"nftkeyme_access_token"`
	NftkeymeRefreshToken string       `db:"nftkeyme_refresh_token"`
	LastAssetCheckTime   sql.NullTime `db:"last_asset_check_time"`
}

User struct to store user info

type UserNfts

type UserNfts struct {
	UserID     int           `db:"zfc_user_id"`
	NftID      int           `db:"nft_id"`
	NftName    string        `db:"name"`
	NftType    string        `db:"nft_type"`
	ListAmount sql.NullInt16 `db:"amount_ada"`
	ListDate   sql.NullTime  `db:"listed_date"`
	Wins       int           `db:"wins"`
	Loses      int           `db:"loses"`
}

UserNfts struct to hold nfts owned by user

Jump to

Keyboard shortcuts

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