Skip to content

Commit

Permalink
tweaks to processing
Browse files Browse the repository at this point in the history
  • Loading branch information
karnthis committed May 10, 2024
1 parent 06e2292 commit 19ef7a6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jackallabs/banshee",
"version": "0.2.0",
"version": "0.3.0-alpha.1",
"description": "Modern problems require modern solutions",
"keywords": [],
"exports": {
Expand Down
14 changes: 9 additions & 5 deletions src/classes/websocketCore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TPossibleTxEvents } from '@/types'
import {
IIbcEngageBundle,
IWebsocketCore,
IIbcEngageBundle, IIbcFeedBundle,
IWebsocketCore
} from '@/interfaces'

import { Responses } from '@cosmjs/tendermint-rpc/build/tendermint34/adaptor'
Expand Down Expand Up @@ -48,7 +48,7 @@ export class WebsocketCore implements IWebsocketCore {
method: 'subscribe',
id: Date.now().toString(),
params: {
query: (conn.query) ? `tm.event = 'Tx' AND '${conn.query}'` : `tm.event = 'Tx'`,
query: (conn.query) ? `tm.event = 'Tx' AND ${conn.query}` : `tm.event = 'Tx'`,
},
}
client.onopen = () => {
Expand All @@ -60,8 +60,12 @@ export class WebsocketCore implements IWebsocketCore {
if (!data.result.data) {
return
}
const postProcess = Responses.decodeTxEvent(data.result)
conn.feed.push(postProcess as T)
const ready = Responses.decodeTxEvent(data.result) as T
const postProcess: IIbcFeedBundle<T> = {
resp: ready,
parsed: conn.parser(ready)
}
conn.feed.push(postProcess)
} catch (err) {
console.error(err)
}
Expand Down
12 changes: 9 additions & 3 deletions src/interfaces/IIbcBundle.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import type { TCurrentTxEvent, TPossibleTxEvents } from '@/types'
import type { TPossibleTxEvents } from '@/types'

/**
* @interface IIbcEngageBundle
* @property {string} chainId
* @property {string} endpoint
* @property {string} [query]
* @property {TCurrentTxEvent<T>[]} feed
* @property {IIbcFeedBundle<T>[]} feed
*/
export interface IIbcEngageBundle<T extends TPossibleTxEvents> {
chainId: string
endpoint: string
parser: (source: T) => any
query?: string
feed: TCurrentTxEvent<T>[]
feed: IIbcFeedBundle<T>[]
}

export interface IIbcFeedBundle<T extends TPossibleTxEvents> {
resp: T,
parsed: any
}

0 comments on commit 19ef7a6

Please sign in to comment.