{"version":3,"file":"rpc-service-requestable.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type {\n  Json,\n  JsonRpcParams,\n  JsonRpcRequest,\n  JsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n  CockatielEventToEventListenerWithData,\n  ExcludeCockatielEventData,\n  ExtendCockatielEventData,\n  ExtractCockatielEventData,\n  FetchOptions,\n} from './shared';\n\n/**\n * The interface for a service class responsible for making a request to a\n * target, whether that is a single RPC endpoint or an RPC endpoint in an RPC\n * service chain.\n *\n * @deprecated Don't use this interface (it will be removed in an upcoming major\n * version). If you need to take an \"RPC-service-like\" argument, it's best to\n * declare which properties you're interested in rather than accepting the\n * entire RPC service interface.\n */\nexport type RpcServiceRequestable = {\n  /**\n   * Listens for when the RPC service retries the request.\n   *\n   * @param listener - The callback to be called when the retry occurs.\n   * @returns What {@link ServicePolicy.onRetry} returns.\n   * @see {@link createServicePolicy}\n   */\n  onRetry(\n    listener: CockatielEventToEventListenerWithData<\n      ServicePolicy['onRetry'],\n      { endpointUrl: string }\n    >,\n  ): ReturnType<ServicePolicy['onRetry']>;\n\n  /**\n   * Listens for when the RPC service retries the request too many times in a\n   * row.\n   *\n   * @param listener - The callback to be called when the circuit is broken.\n   * @returns What {@link ServicePolicy.onBreak} returns.\n   * @see {@link createServicePolicy}\n   */\n  onBreak(\n    listener: (\n      data: ExcludeCockatielEventData<\n        ExtendCockatielEventData<\n          ExtractCockatielEventData<ServicePolicy['onBreak']>,\n          { endpointUrl: string }\n        >,\n        'isolated'\n      >,\n    ) => void,\n  ): ReturnType<ServicePolicy['onBreak']>;\n\n  /**\n   * Listens for when the policy underlying this RPC service detects a slow\n   * request.\n   *\n   * @param listener - The callback to be called when the request is slow.\n   * @returns What {@link ServicePolicy.onDegraded} returns.\n   * @see {@link createServicePolicy}\n   */\n  onDegraded(\n    listener: CockatielEventToEventListenerWithData<\n      ServicePolicy['onDegraded'],\n      { endpointUrl: string; rpcMethodName: string }\n    >,\n  ): ReturnType<ServicePolicy['onDegraded']>;\n\n  /**\n   * Listens for when the policy underlying this RPC service is available.\n   *\n   * @param listener - The callback to be called when the request is available.\n   * @returns What {@link ServicePolicy.onDegraded} returns.\n   * @see {@link createServicePolicy}\n   */\n  onAvailable(\n    listener: CockatielEventToEventListenerWithData<\n      ServicePolicy['onAvailable'],\n      { endpointUrl: string }\n    >,\n  ): ReturnType<ServicePolicy['onAvailable']>;\n\n  /**\n   * Makes a request to the target.\n   */\n  request<Params extends JsonRpcParams, Result extends Json>(\n    jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n    fetchOptions?: FetchOptions,\n  ): Promise<JsonRpcResponse<Result | null>>;\n};\n"]}