entities

package
v0.0.0-...-29e199f Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package entities defines custom data types to be used across the whole application.

Index

Constants

View Source
const (
	OrderAsc  = "asc"
	OrderDesc = "desc"

	OrderByLastUpdate   = "lastUpdate"
	OrderByCreationDate = "creationDate"
)
View Source
const MaxUInt64 = 1<<64 - 1

Variables

This section is empty.

Functions

func CopyBytes

func CopyBytes(b []byte) (copiedBytes []byte)

CopyBytes returns an exact copy of the provided bytes.

func FromHex

func FromHex(s string) ([]byte, error)

FromHex returns the bytes represented by the hexadecimal string s which may be prefixed with "0x".

func HasHexPrefix

func HasHexPrefix(str string) bool

HasHexPrefix validates str begins with '0x' or '0X'.

func HexToBytes

func HexToBytes(str string) ([]byte, error)

HexToBytes returns the bytes represented by the hexadecimal string str.

func IsHex

func IsHex(str string) bool

IsHex validates whether each byte is valid hexadecimal string.

func IsHexCharacter

func IsHexCharacter(c byte) bool

IsHexCharacter returns bool of c being a valid hexadecimal.

func IsHexInt256

func IsHexInt256(input string) bool

IsHexInt256 checks if the input string is an hex encoded 256-bit integer

func IsInt256

func IsInt256(s string) bool

IsInt256 parses the input string s as a 256-bit integer. It returns true if valid and false otherwise.

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func MaxBigInt

func MaxBigInt(x, y *big.Int) *big.Int

MaxBigInt returns the larger of x or y.

func MinBigInt

func MinBigInt(x, y *big.Int) *big.Int

MinBigInt returns the smaller of x or y.

func PowBigInt

func PowBigInt(a, b int64) *big.Int

PowBigInt returns a ** b as a 256-bit integer.

func RightPadBytes

func RightPadBytes(slice []byte, l int) []byte

RightPadBytes zero-pads slice to the right up to length l.

func TrimRightZeroes

func TrimRightZeroes(s []byte) []byte

TrimRightZeroes returns a subslice of s without trailing zeroes

Types

type ApplicationStandardID

type ApplicationStandardID struct {
	ID            string `json:"id" valid:"required,maxstringlength(64)" storage:"id"`
	ApplicationID string `json:"application_id"  valid:"required" storage:"application_id"`
}

ApplicationStandardID the Standard identification for every application-related resource.

type ApplicationStandardResource

type ApplicationStandardResource struct {
	// ApplicationStandardID identifier of ApplicationStandardResource object
	ApplicationStandardID `json:",inline"`
	// Timestamps of ApplicationStandardResource object
	Timestamps `json:",inline"`
}

ApplicationStandardResource the Standard identification for every application-related resource including when it was created and last updated

type ApplicationStandardResourceMeta

type ApplicationStandardResourceMeta struct {
	// entities.ApplicationStandardResource standard application resource data
	ApplicationStandardResource
	// ResourceVersion resource version for resource locking
	ResourceVersion string `json:"ResourceVersion" storage:"resource_version"`
}

ApplicationStandardResourceMeta defines the meta-information of an application resource.

type ContextKey

type ContextKey string

ContextKey used in the signare for storing and retrieving values from context.

type HexBytes

type HexBytes []byte

HexBytes marshals/unmarshals with 0x prefix. The empty slice marshals as 0x.

func HashKeccak256

func HashKeccak256(data []byte) (*HexBytes, error)

HashKeccak256 returns the keccak256 hash of the input data

func NewHexBytes

func NewHexBytes(input []byte) *HexBytes

NewHexBytes wraps the given input as a HexBytes.

func NewHexBytesFromString

func NewHexBytesFromString(input string) (HexBytes, error)

NewHexBytesFromString decodes a hex string with 0x prefix.

func (*HexBytes) Bytes

func (b *HexBytes) Bytes() []byte

Bytes returns the underlying slice of bytes of b.

func (HexBytes) Encode

func (b HexBytes) Encode() string

Encode encodes b as a hex string with 0x prefix.

func (HexBytes) MarshalJSON

func (b HexBytes) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

func (HexBytes) MarshalText

