utils

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: GPL-2.0, GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SuiAddressLength = 32
	TxDigestLength   = 32
)

Variables

View Source
var (
	SUI_DECIMALS                      = 9
	MIST_PER_SUI                      = 1000000000
	GAS_SAFE_OVERHEAD          uint64 = 1000
	MAX_GAS                    uint64 = 50000000000
	MOVE_STDLIB_ADDRESS               = NormalizeSuiObjectId("0x1")
	SUI_FRAMEWORK_ADDRESS             = NormalizeSuiObjectId("0x2")
	SUI_SYSTEM_ADDRESS                = NormalizeSuiObjectId("0x3")
	SUI_CLOCK_OBJECT_ID               = NormalizeSuiObjectId("0x6")
	SUI_SYSTEM_MODULE_NAME            = "sui_system"
	SUI_TYPE_ARG                      = fmt.Sprintf("%s::sui::SUI", SUI_FRAMEWORK_ADDRESS)
	SUI_SYSTEM_STATE_OBJECT_ID        = NormalizeSuiObjectId("0x5")
)

Functions

func GetHexByteLength added in v0.0.15

func GetHexByteLength(v string) int

func IsHex added in v0.0.15

func IsHex(v string) bool

func IsValidSuiAddress added in v0.0.15

func IsValidSuiAddress(v string) bool

func IsValidSuiObjectId added in v0.0.15

func IsValidSuiObjectId(v string) bool

func IsValidTransactionDigest added in v0.0.15

func IsValidTransactionDigest(v string) bool

Returns whether the tx digest is valid based on the serialization format

func NormalizeShortSuiAddress added in v0.0.15

func NormalizeShortSuiAddress(v string) string

0x0000000000000000000000000000000000000000000000000000000000000001 -> 0x1

func NormalizeShortSuiCoinType added in v0.0.15

func NormalizeShortSuiCoinType(v string) string

0x2::sui::SUI -> 0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI

func NormalizeShortSuiObjectId added in v0.0.15

func NormalizeShortSuiObjectId(v string) string

0x0000000000000000000000000000000000000000000000000000000000000001 -> 0x1

func NormalizeSuiAddress added in v0.0.15

func NormalizeSuiAddress(v string) string

*

  • Perform the following operations:

  • 1. Make the address lower case

  • 2. Prepend `0x` if the string does not start with `0x`.

  • 3. Add more zeros if the length of the address(excluding `0x`) is less than `SUI_ADDRESS_LENGTH` *

  • WARNING: if the address value itself starts with `0x`, e.g., `0x0x`, the default behavior

  • is to treat the first `0x` not as part of the address. The default behavior can be overridden by

  • setting `forceAdd0x` to true *

    0x1 -> 0x0000000000000000000000000000000000000000000000000000000000000001

func NormalizeSuiCoinType added in v0.0.15

func NormalizeSuiCoinType(v string) string

0x2::sui::SUI -> 0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI

func NormalizeSuiObjectId added in v0.0.15

func NormalizeSuiObjectId(v string) string

0x1 -> 0x0000000000000000000000000000000000000000000000000000000000000001

func SliceToMap added in v0.0.33

func SliceToMap[T any, V comparable](src []T, key func(T) V) map[V]T

func UnsignedIntegerToUint64 added in v0.0.33

func UnsignedIntegerToUint64(v any) uint64

Types

This section is empty.

Jump to

Keyboard shortcuts

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