rpctypes

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package rpctypes provides the serialized types for queries and responses shared by swapd's JSON-RPC server and client-side libraries.

Index

Constants

View Source
const (
	SubscribeMakeOffer  = "net_makeOfferAndSubscribe"
	SubscribeTakeOffer  = "net_takeOfferAndSubscribe"
	SubscribeSwapStatus = "swap_subscribeStatus"
	SubscribeSigner     = "signer_subscribe"
)

JSON RPC method names that we serve on the localhost server

View Source
const DefaultJSONRPCVersion = "2.0"

DefaultJSONRPCVersion ...

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressesResponse

type AddressesResponse struct {
	Addrs []string `json:"addresses" validate:"dive,required"`
}

AddressesResponse ...

type BalancesRequest

type BalancesRequest struct {
	TokenAddrs []ethcommon.Address `json:"tokensAddrs" validate:"dive,required"`
}

BalancesRequest is used to request the combined Monero and Ethereum balances as well as the balances of any tokens included in the request.

type BalancesResponse

type BalancesResponse struct {
	MoneroAddress           *mcrypto.Address          `json:"moneroAddress" validate:"required"`
	PiconeroBalance         *coins.PiconeroAmount     `json:"piconeroBalance" validate:"required"`
	PiconeroUnlockedBalance *coins.PiconeroAmount     `json:"piconeroUnlockedBalance" validate:"required"`
	BlocksToUnlock          uint64                    `json:"blocksToUnlock"`
	EthAddress              ethcommon.Address         `json:"ethAddress" validate:"required"`
	WeiBalance              *coins.WeiAmount          `json:"weiBalance" validate:"required"`
	TokenBalances           []*coins.ERC20TokenAmount `json:"tokenBalances" validate:"dive,required"`
}

BalancesResponse holds the response for the combined Monero, Ethereum and optional token Balances request

type DiscoverRequest

type DiscoverRequest struct {
	Provides   string `json:"provides"`
	SearchTime uint64 `json:"searchTime"` // in seconds
}

DiscoverRequest ...

type DiscoverResponse

type DiscoverResponse struct {
	PeerIDs []peer.ID `json:"peerIDs" validate:"dive,required"`
}

DiscoverResponse ...

type ErrCode

type ErrCode int

ErrCode is a int type used for the rpc error codes

type Error

type Error struct {
	Message   string                 `json:"message"`
	ErrorCode ErrCode                `json:"code"`
	Data      map[string]interface{} `json:"data"`
}

Error is a struct that holds the error message and the error code for a error

func (*Error) Error

func (e *Error) Error() string

Error ...

type MakeOfferRequest

type MakeOfferRequest struct {
	MinAmount    *apd.Decimal        `json:"minAmount" validate:"required"`
	MaxAmount    *apd.Decimal        `json:"maxAmount" validate:"required"`
	ExchangeRate *coins.ExchangeRate `json:"exchangeRate" validate:"required"`
	EthAsset     types.EthAsset      `json:"ethAsset,omitempty"`
	UseRelayer   bool                `json:"useRelayer,omitempty"`
}

MakeOfferRequest ...

type MakeOfferResponse

type MakeOfferResponse struct {
	PeerID  peer.ID    `json:"peerID" validate:"required"`
	OfferID types.Hash `json:"offerID" validate:"required"`
}

MakeOfferResponse ...

type PairsRequest added in v0.4.2

type PairsRequest struct {
	SearchTime uint64 `json:"searchTime"` // in seconds
}

PairsRequest ...

type PairsResponse added in v0.4.2

type PairsResponse struct {
	Pairs []*types.Pair
}

PairsResponse ...

type PeerWithOffers

type PeerWithOffers struct {
	PeerID peer.ID        `json:"peerID" validate:"required"`
	Offers []*types.Offer `json:"offers" validate:"dive,required"`
}

PeerWithOffers ...

type PeersResponse

type PeersResponse struct {
	Addrs []string `json:"addresses" validate:"dive,required"`
}

PeersResponse ...

type QueryAllRequest

type QueryAllRequest = DiscoverRequest

QueryAllRequest ...

type QueryAllResponse

type QueryAllResponse struct {
	PeersWithOffers []*PeerWithOffers `json:"peersWithOffers" validate:"dive,required"`
}

QueryAllResponse ...

type QueryPeerRequest

type QueryPeerRequest struct {
	// Peer ID of peer to query
	PeerID peer.ID `json:"peerID" validate:"required"`
}

QueryPeerRequest ...

type QueryPeerResponse

type QueryPeerResponse struct {
	Offers []*types.Offer `json:"offers" validate:"dive,required"`
}

QueryPeerResponse ...

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params"`
	ID      uint64          `json:"id"`
}

Request represents a JSON-RPC request

type Response

type Response struct {
	Version string           `json:"jsonrpc"`
	Result  json.RawMessage  `json:"result"`
	Error   *Error           `json:"error"`
	ID      *json.RawMessage `json:"id"`
}

Response is the JSON format of a response

type SignerRequest

type SignerRequest struct {
	OfferID    types.Hash        `json:"offerID" validate:"required"`
	EthAddress ethcommon.Address `json:"ethAddress" validate:"required"`
	XMRAddress *mcrypto.Address  `json:"xmrAddress" validate:"required"`
}

SignerRequest initiates the signer_subscribe handler from the front-end

type SignerResponse

type SignerResponse struct {
	OfferID types.Hash        `json:"offerID" validate:"required"`
	To      ethcommon.Address `json:"to" validate:"required"`
	Data    []byte            `json:"data" validate:"required"`
	Value   *apd.Decimal      `json:"value" validate:"required"` // In ETH (or other ETH asset) not WEI
}

SignerResponse sends a tx to be signed to the front-end

type SignerTxSigned

type SignerTxSigned struct {
	OfferID types.Hash     `json:"offerID" validate:"required"`
	TxHash  ethcommon.Hash `json:"txHash" validate:"required"`
}

SignerTxSigned is a response from the front-end saying the given tx has been submitted successfully

type SubscribeSwapStatusRequest

type SubscribeSwapStatusRequest struct {
	OfferID types.Hash `json:"offerID" validate:"required"`
}

SubscribeSwapStatusRequest ...

type SubscribeSwapStatusResponse

type SubscribeSwapStatusResponse struct {
	Status types.Status `json:"status" validate:"required"`
}

SubscribeSwapStatusResponse ...

type TakeOfferRequest

type TakeOfferRequest struct {
	PeerID         peer.ID      `json:"peerID" validate:"required"`
	OfferID        types.Hash   `json:"offerID" validate:"required"`
	ProvidesAmount *apd.Decimal `json:"providesAmount" validate:"required"` // eth asset amount
}

TakeOfferRequest ...

type TokenInfoRequest

type TokenInfoRequest struct {
	TokenAddr ethcommon.Address `json:"tokenAddr" validate:"required"`
}

TokenInfoRequest is used to request lookup of the token's metadata.

type TokenInfoResponse

type TokenInfoResponse = coins.ERC20TokenInfo

TokenInfoResponse contains the metadata for the requested token

Jump to

Keyboard shortcuts

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