UNPKG

@moonwall/cli

Version:

Testing framework for the Moon family of projects

28 lines 1.03 kB
import { vitestAutoUrl } from "../internal/providerFactories"; import { getEnvironmentFromConfig } from "./configReader"; export async function customDevRpcRequest(method, params = []) { const env = getEnvironmentFromConfig(); const endpoint = env.connections ? env.connections[0].endpoints[0].replaceAll("ws://", "http://") : vitestAutoUrl().replaceAll("ws://", "http://").replaceAll("wss://", "https://"); const data = { jsonrpc: "2.0", id: 1, method, params, }; if (endpoint.startsWith("ws")) { console.log("you've passed a websocket to fetch, is this intended?"); } const response = await fetch(endpoint, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }); const responseData = (await response.json()); if (responseData.error) { throw new Error(responseData.error.message); } return responseData.result; } //# sourceMappingURL=rpcFunctions.js.map