utils

package
v1.58.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: GPL-3.0 Imports: 69 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Day      = 24 * time.Hour
	Week     = 7 * Day
	Month    = 30 * Day
	Year     = 12 * Month
	LongTime = 37 * Year
)

Seconds-based time units

View Source
const AccessDenied = "access_denied"
View Source
const BeginningOfSetWithdrawalCredentials = "010000000000000000000000"
View Source
const CalculatingHint = `Calculating…`
View Source
const ClaimsContextKey = "ClaimsKey"

UserIDKey Key for context access to get the validated userID

View Source
const GROUP_ADDON = "addon"
View Source
const GROUP_API = "api"
View Source
const GROUP_MOBILE = "mobile"
View Source
const InvalidClient = "invalid_client"
View Source
const InvalidGrant = "invalid_grant"
View Source
const InvalidRequest = "invalid_request"
View Source
const InvalidScope = "invalid_scope"
View Source
const JsonBodyKey = "JsonBodyKey"
View Source
const JsonBodyNakedKey = "JsonBodyNakedKey"
View Source
const MobileAuthorizedKey = "MobileAuthKey"
View Source
const ServerError = "server_error"
View Source
const TemporarilyUnavailable = "temporarily_unavailable"
View Source
const UnauthorizedClient = "unauthorized_client"
View Source
const UnsupportedGrantType = "unsupported_grant_type"

Variables

View Source
var Config *types.Config

Config is the globally accessible configuration

View Source
var ENS_ETH_REGEXP = regexp.MustCompile(`^.{3,}\.eth$`)
View Source
var Erc1155TransferSingleEventHash = common.HexToHash("0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62")
View Source
var Erc20TransferEventHash = common.HexToHash("0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")
View Source
var ErrInvalidSpecification = errors.New("specification must be a struct pointer")

ErrInvalidSpecification indicates that a specification is of the wrong type.

View Source
var ErrRateLimit = errors.New("## RATE LIMIT ##")
View Source
var HashLikeRegex = regexp.MustCompile(`^[0-9a-fA-F]{0,96}$`)
View Source
var ProductsGroups = map[string]string{
	"sapphire":             GROUP_API,
	"emerald":              GROUP_API,
	"diamond":              GROUP_API,
	"plankton":             GROUP_MOBILE,
	"goldfish":             GROUP_MOBILE,
	"whale":                GROUP_MOBILE,
	"guppy":                GROUP_MOBILE,
	"dolphin":              GROUP_MOBILE,
	"orca":                 GROUP_MOBILE,
	"guppy.yearly":         GROUP_MOBILE,
	"dolphin.yearly":       GROUP_MOBILE,
	"orca.yearly":          GROUP_MOBILE,
	"vdb_addon_1k":         GROUP_ADDON,
	"vdb_addon_1k.yearly":  GROUP_ADDON,
	"vdb_addon_10k":        GROUP_ADDON,
	"vdb_addon_10k.yearly": GROUP_ADDON,
}
View Source
var ProductsMapV1ToV2 = map[string]string{
	"plankton": "guppy",
	"goldfish": "guppy",
	"whale":    "dolphin",
}
View Source
var ProductsMapV2ToV1 = map[string]string{
	"guppy":                "goldfish",
	"dolphin":              "whale",
	"orca":                 "whale",
	"guppy.yearly":         "goldfish",
	"dolphin.yearly":       "whale",
	"orca.yearly":          "whale",
	"vdb_addon_1k":         "",
	"vdb_addon_1k.yearly":  "",
	"vdb_addon_10k":        "",
	"vdb_addon_10k.yearly": "",
}
View Source
var Rates map[string]int = map[string]int{
	"AT": 20,
	"BE": 21,
	"BG": 20,
	"CY": 19,
	"CZ": 21,
	"DE": 19,
	"DK": 25,
	"EE": 20,
	"EL": 24,
	"ES": 21,
	"FI": 24,
	"FR": 20,
	"GB": 20,
	"HR": 25,
	"HU": 27,
	"IE": 23,
	"IT": 22,
	"LT": 21,
	"LU": 17,
	"LV": 21,
	"MT": 18,
	"NL": 21,
	"PL": 23,
	"PT": 23,
	"RO": 19,
	"SE": 25,
	"SI": 22,
	"SK": 20,
}

A map of the european tax rates according to https://ec.europa.eu/taxation_customs/sites/taxation/files/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf

