common

package
v0.7.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// WithoutPrivateKey is a flag that can be passed to DialClient to indicate
	// that the client does not require the private key for signing. If set in
	// the config, the private key will still be loaded to set the call message
	// sender and to infer owner in database call commands.
	WithoutPrivateKey uint8 = 1 << iota

	// UsingGateway is a flag that can be passed to DialClient to indicate that the client is talking to a gateway.
	// Since very few commands use the gateway, we bind this to specific commands instead of making it a global flag.
	UsingGateway
)

Variables

This section is empty.

Functions

func BindAssumeYesFlag

func BindAssumeYesFlag(cmd *cobra.Command)

BindAssumeYesFlag binds the assume yes flag to the passed command If bound, the command will assume yes for all prompts

func DeleteCookie

func DeleteCookie(authFile string, userIdentifier []byte) error

DeleteCookie will delete a cookie that exists for a given user identifier. If no cookie exists for the user identifier, it will do nothing.

func DialClient

func DialClient(ctx context.Context, cmd *cobra.Command, flags uint8, fn RoundTripper) error

DialClient dials a kwil node and calls the passed function with the client. It includes the command that is being run, so that it can read global flags.

func GetAssumeYesFlag

func GetAssumeYesFlag(cmd *cobra.Command) (bool, error)

GetAssumeYesFlag returns the value of the assume yes flag

func KGWAuthTokenFilePath

func KGWAuthTokenFilePath() string

KGWAuthTokenFilePath returns the path to the file that stores the Gateway Auth cookies.

func LoadPersistedCookie

func LoadPersistedCookie(authFile string, userIdentifier []byte) (*http.Cookie, error)

LoadPersistedCookie loads a persisted cookie from the auth file. It will look up the cookie for the given user identifier. If nothing is found, it returns nil, nil.

func SaveCookie

func SaveCookie(authFile string, userIdentifier []byte, originCookie *http.Cookie) error

SaveCookie saves the cookie to auth file. It will overwrite the cookie if the address already exists.

Types

type PersistedCookies

type PersistedCookies map[string]cookie

PersistedCookies is a set of Gateway Auth cookies that can be saved to a file. It maps a base64 user identifier to a cookie, ensuring only one cookie per wallet. It uses a custom cookie type that is json serializable.

type RoundTripper

type RoundTripper func(ctx context.Context, client clientType.Client, conf *config.KwilCliConfig) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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