Skip to content

Commit

Permalink
Merge pull request #373 from torusresearch/master
Browse files Browse the repository at this point in the history
replace legacy sendAsync with request
  • Loading branch information
rob-casper authored Oct 17, 2023
2 parents d05c540 + 6628031 commit 7db9a50
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/services/ProviderTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ export interface JRPCResponse<T> extends JRPCBase {
}

export type SendCallBack<U> = (err: any, providerRes: U) => void;
export type Maybe<T> = T | Partial<T> | null | undefined;

export interface RequestArguments<T> {
method: string;
params?: T;
}

export interface SafeEventEmitterProvider {
sendAsync: <T, U>(req: JRPCRequest<T>) => Promise<U>;
send: <T, U>(req: JRPCRequest<T>, callback: SendCallBack<U>) => void;
send: <T, U>(
req: JRPCRequest<T>,
callback: SendCallBack<JRPCResponse<U>>
) => void;
request: <T, U>(req: RequestArguments<T>) => Promise<Maybe<U>>;
}

class ProviderTransport extends Transport {
Expand All @@ -50,8 +60,8 @@ class ProviderTransport extends Transport {
const notifications = getNotifications(data);
const batch = getBatchRequests(data);
try {
const result = await this.provider.sendAsync(
(data.request as IJSONRPCRequest) as JRPCRequest<any>
const result = await this.provider.request(
(data.request as IJSONRPCRequest) as RequestArguments<any>
);
const jsonrpcResponse = {
id: data.request.id,
Expand Down

0 comments on commit 7db9a50

Please sign in to comment.