utils

package
v0.0.0-...-b8dc01b Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: GPL-3.0 Imports: 64 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 ClaimsContextKey = "ClaimsKey"

UserIDKey Key for context access to get the validated userID

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 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 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 AddCopyButton

func AddCopyButton(element template.HTML, copyContent string) template.HTML

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 CopyButton

func CopyButton(clipboardText interface{}) string

func CopyButtonText

func CopyButtonText(clipboardText interface{}) string

func CopyButtonWithTitle

func CopyButtonWithTitle(clipboardText interface{}, title string) 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 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 ExchangeRateForCurrency

func ExchangeRateForCurrency(currency string) float64

func FirstEpochOfSyncPeriod

func FirstEpochOfSyncPeriod(syncPeriod uint64) uint64

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 FormatAddCommasFormated

func FormatAddCommasFormated(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, urlFragment string, digitsLimit int, nameLimit int, addCopyToClipboard bool) template.HTML
func FormatAddressAsLink(address []byte, name string, verified bool, 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 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 FormatBalanceChangeFormated

func FormatBalanceChangeFormated(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 FormatBitvector

func FormatBitvector(b []byte) template.HTML

func FormatBlockHash

func FormatBlockHash(hash []byte) template.HTML

func FormatBlockNumber

func FormatBlockNumber(number uint64) template.HTML

func FormatBlockReward

func FormatBlockReward(blockNumber int64) 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 uint64) template.HTML

FormatBlockStatus will return an html status for a block.

func FormatBlockStatusShort

func FormatBlockStatusShort(status 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 FormatBytesAmount

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

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 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 FormatEth1AddressString

func FormatEth1AddressString(addr []byte) template.HTML

FormatEth1AddressString will return the eth1-address formated as html string

func FormatEth1AddressStringLowerCase

func FormatEth1AddressStringLowerCase(addr []byte) template.HTML

FormatEth1AddressString will return the eth1-address formated as html string

func FormatEth1AddressWithName

func FormatEth1AddressWithName(address []byte, name string) template.HTML

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(symbol string, ethPrice *big.Float, currentPrice template.HTML) template.HTML

func FormatEthstoreComparison

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

func FormatExchangedAmount

func FormatExchangedAmount(balanceInt int64, currency string) template.HTML

func FormatFloat

func FormatFloat(num float64, precision int) string

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.

func FormatHashLong

func FormatHashLong(hash common.Hash) template.HTML

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(balanceInt int64, currency string) template.HTML

FormatIncome will return a string for a balance

func FormatIncomeClElInt64

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

func FormatIncomeNoCurrency

func FormatIncomeNoCurrency(balanceInt int64, 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 FormatName

func FormatName(name string, trunc_opt ...bool) 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 FormatPercentageColored

func FormatPercentageColored(percentage float64) template.HTML

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 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 FormatSlashedValidatorsInt64

func FormatSlashedValidatorsInt64(validators []int64) template.HTML

FormatSlashedValidatorsInt64 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 uint64) template.HTML

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

func FormatThousandsEnglish

func FormatThousandsEnglish(number string) string

func FormatTime

func FormatTime(t time.Time) template.HTML

func FormatTimeFromNow

func FormatTimeFromNow(t time.Time) template.HTML

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 FormatTimestampTs

func FormatTimestampTs(ts time.Time) template.HTML

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

func FormatTimestampUInt64

func FormatTimestampUInt64(ts uint64) 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 FormatTokenSymbolHTML

func FormatTokenSymbolHTML(tmpl template.HTML) template.HTML

func FormatTokenSymbolTitle

func FormatTokenSymbolTitle(symbol string) string

func FormatTokenValue

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

func FormatTransactionHash

func FormatTransactionHash(hash []byte) template.HTML

func FormatTransactionType

func FormatTransactionType(txnType uint8) string

func FormatTsWithoutTooltip

func FormatTsWithoutTooltip(ts int64) template.HTML

FormatTs 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 FormatValidatorsInt64

func FormatValidatorsInt64(validators []int64) template.HTML

FormatValidatosrInt64 will return html formatted text for validators

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 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 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 GetNetwork

func GetNetwork() string

func GetPurchaseGroup

func GetPurchaseGroup(priceId string) string

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 GraffitiToSring

func GraffitiToSring(graffiti []byte) string

func HashAndEncode

func HashAndEncode(input string) string

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

func HumanizeTime

func HumanizeTime(then time.Time) string

Time formats a time into a relative string.

Time(someT) -> "3 weeks ago"

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 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 IsValidEmail

func IsValidEmail(s string) bool

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

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 ...string)

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 ...string)

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 MustParseHex

func MustParseHex(hexString string) []byte

MustParseHex will parse a string into hex

func ProcessSecrets

func ProcessSecrets(cfg interface{}) error

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 Reverse

func Reverse(s string) string

func ReverseSlice

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

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 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 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 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 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 WeiToEther

func WeiToEther(wei *big.Int) *big.Float

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 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