The fulfillRequest
function plays a central role in processing Chainlink Functions responses. It is supposed to handle two separate cases:
If the requestId
is associated with a mint query, it stores the response in funcReqIdToMintFunctionReqResponse
.
If the requestId
is linked to a weather update, it immediately calls _fulfillWeatherUpdate
to update the NFT metadata.
However, the implemented conditional logic systematically prevents the execution of the second case when both types of data are present for the same requestId.
And
This test fails because NftWeatherUpdated
is not emitted, confirming that _fulfillWeatherUpdate()
was never invoked — even though a valid tokenId
existed in s_funcReqIdToTokenIdUpdate
.
Refactor the logic to allow both cases to be executed independently. One safe approach is to split the two conditions instead of using if / else if
:
This way, both actions are executed when appropriate.
Actually this is not correct. The `requestId` for the `s_funcReqIdToUserMintReq` is created in `requestMintWeatherNFT` after sending a request to the Chainlink. The `requestId` for the `s_funcReqIdToTokenIdUpdate` mapping is created in `performUpkeep` function after sending a request to the Chainlink. The Chainlink returns always unique `requestIds`. The `fulfillRequest` accepts as argument one `requestId` and there is no chance that the both conditions in the `fulfillRequest` function will be `true` at the same time, if the `requestId` is from the `s_funcReqIdToUserMintReq` mapping, it can't be from the `s_funcReqIdToTokenIdUpdate` and vice versa.
Actually this is not correct. The `requestId` for the `s_funcReqIdToUserMintReq` is created in `requestMintWeatherNFT` after sending a request to the Chainlink. The `requestId` for the `s_funcReqIdToTokenIdUpdate` mapping is created in `performUpkeep` function after sending a request to the Chainlink. The Chainlink returns always unique `requestIds`. The `fulfillRequest` accepts as argument one `requestId` and there is no chance that the both conditions in the `fulfillRequest` function will be `true` at the same time, if the `requestId` is from the `s_funcReqIdToUserMintReq` mapping, it can't be from the `s_funcReqIdToTokenIdUpdate` and vice versa.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.