Documentation ¶
Index ¶
- Constants
- func AddressTo32Bytes(address common.Address) [32]byte
- func Byte32ToSlice(in [32]byte) []byte
- func ByteArrayTo32BytesLeftPadded(in []byte) ([32]byte, error)
- func ByteFixedToBigInt(bytes []byte, size int) *big.Int
- func ByteSliceToBigInt(slice []byte) *big.Int
- func Check32BytesFilled(b []byte) bool
- func CheckMultiple32BytesFilled(b []byte, bs ...[]byte) bool
- func ContainsBigIntInSlice(value *big.Int, list []*big.Int) bool
- func ContainsString(slice []string, str string) bool
- func ConvertByte32ToInt(nb [32]byte) int
- func ConvertIntToByte32(n int) ([32]byte, error)
- func ConvertProofForEthereum(sortedHashes [][]byte) ([][32]byte, error)
- func FromTimestamp(t *timestamp.Timestamp) (time.Time, error)
- func GetCentLogFormat() string
- func GetFreeAddrPort() (string, int, error)
- func InRange(i, min, max int) bool
- func IsEmptyAddress(addr common.Address) bool
- func IsEmptyByte32(source [32]byte) bool
- func IsEmptyByteSlice(s []byte) bool
- func IsSameByteSlice(a []byte, b []byte) bool
- func IsStringEmpty(msg string) bool
- func IsStringOfLength(msg string, n int) bool
- func IsValidByteSliceForLength(slice []byte, length int) bool
- func LookForEvent(iter EventIterator) (err error)
- func MustSliceToByte32(in []byte) [32]byte
- func RandomBigInt(max string) (*big.Int, error)
- func RandomByte32() (out [32]byte)
- func RandomSlice(size int) (out []byte)
- func ReadKeyFromPemFile(fileName, keyPurpose string) (key []byte, err error)
- func SendPOSTRequest(url string, contentType string, payload []byte) (statusCode int, err error)
- func SimulateJSONDecodeForGocelery(kwargs map[string]interface{}) (map[string]interface{}, error)
- func SliceOfByteSlicesToHexStringSlice(byteSlices [][]byte) []string
- func SliceToByte32(in []byte) (out [32]byte, err error)
- func ToTimestamp(time time.Time) (*timestamp.Timestamp, error)
- func WriteKeyToPemFile(fileName string, keyPurpose string, key []byte) (err error)
- type EventIterator
Constants ¶
const ( PublicKey = "PUBLIC KEY" PrivateKey = "PRIVATE KEY" )
Constants that are common across packages.
const ErrEventNotFound = errors.Error("event not found")
ErrEventNotFound when event is not found and need to retry
Variables ¶
This section is empty.
Functions ¶
func AddressTo32Bytes ¶
AddressTo32Bytes converts an address to 32 a byte array The length of an address is 20 bytes. First 12 bytes are filled with zeros.
func Byte32ToSlice ¶
Byte32ToSlice converts a [32]bytes to an unbounded byte array
func ByteArrayTo32BytesLeftPadded ¶
ByteArrayTo32BytesLeftPadded converts an address to 32 a byte array The length of the input has to be less or equals to 32
func ByteFixedToBigInt ¶
ByteFixedToBigInt convert arbitrary length byte arrays to big.Int
func ByteSliceToBigInt ¶
ByteSliceToBigInt convert bute slices to big.Int (bigendian)
func Check32BytesFilled ¶
Check32BytesFilled ensures byte slice is of length 32 and don't contain all 0x0 bytes.
func CheckMultiple32BytesFilled ¶
CheckMultiple32BytesFilled takes multiple []byte slices and ensures they are all of length 32 and don't contain all 0x0 bytes.
func ContainsBigIntInSlice ¶
ContainsBigIntInSlice checks if value is present in list.
func ContainsString ¶
ContainsString returns true if the slice contains str.
func ConvertByte32ToInt ¶
ConvertByte32ToInt converts a fixed length byte array into int with BigEndian order
func ConvertIntToByte32 ¶
ConvertIntToByte32 converts an integer into a fixed length byte array with BigEndian order
func ConvertProofForEthereum ¶
ConvertProofForEthereum converts a proof to 32 byte format needed by ethereum
func FromTimestamp ¶
FromTimestamp converts a timestamp protobuf to time
func GetCentLogFormat ¶
func GetCentLogFormat() string
GetCentLogFormat returns the specific log format
func GetFreeAddrPort ¶
GetFreeAddrPort returns a loopback address and port that can be listened from. Note: port is included in the address.
func InRange ¶ added in v1.0.0
InRange returns a boolean if the given number is in between a specified range.
func IsEmptyAddress ¶
IsEmptyAddress checks if the addr is empty.
func IsEmptyByte32 ¶
IsEmptyByte32 checks if the source is empty.
func IsEmptyByteSlice ¶
IsEmptyByteSlice checks if the provided slice is empty returns true if: s == nil every element is == 0
func IsSameByteSlice ¶
IsSameByteSlice checks if a and b contains same bytes.
func IsStringEmpty ¶
IsStringEmpty returns true if the string is empty
func IsStringOfLength ¶
IsStringOfLength returns true if length of the string == n
func IsValidByteSliceForLength ¶
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 MustSliceToByte32 ¶ added in v1.0.0
MustSliceToByte32 converts the bytes to byte 32 panics if the input length is > 32 bytes.
func RandomBigInt ¶ added in v1.0.0
RandomBigInt returns a random big int that's less than the provided max.
func RandomByte32 ¶
func RandomByte32() (out [32]byte)
RandomByte32 returns a randomly filled byte array with length of 32
func RandomSlice ¶
RandomSlice returns a randomly filled byte array with length of given size
func ReadKeyFromPemFile ¶
ReadKeyFromPemFile reads the pem file and returns the key with matching key purpose
func SendPOSTRequest ¶
SendPOSTRequest sends post with data to given URL.
func SimulateJSONDecodeForGocelery ¶
SimulateJSONDecodeForGocelery encodes and decodes the kwargs.
func SliceOfByteSlicesToHexStringSlice ¶
SliceOfByteSlicesToHexStringSlice converts the given slice of byte slices to a hex encoded string array with 0x prefix
func SliceToByte32 ¶
SliceToByte32 converts a 32 byte slice to an array. Will throw error if the slice is too long
func ToTimestamp ¶
ToTimestamp converts time.Time to timestamp.TimeStamp.
Types ¶
type EventIterator ¶
EventIterator contains functions that make events listening more easier