Skip to content

Commit

Permalink
replace legacy sendAsync with request
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitanyapotti authored and gyroflaw committed Oct 16, 2023
1 parent 679fe77 commit 80abff9
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 80abff9

Please sign in to comment.