priceoraclerpc

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package priceoraclerpc is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	TransactionType_name = map[int32]string{
		0: "PURCHASE",
		1: "SALE",
	}
	TransactionType_value = map[string]int32{
		"PURCHASE": 0,
		"SALE":     1,
	}
)

Enum value maps for TransactionType.

View Source
var File_priceoraclerpc_price_oracle_proto protoreflect.FileDescriptor
View Source
var PriceOracle_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "priceoraclerpc.PriceOracle",
	HandlerType: (*PriceOracleServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "QueryRateTick",
			Handler:    _PriceOracle_QueryRateTick_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "priceoraclerpc/price_oracle.proto",
}

PriceOracle_ServiceDesc is the grpc.ServiceDesc for PriceOracle service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func IsAssetBtc

func IsAssetBtc(assetSpecifier *AssetSpecifier) bool

IsAssetBtc is a helper function that returns true if the given asset specifier represents BTC, and false otherwise.

func RegisterPriceOracleHandler

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

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

func RegisterPriceOracleHandlerClient

func RegisterPriceOracleHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PriceOracleClient) error

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

func RegisterPriceOracleHandlerFromEndpoint

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

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

func RegisterPriceOracleHandlerServer

func RegisterPriceOracleHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PriceOracleServer) error

RegisterPriceOracleHandlerServer registers the http handlers for service PriceOracle to "mux". UnaryRPC :call PriceOracleServer 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 RegisterPriceOracleHandlerFromEndpoint instead.

func RegisterPriceOracleJSONCallbacks

func RegisterPriceOracleJSONCallbacks(registry map[string]func(ctx context.Context,
	conn *grpc.ClientConn, reqJSON string, callback func(string, error)))

func RegisterPriceOracleServer

func RegisterPriceOracleServer(s grpc.ServiceRegistrar, srv PriceOracleServer)

Types

type AssetSpecifier

type AssetSpecifier struct {

	// Types that are assignable to Id:
	//
	//	*AssetSpecifier_AssetId
	//	*AssetSpecifier_AssetIdStr
	//	*AssetSpecifier_GroupKey
	//	*AssetSpecifier_GroupKeyStr
	Id isAssetSpecifier_Id `protobuf_oneof:"id"`
	// contains filtered or unexported fields
}

AssetSpecifier is a union type for specifying an asset by either its asset ID or group key.

func (*AssetSpecifier) Descriptor deprecated

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

Deprecated: Use AssetSpecifier.ProtoReflect.Descriptor instead.

func (*AssetSpecifier) GetAssetId

func (x *AssetSpecifier) GetAssetId() []byte

func (*AssetSpecifier) GetAssetIdStr

func (x *AssetSpecifier) GetAssetIdStr() string

func (*AssetSpecifier) GetGroupKey

func (x *AssetSpecifier) GetGroupKey() []byte

func (*AssetSpecifier) GetGroupKeyStr

func (x *AssetSpecifier) GetGroupKeyStr() string

func (*AssetSpecifier) GetId

func (m *AssetSpecifier) GetId() isAssetSpecifier_Id

func (*AssetSpecifier) ProtoMessage

func (*AssetSpecifier) ProtoMessage()

func (*AssetSpecifier) ProtoReflect

func (x *AssetSpecifier) ProtoReflect() protoreflect.Message

func (*AssetSpecifier) Reset

func (x *AssetSpecifier) Reset()

func (*AssetSpecifier) String

func (x *AssetSpecifier) String() string

type AssetSpecifier_AssetId

type AssetSpecifier_AssetId struct {
	// The 32-byte asset ID specified as raw bytes (gRPC only).
	AssetId []byte `protobuf:"bytes,1,opt,name=asset_id,json=assetId,proto3,oneof"`
}

type AssetSpecifier_AssetIdStr

type AssetSpecifier_AssetIdStr struct {
	// The 32-byte asset ID encoded as a hex string (use this for REST).
	AssetIdStr string `protobuf:"bytes,2,opt,name=asset_id_str,json=assetIdStr,proto3,oneof"`
}

type AssetSpecifier_GroupKey

type AssetSpecifier_GroupKey struct {
	// The 32-byte asset group key specified as raw bytes (gRPC only).
	GroupKey []byte `protobuf:"bytes,3,opt,name=group_key,json=groupKey,proto3,oneof"`
}

type AssetSpecifier_GroupKeyStr

type AssetSpecifier_GroupKeyStr struct {
	// The 32-byte asset group key encoded as hex string (use this for
	// REST).
	GroupKeyStr string `protobuf:"bytes,4,opt,name=group_key_str,json=groupKeyStr,proto3,oneof"`
}

type PriceOracleClient

type PriceOracleClient interface {
	// QueryRateTick queries the rate tick for a given transaction type, subject
	// asset, and payment asset. The rate tick is the exchange rate between the
	// subject asset and the payment asset.
	QueryRateTick(ctx context.Context, in *QueryRateTickRequest, opts ...grpc.CallOption) (*QueryRateTickResponse, error)
}

