model package - github.com/blndgs/model - Go Packages

model

package module
v0.5.0-test.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: MIT Imports: 5 Imported by: 8

README

Model

Reusing data types, domain model or Shared Kernel in DDD parlance.

Documentation

Index

Constants

View Source
const (
	Swap = "swap"
	Buy  = "buy"
	Sell = "sell"
)

Variables

This section is empty.

Functions

func NewValidator

func NewValidator() error

Types

type Body

type Body struct {
	Intents []*Intent `json:"intents" binding:"required,dive"`
}

type Intent

type Intent struct {
	Sender            string           `json:"sender" binding:"required,eth_addr"` // filled by ui
	Kind              string           `json:"kind" binding:"required"`            // ui
	Hash              string           `json:"hash"`                               // ui or bundler
	SellToken         string           `json:"sellToken"`                          // optional for limit orders, ui
	BuyToken          string           `json:"buyToken"`                           // ui
	SellAmount        float64          `json:"sellAmount"`                         // optional for limit orders, ui
	BuyAmount         float64          `json:"buyAmount"`                          // ui
	PartiallyFillable bool             `json:"partiallyFillable"`                  // ui
	CallData          string           `json:"callData"`                           // UI, Bundler, Solver
	Status            ProcessingStatus `json:"status" binding:"status"`            // ui or bundler
	CreatedAt         int64            `json:"createdAt" binding:"opt_int"`        // ui or bundler
	ExpirationAt      int64            `json:"expirationAt" binding:"opt_int"`     // ui or bundler for default expiration (TTL: 100 seconds)
}

func (*Intent) ToJSON added in v0.4.0

func (i *Intent) ToJSON() (string, error)

ToJSON serializes the Intent into a JSON string

func (*Intent) ToString added in v0.4.0

func (i *Intent) ToString() string

ToString provides a string representation of the Intent

func (*Intent) ValidateKind

func (i *Intent) ValidateKind() bool

ValidateKind this function is manually, and it's not bound to Gin's validation. Should be called before posting or responding to a request. Investigate if it can be bound to Gin's validation.

type ProcessingStatus

type ProcessingStatus string
const (
	Received     ProcessingStatus = "Received"
	SentToSolver ProcessingStatus = "SentToSolver"
	Solved       ProcessingStatus = "Solved"
	Unsolved     ProcessingStatus = "Unsolved"
	Expired      ProcessingStatus = "Expired"
	OnChain      ProcessingStatus = "OnChain"
	Invalid      ProcessingStatus = "Invalid"
)

Jump to

Keyboard shortcuts

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