More relaxed parsing of RemoteKeystores to regain compatibility with version 1 (#4967)

This commit is contained in:
zah 2023-05-16 19:06:16 +03:00 committed by GitHub
parent 5aeb5d9209
commit e8572c0246
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 9 deletions

View File

@ -699,14 +699,6 @@ proc readValue*(reader: var JsonReader, value: var RemoteKeystore)
if remoteType.isSome: if remoteType.isSome:
reader.raiseUnexpectedField("Multiple `type` fields found", reader.raiseUnexpectedField("Multiple `type` fields found",
"RemoteKeystore") "RemoteKeystore")
if version.isNone:
reader.raiseUnexpectedField(
"The `type` field should be specified after the `version` field of the keystore",
"RemoteKeystore")
if version.get < 2:
reader.raiseUnexpectedField(
"The `type` field is valid only past version 2 of the remote keystore format",
"RemoteKeystore")
let remoteTypeValue = case reader.readValue(string).toLowerAscii() let remoteTypeValue = case reader.readValue(string).toLowerAscii()
of "web3signer": of "web3signer":
RemoteSignerType.Web3Signer RemoteSignerType.Web3Signer

View File

@ -36,7 +36,7 @@ suite "Remove keystore testing suite":
check keystore.remotes[0].id == 0 check keystore.remotes[0].id == 0
check keystore.remotes[0].pubkey.toHex == "8b9c875fbe539c6429c4fc304675062579ce47fb6b2ac6b6a1ba1188ca123a80affbfe381dbbc8e7f2437709a4c3325c" check keystore.remotes[0].pubkey.toHex == "8b9c875fbe539c6429c4fc304675062579ce47fb6b2ac6b6a1ba1188ca123a80affbfe381dbbc8e7f2437709a4c3325c"
for version in [3]: for version in [1, 3]:
let remoteKeyStores = """{ let remoteKeyStores = """{
"version": """ & $version & """, "version": """ & $version & """,
"type": "web3signer", "type": "web3signer",