models

package
v0.0.0-...-9f5e8be Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CurrentAATVersion represents the current version of the Application Authentication Token (AAT).
	CurrentAATVersion = "0.0.1"
)

Variables

View Source
var (
	ErrMissingFullNodes          = errors.New("require full node host")
	ErrSessionHasZeroNodes       = errors.New("session missing valid nodes")
	ErrNodeNotFound              = errors.New("node not found")
	ErrMalformedSendRelayRequest = errors.New("malformed send relay request")
)
View Source
var (
	ErrPocketCoreInvalidBlockHeight = PocketSdkError{Codespace: modulePocketCore, Code: 60}
	ErrPocketCoreOverService        = PocketSdkError{Codespace: modulePocketCore, Code: 71}
	ErrPocketEvidenceSealed         = PocketSdkError{Codespace: modulePocketCore, Code: 90}
	ErrorServicerNotFound           = PocketSdkError{Codespace: moduleRoot, Message: "Failed to find correct servicer PK"}
)
View Source
var (
	// ErrInvalidPrivateKey is returned when the private key is invalid.
	ErrInvalidPrivateKey = errors.New("invalid private key, requires 128 chars")
)

Functions

This section is empty.

Types

type AAT

type AAT struct {
	Version      string `json:"version"`
	AppPubKey    string `json:"app_pub_key"`
	ClientPubKey string `json:"client_pub_key"`
	Signature    string `json:"signature"`
}

func (AAT) Hash

func (a AAT) Hash() string

func (*AAT) MarshalJSON

func (j *AAT) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*AAT) MarshalJSONBuf

func (j *AAT) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*AAT) UnmarshalJSON

func (j *AAT) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*AAT) UnmarshalJSONFFLexer

func (j *AAT) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type Ed25519Account

type Ed25519Account struct {
	PrivateKey string `json:"privateKey"`
	PublicKey  string `json:"publicKey"`
	Address    string `json:"address"`
	// contains filtered or unexported fields
}

Ed25519Account represents an account using the Ed25519 cryptographic algorithm.

func NewAccount

func NewAccount(privateKey string) (*Ed25519Account, error)

NewAccount creates a new Ed25519Account instance.

Parameters:

  • privateKey: Private key as a string.

Returns:

  • (*Ed25519Account): New Ed25519Account instance.
  • (error): Error, if any.

func (*Ed25519Account) GetAAT

func (a *Ed25519Account) GetAAT() *AAT

GetAAT retrieves the Application Authentication Token (AAT) associated with the account.

Returns:

  • (*AAT): AAT for the account.

func (*Ed25519Account) MarshalJSON

func (j *Ed25519Account) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Ed25519Account) MarshalJSONBuf

func (j *Ed25519Account) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*Ed25519Account) Sign

func (a *Ed25519Account) Sign(message []byte) []byte

Sign signs a given message using the account's private key.

Parameters:

  • message: Message to sign.

Returns:

  • []byte: Signature.

func (*Ed25519Account) UnmarshalJSON

func (j *Ed25519Account) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*Ed25519Account) UnmarshalJSONFFLexer

func (j *Ed25519Account) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type GetApplicationResponse

type GetApplicationResponse struct {
	Result []*PoktApplication `json:"result"`
}

func (*GetApplicationResponse) MarshalJSON

func (j *GetApplicationResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*GetApplicationResponse) MarshalJSONBuf

func (j *GetApplicationResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*GetApplicationResponse) UnmarshalJSON

func (j *GetApplicationResponse) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*GetApplicationResponse) UnmarshalJSONFFLexer

func (j *GetApplicationResponse) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type GetLatestBlockHeightResponse

type GetLatestBlockHeightResponse struct {
	Height uint `json:"height"`
}

func (*GetLatestBlockHeightResponse) MarshalJSON

func (j *GetLatestBlockHeightResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*GetLatestBlockHeightResponse) MarshalJSONBuf

func (j *GetLatestBlockHeightResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*GetLatestBlockHeightResponse) UnmarshalJSON

