Skip to content

Commit

Permalink
v1.0.2 - better event decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
karnthis committed Oct 11, 2024
1 parent 38bf4ce commit e1f8df7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/classes/websocketCore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { TPossibleTxEvents } from '@/types'
import { IIbcEngageBundle, IWebsocketCore } from '@/interfaces'

import { Responses } from '@cosmjs/tendermint-rpc/build/tendermint34/adaptor'
import { Responses as T34Responses } from '@cosmjs/tendermint-rpc/build/tendermint34/adaptor'
import { Responses as C38Responses } from '@cosmjs/tendermint-rpc/build/comet38/adaptor'
import { tidyString } from '@/utils/misc'

export class WebsocketCore implements IWebsocketCore {
Expand Down Expand Up @@ -76,7 +77,17 @@ export class WebsocketCore implements IWebsocketCore {
return
}

const ready = Responses.decodeTxEvent(data.result) as T
let ready
try {
ready = T34Responses.decodeTxEvent(data.result) as T
} catch (_) {
try {
ready = C38Responses.decodeTxEvent(data.result) as T
} catch (_) {
throw new Error('Unable to decode event')
}
}

this.wsFeeds[`${marker}|${data.result.query}`].push(ready)
this.wsFeeds[`${marker}|${data.result.query}`] = []
} catch (err) {
Expand Down

0 comments on commit e1f8df7

Please sign in to comment.