utils

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindAndValidate

func BindAndValidate(c echo.Context, i interface{}) error

func BlueMsg

func BlueMsg(s string) string

func CalculateDestinationAddress

func CalculateDestinationAddress(payload []byte, chainInfoBytes *chain.ChainInfoBytes) (destinationAddress string, err error)

func ColorMethod

func ColorMethod(method string) string

func ConvertUint64ToChainInfo

func ConvertUint64ToChainInfo(n uint64) (*chain.ChainInfo, error)

func DecodeContractCallWithTokenPayload

func DecodeContractCallWithTokenPayload(payload []byte) (*encode.ContractCallWithTokenPayload, error)

func GetFunctionName

func GetFunctionName(f interface{}) string

func HttpErrorHandler

func HttpErrorHandler(err error, c echo.Context)

func LogMap

func LogMap(data map[string][]string)

func Logf

func Logf(foreground ForegroundColor, v ...interface{}) string

func MagentaMsg

func MagentaMsg(s string) string

func NormalizeAddress

func NormalizeAddress(address string, chainType types.ChainType) string

func NormalizeHash

func NormalizeHash(hash string) string

func RandomNumber

func RandomNumber(n int) (string, error)

func RandomString

func RandomString(n int) (string, error)

func Request

func RequestLogMiddleware

func RequestLogMiddleware() echo.MiddlewareFunc

func YellowMsg

func YellowMsg(s string) string

Types

type CustomValidator

type CustomValidator struct {
	// contains filtered or unexported fields
}

CustomValidator is type setting of third party validator

func NewValidator

func NewValidator() *CustomValidator

Init validator

func (*CustomValidator) AddRules

func (cv *CustomValidator) AddRules(rules ...ValidationRule) error

func (*CustomValidator) Validate

func (cv *CustomValidator) Validate(i interface{}) error

type ErrResponse

type ErrResponse struct {
	Message  string      `json:"message"`
	Metadata interface{} `json:"metadata,omitempty"`
}

type ForegroundColor

type ForegroundColor int
const (
	Black   ForegroundColor = 30
	Red     ForegroundColor = 31
	Green   ForegroundColor = 32
	Yellow  ForegroundColor = 33
	Blue    ForegroundColor = 34
	Magenta ForegroundColor = 35
	Cyan    ForegroundColor = 36
	White   ForegroundColor = 37
)

type RequestOption

type RequestOption struct {
	Method      string
	URL         string
	Body        interface{}
	ContentType string
}

type ValidationError

type ValidationError struct {
	Message  string                 `json:"message"`
	Metadata map[string]interface{} `json:"metadata"`
}

func (ValidationError) Error

func (ve ValidationError) Error() string

type ValidationRule

type ValidationRule struct {
	Tag string
	Fn  validator.Func
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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