Documentation ¶
Overview ¶
Package allowance provides subcommands to manage the allowance of an user.
USAGE:
dps allowance command [command options] [arguments...]
COMMANDS:
set Set credits allowance. get Get the allowance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = cli.Command{ Name: "allowance", Usage: "Manage allowance.", Subcommands: []*cli.Command{ { Name: "set", Usage: "Set credits allowance.", ArgsUsage: "<amount in credits (use --wei for wei)>", Flags: flags, Action: func(cCtx *cli.Context) error { if cCtx.NArg() < 1 { return errors.New("missing arguments") } if wei { c, ok := new(big.Int).SetString(cCtx.Args().First(), 10) if !ok { return errors.New("couldn't parse amount") } creditsWei = c credits = ether.FromWei(creditsWei) } else { c, ok := new(big.Float).SetString(cCtx.Args().First()) if !ok { return errors.New("couldn't parse amount") } credits = c creditsWei = ether.ToWei(credits) } ctx := cCtx.Context clientset, err := initClient(ctx) if err != nil { return err } if !force { msg := fmt.Sprintf( "Set allowance of %s credits (%s wei) to %s?", credits.String(), creditsWei.String(), metaschedulerSmartContract, ) input := confirmation.New(msg, confirmation.No) ok, err := input.RunPrompt() if err != nil { return err } if !ok { fmt.Println("Cancelled.") return nil } } if err := clientset.AllowanceManager().SetAllowance(ctx, creditsWei); err != nil { return err } fmt.Println("Done.") return nil }, }, { Name: "get", Usage: "Get the allowance.", Flags: flags, Action: func(cCtx *cli.Context) error { ctx := cCtx.Context clientset, err := initClient(ctx) if err != nil { return err } amount, err := clientset.AllowanceManager().GetAllowance(ctx) if err != nil { return err } if wei { fmt.Println(amount.String()) } else { fmt.Println(ether.FromWei(amount).String()) } return nil }, }, }, }
Command is the allowance subcommand used to manage allowance.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.