@@ -9,17 +9,19 @@ export type IRealmNameComponent = IBaseComponent & {
99}
1010
1111export async function createRealmNameComponent (
12- components : Pick < BaseComponents , 'fetch' | 'config' | 'provider' >
12+ components : Pick < BaseComponents , 'fetch' | 'config' | 'provider' | 'logs' >
1313) : Promise < IRealmNameComponent > {
14- const { config, fetch, provider } = components
14+ const { config, fetch, provider, logs } = components
1515
16- async function resolveRealmName ( { address } : CatalystServerInfo ) : Promise < string | undefined > {
17- const response = await fetch . fetch ( `${ address } /about` )
18- if ( ! response . ok ) {
19- return undefined
20- }
16+ const logger = logs . getLogger ( 'realm-name' )
2117
18+ async function resolveRealmName ( { address } : CatalystServerInfo ) : Promise < string | undefined > {
2219 try {
20+ const response = await fetch . fetch ( `${ address } /about` )
21+ if ( ! response . ok ) {
22+ return undefined
23+ }
24+
2325 const data : About = await response . json ( )
2426 return data . configurations . realmName
2527 } catch ( err ) {
@@ -42,6 +44,7 @@ export async function createRealmNameComponent(
4244 const servers = await getCatalystServersFromDAO ( network as any , provider )
4345 const names = new Set ( await Promise . all ( servers . map ( resolveRealmName ) ) )
4446
47+ logger . log ( `Realm names found: ${ JSON . stringify ( Array . from ( names ) ) } ` )
4548 if ( ! names . has ( realmName ) ) {
4649 validatedRealmName = realmName
4750 return realmName
0 commit comments