types

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	// DenomToIdKeyPrefix is the prefix to retrieve denom-to-asset-id mappings.
	DenomToIdKeyPrefix = "Asset/denom_to_id/"
	// AssetKeyPrefix is the prefix to retrieve all Assets
	AssetKeyPrefix = "Asset/value/"
	// NumAssetsKey is the prefix to retrieve the cardinality of Assets
	NumAssetsKey = "Asset/num/"
)
View Source
const (
	// ModuleName defines the module name
	ModuleName = "assets"

	// StoreKey defines the primary module store key
	StoreKey = ModuleName
)
View Source
const (
	// MaxAssetSymbolLength is the maximum exponent for a asset/coin unit
	// (e.g. DenomExponent, AtomicResolution)
	MaxAssetUnitExponentAbs = 32
)
View Source
const (
	// UusdcDenom is the precomputed denom for IBC Micro USDC.
	UusdcDenom = "ibc/8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5"
)

Variables

View Source
var (
	ErrInvalidLengthAsset        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAsset          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupAsset = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrAssetDoesNotExist            = sdkerrors.Register(ModuleName, 1, "Asset does not exist")
	ErrNegativeLongInterest         = sdkerrors.Register(ModuleName, 2, "LongInterest cannot be negative")
	ErrNoAssetWithDenom             = sdkerrors.Register(ModuleName, 3, "No asset found associated with given denom")
	ErrAssetDenomAlreadyExists      = sdkerrors.Register(ModuleName, 4, "Existing asset found with the same denom")
	ErrAssetIdAlreadyExists         = sdkerrors.Register(ModuleName, 5, "Existing asset found with the same asset id")
	ErrGapFoundInAssetId            = sdkerrors.Register(ModuleName, 6, "Found gap in asset Id")
	ErrAssetZeroNotUsdc             = sdkerrors.Register(ModuleName, 7, "First asset is not USDC")
	ErrNoAssetInGenesis             = sdkerrors.Register(ModuleName, 8, "No asset found in genesis state")
	ErrInvalidMarketId              = sdkerrors.Register(ModuleName, 9, "Found market id for asset without market")
	ErrInvalidAssetAtomicResolution = sdkerrors.Register(ModuleName, 10, "Invalid asset atomic resolution")
	ErrInvalidDenomExponent         = sdkerrors.Register(ModuleName, 11, "Invalid denom exponent")

	// Errors for Not Implemented
	ErrNotImplementedMulticollateral = sdkerrors.Register(ModuleName, 401, "Not Implemented: Multi-Collateral")
	ErrNotImplementedMargin          = sdkerrors.Register(ModuleName, 402, "Not Implemented: Margin-Trading of Assets")
)

x/assets module sentinel errors

View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)

Functions

func AssetKey

func AssetKey(
	id uint32,
) []byte

AssetKey returns the store key to retrieve an Asset from the id field

func KeyPrefix

func KeyPrefix(p string) []byte

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

func RegisterInterfaces

func RegisterInterfaces(registry cdctypes.InterfaceRegistry)

func RegisterMsgServer

func RegisterMsgServer(s grpc1.Server, srv MsgServer)

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

Types

type Asset

type Asset struct {
	// Unique, sequentially-generated.
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// The human readable symbol of the `Asset` (e.g. `USDC`, `ATOM`).
	// Must be uppercase, unique and correspond to the canonical symbol of the
	// full coin.
	Symbol string `protobuf:"bytes,2,opt,name=symbol,proto3" json:"symbol,omitempty"`
	// The name of base denomination unit of the `Asset` (e.g. `uatom`,
	// 'ibc/xxxxx'). Must be unique and match the `denom` used in the `sdk.Coin`
	// type in the `x/bank` module.
	Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"`
	// The exponent of converting one unit of `denom` to a full coin.
	// For example, `name=USDC, denom=uusdc, denom_exponent=-6` defines that
	// `1 uusdc = 10^(-6) USDC`. Note that `uusdc` refers to a `Coin` type in
	// `x/bank`, where the prefix `u` means `micro` by convetion. `uusdc` is
	// a different concept from a "quantum" defined by `atomic_resolution` below.
	// To convert from an amount of `denom` to quantums:
	// `quantums = denom_amount * 10^(denom_exponent - atomic_resolution)`
	DenomExponent int32 `protobuf:"zigzag32,4,opt,name=denom_exponent,json=denomExponent,proto3" json:"denom_exponent,omitempty"`
	// `true` if this `Asset` has a valid `MarketId` value.
	HasMarket bool `protobuf:"varint,5,opt,name=has_market,json=hasMarket,proto3" json:"has_market,omitempty"`
	// The `Id` of the `Market` associated with this `Asset`. It acts as the
	// oracle price for the purposes of calculating collateral
	// and margin requirements.
	MarketId uint32 `protobuf:"varint,6,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"`
	// The exponent for converting an atomic amount (1 'quantum')
	// to a full coin. For example, if `atomic_resolution = -8`
	// then an `asset_position` with `base_quantums = 1e8` is equivalent to
	// a position size of one full coin.
	AtomicResolution int32 `protobuf:"zigzag32,7,opt,name=atomic_resolution,json=atomicResolution,proto3" json:"atomic_resolution,omitempty"`
	// The total positive balance across the exchange.
	LongInterest uint64 `protobuf:"varint,8,opt,name=long_interest,json=longInterest,proto3" json:"long_interest,omitempty"`
}

