mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
cli: display info about imported NEP5 token
This commit is contained in:
parent
053b779be7
commit
97131683d8
1 changed files with 38 additions and 0 deletions
|
@ -53,6 +53,19 @@ func newNEP5Commands() []cli.Command {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "info",
|
||||
Usage: "print imported NEP5 token info",
|
||||
UsageText: "print --path <path> [--token <hash-or-name>]",
|
||||
Action: printNEP5Info,
|
||||
Flags: []cli.Flag{
|
||||
walletPathFlag,
|
||||
cli.StringFlag{
|
||||
Name: "token",
|
||||
Usage: "Token name or hash",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "transfer",
|
||||
Usage: "transfer NEP5 tokens",
|
||||
|
@ -222,6 +235,31 @@ func printTokenInfo(tok *wallet.Token) {
|
|||
fmt.Printf("Address: %s\n", tok.Address)
|
||||
}
|
||||
|
||||
func printNEP5Info(ctx *cli.Context) error {
|
||||
wall, err := openWallet(ctx.String("path"))
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
defer wall.Close()
|
||||
|
||||
if name := ctx.String("token"); name != "" {
|
||||
token, err := getMatchingToken(wall, name)
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
}
|
||||
printTokenInfo(token)
|
||||
return nil
|
||||
}
|
||||
|
||||
for i, t := range wall.Extra.Tokens {
|
||||
if i > 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
printTokenInfo(t)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func transferNEP5(ctx *cli.Context) error {
|
||||
wall, err := openWallet(ctx.String("path"))
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue