cli/wallet: add sysgas option to candidate and claim commands

It doesn't make a lot of sense, but hey, it's a transaction, it can have a bit
more GAS.
This commit is contained in:
Roman Khimov 2022-10-06 22:09:32 +03:00
parent 1ea06e9757
commit 5bafa5f6b4
2 changed files with 10 additions and 4 deletions

View file

@ -22,12 +22,13 @@ func newValidatorCommands() []cli.Command {
{ {
Name: "register", Name: "register",
Usage: "register as a new candidate", Usage: "register as a new candidate",
UsageText: "register -w <path> -r <rpc> -a <addr>", UsageText: "register -w <path> -r <rpc> -a <addr> [-g gas] [-e sysgas]",
Action: handleRegister, Action: handleRegister,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
walletPathFlag, walletPathFlag,
walletConfigFlag, walletConfigFlag,
gasFlag, gasFlag,
sysGasFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to register", Usage: "Address to register",
@ -37,12 +38,13 @@ func newValidatorCommands() []cli.Command {
{ {
Name: "unregister", Name: "unregister",
Usage: "unregister self as a candidate", Usage: "unregister self as a candidate",
UsageText: "unregister -w <path> -r <rpc> -a <addr>", UsageText: "unregister -w <path> -r <rpc> -a <addr> [-g gas] [-e sysgas]",
Action: handleUnregister, Action: handleUnregister,
Flags: append([]cli.Flag{ Flags: append([]cli.Flag{
walletPathFlag, walletPathFlag,
walletConfigFlag, walletConfigFlag,
gasFlag, gasFlag,
sysGasFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to unregister", Usage: "Address to unregister",
@ -52,7 +54,7 @@ func newValidatorCommands() []cli.Command {
{ {
Name: "vote", Name: "vote",
Usage: "vote for a validator", Usage: "vote for a validator",
UsageText: "vote -w <path> -r <rpc> [-s <timeout>] [-g gas] -a <addr> [-c <public key>]", UsageText: "vote -w <path> -r <rpc> [-s <timeout>] [-g gas] [-e sysgas] -a <addr> [-c <public key>]",
Description: `Votes for a validator by calling "vote" method of a NEO native Description: `Votes for a validator by calling "vote" method of a NEO native
contract. Do not provide candidate argument to perform unvoting. contract. Do not provide candidate argument to perform unvoting.
`, `,
@ -61,6 +63,7 @@ func newValidatorCommands() []cli.Command {
walletPathFlag, walletPathFlag,
walletConfigFlag, walletConfigFlag,
gasFlag, gasFlag,
sysGasFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to vote from", Usage: "Address to vote from",
@ -119,12 +122,14 @@ func handleNeoAction(ctx *cli.Context, mkTx func(*neo.Contract, util.Uint160, *w
} }
gas := flags.Fixed8FromContext(ctx, "gas") gas := flags.Fixed8FromContext(ctx, "gas")
sysgas := flags.Fixed8FromContext(ctx, "sysgas")
contract := neo.New(act) contract := neo.New(act)
tx, err := mkTx(contract, addr, acc) tx, err := mkTx(contract, addr, acc)
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
tx.NetworkFee += int64(gas) tx.NetworkFee += int64(gas)
tx.SystemFee += int64(sysgas)
res, _, err := act.SignAndSend(tx) res, _, err := act.SignAndSend(tx)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("failed to sign/send transaction: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to sign/send transaction: %w", err), 1)

View file

@ -92,6 +92,7 @@ func NewCommands() []cli.Command {
walletPathFlag, walletPathFlag,
walletConfigFlag, walletConfigFlag,
gasFlag, gasFlag,
sysGasFlag,
flags.AddressFlag{ flags.AddressFlag{
Name: "address, a", Name: "address, a",
Usage: "Address to claim GAS for", Usage: "Address to claim GAS for",
@ -116,7 +117,7 @@ func NewCommands() []cli.Command {
{ {
Name: "claim", Name: "claim",
Usage: "claim GAS", Usage: "claim GAS",
UsageText: "neo-go wallet claim -w wallet [--wallet-config path] [-g gas] -a address -r endpoint [-s timeout]", UsageText: "neo-go wallet claim -w wallet [--wallet-config path] [-g gas] [-e sysgas] -a address -r endpoint [-s timeout]",
Action: claimGas, Action: claimGas,
Flags: claimFlags, Flags: claimFlags,
}, },