Skip to content

Commit

Permalink
Merge branch 'main' into backport/fpd-commit-pubrand
Browse files Browse the repository at this point in the history
  • Loading branch information
bap2pecs committed Nov 22, 2024
2 parents 9bb810d + 3117772 commit 9110414
Show file tree
Hide file tree
Showing 13 changed files with 456 additions and 46 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Improvements

* [149](https://github.com/babylonlabs-io/finality-provider/pull/149) Remove update of config after `fpd keys add`
* [148](https://github.com/babylonlabs-io/finality-provider/pull/148) Allow command `eotsd keys add` to use
empty HD path to derive new key and use master private key.
* [153](https://github.com/babylonlabs-io/finality-provider/pull/153) Add `unsafe-commit-pubrand` command

## v0.12.0
Expand Down
18 changes: 18 additions & 0 deletions eotsmanager/cmd/eotsd/daemon/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package daemon

const (
forceFlag = "force"
rpcListenerFlag = "rpc-listener"
flagInteractive = "interactive"
flagNoBackup = "no-backup"
flagMultisig = "multisig"
flagMultiSigThreshold = "multisig-threshold"
flagPubKeyBase64 = "pubkey-base64"
flagNoSort = "nosort"
flagCoinType = "coin-type"
flagAccount = "account"
flagHDPath = "hd-path"
flagIndex = "index"
flagRecover = "recover"
flagMnemonicSrc = "source"
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package daemon

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package main
package daemon

import (
"bytes"
"fmt"

"sigs.k8s.io/yaml"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/spf13/cobra"

"github.com/babylonlabs-io/finality-provider/eotsmanager"
"github.com/babylonlabs-io/finality-provider/eotsmanager/config"
"github.com/babylonlabs-io/finality-provider/log"
"github.com/babylonlabs-io/finality-provider/util"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
)

type KeyOutput struct {
Expand All @@ -24,20 +23,21 @@ func NewKeysCmd() *cobra.Command {
keysCmd := keys.Commands()

// Find the "add" subcommand
addCmd := findSubCommand(keysCmd, "add")
addCmd := util.GetSubCommand(keysCmd, "add")
if addCmd == nil {
panic("failed to find keys add command")
}

// Wrap the original RunE function
originalRunE := addCmd.RunE
// Override the original RunE function to run almost the same as
// the sdk, but it allows empty hd path and allow to save the key
// in the name mapping
addCmd.RunE = func(cmd *cobra.Command, args []string) error {
// Create a buffer to intercept the key items
var buf bytes.Buffer
cmd.SetOut(&buf)

// Run the original command
err := originalRunE(cmd, args)
err := runAddCmdPrepare(cmd, args)
if err != nil {
return err
}
Expand All @@ -48,15 +48,6 @@ func NewKeysCmd() *cobra.Command {
return keysCmd
}

func findSubCommand(cmd *cobra.Command, name string) *cobra.Command {
for _, subCmd := range cmd.Commands() {
if subCmd.Name() == name {
return subCmd
}
}
return nil
}

func saveKeyNameMapping(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package daemon

import (
"bytes"
Expand Down
Loading

0 comments on commit 9110414

Please sign in to comment.