View Source
var StripeDynamicRatesLive = []*string{
	strToPointer("txr_1IBMDaBiORp9oTlKp8EWwp8j"),
	strToPointer("txr_1IBMDYBiORp9oTlKdcfgMZX3"),
	strToPointer("txr_1IBMDXBiORp9oTlKlZ1VbEqY"),
	strToPointer("txr_1IBMDVBiORp9oTlKeV6FwBnA"),
	strToPointer("txr_1IBMDUBiORp9oTlK6p8C6qK9"),
	strToPointer("txr_1IBMDSBiORp9oTlKMj0KwTwm"),
	strToPointer("txr_1IBMDQBiORp9oTlKDnYFmsv3"),
	strToPointer("txr_1IBMDPBiORp9oTlKfaPyr9il"),
	strToPointer("txr_1IBMDNBiORp9oTlKcZfiSttV"),
	strToPointer("txr_1IBMDLBiORp9oTlKnKCLXOF8"),
	strToPointer("txr_1IBMDJBiORp9oTlKtDR2w3uh"),
	strToPointer("txr_1IBMDIBiORp9oTlKIlPuDNmy"),
	strToPointer("txr_1IBMDHBiORp9oTlKgJaePWff"),
	strToPointer("txr_1IBMDFBiORp9oTlK2JDAsvYn"),
	strToPointer("txr_1IBMDEBiORp9oTlKfhwkiebt"),
	strToPointer("txr_1IBMDDBiORp9oTlKtWxmZyAT"),
	strToPointer("txr_1IBMDABiORp9oTlK25TCgczQ"),
	strToPointer("txr_1IBMD8BiORp9oTlKsB9QPkUG"),
	strToPointer("txr_1IBMD7BiORp9oTlKwtw2fxpe"),
	strToPointer("txr_1IBMD6BiORp9oTlKMsgBKyMe"),
	strToPointer("txr_1IBMD4BiORp9oTlKVIN2jYCU"),
	strToPointer("txr_1IBMD3BiORp9oTlKU1vYxvH5"),
	strToPointer("txr_1IBMD2BiORp9oTlKKLV4yE2z"),
	strToPointer("txr_1IBMD0BiORp9oTlKHcW9KHQ7"),
	strToPointer("txr_1IBMCzBiORp9oTlKFp9CLAND"),
	strToPointer("txr_1IBMCxBiORp9oTlK0lc5PZgI"),
	strToPointer("txr_1IBMCuBiORp9oTlKIQmX5NaZ"),
	strToPointer("txr_1IBMBfBiORp9oTlKsxI0Css0"),
}
View Source
var StripeDynamicRatesTest = []*string{
	strToPointer("txr_1HqcFcBiORp9oTlKnyNWVp4r"),
	strToPointer("txr_1I9pNwBiORp9oTlKxTmOz7a1"),
	strToPointer("txr_1I9pOKBiORp9oTlKfMcVou1L"),
	strToPointer("txr_1I9pP0BiORp9oTlKy5CpfXQR"),
	strToPointer("txr_1I9pPzBiORp9oTlKWnfxgOw1"),
	strToPointer("txr_1HqdWaBiORp9oTlKkij8L6dU"),
	strToPointer("txr_1I9pQsBiORp9oTlK4UTiJJTN"),
	strToPointer("txr_1I9pR7BiORp9oTlKgaTRDucB"),
	strToPointer("txr_1I9pRKBiORp9oTlKudk6Zbf5"),
	strToPointer("txr_1I9pRYBiORp9oTlKlFCuCxDv"),
	strToPointer("txr_1I9pRsBiORp9oTlKabg2US6z"),
	strToPointer("txr_1I9pS5BiORp9oTlKK6b9bi1n"),
	strToPointer("txr_1I9pSNBiORp9oTlKCO3Of9YI"),
	strToPointer("txr_1I9pSdBiORp9oTlKsdb5E2eO"),
	strToPointer("txr_1I9pSuBiORp9oTlKW7OdEDln"),
	strToPointer("txr_1I9pTCBiORp9oTlK4LAH8ZAQ"),
	strToPointer("txr_1I9pUOBiORp9oTlKrissM9GJ"),
	strToPointer("txr_1I9pUgBiORp9oTlKCXqz67MM"),
	strToPointer("txr_1I9pUzBiORp9oTlK8zsYnVgS"),
	strToPointer("txr_1I9pVCBiORp9oTlKUGQ94mXO"),
	strToPointer("txr_1I9pVPBiORp9oTlKDaogHVHn"),
	strToPointer("txr_1I9pVeBiORp9oTlKbn6ZdXvh"),
	strToPointer("txr_1I9pVvBiORp9oTlKJuyxDeDD"),
	strToPointer("txr_1I9pW8BiORp9oTlKEiGKbdcq"),
	strToPointer("txr_1I9pWNBiORp9oTlKRvGIm5mx"),
	strToPointer("txr_1I9pWbBiORp9oTlKqGEvmQ0H"),
	strToPointer("txr_1I9pWrBiORp9oTlKljnvpOqI"),
	strToPointer("txr_1I9pX9BiORp9oTlKDtkJ8A09"),
}
View Source
var StripeRatesLive map[string]string = map[string]string{
	"AT": "txr_1IBMDaBiORp9oTlKp8EWwp8j",
	"BE": "txr_1IBMDXBiORp9oTlKlZ1VbEqY",
	"BG": "txr_1IBMDVBiORp9oTlKeV6FwBnA",
	"CY": "txr_1IBMDUBiORp9oTlK6p8C6qK9",
	"CZ": "txr_1IBMDSBiORp9oTlKMj0KwTwm",
	"DE": "txr_1IBMDYBiORp9oTlKdcfgMZX3",
	"DK": "txr_1IBMDQBiORp9oTlKDnYFmsv3",
	"EE": "txr_1IBMDPBiORp9oTlKfaPyr9il",
	"EL": "txr_1IBMDNBiORp9oTlKcZfiSttV",
	"ES": "txr_1IBMDLBiORp9oTlKnKCLXOF8",
	"FI": "txr_1IBMDJBiORp9oTlKtDR2w3uh",
	"FR": "txr_1IBMDIBiORp9oTlKIlPuDNmy",
	"GB": "txr_1IBMDHBiORp9oTlKgJaePWff",
	"HR": "txr_1IBMDFBiORp9oTlK2JDAsvYn",
	"HU": "txr_1IBMDEBiORp9oTlKfhwkiebt",
	"IE": "txr_1IBMDDBiORp9oTlKtWxmZyAT",
	"IT": "txr_1IBMDABiORp9oTlK25TCgczQ",
	"LT": "txr_1IBMD8BiORp9oTlKsB9QPkUG",
	"LU": "txr_1IBMD7BiORp9oTlKwtw2fxpe",
	"LV": "txr_1IBMD6BiORp9oTlKMsgBKyMe",
	"MT": "txr_1IBMD4BiORp9oTlKVIN2jYCU",
	"NL": "txr_1IBMD3BiORp9oTlKU1vYxvH5",
	"PL": "txr_1IBMD2BiORp9oTlKKLV4yE2z",
	"PT": "txr_1IBMD0BiORp9oTlKHcW9KHQ7",
	"RO": "txr_1IBMCzBiORp9oTlKFp9CLAND",
	"SE": "txr_1IBMCxBiORp9oTlK0lc5PZgI",
	"SI": "txr_1IBMCuBiORp9oTlKIQmX5NaZ",
	"SK": "txr_1IBMBfBiORp9oTlKsxI0Css0",
}
View Source
var StripeRatesTest map[string]string = map[string]string{
	"AT": "txr_1HqcFcBiORp9oTlKnyNWVp4r",
	"BE": "txr_1I9pNwBiORp9oTlKxTmOz7a1",
	"BG": "txr_1I9pOKBiORp9oTlKfMcVou1L",
	"CY": "txr_1I9pP0BiORp9oTlKy5CpfXQR",
	"CZ": "txr_1I9pPzBiORp9oTlKWnfxgOw1",
	"DE": "txr_1HqdWaBiORp9oTlKkij8L6dU",
	"DK": "txr_1I9pQsBiORp9oTlK4UTiJJTN",
	"EE": "txr_1I9pR7BiORp9oTlKgaTRDucB",
	"EL": "txr_1I9pRKBiORp9oTlKudk6Zbf5",
	"ES": "txr_1I9pRYBiORp9oTlKlFCuCxDv",
	"FI": "txr_1I9pRsBiORp9oTlKabg2US6z",
	"FR": "txr_1I9pS5BiORp9oTlKK6b9bi1n",
	"GB": "txr_1I9pSNBiORp9oTlKCO3Of9YI",
	"HR": "txr_1I9pSdBiORp9oTlKsdb5E2eO",
	"HU": "txr_1I9pSuBiORp9oTlKW7OdEDln",
	"IE": "txr_1I9pTCBiORp9oTlK4LAH8ZAQ",
	"IT": "txr_1I9pUOBiORp9oTlKrissM9GJ",
	"LT": "txr_1I9pUgBiORp9oTlKCXqz67MM",
	"LU": "txr_1I9pUzBiORp9oTlK8zsYnVgS",
	"LV": "txr_1I9pVCBiORp9oTlKUGQ94mXO",
	"MT": "txr_1I9pVPBiORp9oTlKDaogHVHn",
	"NL": "txr_1I9pVeBiORp9oTlKbn6ZdXvh",
	"PL": "txr_1I9pVvBiORp9oTlKJuyxDeDD",
	"PT": "txr_1I9pW8BiORp9oTlKEiGKbdcq",
	"RO": "txr_1I9pWNBiORp9oTlKRvGIm5mx",
	"SE": "txr_1I9pWbBiORp9oTlKqGEvmQ0H",
	"SI": "txr_1I9pWrBiORp9oTlKljnvpOqI",
	"SK": "txr_1I9pX9BiORp9oTlKDtkJ8A09",
}

