@@ -195,7 +195,7 @@ impl TmEvent {
195195 }
196196
197197 pub fn denom ( & self ) -> Result < Denom , IndexerError > {
198- self . get_denom ( "denom" )
198+ self . get_denom_string ( "denom" )
199199 }
200200
201201 pub fn capacity ( & self ) -> Result < Capacity , IndexerError > {
@@ -235,11 +235,11 @@ impl TmEvent {
235235 }
236236
237237 pub fn base_token ( & self ) -> Result < Denom , IndexerError > {
238- self . get_denom ( "base_token" )
238+ self . get_denom_0x_with_string_fallback ( "base_token" )
239239 }
240240
241241 pub fn quote_token ( & self ) -> Result < Denom , IndexerError > {
242- self . get_denom ( "quote_token" )
242+ self . get_denom_0x_with_string_fallback ( "quote_token" )
243243 }
244244
245245 pub fn metadata ( & self ) -> Result < Metadata , IndexerError > {
@@ -309,8 +309,22 @@ impl TmEvent {
309309 Ok ( self . get_bytes ( key, "packet_data" ) ?. into ( ) )
310310 }
311311
312- fn get_denom ( & self , key : & str ) -> Result < Denom , IndexerError > {
313- Ok ( self . get_bytes_utf8 ( key, "denom" ) ?. into ( ) )
312+ // bech32 encoded address
313+ fn get_denom_string ( & self , key : & str ) -> Result < Denom , IndexerError > {
314+ Ok ( self . get_bytes_utf8 ( key, "denom_string" ) ?. into ( ) )
315+ }
316+
317+ // fallback to support test events created when developing token order v2
318+ fn get_denom_0x_with_string_fallback ( & self , key : & str ) -> Result < Denom , IndexerError > {
319+ match self . get_value ( key, "denom_0x_or_string" ) ?. starts_with ( "0x" ) {
320+ true => self . get_denom_0x ( key) ,
321+ false => self . get_denom_string ( key) ,
322+ }
323+ }
324+
325+ // hex representation of address (bech32 for cosmos addresses)
326+ fn get_denom_0x ( & self , key : & str ) -> Result < Denom , IndexerError > {
327+ Ok ( self . get_bytes ( key, "denom_0x" ) ?. into ( ) )
314328 }
315329
316330 fn get_metadata ( & self , key : & str ) -> Result < Metadata , IndexerError > {
0 commit comments