Skip to content

Commit

Permalink
updating the js doc comments based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NiranjanaBinoy committed Mar 25, 2024
1 parent 0012b54 commit bd7d215
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type getProviderStateImplementationType<
* The background sends RPC notifications on state changes, but the provider
* first requests state on initialization.
*/

const getProviderState: getProviderStateImplementationType = {
methodNames: [MESSAGE_TYPE.GET_PROVIDER_STATE],
implementation: getProviderStateHandler,
Expand All @@ -44,24 +43,18 @@ const getProviderState: getProviderStateImplementationType = {
export default getProviderState;

/**
* @typedef {object} ProviderStateHandlerOptions
* @property {() => ProviderStateHandlerResult} getProviderState - A function that
* gets the current provider state.
*/

/**
* @param _req - The JSON-RPC request object.
* @param req - The JSON-RPC request object.
* @param res - The JSON-RPC response object.
* @param _next - The json-rpc-engine 'next' callback.
* @param end - The json-rpc-engine 'end' callback.
* @param options
* @param options.getProviderState
* @param options.getProviderState - An async function that gets the current provider state.
*/
async function getProviderStateHandler<
Params extends JsonRpcParams = JsonRpcParams,
Result extends Json = Json,
>(
_req: JsonRpcRequest<Params>,
req: JsonRpcRequest<Params>,
res: JsonRpcResponse<Result>,
_next: JsonRpcEngineNextCallback,
end: JsonRpcEngineEndCallback,
Expand All @@ -70,7 +63,7 @@ async function getProviderStateHandler<
}: Record<string, (origin: string) => Promise<ProviderStateHandlerResult>>,
): Promise<void> {
res.result = {
...(await _getProviderState((origin = _req.origin))),
...(await _getProviderState((origin = req.origin))),
};
return end();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ export type HandlerWrapperType = {
};

/**
* @typedef {object} ProviderStateHandlerResult
* @property {string} chainId - The current chain ID.
* @property {boolean} isUnlocked - Whether the extension is unlocked or not.
* @property {string} networkVersion - The current network ID.
* @property {string[]} accounts - List of permitted accounts for the specified origin.
* @property chainId - The current chain ID.
* @property isUnlocked - Whether the extension is unlocked or not.
* @property networkVersion - The current network ID.
* @property accounts - List of permitted accounts for the specified origin.
*/
export type ProviderStateHandlerResult = {
chainId: string;
Expand Down

0 comments on commit bd7d215

Please sign in to comment.