A map of the european tax rates according to https://ec.europa.eu/taxation_customs/sites/taxation/files/resources/documents/taxation/vat/how_vat_works/rates/vat_rates_en.pdf

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 AddBigInts

func AddBigInts(a, b []byte) []byte

func AddSyncStats

func AddSyncStats(validators []uint64, syncDutiesHistory map[uint64]map[uint64]*types.ValidatorSyncParticipation, stats *types.SyncCommitteesStats) types.SyncCommitteesStats

AddSyncStats adds the sync stats of a set of validators from a given syncDutiesHistory to the given stats, if stats is nil a new stats object is created. Parameters:

  • validators: the validators to add the stats for
  • syncDutiesHistory: the sync duties history of all queried validators
  • stats: the stats object to add the stats to, if nil a new stats object is created

func AddressToWithdrawalCredentials

func AddressToWithdrawalCredentials(address []byte) ([]byte, error)

AddressToWithdrawalCredentials converts a valid address to withdrawalCredentials

func AuthorizedAPIMiddleware

func AuthorizedAPIMiddleware(next http.Handler) http.Handler

AuthorizedAPIMiddleware Demands an Authorization header to be present with a valid user api token Once authorization passes, this middleware sets a context entry with the authenticated userID

func BitAtVector

func BitAtVector(b []byte, i int) bool

func BitAtVectorReversed

func BitAtVectorReversed(b []byte, i int) bool

func CORSMiddleware

func CORSMiddleware(next http.Handler) http.Handler

func ClToCurrency

func ClToCurrency(valIf interface{}, currency string) decimal.Decimal

func ClToCurrencyGwei

func ClToCurrencyGwei(valIf interface{}, currency string) decimal.Decimal

func ClToMainCurrency

func ClToMainCurrency(valIf interface{}) decimal.Decimal

func CmdPrompt

func CmdPrompt(label string) string

Prompt asks for a string value using the label. For comand line interactions.

func CopyButton

func CopyButton(clipboardText interface{}) string

func CopyButtonText

func CopyButtonText(clipboardText interface{}) string

func CreateAccessToken

func CreateAccessToken(userID, appID, deviceID uint64, pkg, theme string) (string, int, error)

CreateAccessToken Creates a new access token for a given user

func DayOfSlot

func DayOfSlot(slot uint64) uint64

DayOfSlot returns the corresponding day of a slot

func DayToTime

func DayToTime(day int64) time.Time

func DerefString

func DerefString(str *string) string

func EffectiveProductId

func EffectiveProductId(productId string) string

func EffectiveProductName

func EffectiveProductName(productId string) string

func ElToCurrency

func ElToCurrency(valIf interface{}, currency string) decimal.Decimal

func ElToMainCurrency

func ElToMainCurrency(valIf interface{}) decimal.Decimal

func ElementExists

func ElementExists(arr []string, el string) bool

func EpochOfSlot

func EpochOfSlot(slot uint64) uint64

EpochOfSlot returns the corresponding epoch of a slot

func EpochToTime

func EpochToTime(epoch uint64) time.Time

EpochToTime will return a time.Time for an epoch

func EpochsPerDay

func EpochsPerDay() uint64

func Eth1BlockReward

func Eth1BlockReward(blockNumber uint64, difficulty []byte) *big.Int

func Eth1TotalReward

func Eth1TotalReward(block *types.Eth1BlockIndexed) *big.Int

func EthBytesToFloat

func EthBytesToFloat(b []byte) float64

func FirstEpochOfSyncPeriod

func FirstEpochOfSyncPeriod(syncPeriod uint64) uint64

FirstEpochOfSyncPeriod returns the first epoch of a given sync period.

Please note that it will return the calculated first epoch of the sync period even if it is pre ALTAIR.

Furthermore, for the very first actual sync period, it may return an epoch pre ALTAIR even though that is inccorect.

For more information: https://eth2book.info/capella/annotated-spec/#sync-committee-updates

func FixAddressCasing

func FixAddressCasing(add string) string

func ForkVersionAtEpoch

func ForkVersionAtEpoch(epoch uint64) *types.ForkVersion

ForkVersionAtEpoch returns the forkversion active a specific epoch

func FormatAddCommas

func FormatAddCommas(n uint64) template.HTML

func FormatAddCommasFormatted

func FormatAddCommasFormatted(num float64, precision uint) template.HTML

