2022-08-18 22:28:56 +00:00
|
|
|
import { DNS_RECORD_TYPE, resolverError, } from "@lumeweb/resolver-common";
|
|
|
|
import { resolve } from "@lumeweb/kernel-dns-client";
|
2022-08-18 22:50:54 +00:00
|
|
|
import { RpcNetwork } from "@lumeweb/kernel-rpc-client";
|
2022-08-18 22:28:56 +00:00
|
|
|
export class ResolverRegistry {
|
2022-08-18 22:50:54 +00:00
|
|
|
_rpcNetwork;
|
|
|
|
constructor(network) {
|
|
|
|
this._rpcNetwork = network;
|
|
|
|
}
|
|
|
|
get rpcNetwork() {
|
|
|
|
return this._rpcNetwork;
|
|
|
|
}
|
2022-08-18 22:28:56 +00:00
|
|
|
async resolve(domain, options = { type: DNS_RECORD_TYPE.DEFAULT }, bypassCache = false) {
|
|
|
|
let result;
|
|
|
|
try {
|
|
|
|
result = await resolve(domain, options, bypassCache);
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
return resolverError(e);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
2022-08-18 22:50:54 +00:00
|
|
|
export { RpcNetwork };
|