keychain

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: 11 Imported by: 0

Documentation

Overview

Package keychain is an SDK for building Keychain on the Warden Protocol blockchain.

To learn more about the Warden Protocol, visit https://docs.wardenprotocol.com/.

For an example of an application built using this SDK, see the `wardenkms/` folder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(config Config) *App

func (*App) ConnectionState

func (a *App) ConnectionState() connectivity.State

func (*App) SetKeyRequestHandler

func (a *App) SetKeyRequestHandler(handler KeyRequestHandler)

func (*App) SetSignRequestHandler

func (a *App) SetSignRequestHandler(handler SignRequestHandler)

func (*App) Start

func (a *App) Start(ctx context.Context) error

type Batch added in v0.1.1

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

func (*Batch) Append added in v0.1.1

func (b *Batch) Append(item BatchItem) int

func (*Batch) Clear added in v0.1.1

func (b *Batch) Clear() []BatchItem

func (*Batch) Len added in v0.1.1

func (b *Batch) Len() int

type BatchItem added in v0.1.1

type BatchItem struct {
	client.Msger
	Done chan error
}

type Config

type Config struct {
	Logger *slog.Logger

	// ChainID is the chain ID of the chain the keychain is running on.
	ChainID string

	// GRPCURL is the URL of the gRPC server to connect to.
	// e.g. "localhost:9090"
	GRPCURL string

	// GRPCInsecure is whether to use an insecure connection to the gRPC server.
	GRPCInsecure bool

	// KeychainId is the ID of the keychain this instance will fetch requests for.
	KeychainId uint64

	// DerivationPath is the derivation path to use with the Mnemonic to derive this Keychain's party private key.
	DerivationPath string

	// Mnemonic is the mnemonic to use to derive this Keychain's party private key.
	Mnemonic string

	// BatchTimeout is the time to wait before sending a batch of requests to the blockchain.
	// Tipically, the batch timeout should be set to the time it takes to produce a block on the blockchain.
	BatchTimeout time.Duration

	// BatchSize is the maximum number of requests to batch together before sending them to the blockchain.
	BatchSize int

	// GasLimit is the maximum amount of gas to use for each transaction.
	// The more messages in a batch, the more gas is needed.
	GasLimit uint64
}

type KeyRequest

type KeyRequest wardentypes.KeyRequest

type KeyRequestHandler

type KeyRequestHandler func(w KeyResponseWriter, req *KeyRequest)

type KeyResponseWriter

type KeyResponseWriter interface {
	Fulfil(publicKey []byte) error
	Reject(reason string) error
}

type RequestTracker added in v0.1.1

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

func NewRequestTracker added in v0.1.1

func NewRequestTracker() *RequestTracker

func (*RequestTracker) Done added in v0.1.1

func (t *RequestTracker) Done(id uint64)

func (*RequestTracker) Ingested added in v0.1.1

func (t *RequestTracker) Ingested(id uint64)

func (*RequestTracker) IsNew added in v0.1.1

func (t *RequestTracker) IsNew(id uint64) bool

type SignRequest

type SignRequest wardentypes.SignRequest

type SignRequestHandler

type SignRequestHandler func(w SignResponseWriter, req *SignRequest)

type SignResponseWriter

type SignResponseWriter interface {
	Fulfil(signature []byte) error
	Reject(reason string) error
}

type TxWriter added in v0.1.1

type TxWriter struct {
	// Limit is the maximum number of messages to batch together. When the limit is reached, the batch is sent.
	Limit int

	// BatchTimeout is the maximum time to wait before sending a batch of messages.
	BatchTimeout time.Duration

	// Client is the client used to send transactions to the chain.
	Client *client.TxClient

	Logger *slog.Logger

	GasLimit uint64

	Fees sdk.Coins
	// contains filtered or unexported fields
}

func NewTxWriter added in v0.1.1

func NewTxWriter(
	client *client.TxClient,
	batchSize int,
	batchTimeout time.Duration,
	logger *slog.Logger,
) *TxWriter

func (*TxWriter) Flush added in v0.1.1

func (w *TxWriter) Flush(ctx context.Context) error

func (*TxWriter) Start added in v0.1.1

func (w *TxWriter) Start(ctx context.Context, flushErrors chan error) error

func (*TxWriter) Write added in v0.1.1

func (w *TxWriter) Write(ctx context.Context, msg client.Msger) error

Jump to

Keyboard shortcuts

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