func FormatAddress

func FormatAddress(address []byte, token []byte, name string, verified bool, isContract bool, link bool) template.HTML

func FormatAddressAll

func FormatAddressAll(address []byte, name string, isContract bool, link string, digitsLimit int, nameLimit int, addCopyToClipboard bool) template.HTML
func FormatAddressAsLink(address []byte, name string, isContract bool) template.HTML
func FormatAddressAsTokenLink(token, address []byte, name string, verified bool, isContract bool) template.HTML

func FormatAddressEthBalance

func FormatAddressEthBalance(balance *types.Eth1AddressBalance) template.HTML

func FormatAddressLong

func FormatAddressLong(address string) template.HTML

func FormatAddressToWithdrawalCredentials

func FormatAddressToWithdrawalCredentials(address []byte, addCopyButton bool) template.HTML

func FormatAddressWithLimits

func FormatAddressWithLimits(address []byte, name string, isContract bool, link string, digitsLimit int, nameLimit int, addCopyToClipboard bool) template.HTML

func FormatAddressWithLimitsInAddressPageTable

func FormatAddressWithLimitsInAddressPageTable(mainAddress []byte, txAddress []byte, name string, isContract bool, digitsLimit int, nameLimit int, addCopyToClipboard bool) template.HTML

wrapper function of FormatAddressWithLimits used to format addresses in the address page's tables for txs

no link to the given txAddress will be added if it is mainAddress of the page is formatted

otherwise, "address" will be passed as link

func FormatAmount

func FormatAmount(amount *big.Int, unit string, digits int) template.HTML

func FormatAmountFormatted

func FormatAmountFormatted(amount *big.Int, unit string, digits int, maxPreCommaDigitsBeforeTrim int, fullAmountTooltip bool, smallUnit bool, newLineForUnit bool) template.HTML

func FormatAttestationInclusionEffectiveness

func FormatAttestationInclusionEffectiveness(eff float64) template.HTML

func FormatAttestationInclusionSlot

func FormatAttestationInclusionSlot(blockSlot uint64) template.HTML

FormatAttestationInclusionSlot will return the block-slot formated as html

func FormatAttestationStatus

func FormatAttestationStatus(status uint64) template.HTML

FormatAttestationStatus will return a user-friendly attestation for an attestation status number

func FormatAttestationStatusShort

func FormatAttestationStatusShort(status uint64) template.HTML

FormatAttestationStatusShort will return a user-friendly attestation for an attestation status number

func FormatAttestorAssignmentKey

func FormatAttestorAssignmentKey(AttesterSlot, CommitteeIndex, MemberIndex uint64) string

FormatAttestorAssignmentKey will format attestor assignment keys

func FormatBalance

func FormatBalance(balanceInt uint64, currency string) template.HTML

FormatBalance will return a string for a balance

func FormatBalanceChange

func FormatBalanceChange(balance *int64, currency string) template.HTML

FormatBalanceChange will return a string for a balance change

func FormatBalanceChangeFormatted

func FormatBalanceChangeFormatted(balance *int64, currencyName string, details *itypes.ValidatorEpochIncome) template.HTML

func FormatBalanceGwei

func FormatBalanceGwei(balance *int64, currency string) template.HTML

func FormatBalanceShort

func FormatBalanceShort(balanceInt uint64, currency string) template.HTML

FormatBalance will return a string for a balance

func FormatBalanceSql

func FormatBalanceSql(balanceInt sql.NullInt64, currency string) template.HTML

func FormatBigAmount

func FormatBigAmount(amount *hexutil.Big, unit string, digits int) template.HTML

func FormatBigNumberAddCommasFormated

func FormatBigNumberAddCommasFormated(val hexutil.Big, precision uint) template.HTML

func FormatBitlist

func FormatBitlist(b []byte) template.HTML

func FormatBlobVersionedHash

func FormatBlobVersionedHash(h []byte) template.HTML

func FormatBlockHash

func FormatBlockHash(hash []byte) template.HTML

func FormatBlockNumber

func FormatBlockNumber(number uint64) template.HTML

func FormatBlockRoot

func FormatBlockRoot(blockRoot []byte) template.HTML

FormatBlockRoot will return the block-root formated as html

func FormatBlockSlot

func FormatBlockSlot(blockSlot uint64) template.HTML

FormatBlockSlot will return the block-slot formated as html

func FormatBlockStatus

func FormatBlockStatus(status, slot uint64) template.HTML

FormatBlockStatus will return an html status for a block.

func FormatBlockStatusShort

func FormatBlockStatusShort(status, slot uint64) template.HTML

FormatBlockStatusShort will return an html status for a block.

func FormatBlockUsage

func FormatBlockUsage(gasUsage uint64, gasLimit uint64) template.HTML

func FormatBuilder

func FormatBuilder(pubkey []byte) template.HTML

func FormatBytes

func FormatBytes(b []byte, addCopyToClipboard bool, link string) template.HTML

func FormatBytesAmount

func FormatBytesAmount(amount []byte, unit string, digits int) template.HTML

func FormatClCurrency

func FormatClCurrency(value interface{}, targetCurrency string, digitsAfterComma int, showCurrencySymbol, showPlusSign, colored, truncateAndAddTooltip bool) template.HTML

func FormatClCurrencyString

func FormatClCurrencyString(value interface{}, targetCurrency string, digitsAfterComma int, showCurrencySymbol, showPlusSign, truncateAndAddTooltip bool) string

func FormatCount

func FormatCount(count uint64, finalized bool, shortenCalcHint bool) template.HTML

When 'finalized' is false and 'count' is 0, a in-progress hint is returned (three dots if 'shortenCalcHint' is true) If 'count' is positive or 'finalized' is true, 'count' is returned as a string

func FormatCurrentBalance

func FormatCurrentBalance(balanceInt uint64, currency string) template.HTML

FormatCurrentBalance will return the current balance formated as string with 9 digits after the comma (1 gwei = 1e9 eth)

func FormatDepositAmount

func FormatDepositAmount(balanceInt uint64, currency string) template.HTML

FormatDepositAmount will return the deposit amount formated as string

func FormatDifficulty

func FormatDifficulty(number *big.Int) string

func FormatETH

func FormatETH(num string) string

