common

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 6 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) MarshalBinary added in v0.2.3

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

Used by the `cbor` library.

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) Plus added in v0.2.3

func (b BigInt) Plus(other BigInt) BigInt

func (*BigInt) ScanNumeric

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

Implement NumericDecoder interface for BigInt.

func (BigInt) String added in v0.1.24

func (b BigInt) String() string

func (BigInt) Times added in v0.2.3

func (b BigInt) Times(other BigInt) BigInt

func (*BigInt) UnmarshalBinary added in v0.2.3

func (b *BigInt) UnmarshalBinary(data []byte) error

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 Layer added in v0.1.13

type Layer string

Layer is an identifier for either Consensus or a network runtime.

const (
	LayerConsensus Layer = "consensus"
	LayerEmerald   Layer = "emerald"
	LayerCipher    Layer = "cipher"
	LayerSapphire  Layer = "sapphire"
)

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"
)

type TokenType added in v0.1.17

type TokenType int

TokenType is a small-ish number that we use to identify what type of token each row of the tokens table is. Values aren't consecutive like in an enum. Prefer to use the number of the ERC if applicable and available, e.g. 20 for ERC-20. "Historical reasons" style note: this has grown to include non-EVM token types as well.

const (
	TokenTypeNative      TokenType = -1 // A placeholder type to represent the runtime's native token. No contract should be assigned this type.
	TokenTypeUnsupported TokenType = 0  // A smart contract for which we're confident it's not a supported token kind.
	TokenTypeERC20       TokenType = 20
	TokenTypeERC721      TokenType = 721
)

Jump to

Keyboard shortcuts

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