cli: add await flag for operations with transactions
New --await flag is an option to synchronize on transaction execution for CLI commands. Closes #3244 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
4f5e3f363a
commit
0ffa24932b
18 changed files with 383 additions and 39 deletions
|
@ -5,6 +5,9 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/cli/options"
|
||||
"github.com/nspcc-dev/neo-go/cli/paramcontext"
|
||||
"github.com/nspcc-dev/neo-go/cli/txctx"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient/waiter"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -37,6 +40,14 @@ func sendTx(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("failed to submit transaction to RPC node: %w", err), 1)
|
||||
}
|
||||
fmt.Fprintln(ctx.App.Writer, res.StringLE())
|
||||
var aer *state.AppExecResult
|
||||
if ctx.Bool("await") {
|
||||
version, err := c.GetVersion()
|
||||
aer, err = waiter.New(c, version).Wait(res, tx.ValidUntilBlock, err)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("failed to await transaction %s: %w", res.StringLE(), err), 1)
|
||||
}
|
||||
}
|
||||
txctx.DumpTransactionInfo(ctx.App.Writer, res, aer)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue