Documentation ¶
Index ¶
- Constants
- func NullIntToUint64(value sql.NullInt64) uint64
- func NullStringToString(value sql.NullString) string
- func NullTimeToTime(value sql.NullTime) *time.Time
- func StringToNullString(value string) sql.NullString
- func TimeToNullTime(value *time.Time) sql.NullTime
- func Uint64toNullInt(value uint64) sql.NullInt64
- type Database
- func (db *Database) DeleteAllSessions(desmosAddress string) error
- func (db *Database) DeleteApp(appID string) error
- func (db *Database) DeleteNonce(nonce *types.EncryptedNonce) error
- func (db *Database) DeleteSession(sessionToken string) error
- func (db *Database) DeleteUser(desmosAddress string) error
- func (db *Database) GetApp(appID string) (*types.Application, bool, error)
- func (db *Database) GetAppDeepLinksCount(appID string) (uint64, error)
- func (db *Database) GetAppDeepLinksRateLimit(appID string) (uint64, error)
- func (db *Database) GetAppFeeGrantRequestsCount(appID string) (uint64, error)
- func (db *Database) GetAppFeeGrantRequestsLimit(appID string) (uint64, error)
- func (db *Database) GetAppNotificationsCount(appID string) (uint64, error)
- func (db *Database) GetAppNotificationsRateLimit(appID string) (uint64, error)
- func (db *Database) GetAppToken(token string) (*types.EncryptedAppToken, error)
- func (db *Database) GetDeepLinkConfig(url string) (*types.LinkConfig, error)
- func (db *Database) GetFeeGrantRequest(appID string, requestID string) (*types.FeeGrantRequest, bool, error)
- func (db *Database) GetNonce(desmosAddress string, value string) (*types.EncryptedNonce, error)
- func (db *Database) GetNotGrantedFeeGrantRequests(limit int) ([]types.FeeGrantRequest, error)
- func (db *Database) GetUserNotificationTokens(userAddress string) ([]string, error)
- func (db *Database) GetUserSession(token string) (*types.EncryptedUserSession, error)
- func (db *Database) HasFeeGrantBeenGrantedToUser(appID string, user string) (bool, error)
- func (db *Database) IsUserAdminOfApp(userAddress string, appID string) (bool, error)
- func (db *Database) SaveApp(app types.Application) error
- func (db *Database) SaveAppSubscription(subscription types.ApplicationSubscription) error
- func (db *Database) SaveAppToken(token types.AppToken) error
- func (db *Database) SaveCreatedDeepLink(link *types.CreatedDeepLink) error
- func (db *Database) SaveFeeGrantRequest(request types.FeeGrantRequest) error
- func (db *Database) SaveNonce(nonce *types.Nonce) error
- func (db *Database) SaveSentNotification(notification *types.SentNotification) error
- func (db *Database) SaveSession(session *types.UserSession) error
- func (db *Database) SaveUser(desmosAddress string) error
- func (db *Database) SaveUserNotificationDeviceToken(token *types.UserNotificationDeviceToken) error
- func (db *Database) SetAppAdmin(appID string, userAddress string) error
- func (db *Database) SetFeeGrantRequestGranted(appID string, userAddress string) error
- func (db *Database) SetFeeGrantRequestsGranted(ids []string) error
- func (db *Database) UpdateLoginInfo(desmosAddress string) error
- func (db *Database) UpdateSession(session *types.EncryptedUserSession) error
Constants ¶
const (
EnvDatabaseURI = "DATABASE_URI"
)
Variables ¶
This section is empty.
Functions ¶
func NullIntToUint64 ¶
func NullStringToString ¶
func NullStringToString(value sql.NullString) string
NullStringToString allows to convert the given sql.NullString to a string
func NullTimeToTime ¶
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 ¶
TimeToNullTime allows to convert the given time.Time to a sql.NullTime
func Uint64toNullInt ¶
Types ¶
type Database ¶
func NewDatabase ¶
NewDatabase returns a new Database instance
func NewDatabaseFromEnvVariables ¶
NewDatabaseFromEnvVariables returns a new Database instance reading the configuration from the environment variables
func (*Database) DeleteAllSessions ¶
DeleteAllSessions deletes all the sessions associated to the given user
func (*Database) DeleteNonce ¶
func (db *Database) DeleteNonce(nonce *types.EncryptedNonce) error
DeleteNonce removes the given nonce from the database
func (*Database) DeleteSession ¶
DeleteSession deletes the given session from the database
func (*Database) DeleteUser ¶
DeleteUser removes the user with the given address from the database
func (*Database) GetApp ¶
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 ¶
GetAppDeepLinksCount returns the number of deep links that the given application has created during the current day
func (*Database) GetAppDeepLinksRateLimit ¶
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 ¶
GetAppFeeGrantRequestsCount returns the number of fee grant requests that the given application has performed during the current day
func (*Database) GetAppFeeGrantRequestsLimit ¶
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 ¶
GetAppNotificationsCount returns the number of notifications that the given application has sent during the current day
func (*Database) GetAppNotificationsRateLimit ¶
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) GetNotGrantedFeeGrantRequests ¶
func (db *Database) GetNotGrantedFeeGrantRequests(limit int) ([]types.FeeGrantRequest, error)
GetNotGrantedFeeGrantRequests returns the oldest fee grant requests made from users
func (*Database) GetUserNotificationTokens ¶
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 ¶
HasFeeGrantBeenGrantedToUser returns true if the given user has already been granted the fee grant
func (*Database) IsUserAdminOfApp ¶
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 ¶
SaveAppToken allows to save the given application token inside the database
func (*Database) SaveCreatedDeepLink ¶
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) 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) SaveUserNotificationDeviceToken ¶
func (db *Database) SaveUserNotificationDeviceToken(token *types.UserNotificationDeviceToken) error
SaveUserNotificationDeviceToken allows to save the given device token inside the database
func (*Database) SetAppAdmin ¶
SetAppAdmin sets the given user as admin of the application having the given id
func (*Database) SetFeeGrantRequestGranted ¶
SetFeeGrantRequestGranted sets the fee grant requests for the given users as granted
func (*Database) SetFeeGrantRequestsGranted ¶
SetFeeGrantRequestsGranted sets the fee grant requests having the given ids as granted
func (*Database) UpdateLoginInfo ¶
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