diff --git a/src/SsoAccount.sol b/src/SsoAccount.sol index 382e1c1e..20e793c9 100644 --- a/src/SsoAccount.sol +++ b/src/SsoAccount.sol @@ -75,7 +75,7 @@ contract SsoAccount is Initializable, HookManager, ERC1271Handler, TokenCallback // If there is not enough balance for the transaction, the account should reject it // on the validation step to prevent paying fees for revertable transactions. if (_transaction.totalRequiredBalance() > address(this).balance) { - revert Errors.INSUFFICIENT_FUNDS(); + revert Errors.INSUFFICIENT_FUNDS(_transaction.totalRequiredBalance(), address(this).balance); } // While the suggested signed hash is usually provided, it is generally diff --git a/src/auth/BootloaderAuth.sol b/src/auth/BootloaderAuth.sol index 0a55a7b0..9b294f2d 100644 --- a/src/auth/BootloaderAuth.sol +++ b/src/auth/BootloaderAuth.sol @@ -12,7 +12,7 @@ import { Errors } from "../libraries/Errors.sol"; abstract contract BootloaderAuth { modifier onlyBootloader() { if (msg.sender != BOOTLOADER_FORMAL_ADDRESS) { - revert Errors.NOT_FROM_BOOTLOADER(); + revert Errors.NOT_FROM_BOOTLOADER(msg.sender); } _; } diff --git a/src/auth/HookAuth.sol b/src/auth/HookAuth.sol index 540d6c93..79389848 100644 --- a/src/auth/HookAuth.sol +++ b/src/auth/HookAuth.sol @@ -13,7 +13,7 @@ abstract contract HookAuth { modifier onlyHook() { if (!_isHook(msg.sender)) { - revert Errors.NOT_FROM_HOOK(); + revert Errors.NOT_FROM_HOOK(msg.sender); } _; } diff --git a/src/auth/SelfAuth.sol b/src/auth/SelfAuth.sol index d8ad59b2..fc4667fc 100644 --- a/src/auth/SelfAuth.sol +++ b/src/auth/SelfAuth.sol @@ -11,7 +11,7 @@ import { Errors } from "../libraries/Errors.sol"; abstract contract SelfAuth { modifier onlySelf() { if (msg.sender != address(this)) { - revert Errors.NOT_FROM_SELF(); + revert Errors.NOT_FROM_SELF(msg.sender); } _; } diff --git a/src/batch/BatchCaller.sol b/src/batch/BatchCaller.sol index 09b728c5..7561b60e 100644 --- a/src/batch/BatchCaller.sol +++ b/src/batch/BatchCaller.sol @@ -48,12 +48,12 @@ abstract contract BatchCaller is SelfAuth { } if (!_calls[i].allowFailure && !success) { - revert Errors.CALL_FAILED(); + revert Errors.CALL_FAILED(i); } } if (totalValue != msg.value) { - revert Errors.MsgValueMismatch(msg.value, totalValue); + revert Errors.MSG_VALUE_MISMATCH(msg.value, totalValue); } } } diff --git a/src/libraries/Errors.sol b/src/libraries/Errors.sol index 2b2e61d4..8a85aa50 100644 --- a/src/libraries/Errors.sol +++ b/src/libraries/Errors.sol @@ -6,7 +6,7 @@ library Errors { ACCOUNT //////////////////////////////////////////////////////////////*/ - error INSUFFICIENT_FUNDS(); + error INSUFFICIENT_FUNDS(uint256 required, uint256 available); error FEE_PAYMENT_FAILED(); error METHOD_NOT_IMPLEMENTED(); @@ -14,58 +14,43 @@ library Errors { LINKED LIST //////////////////////////////////////////////////////////////*/ - error INVALID_PREV(); + error INVALID_PREV_BYTES(bytes prevValue, bytes oldValue); + error INVALID_PREV_ADDR(address prevValue, address oldValue); // Bytes - error INVALID_BYTES(); - error BYTES_ALREADY_EXISTS(); - error BYTES_NOT_EXISTS(); + error INVALID_BYTES(uint256 length); + error BYTES_ALREADY_EXISTS(bytes length); + error BYTES_NOT_EXISTS(bytes lookup); // Address - error INVALID_ADDRESS(); - error ADDRESS_ALREADY_EXISTS(); - error ADDRESS_NOT_EXISTS(); - - /*////////////////////////////////////////////////////////////// - OWNER MANAGER - //////////////////////////////////////////////////////////////*/ - - error INVALID_PUBKEY_LENGTH(); + error INVALID_ADDRESS(address valid); + error ADDRESS_ALREADY_EXISTS(address exists); + error ADDRESS_NOT_EXISTS(address notExists); /*////////////////////////////////////////////////////////////// VALIDATOR MANAGER //////////////////////////////////////////////////////////////*/ - error VALIDATOR_ERC165_FAIL(); + error VALIDATOR_ERC165_FAIL(address validator); /*////////////////////////////////////////////////////////////// HOOK MANAGER //////////////////////////////////////////////////////////////*/ - error EMPTY_HOOK_ADDRESS(); - error HOOK_ERC165_FAIL(); - error INVALID_KEY(); - - /*////////////////////////////////////////////////////////////// - MODULE MANAGER - //////////////////////////////////////////////////////////////*/ - - error EMPTY_MODULE_ADDRESS(); - error RECURSIVE_MODULE_CALL(); - error MODULE_ERC165_FAIL(); + error EMPTY_HOOK_ADDRESS(uint256 hookAndDataLength); + error HOOK_ERC165_FAIL(address hookAddress, bool isValidation); + error INVALID_KEY(bytes32 key); /*////////////////////////////////////////////////////////////// AUTH //////////////////////////////////////////////////////////////*/ - error NOT_FROM_BOOTLOADER(); - error NOT_FROM_MODULE(); - error NOT_FROM_HOOK(); - error NOT_FROM_SELF(); - error NOT_FROM_SELF_OR_MODULE(); + error NOT_FROM_BOOTLOADER(address notBootloader); + error NOT_FROM_HOOK(address notHook); + error NOT_FROM_SELF(address notSelf); /*////////////////////////////////////////////////////////////// BatchCaller //////////////////////////////////////////////////////////////*/ - error CALL_FAILED(); - error MsgValueMismatch(uint256 actualValue, uint256 expectedValue); + error CALL_FAILED(uint256 batchCallIndex); + error MSG_VALUE_MISMATCH(uint256 actualValue, uint256 expectedValue); } diff --git a/src/libraries/LinkedList.sol b/src/libraries/LinkedList.sol index 6dec0816..f0b02739 100644 --- a/src/libraries/LinkedList.sol +++ b/src/libraries/LinkedList.sol @@ -14,14 +14,14 @@ library BytesLinkedList { modifier validBytes(bytes calldata value) { if (value.length <= SENTINEL_LENGTH) { - revert Errors.INVALID_BYTES(); + revert Errors.INVALID_BYTES(value.length); } _; } function add(mapping(bytes => bytes) storage self, bytes calldata value) internal validBytes(value) { if (self[value].length != 0) { - revert Errors.BYTES_ALREADY_EXISTS(); + revert Errors.BYTES_ALREADY_EXISTS(self[value]); } bytes memory prev = self[SENTINEL_BYTES]; @@ -36,10 +36,10 @@ library BytesLinkedList { function replace(mapping(bytes => bytes) storage self, bytes calldata oldValue, bytes calldata newValue) internal { if (!exists(self, oldValue)) { - revert Errors.BYTES_NOT_EXISTS(); + revert Errors.BYTES_NOT_EXISTS(oldValue); } if (exists(self, newValue)) { - revert Errors.BYTES_ALREADY_EXISTS(); + revert Errors.BYTES_ALREADY_EXISTS(newValue); } bytes memory cursor = SENTINEL_BYTES; @@ -63,13 +63,13 @@ library BytesLinkedList { bytes calldata newValue ) internal { if (!exists(self, oldValue)) { - revert Errors.BYTES_NOT_EXISTS(); + revert Errors.BYTES_NOT_EXISTS(oldValue); } if (exists(self, newValue)) { - revert Errors.BYTES_ALREADY_EXISTS(); + revert Errors.BYTES_ALREADY_EXISTS(newValue); } if (!equals(self[prevValue], oldValue)) { - revert Errors.INVALID_PREV(); + revert Errors.INVALID_PREV_BYTES(self[prevValue], oldValue); } self[newValue] = self[oldValue]; @@ -79,7 +79,7 @@ library BytesLinkedList { function remove(mapping(bytes => bytes) storage self, bytes calldata value) internal { if (!exists(self, value)) { - revert Errors.BYTES_NOT_EXISTS(); + revert Errors.BYTES_NOT_EXISTS(value); } bytes memory cursor = SENTINEL_BYTES; @@ -101,10 +101,10 @@ library BytesLinkedList { bytes calldata value ) internal { if (!exists(self, value)) { - revert Errors.BYTES_NOT_EXISTS(); + revert Errors.BYTES_NOT_EXISTS(value); } if (!equals(self[prevValue], value)) { - revert Errors.INVALID_PREV(); + revert Errors.INVALID_PREV_BYTES(self[prevValue], value); } self[prevValue] = self[value]; @@ -175,14 +175,14 @@ library AddressLinkedList { modifier validAddress(address value) { if (value <= SENTINEL_ADDRESS) { - revert Errors.INVALID_ADDRESS(); + revert Errors.INVALID_ADDRESS(value); } _; } function add(mapping(address => address) storage self, address value) internal validAddress(value) { if (self[value] != address(0)) { - revert Errors.ADDRESS_ALREADY_EXISTS(); + revert Errors.ADDRESS_ALREADY_EXISTS(value); } address prev = self[SENTINEL_ADDRESS]; @@ -197,10 +197,10 @@ library AddressLinkedList { function replace(mapping(address => address) storage self, address oldValue, address newValue) internal { if (!exists(self, oldValue)) { - revert Errors.ADDRESS_NOT_EXISTS(); + revert Errors.ADDRESS_NOT_EXISTS(oldValue); } if (exists(self, newValue)) { - revert Errors.ADDRESS_ALREADY_EXISTS(); + revert Errors.ADDRESS_ALREADY_EXISTS(newValue); } address cursor = SENTINEL_ADDRESS; @@ -224,13 +224,13 @@ library AddressLinkedList { address newValue ) internal { if (!exists(self, oldValue)) { - revert Errors.ADDRESS_NOT_EXISTS(); + revert Errors.ADDRESS_NOT_EXISTS(oldValue); } if (exists(self, newValue)) { - revert Errors.ADDRESS_ALREADY_EXISTS(); + revert Errors.ADDRESS_ALREADY_EXISTS(newValue); } if (self[prevValue] != oldValue) { - revert Errors.INVALID_PREV(); + revert Errors.INVALID_PREV_ADDR(self[prevValue], oldValue); } self[newValue] = self[oldValue]; @@ -240,7 +240,7 @@ library AddressLinkedList { function remove(mapping(address => address) storage self, address value) internal { if (!exists(self, value)) { - revert Errors.ADDRESS_NOT_EXISTS(); + revert Errors.ADDRESS_NOT_EXISTS(value); } address cursor = SENTINEL_ADDRESS; @@ -258,10 +258,10 @@ library AddressLinkedList { function removeUsingPrev(mapping(address => address) storage self, address prevValue, address value) internal { if (!exists(self, value)) { - revert Errors.ADDRESS_NOT_EXISTS(); + revert Errors.ADDRESS_NOT_EXISTS(value); } if (self[prevValue] != value) { - revert Errors.INVALID_PREV(); + revert Errors.INVALID_PREV_ADDR(self[prevValue], value); } self[prevValue] = self[value]; diff --git a/src/managers/HookManager.sol b/src/managers/HookManager.sol index 44db44b0..20a0e6c0 100644 --- a/src/managers/HookManager.sol +++ b/src/managers/HookManager.sol @@ -83,7 +83,7 @@ abstract contract HookManager is IHookManager, Auth { /// @inheritdoc IHookManager function setHookData(bytes32 key, bytes calldata data) external override onlyHook { if (key == CONTEXT_KEY) { - revert Errors.INVALID_KEY(); + revert Errors.INVALID_KEY(key); } _hookDataStore()[msg.sender][key] = data; @@ -161,7 +161,7 @@ abstract contract HookManager is IHookManager, Auth { function _addHook(bytes calldata hookAndData, bool isValidation) internal { if (hookAndData.length < 20) { - revert Errors.EMPTY_HOOK_ADDRESS(); + revert Errors.EMPTY_HOOK_ADDRESS(hookAndData.length); } address hookAddress = address(bytes20(hookAndData[0:20])); @@ -173,7 +173,7 @@ abstract contract HookManager is IHookManager, Auth { function _installHook(address hookAddress, bytes memory initData, bool isValidation) internal { if (!_supportsHook(hookAddress, isValidation)) { - revert Errors.HOOK_ERC165_FAIL(); + revert Errors.HOOK_ERC165_FAIL(hookAddress, isValidation); } if (isValidation) { diff --git a/src/managers/ValidatorManager.sol b/src/managers/ValidatorManager.sol index 99b4fca7..8f02a9c8 100644 --- a/src/managers/ValidatorManager.sol +++ b/src/managers/ValidatorManager.sol @@ -47,7 +47,7 @@ abstract contract ValidatorManager is IValidatorManager, Auth { function _addModuleValidator(address validator, bytes memory accountValidationKey) internal { if (!_supportsModuleValidator(validator)) { - revert Errors.VALIDATOR_ERC165_FAIL(); + revert Errors.VALIDATOR_ERC165_FAIL(validator); } _moduleValidatorsLinkedList().add(validator);