Skip to content
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
7 changes: 5 additions & 2 deletions src/policies/CallerPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import {
* If you need to validate who signed, use a signer module instead.
*/
contract CallerPolicy is PolicyBase, IStatelessValidatorWithSender {
error EmptyCallers();
error ZeroAddressCaller();

mapping(bytes32 id => mapping(address => Status)) public status;
/// @notice Maps policy ID => requesting protocol => wallet => whether protocol is allowed
mapping(bytes32 id => mapping(address caller => mapping(address wallet => bool))) public allowedCaller;
Expand Down Expand Up @@ -84,9 +87,9 @@ contract CallerPolicy is PolicyBase, IStatelessValidatorWithSender {
function _policyOninstall(bytes32 id, bytes calldata _data) internal override {
require(status[id][msg.sender] == Status.NA, "Already installed");
address[] memory callers = abi.decode(_data, (address[]));
require(callers.length > 0, "Empty callers array");
require(callers.length > 0, EmptyCallers());
for (uint256 i = 0; i < callers.length; i++) {
require(callers[i] != address(0), "Zero address caller");
require(callers[i] != address(0), ZeroAddressCaller());
allowedCaller[id][callers[i]][msg.sender] = true;
}
status[id][msg.sender] = Status.Live;
Expand Down
4 changes: 2 additions & 2 deletions src/signers/ECDSASigner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ contract ECDSASigner is SignerBase, IStatelessValidator, IStatelessValidatorWith

function _signerOninstall(bytes32 id, bytes calldata _data) internal override {
require(signer[id][msg.sender] == address(0), "Already installed");
if (_data.length != 20) revert InvalidDataLength();
require(_data.length == 20, InvalidDataLength());
address signerAddr = address(bytes20(_data[0:20]));
if (signerAddr == address(0)) revert ZeroAddressSigner();
require(signerAddr != address(0), ZeroAddressSigner());
signer[id][msg.sender] = signerAddr;
}

Expand Down
2 changes: 2 additions & 0 deletions src/signers/WeightedECDSASigner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract WeightedECDSASigner is EIP712, SignerBase, IStatelessValidator, IStatel
keccak256("Proposal(address account,bytes32 id,bytes callData,uint256 nonce)");

error ZeroWeightSigner();
error ThresholdExceedsTotalWeight();

mapping(bytes32 id => mapping(address kernel => WeightedECDSASignerStorage)) public weightedStorage;
mapping(address guardian => mapping(bytes32 id => mapping(address kernel => GuardianStorage))) public guardian;
Expand Down Expand Up @@ -69,6 +70,7 @@ contract WeightedECDSASigner is EIP712, SignerBase, IStatelessValidator, IStatel
weightedStorage[id][msg.sender].totalWeight += _weights[i];
emit GuardianAdded(_guardians[i], msg.sender, _weights[i]);
}
require(_threshold <= weightedStorage[id][msg.sender].totalWeight, ThresholdExceedsTotalWeight());
weightedStorage[id][msg.sender].threshold = _threshold;
}

Expand Down
4 changes: 2 additions & 2 deletions src/validators/ECDSAValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ contract ECDSAValidator is IValidator, IHook, IStatelessValidator, IStatelessVal

function onInstall(bytes calldata _data) external payable override {
if (_isInitialized(msg.sender)) revert AlreadyInitialized(msg.sender);
if (_data.length != 20) revert InvalidDataLength();
require(_data.length == 20, InvalidDataLength());
address owner = address(bytes20(_data[0:20]));
if (owner == address(0)) revert ZeroAddressOwner();
require(owner != address(0), ZeroAddressOwner());
ecdsaValidatorStorage[msg.sender].owner = owner;
emit OwnerRegistered(msg.sender, owner);
}
Expand Down