-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* outline of sudo commands * sequencer commands defaults and utils refactor * add fee asset commands * add ibc relayer commands, refactor commands and sub commands * add mint command * add sudo address change command, update existing sudo commands to have fixed args for required inputs * refactor directories * move sudo package * add validator update command * command description updates * file renaming and small logging message updates * small internal sequencer file cleanup * move default sequencer id to cmd package * add get block command * cleanup from main merge * bump dependencies, fix typos
- Loading branch information
1 parent
30efe51
commit ca8036c
Showing
5 changed files
with
268 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package sequencer | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/astria/astria-cli-go/cmd" | ||
"github.com/astria/astria-cli-go/internal/sequencer" | ||
"github.com/astria/astria-cli-go/internal/ui" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// blockCmd represents the block command | ||
var blockCmd = &cobra.Command{ | ||
Use: "block [height]", | ||
Short: "Get sequencer block at specified height.", | ||
Args: cobra.ExactArgs(1), | ||
Run: blockCmdHandler, | ||
} | ||
|
||
func init() { | ||
SequencerCmd.AddCommand(blockCmd) | ||
|
||
flagHandler := cmd.CreateCliFlagHandler(blockCmd, cmd.EnvPrefix) | ||
flagHandler.BindStringPFlag("sequencer-url", "u", DefaultSequencerURL, "The URL of the sequencer to retrieve the block from.") | ||
flagHandler.BindBoolFlag("json", false, "Output the block in JSON format.") | ||
} | ||
|
||
func blockCmdHandler(c *cobra.Command, args []string) { | ||
flagHandler := cmd.CreateCliFlagHandler(c, cmd.EnvPrefix) | ||
url := flagHandler.GetValue("sequencer-url") | ||
printJSON := flagHandler.GetValue("json") == "true" | ||
|
||
h := args[0] | ||
height, err := strconv.ParseInt(h, 10, 64) | ||
if err != nil { | ||
log.WithError(err).Error("Error parsing block height to int64") | ||
panic(err) | ||
} | ||
|
||
opts := sequencer.BlockOpts{ | ||
SequencerURL: url, | ||
BlockHeight: height, | ||
} | ||
block, err := sequencer.GetBlock(opts) | ||
if err != nil { | ||
log.WithError(err) | ||
return | ||
} | ||
|
||
printer := ui.ResultsPrinter{ | ||
Data: block, | ||
PrintJSON: printJSON, | ||
} | ||
printer.Render() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.