Skip to content

Commit

Permalink
feat: Support yDaemon url without chain
Browse files Browse the repository at this point in the history
  • Loading branch information
karelianpie committed Sep 24, 2023
1 parent 9477b09 commit fa0faf5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions apps/common/utils/getYDaemonBaseURI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@ type TProps = {
chainID: number | string;
};

export function useYDaemonBaseURI({chainID}: TProps): {
export function useYDaemonBaseURI(props?: TProps): {
yDaemonBaseUri: string;
} {
// eslint-disable-next-line @typescript-eslint/naming-convention
const {settings} = useSettings();

const baseUri = settings.yDaemonBaseURI || process.env.YDAEMON_BASE_URI;
const yDaemonBaseUri =
settings.yDaemonBaseURI || process.env.YDAEMON_BASE_URI;

if (!baseUri) {
if (!yDaemonBaseUri) {
throw new Error('YDAEMON_BASE_URI is not defined');
}

return {yDaemonBaseUri: `${baseUri}/${chainID}`};
if (!props?.chainID) {
return {yDaemonBaseUri};
}

return {yDaemonBaseUri: `${yDaemonBaseUri}/${props.chainID}`};
}

0 comments on commit fa0faf5

Please sign in to comment.