func FormatEffectiveBalance

func FormatEffectiveBalance(balanceInt uint64, currency string) template.HTML

FormatEffectiveBalance will return the effective balance formated as string with 1 digit after the comma

func FormatElCurrency

func FormatElCurrency(value interface{}, targetCurrency string, digitsAfterComma int, showCurrencySymbol, showPlusSign, colored, truncateAndAddTooltip bool) template.HTML

func FormatElCurrencyString

func FormatElCurrencyString(value interface{}, targetCurrency string, digitsAfterComma int, showCurrencySymbol, showPlusSign, truncateAndAddTooltip bool) string

func FormatEligibleBalance

func FormatEligibleBalance(balanceInt uint64, currency string) template.HTML

FormatBalance will return a string for a balance

func FormatEpoch

func FormatEpoch(epoch uint64) template.HTML

FormatEpoch will return the epoch formated as html

func FormatErc20Decimals

func FormatErc20Decimals(balance []byte, metadata *types.ERC20Metadata) decimal.Decimal

func FormatEth1Address

func FormatEth1Address(addr []byte) template.HTML

FormatEth1Address will return the eth1-address formated as html

func FormatEth1AddressFull

func FormatEth1AddressFull(addr common.Address) template.HTML

FormatEth1AddressFull will return the eth1-address formated as html

func FormatEth1AddressStringLowerCase

func FormatEth1AddressStringLowerCase(addr []byte) template.HTML

FormatEth1AddressStringLowerCase will return the eth1-address formated as html string in lower case

func FormatEth1Block

func FormatEth1Block(block uint64) template.HTML

FormatEth1Block will return the eth1-block formated as html

func FormatEth1BlockHash

func FormatEth1BlockHash(block []byte) template.HTML

FormatEth1BlockHash will return the eth1-block formated as html

func FormatEth1TxHash

func FormatEth1TxHash(hash []byte) template.HTML

FormatEth1TxHash will return the eth1-tx-hash formated as html

func FormatEth1TxStatus

func FormatEth1TxStatus(status uint64) template.HTML

FormatBalance will return a string for a balance

func FormatEtherValue

func FormatEtherValue(currency string, ethPrice decimal.Decimal, currentPrice template.HTML) template.HTML

func FormatEthstoreComparison

func FormatEthstoreComparison(pool string, val float64) template.HTML

func FormatFloat

func FormatFloat(num float64, precision int) string

func FormatFloatWithDigits

func FormatFloatWithDigits(num float64, min, max int) template.HTML

func FormatFloatWithDigitsString

func FormatFloatWithDigitsString(num float64, min, max int) string

FormatFloatWithDigitsString formats num with max amount of digits after comma but stop after min number of non-zero-digits after comma. In other words it can be used to format a number with the least amount of characters keeping a threshold of significant digits.

examples:

FormatFloatWithDigitsString(0.01234,2,2) = "0.01"
FormatFloatWithDigitsString(0.01234,2,3) = "0.012"
FormatFloatWithDigitsString(0.01234,2,4) = "0.012"
FormatFloatWithDigitsString(0.01234,3,4) = "0.0123"

func FormatGlobalParticipationRate

func FormatGlobalParticipationRate(e uint64, r float64, currency string) template.HTML

FormatGlobalParticipationRate will return the global-participation-rate formated as html

func FormatGraffiti

func FormatGraffiti(graffiti []byte) template.HTML

FormatGraffiti will return the graffiti formated as html

func FormatGraffitiAsLink(graffiti []byte) template.HTML

FormatGraffitiAsLink will return the graffiti formated as html-link

func FormatGraffitiString

func FormatGraffitiString(graffiti string) string

FormatGraffitiString formats (and escapes) the graffiti

func FormatHash

func FormatHash(hash []byte, trunc_opt ...bool) template.HTML
  • FormatHash will return a hash formated as html hash is required, trunc is optional. Only the first value in trunc_opt will be used. ATTENTION: IT TRUNCATES BY DEFAULT, PASS FALSE TO trunc_opt TO DISABLE

func FormatHashLong

func FormatHashLong(hash common.Hash) template.HTML

func FormatHashRaw

func FormatHashRaw(hash []byte, trunc_opt ...bool) string
  • FormatHashRaw will return a hash formated hash is required, trunc is optional. Only the first value in trunc_opt will be used. ATTENTION: IT TRUNCATES BY DEFAULT, PASS FALSE TO trunc_opt TO DISABLE

func FormatHashWithCopy

func FormatHashWithCopy(hash []byte) template.HTML

func FormatHashrate

func FormatHashrate(h float64) template.HTML

func FormatInOutSelf

func FormatInOutSelf(address, from, to []byte) template.HTML

func FormatInclusionDelay

func FormatInclusionDelay(inclusionSlot uint64, delay int64) template.HTML

FormatAttestationInclusionSlot will return the block-slot formated as html

func FormatIncome

func FormatIncome(balance interface{}, currency string, includeCurrency bool) template.HTML

func FormatIncomeClEl

func FormatIncomeClEl(income types.ClEl, currency string) template.HTML

func FormatIncomeClElInt64

func FormatIncomeClElInt64(income types.ClElInt64, currency string) template.HTML

func FormatIncomeSql

func FormatIncomeSql(balanceInt sql.NullInt64, currency string) template.HTML

func FormatMachineName

func FormatMachineName(machineName string) template.HTML

func FormatMessageToHtml

func FormatMessageToHtml(message string) template.HTML

func FormatMethod

func FormatMethod(method string) template.HTML

func FormatNotificationChannel

func FormatNotificationChannel(ch types.NotificationChannel) template.HTML

func FormatNumber

func FormatNumber(number interface{}) string

func FormatParticipation

func FormatParticipation(v float64) template.HTML

func FormatPercentage

func FormatPercentage(percentage float64) string

FormatPercentage will return a string for a percentage

func FormatPercentageColoredEmoji

func FormatPercentageColoredEmoji(percentage float64) template.HTML

func FormatPercentageWithGPrecision

func FormatPercentageWithGPrecision(percentage float64, precision int) string

FormatPercentageWithGPrecision will return a string for a percentage the maximum number of significant digits (trailing zeros are removed).

func FormatPercentageWithPrecision

