mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-14 12:05:18 +00:00
ffd306ef52
* add grpc client * add e2e tests for grpc client * add grpc client readme * doc update * fix more doc issues * remove util namespace & move grpc client to chain * rename GrpcClient to Grpc * add 3rd party query clients * fix invalid url in readme * update e2e tests to use grpc client (#1787)
33 lines
807 B
Go
33 lines
807 B
Go
package util
|
|
|
|
import (
|
|
"context"
|
|
"strconv"
|
|
|
|
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
|
|
"google.golang.org/grpc/metadata"
|
|
|
|
"github.com/kava-labs/kava/app"
|
|
"github.com/kava-labs/kava/app/params"
|
|
query "github.com/kava-labs/kava/client/grpc/query"
|
|
)
|
|
|
|
// Util contains utility functions for the Kava gRPC client
|
|
type Util struct {
|
|
query *query.QueryClient
|
|
encodingConfig params.EncodingConfig
|
|
}
|
|
|
|
// NewUtil creates a new Util instance
|
|
func NewUtil(query *query.QueryClient) *Util {
|
|
return &Util{
|
|
query: query,
|
|
encodingConfig: app.MakeEncodingConfig(),
|
|
}
|
|
}
|
|
|
|
func (u *Util) CtxAtHeight(height int64) context.Context {
|
|
heightStr := strconv.FormatInt(height, 10)
|
|
return metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, heightStr)
|
|
}
|