Skip to content

Commit

Permalink
add: verifying Reports in GuardRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Aug 17, 2022
1 parent dbe6922 commit 79e9659
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/contracts/contracts/registry/AbstractGuardRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import { TypedMemView } from "../libs/TypedMemView.sol";
import { Report } from "../libs/Report.sol";
import { Auth } from "../libs/Auth.sol";

abstract contract AbstractGuardRegistry {
using Report for bytes;
using Report for bytes29;
using TypedMemView for bytes29;

function _checkGuardAuth(bytes memory _report)
internal
view
returns (address _guard, bytes29 _data)
returns (address _guard, bytes29 _view)
{
// TODO: check if _report is valid, once guard message standard is finalized
_view = _report.castToReport();
require(_view.isReport(), "Not a report");
_guard = Auth.recoverSigner(_view.reportData(), _view.guardSignature().clone());
require(_isGuard(_guard), "Signer is not a guard");
}

function _isGuard(address _guard) internal view virtual returns (bool);
Expand Down

0 comments on commit 79e9659

Please sign in to comment.