func (b HexBytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (HexBytes) String

func (b HexBytes) String() string

String implements Stringer.

func (*HexBytes) UnmarshalJSON

func (b *HexBytes) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HexBytes) UnmarshalText

func (b *HexBytes) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type HexBytes32

type HexBytes32 [32]byte

HexBytes32 holds the internal representation for HexBytes32

func NewHexBytes32FromString

func NewHexBytes32FromString(input string) (HexBytes32, error)

NewHexBytes32FromString decodes a hex string with 0x prefix.

func (HexBytes32) Bytes

func (b HexBytes32) Bytes() []byte

Bytes exports HexBytes32 as a slice of bytes.

func (HexBytes32) Encode

func (b HexBytes32) Encode() string

Encode encodes b as a hex string with 0x prefix.

func (*HexBytes32) FromBytes

func (b *HexBytes32) FromBytes(src []byte)

FromBytes transform a slice of bytes into a HexBytes32.

func (*HexBytes32) FromString

func (b *HexBytes32) FromString(src string)

FromString transform a string into a HexBytes32.

func (HexBytes32) MarshalJSON

func (b HexBytes32) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

func (HexBytes32) String

func (b HexBytes32) String() string

String implements fmt.Stringer.

func (*HexBytes32) UnmarshalJSON

func (b *HexBytes32) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HexBytes32) UnmarshalText

func (b *HexBytes32) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type HexInt256

type HexInt256 struct {
	Int256
}

HexInt256 as an hex encoded 256-bit integer.

func NewHexInt256

func NewHexInt256(i *big.Int) *HexInt256

NewHexInt256 returns a hex 256-bit integer from the input big integer

func NewHexInt256FromString

func NewHexInt256FromString(input string) (*HexInt256, error)

NewHexInt256FromString decodes a hex string and returns a new 256-bit integer. Numbers larger than 256-bits are not allowed.

func (*HexInt256) Encode

func (b *HexInt256) Encode() string

Encode encodes bigint as a hex string with 0x prefix. The sign of the integer is ignored.

func (*HexInt256) MarshalJSON

func (b *HexInt256) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

func (HexInt256) MarshalText

func (b HexInt256) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*HexInt256) String

func (b *HexInt256) String() string

String implements fmt.Stringer.

func (*HexInt256) UnmarshalJSON

func (b *HexInt256) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HexInt256) UnmarshalText

func (b *HexInt256) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler

type HexUInt64

type HexUInt64 struct {
	UInt64
}

HexUInt64 as an hex encoded 64 bit unsigned integer

func NewHexUInt64

func NewHexUInt64(input uint64) HexUInt64

NewHexUInt64 wraps the given input as a HexUInt64.

func NewHexUInt64FromString

func NewHexUInt64FromString(input string) (HexUInt64, error)

NewHexUInt64FromString decodes a hex string with 0x prefix and returns it as a HexUInt64.

func (*HexUInt64) MarshalJSON

func (b *HexUInt64) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

func (HexUInt64) MarshalText

func (b HexUInt64) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (HexUInt64) String

func (b HexUInt64) String() string

String returns the hex encoding of b.

func (*HexUInt64) UnmarshalJSON

func (b *HexUInt64) UnmarshalJSON(input []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*HexUInt64) UnmarshalText

func (b *HexUInt64) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Int256

type Int256 struct {
	big.Int
}

Int256 as a 256-bit integer

func NewInt256

func NewInt256(i *big.Int) *Int256

NewInt256 returns a 256-bit integer from the input big integer

func NewInt256FromInt

func NewInt256FromInt(x int64) *Int256

NewInt256FromInt creates a new 256-bit integer from a 64 bit input integer

func NewInt256FromString

func NewInt256FromString(s string) (*Int256, error)

NewInt256FromString parses the input string s as a 256-bit integer in decimal or hexadecimal syntax. Leading zeros are allowed. The empty string parses as zero.

func ZeroInt256

func ZeroInt256() *Int256

ZeroInt256 returns a zero valued 256-bit integer

func (*Int256) BigEndianByteAt

func (b *Int256) BigEndianByteAt(n int) byte

BigEndianByteAt returns the byte at position n, in big-endian encoding, so that n==0 returns the least significant byte.

func (*Int256) BigInt

