Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid emitting events with empty data #91

Open
wants to merge 1 commit into
base: fix/internal-review
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading