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

refactor(zetaclient)!: cli improvements #3122

Merged
merged 14 commits into from
Nov 7, 2024
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* [2984](https://github.com/zeta-chain/node/pull/2984) - add Whitelist message ability to whitelist SPL tokens on Solana
* [3091](https://github.com/zeta-chain/node/pull/3091) - improve build reproducability. `make release{,-build-only}` checksums should now be stable.

### Refactor
* [3122](https://github.com/zeta-chain/node/pull/3122) - improve & refactor zetaclientd cli

### Tests
* [3075](https://github.com/zeta-chain/node/pull/3075) - ton: withdraw concurrent, deposit & revert.

Expand Down
12 changes: 0 additions & 12 deletions cmd/config.go

This file was deleted.

36 changes: 36 additions & 0 deletions cmd/cosmos.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Package cmd provides cosmos constants for ZetaClient.
package cmd

import (
"sync"

cosmos "github.com/cosmos/cosmos-sdk/types"
)

const (
Bech32PrefixAccAddr = "zeta"
Bech32PrefixAccPub = "zetapub"
Bech32PrefixValAddr = "zetav"
Bech32PrefixValPub = "zetavpub"
Bech32PrefixConsAddr = "zetac"
Bech32PrefixConsPub = "zetacpub"
DenomRegex = `[a-zA-Z][a-zA-Z0-9:\\/\\\-\\_\\.]{2,127}`
ZetaChainHDPath string = `m/44'/60'/0'/0/0`
)

var setupConfig sync.Once

// SetupCosmosConfig configures basic Cosmos parameters.
// This function is required because some parts of ZetaClient rely on these constants.
func SetupCosmosConfig() {
setupConfig.Do(setupCosmosConfig)
}

func setupCosmosConfig() {
config := cosmos.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
config.SetFullFundraiserPath(ZetaChainHDPath)
cosmos.SetCoinDenomRegex(func() string { return DenomRegex })
}
swift1337 marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 0 additions & 47 deletions cmd/zetaclientd/encrypt_tss.go

This file was deleted.

40 changes: 0 additions & 40 deletions cmd/zetaclientd/gen_pre_params.go

This file was deleted.

153 changes: 0 additions & 153 deletions cmd/zetaclientd/import_relayer_keys.go

This file was deleted.

39 changes: 13 additions & 26 deletions cmd/zetaclientd/debug.go → cmd/zetaclientd/inbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"fmt"
"os"
"strconv"
"strings"

Expand All @@ -26,36 +25,24 @@ import (
"github.com/zeta-chain/node/zetaclient/zetacore"
)

var debugArgs = debugArguments{}

type debugArguments struct {
zetaCoreHome string
zetaNode string
zetaChainID string
type inboundOptions struct {
Node string
ChainID string
}

func init() {
defaultHomeDir := os.ExpandEnv("$HOME/.zetacored")
var inboundOpts inboundOptions

cmd := DebugCmd()
cmd.Flags().StringVar(&debugArgs.zetaCoreHome, "core-home", defaultHomeDir, "zetacore home directory")
cmd.Flags().StringVar(&debugArgs.zetaNode, "node", "46.4.15.110", "public ip address")
cmd.Flags().StringVar(&debugArgs.zetaChainID, "chain-id", "athens_7001-1", "pre-params file path")
func setupInboundOptions() {
f, cfg := InboundCmd.PersistentFlags(), &inboundOpts

RootCmd.AddCommand(cmd)
f.StringVar(&cfg.Node, "node", "46.4.15.110", "zeta public ip address")
f.StringVar(&cfg.ChainID, "chain-id", "athens_7001-1", "zeta chain id")
}

func DebugCmd() *cobra.Command {
return &cobra.Command{
Use: "get-inbound-ballot [inboundHash] [chainID]",
Short: "provide txHash and chainID to get the ballot status for the txHash",
RunE: debugCmd,
}
}

func debugCmd(_ *cobra.Command, args []string) error {
func InboundGetBallot(_ *cobra.Command, args []string) error {
cobra.ExactArgs(2)
cfg, err := config.Load(debugArgs.zetaCoreHome)

swift1337 marked this conversation as resolved.
Show resolved Hide resolved
cfg, err := config.Load(globalOpts.ZetacoreHome)
if err != nil {
return errors.Wrap(err, "failed to load config")
}
Expand All @@ -70,9 +57,9 @@ func debugCmd(_ *cobra.Command, args []string) error {
// create a new zetacore client
client, err := zetacore.NewClient(
&keys.Keys{OperatorAddress: sdk.MustAccAddressFromBech32(sample.AccAddress())},
debugArgs.zetaNode,
inboundOpts.Node,
"",
debugArgs.zetaChainID,
inboundOpts.ChainID,
zerolog.Nop(),
)
if err != nil {
Expand Down
Loading
Loading