types

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeCreateSession = "create_session"

	AttributeKeySessionID     = "session_id"
	AttributeKeyNamespace     = "namespace"
	AttributeKeyExternalOwner = "external_owner"
	AttributeKeyExpiry        = "expiry"

	AttributeValueCategory = ModuleName
)

Magpie module event types

View Source
const (
	ModuleName = "magpie"
	RouterKey  = ModuleName
	StoreKey   = ModuleName

	ActionCreationSession = "create_session"
)

Variables

View Source
var (
	SessionLengthKey      = []byte("default_session_length")
	LastSessionIDStoreKey = []byte("last_session_id")
	SessionStorePrefix    = []byte("session")
)
View Source
var ModuleCdc = codec.New()

ModuleCdc is the codec

Functions

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers concrete types on the Amino codec

func SessionStoreKey added in v0.3.0

func SessionStoreKey(id SessionID) []byte

SessionStoreKey turns a session id to a key used to store a session into the sessions store nolint: interfacer

func ValidateGenesis added in v0.3.0

func ValidateGenesis(state GenesisState) error

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

Types

type GenesisState added in v0.3.0

type GenesisState struct {
	DefaultSessionLength int64    `json:"default_session_length"`
	Sessions             Sessions `json:"sessions"`
}

GenesisState represents the genesis state for the magpie module

func DefaultGenesisState added in v0.3.0

func DefaultGenesisState() GenesisState

DefaultGenesisState returns a default GenesisState

func NewGenesisState added in v0.3.0

func NewGenesisState(defaultSessionLength int64, sessions Sessions) GenesisState

NewGenesisState allows to create a new genesis state containing the given default session length and sessions

type MsgCreateSession

type MsgCreateSession struct {
	Owner         sdk.AccAddress `json:"owner" yaml:"owner"`
	Namespace     string         `json:"namespace" yaml:"namespace"`
	ExternalOwner string         `json:"external_owner" yaml:"external_owner"`
	PubKey        string         `json:"pub_key" yaml:"pub_key"`
	Signature     string         `json:"signature" yaml:"signature"`
}

MsgCreateSession defines the MsgCreateSession message

func NewMsgCreateSession

func NewMsgCreateSession(owner sdk.AccAddress, namespace string, externalOwner string, pubkey string, signature string) MsgCreateSession

NewMsgCreateSession is the constructor of MsgCreateSession

func (MsgCreateSession) GetSignBytes

func (msg MsgCreateSession) GetSignBytes() []byte

GetSignBytes encodes the message for signing

func (MsgCreateSession) GetSigners

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

GetSigners defines whose signature is required

func (MsgCreateSession) Route

func (msg MsgCreateSession) Route() string

Route should return the name of the module

func (MsgCreateSession) Type

func (msg MsgCreateSession) Type() string

Type should return the action

func (MsgCreateSession) ValidateBasic

func (msg MsgCreateSession) ValidateBasic() error

ValidateBasic runs stateless checks on the message

type Session

type Session struct {
	SessionID     SessionID      `json:"id,string" yaml:"id,string"`                    // Id of the session
	Owner         sdk.AccAddress `json:"owner" yaml:"owner"`                            // Desmos owner of this session
	Created       int64          `json:"creation_time,string" yaml:"creation_time"`     // Block height at which the session has been created
	Expiry        int64          `json:"expiration_time,string" yaml:"expiration_time"` // Block height at which the session will expire
	Namespace     string         `json:"namespace" yaml:"namespace"`                    // External chain identifier
	ExternalOwner string         `json:"external_owner" yaml:"external_owner"`          // External chain owner address
	PubKey        string         `json:"pub_key" yaml:"pub_key"`                        // External chain owner public key
	Signature     string         `json:"signature" yaml:"signature"`                    // Session signature
}

Session is a struct of a user session

func NewSession

func NewSession(id SessionID, owner sdk.AccAddress, created, expiry int64,
	namespace, externalOwner, pubKey, signature string) Session

NewSession return a new session containing the given parameters

func (Session) Equals

func (s Session) Equals(other Session) bool

Equals returns true iff s and other contain the same data

func (Session) String

func (s Session) String() string

implement fmt.Stringer

type SessionID

type SessionID uint64

SessionID represents a unique session id

func ParseSessionID

func ParseSessionID(value string) (SessionID, error)

ParseSessionID take the given string value and parses it returning a SessionID. If the given value is not valid, returns an error instead

func (SessionID) Next

func (id SessionID) Next() SessionID

Next returns the next id to this one

func (SessionID) String

func (id SessionID) String() string

String implements fmt.Stringer

func (SessionID) Valid

func (id SessionID) Valid() bool

Valid returns true if and only if this id can be considered valid to be stored on the chain

type Sessions

type Sessions []Session

Sessions represents a slice of Session objects

func (Sessions) Equals

func (slice Sessions) Equals(other Sessions) bool

Equals returns true if and only if slice contains the same session objects as the other slice, false otherwise

Jump to

Keyboard shortcuts

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