Documentation
¶
Overview ¶
Package utils implements helper functions for the Go NEAR API.
Index ¶
- Constants
- Variables
- func ExponentialBackoff(startWaitTime, retryNumber int, waitBackoff float64, fn GetResult) (map[string]interface{}, error)
- func FormatNearAmount(balance string) (string, error)
- func ParseNearAmount(amount string) (string, error)
- func ParseNearAmountAsBigInt(amount string) (*big.Int, error)
- func PrettyPrintResponse(res map[string]interface{})
- type GetResult
- type PublicKey
Constants ¶
const (
ED25519 = 0
)
All supported key types
const NearNominationExp = 24
NearNominationExp defines the exponent for calculating how many indivisible units are there in one NEAR. See NearNomination.
Variables ¶
var ErrRetriesExceeded = errors.New("utils: exceeded retry attempts for request")
ErrRetriesExceeded if the maximum number of retry attempts have been exceeded for request.
var NearNomination = big.NewInt(0).Exp(big.NewInt(10), big.NewInt(NearNominationExp), nil)
NearNomination defines the number of indivisible units in one NEAR. Derived from NearNominationExp.
Functions ¶
func ExponentialBackoff ¶
func ExponentialBackoff( startWaitTime, retryNumber int, waitBackoff float64, fn GetResult, ) (map[string]interface{}, error)
ExponentialBackoff implements an exponential backoff strategy for calling function fn.
func FormatNearAmount ¶
FormatNearAmount converts account balance value from internal indivisible units to NEAR. 1 NEAR is defined by NearNomination. Effectively this divides given amount by NearNomination.
func ParseNearAmount ¶
ParseNearAmount converts a human readable NEAR amount (potentially factional) to internal indivisible units. Effectively this multiplies given amount by NearNomination. Returns the parsed yoctoⓃ amount.
func ParseNearAmountAsBigInt ¶
ParseNearAmountAsBigInt converts a human readable NEAR amount (potentially factional) to internal indivisible units. Effectively this multiplies given amount by NearNomination. Returns the parsed yoctoⓃ amount.
func PrettyPrintResponse ¶
func PrettyPrintResponse(res map[string]interface{})
PrettyPrintResponse pretty prints some info from the given JSON result map res.