func FormatPercentageWithPrecision(percentage float64, precision int) string

FormatPercentageWithPrecision will return a string for a percentage

func FormatPoolPerformance

func FormatPoolPerformance(val float64) template.HTML

func FormatPricedValue

func FormatPricedValue(val interface{}, valueCurrency, targetCurrency string) template.HTML

func FormatPublicKey

func FormatPublicKey(validator []byte) template.HTML

FormatPublicKey will return html formatted text for a validator-public-key

func FormatRPL

func FormatRPL(num string) string

func FormatSlashedValidator

func FormatSlashedValidator(validator uint64) template.HTML

FormatSlashedValidator will return html formatted text for a slashed validator

func FormatSlashedValidatorInt64

func FormatSlashedValidatorInt64(validator int64) template.HTML

FormatSlashedValidatorInt64 will return html formatted text for a slashed validator

func FormatSlashedValidatorWithName

func FormatSlashedValidatorWithName(validator uint64, name string) template.HTML

FormatSlashedValidator will return html formatted text for a slashed validator

func FormatSlashedValidators

func FormatSlashedValidators(validators []uint64) template.HTML

FormatSlashedValidators will return html formatted text for slashed validators

func FormatSlashedValidatorsWithName

func FormatSlashedValidatorsWithName(validators []uint64, nameMap map[uint64]string) template.HTML

FormatSlashedValidators will return html formatted text for slashed validators

func FormatSlotToTimestamp

func FormatSlotToTimestamp(blockSlot uint64) template.HTML

FormatSlotToTimestamp will return the time elapsed since blockSlot

func FormatSqlInt64

func FormatSqlInt64(i sql.NullInt64) template.HTML

func FormatSyncParticipationStatus

func FormatSyncParticipationStatus(status, blockSlot uint64) template.HTML

FormatSyncParticipationStatus will return a user-friendly format for an sync-participation-status number

func FormatSyncParticipations

func FormatSyncParticipations(participants uint64) template.HTML

FormatSyncParticipationStatus will return a user-friendly format for an sync-participation-status number

func FormatThousandsEnglish

func FormatThousandsEnglish(number string) string

func FormatTimestamp

func FormatTimestamp(ts int64) template.HTML

FormatTimestamp will return a timestamp formated as html. This is supposed to be used together with client-side js

func FormatTokenBalance

func FormatTokenBalance(balance *types.Eth1AddressBalance) template.HTML

func FormatTokenIcon

func FormatTokenIcon(icon []byte, size int) template.HTML

func FormatTokenName

func FormatTokenName(balance *types.Eth1AddressBalance) template.HTML

func FormatTokenSymbol

func FormatTokenSymbol(symbol string) string

func FormatTokenSymbolTitle

func FormatTokenSymbolTitle(symbol string) string

func FormatTokenValue

func FormatTokenValue(balance *types.Eth1AddressBalance, fullAmountTooltip bool) template.HTML

func FormatTracePath

func FormatTracePath(callType string, tracePath []int64, success bool, method string) template.HTML

func FormatTransactionHash

func FormatTransactionHash(hash []byte, successful bool) template.HTML

func FormatTransactionType

func FormatTransactionType(txnType uint8) string

func FormatTsWithoutTooltip

func FormatTsWithoutTooltip(ts int64) template.HTML

FormatTsWithoutTooltip will return a timestamp formated as html. This is supposed to be used together with client-side js

func FormatTxHash

func FormatTxHash(hash string) template.HTML

func FormatValidator

func FormatValidator(validator uint64) template.HTML

FormatValidator will return html formatted text for a validator

func FormatValidatorInt64

func FormatValidatorInt64(validator int64) template.HTML

FormatValidatorInt64 will return html formatted text for a validator (for an int64 validator-id)

func FormatValidatorName

func FormatValidatorName(name string) template.HTML

func FormatValidatorStatus

func FormatValidatorStatus(status string) template.HTML

FormatValidatorStatus will return the validator-status formated as html possible states pending, active_online, active_offline, exiting_online, exciting_offline, slashing_online, slashing_offline, exited, slashed

func FormatValidatorTag

func FormatValidatorTag(tag string) template.HTML

FormatValidatorTag will return html formated text of a validator-tag. Depending on the tag it will describe the tag in a tooltip and link to more information regarding the tag.

func FormatValidatorTags

func FormatValidatorTags(tags []string) template.HTML

func FormatValidatorWithName

func FormatValidatorWithName(validator interface{}, name string) template.HTML

func FormatWithdawalCredentials

func FormatWithdawalCredentials(hash []byte, addCopyButton bool) template.HTML

func FormatWithdrawalShort

func FormatWithdrawalShort(slot uint64, amount uint64) template.HTML

FormatBlockStatusShort will return an html status for a block.

func FormatYesNo

func FormatYesNo(yes bool) template.HTML

FormatYesNo will return yes or no formated as html

func GWeiBytesToEther

func GWeiBytesToEther(gwei []byte) decimal.Decimal

func GWeiToEther

func GWeiToEther(gwei *big.Int) decimal.Decimal

func GenerateQRCodeForAddress

func GenerateQRCodeForAddress(address []byte) (string, string, error)

Generates a QR code for an address returns two transparent base64 encoded img strings for dark and light theme the first has a black QR code the second a white QR code

func GenerateRandomAPIKey

func GenerateRandomAPIKey() (string, error)

GenerateAPIKey generates an API key for a user

func GenerateRandomBytesSecure

func GenerateRandomBytesSecure(n int) ([]byte, error)

func GetCurrentFuncName

func GetCurrentFuncName() string

func GetEtherscanAPIBaseUrl

func GetEtherscanAPIBaseUrl(provideDefault bool) string

func GetFirstAndLastEpochForDay

func GetFirstAndLastEpochForDay(day uint64) (firstEpoch uint64, lastEpoch uint64)

func GetFlash

func GetFlash(w http.ResponseWriter, r *http.Request, name string) (string, error)

func GetFlashes

func GetFlashes(w http.ResponseWriter, r *http.Request, name string) []interface{}

func GetLastBalanceInfoSlotForDay

func GetLastBalanceInfoSlotForDay(day uint64) uint64

func GetMaxAllowedDayRangeValidatorStats

