Esempio n. 1
0
func cliPermissions(c *cli.Context) {
	chainID, nodeAddr, signAddr := c.String("chainID"), c.String("node-addr"), c.String("sign-addr")
	sign, broadcast, wait := c.Bool("sign"), c.Bool("broadcast"), c.Bool("wait")
	pubkey, nonceS, addr := c.String("pubkey"), c.String("nonce"), c.String("addr")

	// all functions take at least 2 args (+ name)
	if len(c.Args()) < 3 {
		common.Exit(fmt.Errorf("Please enter the permission function you'd like to call, followed by it's arguments"))
	}
	permFunc := c.Args()[0]
	tx, err := core.Permissions(nodeAddr, pubkey, addr, nonceS, permFunc, c.Args()[1:])
	common.IfExit(err)
	logger.Debugf("%v\n", tx)
	unpackSignAndBroadcast(core.SignAndBroadcast(chainID, nodeAddr, signAddr, tx, sign, broadcast, wait))
}
Esempio n. 2
0
func cliName(cmd *cobra.Command, args []string) {
	if dataFlag != "" && dataFileFlag != "" {
		common.Exit(fmt.Errorf("Please specify only one of --data and --data-file"))
	}
	data := dataFlag
	if dataFlag == "" && dataFileFlag != "" {
		b, err := ioutil.ReadFile(dataFileFlag)
		common.IfExit(err)
		data = string(b)
	}
	tx, err := core.Name(nodeAddrFlag, signAddrFlag, pubkeyFlag, addrFlag, amtFlag, nonceFlag, feeFlag, nameFlag, data)
	common.IfExit(err)
	logger.Debugf("%v\n", tx)
	unpackSignAndBroadcast(core.SignAndBroadcast(chainidFlag, nodeAddrFlag, signAddrFlag, tx, signFlag, broadcastFlag, waitFlag))
}
Esempio n. 3
0
func cliPermissions(cmd *cobra.Command, args []string) {
	// all functions take at least 2 args (+ name)
	if len(args) < 3 {
		s := fmt.Sprintf("Please enter the permission function you'd like to call, followed by it's arguments.")
		s = fmt.Sprintf("%s\nOptions:", s)
		for _, p := range core.PermsFuncs {
			s = fmt.Sprintf("%s\n\t%s(%s)", s, p.Name, p.Args)
		}
		s += "\n"
		s += "eg. mintx permission set_base 098E260AD99FFAE17A02E0F3692C7A493B122274 create_account true\n"

		common.Exit(fmt.Errorf(s))
	}
	permFunc := args[0]
	tx, err := core.Permissions(nodeAddrFlag, signAddrFlag, pubkeyFlag, addrFlag, nonceFlag, permFunc, args[1:])
	common.IfExit(err)
	logger.Debugf("%v\n", tx)
	unpackSignAndBroadcast(core.SignAndBroadcast(chainidFlag, nodeAddrFlag, signAddrFlag, tx, signFlag, broadcastFlag, waitFlag))
}
Esempio n. 4
0
func cliName(c *cli.Context) {
	chainID, nodeAddr, signAddr := c.String("chainID"), c.String("node-addr"), c.String("sign-addr")
	sign, broadcast, wait := c.Bool("sign"), c.Bool("broadcast"), c.Bool("wait")
	pubkey, amtS, nonceS, feeS, addr := c.String("pubkey"), c.String("amt"), c.String("nonce"), c.String("fee"), c.String("addr")

	if c.IsSet("data") && c.IsSet("data-file") {
		common.Exit(fmt.Errorf("Please specify only one of --data and --data-file"))
	}
	name, data, dataFile := c.String("name"), c.String("data"), c.String("data-file")
	if data == "" && dataFile != "" {
		b, err := ioutil.ReadFile(dataFile)
		common.IfExit(err)
		data = string(b)
	}
	tx, err := core.Name(nodeAddr, pubkey, addr, amtS, nonceS, feeS, name, data)
	common.IfExit(err)
	logger.Debugf("%v\n", tx)
	unpackSignAndBroadcast(core.SignAndBroadcast(chainID, nodeAddr, signAddr, tx, sign, broadcast, wait))
}