types

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	EventTypeProfileSaved   = "profile_saved"
	EventTypeProfileDeleted = "profile_deleted"

	// Profile attributes
	AttributeProfileDtag         = "profile_dtag"
	AttributeProfileCreator      = "profile_creator"
	AttributeProfileCreationTime = "profile_creation_time"
)
View Source
const (
	ModuleName = "profiles"
	RouterKey  = ModuleName
	StoreKey   = ModuleName

	ActionSaveProfile   = "save_profile"
	ActionDeleteProfile = "delete_profile"

	//Queries
	QuerierRoute  = ModuleName
	QueryProfile  = "profile"
	QueryProfiles = "all"
	QueryParams   = "params"
)
View Source
const (
	// default paramspace for paramsModule keeper
	DefaultParamspace = ModuleName
)

Variables

View Source
var (
	URIRegEx = regexp.MustCompile(`^(?:http(s)?://)[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]+$`)

	ProfileStorePrefix = []byte("profile")
	DtagStorePrefix    = []byte("dtag")
)
View Source
var (
	DefaultMinMonikerLength = sdk.NewInt(2)
	DefaultMaxMonikerLength = sdk.NewInt(1000) //longest name on earth count 954 chars
	DefaultRegEx            = `^[A-Za-z0-9_]+$`
	DefaultMinDTagLength    = sdk.NewInt(3)
	DefaultMaxDTagLength    = sdk.NewInt(30)
	DefaultMaxBioLength     = sdk.NewInt(1000)
)

Default profile paramsModule

View Source
var (
	MonikerLenParamsKey = []byte("MonikerParams")
	DtagLenParamsKey    = []byte("DtagParams")
	MaxBioLenParamsKey  = []byte("MaxBioLen")
)

Parameters store keys

View Source
var ModuleCdc = codec.New()

ModuleCdc is the codec used inside the whole profile module

Functions

func DtagStoreKey

func DtagStoreKey(dtag string) []byte

DtagStoreKey turns a dtag to a key used to store a dtag -> address couple

func ParamKeyTable

func ParamKeyTable() paramsModule.KeyTable

ParamKeyTable Key declaration for parameters

func ProfileStoreKey

func ProfileStoreKey(address sdk.AccAddress) []byte

ProfileStoreKey turns an address to a key used to store a profile into the profiles store

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

func ValidateBioParams

func ValidateBioParams(i interface{}) error

func ValidateDtagParams

func ValidateDtagParams(i interface{}) error

func ValidateGenesis

func ValidateGenesis(data GenesisState) error

ValidateGenesis validates the given genesis state and returns an error if something is invalid

func ValidateMonikerParams

func ValidateMonikerParams(i interface{}) error

Types

type DtagParams

type DtagParams struct {
	RegEx      string  `json:"reg_ex" yaml:"reg_ex"`
	MinDtagLen sdk.Int `json:"min_length" yaml:"min_length"`
	MaxDtagLen sdk.Int `json:"max_length" yaml:"max_length"`
}

DtagParams defines the paramsModule around profiles' dtag

func DefaultDtagParams

func DefaultDtagParams() DtagParams

DefaultDtagParams return default paramsModule

func NewDtagParams

func NewDtagParams(regEx string, minLen, maxLen sdk.Int) DtagParams

NewDtagParams creates a new DtagParams obj

func (DtagParams) String

func (params DtagParams) String() string

String implements stringer interface

type GenesisState

type GenesisState struct {
	Profiles []Profile `json:"profiles" yaml:"profiles"`
	Params   Params    `json:"params" yaml:"params"`
}

GenesisState contains the data of the genesis state for the profile module

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState returns a default GenesisState

func NewGenesisState

func NewGenesisState(profiles []Profile, params Params) GenesisState

NewGenesisState creates a new genesis state

type MonikerParams

type MonikerParams struct {
	MinMonikerLen sdk.Int `json:"min_length" yaml:"min_length"`
	MaxMonikerLen sdk.Int `json:"max_length" yaml:"max_length"`
}

MonikerParams defines the paramsModule around moniker len

func DefaultMonikerParams

func DefaultMonikerParams() MonikerParams

DefaultMonikerParams return default moniker params

func NewMonikerParams

func NewMonikerParams(minLen, maxLen sdk.Int) MonikerParams

NewMonikerParams creates a new MonikerParams obj

func (MonikerParams) String

func (params MonikerParams) String() string

String implements stringer interface

type MsgDeleteProfile

type MsgDeleteProfile struct {
	Creator sdk.AccAddress `json:"creator" yaml:"creator"`
}

MsgDeleteProfile defines a DeleteProfile message

func NewMsgDeleteProfile

func NewMsgDeleteProfile(creator sdk.AccAddress) MsgDeleteProfile

NewMsgDeleteProfile is a constructor function for MsgDeleteProfile

func (MsgDeleteProfile) GetSignBytes

func (msg MsgDeleteProfile) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgDeleteProfile) GetSigners

func (msg MsgDeleteProfile) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgDeleteProfile) Route

