gonibi

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: MIT Imports: 30 Imported by: 0

README

gonibi

A Golang client for interacting with the Nibiru blockchain.


Dev Notes

Mini Sprint
  • feat: add in transaction broadcasting
    • initialize keyring obj with mnemonic
    • initialize keyring obj with priv key
    • write a test that sends a bank transfer.
    • write a test that submits a text gov proposal.
  • impl Tendermint RPC client
  • refactor: DRY improvements on the QueryClient initialization
  • ci: Add go tests to CI
  • ci: Add code coverage to CI
  • ci: Add linting to CI
  • docs: for grpc.go
  • docs: for clients.go
  • impl wallet abstraction for the keyring
  • epic: storing transaction history storage
Question Brain-dump
  • Q: Should gonibi run as a binary? -> Yes. What should it be able to do?
  • Q: Which functionality warrants localnet testing?
  • Q: Should there be a way to run queries with JSON-RPC 2 instead of GRPC?

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultNetworkInfo = NetworkInfo{
		GrpcEndpoint:      "localhost:9090",
		LcdEndpoint:       "http://localhost:1317",
		TmRpcEndpoint:     "http://localhost:26657",
		WebsocketEndpoint: "ws://localhost:26657/websocket",
		ChainID:           "nibiru-localnet-0",
	}
)
View Source
var EncodingConfig = app.MakeEncodingConfig()

Functions

func AddSignerToKeyring added in v0.0.4

func AddSignerToKeyring(
	kring keyring.Keyring, privKey cryptotypes.PrivKey, keyName string,
) error

func BroadcastMsgs added in v0.0.4

func BroadcastMsgs(
	args BroadcastArgs,
	from sdk.AccAddress,
	msgs ...sdk.Msg,
) (*sdk.TxResponse, error)

func CreateSigner added in v0.0.4

func CreateSigner(
	mnemonic string,
	kring keyring.Keyring,
	keyName string,
) (kringRecord *keyring.Record, privKey cryptotypes.PrivKey, err error)

func CreateSignerFromPrivKey added in v0.0.4

func CreateSignerFromPrivKey(
	privKey cryptotypes.PrivKey, keyName string,
) (*keyring.Record, error)

func EnsureNibiruPrefix added in v0.0.4

func EnsureNibiruPrefix()

func GetGRPCConnection

func GetGRPCConnection(
	grpcUrl string, grpcInsecure bool, timeoutSeconds int64,
) (*grpc.ClientConn, error)

func NewKeyring added in v0.0.4

func NewKeyring() keyring.Keyring

NewKeyring: Creates an empty, in-memory keyring

func NewRPCClient added in v0.0.4

func NewRPCClient(rpcEndpt string, websocket string) (*cmtrpchttp.HTTP, error)

NewRPCClient: A remote Comet-BFT RPC client. An error is returned on invalid remote. The function panics when remote is nil.

Args:

  • rpcEndpt: endpoint in the form <protocol>://<host>:<port>
  • websocket: websocket path (which always seems to be "/websocket")

func PrivKeyFromMnemonic added in v0.0.4

func PrivKeyFromMnemonic(
	kring keyring.Keyring, mnemonic string, keyName string,
) (cryptotypes.PrivKey, sdk.AccAddress, error)

Types

type AccountNumbers added in v0.0.4

type AccountNumbers struct {
	Number   uint64
	Sequence uint64
}

func GetAccountNumbers added in v0.0.5

func GetAccountNumbers(
	address string,
	grpcConn *grpc.ClientConn,
	encCfg app.EncodingConfig,
) (nums AccountNumbers, err error)

type BroadcastArgs added in v0.0.4

type BroadcastArgs struct {
	Broadcaster Broadcaster
	// contains filtered or unexported fields
}

type Broadcaster added in v0.0.5

type Broadcaster interface {
	BroadcastTxSync(txBytes []byte) (*sdk.TxResponse, error)
}

type BroadcasterGrpc added in v0.0.5

type BroadcasterGrpc struct {
	GRPC *grpc.ClientConn
}

func (BroadcasterGrpc) BroadcastTx added in v0.0.5

func (b BroadcasterGrpc) BroadcastTx(
	txBytes []byte, mode sdktypestx.BroadcastMode,
) (*sdk.TxResponse, error)

func (BroadcasterGrpc) BroadcastTxAsync added in v0.0.5

func (b BroadcasterGrpc) BroadcastTxAsync(
	txBytes []byte,
) (*sdk.TxResponse, error)

func (BroadcasterGrpc) BroadcastTxSync added in v0.0.5

func (b BroadcasterGrpc) BroadcastTxSync(
	txBytes []byte,
) (*sdk.TxResponse, error)

type BroadcasterTmRpc added in v0.0.5

type BroadcasterTmRpc struct {
	RPC cmtrpc.Client
}

func (BroadcasterTmRpc) BroadcastTxSync added in v0.0.5

func (b BroadcasterTmRpc) BroadcastTxSync(
	txBytes []byte,
) (*sdk.TxResponse, error)

type INibiruClient added in v0.0.5

type INibiruClient interface {
	BroadcastMsgs(from csdk.AccAddress, msgs ...csdk.Msg) (*csdk.TxResponse, error)
	ClientCtx(tmCfgRootDir string) sdkclient.Context
	GetAccountNumbers(address string) (nums AccountNumbers, err error)
}

type NetworkInfo

type NetworkInfo struct {
	GrpcEndpoint      string
	LcdEndpoint       string
	TmRpcEndpoint     string
	WebsocketEndpoint string
	ChainID           string
}

type NibiruClient

type NibiruClient struct {
	ChainId          string
	Keyring          keyring.Keyring
	EncCfg           app.EncodingConfig
	Querier          Querier
	CometRPC         cmtrpcclient.Client
	AccountRetriever authtypes.AccountRetriever
	GrpcClient       *grpc.ClientConn
}

func NewNibiruClient

func NewNibiruClient(
	chainId string,
	grpcConn *grpc.ClientConn,
	rpcEndpt string,
) (NibiruClient, error)

func (*NibiruClient) BroadcastMsgs added in v0.0.4

func (nc *NibiruClient) BroadcastMsgs(
	from sdk.AccAddress,
	msgs ...sdk.Msg,
) (*sdk.TxResponse, error)

func (*NibiruClient) BroadcastMsgsGrpc added in v0.0.5

func (nc *NibiruClient) BroadcastMsgsGrpc(
	from sdk.AccAddress,
	msgs ...sdk.Msg,
) (*sdk.TxResponse, error)

func (*NibiruClient) ClientCtx added in v0.0.4

func (nc *NibiruClient) ClientCtx(
	tmCfgRootDir string,
) sdkclient.Context

ClientCtx: Docs for args TODO

  • tmCfgRootDir: /node0/simd
  • Validator.Dir: /node0
  • Validator.ClientCtx.KeyringDir: /node0/simcli

func (*NibiruClient) GetAccountNumbers added in v0.0.4

func (nc *NibiruClient) GetAccountNumbers(
	address string,
) (nums AccountNumbers, err error)

type Querier added in v0.0.5

type Querier struct {
	ClientConn *grpc.ClientConn
	Perp       xperp.QueryClient
	Epoch      xepochs.QueryClient
	Oracle     xoracle.QueryClient
	Wasm       xwasm.QueryClient
}

func NewQueryClient

func NewQueryClient(
	grpcConn *grpc.ClientConn,
) (Querier, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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