transactions exclude include
@@ -23,6 +23,8 @@ import (
"encoding/json"
"fmt"
+ "github.com/onflow/flow-cli/internal/command"
+
jsoncdc "github.com/onflow/cadence/encoding/json"
"github.com/onflow/flow-go-sdk"
"github.com/spf13/cobra"
@@ -50,6 +52,8 @@ type TransactionResult struct {
result *flow.TransactionResult
tx *flow.Transaction
code bool
+ include []string
+ exclude []string
}
// JSON convert result to JSON
@@ -117,21 +121,35 @@ func (r *TransactionResult) String() string {
_, _ = fmt.Fprintf(writer, "\nNo Envelope Signatures\n")
}
+ // todo add exclude flags
+
for i, e := range r.tx.PayloadSignatures {
+ if command.FieldIncluded(r.include, "signatures") {
_, _ = fmt.Fprintf(writer, "\nPayload Signature %v:\n", i)
_, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address)
_, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature)
_, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex)
+ } else {
+ _, _ = fmt.Fprintf(writer, "\nPayload Signature %v: %s", i, e.Address)
+ }
}
for i, e := range r.tx.EnvelopeSignatures {
+ if command.FieldIncluded(r.include, "signatures") {
_, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v:\n", i)
_, _ = fmt.Fprintf(writer, " Address\t%s\n", e.Address)
_, _ = fmt.Fprintf(writer, " Signature\t%x\n", e.Signature)
_, _ = fmt.Fprintf(writer, " Key Index\t%d\n", e.KeyIndex)
+ } else {
+ _, _ = fmt.Fprintf(writer, "\nEnvelope Signature %v: %s", i, e.Address)
+ }
}
- if r.result != nil {
+ if !command.FieldIncluded(r.include, "signatures") {
+ _, _ = fmt.Fprintf(writer, "\nSignatures (minimized, use --include signatures)")
+ }
+
+ if !command.FieldExcluded(r.exclude, "events") {
e := events.EventResult{
Events: r.result.Events,
}
@@ -145,6 +163,7 @@ func (r *TransactionResult) String() string {
}
if r.tx.Script != nil {
+ if command.FieldIncluded(r.include, "code") {
if len(r.tx.Arguments) == 0 {
_, _ = fmt.Fprintf(writer, "\n\nArguments\tNo arguments\n")
} else {
@@ -155,9 +174,16 @@ func (r *TransactionResult) String() string {
}
_, _ = fmt.Fprintf(writer, "\nCode\n\n%s\n", r.tx.Script)
+ } else {
+ _, _ = fmt.Fprint(writer, "\n\nCode (hidden, use --include code)")
+ }
}
+ if command.FieldIncluded(r.include, "payload") {
_, _ = fmt.Fprintf(writer, "\n\nPayload:\n%x", r.tx.Encode())
+ } else {
+ _, _ = fmt.Fprint(writer, "\n\nPayload (hidden, use --include payload)")
+ }
_ = writer.Flush()
return b.String()
