Skip to content

Commit

Permalink
fix: query tx events with >= and <= operators (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp authored Jul 14, 2023
1 parent 489c818 commit c30c073
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x/auth/tx/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ var (
_ txtypes.ServiceServer = txServer{}

// EventRegex checks that an event string is formatted with {alphabetic}.{alphabetic}={value}
EventRegex = regexp.MustCompile(`^[a-zA-Z_]+\.[a-zA-Z_]+=\S+$`)
// Note: in addition to equality, the `>=` and `<=` operators are also valid.
EventRegex = regexp.MustCompile(`^[a-zA-Z_]+\.[a-zA-Z_]+[<>]?=\S+$`)
)

const (
Expand Down
10 changes: 10 additions & 0 deletions x/auth/tx/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ func TestEventRegex(t *testing.T) {
event: "tx.signature='foobar/baz123=='",
match: true,
},
{
name: "valid: with >= operator",
event: "tx.height>=10'",
match: true,
},
{
name: "valid: with <= operator",
event: "tx.height<=10'",
match: true,
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit c30c073

Please sign in to comment.