Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Dec 5, 2024
1 parent 2af8a8b commit fafa634
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 1 addition & 3 deletions packages/sdk/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as logger from "@onflow/util-logger"
// Base
export {build} from "./build/build.js"
export {resolve} from "./resolve/resolve.js"
export {send} from "./transport"
export {send, subscribe, rawSubscribe} from "./transport"
export {decode} from "./decode/sdk-decode.js"
export {
encodeTransactionPayload,
Expand Down Expand Up @@ -113,5 +113,3 @@ import * as TestUtils from "./test-utils"
export {TestUtils}

export {VERSION} from "./VERSION"

export {subscribe, rawSubscribe} from "./transport"
14 changes: 5 additions & 9 deletions packages/transport-http/src/subscribe/subscription-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type DeepRequired<T> = Required<{

type InferHandler<T> = T extends SubscriptionHandler<infer H> ? H : never

interface SubscriptionInfo<T extends DataSubscriber<any, any, any>> {
interface SubscriptionInfo {
// Internal ID for the subscription
id: number
// Remote ID assigned by the server used for message routing and unsubscribing
Expand Down Expand Up @@ -63,7 +63,7 @@ export interface SubscriptionManagerConfig {
export class SubscriptionManager<Handlers extends SubscriptionHandler<any>[]> {
private counter = 0
private socket: WebSocket | null = null
private subscriptions: SubscriptionInfo<DataSubscriber<any, any, any>>[] = []
private subscriptions: SubscriptionInfo[] = []
private config: DeepRequired<SubscriptionManagerConfig>
private reconnectAttempts = 0
private handlers: Record<string, SubscriptionHandler<any>>
Expand Down Expand Up @@ -203,7 +203,7 @@ export class SubscriptionManager<Handlers extends SubscriptionHandler<any>[]> {
)

// Track the subscription locally
const sub: SubscriptionInfo<DataSubscriber<any, any, any>> = {
const sub: SubscriptionInfo = {
id: this.counter++,
topic: opts.topic,
subscriber: subscriber,
Expand Down Expand Up @@ -248,9 +248,7 @@ export class SubscriptionManager<Handlers extends SubscriptionHandler<any>[]> {
}
}

private async sendSubscribe(
sub: SubscriptionInfo<DataSubscriber<any, any, any>>
) {
private async sendSubscribe(sub: SubscriptionInfo) {
// Send the subscription message
const request: SubscribeMessageRequest = {
action: Action.SUBSCRIBE,
Expand All @@ -270,9 +268,7 @@ export class SubscriptionManager<Handlers extends SubscriptionHandler<any>[]> {
return response
}

private async sendUnsubscribe(
sub: SubscriptionInfo<DataSubscriber<any, any, any>>
) {
private async sendUnsubscribe(sub: SubscriptionInfo) {
// Send the unsubscribe message if the subscription has a remote id
const {remoteId} = sub
if (remoteId) {
Expand Down

0 comments on commit fafa634

Please sign in to comment.