func (b *Int256) BigInt() *big.Int

BigInt converts b to a big.BigInt.

func (*Int256) ByteAt

func (b *Int256) ByteAt(padLength, n int) byte

ByteAt returns the byte at position n, with the supplied pad length in little-endian encoding.

func (*Int256) FirstBitSet

func (b *Int256) FirstBitSet() int

FirstBitSet returns the index of the first 1 bit in v, counting from LSB.

func (Int256) MarshalJSON

func (b Int256) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

func (*Int256) PaddedBytes

func (b *Int256) PaddedBytes(n int) []byte

PaddedBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.

func (*Int256) ReadBits

func (b *Int256) ReadBits(buf []byte)

ReadBits encodes the absolute value of bigint as big-endian bytes.

func (*Int256) S256

func (b *Int256) S256() *big.Int

S256 interprets b as a two's complement number. S256(0) = 0, S256(1) = 1, S256(2**255) = -2**255, S256(2**256-1) = -1.

func (*Int256) U256

func (b *Int256) U256() *big.Int

U256 encodes to the 256-bit two's complement number.

func (*Int256) U256Bytes

func (b *Int256) U256Bytes() []byte

U256Bytes converts into a padded 256-bit EVM number.

type InternalResourceID

type InternalResourceID string

InternalResourceID is a hash composed by the unique keys of a resource, and it uniquely identifies a resource by a single ID.

func NewInternalResourceID

func NewInternalResourceID() InternalResourceID

func (InternalResourceID) String

func (i InternalResourceID) String() string

String implements fmt.Stringer

type StandardCollectionPage

type StandardCollectionPage struct {
	// Limit of entries contained in the page
	Limit int `json:"limit"`
	// Offset zero-based offset of the first item in the page
	Offset int `json:"offset"`
	// MoreItems is true if there are entries after the < Offset + Size > entry
	MoreItems bool `json:"moreItems"`
}

StandardCollectionPage defines the standard data structure included in all the collections items.

func NewUnlimitedQueryStandardCollectionPage

func NewUnlimitedQueryStandardCollectionPage(size int) StandardCollectionPage

type StandardID

type StandardID struct {
	ID string `json:"id" valid:"required,maxstringlength(64)" storage:"id"`
}

StandardID the Standard identification for every not application-related resource.

type StandardResource

type StandardResource struct {
	// StandardID identifier of StandardResource object
	StandardID `json:",inline"`
	// Timestamps of StandardResource object
	Timestamps `json:",inline"`
}

StandardResource the Standard identification for every not application-related resource including when it was created and last updated

type StandardResourceMeta

type StandardResourceMeta struct {
	// entities.StandardResource standard resource data
	StandardResource
	// ResourceVersion resource version for resource locking
	ResourceVersion string `json:"ResourceVersion" storage:"resource_version"`
}

StandardResourceMeta defines the meta-information of a standard non-application resource.

type Timestamps

type Timestamps struct {
	// CreationDate creation date of the resource
	CreationDate time.Timestamp `json:"creationDate"`
	// LastUpdate last update date of the resource
	LastUpdate time.Timestamp `json:"lastUpdate"`
}

type UInt64

type UInt64 uint64

UInt64 as an unsigned 64 bit integer

func NewUInt64

func NewUInt64(input uint64) UInt64

NewUInt64 wraps the given input as a UInt64.

func NewUInt64FromString

func NewUInt64FromString(s string) (UInt64, error)

NewUInt64FromString parses s as an integer in decimal or hexadecimal syntax. Leading zeros are accepted. The empty string parses as zero.

func (UInt64) Add

func (ui UInt64) Add(y uint64) (uint64, bool)

func (UInt64) Mul

func (ui UInt64) Mul(y uint64) (uint64, bool)

func (UInt64) String

func (ui UInt64) String() string

String implements fmt.Stringer

func (UInt64) Sub

func (ui UInt64) Sub(y uint64) (uint64, bool)

func (UInt64) Uint64

func (ui UInt64) Uint64() uint64

Uint64 converts b to a uint64.

Directories

Path Synopsis
Package address defines the custom Ethereum address data type of the signare.
Package address defines the custom Ethereum address data type of the signare.

Jump to

Keyboard shortcuts

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