From 2e728edfdadd50b0201e7f1640c2c1a59552c38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Tue, 13 Aug 2024 16:54:17 +0200 Subject: [PATCH] fix(wrb): readResponseResult must return unsuccessful result if reponse cbor value is empty --- .../core/customs/WitnetRequestBoardBypassV20.sol | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contracts/impls/core/customs/WitnetRequestBoardBypassV20.sol b/contracts/impls/core/customs/WitnetRequestBoardBypassV20.sol index c6976df6..d336db6a 100644 --- a/contracts/impls/core/customs/WitnetRequestBoardBypassV20.sol +++ b/contracts/impls/core/customs/WitnetRequestBoardBypassV20.sol @@ -653,7 +653,21 @@ contract WitnetRequestBoardBypassV20 legacyFallback(_queryId) returns (Witnet.Result memory) { - return Witnet.resultFromCborBytes(__response(_queryId).cborBytes); + if (__response(_queryId).cborBytes.length > 0) { + return Witnet.resultFromCborBytes(__response(_queryId).cborBytes); + } else { + return Witnet.Result({ + success: false, + value: WitnetCBOR.CBOR({ + buffer: WitnetBuffer.Buffer(hex"", 0), + initialByte: 0, + majorType: 0, + additionalInformation: 0, + len: 0, + tag: 0 + }) + }); + } } /// Retrieves the timestamp in which the result to the referred query was solved by the Witnet DON.