Skip to content
This repository has been archived by the owner on Aug 22, 2022. It is now read-only.

Add request api #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,24 @@ export class IFrameEthereumProvider extends EventEmitter<
return promise;
}

/**
* Request the JSON RPC and return the result.
* @param method method to send to the parent provider
* @param params parameters to send
*/
public async request<TParams = any[], TResult = any>(
method: string,
params?: TParams
): Promise<TResult> {
const response = await this.execute<TParams, TResult, any>(method, params);

if ('error' in response) {
throw new RpcError(response.error.code, response.error.message);
} else {
return response.result;
}
}

/**
* Send the JSON RPC and return the result.
* @param method method to send to the parent provider
Expand Down