forked from TrueCloudLab/neoneo-go
cli: refactor handleCandidate method
Reuse existing RPC client method for transaction sending.
This commit is contained in:
parent
14c2d7d25a
commit
e43ab642d1
1 changed files with 3 additions and 11 deletions
|
@ -112,23 +112,15 @@ func handleCandidate(ctx *cli.Context, method string, sysGas int64) error {
|
||||||
w := io.NewBufBinWriter()
|
w := io.NewBufBinWriter()
|
||||||
emit.AppCall(w.BinWriter, neoContractHash, method, callflag.States, acc.PrivateKey().PublicKey().Bytes())
|
emit.AppCall(w.BinWriter, neoContractHash, method, callflag.States, acc.PrivateKey().PublicKey().Bytes())
|
||||||
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
emit.Opcodes(w.BinWriter, opcode.ASSERT)
|
||||||
tx, err := c.CreateTxFromScript(w.Bytes(), acc, sysGas, int64(gas), []client.SignerAccount{{
|
res, err := c.SignAndPushInvocationTx(w.Bytes(), acc, sysGas, gas, []client.SignerAccount{{
|
||||||
Signer: transaction.Signer{
|
Signer: transaction.Signer{
|
||||||
Account: acc.Contract.ScriptHash(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
},
|
},
|
||||||
Account: acc,
|
Account: acc,
|
||||||
},
|
}})
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.NewExitError(err, 1)
|
return cli.NewExitError(fmt.Errorf("failed to push transaction: %w", err), 1)
|
||||||
} else if err = acc.SignTx(c.GetNetwork(), tx); err != nil {
|
|
||||||
return cli.NewExitError(fmt.Errorf("can't sign tx: %v", err), 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
res, err := c.SendRawTransaction(tx)
|
|
||||||
if err != nil {
|
|
||||||
return cli.NewExitError(err, 1)
|
|
||||||
}
|
}
|
||||||
fmt.Fprintln(ctx.App.Writer, res.StringLE())
|
fmt.Fprintln(ctx.App.Writer, res.StringLE())
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue