forked from TrueCloudLab/neoneo-go
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",
|
Name: "transfer",
|
||||||
Usage: "transfer NEP5 tokens",
|
Usage: "transfer NEP5 tokens",
|
||||||
|
@ -222,6 +235,31 @@ func printTokenInfo(tok *wallet.Token) {
|
||||||
fmt.Printf("Address: %s\n", tok.Address)
|
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 {
|
func transferNEP5(ctx *cli.Context) error {
|
||||||
wall, err := openWallet(ctx.String("path"))
|
wall, err := openWallet(ctx.String("path"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue