utils

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Native = "native"

Native is the string representing the type for the native lumen asset

View Source
const SdexPrecision int8 = 7

SdexPrecision defines the number of decimals used in SDEX

Variables

View Source
var NativeAsset = horizon.Asset{Type: Native}

NativeAsset represents the native asset

Functions

func AmountStringAsFloat

func AmountStringAsFloat(amount string) float64

AmountStringAsFloat converts a string amount to a float amount

func Asset2Asset

func Asset2Asset(Asset horizon.Asset) build.Asset

Asset2Asset is a Boyz2Men cover band on the blockchain

func Asset2Asset2

func Asset2Asset2(Asset build.Asset) horizon.Asset

Asset2Asset2 converts a build.Asset to a horizon.Asset

func Asset2CodeString added in v1.3.0

func Asset2CodeString(asset horizon.Asset) string

Asset2CodeString extracts the code out of a horizon.Asset

func Asset2String

func Asset2String(asset horizon.Asset) string

Asset2String converts a horizon.Asset to a string representation, using "native" for the native XLM

func AssetsEqual

func AssetsEqual(baseAsset base.Asset, horizonAsset horizon.Asset) bool

AssetsEqual is a convenience method to compare horizon.Asset and base.Asset because they are not type aliased

func CheckConfigError

func CheckConfigError(cfg fmt.Stringer, e error, filename string)

CheckConfigError checks configs for errors, crashes app if there's an error

func CheckFetchFloat added in v1.1.1

func CheckFetchFloat(m map[string]interface{}, key string) (float64, error)

CheckFetchFloat tries to fetch and then cast the value for the provided key

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 []horizon.Offer, sellAsset horizon.Asset, buyAsset horizon.Asset) (sellOffers []horizon.Offer, buyOffers []horizon.Offer)

FilterOffers filters out the offers into selling and buying, where sellOffers sells the sellAsset and buyOffers buys the sellAsset

func GetCreditBalance

func GetCreditBalance(a horizon.Account, code string, issuer string) *string

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

func GetInvertedPrice(offer horizon.Offer) float64

GetInvertedPrice gets the inverted price from an offer

func GetJSON

func GetJSON(client http.Client, url string, target interface{}) error

GetJSON is a helper method to get json from a URL

func GetPrice

func GetPrice(offer horizon.Offer) float64

GetPrice gets the price from an offer

func Hide added in v1.3.0

func Hide(i interface{}) interface{}

Hide returns an empty string

func IsSelling added in v1.6.0

func IsSelling(sdexBase horizon.Asset, sdexQuote horizon.Asset, selling xdr.Asset, buying xdr.Asset) (bool, error)

IsSelling helper method

func LoadAllOffers

func LoadAllOffers(account string, api *horizon.Client) ([]horizon.Offer, error)

LoadAllOffers loads all the offers for a given account

func LogConfig added in v1.2.0

func LogConfig(cfg fmt.Stringer)

LogConfig logs out the config file

func ParseAsset added in v1.4.0

func ParseAsset(code string, issuer string) (*horizon.Asset, error)

ParseAsset returns a horizon asset a string

func ParseNetwork

func ParseNetwork(horizonURL string) build.Network

ParseNetwork checks the horizon url and returns the test network if it contains "test"

func ParseOfferAmount added in v1.6.0

func ParseOfferAmount(amt string) (float64, error)

ParseOfferAmount is a convenience method to parse an offer amount

func ParseSecret

func ParseSecret(secret string) (*string, error)

ParseSecret returns the address from the secret

func PriceAsFloat

func PriceAsFloat(price string) float64

PriceAsFloat converts a string price to a float price

func SecretKey2PublicKey

func SecretKey2PublicKey(i interface{}) interface{}

SecretKey2PublicKey converts a secret key to a public key

func String2Asset

func String2Asset(code string, issuer string) horizon.Asset

String2Asset converts a code:issuer to a horizon.Asset

func StructString

func StructString(s interface{}, transforms map[string]func(interface{}) interface{}) string

StructString is a helper method that

func UnwrapFloat64Pointer added in v1.6.1

func UnwrapFloat64Pointer(i interface{}) interface{}

UnwrapFloat64Pointer unwraps a float64 pointer

func UnwrapInt8Pointer added in v1.6.1

func UnwrapInt8Pointer(i interface{}) interface{}

UnwrapInt8Pointer unwraps a int8 pointer

Types

type ByPrice

type ByPrice []horizon.Offer

ByPrice implements sort.Interface for []horizon.Offer based on the price

func (ByPrice) Len

func (a ByPrice) Len() int

func (ByPrice) Less

func (a ByPrice) Less(i, j int) bool

func (ByPrice) Swap

func (a ByPrice) Swap(i, j int)

Jump to

Keyboard shortcuts

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