utils

package
v2.0.0-alpha.19 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYSTEM_NAME         = "SYSTEM"
	BIG_INT_EXP         = 18
	COINGECKO_SOURCE_ID = 3
	USD_ID              = 34
	ETH_ID              = 35
	// structured value id
	ASSET_TYPE_CRYPTO_STRUCTURED_VALUE_ID                    = 1
	LIVE_INTERVAL_STRUCTURED_VALUE_ID                        = 58
	DAILY_STRUCTURED_VALUE_ID                                = 5
	FIAT_STRUCTURED_VALUE_ID                                 = 9
	ASSET_PAIR_STRUCTURED_VALUE_ID                           = 12
	LIVE_DATA_MARKET_DATA_TYPE_STRUCTURED_VALUE_ID           = 7
	END_OF_DAY_MARKET_DATA_TYPE_STRUCTURED_VALUE_ID          = 8
	SUCCESS_STRUCTURED_VALUE_ID                              = 52
	RUNNING_STRUCTURED_VALUE_ID                              = 53
	WARNING_STRUCTURED_VALUE_ID                              = 54
	FAILED_STRUCTURED_VALUE_ID                               = 55
	LIVE_JOB_CATEGORY_STRUCTURED_VALUE_ID                    = 56
	EOD_JOB_CATEGORY_STRUCTURED_VALUE_ID                     = 57
	HARVESTING_FREQUENCY_STRUCTURED_VALUE_ID                 = 73
	STRATEGY_MARKET_DATA_IMPORT_JOB_TYPE_STRUCTURED_VALUE_ID = 74
	STRATEGY_SNAPSHOT_MARKET_DATA_TYPE_STRUCTURED_VALUE_ID   = 75
	STRATEGY_EXEUCTION_JOB_TYPE_STRUCTURED_VALUE_ID          = 76
	CALCULATION_ON_CHAIN_ANALYTICS_STRUCTURED_VALUE_ID       = 89
	EOA_ADDRESS_TYPE_STRUCTURED_VALUE_ID                     = 84
	CONTRACT_ADDRESS_TYPE_STRUCTURED_VALUE_ID                = 85
	CREATE_AUDIT_TYPE_STRUCTURED_VALUE_ID                    = 86
	UPDATE_AUDIT_TYPE_STRUCTURED_VALUE_ID                    = 87
	GETH_RELATED_JOB_IMPORT_JOB_TYPE_STRUCTURED_VALUE_ID     = 88
	IMPOPRT_BALANCE_AND_TRANSFERS_STRUCTURED_VALUE_ID        = 81
	IMPOPRT_SWAPS_STRUCTURED_VALUE_ID                        = 83
	GETH_RELATED_JOB_DELETE_JOB_TYPE_STRUCTURED_VALUE_ID     = 90
	SMART_CONTRACT_TAX_STRUCTURED_VALUE_ID                   = 95
	FIXED_STRUCTURED_VALUE_ID                                = 94
	PERCENTAGE_STRUCTURED_VALUE_ID                           = 93
	IMPORT_TRADES_GETH_STRUCTURED_VALUE_ID                   = 96
	IMPOPRT_ASSETS_STRUCTURED_VALUE_ID                       = 97
	CATEGORY_TYPE_NEEDS_REVIEW_STRUCTURED_VALUE_ID           = 98
	TRANSFER_TYPE_ERC20_STRUCTURED_VALUE_ID                  = 99
	TRANSFER_TYPE_INTERNAL_STRUCTURED_VALUE_ID               = 100
	TRANSFER_TYPE_NATIVE_STRUCTURED_VALUE_ID                 = 101
	IMPORT_MINER_TRANSACTION_STRUCTURED_VALUE_ID             = 102
	CALCULATE_MINER_STRUCTURED_VALUE_ID                      = 103
	// structured value type ids
	JOB_STATUS_STRUCTURED_VALUE_TYPE_ID          = 14
	JOB_CATEGORY_STRUCTURED_VALUE_TYPE_ID        = 15
	STRATEGY_STRUCTURED_VALUE_TYPE_ID            = 16
	FREQUENCY_STRUCTURED_VALUE_TYPE_ID           = 17
	STEP_ACTION_TYPE_STRUCTURED_VALUE_TYPE_ID    = 18
	LIQUITIDY_POOL_TYPE_STRUCTURED_VALUE_TYPE_ID = 20
	ADDRESS_TYPE_STRUCTURED_VALUE_TYPE_ID        = 22
	AUDIT_TYPE_STRUCTURED_VALUE_TYPE_ID          = 23
	RATE_TYPE_STRUCTURED_VALUE_TYPE_ID           = 24
	TAX_TYPE_STRUCTURED_VALUE_TYPE_ID            = 25
	TRANSFER_TYPE_STRUCTURED_VALUE_TYPE_ID       = 26
	MINER_IMPORT_TYPE_STRUCTURED_VALUE_TYPE_ID   = 27
)
View Source
const (
	LayoutISO       = "2006-01-02"
	LayoutUS        = "January 2, 2006"
	LayoutPostgres  = "2006-01-02 15:04:05"
	LayoutCoingecko = "02-01-2006"
	LayoutRFC3339   = "2016-06-20T12:41:45.140Z"
	TimeFormat      = "15:04:05"
)

