From 98f5908bb2ed8cb1aea3582b0116fdd884350ef2 Mon Sep 17 00:00:00 2001 From: Rootul Patel Date: Thu, 13 Jul 2023 16:10:36 -0400 Subject: [PATCH] fix: query tx events with >= and <= operators --- x/auth/tx/service.go | 3 ++- x/auth/tx/service_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index 6bc4c95120c0..52c788fd6c75 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -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 ( diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index e61abadd7a48..e80a3891ba74 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -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 {