diff --git a/providers/ethereum-provider/src/EthereumProvider.ts b/providers/ethereum-provider/src/EthereumProvider.ts index 2199d89af..e175ae85c 100644 --- a/providers/ethereum-provider/src/EthereumProvider.ts +++ b/providers/ethereum-provider/src/EthereumProvider.ts @@ -10,6 +10,7 @@ import { } from "./types"; import { Metadata, Namespace, UniversalProvider } from "@walletconnect/universal-provider"; import { SessionTypes, SignClientTypes } from "@walletconnect/types"; +import { JsonRpcResult } from "@walletconnect/jsonrpc-types"; import { STORAGE_KEY, REQUIRED_METHODS, @@ -241,7 +242,7 @@ export class EthereumProvider implements IEthereumProvider { public sendAsync( args: RequestArguments, - callback: (error: Error | null, response: any) => void, + callback: (error: Error | null, response: JsonRpcResult) => void, ): void { this.signer.sendAsync(args, callback, this.formatChainId(this.chainId)); } diff --git a/providers/universal-provider/src/UniversalProvider.ts b/providers/universal-provider/src/UniversalProvider.ts index 51b9fdf14..91b6b6179 100644 --- a/providers/universal-provider/src/UniversalProvider.ts +++ b/providers/universal-provider/src/UniversalProvider.ts @@ -1,5 +1,6 @@ import SignClient, { PROPOSAL_EXPIRY_MESSAGE } from "@walletconnect/sign-client"; import { SessionTypes } from "@walletconnect/types"; +import { JsonRpcResult } from "@walletconnect/jsonrpc-types"; import { getSdkError, isValidArray, parseNamespaceKey } from "@walletconnect/utils"; import { getDefaultLoggerOptions, Logger, pino } from "@walletconnect/logger"; import { @@ -34,6 +35,7 @@ import { import { RELAY_URL, LOGGER, STORAGE, PROVIDER_EVENTS } from "./constants"; import EventEmitter from "events"; +import { formatJsonRpcResult } from "@walletconnect/jsonrpc-utils"; export class UniversalProvider implements IUniversalProvider { public client!: SignClient; @@ -87,12 +89,13 @@ export class UniversalProvider implements IUniversalProvider { public sendAsync( args: RequestArguments, - callback: (error: Error | null, response: any) => void, + callback: (error: Error | null, response: JsonRpcResult) => void, chain?: string | undefined, ): void { + const id = new Date().getTime(); this.request(args, chain) - .then((response) => callback(null, response)) - .catch((error) => callback(error, undefined)); + .then((response) => callback(null, formatJsonRpcResult(id, response))) + .catch((error) => callback(error, undefined as any)); } public async enable(): Promise { diff --git a/providers/universal-provider/src/types/providers.ts b/providers/universal-provider/src/types/providers.ts index 2a2f6336f..569167596 100644 --- a/providers/universal-provider/src/types/providers.ts +++ b/providers/universal-provider/src/types/providers.ts @@ -1,5 +1,6 @@ import SignClient from "@walletconnect/sign-client"; import { SessionTypes } from "@walletconnect/types"; +import { JsonRpcResult } from "@walletconnect/jsonrpc-types"; import { RpcProvidersMap, @@ -34,7 +35,7 @@ export interface IUniversalProvider extends IEthereumProvider { request: (args: RequestArguments, chain?: string) => Promise; sendAsync: ( args: RequestArguments, - callback: (error: Error | null, response: any) => void, + callback: (error: Error | null, response: JsonRpcResult) => void, chain?: string, ) => void; pair: (pairingTopic: string | undefined) => Promise;