Documentation ¶
Index ¶
- Constants
- Variables
- func AddressToID(input string) (addr int64)
- func AddressToString(int int64) (str string)
- func AddressToStringUint64(uint uint64) (str string)
- func BinMarshal(out *[]byte, v any) (*[]byte, error)
- func BinToDec(bin []byte) int64
- func BinToDecBytesShift(bin *[]byte, num int64) int64
- func BinToHex(v any) []byte
- func BinUnmarshal(out *[]byte, v any) error
- func BinUnmarshalBuff(buf *bytes.Buffer, v any) error
- func BytesShift(str *[]byte, index int64) (ret []byte)
- func BytesShiftReverse(str *[]byte, v any) []byte
- func BytesToFloat64(s []byte) float64
- func BytesToInt(s []byte) int
- func BytesToInt64(s []byte) int64
- func CheckSum(val []byte) int
- func DecToBin(v any, sizeBytes int64) []byte
- func DecodeBytesBuf(buf *bytes.Buffer) ([]byte, error)
- func DecodeLenInt64(data *[]byte) (int64, error)
- func DecodeLenInt64Buf(buf *bytes.Buffer) (int64, error)
- func DecodeLength(buf *[]byte) (ret int64, err error)
- func DecodeLengthBuf(buf *bytes.Buffer) (int, error)
- func EncodeLenByte(out *[]byte, buf []byte) *[]byte
- func EncodeLenInt64(data *[]byte, x int64) *[]byte
- func EncodeLenInt64InPlace(x int64) []byte
- func EncodeLength(length int64) []byte
- func EncodeLengthPlusData(idata any) []byte
- func Escape(data string) string
- func EscapeForJSON(data string) string
- func EscapeName(name string) string
- func EscapeSQL(name string) string
- func FieldToBytes(v any, num int) []byte
- func Float64ToStr(f float64) string
- func FormatMoney(exp string, digit int32) (string, error)
- func HexToBin(ihexdata any) []byte
- func IDToAddress(id int64) (out string)
- func InSliceString(search string, slice []string) bool
- func Int64ToByte(num int64) []byte
- func Int64ToDateStr(date int64, format string) string
- func Int64ToStr(num int64) string
- func Int64Toint(dat int64) (int, error)
- func IntToStr(num int) string
- func InterfaceSliceToStr(i []any) (strs []string, err error)
- func InterfaceToFloat64(i any) float64
- func InterfaceToStr(v any) (string, error)
- func IsLatin(name string) bool
- func IsValidAddress(address string) bool
- func MarshalJson(v any) string
- func NumString(in string) string
- func ParseName(in string) (id int64, name string)
- func ParseTable(tblname string, defaultEcosystem int64) string
- func RSortMap(m map[int64]string) []map[int64]string
- func Round(num float64) int64
- func RoundWithPrecision(num float64, precision int) float64
- func RoundWithoutPrecision(num float64) int64
- func Sanitize(name string, available string) string
- func SanitizeName(input string) string
- func SanitizeNumber(input string) string
- func SanitizeScript(input string) string
- func SliceReverse(s []int64) []int64
- func SortMap(m map[int64]string) []map[int64]string
- func StrToFloat64(s string) float64
- func StrToInt(s string) int
- func StrToInt64(s string) int64
- func StrToMoney(str string) float64
- func StrToUint64(s string) uint64
- func StringToAddress(str string) (result int64)
- func StripTags(value string) string
- func SubNodeParseTable(tblname string, defaultEcosystem int64) string
- func UInt32ToStr(num uint32) string
- func ValidateEmail(email string) bool
- func ValueToDecimal(v any) (ret decimal.Decimal, err error)
- func ValueToInt(v any) (ret int64, err error)
- type Hole
Constants ¶
const ( BlackHoleAddr = "BlackHole" WhiteHoleAddr = "WhiteHole" )
Variables ¶
var ErrSliceSize = errors.New("Slice size larger than buffer size")
var FirstEcosystemTables = map[string]bool{ `keys`: true, `menu`: true, `pages`: true, `snippets`: true, `languages`: true, `contracts`: true, `tables`: true, `parameters`: true, `history`: true, `sections`: true, `members`: true, `roles`: true, `roles_participants`: true, `notifications`: true, `applications`: true, `binaries`: true, `buffer_data`: true, `app_params`: true, `views`: true, }
var ( HoleAddrMap = map[string]Hole{ BlackHoleAddr: {K: 0, S: "0000-0000-0000-0000-0000"}, WhiteHoleAddr: {K: 5555, S: "0000-0000-0000-0000-5555"}, } )
Functions ¶
func AddressToID ¶
AddressToID converts the string representation of the wallet number to a numeric
func AddressToString ¶
AddressToString converts int64 address to chain address as xxxx-xxxx-xxxx-xxxx-xxxx.
func AddressToStringUint64 ¶
func BinMarshal ¶
BinMarshal converts v parameter to []byte slice.
func BinToDecBytesShift ¶
BinToDecBytesShift converts the input binary []byte to int64 and shifts the input bin
func BinUnmarshal ¶
BinUnmarshal converts []byte slice which has been made with BinMarshal to v
func BytesShift ¶
BytesShift returns the index bytes of the input []byte and shift str pointer
func BytesShiftReverse ¶
BytesShiftReverse gets []byte from the end of the input and cut the input pointer to []byte
func BytesToFloat64 ¶
BytesToFloat64 converts []byte to float64
func DecodeLenInt64 ¶
DecodeLenInt64 gets int64 from []byte and shift the slice. The []byte should be encoded with EncodeLengthPlusInt64.
func DecodeLength ¶
DecodeLength decodes []byte to int64 and shifts buf. Bytes must be encoded with EncodeLength function.
0x43 => 67 0x820400 => 1024 0x830f4240 => 1000000
func EncodeLenByte ¶
func EncodeLenInt64 ¶
func EncodeLenInt64InPlace ¶
func EncodeLength ¶
EncodeLength encodes int64 number to []byte. If it is less than 128 then it returns []byte{length}. Otherwise, it returns (0x80 | len of int64) + int64 as BigEndian []byte
67 => 0x43 1024 => 0x820400 1000000 => 0x830f4240
func EncodeLengthPlusData ¶
EncodeLengthPlusData encoding interface into []byte
func EscapeForJSON ¶
EscapeForJSON replaces quote to slash and quote
func EscapeName ¶
EscapeName deletes unaccessable characters for input name(s)
func FieldToBytes ¶
FieldToBytes returns the value of n-th field of v as []byte
func FormatMoney ¶
FormatMoney converts minimal unit to legibility unit. For example, value * 10 ^ -digit
func IDToAddress ¶
IDToAddress converts the identifier of account to a string of the form xxxx-xxxx-xxxx-xxxx-xxxx.
func InSliceString ¶
InSliceString searches the string in the slice of strings
func Int64ToDateStr ¶
func Int64Toint ¶
func InterfaceSliceToStr ¶
InterfaceSliceToStr converts the slice of interfaces to the slice of strings
func InterfaceToFloat64 ¶
InterfaceToFloat64 converts the interfaces to the float64
func InterfaceToStr ¶
InterfaceToStr converts the interfaces to the string
func IsLatin ¶
IsLatin checks if the specified string contains only latin character, digits and '-', '_'.
func IsValidAddress ¶
IsValidAddress checks if the specified address is chain address.
func MarshalJson ¶
func ParseName ¶
ParseName gets a state identifier and the name of the contract or table from the full name like @[id]name
func ParseTable ¶
ParseTable return format 1:@[id]tblname -> parse id_tblname format 2:[defaultEcosystem]_tblname
func RoundWithPrecision ¶
RoundWithPrecision rounds float64 value
func RoundWithoutPrecision ¶
RoundWithoutPrecision is round float64 without precision
func SanitizeName ¶
SanitizeName deletes unaccessable characters from name string
func SanitizeNumber ¶
SanitizeNumber deletes unaccessable characters from number or name string
func SanitizeScript ¶
SanitizeScript deletes unaccessable characters from input string
func StrToUint64 ¶
StrToUint64 converts string to the unsinged int64
func StringToAddress ¶
StringToAddress converts string chain address to int64 address. The input address can be a positive or negative number, or chain address in xxxx-xxxx-xxxx-xxxx-xxxx format. Returns 0 when error occurs.
func SubNodeParseTable ¶
func ValueToInt ¶
ValueToInt converts interface (string or int64) to int64