database

package
v0.0.0-...-eec4b17 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvDatabaseURI = "DATABASE_URI"
)

Variables

This section is empty.

Functions

func NullIntToUint64

func NullIntToUint64(value sql.NullInt64) uint64

func NullStringToString

func NullStringToString(value sql.NullString) string

NullStringToString allows to convert the given sql.NullString to a string

func NullTimeToTime

func NullTimeToTime(value sql.NullTime) *time.Time

NullTimeToTime allows to convert the given sql.NullTime to a time.Time

func StringToNullString

func StringToNullString(value string) sql.NullString

StringToNullString allows to convert the given string to a sql.NullString

func TimeToNullTime

func TimeToNullTime(value *time.Time) sql.NullTime

TimeToNullTime allows to convert the given time.Time to a sql.NullTime

func Uint64toNullInt

func Uint64toNullInt(value uint64) sql.NullInt64

Types

type Database

type Database struct {
	SQL *sqlx.DB
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(url string, cdc codec.Codec) (*Database, error)

NewDatabase returns a new Database instance

func NewDatabaseFromEnvVariables

func NewDatabaseFromEnvVariables(cdc codec.Codec) (*Database, error)

NewDatabaseFromEnvVariables returns a new Database instance reading the configuration from the environment variables

func (*Database) DeleteAllSessions

func (db *Database) DeleteAllSessions(desmosAddress string) error

DeleteAllSessions deletes all the sessions associated to the given user

func (*Database) DeleteApp

func (db *Database) DeleteApp(appID string) error

DeleteApp deletes the application having the given id, if any.

func (*Database) DeleteNonce

func (db *Database) DeleteNonce(nonce *types.EncryptedNonce) error

DeleteNonce removes the given nonce from the database

func (*Database) DeleteSession

func (db *Database) DeleteSession(sessionToken string) error

DeleteSession deletes the given session from the database

func (*Database) DeleteUser

func (db *Database) DeleteUser(desmosAddress string) error

DeleteUser removes the user with the given address from the database

func (*Database) GetApp

func (db *Database) GetApp(appID string) (*types.Application, bool, error)

GetApp returns the application having the given id, if any. If no application having the given id is found, returns false as second value.

func (*Database) GetAppDeepLinksCount

func (db *Database) GetAppDeepLinksCount(appID string) (uint64, error)

GetAppDeepLinksCount returns the number of deep links that the given application has created during the current day

func (*Database) GetAppDeepLinksRateLimit

func (db *Database) GetAppDeepLinksRateLimit(appID string) (uint64, error)

GetAppDeepLinksRateLimit returns the deep links rate limit for the given application. If 0 is returned, it means that the application has no rate limit.

func (*Database) GetAppFeeGrantRequestsCount

func (db *Database) GetAppFeeGrantRequestsCount(appID string) (uint64, error)

GetAppFeeGrantRequestsCount returns the number of fee grant requests that the given application has performed during the current day

func (*Database) GetAppFeeGrantRequestsLimit

func (db *Database) GetAppFeeGrantRequestsLimit(appID string) (uint64, error)

GetAppFeeGrantRequestsLimit returns the maximum number of fee grant requests that the given application can perform in a day. If 0 is returned, it means that the application has no limit.

func (*Database) GetAppNotificationsCount

func (db *Database) GetAppNotificationsCount(appID string) (uint64, error)

GetAppNotificationsCount returns the number of notifications that the given application has sent during the current day

func (*Database) GetAppNotificationsRateLimit

func (db *Database) GetAppNotificationsRateLimit(appID string) (uint64, error)

GetAppNotificationsRateLimit returns the notifications rate limit for the given application. If 0 is returned, it means that the application has no rate limit.

func (*Database) GetAppToken

func (db *Database) GetAppToken(token string) (*types.EncryptedAppToken, error)

GetAppToken returns the application token having the given value, if any. The value is encrypted before being used to query the database.

func (*Database) GetDeepLinkConfig

func (db *Database) GetDeepLinkConfig(url string) (*types.LinkConfig, error)

GetDeepLinkConfig allows to return the types.LinkConfig associated to the link having the given URL, if any

func (*Database) GetFeeGrantRequest

func (db *Database) GetFeeGrantRequest(appID string, requestID string) (*types.FeeGrantRequest, bool, error)

GetFeeGrantRequest returns the fee grant request having the given id and application id

func (*Database) GetNonce

func (db *Database) GetNonce(desmosAddress string, value string) (*types.EncryptedNonce, error)

GetNonce returns all the nonce stored for the given user

func (*Database) GetNotGrantedFeeGrantRequests

func (db *Database) GetNotGrantedFeeGrantRequests(limit int) ([]types.FeeGrantRequest, error)

GetNotGrantedFeeGrantRequests returns the oldest fee grant requests made from users

func (*Database) GetUserNotificationTokens

func (db *Database) GetUserNotificationTokens(userAddress string) ([]string, error)

GetUserNotificationTokens returns all the device notification tokens for the user having the given address

func (*Database) GetUserSession

func (db *Database) GetUserSession(token string) (*types.EncryptedUserSession, error)

GetUserSession returns the session associated to the given token, if any

func (*Database) HasFeeGrantBeenGrantedToUser

func (db *Database) HasFeeGrantBeenGrantedToUser(appID string, user string) (bool, error)

HasFeeGrantBeenGrantedToUser returns true if the given user has already been granted the fee grant

func (*Database) IsUserAdminOfApp

func (db *Database) IsUserAdminOfApp(userAddress string, appID string) (bool, error)

IsUserAdminOfApp tells whether the given user is an administrator of the app having the given id

func (*Database) SaveApp

func (db *Database) SaveApp(app types.Application) error

SaveApp allows to save the given application inside the database.

func (*Database) SaveAppSubscription

func (db *Database) SaveAppSubscription(subscription types.ApplicationSubscription) error

SaveAppSubscription allows to save the given application subscription inside the database.

func (*Database) SaveAppToken

func (db *Database) SaveAppToken(token types.AppToken) error

SaveAppToken allows to save the given application token inside the database

func (db *Database) SaveCreatedDeepLink(link *types.CreatedDeepLink) error

SaveCreatedDeepLink allows to save the given link inside the database

func (*Database) SaveFeeGrantRequest

func (db *Database) SaveFeeGrantRequest(request types.FeeGrantRequest) error

SaveFeeGrantRequest stores a new authorization request from the given user

func (*Database) SaveNonce

func (db *Database) SaveNonce(nonce *types.Nonce) error

SaveNonce stores the given nonce

func (*Database) SaveSentNotification

func (db *Database) SaveSentNotification(notification *types.SentNotification) error

SaveSentNotification allows to save the given notification inside the database

func (*Database) SaveSession

func (db *Database) SaveSession(session *types.UserSession) error

SaveSession stores the given session inside the database

func (*Database) SaveUser

func (db *Database) SaveUser(desmosAddress string) error

SaveUser stores the given user inside the database

func (*Database) SaveUserNotificationDeviceToken

func (db *Database) SaveUserNotificationDeviceToken(token *types.UserNotificationDeviceToken) error

SaveUserNotificationDeviceToken allows to save the given device token inside the database

func (*Database) SetAppAdmin

func (db *Database) SetAppAdmin(appID string, userAddress string) error

SetAppAdmin sets the given user as admin of the application having the given id

func (*Database) SetFeeGrantRequestGranted

func (db *Database) SetFeeGrantRequestGranted(appID string, userAddress string) error

SetFeeGrantRequestGranted sets the fee grant requests for the given users as granted

func (*Database) SetFeeGrantRequestsGranted

func (db *Database) SetFeeGrantRequestsGranted(ids []string) error

SetFeeGrantRequestsGranted sets the fee grant requests having the given ids as granted

func (*Database) UpdateLoginInfo

func (db *Database) UpdateLoginInfo(desmosAddress string) error

UpdateLoginInfo updates the login info for the user with the given address

func (*Database) UpdateSession

func (db *Database) UpdateSession(session *types.EncryptedUserSession) error

UpdateSession updates the stored data of the given session

Jump to

Keyboard shortcuts

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