Asset defines a single exchangable asset.

var AssetUsdc Asset = Asset{
	Id:               0,
	Symbol:           "USDC",
	DenomExponent:    -6,
	Denom:            UusdcDenom,
	HasMarket:        false,
	AtomicResolution: lib.QuoteCurrencyAtomicResolution,
}

func (*Asset) Descriptor

func (*Asset) Descriptor() ([]byte, []int)

func (*Asset) GetAtomicResolution

func (m *Asset) GetAtomicResolution() int32

func (*Asset) GetDenom

func (m *Asset) GetDenom() string

func (*Asset) GetDenomExponent

func (m *Asset) GetDenomExponent() int32

func (*Asset) GetHasMarket

func (m *Asset) GetHasMarket() bool

func (*Asset) GetId

func (m *Asset) GetId() uint32

func (*Asset) GetLongInterest

func (m *Asset) GetLongInterest() uint64

func (*Asset) GetMarketId

func (m *Asset) GetMarketId() uint32

func (*Asset) GetSymbol

func (m *Asset) GetSymbol() string

func (*Asset) Marshal

func (m *Asset) Marshal() (dAtA []byte, err error)

func (*Asset) MarshalTo

func (m *Asset) MarshalTo(dAtA []byte) (int, error)

func (*Asset) MarshalToSizedBuffer

func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Asset) ProtoMessage

func (*Asset) ProtoMessage()

func (*Asset) Reset

func (m *Asset) Reset()

func (*Asset) Size

func (m *Asset) Size() (n int)

func (*Asset) String

func (m *Asset) String() string

func (*Asset) Unmarshal

func (m *Asset) Unmarshal(dAtA []byte) error

func (*Asset) XXX_DiscardUnknown

func (m *Asset) XXX_DiscardUnknown()

func (*Asset) XXX_Marshal

func (m *Asset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Asset) XXX_Merge

func (m *Asset) XXX_Merge(src proto.Message)

func (*Asset) XXX_Size

func (m *Asset) XXX_Size() int

func (*Asset) XXX_Unmarshal

func (m *Asset) XXX_Unmarshal(b []byte) error

type GenesisState

type GenesisState struct {
	Assets []Asset `protobuf:"bytes,1,rep,name=assets,proto3" json:"assets"`
}

GenesisState defines the assets module's genesis state.

func DefaultGenesis

func DefaultGenesis() *GenesisState

DefaultGenesis returns the default Capability genesis state

func (*GenesisState) Descriptor

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetAssets

func (m *GenesisState) GetAssets() []Asset

func (*GenesisState) Marshal

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

func (m *GenesisState) Size() (n int)

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate performs basic genesis state validation returning an error upon any failure.

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type MsgClient

type MsgClient interface {
}

MsgClient is the client API for Msg service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMsgClient

func NewMsgClient(cc grpc1.ClientConn) MsgClient

type MsgServer

type MsgServer interface {
}

MsgServer is the server API for Msg service.

type PricesKeeper

type PricesKeeper interface {
	GetMarketPrice(
		ctx sdk.Context,
		id uint32,
	) (market prices.MarketPrice, err error)
}

type QueryAllAssetsRequest

