Skip to content

Commit

Permalink
goal abi method outfile checking (#3204)
Browse files Browse the repository at this point in the history
Check if the outFilename argument is passed and write to the path specified as other commands
  • Loading branch information
barnjamin authored Nov 18, 2021
1 parent 38329e1 commit 83ca8ec
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions cmd/goal/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,10 @@ func init() {

infoAppCmd.MarkFlagRequired("app-id")

methodAppCmd.MarkFlagRequired("method") // nolint:errcheck // follow previous required flag format
methodAppCmd.MarkFlagRequired("app-id") // nolint:errcheck
methodAppCmd.MarkFlagRequired("from") // nolint:errcheck
methodAppCmd.Flags().MarkHidden("app-arg") // nolint:errcheck
methodAppCmd.Flags().MarkHidden("app-input") // nolint:errcheck
methodAppCmd.Flags().MarkHidden("i") // nolint:errcheck
methodAppCmd.MarkFlagRequired("method") // nolint:errcheck // follow previous required flag format
methodAppCmd.MarkFlagRequired("app-id") // nolint:errcheck
methodAppCmd.MarkFlagRequired("from") // nolint:errcheck
methodAppCmd.Flags().MarkHidden("app-arg") // nolint:errcheck
}

type appCallArg struct {
Expand Down Expand Up @@ -1116,6 +1114,20 @@ var methodAppCmd = &cobra.Command{
tx.Fee = basics.MicroAlgos{Raw: fee}
}

if outFilename != "" {
if dumpForDryrun {
err = writeDryrunReqToFile(client, tx, outFilename)
} else {
// Write transaction to file
err = writeTxnToFile(client, sign, dataDir, walletName, tx, outFilename)
}

if err != nil {
reportErrorf(err.Error())
}
return
}

// Broadcast
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
signedTxn, err := client.SignTransactionWithWallet(wh, pw, tx)
Expand Down Expand Up @@ -1180,7 +1192,7 @@ var methodAppCmd = &cobra.Command{
if err != nil {
reportErrorf("cannot marshal returned bytes %v to JSON: %v", decoded, err)
}
fmt.Printf("method %s output: %s", method, string(decodedJSON))
fmt.Printf("method %s output: %s\n", method, string(decodedJSON))
}
},
}

0 comments on commit 83ca8ec

Please sign in to comment.