forked from fbsobreira/gotron-sdk
/
utility.go
55 lines (50 loc) · 1.19 KB
/
utility.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package cmd
import (
"fmt"
"github.com/SergeevDmitry/gotron-sdk/pkg/address"
"github.com/spf13/cobra"
)
func init() {
cmdUtilities := &cobra.Command{
Use: "utility",
Short: "common tron utilities",
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Help()
return nil
},
}
cmdUtilities.AddCommand([]*cobra.Command{{
Use: "metadata",
Short: "data includes network specific values",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}, {
Use: "metrics",
Short: "mostly in-memory fluctuating values",
RunE: func(cmd *cobra.Command, args []string) error {
return nil
},
}, {
Use: "base58-to-addr",
Args: cobra.ExactArgs(1),
Short: "0x Address of a base58 one-address",
RunE: func(cmd *cobra.Command, args []string) error {
addr, err := address.Base58ToAddress(args[0])
if err != nil {
return err
}
fmt.Println(addr.Hex())
return nil
},
}, {
Use: "addr-to-base58",
Args: cobra.ExactArgs(1),
Short: "base58 tron-address of an 0x address",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println(address.HexToAddress(args[0]))
return nil
},
}}...)
RootCmd.AddCommand(cmdUtilities)
}