Documentation ¶
Index ¶
- Constants
- Variables
- func AmountStringAsFloat(amount string) float64
- func Asset2Asset(Asset hProtocol.Asset) txnbuild.Asset
- func Asset2Asset2(Asset txnbuild.Asset) hProtocol.Asset
- func Asset2CodeString(asset hProtocol.Asset) string
- func Asset2String(asset hProtocol.Asset) string
- func AssetFloatEquals(t *testing.T, want float64, actual float64)
- func AssetOnlyCodeEquals(hAsset hProtocol.Asset, txnAsset txnbuild.Asset) (bool, error)
- func AssetsEqual(baseAsset base.Asset, horizonAsset hProtocol.Asset) bool
- func CheckConfigError(cfg fmt.Stringer, e error, filename string)
- func CheckFetchFloat(m map[string]interface{}, key string) (float64, error)
- func CheckedFloatPtr(v *float64) string
- func CheckedString(v interface{}) string
- func Dedupe(list []string) []string
- func FilterOffers(offers []hProtocol.Offer, sellAsset hProtocol.Asset, buyAsset hProtocol.Asset) (sellOffers []hProtocol.Offer, buyOffers []hProtocol.Offer)
- func GetCreditBalance(a hProtocol.Account, code string, issuer string) *string
- func GetInvertedPrice(offer hProtocol.Offer) float64
- func GetJSON(client http.Client, url string, target interface{}) error
- func GetPrice(offer hProtocol.Offer) float64
- func HashString(s string) (uint32, error)
- func Hide(i interface{}) interface{}
- func IsSelling(sdexBase hProtocol.Asset, sdexQuote hProtocol.Asset, selling txnbuild.Asset, ...) (bool, error)
- func LoadAllOffers(account string, api *horizonclient.Client) ([]hProtocol.Offer, error)
- func LogConfig(cfg fmt.Stringer)
- func MergeMaps(original map[string]interface{}, overrides map[string]interface{}) (map[string]interface{}, error)
- func MustParseAsset(code string, issuer string) *hProtocol.Asset
- func Offer2TxnBuildSellOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer
- func ParseAsset(code string, issuer string) (*hProtocol.Asset, error)
- func ParseMaybeFloat(valueString string) (*float64, error)
- func ParseNetwork(horizonURL string) string
- func ParseOfferAmount(amt string) (float64, error)
- func ParseSecret(secret string) (*string, error)
- func PriceAsFloat(price string) float64
- func PrintErrorHintf(message string, args ...interface{})
- func SecretKey2PublicKey(i interface{}) interface{}
- func Shuffle(slice []string)
- func SignWithSeed(tx *txnbuild.Transaction, network string, seeds ...string) (*txnbuild.Transaction, error)
- func String2Asset(code string, issuer string) hProtocol.Asset
- func StringSet(list []string) map[string]bool
- func StructString(s interface{}, indentLevel uint8, ...) string
- func ToJSONHash(v interface{}) (uint32, error)
- func ToMapStringInterface(v interface{}) (map[string]interface{}, error)
- type ByPrice
Constants ¶
const Native = "native"
Native is the string representing the type for the native lumen asset
const SdexPrecision int8 = 7
SdexPrecision defines the number of decimals used in SDEX
Variables ¶
var NativeAsset = hProtocol.Asset{Type: Native}
NativeAsset represents the native asset
Functions ¶
func AmountStringAsFloat ¶
AmountStringAsFloat converts a string amount to a float amount
func Asset2Asset ¶
Asset2Asset converts a horizon.Asset to a txnbuild.Asset.
func Asset2Asset2 ¶
Asset2Asset2 converts a txnbuild.Asset to a horizon.Asset.
func Asset2CodeString ¶ added in v1.3.0
Asset2CodeString extracts the code out of a horizon.Asset
func Asset2String ¶
Asset2String converts a horizon.Asset to a string representation, using "native" for the native XLM
func AssetFloatEquals ¶ added in v1.10.0
AssetFloatEquals is a float comparison within a pre-defined epsilon error
func AssetOnlyCodeEquals ¶ added in v1.8.0
AssetOnlyCodeEquals only checks the type and code of these assets, i.e. insensitive to asset issuer
func AssetsEqual ¶
AssetsEqual is a convenience method to compare horizon.Asset and base.Asset because they are not type aliased
func CheckConfigError ¶
CheckConfigError checks configs for errors, crashes app if there's an error
func CheckFetchFloat ¶ added in v1.1.1
CheckFetchFloat tries to fetch and then cast the value for the provided key
func CheckedFloatPtr ¶ added in v1.8.0
CheckedFloatPtr returns "<nil>" if the object is nil, otherwise calls the String() function on the object
func CheckedString ¶ added in v1.2.0
func CheckedString(v interface{}) string
CheckedString returns "<nil>" if the object is nil, otherwise calls the String() function on the object
func FilterOffers ¶
func FilterOffers(offers []hProtocol.Offer, sellAsset hProtocol.Asset, buyAsset hProtocol.Asset) (sellOffers []hProtocol.Offer, buyOffers []hProtocol.Offer)
FilterOffers filters out the offers into selling and buying, where sellOffers sells the sellAsset and buyOffers buys the sellAsset
func GetCreditBalance ¶
GetCreditBalance is a drop-in for the function in the GoSDK, we want it to return nil if there's no balance (as opposed to "0")
func GetInvertedPrice ¶
GetInvertedPrice gets the inverted price from an offer
func HashString ¶ added in v1.10.0
HashString hashes a string using the FNV-1 hash function.
func IsSelling ¶ added in v1.6.0
func IsSelling(sdexBase hProtocol.Asset, sdexQuote hProtocol.Asset, selling txnbuild.Asset, buying txnbuild.Asset) (bool, error)
IsSelling helper method TODO DS Add tests for the various possible errors.
func LoadAllOffers ¶
LoadAllOffers loads all the offers for a given account
func MergeMaps ¶ added in v1.11.0
func MergeMaps(original map[string]interface{}, overrides map[string]interface{}) (map[string]interface{}, error)
MergeMaps combines two arbitrary maps. Note that values from the second would override the first.
func MustParseAsset ¶ added in v1.11.0
MustParseAsset returns a horizon asset or panics
func Offer2TxnBuildSellOffer ¶ added in v1.9.0
func Offer2TxnBuildSellOffer(offer hProtocol.Offer) txnbuild.ManageSellOffer
Offer2TxnBuildSellOffer converts an hProtocol.Offer to a txnbuild.ManageSellOffer
func ParseAsset ¶ added in v1.4.0
ParseAsset returns a horizon asset
func ParseMaybeFloat ¶ added in v1.8.0
ParseMaybeFloat parses an optional string value as a float pointer
func ParseNetwork ¶
ParseNetwork checks the horizon url and returns the test network if it contains "test"
func ParseOfferAmount ¶ added in v1.6.0
ParseOfferAmount is a convenience method to parse an offer amount
func ParseSecret ¶
ParseSecret returns the address from the secret
func PriceAsFloat ¶
PriceAsFloat converts a string price to a float price
func PrintErrorHintf ¶ added in v1.8.0
func PrintErrorHintf(message string, args ...interface{})
PrintErrorHintf shows a helpful hint for the user when there is an error (likely recoverable)
func SecretKey2PublicKey ¶
func SecretKey2PublicKey(i interface{}) interface{}
SecretKey2PublicKey converts a secret key to a public key
func SignWithSeed ¶ added in v1.8.0
func SignWithSeed(tx *txnbuild.Transaction, network string, seeds ...string) (*txnbuild.Transaction, error)
SignWithSeed returns a new tx with the signatures of the passed in seeds
func String2Asset ¶
String2Asset converts a code:issuer to a horizon.Asset
func StringSet ¶ added in v1.8.0
StringSet converts a string slice to a map of string to bool values to represent a Set
func StructString ¶
func StructString(s interface{}, indentLevel uint8, transforms map[string]func(interface{}) interface{}) string
StructString is a helper method that serizlies configs; the transform keys are always flattened, i.e specify the key meant to be on an inner object at a top level key on the transform map
func ToJSONHash ¶ added in v1.11.0
ToJSONHash converts to json first and then takes the hash
func ToMapStringInterface ¶ added in v1.11.0
ToMapStringInterface converts an arbitrary struct to a map[string]interface{}, through serializing to and deserializing from JSON.