cli/smartcontract: allow deploying contracts from multisig accounts

By providing `--out` flag.
This commit is contained in:
Roman Khimov 2021-04-07 11:50:24 +03:00
parent 99ca0b2578
commit 26eff7110c

View file

@ -113,6 +113,7 @@ func NewCommands() []cli.Command {
}, },
walletFlag, walletFlag,
addressFlag, addressFlag,
outFlag,
gasFlag, gasFlag,
} }
deployFlags = append(deployFlags, options.RPC...) deployFlags = append(deployFlags, options.RPC...)
@ -865,9 +866,21 @@ func contractDeploy(ctx *cli.Context) error {
return cli.NewExitError(fmt.Errorf("failed to test-invoke deployment script: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to test-invoke deployment script: %w", err), 1)
} }
txHash, err := c.SignAndPushInvocationTx(txScript, acc, invRes.GasConsumed, gas, nil) var txHash util.Uint256
if err != nil { if out := ctx.String("out"); out != "" {
return cli.NewExitError(fmt.Errorf("failed to push invocation tx: %w", err), 1) tx, err := c.CreateTxFromScript(txScript, acc, invRes.GasConsumed, int64(gas), nil)
if err != nil {
return cli.NewExitError(fmt.Errorf("failed to create tx: %w", err), 1)
}
if err := paramcontext.InitAndSave(c.GetNetwork(), tx, acc, out); err != nil {
return cli.NewExitError(err, 1)
}
txHash = tx.Hash()
} else {
txHash, err = c.SignAndPushInvocationTx(txScript, acc, invRes.GasConsumed, gas, nil)
if err != nil {
return cli.NewExitError(fmt.Errorf("failed to push invocation tx: %w", err), 1)
}
} }
hash := state.CreateContractHash(sender, nefFile.Checksum, m.Name) hash := state.CreateContractHash(sender, nefFile.Checksum, m.Name)
fmt.Fprintf(ctx.App.Writer, "Contract: %s\n", hash.StringLE()) fmt.Fprintf(ctx.App.Writer, "Contract: %s\n", hash.StringLE())