func GetMaxAllowedDayRangeValidatorStats(validatorAmount int) int

func GetNetwork

func GetNetwork() string

func GetParentFuncName

func GetParentFuncName() string

func GetPurchaseGroup

func GetPurchaseGroup(priceId string) string

func GetRemainingScheduledSyncDuties

func GetRemainingScheduledSyncDuties(validatorCount int, stats types.SyncCommitteesStats, lastExportedEpoch, firstEpochOfPeriod uint64) uint64

GetRemainingScheduledSyncDuties returns the remaining count of scheduled slots given the stats of the current period, while also accounting for exported slots.

Parameters:

  • validatorCount: the count of validators associated with the stats.
  • stats: the current sync committee stats of the validators
  • lastExportedEpoch: the last epoch that was exported into the validator_stats table
  • firstEpochOfPeriod: the first epoch of the current sync committee period

func GetSigningDomain

func GetSigningDomain() ([]byte, error)

func GetTemplateFuncs

func GetTemplateFuncs() template.FuncMap

GetTemplateFuncs will get the template functions

func GetTimeToNextWithdrawal

func GetTimeToNextWithdrawal(distance uint64) time.Time

GetTimeToNextWithdrawal calculates the time it takes for the validators next withdrawal to be processed.

func Glob

func Glob(dir string, ext string) ([]string, error)

Glob walks through a directory and returns files with a given extension

func GraffitiToString

func GraffitiToString(graffiti []byte) string

func HandleRecaptcha

func HandleRecaptcha(w http.ResponseWriter, r *http.Request, errorRoute string) error

func HasProblematicUtfCharacters

func HasProblematicUtfCharacters(s string) bool

func HashAndEncode

func HashAndEncode(input string) string

HashAndEncode digests the input with sha256 and returns it as hex string

func HttpReq

func HttpReq(ctx context.Context, method, url string, params, result interface{}) error

func IfToDec

func IfToDec(valIf interface{}) decimal.Decimal

IfToDec trys to parse given parameter to decimal.Decimal, it only logs on error

func IncludeHTML

func IncludeHTML(path string) template.HTML

IncludeHTML adds html to the page

func IncludeSvg

func IncludeSvg(name string) template.HTML

func InitSessionStore

func InitSessionStore(secret string)

InitSessionStore initializes SessionStore with the given secret.

func Int64Max

func Int64Max(x, y int64) int64

func Int64Min

func Int64Min(x, y int64) int64

func IsApiRequest

func IsApiRequest(r *http.Request) bool

func IsEth1Address

func IsEth1Address(s string) bool

IsEth1Address verifies whether a string represents an eth1-address. In contrast to IsValidEth1Address, this also returns true for the 0x0 address

func IsEth1Tx

func IsEth1Tx(s string) bool

IsEth1Tx verifies whether a string represents an eth1-tx-hash. In contrast to IsValidEth1Tx, this also returns true for the 0x0 address

func IsHash

func IsHash(s string) bool

IsHash verifies whether a string represents an eth1-hash.

func IsPoSBlock0

func IsPoSBlock0(number uint64, ts int64) bool

Returns true if the given block number is 0 and if it is (according to its timestamp) included in slot 0

This is only true for networks that launch with active PoS at block 0 which requires

  • Belatrix happening at epoch 0 (pre condition for merged networks)
  • Genesis for PoS to happen at the same timestamp as the first block

func IsValidEmail

func IsValidEmail(s string) bool

IsValidEmail verifies whether a string represents a valid email-address.

func IsValidEnsDomain

func IsValidEnsDomain(text string) bool

func IsValidEth1Address

func IsValidEth1Address(s string) bool

IsValidEth1Address verifies whether a string represents a valid eth1-address.

func IsValidEth1Tx

func IsValidEth1Tx(s string) bool

IsValidEth1Tx verifies whether a string represents a valid eth1-tx-hash.

func IsValidUrl

func IsValidUrl(s string) bool

IsValidUrl verifies whether a string represents a valid Url.

func IsValidWithdrawalCredentials

func IsValidWithdrawalCredentials(s string) bool

IsValidWithdrawalCredentials verifies whether a string represents valid withdrawal credentials.

func KFormatterEthPrice

func KFormatterEthPrice(price uint64) template.HTML

func LogError

func LogError(err error, errorMsg interface{}, callerSkip int, additionalInfos ...map[string]interface{})

LogError logs an error with callstack info that skips callerSkip many levels with arbitrarily many additional infos. callerSkip equal to 0 gives you info directly where LogError is called.

func LogFatal

func LogFatal(err error, errorMsg interface{}, callerSkip int, additionalInfos ...map[string]interface{})

LogFatal logs a fatal error with callstack info that skips callerSkip many levels with arbitrarily many additional infos. callerSkip equal to 0 gives you info directly where LogFatal is called.

func LogWarn

func LogWarn(err error, errorMsg interface{}, callerSkip int, additionalInfos ...map[string]interface{})

LogError logs a warning with callstack info that skips callerSkip many levels with arbitrarily many additional infos. callerSkip equal to 0 gives you info directly where LogError is called.

func MapProductV1ToV2

func MapProductV1ToV2(product string) string

func MapProductV2ToV1

func MapProductV2ToV1(product string) string

func MustParseHex

func MustParseHex(hexString string) []byte

MustParseHex will parse a string into hex

func PriceIdToProductId

func PriceIdToProductId(priceId string) string

func ProcessSecrets

func ProcessSecrets(cfg interface{}) error

func ProductIsEligibleForAddons

func ProductIsEligibleForAddons(productId string) bool

func RandomString

func RandomString(length int) string

RandomString returns a random hex-string

func ReadConfig

func ReadConfig(cfg *types.Config, path string) error

ReadConfig will process a configuration

func RemoveRoundBracketsIncludingContent

func RemoveRoundBracketsIncludingContent(input string) string

To remove all round brackets (including its content) from a string

func ReverseSlice

func ReverseSlice[S ~[]E, E any](s S)

func ReverseString

func ReverseString(s string) string

func RoundDecimals

func RoundDecimals(f float64, n int) float64

RoundDecimals rounds (nearest) a number to the specified number of digits after comma

func SendOAuthErrorResponse

func SendOAuthErrorResponse(j *json.Encoder, route, errString, description string)

