client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

README

go-client

gRPC client for querying and interacting with wardend.

Cosmos SDK uses protobuffers and already provides an autogenerated client but this package goal is to be slightly more opinionated and ergonomic to be used.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultGasLimit = uint64(300000)
	DefaultFees     = types.NewCoins(types.NewCoin("uward", math.NewInt(1000)))
)

Functions

This section is empty.

Types

type AccountFetcher

type AccountFetcher interface {
	Account(ctx context.Context, addr string) (types.AccountI, error)
}

type AuthQueryClient

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

AuthQueryClient stores a query client for the warden auth module

func NewAuthQueryClient

func NewAuthQueryClient(c *grpc.ClientConn) *AuthQueryClient

NewAuthQueryClient returns a new AuthQueryClient with the supplied GRPC client connection.

func (*AuthQueryClient) Account

func (c *AuthQueryClient) Account(ctx context.Context, addr string) (types.AccountI, error)

Account returns the auth account for the supplied address.

type Identity

type Identity struct {
	Address sdktypes.AccAddress
	PrivKey cryptotypes.PrivKey
}

Identity represents an account on the Warden Protocol. It can be used to sign transactions.

func NewIdentityFromSeed

func NewIdentityFromSeed(derivationPath, seedPhrase string) (Identity, error)

NewIdentityFromSeed returns a Identity from a seed phrase. This is useful in a mock environment or during testing but should not be used in production.

type KeyRequestFulfilment added in v0.1.1

type KeyRequestFulfilment struct {
	RequestID uint64
	PublicKey []byte
}

func (KeyRequestFulfilment) Msg added in v0.1.1

func (r KeyRequestFulfilment) Msg(creator string) sdk.Msg

type KeyRequestRejection added in v0.1.1

type KeyRequestRejection struct {
	RequestID uint64
	Reason    string
}

func (KeyRequestRejection) Msg added in v0.1.1

func (r KeyRequestRejection) Msg(creator string) sdk.Msg

type Msger added in v0.1.1

type Msger interface {
	Msg(creator string) sdk.Msg
}

type PageRequest

type PageRequest = query.PageRequest

type QueryClient

type QueryClient struct {
	*AuthQueryClient
	*WardenQueryClient
	// contains filtered or unexported fields
}

QueryClient holds a query client for the auth and treasury modules.

func NewQueryClient

func NewQueryClient(url string, insecure bool) (*QueryClient, error)

NewQueryClient returns a QueryClient. The supplied url must be a GRPC compatible endpoint for wardend.

func NewQueryClientWithConn

func NewQueryClientWithConn(c *grpc.ClientConn) *QueryClient

NewQueryClientWithConn returns a QueryClient with the supplied GRPC client connection.

func (*QueryClient) Conn

func (c *QueryClient) Conn() *grpc.ClientConn

Conn returns the gRPC client connection.

type RawTxClient

type RawTxClient struct {
	Identity Identity
	// contains filtered or unexported fields
}

RawTxClient is the client used for sending new transactions to the chain.

func NewRawTxClient

func NewRawTxClient(id Identity, chainID string, c *grpc.ClientConn, accountFetcher AccountFetcher) *RawTxClient

func (*RawTxClient) BuildTx

func (c *RawTxClient) BuildTx(ctx context.Context, gasLimit uint64, fees types.Coins, msgers ...Msger) ([]byte, error)

Build a transaction with the given messages and sign it. Sequence and account numbers will be fetched automatically from the chain.

func (*RawTxClient) SendTx

func (c *RawTxClient) SendTx(ctx context.Context, txBytes []byte) (string, error)

SendTx broadcasts a signed transaction and returns its hash. This method does not wait until the transaction is actually added to the, blockchain. Use SendWaitForTx for that.

func (*RawTxClient) SendWaitTx

func (c *RawTxClient) SendWaitTx(ctx context.Context, txBytes []byte) error

Send a transaction and wait for it to be included in a block.

func (*RawTxClient) WaitForTx

func (c *RawTxClient) WaitForTx(ctx context.Context, hash string) error

WaitForTx requests the tx from hash, if not found, waits for some time and tries again. Returns an error if ctx is canceled.

type SignRequestFulfilment added in v0.1.1

type SignRequestFulfilment struct {
	RequestID uint64
	Signature []byte
}

func (SignRequestFulfilment) Msg added in v0.1.1

func (r SignRequestFulfilment) Msg(creator string) sdk.Msg

type SignRequestRejection added in v0.1.1

type SignRequestRejection struct {
	RequestID uint64
	Reason    string
}

func (SignRequestRejection) Msg added in v0.1.1

func (r SignRequestRejection) Msg(creator string) sdk.Msg

type TxClient

type TxClient struct {
	*RawTxClient
}

TxClient can read/write transactions to wardend and endpoints provided by the treasury module.

func NewTxClient

func NewTxClient(id Identity, chainID string, c *grpc.ClientConn, accountFetcher AccountFetcher) *TxClient

NewTxClient returns a TxClient.

type WardenQueryClient

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

WardenQueryClient is the client for the treasury module.

func NewWardenQueryClient

func NewWardenQueryClient(c *grpc.ClientConn) *WardenQueryClient

NewWardenQueryClient returns a WardenQueryClient

func (*WardenQueryClient) GetKeyRequest

func (t *WardenQueryClient) GetKeyRequest(ctx context.Context, requestID uint64) (*types.KeyRequest, error)

GetKeyRequest returns the key request corresponding to the specific request ID.

func (*WardenQueryClient) GetSignatureRequest

func (t *WardenQueryClient) GetSignatureRequest(ctx context.Context, requestID uint64) (*types.SignRequest, error)

GetSignatureRequest returns the signature request corresponding to the specific request ID.

func (*WardenQueryClient) PendingKeyRequests

func (t *WardenQueryClient) PendingKeyRequests(ctx context.Context, page *PageRequest, keychainId uint64) ([]*types.KeyRequest, error)

PendingKeyRequests executes a paginated pending key request query with context. wardend will return a slice of pending key requests for the supplied keychain address.

func (*WardenQueryClient) PendingSignatureRequests

func (t *WardenQueryClient) PendingSignatureRequests(ctx context.Context, page *PageRequest, keychainId uint64) ([]*types.SignRequest, error)

PendingSignatureRequests executes a paginated pending signature request query with context. wardend will return a slice of pending signature requests for the supplied keychain address.

Jump to

Keyboard shortcuts

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