2024-09-21 21:42:51 -04:00
|
|
|
package cli
|
2024-09-14 12:47:25 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
|
|
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
2024-09-25 19:45:28 -04:00
|
|
|
"github.com/onsonr/sonr/app/cli/dexmodel"
|
|
|
|
"github.com/onsonr/sonr/app/cli/txmodel"
|
2024-09-14 12:47:25 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2024-09-25 19:45:28 -04:00
|
|
|
func NewBuildTxnTUICmd() *cobra.Command {
|
2024-09-14 12:47:25 -04:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "dash",
|
|
|
|
Short: "TUI for managing the local Sonr validator node",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
txBody, err := txmodel.RunBuildTxnTUI()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
|
|
|
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
|
|
|
jsonBytes, err := marshaler.MarshalJSON(txBody)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("failed to marshal tx body: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Generated Protobuf Message (JSON format):")
|
|
|
|
fmt.Println(string(jsonBytes))
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-25 19:45:28 -04:00
|
|
|
func NewExplorerTUICmd() *cobra.Command {
|
2024-09-14 12:47:25 -04:00
|
|
|
return &cobra.Command{
|
|
|
|
Use: "cosmos-explorer",
|
|
|
|
Short: "A terminal-based Cosmos blockchain explorer",
|
|
|
|
RunE: dexmodel.RunExplorerTUI,
|
|
|
|
}
|
|
|
|
}
|