SendOAuthErrorResponse creates and sends a OAuth error response according to RFC6749

func SendOAuthResponse

func SendOAuthResponse(j *json.Encoder, route, accessToken, refreshToken string, expiresIn int)

SendOAuthResponse creates and sends a OAuth response according to RFC6749

func SetFlash

func SetFlash(w http.ResponseWriter, r *http.Request, name string, value string)

func SliceContains

func SliceContains(list []string, target string) bool

sliceContains reports whether the provided string is present in the given slice of strings.

func SlotToTime

func SlotToTime(slot uint64) time.Time

SlotToTime returns a time.Time to slot

func SlotsPerSyncCommittee

func SlotsPerSyncCommittee() uint64

SlotsPerSyncCommittee returns the count of slots per sync committee period (might be wrong for the first sync period at atlair which might be shorter, see https://eth2book.info/capella/annotated-spec/#sync-committee-updates)

func SortedUniqueUint64

func SortedUniqueUint64(arr []uint64) []uint64

func SqlRowsToJSON

func SqlRowsToJSON(rows *sql.Rows) ([]interface{}, error)

func StripPrefix

func StripPrefix(hexStr string) string

func SyncPeriodOfEpoch

func SyncPeriodOfEpoch(epoch uint64) uint64

func TimeToDay

func TimeToDay(timestamp uint64) uint64

TimeToDay will return a days since genesis for an timestamp

func TimeToEpoch

func TimeToEpoch(ts time.Time) int64

TimeToEpoch will return an epoch for a given time

func TimeToFirstSlotOfEpoch

func TimeToFirstSlotOfEpoch(timestamp uint64) uint64

func TimeToSlot

func TimeToSlot(timestamp uint64) uint64

TimeToSlot returns time to slot in seconds

func TimeToSyncPeriod

func TimeToSyncPeriod(t time.Time) uint64

func ToBase64

func ToBase64(input []byte) string

func TrLang

func TrLang(lang string, key string) template.HTML

TrLang returns translated text based on language tag and text id

func TryFetchContractMetadata

func TryFetchContractMetadata(address []byte) (*types.ContractMetadata, error)

func UniqueStrings

func UniqueStrings(s []string) []string

UniqueStrings returns an array of strings containing each value of s only once

func ValidateReCAPTCHA

func ValidateReCAPTCHA(recaptchaResponse string) (bool, error)

ValidateReCAPTCHA validates a ReCaptcha server side

func VerifyVoluntaryExitSignature

func VerifyVoluntaryExitSignature(op *phase0.SignedVoluntaryExit, forkVersion, pubkeyBytes []byte) error

VerifyVoluntaryExitSignature verifies the signature of an voluntary_exit message

func VersionedBlobHash

func VersionedBlobHash(commitment []byte) common.Hash

func WaitForCtrlC

func WaitForCtrlC()

WaitForCtrlC will block/wait until a control-c is pressed

func WeekOfSlot

func WeekOfSlot(slot uint64) uint64

WeekOfSlot returns the corresponding week of a slot

func WeiBytesToEther

func WeiBytesToEther(wei []byte) decimal.Decimal

func WeiToEther

func WeiToEther(wei *big.Int) decimal.Decimal

func WithdrawalCredentialsToAddress

func WithdrawalCredentialsToAddress(credentials []byte) ([]byte, error)

WithdrawalCredentialsToAddress converts withdrawalCredentials to an address if possible

Types

type CustomClaims

type CustomClaims struct {
	UserID   uint64 `json:"userID"`
	AppID    uint64 `json:"appID"`
	DeviceID uint64 `json:"deviceID"`
	Package  string `json:"package"`
	Theme    string `json:"theme"`
	jwt.StandardClaims
}

CustomClaims Structure of JWT body, contains standard JWT claims and userID as a custom claim

func GetAuthorizationClaims

func GetAuthorizationClaims(r *http.Request) *CustomClaims

func UnsafeGetClaims

func UnsafeGetClaims(tokenString string) (*CustomClaims, error)

UnsafeGetClaims this method returns the userID of a given jwt token WITHOUT VALIDATION DO NOT USE THIS METHOD AS RELIABLE SOURCE FOR USERID

func ValidateAccessTokenGetClaims

func ValidateAccessTokenGetClaims(tokenString string) (*CustomClaims, error)

ValidateAccessTokenGetClaims validates the jwt token and returns the UserID

type CustomSession

type CustomSession struct {
	SCS       *scs.SessionManager
	ContextFn func() context.Context
}

func (*CustomSession) AddFlash

func (cs *CustomSession) AddFlash(value string)

func (*CustomSession) DeleteValue

func (cs *CustomSession) DeleteValue(key string)

func (*CustomSession) Flashes

func (cs *CustomSession) Flashes(vars ...string) []interface{}

func (*CustomSession) GetValue

func (cs *CustomSession) GetValue(key string) interface{}

func (*CustomSession) Save

func (*CustomSession) SetValue

func (cs *CustomSession) SetValue(key string, value interface{})

func (*CustomSession) Values

func (cs *CustomSession) Values() map[interface{}]interface{}

type CustomSessionStore

type CustomSessionStore struct {
	// TODO: Implement
	SCS *scs.SessionManager
}
var SessionStore *CustomSessionStore

func (*CustomSessionStore) Get

func (css *CustomSessionStore) Get(r *http.Request, name string) (*CustomSession, error)

type Decoder

type Decoder interface {
	Decode(value string) error
}

Decoder has the same semantics as Setter, but takes higher precedence. It is provided for historical compatibility.

type HttpReqHttpError

type HttpReqHttpError struct {
	StatusCode int
	Url        string
	Body       []byte
}

func (*HttpReqHttpError) Error

func (err *HttpReqHttpError) Error() string

type OAuthErrorResponse

type OAuthErrorResponse struct {
	Error       string `json:"error"`
	Description string `json:"error_description"`
}

OAuthErrorResponse Structure of an OAuth error response

type OAuthResponse

type OAuthResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

OAuthResponse Structure of an successful OAuth response

type Setter

type Setter interface {
	Set(value string) error
}

Setter is implemented by types can self-deserialize values. Any type that implements flag.Value also implements Setter.

Jump to

Keyboard shortcuts

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