@@ -126,6 +126,15 @@ proc parseCmdArg*(T: type EngineApiUrlConfigValue, input: string): T
126126 jwtSecretFile: jwtSecretFile,
127127 roles: roles)
128128
129+ proc fixupWeb3Urls * (web3Url: var string ) =
130+ var normalizedUrl = toLowerAscii (web3Url)
131+ if not (normalizedUrl.startsWith (" https://" ) or
132+ normalizedUrl.startsWith (" http://" ) or
133+ normalizedUrl.startsWith (" wss://" ) or
134+ normalizedUrl.startsWith (" ws://" )):
135+ warn " The Web3 URL does not specify a protocol. Assuming a WebSocket server" , web3Url
136+ web3Url = " ws://" & web3Url
137+
129138proc toFinalUrl * (confValue: EngineApiUrlConfigValue ,
130139 confJwtSecret: Option [seq [byte ]]): Result [EngineApiUrl , cstring ] =
131140 if confValue.jwtSecret.isSome and confValue.jwtSecretFile.isSome:
@@ -138,8 +147,11 @@ proc toFinalUrl*(confValue: EngineApiUrlConfigValue,
138147 else :
139148 confJwtSecret
140149
150+ var url = confValue.url
151+ fixupWeb3Urls (url)
152+
141153 ok EngineApiUrl .init (
142- url = confValue. url,
154+ url = url,
143155 jwtSecret = jwtSecret,
144156 roles = confValue.roles.get (defaultEngineApiRoles))
145157
@@ -163,12 +175,3 @@ proc toFinalEngineApiUrls*(elUrls: seq[EngineApiUrlConfigValue],
163175 fatal " Invalid EL configuration" , err = error
164176 quit 1
165177 result .add engineApiUrl
166-
167- proc fixupWeb3Urls * (web3Url: var string ) =
168- var normalizedUrl = toLowerAscii (web3Url)
169- if not (normalizedUrl.startsWith (" https://" ) or
170- normalizedUrl.startsWith (" http://" ) or
171- normalizedUrl.startsWith (" wss://" ) or
172- normalizedUrl.startsWith (" ws://" )):
173- warn " The Web3 URL does not specify a protocol. Assuming a WebSocket server" , web3Url
174- web3Url = " ws://" & web3Url
0 commit comments