util

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: GPL-3.0 Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ParamsError           = ecode.New(10001)
	InvalidAccountAddress = ecode.New(10002)
	RecordNotFound        = ecode.New(10004)
)
View Source
var (
	CurrentRuntimeSpecVersion int
	EventStorageKey           = GetEnv("SUBSTRATE_EVENT_KEY", "0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7")
	AddressType               = GetEnv("SUBSTRATE_ADDRESS_TYPE", "1")
	BalanceAccuracy           = GetEnv("SUBSTRATE_ACCURACY", "9")
	CommissionAccuracy        = GetEnv("COMMISSION_ACCURACY", "9")
	WSEndPoint                = GetEnv("CHAIN_WS_ENDPOINT", "wss://polkadot.elara.patract.io")
	NetworkNode               = GetEnv("NETWORK_NODE", "polkadot")
	IsProduction              = os.Getenv("DEPLOY_ENV") == "prod"
)

Functions

func AddHex

func AddHex(s string) string

Add `0x` prefix

func BoolFromInterface

func BoolFromInterface(i interface{}) bool

Interface

func BytesToHex

func BytesToHex(b []byte) string

func CallerName

func CallerName() string

Func

func CamelString

func CamelString(s string) string

Camel String

func ContinuousNums added in v0.1.0

func ContinuousNums(start, count int, order string) (r []int)

func DecimalFromInterface

func DecimalFromInterface(i interface{}) decimal.Decimal

func GetEnv

func GetEnv(key, defaultValue string) string

func GetFuncName

func GetFuncName() string

func HexToBytes

func HexToBytes(s string) []byte

func HexToNumStr

func HexToNumStr(v string) string

func InsertInts

func InsertInts(o []int, index int, new int) []int

func Int64FromInterface

func Int64FromInterface(i interface{}) int64

func IntFromInterface

func IntFromInterface(i interface{}) int

Convert int64, uint64, float64, string to int, return 0 if other types

func IntInSlice

func IntInSlice(a int, list []int) bool

func IntToHex

func IntToHex(i interface{}) string

func IntToString

func IntToString(i int) string

Int

func MapStringToSlice

func MapStringToSlice(m map[string]bool) []string

func StringInSlice

func StringInSlice(a string, list []string) bool

func StringToInt

func StringToInt(s string) int

Convert str to int, return 0 if error

func StringsExclude

func StringsExclude(a []string, b []string) []string

String

func StringsIntersection

func StringsIntersection(a []string, b []string) []string

func ToString added in v0.1.0

func ToString(i interface{}) string

func TrimHex

func TrimHex(s string) string

func U256

func U256(v string) *big.Int

func UnmarshalAny added in v0.1.0

func UnmarshalAny(r interface{}, raw interface{})

func UpperCamel

func UpperCamel(s string) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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