Skip to content

Commit

Permalink
Clean getEthConsClientApiUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Sep 4, 2024
1 parent ef5e07b commit 613f974
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions packages/installer/src/ethClient/apiUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,28 @@ export function getEthExecClientApiUrl(dnpName: string, port = 8545): string {
* @param dnpName
*/
export async function getEthConsClientApiUrl(dnpName: string): Promise<string> {
let port = 3500;
let domain = "";
const defaultPort = 3500;
const defaultServiceName = "beacon-chain";

const dnp = await listPackageNoThrow({ dnpName });
if (dnp && typeof dnp.chain === "object" && dnp.chain.portNumber && dnp.chain.serviceName) {
port = dnp.chain.portNumber;
domain = buildNetworkAlias({
dnpName: dnpName,
serviceName: dnp.chain.serviceName,
isMainOrMonoservice: false
});
} else {
domain = buildNetworkAlias({
dnpName: dnpName,
serviceName: "beacon-chain",

if (!dnp || typeof dnp.chain !== "object") {
const domain = buildNetworkAlias({
dnpName,
serviceName: defaultServiceName,
isMainOrMonoservice: false
});

return `http://${domain}:${defaultPort}`;
}
return `http://${domain}:${port}`;

const { chain: { portNumber = defaultPort, serviceName = defaultServiceName } = {} } = dnp;

const domain = buildNetworkAlias({
dnpName,
serviceName,
isMainOrMonoservice: false
});

return `http://${domain}:${portNumber}`;
}

0 comments on commit 613f974

Please sign in to comment.