Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goal abi method outfile checking #3204

Merged
merged 3 commits into from
Nov 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines -183 to -184
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are these and why did they go away?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suppose we want to support foreignAssets/foreignApp/etc., we can pass that in cmd line and I suppose they can also be passed from a file, right?
This was left from previous #3088 about if keeping argument for foreignApp etc., and I think the option should be available and kept

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only things that went away are:

methodAppCmd.Flags().MarkHidden("app-input") // nolint:errcheck
methodAppCmd.Flags().MarkHidden("i")         // nolint:errcheck

They are both flags which specify a JSON input file which can contain foreign references (and app args, but we already handle these properly). Since we want to allow specifying additional foreign references, I think it makes sense to keep this flag unhidden.

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))
}
},
}