rosetta

package
v0.42.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBlockchain defines the default blockchain identifier name
	DefaultBlockchain = "app"
	// DefaultAddr defines the default rosetta binding address
	DefaultAddr = ":8080"
	// DefaultRetries is the default number of retries
	DefaultRetries = 5
	// DefaultTendermintEndpoint is the default value for the tendermint endpoint
	DefaultTendermintEndpoint = "localhost:26657"
	// DefaultGRPCEndpoint is the default value for the gRPC endpoint
	DefaultGRPCEndpoint = "localhost:9090"
	// DefaultNetwork defines the default network name
	DefaultNetwork = "network"
	// DefaultOffline defines the default offline value
	DefaultOffline = false
)

configuration defaults constants

View Source
const (
	FlagBlockchain         = "blockchain"
	FlagNetwork            = "network"
	FlagTendermintEndpoint = "tendermint"
	FlagGRPCEndpoint       = "grpc"
	FlagAddr               = "addr"
	FlagRetries            = "retries"
	FlagOffline            = "offline"
)

configuration flags

View Source
const (
	StatusSuccess  = "Success"
	StatusReverted = "Reverted"
	StageSynced    = "synced"
	StageSyncing   = "syncing"
)

statuses

View Source
const (
	OptionAccountNumber = "account_number"
	OptionAddress       = "address"
	OptionChainID       = "chain_id"
	OptionSequence      = "sequence"
	OptionMemo          = "memo"
	OptionGas           = "gas"
)

options

View Source
const (
	Log = "log"
)

misc

View Source
const (
	OperationFee = "fee"
)

operations

Variables

This section is empty.

Functions

func MakeCodec

MakeCodec generates the codec required to interact with the cosmos APIs used by the rosetta gateway

func ServerFromConfig

func ServerFromConfig(conf *Config) (crg.Server, error)

func SetFlags

func SetFlags(flags *pflag.FlagSet)

SetFlags sets the configuration flags to the given flagset

func TMBlockToRosettaBlockIdentifier

func TMBlockToRosettaBlockIdentifier(block *tmcoretypes.ResultBlock) *types.BlockIdentifier

TMBlockToRosettaBlockIdentifier converts a tendermint result block to a rosetta block identifier

func TMBlockToRosettaParentBlockIdentifier

func TMBlockToRosettaParentBlockIdentifier(block *tmcoretypes.ResultBlock) *types.BlockIdentifier

TMBlockToRosettaParentBlockIdentifier returns the parent block identifier from the last block

func TMStatusToRosettaSyncStatus

func TMStatusToRosettaSyncStatus(status *tmcoretypes.ResultStatus) *types.SyncStatus

TMStatusToRosettaSyncStatus converts a tendermint status to rosetta sync status

func TMTxsToRosettaTxsIdentifiers

func TMTxsToRosettaTxsIdentifiers(txs []tmtypes.Tx) []*types.TransactionIdentifier

TMTxsToRosettaTxsIdentifiers converts a tendermint raw transactions into an array of rosetta tx identifiers

func TmPeersToRosettaPeers

func TmPeersToRosettaPeers(peers []tmcoretypes.Peer) []*types.Peer

TmPeersToRosettaPeers converts tendermint peers to rosetta ones

func TmTxToRosettaTxsIdentifier

func TmTxToRosettaTxsIdentifier(tx tmtypes.Tx) *types.TransactionIdentifier

TmTxToRosettaTxsIdentifier converts a tendermint raw transaction into a rosetta tx identifier

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements a single network client to interact with cosmos based chains

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient instantiates a new online servicer

func (*Client) AccountIdentifierFromPublicKey

func (c *Client) AccountIdentifierFromPublicKey(pubKey *types.PublicKey) (*types.AccountIdentifier, error)

func (*Client) Balances

func (c *Client) Balances(ctx context.Context, addr string, height *int64) ([]*types.Amount, error)

func (*Client) BlockByHash

func (c *Client) BlockByHash(ctx context.Context, hash string) (crgtypes.BlockResponse, error)

func (*Client) BlockByHeight

func (c *Client) BlockByHeight(ctx context.Context, height *int64) (crgtypes.BlockResponse, error)

func (*Client) BlockTransactionsByHash

func (c *Client) BlockTransactionsByHash(ctx context.Context, hash string) (crgtypes.BlockTransactionsResponse, error)

