Documentation
¶
Index ¶
- func AddHexPrefix(str string) string
- func DecodeDomain(encoded []*felt.Felt) string
- func DecodeShortString(str string) (string, error)
- func EncodeDomain(domain string) ([]*felt.Felt, error)
- func EncodeShortString(str string) (*felt.Felt, error)
- func FmtFeltArrayCallData(callData []*felt.Felt) []*felt.Felt
- func GetBlobbertContract(chainId types.StarknetChainId) (string, error)
- func GetIdentityContract(chainId types.StarknetChainId) (string, error)
- func GetMulticallContract(chainId types.StarknetChainId) (string, error)
- func GetNamingContract(chainId types.StarknetChainId) (string, error)
- func GetPfpVerifierContract(chainId types.StarknetChainId) (string, error)
- func GetPopVerifierContract(chainId types.StarknetChainId) (string, error)
- func GetUtilsMulticallContract(chainId types.StarknetChainId) (string, error)
- func GetVerifierContract(chainId types.StarknetChainId) (string, error)
- func IsASCII(str string) bool
- func IsBraavosSubdomain(domain string) bool
- func IsDecimalString(str string) bool
- func IsHex(str string) bool
- func IsShortString(str string) bool
- func IsStarkDomain(domain string) bool
- func IsStarkRootDomain(domain string) bool
- func IsSubdomain(subdomain string) bool
- func IsXplorerSubdomain(domain string) bool
- func RemoveHexPrefix(str string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHexPrefix ¶
AddHexPrefix adds the "0x" prefix to a string if it does not already have it.
Parameters:
- str: The string to add the prefix to.
Returns:
- string: The string with the "0x" prefix.
func DecodeDomain ¶
DecodeDomain decodes a starknet.id domain from a list of felt.
Parameters:
- encoded: The encoded domain.
Returns:
- string: The decoded domain.
Examples:
- DecodeDomain(nil) => ""
- DecodeDomain([felt_0]) => ""
- DecodeDomain([felt_abc]) => "abc.stark"
- DecodeDomain([felt_def]) => "def.stark"
- DecodeDomain([felt_ghi]) => "ghi.stark"
- DecodeDomain([felt_abc, felt_def]) => "abc.def.stark"
- DecodeDomain([felt_abc, felt_def, felt_ghi]) => "abc.def.ghi.stark"
func DecodeShortString ¶ added in v0.1.7
DecodeShortString decodes a string from its hexadecimal representation.
Parameters:
- str: The string to decode.
Returns:
- string: The decoded string.
- error: An error if the string is not a hexadecimal or decimal string.
func EncodeDomain ¶
EncodeDomain encodes a starknet.id domain into a list of felt, with one felt per subdomain.
Parameters:
- domain: The domain to encode (.stark suffix is optional).
Returns:
- []*felt.Felt: The encoded domain.
- error: An error if the encoding fails.
Examples:
- EncodeDomain("") => [felt_0]
- EncodeDomain("abc.stark") => [felt_abc]
- EncodeDomain("abc") => [felt_abc]
- EncodeDomain("def.stark") => [felt_def]
- EncodeDomain("ghi.stark") => [felt_ghi]
- EncodeDomain("abc.def.stark") => [felt_abc, felt_def]
- EncodeDomain("abc.def.ghi.stark") => [felt_abc, felt_def, felt_ghi]
- EncodeDomain("αβγ.stark") => error failed to encode subdomain αβγ: invalid character α
func EncodeShortString ¶
EncodeShortString encodes a string to its hexadecimal representation with a "0x" prefix.
Parameters:
- str: The string to encode.
Returns:
- *felt.Felt: The encoded string.
- error: An error if the string is not an ASCII string or is too long.
func FmtFeltArrayCallData ¶
FmtFeltArrayCallData formats an array call data: [len(callData), callData...]
Parameters:
- callData: The call data to format.
Returns:
- []*felt.Felt: The formatted call data.
func GetBlobbertContract ¶
func GetBlobbertContract(chainId types.StarknetChainId) (string, error)
GetBlobbertContract returns the blobbert contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The blobbert contract address.
- error: An error if the blobbert contract is not deployed on the chain.
func GetIdentityContract ¶
func GetIdentityContract(chainId types.StarknetChainId) (string, error)
GetIdentityContract returns the identity contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The identity contract address.
- error: An error if the identity contract is not deployed on the chain.
func GetMulticallContract ¶
func GetMulticallContract(chainId types.StarknetChainId) (string, error)
GetMulticallContract returns the multicall contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The multicall contract address.
- error: An error if the multicall contract is not deployed on the chain.
func GetNamingContract ¶
func GetNamingContract(chainId types.StarknetChainId) (string, error)
GetNamingContract returns the naming contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The naming contract address.
- error: An error if the naming contract is not deployed on the chain.
func GetPfpVerifierContract ¶
func GetPfpVerifierContract(chainId types.StarknetChainId) (string, error)
GetPfpVerifierContract returns the profile picture verifier contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The profile picture verifier contract address.
- error: An error if the profile picture verifier contract is not deployed on the chain.
func GetPopVerifierContract ¶
func GetPopVerifierContract(chainId types.StarknetChainId) (string, error)
GetPopVerifierContract returns the proof of personhood verifier contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The proof of personhood verifier contract address.
- error: An error if the proof of personhood verifier contract is not deployed on the chain.
func GetUtilsMulticallContract ¶
func GetUtilsMulticallContract(chainId types.StarknetChainId) (string, error)
GetUtilsMulticallContract returns the utils multicall contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The utils multicall contract address.
- error: An error if the utils multicall contract is not deployed on the chain.
func GetVerifierContract ¶
func GetVerifierContract(chainId types.StarknetChainId) (string, error)
GetVerifierContract returns the verifier contract address for a given chain.
Parameters:
- chainId: The chain ID.
Returns:
- string: The verifier contract address.
- error: An error if the verifier contract is not deployed on the chain.
func IsASCII ¶
IsASCII checks if a string contains only ASCII characters.
Parameters:
- str: The string to check.
Returns:
- bool: True if the string contains only ASCII characters, false otherwise.
func IsBraavosSubdomain ¶
IsBraavosSubdomain checks if a domain is a Braavos subdomain based on the following regular expression: `^([a-z0-9-]){1,48}\.braavos\.stark$`
Parameters:
- domain: The domain to check.
Returns:
- bool: True if the domain is a Braavos subdomain, false otherwise.
func IsDecimalString ¶ added in v0.1.7
IsDecimalString checks if a string is a decimal string.
Parameters:
- str: The string to check.
Returns:
- bool: True if the string is a decimal string, false otherwise.
func IsHex ¶ added in v0.1.7
IsHex checks if a string is a hexadecimal string.
Parameters:
- str: The string to check.
Returns:
- bool: True if the string is a hexadecimal string, false otherwise.
func IsShortString ¶
IsShortString checks if the length of a string is valid for a short string.
Parameters:
- str: The string to check.
Returns:
- bool: True if the string is a short string, false otherwise.
func IsStarkDomain ¶
IsStarkDomain checks if a domain is a starknet.id domain based on the following regular expression: `^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$`
Parameters:
- domain: The domain to check.
Returns:
- bool: True if the domain is a starknet.id domain, false otherwise.
func IsStarkRootDomain ¶
IsStarkRootDomain checks if a domain is a stark root domain based on the following regular expression: `^([a-z0-9-]){1,48}\.stark$`
Parameters:
- domain: The domain to check.
Returns:
- bool: True if the domain is a stark root domain, false otherwise.
func IsSubdomain ¶
IsSubdomain checks if a domain is a subdomain.
Parameters:
- subdomain: The domain to check.
Returns:
- bool: True if the domain is a subdomain, false otherwise.
func IsXplorerSubdomain ¶
IsXplorerSubdomain checks if a domain is an xplorer subdomain based on the following regular expression: `^([a-z0-9-]){1,48}\.xplorer\.stark$`
Parameters:
- domain: The domain to check.
Returns:
- bool: True if the domain is an xplorer subdomain, false otherwise.
func RemoveHexPrefix ¶ added in v0.1.7
RemoveHexPrefix removes the "0x" prefix from a string if it has it.
Parameters:
- str: The string to remove the prefix from.
Returns:
- string: The string without the "0x" prefix.
Types ¶
This section is empty.