diff --git a/src/index.ts b/src/index.ts index 1356c09..a8dfa04 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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( + method: string, + params?: TParams + ): Promise { + const response = await this.execute(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