-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reflect-metadata * rpc-methods wip * rpc-methods wip * wspair -> wscontext * remove @Inject when unnecessary * using autoBindInjectable * defaultScope=singleton + skipBaseClassChecks * config factory logging * zodifying subscription rpc methods * wdatatojson to util * EthSubscribeRpcParamsType * subscriptions/index.ts * outbound subscription factory * todo added * created an eth_unsubscribe method * created 2 util ws functions * introducing context.abort * better logging for the outbound subs factory * outbound subscription * ws-context handles subscription sharing + unsubscribes * docs(changeset): Introducing subscription sharing * removed todo * removed @Inject * linting fix * todo converted * more todos
- Loading branch information
1 parent
9175b64
commit a9a2496
Showing
25 changed files
with
1,218 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@whatsgood/nexus": minor | ||
--- | ||
|
||
Introducing subscription sharing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import { Container } from "inversify"; | ||
|
||
export const container = new Container(); | ||
export const container = new Container({ | ||
autoBindInjectable: true, | ||
skipBaseClassChecks: true, | ||
defaultScope: "Singleton", | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { z } from "zod"; | ||
import { | ||
RpcRequestPayloadSchema, | ||
RpcResponseSuccessPayloadSchema, | ||
} from "@src/rpc-schema"; | ||
|
||
export const eth_subscribe_newHeads = RpcRequestPayloadSchema.extend({ | ||
method: z.literal("eth_subscribe"), | ||
params: z.tuple([ | ||
z.literal("newHeads"), | ||
// TODO: can this method have more params? | ||
]), | ||
}); | ||
|
||
export const eth_subscribe_newPendingTransactions = | ||
RpcRequestPayloadSchema.extend({ | ||
method: z.literal("eth_subscribe"), | ||
params: z.tuple([ | ||
z.literal("newPendingTransactions"), | ||
// TODO: can this method have more params? | ||
]), | ||
}); | ||
|
||
export const eth_subscribe = z.union([ | ||
eth_subscribe_newHeads, | ||
eth_subscribe_newPendingTransactions, | ||
]); | ||
|
||
export type EthSubscribeRpcPayloadType = z.infer<typeof eth_subscribe>; | ||
export type EthSubscribeRpcParamsType = EthSubscribeRpcPayloadType["params"]; | ||
|
||
export const eth_unsubscribe = RpcRequestPayloadSchema.extend({ | ||
method: z.literal("eth_unsubscribe"), | ||
params: z.tuple([z.string()]), | ||
}); | ||
|
||
export const eth_subscribeSuccessResponsePayloadSchema = | ||
RpcResponseSuccessPayloadSchema.extend({ | ||
result: z.string(), | ||
}); | ||
|
||
export type EthSubscribeSuccessResponsePayloadType = z.infer< | ||
typeof eth_subscribeSuccessResponsePayloadSchema | ||
>; | ||
|
||
export const eth_subscriptionPayloadSchema = z.object({ | ||
jsonrpc: z.literal("2.0"), | ||
method: z.literal("eth_subscription"), | ||
params: z.object({ | ||
subscription: z.string(), | ||
result: z.unknown(), // TODO: do better narrowing here | ||
}), | ||
}); | ||
|
||
export type EthSubscriptionPayloadType = z.infer< | ||
typeof eth_subscriptionPayloadSchema | ||
>; |
Oops, something went wrong.