Variables

View Source
var SampleCreatedAtTime, _ = time.Parse(LayoutPostgres, createdAtTimeStr)

Functions

func AccessSecretVersion

func AccessSecretVersion(name string) (string, error)

accessSecretVersion accesses the payload for the given secret version if one exists. The version can be a version number as a string (e.g. "5") or an alias (e.g. "latest").

func CheckIfStringPrefixExistsInArray

func CheckIfStringPrefixExistsInArray(arr []string, val string) bool

func ConvertDateToUTCZero

func ConvertDateToUTCZero(t time.Time) time.Time

func ConvertFloatToDecimal

func ConvertFloatToDecimal(value *float64) *decimal.Decimal

func ConvertFloatToPgTypeNumeric

func ConvertFloatToPgTypeNumeric(value *float64) *pgtype.DataType

func EndDate

func EndDate(t time.Time) time.Time

func EndOfMonthDate

func EndOfMonthDate(t time.Time) time.Time

func GetEnv

func GetEnv() string

func GetFiltersFromQueryStrings

func GetFiltersFromQueryStrings(query map[string][]string, filterKeys []string) []string

func GoDotEnvVariable

func GoDotEnvVariable(key string) string

use godot package to load/read the .env file and return the value of the key

func IndexOfInts

func IndexOfInts(arr []int, val int) int

func IndexOfStrings

func IndexOfStrings(arr []string, val string) int

func LookupEnv

func LookupEnv(k string) string

func MustGetenv

func MustGetenv(k string) string

func OffsetDateByDay

func OffsetDateByDay(t time.Time, offsetDay *int) time.Time

func ParseStringToDate

func ParseStringToDate(s string, layout string) (time.Time, error)

func Ptr

func Ptr[T any](v T) *T

func RandomString

func RandomString(length int) string

func RandomStringWithCharset

func RandomStringWithCharset(length int, charset string) string

func RangeDate

func RangeDate(start, end time.Time) func() time.Time

func RangeDateMonthly

func RangeDateMonthly(start, end time.Time) func() time.Time

func RangeDateOffsetByDate

func RangeDateOffsetByDate(start, end time.Time, offSetDays *int) func() time.Time

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, message string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

func SleepLog

func SleepLog(msg string, totalDuration time.Duration)

func SliceAtoi

func SliceAtoi(sa []string) ([]int, error)

func SplitToString

func SplitToString(a []int, sep string) string

func TimeDiff

func TimeDiff(TimeA time.Time, TimeB time.Time) time.Time

Types

type PgxIface

type PgxIface interface {
	Begin(context.Context) (pgx.Tx, error)
	CopyFrom(context.Context, pgx.Identifier, []string, pgx.CopyFromSource) (int64, error)
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	Ping(context.Context) error

	Close()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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