Revert "*Need to use dynamic import"

This reverts commit 6413d97c61.
This commit is contained in:
Derrick Hammer 2022-12-15 06:23:28 -05:00
parent 485fa98f0e
commit d28868508b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 1 additions and 18 deletions

View File

@ -11,30 +11,13 @@ import {
import { getRpcByPeer } from "../rpc";
import { get as getSwarm, LUMEWEB_TOPIC_HASH } from "../swarm";
import b4a from "b4a";
import type { ClearablePromise } from "p-timeout";
async function dImport(pkg: string): Promise<any> {
return new Function(`return import("${pkg}")`);
}
let pTimeout: typeof import("p-timeout").default;
const pTimeoutImport = dImport(
"p-timeout"
) as unknown as typeof import("p-timeout");
async function importSetup() {
if (!pTimeout) {
pTimeout = (await pTimeoutImport).default;
}
}
import pTimeout, { ClearablePromise } from "p-timeout";
async function broadcastRequest(
request: RPCRequest,
relays: string[],
timeout = 5000
): Promise<Map<string, Promise<any>>> {
await importSetup();
const makeRequest = async (relay: string) => {
const rpc = await getRpcByPeer(relay);
return rpc.request(`${request.module}.${request.method}`, request.data);