Documentation
¶
Index ¶
- Constants
- Variables
- func B64PublicKeyToSuiAddress(b64 string) (string, error)
- func B64ToSuiPrivateKey(b64 string) (string, error)
- func Ed25519PublicKeyToB64PublicKey(ed25519PubKey ed25519.PublicKey) string
- func GetHexByteLength(v string) int
- func IsHex(v string) bool
- func IsValidSuiAddress(v string) bool
- func IsValidSuiObjectID(v string) bool
- func IsValidTransactionDigest(v string) bool
- func NormalizeShortSuiAddress(v string) string
- func NormalizeShortSuiCoinType(v string) string
- func NormalizeShortSuiObjectID(v string) string
- func NormalizeSuiAddress(v string) string
- func NormalizeSuiCoinType(v string) string
- func NormalizeSuiObjectID(v string) string
- func ParseDevInspectReturnValue(v [2]interface{}) ([]byte, error)
- func SliceToMap[T any, V comparable](src []T, key func(T) V) map[V]T
- func SuiPrivateKeyToB64(pk string) (string, error)
- type Endpoint
- type Network
Constants ¶
const ( // SuiAddressLength is the length of a Sui address in bytes SuiAddressLength = 32 // TxDigestLength is the length of a transaction digest in bytes TxDigestLength = 32 )
Variables ¶
var ( // SuiDecimals is the number of decimals used in SUI tokens SuiDecimals = 9 // MistPerSui is the number of mist per SUI token MistPerSui = 1000000000 // GasSafeOverhead is the overhead for gas in SUI transactions GasSafeOverhead uint64 = 1000 // MaxGas is the maximum gas limit for SUI transactions MaxGas uint64 = 50000000000 // MoveStdlibAddress is the address of the Move standard library in SUI, 0x0000000000000000000000000000000000000000000000000000000000000001 MoveStdlibAddress = NormalizeSuiObjectID("0x1") // SuiFrameworkAddress is the address of the SUI framework, 0x0000000000000000000000000000000000000000000000000000000000000002 SuiFrameworkAddress = NormalizeSuiObjectID("0x2") // SuiSystemAddress is the address of the SUI system, 0x0000000000000000000000000000000000000000000000000000000000000003 SuiSystemAddress = NormalizeSuiObjectID("0x3") // SuiClockObjectID is the object ID for SUI clock, 0x0000000000000000000000000000000000000000000000000000000000000006 SuiClockObjectID = NormalizeSuiObjectID("0x6") // SuiSystemModuleName is the name of the SUI system module SuiSystemModuleName = "sui_system" // SuiTypeArg is the type argument for SUI, used in Move types, 0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI SuiTypeArg = fmt.Sprintf("%s::sui::SUI", SuiFrameworkAddress) // SuiSystemStateObjectID is the object ID for the SUI system state, 0x0000000000000000000000000000000000000000000000000000000000000005 SuiSystemStateObjectID = NormalizeSuiObjectID("0x5") )
Functions ¶
func B64PublicKeyToSuiAddress ¶
B64PublicKeyToSuiAddress converts a base64 encoded public key to a Sui address.
func B64ToSuiPrivateKey ¶
B64ToSuiPrivateKey converts a base64 encoded Sui private key to a hex string representation.
func Ed25519PublicKeyToB64PublicKey ¶
Ed25519PublicKeyToB64PublicKey converts an Ed25519 public key to a base64 encoded string.
func GetHexByteLength ¶
GetHexByteLength returns the number of bytes represented by a hex string.
func IsValidSuiAddress ¶
IsValidSuiAddress checks if a given Sui address is valid.
func IsValidSuiObjectID ¶ added in v0.0.6
IsValidSuiObjectID checks if a given Sui object ID is valid.
func IsValidTransactionDigest ¶
IsValidTransactionDigest checks if a given transaction digest is valid.
func NormalizeShortSuiAddress ¶
NormalizeShortSuiAddress normalizes a short Sui address string. 0x0000000000000000000000000000000000000000000000000000000000000001 -> 0x1
func NormalizeShortSuiCoinType ¶
NormalizeShortSuiCoinType normalizes a short Sui coin type string. 0x2::sui::SUI -> 0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI
func NormalizeShortSuiObjectID ¶ added in v0.0.6
NormalizeShortSuiObjectID normalizes a short Sui object ID string. 0x0000000000000000000000000000000000000000000000000000000000000001 -> 0x1
func NormalizeSuiAddress ¶
NormalizeSuiAddress normalizes a Sui address string to a standard format. *
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 ¶
NormalizeSuiCoinType normalizes a Sui coin type string to a standard format. 0x2::sui::SUI -> 0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI
func NormalizeSuiObjectID ¶ added in v0.0.6
NormalizeSuiObjectID normalizes a Sui object ID string to a standard format. 0x1 -> 0x0000000000000000000000000000000000000000000000000000000000000001
func ParseDevInspectReturnValue ¶
ParseDevInspectReturnValue parses the return value from a dev inspect call.
func SliceToMap ¶
func SliceToMap[T any, V comparable](src []T, key func(T) V) map[V]T
SliceToMap converts a slice to a map using a key function to extract the key from each element.
func SuiPrivateKeyToB64 ¶
SuiPrivateKeyToB64 converts a Sui private key in hex format to a base64 encoded string.
Types ¶
type Endpoint ¶ added in v0.0.5
type Endpoint string
Endpoint represents a SUI network endpoint
const ( // MainnetRPC is the RPC endpoint for the SUI mainnet MainnetRPC Endpoint = "https://fullnode.mainnet.sui.io" // TestnetRPC is the RPC endpoint for the SUI testnet TestnetRPC Endpoint = "https://fullnode.testnet.sui.io" // DevnetRPC is the RPC endpoint for the SUI devnet DevnetRPC Endpoint = "https://fullnode.devnet.sui.io" // LocalnetRPC is the RPC endpoint for the SUI localnet LocalnetRPC Endpoint = "http://127.0.0.1:9000" // MainnetWSS is the WebSocket endpoint for the SUI mainnet MainnetWSS Endpoint = "wss://fullnode.mainnet.sui.io" // TestnetWSS is the WebSocket endpoint for the SUI testnet TestnetWSS Endpoint = "wss://fullnode.testnet.sui.io" // TestnetFaucet is the faucet endpoint for the SUI testnet TestnetFaucet Endpoint = "https://faucet.testnet.sui.io/gas" // DevnetFaucet is the faucet endpoint for the SUI devnet DevnetFaucet Endpoint = "https://faucet.devnet.sui.io" // LocalnetFaucet is the faucet endpoint for the SUI localnet LocalnetFaucet Endpoint = "http://127.0.0.1:9123" )