Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: signing behind interface #20

Merged
merged 18 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Improvements

* [#20](https://github.com/babylonlabs-io/covenant-emulator/pull/20) Add signing behind
interface.
4 changes: 2 additions & 2 deletions cmd/covd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"

covcfg "github.com/babylonlabs-io/covenant-emulator/config"
"github.com/babylonlabs-io/covenant-emulator/covenant"
"github.com/babylonlabs-io/covenant-emulator/keyring"
)

type covenantKey struct {
Expand Down Expand Up @@ -71,7 +71,7 @@ func createKey(ctx *cli.Context) error {
return fmt.Errorf("failed to load the config from %s: %w", covcfg.ConfigFile(homePath), err)
}

keyPair, err := covenant.CreateCovenantKey(
keyPair, err := keyring.CreateCovenantKey(
homePath,
chainID,
keyName,
Expand Down
14 changes: 13 additions & 1 deletion cmd/covd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"

covcfg "github.com/babylonlabs-io/covenant-emulator/config"
"github.com/babylonlabs-io/covenant-emulator/keyring"
"github.com/babylonlabs-io/covenant-emulator/log"
"github.com/babylonlabs-io/covenant-emulator/util"

Expand Down Expand Up @@ -57,7 +58,14 @@ func start(ctx *cli.Context) error {
return fmt.Errorf("failed to create rpc client for the consumer chain: %w", err)
}

ce, err := covenant.NewCovenantEmulator(cfg, bbnClient, ctx.String(passphraseFlag), logger)
pwd := ctx.String(passphraseFlag)

signer, err := NewSignerFromConfig(cfg, pwd)
if err != nil {
return fmt.Errorf("failed to create signer from config: %w", err)
}

ce, err := covenant.NewCovenantEmulator(cfg, bbnClient, pwd, logger, signer)
if err != nil {
return fmt.Errorf("failed to start the covenant emulator: %w", err)
}
Expand All @@ -75,3 +83,7 @@ func start(ctx *cli.Context) error {

return srv.RunUntilShutdown()
}

func NewSignerFromConfig(cfg *covcfg.Config, passphrase string) (*keyring.KeyringSigner, error) {
RafilxTenfen marked this conversation as resolved.
Show resolved Hide resolved
return keyring.NewKeyringSigner(cfg.BabylonConfig.ChainID, cfg.BabylonConfig.Key, cfg.BabylonConfig.KeyDirectory, cfg.BabylonConfig.KeyringBackend, passphrase)
RafilxTenfen marked this conversation as resolved.
Show resolved Hide resolved
}
Loading
Loading