utils

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKey  = "PUBLIC KEY"
	PrivateKey = "PRIVATE KEY"
)

Constants that are common across packages.

Variables

View Source
var ErrEventNotFound = fmt.Errorf("event not found")

ErrEventNotFound when event is not found and need to retry

Functions

func Byte32ToSlice

func Byte32ToSlice(in [32]byte) []byte

Byte32ToSlice converts a [32]bytes to an unbounded byte array

func ByteFixedToBigInt

func ByteFixedToBigInt(bytes []byte, size int) *big.Int

ByteFixedToBigInt convert arbitrary length byte arrays to big.Int

func ByteSliceToBigInt

func ByteSliceToBigInt(slice []byte) *big.Int

ByteSliceToBigInt convert bute slices to big.Int (bigendian)

func CheckMultiple32BytesFilled

func CheckMultiple32BytesFilled(b []byte, bs ...[]byte) bool

CheckMultiple32BytesFilled takes multiple []byte slices and ensures they are all of length 32 and don't contain all 0x0 bytes.

func ContainsBigIntInSlice

func ContainsBigIntInSlice(value *big.Int, list []*big.Int) bool

ContainsBigIntInSlice checks if value is present in list.

func GetCentLogFormat

func GetCentLogFormat() string

GetCentLogFormat returns the specific log format

func IsEmptyAddress

func IsEmptyAddress(addr common.Address) bool

IsEmptyAddress checks if the addr is empty.

func IsEmptyByte32

func IsEmptyByte32(source [32]byte) bool

IsEmptyByte32 checks if the source is empty.

func IsEmptyByteSlice

func IsEmptyByteSlice(s []byte) bool

IsEmptyByteSlice checks if the provided slice is empty returns true if: s == nil every element is == 0

func IsSameByteSlice

func IsSameByteSlice(a []byte, b []byte) bool

IsSameByteSlice checks if a and b contains same bytes.

func IsStringEmpty

func IsStringEmpty(msg string) bool

IsStringEmpty returns true if the string is empty

func IsStringOfLength

func IsStringOfLength(msg string, n int) bool

IsStringOfLength returns true if length of the string == n

func IsValidByteSliceForLength

func IsValidByteSliceForLength(slice []byte, length int) bool

IsValidByteSliceForLength checks if the len(slice) == length.

func LookForEvent

func LookForEvent(iter EventIterator) (err error)

LookForEvent checks if the iterator is ready with the Event if no event is found, returns ErrEventNotFound returns iter.Error when iterator errored out

func RandomByte32

func RandomByte32() (out [32]byte)

RandomByte32 returns a randomly filled byte array with length of 32

func RandomSlice

func RandomSlice(size int) (out []byte)

RandomSlice returns a randomly filled byte array with length of given size

func ReadKeyFromPemFile

func ReadKeyFromPemFile(fileName, keyPurpose string) (key []byte, err error)

ReadKeyFromPemFile reads the pem file and returns the key with matching key purpose

func SendPOSTRequest

func SendPOSTRequest(url string, contentType string, payload []byte) (statusCode int, err error)

SendPOSTRequest sends post with data to given URL.

func SimulateJSONDecodeForGocelery

func SimulateJSONDecodeForGocelery(kwargs map[string]interface{}) (map[string]interface{}, error)

SimulateJSONDecodeForGocelery encodes and decodes the kwargs.

func SliceOfByteSlicesToHexStringSlice

func SliceOfByteSlicesToHexStringSlice(byteSlices [][]byte) []string

SliceOfByteSlicesToHexStringSlice converts the given slice of byte slices to a hex encoded string array with 0x prefix

func SliceToByte32

func SliceToByte32(in []byte) (out [32]byte, err error)

SliceToByte32 converts a 32 byte slice to an array. Will thorw error if the slice is too long

func ToTimestamp

func ToTimestamp(time time.Time) *timestamp.Timestamp

ToTimestamp converts time.Time to timestamp.TimeStamp.

func WriteKeyToPemFile

func WriteKeyToPemFile(fileName string, keyPurpose string, key []byte) error

WriteKeyToPemFile writes encode of key and purpose to the file

Types

type EventIterator

type EventIterator interface {
	Next() bool
	Error() error
	Close() error
}

EventIterator contains functions that make events listening more easier

Jump to

Keyboard shortcuts

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