func (*Client) BlockTransactionsByHeight

func (c *Client) BlockTransactionsByHeight(ctx context.Context, height *int64) (crgtypes.BlockTransactionsResponse, error)

func (*Client) Bootstrap

func (c *Client) Bootstrap() error

func (*Client) ConstructionMetadataFromOptions

func (c *Client) ConstructionMetadataFromOptions(ctx context.Context, options map[string]interface{}) (meta map[string]interface{}, err error)

func (*Client) ConstructionPayload

func (c *Client) ConstructionPayload(_ context.Context, request *types.ConstructionPayloadsRequest) (resp *types.ConstructionPayloadsResponse, err error)

func (*Client) GetTx

func (c *Client) GetTx(_ context.Context, hash string) (*types.Transaction, error)

GetTx returns a transaction given its hash

func (*Client) GetUnconfirmedTx

func (c *Client) GetUnconfirmedTx(ctx context.Context, hash string) (*types.Transaction, error)

GetUnconfirmedTx gets an unconfirmed transaction given its hash

func (*Client) Mempool

func (c *Client) Mempool(ctx context.Context) ([]*types.TransactionIdentifier, error)

Mempool returns the unconfirmed transactions in the mempool

func (*Client) OperationStatuses

func (c *Client) OperationStatuses() []*types.OperationStatus

func (*Client) Peers

func (c *Client) Peers(ctx context.Context) ([]*types.Peer, error)

Peers gets the number of peers

func (*Client) PostTx

func (c *Client) PostTx(txBytes []byte) (*types.TransactionIdentifier, map[string]interface{}, error)

func (*Client) PreprocessOperationsToOptions

func (c *Client) PreprocessOperationsToOptions(_ context.Context, req *types.ConstructionPreprocessRequest) (options map[string]interface{}, err error)

func (*Client) Ready

func (c *Client) Ready() error

func (*Client) SignedTx

func (c *Client) SignedTx(ctx context.Context, txBytes []byte, signatures []*types.Signature) (signedTxBytes []byte, err error)

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*types.SyncStatus, error)

func (*Client) SupportedOperations

func (c *Client) SupportedOperations() []string

func (*Client) TxOperationsAndSignersAccountIdentifiers

func (c *Client) TxOperationsAndSignersAccountIdentifiers(signed bool, txBytes []byte) (ops []*types.Operation, signers []*types.AccountIdentifier, err error)

func (*Client) Version

func (c *Client) Version() string

type Config

type Config struct {
	// Blockchain defines the blockchain name
	// defaults to DefaultBlockchain
	Blockchain string
	// Network defines the network name
	Network string
	// TendermintRPC defines the endpoint to connect to
	// tendermint RPC, specifying 'tcp://' before is not
	// required, usually it's at port 26657 of the
	TendermintRPC string
	// GRPCEndpoint defines the cosmos application gRPC endpoint
	// usually it is located at 9090 port
	GRPCEndpoint string
	// Addr defines the default address to bind the rosetta server to
	// defaults to DefaultAddr
	Addr string
	// Retries defines the maximum number of retries
	// rosetta will do before quitting
	Retries int
	// Offline defines if the server must be run in offline mode
	Offline bool
	// Codec overrides the default data and construction api client codecs
	Codec *codec.ProtoCodec
	// InterfaceRegistry overrides the default data and construction api interface registry
	InterfaceRegistry codectypes.InterfaceRegistry
}

Config defines the configuration of the rosetta server

func FromFlags

func FromFlags(flags *pflag.FlagSet) (*Config, error)

FromFlags gets the configuration from flags

func (*Config) NetworkIdentifier

func (c *Config) NetworkIdentifier() *types.NetworkIdentifier

NetworkIdentifier returns the network identifier given the configuration

func (*Config) WithCodec

func (c *Config) WithCodec(ir codectypes.InterfaceRegistry, cdc *codec.ProtoCodec)

WithCodec extends the configuration with a predefined Codec

type Msg

type Msg interface {
	sdk.Msg
	ToOperations(withStatus, hasError bool) []*types.Operation
	FromOperations(ops []*types.Operation) (sdk.Msg, error)
}

type PayloadReqMetadata

type PayloadReqMetadata struct {
	ChainID       string
	Sequence      uint64
	AccountNumber uint64
	Gas           uint64
	Memo          string
}

Jump to

Keyboard shortcuts

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