util

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS                = 1
	FAILED                 = 0
	PENDING                = 2
	TXTYPE_REWARD_SHIPPING = 3
	TXTYPE_SELLER_WITHDRAW = 4
	TIMEOUT                = 5
)
View Source
const IMPORT_ID_PREFIX string = "import_id:"

Variables

This section is empty.

Functions

func AmountToWei

func AmountToWei(amount float64, decimal *big.Int) (*big.Int, error)

Astra amount to Wei

func GetUserIdFromClaims

func GetUserIdFromClaims(ctx *gin.Context) (uint, error)

func ImportIdToRequestId

func ImportIdToRequestId(importId int) string

func JoinList

func JoinList[T any](list []T, sep string) string

func NewError

func NewError(key string, err error) map[string]interface{}

func Paginate

func Paginate(page, pageSize int) func(db *gorm.DB) *gorm.DB

func RandomAddress

func RandomAddress() common.Address

func RemoveFromList

func RemoveFromList[T any](list []T, index int) []T

func RequestIdToImportId

func RequestIdToImportId(requestId string) int

func RespondError

func RespondError(w *gin.Context, status int, msg string, errors ...error)

func RespondErrors

func RespondErrors(w *gin.Context, status int, payload interface{})

func RespondJSON

func RespondJSON(w *gin.Context, status int, payload interface{}, isCached bool)

func UserAmountToWei

func UserAmountToWei(amount string, decimal *big.Int) (*big.Int, error)

UserAmountToWei converts decimal user friendly representation of token amount to 'Wei' representation with provided amount of decimal places eg UserAmountToWei(1, 5) => 100000

Types

type Channel

type Channel struct {
	NewTxBroadcast chan TxInfo
	Seller         chan *ReceiptSt
	Receipt        chan *ReceiptSt
}

func NewChannel

func NewChannel() *Channel

type ErrorMap

type ErrorMap struct {
	Errors map[string]interface{} `json:"errors"`
}

type GeneralError

type GeneralError struct {
	// HTTP error code, or custom error code
	Code int `json:"code"`
	// Friendly error message
	Message string `json:"string"`
	// List of error send server 2 server
	Errors []string `json:"errors"`
}

type ReceiptSt

type ReceiptSt struct {
	Code    int
	Receipt *types.Receipt
	Hodlers []common.Address
}

type ResponseData

type ResponseData struct {
	Status   int         `json:"status"`
	Data     interface{} `json:"data"`
	IsCached bool        `json:"isCached"`
}

type ResponseError

type ResponseError struct {
	Status int         `json:"status"`
	Errors interface{} `json:"errors"`
}

type TxInfo

type TxInfo struct {
	TxHash  string
	Type    int
	Holders []common.Address
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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