common

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: CC0-1.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	FilterIdByteSize = 16

	SafeBlockNumber      = BN64(-4)
	FinalizedBlockNumber = BN64(-3)
	PendingBlockNumber   = BN64(-2)
	LatestBlockNumber    = BN64(-1)
	EarliestBlockNumber  = BN64(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct{ primitives.Data20 }

func BytesToAddress

func BytesToAddress(b []byte) Address

func HexStringToAddress

func HexStringToAddress(s string) Address

type BN64

type BN64 int64

func IntToBN64

func IntToBN64[T Integer](i T) BN64

func UintToBN64

func UintToBN64[T Uinteger](i T) BN64

func (*BN64) Int64

func (n *BN64) Int64() *int64

Int64 returns block number as *int64. If BN64 contains following tags; Earliest, Latest, Pending, Finalized, Safe it returns; 0, -1, -2, -3, -4 respectively

func (*BN64) Uint64

func (n *BN64) Uint64() *uint64

Uint64 returns block number as *uint64.

	If BN64 contains following tags; Safe, Finalized, Pending, Latest it returns nil
 If BN64 contains the Earliest tag, it returns 0

func (*BN64) UnmarshalJSON

func (n *BN64) UnmarshalJSON(data []byte) error

type BlockNumberOrHash added in v1.1.0

type BlockNumberOrHash struct {
	BlockNumber      *BN64 `json:"blockNumber,omitempty"`
	BlockHash        *H256 `json:"blockHash,omitempty"`
	RequireCanonical bool  `json:"requireCanonical,omitempty"`
}

func BlockNumberOrHashWithBN64 added in v1.1.0

func BlockNumberOrHashWithBN64(bn BN64) BlockNumberOrHash

func BlockNumberOrHashWithHash added in v1.1.0

func BlockNumberOrHashWithHash(hash H256, canonical bool) BlockNumberOrHash

func (*BlockNumberOrHash) Hash added in v1.1.0

func (bnh *BlockNumberOrHash) Hash() (H256, bool)

func (*BlockNumberOrHash) Number added in v1.1.0

func (bnh *BlockNumberOrHash) Number() (BN64, bool)

func (*BlockNumberOrHash) String added in v1.1.0

func (bnh *BlockNumberOrHash) String() string

func (*BlockNumberOrHash) UnmarshalJSON added in v1.1.0

func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error

type DataVec

type DataVec struct{ primitives.VarData }

func HexStringToDataVec added in v1.1.0

func HexStringToDataVec(s string) DataVec

type H256

type H256 struct{ primitives.Data32 }

func HexStringToHash

func HexStringToHash(s string) H256

func (H256) String added in v1.1.0

func (h256 H256) String() string

type Integer

type Integer interface {
	~int | ~int16 | ~int32 | ~int64
}

type Uint256

type Uint256 big.Int

func IntToUint256

func IntToUint256[T Integer](i T) Uint256

func RandomUint256

func RandomUint256() Uint256

RandomUint256 returns a random Uint256 with a size of FilterIdByteSize. The 8 MSBs are BigEndian ordered Unix nanoseconds, the rest of the bytes are randomly generated by crypto/rand

func Uint256FromBytes

func Uint256FromBytes(b []byte) Uint256

func Uint256FromHex

func Uint256FromHex(s string) (*Uint256, error)

func UintToUint256

func UintToUint256[T Uinteger](i T) Uint256

func (*Uint256) Bytes

func (ui256 *Uint256) Bytes() []byte

func (*Uint256) Cmp

func (ui256 *Uint256) Cmp(test Uint256) int

func (*Uint256) Data32

func (ui256 *Uint256) Data32() primitives.Data32

func (Uint256) MarshalText added in v1.1.0

func (ui256 Uint256) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Uint256) Text

func (ui256 *Uint256) Text(base int) string

func (*Uint256) Uint64

func (ui256 *Uint256) Uint64() uint64

func (*Uint256) UnmarshalJSON

func (ui256 *Uint256) UnmarshalJSON(data []byte) error

type Uint64

type Uint64 struct {
	// contains filtered or unexported fields
}

func IntToUint64

func IntToUint64[T Integer](i T) Uint64

func UintToUint64

func UintToUint64[T Uinteger](i T) Uint64

func (*Uint64) Uint64

func (ui64 *Uint64) Uint64() uint64

func (*Uint64) UnmarshalJSON

func (ui64 *Uint64) UnmarshalJSON(data []byte) error

type Uinteger

type Uinteger interface {
	~uint | ~uint16 | ~uint32 | ~uint64
}

Jump to

Keyboard shortcuts

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