github.com/iotexproject/iotex-core@v1.14.1-rc1/ioctl/cmd/ins/ins.go (about) 1 package ins 2 3 import ( 4 "encoding/hex" 5 6 "github.com/spf13/cobra" 7 "golang.org/x/crypto/sha3" 8 9 "github.com/iotexproject/iotex-core/ioctl/config" 10 ) 11 12 // IONode hash for io 13 var IONode, _ = hex.DecodeString("b2b692c69df4aa3b0a24634d20a3ba1b44c3299d09d6c4377577e20b09e68395") 14 15 // Multi-language support 16 var ( 17 _insCmdShorts = map[config.Language]string{ 18 config.English: "Manage INS of IoTeX blockchain", 19 config.Chinese: "管理IoTeX区块链上INS", 20 } 21 _flagInsEndPointUsages = map[config.Language]string{ 22 config.English: "set endpoint for once", 23 config.Chinese: "一次设置端点", // this translation 24 } 25 _flagInsInsecureUsages = map[config.Language]string{ 26 config.English: "insecure connection for once", 27 config.Chinese: "一次不安全连接", // this translation 28 } 29 ) 30 31 // InsCmd represents the ins command 32 var InsCmd = &cobra.Command{ 33 Use: "ins", 34 Short: config.TranslateInLang(_insCmdShorts, config.UILanguage), 35 } 36 37 func init() { 38 InsCmd.AddCommand(_insRegisterCmd) 39 InsCmd.PersistentFlags().StringVar(&config.ReadConfig.Endpoint, "endpoint", 40 config.ReadConfig.Endpoint, config.TranslateInLang(_flagInsEndPointUsages, 41 config.UILanguage)) 42 InsCmd.PersistentFlags().BoolVar(&config.Insecure, "insecure", config.Insecure, 43 config.TranslateInLang(_flagInsInsecureUsages, config.UILanguage)) 44 } 45 46 func nameHash(name string) (hash [32]byte, err error) { 47 sha := sha3.NewLegacyKeccak256() 48 if _, err = sha.Write(IONode); err != nil { 49 return 50 } 51 nameSha := sha3.NewLegacyKeccak256() 52 if _, err = nameSha.Write([]byte(name)); err != nil { 53 return 54 } 55 nameHash := nameSha.Sum(nil) 56 if _, err = sha.Write(nameHash); err != nil { 57 return 58 } 59 sha.Sum(hash[:0]) 60 return 61 }