conversions

package
v1.17.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const SolidityIntSize uint = 256

SolidityIntSize is the size of a Solidity int in bits.

Variables

This section is empty.

Functions

func BytesToInt64 added in v1.3.0

func BytesToInt64(bytes []byte) int64

func FloatToNumeric

func FloatToNumeric(f *big.Float) (pgtype.Numeric, error)

FloatToNumeric converts a big.Float to pgtype.Numeric.

func Int64ToBytes added in v1.3.0

func Int64ToBytes(i int64) []byte

func IntToNumeric

func IntToNumeric(i *big.Int) (pgtype.Numeric, error)

IntToNumeric converts a big.Int to pgtype.Numeric.

func MapValsToArr

func MapValsToArr[T comparable, U any](m map[T]U) []U

func MustFloatToNumeric

func MustFloatToNumeric(f *big.Float) pgtype.Numeric

MustFloatToNumeric converts a big.Float to pgtype.Numeric and panics on error.

func MustIntToNumeric

func MustIntToNumeric(i *big.Int) pgtype.Numeric

MustIntToNumeric converts a big.Int to pgtype.Numeric and panics on error.

func MustNumericToInt

func MustNumericToInt(n pgtype.Numeric) *big.Int

MustNumericToInt converts a pgtype.Numeric to a big.Int and panics on error.

func MustTimeToTimestamp added in v1.14.0

func MustTimeToTimestamp(t time.Time) pgtype.Timestamp

func MustUnixToTimestamp added in v1.14.0

func MustUnixToTimestamp(unix int64) pgtype.Timestamp

func NewLargeFloat

func NewLargeFloat() *big.Float

NewLargeFloat creates a new big.Float with a mantissa large enough to accurately represent the 256-bit integers used in Solidity.

func NumericToFloat

func NumericToFloat(n pgtype.Numeric) (*big.Float, error)

NumericToFloat converts a pgtype.Numeric to a big.Float.

func NumericToInt

func NumericToInt(n pgtype.Numeric) (*big.Int, error)

NumericToInt converts a pgtype.Numeric to a big.Int, ensuring denominator is non-zero.

func NumericToRat

func NumericToRat(n pgtype.Numeric) (*big.Rat, error)

NumericToRat converts a pgtype.Numeric to a big.Rat.

func RatToNumeric

func RatToNumeric(r *big.Rat) (pgtype.Numeric, error)

RatToNumeric converts a big.Rat to pgtype.Numeric with precision.

func TimeToTimestamp added in v1.14.0

func TimeToTimestamp(t time.Time) (pgtype.Timestamp, error)

func UnixToTimestamp added in v1.14.0

func UnixToTimestamp(unix int64) (pgtype.Timestamp, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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