func (j *GetLatestBlockHeightResponse) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*GetLatestBlockHeightResponse) UnmarshalJSONFFLexer

func (j *GetLatestBlockHeightResponse) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type GetSessionRequest

type GetSessionRequest struct {
	AppPubKey     string `json:"app_public_key"`
	Chain         string `json:"chain"`
	SessionHeight uint   `json:"session_height"`
}

func (*GetSessionRequest) MarshalJSON

func (j *GetSessionRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*GetSessionRequest) MarshalJSONBuf

func (j *GetSessionRequest) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*GetSessionRequest) UnmarshalJSON

func (j *GetSessionRequest) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*GetSessionRequest) UnmarshalJSONFFLexer

func (j *GetSessionRequest) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type GetSessionResponse

type GetSessionResponse struct {
	Session *Session `json:"session"`
}

func (*GetSessionResponse) MarshalJSON

func (j *GetSessionResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*GetSessionResponse) MarshalJSONBuf

func (j *GetSessionResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*GetSessionResponse) UnmarshalJSON

func (j *GetSessionResponse) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*GetSessionResponse) UnmarshalJSONFFLexer

func (j *GetSessionResponse) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type MaxRelays

type MaxRelays int

MaxRelays is a custom type for handling the MaxRelays field.

func (*MaxRelays) UnmarshalJSON

func (mr *MaxRelays) UnmarshalJSON(data []byte) error

UnmarshalJSON customizes the JSON unmarshalling for MaxRelays.

type Node

type Node struct {
	ServiceUrl string `json:"service_url"`
	PublicKey  string `json:"public_key"`
}

func (*Node) MarshalJSON

func (j *Node) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Node) MarshalJSONBuf

func (j *Node) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*Node) UnmarshalJSON

func (j *Node) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*Node) UnmarshalJSONFFLexer

func (j *Node) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type Payload

type Payload struct {
	Data    string            `json:"data"`
	Method  string            `json:"method"`
	Path    string            `json:"path"`
	Headers map[string]string `json:"headers"`
}

ffjson: skip

type PocketRPCError

type PocketRPCError struct {
	HttpCode int    `json:"code"`
	Message  string `json:"message"`
}

func (PocketRPCError) Error

func (r PocketRPCError) Error() string

func (*PocketRPCError) MarshalJSON

func (j *PocketRPCError) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*PocketRPCError) MarshalJSONBuf

func (j *PocketRPCError) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (PocketRPCError) ToSdkError

func (r PocketRPCError) ToSdkError() *PocketSdkError

func (*PocketRPCError) UnmarshalJSON

func (j *PocketRPCError) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*PocketRPCError) UnmarshalJSONFFLexer

func (j *PocketRPCError) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type PocketSdkError

type PocketSdkError struct {
	Codespace string
	Code      uint64
	Message   string // Fallback if code does not exist
}

func (PocketSdkError) Error

func (r PocketSdkError) Error() string

func (*PocketSdkError) MarshalJSON

func (j *PocketSdkError) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*PocketSdkError) MarshalJSONBuf

func (j *PocketSdkError) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*PocketSdkError) UnmarshalJSON

func (j *PocketSdkError) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*PocketSdkError) UnmarshalJSONFFLexer

func (j *PocketSdkError) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type PoktApplication

type PoktApplication struct {
	Address   string                `json:"address"`
	Chains    []string              `json:"chains"`
	PublicKey string                `json:"public_key"`
	Status    PoktApplicationStatus `json:"status"`
	MaxRelays MaxRelays             `json:"max_relays"`
}

func (*PoktApplication) MarshalJSON

func (j *PoktApplication) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*PoktApplication) MarshalJSONBuf

func (j *PoktApplication) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*PoktApplication) UnmarshalJSON

func (j *PoktApplication) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*PoktApplication) UnmarshalJSONFFLexer

func (j *PoktApplication) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type PoktApplicationStatus

