dapp

package
v0.0.0-...-8260e65 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 7 Imported by: 5

Documentation

Index

Constants

View Source
const (
	AddressSize = 32
	AddressLen  = (AddressSize * 2) + 2
)
View Source
const (
	EventTypeSize = 4

	EventBodyJSON = 0
)
View Source
const Protocol = 0

Variables

View Source
var (
	AddressNil Address

	ErrInvalidAddressSize = status.New(
		pletyvo.CodeInvalidArgument, "invalid address size",
	)
	ErrInvalidAddressLen = status.New(
		pletyvo.CodeInvalidArgument, "invalid address length",
	)
)

Functions

func DecodeAddress

func DecodeAddress(dst, src []byte) error

Types

type Address

type Address [AddressSize]byte

func AddressFromString

func AddressFromString(s string) (Address, error)

func (Address) MarshalJSON

func (a Address) MarshalJSON() ([]byte, error)

func (Address) String

func (a Address) String() string

func (*Address) UnmarshalJSON

func (a *Address) UnmarshalJSON(b []byte) error

type AuthHeader

type AuthHeader struct {
	Schema    byte   `json:"sch"`
	PublicKey []byte `json:"pub"`
	Signature []byte `json:"sig"`
}

type Event

type Event struct {
	*EventInput
	ID     uuid.UUID `json:"id"`
	Author Address   `json:"author"`
}

type EventBase

type EventBase[T any] struct {
	ID      uuid.UUID
	Network uuid.UUID
	Address Address
	Input   *T
}

type EventBody

type EventBody []byte

func NewEventBody

func NewEventBody(data []byte, version byte, et EventType) EventBody

func NewEventBodyJSON

func NewEventBodyJSON(value any, et EventType) EventBody

func (EventBody) Bytes

func (eb EventBody) Bytes() []byte

func (EventBody) Data

func (eb EventBody) Data() []byte

func (EventBody) SetType

func (eb EventBody) SetType(et EventType)

func (EventBody) SetVersion

func (eb EventBody) SetVersion(version byte)

func (EventBody) String

func (eb EventBody) String() string

func (EventBody) Type

func (eb EventBody) Type() EventType

func (EventBody) VerifyData

func (eb EventBody) VerifyData() bool

func (EventBody) Version

func (eb EventBody) Version() byte

type EventInput

type EventInput struct {
	Body EventBody  `json:"body"`
	Auth AuthHeader `json:"auth"`
}

func (*EventInput) Verify

func (ei *EventInput) Verify(f EventInputVerifierFunc) bool

type EventInputVerifierFunc

type EventInputVerifierFunc func(*EventInput) bool

type EventQuery

type EventQuery interface {
	Get(context.Context, ...*pletyvo.QueryOption) ([]*Event, error)
	GetByID(context.Context, uuid.UUID) (*Event, error)
}

type EventRepository

type EventRepository interface {
	Get(ctx context.Context, ns uuid.UUID, option *pletyvo.QueryOption) ([]*Event, error)
	GetByID(ctx context.Context, ns, id uuid.UUID) (*Event, error)
	Create(ctx context.Context, ns uuid.UUID, event *Event) error
}

type EventResponse

type EventResponse struct {
	ID uuid.UUID `json:"id"`
}

type EventService

type EventService interface {
	EventQuery
	Create(context.Context, *EventInput) (*EventResponse, error)
}

type EventType

type EventType [EventTypeSize]byte

func NewEventType

func NewEventType(event, aggregate, version, protocol byte) EventType

func (EventType) Aggregate

func (e EventType) Aggregate() byte

func (EventType) Event

func (e EventType) Event() byte

func (EventType) Protocol

func (e EventType) Protocol() byte

func (EventType) Version

func (e EventType) Version() byte

type Repository

type Repository struct{ Event EventRepository }

type Service

type Service struct{ Event EventService }

Directories

Path Synopsis
crypto module

Jump to

Keyboard shortcuts

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