common

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNetworkUnknown is returned if a chain context does not correspond
	// to a known network identifier.
	ErrNetworkUnknown = errors.New("network unknown")

	// ErrRuntimeUnknown is returned if a chain context does not correspond
	// to a known runtime identifier.
	ErrRuntimeUnknown = errors.New("runtime unknown")
)

Functions

func Ptr

func Ptr[T any](v T) *T

func TryAsJSON

func TryAsJSON(v interface{}) json.RawMessage

Returns `v` as a JSON string. If `v` cannot be marshaled, returns the string "null" instead.

Types

type BigInt

type BigInt struct {
	big.Int
}

Arbitrary-precision integer. Wrapper around big.Int to allow for custom JSON marshaling.

func BigIntFromQuantity

func BigIntFromQuantity(q quantity.Quantity) BigInt

func NewBigInt

func NewBigInt(v int64) BigInt

func NumericToBigInt

func NumericToBigInt(n pgtype.Numeric) (BigInt, error)

NumericToBigInt converts a pgtype.Numeric to a BigInt similar to the private method found at https://github.com/jackc/pgtype/blob/master/numeric.go#L398

func (BigInt) MarshalJSON

func (b BigInt) MarshalJSON() ([]byte, error)

func (BigInt) MarshalText

func (b BigInt) MarshalText() ([]byte, error)

func (BigInt) NumericValue

func (b BigInt) NumericValue() (pgtype.Numeric, error)

Implement NumericValuer interface for BigInt.

func (*BigInt) ScanNumeric

func (b *BigInt) ScanNumeric(n pgtype.Numeric) error

Implement NumericDecoder interface for BigInt.

func (*BigInt) UnmarshalJSON

func (b *BigInt) UnmarshalJSON(text []byte) error

func (*BigInt) UnmarshalText

func (b *BigInt) UnmarshalText(text []byte) error

type CallFormat

type CallFormat string

type ChainName

type ChainName string

ChainName is a name given to a sequence of networks. Used to index config.DefaultChains and sdkConfig.DefaultNetworks.All.

const (
	// ChainNameTestnet is the identifier for testnet.
	ChainNameTestnet ChainName = "testnet"
	// ChainNameMainnet is the identifier for mainnet.
	ChainNameMainnet ChainName = "mainnet"
	// ChainNameUnknown is the identifier for an unknown network.
	ChainNameUnknown ChainName = "unknown"
)

type ContextKey

type ContextKey string

Key used to set values in a web request context. API uses this to set values, backend uses this to retrieve values.

const (
	// RuntimeContextKey is used to set the relevant runtime name
	// in a request context.
	RuntimeContextKey ContextKey = "runtime"
	// RequestIDContextKey is used to set a request id for tracing
	// in a request context.
	RequestIDContextKey ContextKey = "request_id"
)

type Runtime

type Runtime string

Runtime is an identifier for a runtime on the Oasis Network.

const (
	RuntimeEmerald  Runtime = "emerald"
	RuntimeCipher   Runtime = "cipher"
	RuntimeSapphire Runtime = "sapphire"
	RuntimeUnknown  Runtime = "unknown"
)

Jump to

Keyboard shortcuts

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