type QueryAllAssetsRequest struct {
	Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

Queries a list of Asset items.

func (*QueryAllAssetsRequest) Descriptor

func (*QueryAllAssetsRequest) Descriptor() ([]byte, []int)

func (*QueryAllAssetsRequest) GetPagination

func (m *QueryAllAssetsRequest) GetPagination() *query.PageRequest

func (*QueryAllAssetsRequest) Marshal

func (m *QueryAllAssetsRequest) Marshal() (dAtA []byte, err error)

func (*QueryAllAssetsRequest) MarshalTo

func (m *QueryAllAssetsRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllAssetsRequest) MarshalToSizedBuffer

func (m *QueryAllAssetsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllAssetsRequest) ProtoMessage

func (*QueryAllAssetsRequest) ProtoMessage()

func (*QueryAllAssetsRequest) Reset

func (m *QueryAllAssetsRequest) Reset()

func (*QueryAllAssetsRequest) Size

func (m *QueryAllAssetsRequest) Size() (n int)

func (*QueryAllAssetsRequest) String

func (m *QueryAllAssetsRequest) String() string

func (*QueryAllAssetsRequest) Unmarshal

func (m *QueryAllAssetsRequest) Unmarshal(dAtA []byte) error

func (*QueryAllAssetsRequest) XXX_DiscardUnknown

func (m *QueryAllAssetsRequest) XXX_DiscardUnknown()

func (*QueryAllAssetsRequest) XXX_Marshal

func (m *QueryAllAssetsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllAssetsRequest) XXX_Merge

func (m *QueryAllAssetsRequest) XXX_Merge(src proto.Message)

func (*QueryAllAssetsRequest) XXX_Size

func (m *QueryAllAssetsRequest) XXX_Size() int

func (*QueryAllAssetsRequest) XXX_Unmarshal

func (m *QueryAllAssetsRequest) XXX_Unmarshal(b []byte) error

type QueryAllAssetsResponse

type QueryAllAssetsResponse struct {
	Asset      []Asset             `protobuf:"bytes,1,rep,name=asset,proto3" json:"asset"`
	Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
}

QueryAllAssetsResponse is response type for the AllAssets RPC method.

func (*QueryAllAssetsResponse) Descriptor

func (*QueryAllAssetsResponse) Descriptor() ([]byte, []int)

func (*QueryAllAssetsResponse) GetAsset

func (m *QueryAllAssetsResponse) GetAsset() []Asset

func (*QueryAllAssetsResponse) GetPagination

func (m *QueryAllAssetsResponse) GetPagination() *query.PageResponse

func (*QueryAllAssetsResponse) Marshal

func (m *QueryAllAssetsResponse) Marshal() (dAtA []byte, err error)

func (*QueryAllAssetsResponse) MarshalTo

func (m *QueryAllAssetsResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryAllAssetsResponse) MarshalToSizedBuffer

func (m *QueryAllAssetsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAllAssetsResponse) ProtoMessage

func (*QueryAllAssetsResponse) ProtoMessage()

func (*QueryAllAssetsResponse) Reset

func (m *QueryAllAssetsResponse) Reset()

func (*QueryAllAssetsResponse) Size

func (m *QueryAllAssetsResponse) Size() (n int)

func (*QueryAllAssetsResponse) String

func (m *QueryAllAssetsResponse) String() string

func (*QueryAllAssetsResponse) Unmarshal

func (m *QueryAllAssetsResponse) Unmarshal(dAtA []byte) error

func (*QueryAllAssetsResponse) XXX_DiscardUnknown

func (m *QueryAllAssetsResponse) XXX_DiscardUnknown()

func (*QueryAllAssetsResponse) XXX_Marshal

func (m *QueryAllAssetsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAllAssetsResponse) XXX_Merge

func (m *QueryAllAssetsResponse) XXX_Merge(src proto.Message)

func (*QueryAllAssetsResponse) XXX_Size

func (m *QueryAllAssetsResponse) XXX_Size() int

func (*QueryAllAssetsResponse) XXX_Unmarshal

func (m *QueryAllAssetsResponse) XXX_Unmarshal(b []byte) error

type QueryAssetRequest

type QueryAssetRequest struct {
	Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
}

Queries an Asset by id.

func (*QueryAssetRequest) Descriptor

func (*QueryAssetRequest) Descriptor() ([]byte, []int)

func (*QueryAssetRequest) GetId

func (m *QueryAssetRequest) GetId() uint32

func (*QueryAssetRequest) Marshal

func (m *QueryAssetRequest) Marshal() (dAtA []byte, err error)

func (*QueryAssetRequest) MarshalTo

func (m *QueryAssetRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryAssetRequest) MarshalToSizedBuffer

func (m *QueryAssetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAssetRequest) ProtoMessage

func (*QueryAssetRequest) ProtoMessage()

func (*QueryAssetRequest) Reset

func (m *QueryAssetRequest) Reset()

func (*QueryAssetRequest) Size

func (m *QueryAssetRequest) Size() (n int)

func (*QueryAssetRequest) String

func (m *QueryAssetRequest) String() string

func (*QueryAssetRequest) Unmarshal

func (m *QueryAssetRequest) Unmarshal(dAtA []byte) error

func (*QueryAssetRequest) XXX_DiscardUnknown

func (m *QueryAssetRequest) XXX_DiscardUnknown()

func (*QueryAssetRequest) XXX_Marshal

func (m *QueryAssetRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAssetRequest) XXX_Merge

func (m *QueryAssetRequest) XXX_Merge(src proto.Message)

func (*QueryAssetRequest) XXX_Size

func (m *QueryAssetRequest) XXX_Size() int

func (*QueryAssetRequest) XXX_Unmarshal

func (m *QueryAssetRequest) XXX_Unmarshal(b []byte) error

type QueryAssetResponse

type QueryAssetResponse struct {
	Asset Asset `protobuf:"bytes,1,opt,name=asset,proto3" json:"asset"`
}

QueryAssetResponse is response type for the Asset RPC method.

func (*QueryAssetResponse) Descriptor

func (*QueryAssetResponse) Descriptor() ([]byte, []int)

func (*QueryAssetResponse) GetAsset

func (m *QueryAssetResponse) GetAsset() Asset

func (*QueryAssetResponse) Marshal

func (m *QueryAssetResponse) Marshal() (dAtA []byte, err error)

func (*QueryAssetResponse) MarshalTo

func (m *QueryAssetResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryAssetResponse) MarshalToSizedBuffer

func (m *QueryAssetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*QueryAssetResponse) ProtoMessage

func (*QueryAssetResponse) ProtoMessage()

func (*QueryAssetResponse) Reset

func (m *QueryAssetResponse) Reset()

func (*QueryAssetResponse) Size

func (m *QueryAssetResponse) Size() (n int)

func (*QueryAssetResponse) String

func (m *QueryAssetResponse) String() string

func (*QueryAssetResponse) Unmarshal

func (m *QueryAssetResponse) Unmarshal(dAtA []byte) error

func (*QueryAssetResponse) XXX_DiscardUnknown

func (m *QueryAssetResponse) XXX_DiscardUnknown()

func (*QueryAssetResponse) XXX_Marshal

func (m *QueryAssetResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryAssetResponse) XXX_Merge

func (m *QueryAssetResponse) XXX_Merge(src proto.Message)

func (*QueryAssetResponse) XXX_Size

func (m *QueryAssetResponse) XXX_Size() int

func (*QueryAssetResponse) XXX_Unmarshal

func (m *QueryAssetResponse) XXX_Unmarshal(b []byte) error

type QueryClient

type QueryClient interface {
	// Queries a Asset by id.
	Asset(ctx context.Context, in *QueryAssetRequest, opts ...grpc.CallOption) (*QueryAssetResponse, error)
	// Queries a list of Asset items.
	AllAssets(ctx context.Context, in *QueryAllAssetsRequest, opts ...grpc.CallOption) (*QueryAllAssetsResponse, error)
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryServer

type QueryServer interface {
	// Queries a Asset by id.
	Asset(context.Context, *QueryAssetRequest) (*QueryAssetResponse, error)
	// Queries a list of Asset items.
	AllAssets(context.Context, *QueryAllAssetsRequest) (*QueryAllAssetsResponse, error)
}

QueryServer is the server API for Query service.

type UnimplementedMsgServer

type UnimplementedMsgServer struct {
}

UnimplementedMsgServer can be embedded to have forward compatible implementations.

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) AllAssets

func (*UnimplementedQueryServer) Asset

Jump to

Keyboard shortcuts

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