type PoktApplicationStatus uint
const (
	StatusJailed    PoktApplicationStatus = 0
	StatusUnstaking PoktApplicationStatus = 1
	StatusStaked    PoktApplicationStatus = 2
)

type Relay

type Relay struct {
	Payload    *Payload    `json:"payload"`
	Metadata   *RelayMeta  `json:"meta"`
	RelayProof *RelayProof `json:"proof"`
}

ffjson: skip

type RelayMeta

type RelayMeta struct {
	BlockHeight uint `json:"block_height"`
}

func (*RelayMeta) MarshalJSON

func (j *RelayMeta) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*RelayMeta) MarshalJSONBuf

func (j *RelayMeta) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*RelayMeta) UnmarshalJSON

func (j *RelayMeta) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*RelayMeta) UnmarshalJSONFFLexer

func (j *RelayMeta) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type RelayProof

type RelayProof struct {
	Entropy            uint64 `json:"entropy"`
	SessionBlockHeight uint   `json:"session_block_height"`
	ServicerPubKey     string `json:"servicer_pub_key"`
	Blockchain         string `json:"blockchain"`
	AAT                *AAT   `json:"aat"`
	Signature          string `json:"signature"`
	RequestHash        string `json:"request_hash"`
}

RelayProof represents proof of a relay ffjson: skip

type RelayProofHashPayload

type RelayProofHashPayload struct {
	Entropy            uint64 `json:"entropy"`
	SessionBlockHeight uint   `json:"session_block_height"`
	ServicerPubKey     string `json:"servicer_pub_key"`
	Blockchain         string `json:"blockchain"`
	Signature          string `json:"signature"`
	UnsignedAAT        string `json:"token"`
	RequestHash        string `json:"request_hash"`
}

ffjson: skip

type RequestHashPayload

type RequestHashPayload struct {
	Payload  *Payload   `json:"payload"`
	Metadata *RelayMeta `json:"meta"`
}

RequestHashPayload struct holding data needed to create a request hash ffjson: skip

func (*RequestHashPayload) Hash

func (a *RequestHashPayload) Hash() string

type SendRelayRequest

type SendRelayRequest struct {
	Payload            *Payload
	Signer             *Ed25519Account
	Chain              string
	SelectedNodePubKey string
	Session            *Session
	Timeout            *time.Duration
}

func (*SendRelayRequest) MarshalJSON

func (j *SendRelayRequest) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*SendRelayRequest) MarshalJSONBuf

func (j *SendRelayRequest) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*SendRelayRequest) UnmarshalJSON

func (j *SendRelayRequest) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*SendRelayRequest) UnmarshalJSONFFLexer

func (j *SendRelayRequest) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

func (SendRelayRequest) Validate

func (req SendRelayRequest) Validate() error

type SendRelayResponse

type SendRelayResponse struct {
	Response string `json:"response"`
}

func (*SendRelayResponse) MarshalJSON

func (j *SendRelayResponse) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*SendRelayResponse) MarshalJSONBuf

func (j *SendRelayResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*SendRelayResponse) UnmarshalJSON

func (j *SendRelayResponse) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*SendRelayResponse) UnmarshalJSONFFLexer

func (j *SendRelayResponse) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type Session

type Session struct {
	Nodes         []*Node        `json:"nodes"`
	SessionHeader *SessionHeader `json:"header"`
}

func (*Session) MarshalJSON

func (j *Session) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*Session) MarshalJSONBuf

func (j *Session) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*Session) UnmarshalJSON

func (j *Session) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*Session) UnmarshalJSONFFLexer

func (j *Session) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type SessionHeader

type SessionHeader struct {
	SessionHeight uint   `json:"session_height"`
	Chain         string `json:"chain"`
}

func (*SessionHeader) MarshalJSON

func (j *SessionHeader) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*SessionHeader) MarshalJSONBuf

func (j *SessionHeader) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

func (*SessionHeader) UnmarshalJSON

func (j *SessionHeader) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*SessionHeader) UnmarshalJSONFFLexer

func (j *SessionHeader) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

Jump to

Keyboard shortcuts

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