-
-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(smart-contracts): replace revert strings by error codes (#8867)
* replace revert strings by error struct * remove struct logic in mixin errors * make `UnlockErrors` a library * Revert "make `UnlockErrors` a library" This reverts commit f4b330e. * use solc 0.8.4 custom error patterns * small fixes * fix balance check on withdraw * better conditions for `purchase` * specify hook in error * public lock uses solc 0.8.11 * bump to 0.8.13 * fix condition in `transferFrom` * fix conditions and tests in `extend` and `renewMembershipFor` * fix tests and conditions * hooks revert strings in tests * condition if `_maxKeysPerAddress` * fix some more conditions * fix some more conditons and tests * Update smart-contracts/contracts/mixins/MixinErrors.sol Co-authored-by: Julien Genestoux <[email protected]> * Update smart-contracts/contracts/mixins/MixinPurchase.sol Co-authored-by: Julien Genestoux <[email protected]> Co-authored-by: Julien Genestoux <[email protected]>
- Loading branch information
Showing
18 changed files
with
266 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @title List of all error messages | ||
* (replace string errors message to save on contract size) | ||
*/ | ||
contract MixinErrors { | ||
|
||
// generic | ||
error OUT_OF_RANGE(); | ||
error NULL_VALUE(); | ||
error INVALID_ADDRESS(); | ||
error INVALID_TOKEN(); | ||
error INVALID_LENGTH(); | ||
error UNAUTHORIZED(); | ||
|
||
// erc 721 | ||
error NON_COMPLIANT_ERC721_RECEIVER(); | ||
|
||
// roles | ||
error ONLY_LOCK_MANAGER_OR_KEY_GRANTER(); | ||
error ONLY_KEY_MANAGER_OR_APPROVED(); | ||
error UNAUTHORIZED_KEY_MANAGER_UPDATE(); | ||
error ONLY_LOCK_MANAGER_OR_BENEFICIARY(); | ||
error ONLY_LOCK_MANAGER(); | ||
|
||
// single key status | ||
error KEY_NOT_VALID(); | ||
error NO_SUCH_KEY(); | ||
|
||
// single key operations | ||
error CANT_EXTEND_NON_EXPIRING_KEY(); | ||
error NOT_ENOUGH_TIME(); | ||
error NOT_ENOUGH_FUNDS(); | ||
|
||
// migration & data schema | ||
error SCHEMA_VERSION_NOT_CORRECT(); | ||
error MIGRATION_REQUIRED(); | ||
|
||
// lock status/settings | ||
error OWNER_CANT_BE_ADDRESS_ZERO(); | ||
error MAX_KEYS_REACHED(); | ||
error KEY_TRANSFERS_DISABLED(); | ||
error CANT_BE_SMALLER_THAN_SUPPLY(); | ||
|
||
// transfers and approvals | ||
error TRANSFER_TO_SELF(); | ||
error CANNOT_APPROVE_SELF(); | ||
|
||
// keys management | ||
error LOCK_SOLD_OUT(); | ||
|
||
// purchase | ||
error INSUFFICIENT_ERC20_VALUE(); | ||
error INSUFFICIENT_VALUE(); | ||
|
||
// renewals | ||
error NON_RENEWABLE_LOCK(); | ||
error LOCK_HAS_CHANGED(); | ||
error NOT_READY_FOR_RENEWAL(); | ||
|
||
// gas refund | ||
error GAS_REFUND_FAILED(); | ||
|
||
// hooks | ||
// NB: `hookIndex` designed the index of hook address in the params of `setEventHooks` | ||
error INVALID_HOOK(uint8 hookIndex); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.