Skip to content

Commit

Permalink
refactor(protocol): slightly improve EssentialContract (#18445)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Nov 5, 2024
1 parent 10d99d5 commit 3d077f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ abstract contract EssentialContract is UUPSUpgradeable, Ownable2StepUpgradeable,
_;
}

modifier nonZeroBytes32(bytes32 _value) {
require(_value != 0, ZERO_VALUE());
_;
}

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
Expand Down
14 changes: 7 additions & 7 deletions packages/protocol/contracts/shared/signal/SignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ contract SignalService is EssentialContract, ISignalService {
)
public
view
nonZeroValue(uint256(_chainData))
nonZeroBytes32(_chainData)
returns (bool)
{
bytes32 signal = signalForChainData(_chainId, _kind, _blockId);
Expand Down Expand Up @@ -193,8 +193,8 @@ contract SignalService is EssentialContract, ISignalService {
view
virtual
nonZeroAddr(_app)
nonZeroValue(uint256(_signal))
nonZeroValue(uint256(_value))
nonZeroBytes32(_signal)
nonZeroBytes32(_value)
returns (bytes32)
{
return LibTrieProof.verifyMerkleProof(
Expand Down Expand Up @@ -234,8 +234,8 @@ contract SignalService is EssentialContract, ISignalService {
)
private
nonZeroAddr(_app)
nonZeroValue(uint256(_signal))
nonZeroValue(uint256(_value))
nonZeroBytes32(_signal)
nonZeroBytes32(_value)
returns (bytes32 slot_)
{
slot_ = getSignalSlot(uint64(block.chainid), _app, _signal);
Expand Down Expand Up @@ -276,7 +276,7 @@ contract SignalService is EssentialContract, ISignalService {
private
view
nonZeroAddr(_app)
nonZeroValue(uint256(_signal))
nonZeroBytes32(_signal)
returns (bytes32 value_)
{
bytes32 slot = getSignalSlot(uint64(block.chainid), _app, _signal);
Expand All @@ -295,7 +295,7 @@ contract SignalService is EssentialContract, ISignalService {
private
view
nonZeroAddr(_app)
nonZeroValue(uint256(_signal))
nonZeroBytes32(_signal)
returns (CacheAction[] memory actions)
{
HopProof[] memory hopProofs = abi.decode(_proof, (HopProof[]));
Expand Down

0 comments on commit 3d077f8

Please sign in to comment.