func (msg MsgDeleteProfile) Route() string

Route should return the name of the module

func (MsgDeleteProfile) Type

func (msg MsgDeleteProfile) Type() string

Type should return the action

func (MsgDeleteProfile) ValidateBasic

func (msg MsgDeleteProfile) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type MsgSaveProfile

type MsgSaveProfile struct {
	Dtag       string         `json:"dtag" yaml:"dtag"`
	Moniker    *string        `json:"moniker,omitempty" yaml:"moniker,omitempty"`
	Bio        *string        `json:"bio,omitempty" yaml:"bio,omitempty"`
	ProfilePic *string        `json:"profile_picture,omitempty" yaml:"profile_pic,omitempty"`
	CoverPic   *string        `json:"cover_picture,omitempty" yaml:"cover_pic,omitempty"`
	Creator    sdk.AccAddress `json:"creator" yaml:"creator"`
}

MsgSaveProfile defines a SaveProfile message

func NewMsgSaveProfile

func NewMsgSaveProfile(dtag string, moniker, bio, profilePic, coverPic *string, creator sdk.AccAddress) MsgSaveProfile

NewMsgSaveProfile is a constructor function for MsgSaveProfile

func (MsgSaveProfile) GetSignBytes

func (msg MsgSaveProfile) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgSaveProfile) GetSigners

func (msg MsgSaveProfile) GetSigners() []sdk.AccAddress

GetSigners defines whose signature is required

func (MsgSaveProfile) Route

func (msg MsgSaveProfile) Route() string

Route should return the name of the module

func (MsgSaveProfile) Type

func (msg MsgSaveProfile) Type() string

Type should return the action

func (MsgSaveProfile) ValidateBasic

func (msg MsgSaveProfile) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Params

type Params struct {
	MonikerParams MonikerParams `json:"moniker_params" yaml:"moniker_params"`
	DtagParams    DtagParams    `json:"dtag_params" yaml:"dtag_params"`
	MaxBioLen     sdk.Int       `json:"max_bio_length" yaml:"max_bio_length"`
}

func DefaultParams

func DefaultParams() Params

DefaultParams return default paramsModule

func NewParams

func NewParams(monikerLen MonikerParams, dtagLen DtagParams, maxBioLen sdk.Int) Params

NewParams creates a new ProfileParams obj

func (*Params) ParamSetPairs

func (params *Params) ParamSetPairs() paramsModule.ParamSetPairs

ParamSetPairs implements the ParamSet interface and returns the key/value pairs of profile module's parameters.

func (Params) String

func (params Params) String() string

func (Params) Validate

func (params Params) Validate() error

Validate perform basic checks on all parameters to ensure they are correct

type Pictures

type Pictures struct {
	Profile *string `json:"profile,omitempty" yaml:"profile,omitempty"`
	Cover   *string `json:"cover,omitempty" yaml:"cover,omitempty"`
}

Pictures contains the data of a user profile's related pictures

func NewPictures

func NewPictures(profile, cover *string) *Pictures

NewPictures is a constructor function for Pictures

func (Pictures) Equals

func (pic Pictures) Equals(otherPic *Pictures) bool

Equals allows to check whether the contents of pic are the same of otherPics

func (Pictures) Validate

func (pic Pictures) Validate() error

Validate check the validity of the Pictures

type Profile

type Profile struct {
	DTag         string         `json:"dtag" yaml:"dtag"`
	Moniker      *string        `json:"moniker,omitempty" yaml:"moniker,omitempty"`
	Bio          *string        `json:"bio,omitempty" yaml:"bio,omitempty"`
	Pictures     *Pictures      `json:"pictures,omitempty" yaml:"pictures,omitempty"`
	Creator      sdk.AccAddress `json:"creator" yaml:"creator"`
	CreationDate time.Time      `json:"creation_date" yaml:"creation_date"`
}

Profile represents a generic first on Desmos, containing the information of a single user

func NewProfile

func NewProfile(dtag string, creator sdk.AccAddress, creationDate time.Time) Profile

func (Profile) Equals

func (profile Profile) Equals(other Profile) bool

Equals allows to check whether the contents of acc are the same of other

func (Profile) String

func (profile Profile) String() string

String implements fmt.Stringer

func (Profile) Validate

func (profile Profile) Validate() error

Validate check the validity of the Profile

func (Profile) WithBio

func (profile Profile) WithBio(bio *string) Profile

WithBio updates profile's bio with the given one

func (Profile) WithMoniker

func (profile Profile) WithMoniker(moniker *string) Profile

WithMoniker updates profile's moniker with the given one

func (Profile) WithPictures

func (profile Profile) WithPictures(profilePic, coverPic *string) Profile

WithPicture updates profile's pictures with the given one

type Profiles

type Profiles []Profile

Profiles represents a slice of profile objects

func NewProfiles

func NewProfiles(profiles ...Profile) Profiles

NewProfiles allows to easily create a Profiles object from a list of profiles

Jump to

Keyboard shortcuts

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