PriceOracleClient is the client API for PriceOracle service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type PriceOracleServer

type PriceOracleServer interface {
	// QueryRateTick queries the rate tick for a given transaction type, subject
	// asset, and payment asset. The rate tick is the exchange rate between the
	// subject asset and the payment asset.
	QueryRateTick(context.Context, *QueryRateTickRequest) (*QueryRateTickResponse, error)
	// contains filtered or unexported methods
}

PriceOracleServer is the server API for PriceOracle service. All implementations must embed UnimplementedPriceOracleServer for forward compatibility

type QueryRateTickErrResponse

type QueryRateTickErrResponse struct {

	// error is the error message.
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	// code is the error code.
	Code uint32 `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	// contains filtered or unexported fields
}

QueryRateTickErrResponse is the error response to a rate tick query.

func (*QueryRateTickErrResponse) Descriptor deprecated

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

Deprecated: Use QueryRateTickErrResponse.ProtoReflect.Descriptor instead.

func (*QueryRateTickErrResponse) GetCode

func (x *QueryRateTickErrResponse) GetCode() uint32

func (*QueryRateTickErrResponse) GetMessage

func (x *QueryRateTickErrResponse) GetMessage() string

func (*QueryRateTickErrResponse) ProtoMessage

func (*QueryRateTickErrResponse) ProtoMessage()

func (*QueryRateTickErrResponse) ProtoReflect

func (x *QueryRateTickErrResponse) ProtoReflect() protoreflect.Message

func (*QueryRateTickErrResponse) Reset

func (x *QueryRateTickErrResponse) Reset()

func (*QueryRateTickErrResponse) String

func (x *QueryRateTickErrResponse) String() string

type QueryRateTickRequest

type QueryRateTickRequest struct {

	// transaction_type indicates whether the transaction is a purchase or a
	// sale.
	TransactionType TransactionType `` /* 143-byte string literal not displayed */
	// subject_asset is the asset to be priced for purchase or sale.
	SubjectAsset *AssetSpecifier `protobuf:"bytes,2,opt,name=subject_asset,json=subjectAsset,proto3" json:"subject_asset,omitempty"`
	// subject_asset_max_amount is the maximum amount of the subject asset that
	// could be involved in the transaction.
	SubjectAssetMaxAmount uint64 `` /* 129-byte string literal not displayed */
	// payment_asset is the asset used for purchasing or receiving from a sale.
	//
	// NOTE: An asset ID of all zeros indicates that the payment asset is BTC.
	// In this case, the rate tick will be given as milli-satoshi per asset
	// unit
	PaymentAsset *AssetSpecifier `protobuf:"bytes,4,opt,name=payment_asset,json=paymentAsset,proto3" json:"payment_asset,omitempty"`
	// rate_tick_hint is an optional suggested rate tick for the transaction,
	// used to provide guidance on expected pricing.
	RateTickHint *RateTick `protobuf:"bytes,5,opt,name=rate_tick_hint,json=rateTickHint,proto3" json:"rate_tick_hint,omitempty"`
	// contains filtered or unexported fields
}

QueryRateTickResponse is the request to a rate tick query.

func (*QueryRateTickRequest) Descriptor deprecated

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

Deprecated: Use QueryRateTickRequest.ProtoReflect.Descriptor instead.

func (*QueryRateTickRequest) GetPaymentAsset

func (x *QueryRateTickRequest) GetPaymentAsset() *AssetSpecifier

func (*QueryRateTickRequest) GetRateTickHint

func (x *QueryRateTickRequest) GetRateTickHint() *RateTick

func (*QueryRateTickRequest) GetSubjectAsset

func (x *QueryRateTickRequest) GetSubjectAsset() *AssetSpecifier

func (*QueryRateTickRequest) GetSubjectAssetMaxAmount

func (x *QueryRateTickRequest) GetSubjectAssetMaxAmount() uint64

func (*QueryRateTickRequest) GetTransactionType

func (x *QueryRateTickRequest) GetTransactionType() TransactionType

func (*QueryRateTickRequest) ProtoMessage

func (*QueryRateTickRequest) ProtoMessage()

func (*QueryRateTickRequest) ProtoReflect

func (x *QueryRateTickRequest) ProtoReflect() protoreflect.Message

func (*QueryRateTickRequest) Reset

func (x *QueryRateTickRequest) Reset()

func (*QueryRateTickRequest) String

func (x *QueryRateTickRequest) String() string

type QueryRateTickResponse

type QueryRateTickResponse struct {

	// Types that are assignable to Result:
	//
	//	*QueryRateTickResponse_Success
	//	*QueryRateTickResponse_Error
	Result isQueryRateTickResponse_Result `protobuf_oneof:"result"`
	// contains filtered or unexported fields
}

QueryRateTickResponse is the response to a rate tick query.

func (*QueryRateTickResponse) Descriptor deprecated

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

Deprecated: Use QueryRateTickResponse.ProtoReflect.Descriptor instead.

func (*QueryRateTickResponse) GetError

func (*QueryRateTickResponse) GetResult

func (m *QueryRateTickResponse) GetResult() isQueryRateTickResponse_Result

func (*QueryRateTickResponse) GetSuccess

func (*QueryRateTickResponse) ProtoMessage

func (*QueryRateTickResponse) ProtoMessage()

func (*QueryRateTickResponse) ProtoReflect

func (x *QueryRateTickResponse) ProtoReflect() protoreflect.Message

func (*QueryRateTickResponse) Reset

func (x *QueryRateTickResponse) Reset()

func (*QueryRateTickResponse) String

func (x *QueryRateTickResponse) String() string

type QueryRateTickResponse_Error

type QueryRateTickResponse_Error struct {
	// error is the error response to the rate tick query.
	Error *QueryRateTickErrResponse `protobuf:"bytes,2,opt,name=error,proto3,oneof"`
}

type QueryRateTickResponse_Success

type QueryRateTickResponse_Success struct {
	// success is the successful response to the rate tick query.
	Success *QueryRateTickSuccessResponse `protobuf:"bytes,1,opt,name=success,proto3,oneof"`
}

type QueryRateTickSuccessResponse

type QueryRateTickSuccessResponse struct {

	// rate_tick is the rate tick for the transaction.
	RateTick *RateTick `protobuf:"bytes,1,opt,name=rate_tick,json=rateTick,proto3" json:"rate_tick,omitempty"`
	// contains filtered or unexported fields
}

QueryRateTickSuccessResponse is the successful response to a rate tick query.

func (*QueryRateTickSuccessResponse) Descriptor deprecated

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

Deprecated: Use QueryRateTickSuccessResponse.ProtoReflect.Descriptor instead.

func (*QueryRateTickSuccessResponse) GetRateTick

func (x *QueryRateTickSuccessResponse) GetRateTick() *RateTick

func (*QueryRateTickSuccessResponse) ProtoMessage

func (*QueryRateTickSuccessResponse) ProtoMessage()

func (*QueryRateTickSuccessResponse) ProtoReflect

func (*QueryRateTickSuccessResponse) Reset

func (x *QueryRateTickSuccessResponse) Reset()

func (*QueryRateTickSuccessResponse) String

type RateTick

type RateTick struct {

	// rate is the exchange rate between the subject asset and the payment
	// asset.
	Rate uint64 `protobuf:"varint,1,opt,name=rate,proto3" json:"rate,omitempty"`
	// expiry_timestamp is the Unix timestamp in seconds after which the rate
	// tick is no longer valid.
	ExpiryTimestamp uint64 `protobuf:"varint,2,opt,name=expiry_timestamp,json=expiryTimestamp,proto3" json:"expiry_timestamp,omitempty"`
	// contains filtered or unexported fields
}

RateTick is the internal unit used for asset conversions. A tick is 1/10000th of a currency unit. It gives us up to 4 decimal places of precision (0.0001 or 0.01% or 1 bps). As an example, if the BTC/USD rate was $61,234.95, then we multiply that by 10,000 to arrive at the usd_rate_tick: $61,234.95 * 10000 = 612,349,500. To convert back to our normal rate, we decide by 10,000 to arrive back at $61,234.95.

NOTE: That if the payment asset is BTC, the rate tick will be given as milli-satoshi per asset unit.

func (*RateTick) Descriptor deprecated

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

Deprecated: Use RateTick.ProtoReflect.Descriptor instead.

func (*RateTick) GetExpiryTimestamp

func (x *RateTick) GetExpiryTimestamp() uint64

func (*RateTick) GetRate

func (x *RateTick) GetRate() uint64

func (*RateTick) ProtoMessage

func (*RateTick) ProtoMessage()

func (*RateTick) ProtoReflect

func (x *RateTick) ProtoReflect() protoreflect.Message

func (*RateTick) Reset

func (x *RateTick) Reset()

func (*RateTick) String

func (x *RateTick) String() string

type TransactionType

type TransactionType int32

TransactionType is an enum representing the type of transaction.

const (
	// PURCHASE indicates a purchase transaction.
	TransactionType_PURCHASE TransactionType = 0
	// SALE indicates a sale transaction.
	TransactionType_SALE TransactionType = 1
)

func (TransactionType) Descriptor

func (TransactionType) Enum

func (x TransactionType) Enum() *TransactionType

func (TransactionType) EnumDescriptor deprecated

func (TransactionType) EnumDescriptor() ([]byte, []int)

Deprecated: Use TransactionType.Descriptor instead.

func (TransactionType) Number

func (TransactionType) String

func (x TransactionType) String() string

func (TransactionType) Type

type UnimplementedPriceOracleServer

type UnimplementedPriceOracleServer struct {
}

UnimplementedPriceOracleServer must be embedded to have forward compatible implementations.

func (UnimplementedPriceOracleServer) QueryRateTick

type UnsafePriceOracleServer

type UnsafePriceOracleServer interface {
	// contains filtered or unexported methods
}

UnsafePriceOracleServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PriceOracleServer will result in compilation errors.

Jump to

Keyboard shortcuts

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