Skip to content

Commit

Permalink
fix: avoid emitting events with empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Dec 18, 2024
1 parent af33b14 commit 956a2af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ contract CallbackModule is Module, ICallbackModule {
// purposely skips the return data, so we don't care if the call succeeds or fails
_params.target.call(abi.encodeCall(IProphetCallback.prophetCallback, (_params.data)));

emit Callback(_response.requestId, _params.target, _params.data);
emit RequestFinalized(_response.requestId, _response, _finalizer);
// response might be empty, but we still want to emit the event with data so we calculate the requestId
bytes32 _requestId = _getId(_request);

emit Callback(_requestId, _params.target, _params.data);
emit RequestFinalized(_requestId, _response, _finalizer);
}

/// @inheritdoc IModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ contract HttpRequestModule is Module, IHttpRequestModule {
) external override(IHttpRequestModule, Module) onlyOracle {
RequestParameters memory _params = decodeRequestData(_request.requestModuleData);

if (ORACLE.responseCreatedAt(_getId(_response)) != 0) {
bool _hasResponse = ORACLE.responseCreatedAt(_getId(_response)) != 0;

bytes32 _requestId = _hasResponse ? _response.requestId : _getId(_request);

if (_hasResponse) {
_params.accountingExtension.pay({
_requestId: _response.requestId,
_requestId: _requestId,
_payer: _request.requester,
_receiver: _response.proposer,
_token: _params.paymentToken,
Expand All @@ -50,13 +54,13 @@ contract HttpRequestModule is Module, IHttpRequestModule {
} else {
_params.accountingExtension.release({
_bonder: _request.requester,
_requestId: _getId(_request),
_requestId: _requestId,
_token: _params.paymentToken,
_amount: _params.paymentAmount
});
}

emit RequestFinalized(_response.requestId, _response, _finalizer);
emit RequestFinalized(_requestId, _response, _finalizer);
}

/// @inheritdoc IModule
Expand Down

0 comments on commit 956a2af

Please sign in to comment.