Documentation
¶
Overview ¶
Package scval provides shared helper functions for converting between Go types and Stellar Soroban xdr.ScVal values. These helpers are used by all generated contract bindings and hand-written extras.
Index ¶
- func AddressBytes32SliceToScVal(items [][32]byte) xdr.ScVal
- func AddressFromScVal(val xdr.ScVal) (string, error)
- func AddressSliceToScVal(items []string) xdr.ScVal
- func AddressToScVal(addr string) xdr.ScVal
- func AddressVecFromScVal(val xdr.ScVal) ([][]byte, error)
- func BoolToScVal(v bool) xdr.ScVal
- func BuildContractScAddress(contractIDBytes []byte) *xdr.ScAddress
- func BuildStructScVal(fields map[string]xdr.ScVal) (xdr.ScVal, error)
- func Bytes4FromScVal(val xdr.ScVal) ([4]byte, error)
- func Bytes4SliceToScVal(items [][4]byte) xdr.ScVal
- func Bytes4ToScVal(b [4]byte) xdr.ScVal
- func Bytes16FromScVal(val xdr.ScVal) ([16]byte, error)
- func Bytes16SliceToScVal(items [][16]byte) xdr.ScVal
- func Bytes16ToScVal(b [16]byte) xdr.ScVal
- func Bytes32FromScVal(val xdr.ScVal) ([32]byte, error)
- func Bytes32SliceToScVal(items [][32]byte) xdr.ScVal
- func Bytes32ToScVal(b [32]byte) xdr.ScVal
- func BytesFromScVal(val xdr.ScVal) ([]byte, error)
- func BytesSliceToScVal(items [][]byte) xdr.ScVal
- func BytesToScVal(b []byte) xdr.ScVal
- func BytesVecFromScVal(val xdr.ScVal) ([][]byte, error)
- func HexToContractStrkey(hexAddr string) (string, error)
- func I128FromScVal(val xdr.ScVal) (int64, error)
- func I128ToScVal(v int64) xdr.ScVal
- func MustToScVal(val xdr.ScVal, err error) xdr.ScVal
- func OptionalAddressFromScVal(val xdr.ScVal) (*string, error)
- func OptionalAddressToScVal(addr *string) xdr.ScVal
- func ParseAddress(addr string) *xdr.ScAddress
- func RawBytesFromAddressScVal(val xdr.ScVal) ([]byte, error)
- func StringFromScVal(val xdr.ScVal) (string, error)
- func StringToScVal(s string) xdr.ScVal
- func StructSliceToScVal[T interface{ ... }](items []T) xdr.ScVal
- func SymbolFromScVal(val xdr.ScVal) (string, error)
- func SymbolToScVal(sym string) xdr.ScVal
- func SymbolToScValPtr(sym string) *xdr.ScVal
- func U128ToScVal(parts xdr.UInt128Parts) xdr.ScVal
- func Uint32FromScVal(val xdr.ScVal) (uint32, error)
- func Uint32SliceToScVal(items []uint32) xdr.ScVal
- func Uint32ToScVal(v uint32) xdr.ScVal
- func Uint64FromScVal(val xdr.ScVal) (uint64, error)
- func Uint64SliceToScVal(items []uint64) xdr.ScVal
- func Uint64ToScVal(v uint64) xdr.ScVal
- func VecToScVal(items []xdr.ScVal) xdr.ScVal
- func VoidScVal() xdr.ScVal
- type U128
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressFromScVal ¶
AddressFromScVal extracts a strkey address from an xdr.ScVal.
func AddressSliceToScVal ¶
AddressSliceToScVal converts a slice of address strings to an xdr.ScVal vector.
func AddressToScVal ¶
AddressToScVal converts a Stellar address string (G... or C...) to an xdr.ScVal.
func AddressVecFromScVal ¶
AddressVecFromScVal extracts raw 32-byte addresses from a Vec<Address> ScVal.
func BuildContractScAddress ¶
BuildContractScAddress creates an ScAddress for a contract from raw bytes.
func BuildStructScVal ¶
BuildStructScVal builds a struct xdr.ScVal from a map of field names to values. Soroban requires ScMap keys to be sorted lexicographically.
func Bytes4FromScVal ¶
Bytes4FromScVal extracts a [4]byte from an xdr.ScVal containing BytesN<4>.
func Bytes4SliceToScVal ¶
Bytes4SliceToScVal converts a slice of [4]byte to an xdr.ScVal vector (for Vec<BytesN<4>>).
func Bytes4ToScVal ¶
Bytes4ToScVal converts a [4]byte to an xdr.ScVal (for BytesN<4>).
func Bytes16FromScVal ¶
Bytes16FromScVal extracts a [16]byte from an xdr.ScVal containing BytesN<16>.
func Bytes16SliceToScVal ¶
Bytes16SliceToScVal converts a slice of [16]byte to an xdr.ScVal vector (for Vec<BytesN<16>>).
func Bytes16ToScVal ¶
Bytes16ToScVal converts a [16]byte to an xdr.ScVal.
func Bytes32FromScVal ¶
Bytes32FromScVal extracts a [32]byte from an xdr.ScVal containing BytesN<32>.
func Bytes32SliceToScVal ¶
Bytes32SliceToScVal converts a slice of [32]byte to an xdr.ScVal vector (for Vec<BytesN<32>>).
func Bytes32ToScVal ¶
Bytes32ToScVal converts a [32]byte to an xdr.ScVal.
func BytesFromScVal ¶
BytesFromScVal extracts a byte slice from an xdr.ScVal containing Bytes.
func BytesSliceToScVal ¶
StringSliceToScVal converts a slice of strings to an xdr.ScVal vector.
func BytesToScVal ¶
BytesToScVal converts a byte slice to an xdr.ScVal.
func BytesVecFromScVal ¶
BytesVecFromScVal decodes a Vec<Bytes> from an xdr.ScVal vector.
func HexToContractStrkey ¶
HexToContractStrkey converts a 0x-prefixed hex string (32-byte contract ID) to a Stellar contract strkey (C...).
func I128FromScVal ¶
I128FromScVal extracts an int64 from an xdr.ScVal containing i128. Note: This truncates to int64 for simplicity.
func I128ToScVal ¶
I128ToScVal converts an int64 to an xdr.ScVal representing i128.
func MustToScVal ¶
MustToScVal panics if ToScVal returns an error.
func OptionalAddressFromScVal ¶
OptionalAddressFromScVal extracts a *string from an ScVal. ScvVoid returns nil (Option::None), ScvAddress returns a pointer to the address string (Option::Some).
func OptionalAddressToScVal ¶
OptionalAddressToScVal converts a *string to an ScVal. nil maps to ScvVoid (Soroban Option::None), non-nil maps to ScvAddress (Option::Some).
func ParseAddress ¶
ParseAddress parses a Stellar address string (G... or C...) into an xdr.ScAddress.
func RawBytesFromAddressScVal ¶
RawBytesFromAddressScVal extracts the raw 32-byte key (contract ID or ed25519 pubkey) from an xdr.ScVal address.
func StringFromScVal ¶
StringFromScVal extracts a Go string from an xdr.ScVal containing Soroban String.
func StringToScVal ¶
StringToScVal converts a Go string to an xdr.ScVal representing Soroban String.
func StructSliceToScVal ¶
StructSliceToScVal converts a slice of structs with ToScVal to an xdr.ScVal vector.
func SymbolFromScVal ¶
SymbolFromScVal extracts a string from an xdr.ScVal containing a symbol.
func SymbolToScVal ¶
SymbolToScVal converts a string to an xdr.ScVal symbol.
func SymbolToScValPtr ¶
SymbolToScValPtr returns a pointer to a symbol ScVal.
func U128ToScVal ¶
func U128ToScVal(parts xdr.UInt128Parts) xdr.ScVal
U128ToScVal converts xdr.UInt128Parts to an xdr.ScVal representing u128.
func Uint32FromScVal ¶
Uint32FromScVal extracts a uint32 from an xdr.ScVal.
func Uint32SliceToScVal ¶
func Uint32ToScVal ¶
Uint32ToScVal converts a uint32 to an xdr.ScVal.
func Uint64FromScVal ¶
Uint64FromScVal extracts a uint64 from an xdr.ScVal.
func Uint64SliceToScVal ¶
func Uint64ToScVal ¶
Uint64ToScVal converts a uint64 to an xdr.ScVal.
func VecToScVal ¶
VecToScVal converts a slice of xdr.ScVal into a vector xdr.ScVal.
Types ¶
type U128 ¶
type U128 xdr.UInt128Parts
U128 represents a Soroban u128 value. It wraps xdr.UInt128Parts and implements ToScVal for use in generated struct serialization.
func U128FromScVal ¶
U128FromScVal extracts U128 from an xdr.ScVal containing u128.