Skip to content

Commit c9e70ba

Browse files
committed
commit
1 parent a8d9704 commit c9e70ba

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

cmd/ibctl/internal/command/transaction/transactionlist/transactionlist.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const (
4545
excludeTypeFlagName = ibctlcmd.ExcludeTypeFlagName
4646
// excludeGeoFlagName is the shared flag name for excluding geographic classifications from output.
4747
excludeGeoFlagName = ibctlcmd.ExcludeGeoFlagName
48+
// typeFlagName is the flag name for filtering transactions by type.
49+
typeFlagName = "type"
4850
)
4951

5052
// NewCommand returns a new transaction list command.
@@ -144,6 +146,8 @@ type flags struct {
144146
ExcludeTypes []string
145147
// ExcludeGeos excludes these geographic classifications from all computations and output.
146148
ExcludeGeos []string
149+
// Type filters transactions to only this type (e.g., BUY, SELL, DIVIDEND).
150+
Type string
147151
}
148152

149153
func newFlags() *flags {
@@ -161,6 +165,7 @@ func (f *flags) Bind(flagSet *pflag.FlagSet) {
161165
flagSet.StringSliceVar(&f.ExcludeCategories, excludeCategoryFlagName, nil, "Exclude asset category from all computations and output (repeatable, e.g., EQUITY)")
162166
flagSet.StringSliceVar(&f.ExcludeTypes, excludeTypeFlagName, nil, "Exclude asset type from all computations and output (repeatable, e.g., BOND)")
163167
flagSet.StringSliceVar(&f.ExcludeGeos, excludeGeoFlagName, nil, "Exclude geographic classification from all computations and output (repeatable, e.g., US)")
168+
flagSet.StringVar(&f.Type, typeFlagName, "", "Filter transactions by type (e.g., BUY, SELL, DIVIDEND, INTEREST, WHT)")
164169
}
165170

166171
func run(ctx context.Context, container appext.Container, flags *flags) error {
@@ -232,6 +237,17 @@ func run(ctx context.Context, container appext.Container, flags *flags) error {
232237
if err != nil {
233238
return err
234239
}
240+
// Filter by transaction type if --type is set.
241+
if flags.Type != "" {
242+
filterType := strings.ToUpper(flags.Type)
243+
filtered := make([]*ibctltransactions.TransactionOverview, 0, len(result.Transactions))
244+
for _, t := range result.Transactions {
245+
if t.Type == filterType {
246+
filtered = append(filtered, t)
247+
}
248+
}
249+
result.Transactions = filtered
250+
}
235251
// Log any unmatched sells as warnings.
236252
logger := container.Logger()
237253
for _, unmatched := range result.UnmatchedSells {

0 commit comments

Comments
 (0)