user

package
v0.0.0-...-d4303dc Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddWalletToUser

func AddWalletToUser(pCtx context.Context, pUserID persist.DBID, pChainAddress persist.ChainAddress, addressAuth auth.Authenticator,
	userRepo *postgres.UserRepository, mp *multichain.Provider) error

AddWalletToUser adds a single wallet to a user in the DB because a signature needs to be provided and validated per address

func CreateUser

func CreateUser(ctx context.Context, createUserParams persist.CreateUserInput, createGalleryParams coredb.GalleryRepoCreateParams, userRepo *postgres.UserRepository,
	queries *coredb.Queries) (userID persist.DBID, galleryID persist.DBID, err error)

CreateUser creates a new user

func RemoveWalletsFromUser

func RemoveWalletsFromUser(pCtx context.Context, pUserID persist.DBID, pWalletIDs []persist.DBID, userRepo *postgres.UserRepository) ([]persist.DBID, error)

RemoveWalletsFromUser removes wallets from a user in the DB, and returns the IDs of the wallets that were removed. The set of removed IDs is valid even in cases where this function returns an error; it will contain the IDs of wallets that were successfully removed before the error occurred.

func UpdateUserInfo

func UpdateUserInfo(pCtx context.Context, userID persist.DBID, username string, bio string, userRepository *postgres.UserRepository, ethClient *ethclient.Client) error

UpdateUserInfo updates a user by ID and ensures that if they are using an ENS name as a username that their address resolves to that ENS

Types

type AddUserAddressOutput

type AddUserAddressOutput struct {
	SignatureValid bool `json:"signature_valid"`
}

AddUserAddressOutput is the output of the user add address pipeline

type AddUserAddressesInput

type AddUserAddressesInput struct {

	// needed because this is a new user that cant be logged into, and the client creating
	// the user still needs to prove ownership of their address.
	Signature  string             `json:"signature" binding:"signature"`
	Nonce      string             `json:"nonce"`
	Address    persist.Address    `json:"address"   binding:"required"`
	Chain      persist.Chain      `json:"chain"`
	WalletType persist.WalletType `json:"wallet_type"`
}

AddUserAddressesInput is the input for the user add addresses pipeline and also user creation pipeline given that they have the same requirements

type CreateUserOutput

type CreateUserOutput struct {
	SignatureValid bool         `json:"signature_valid"`
	JWTtoken       string       `json:"jwt_token"` // JWT token is sent back to user to use to continue onboarding
	UserID         persist.DBID `json:"user_id"`
	GalleryID      persist.DBID `json:"gallery_id"`
}

CreateUserOutput is the output of the user create pipeline

type ErrUserAlreadyExists

type ErrUserAlreadyExists struct {
	Address       persist.Address
	Chain         persist.Chain
	Authenticator string
}

func (ErrUserAlreadyExists) Error

func (e ErrUserAlreadyExists) Error() string

type GetUserInput

type GetUserInput struct {
	UserID   persist.DBID    `json:"user_id" form:"user_id"`
	Address  persist.Address `json:"address" form:"address"`
	Chain    persist.Chain   `json:"chain" form:"chain"`
	Username string          `json:"username" form:"username"`
}

GetUserInput is the input for the user get pipeline

type GetUserOutput

type GetUserOutput struct {
	UserID    persist.DBID     `json:"id"`
	Username  string           `json:"username"`
	BioStr    string           `json:"bio"`
	Addresses []persist.Wallet `json:"addresses"`
	CreatedAt time.Time        `json:"created_at"`
}

GetUserOutput is the output of the user get pipeline

func GetUser

func GetUser(pCtx context.Context, pInput GetUserInput, userRepo postgres.UserRepository) (GetUserOutput, error)

GetUser returns a user by ID or address or username

type MergeUsersInput

type MergeUsersInput struct {
	SecondUserID persist.DBID       `json:"second_user_id" binding:"required"`
	Signature    string             `json:"signature" binding:"signature"`
	Nonce        string             `json:"nonce"`
	Address      persist.Address    `json:"address"   binding:"required"`
	Chain        persist.Chain      `json:"chain"`
	WalletType   persist.WalletType `json:"wallet_type"`
}

MergeUsersInput is the input for the user merge pipeline

type RemoveUserAddressesInput

type RemoveUserAddressesInput struct {
	Addresses []persist.Address `json:"addresses"   binding:"required"`
	Chains    []persist.Chain   `json:"chains"      binding:"required"`
}

RemoveUserAddressesInput is the input for the user remove addresses pipeline

Jump to

Keyboard shortcuts

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