* Adding V08 contracts * Removing LibSafeMathV08 * Apply suggestions from code review Co-authored-by: duncancmt <1207590+duncancmt@users.noreply.github.com>
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Solidity
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Solidity
		
	
	
	
	
	
| // SPDX-License-Identifier: Apache-2.0
 | |
| /*
 | |
| 
 | |
|   Copyright 2020 ZeroEx Intl.
 | |
| 
 | |
|   Licensed under the Apache License, Version 2.0 (the "License");
 | |
|   you may not use this file except in compliance with the License.
 | |
|   You may obtain a copy of the License at
 | |
| 
 | |
|     http://www.apache.org/licenses/LICENSE-2.0
 | |
| 
 | |
|   Unless required by applicable law or agreed to in writing, software
 | |
|   distributed under the License is distributed on an "AS IS" BASIS,
 | |
|   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | |
|   See the License for the specific language governing permissions and
 | |
|   limitations under the License.
 | |
| 
 | |
| */
 | |
| 
 | |
| pragma solidity ^0.8;
 | |
| 
 | |
| library LibRichErrorsV08 {
 | |
|     // bytes4(keccak256("Error(string)"))
 | |
|     bytes4 internal constant STANDARD_ERROR_SELECTOR = 0x08c379a0;
 | |
| 
 | |
|     /// @dev ABI encode a standard, string revert error payload.
 | |
|     ///      This is the same payload that would be included by a `revert(string)`
 | |
|     ///      solidity statement. It has the function signature `Error(string)`.
 | |
|     /// @param message The error string.
 | |
|     /// @return The ABI encoded error.
 | |
|     function StandardError(string memory message) internal pure returns (bytes memory) {
 | |
|         return abi.encodeWithSelector(STANDARD_ERROR_SELECTOR, bytes(message));
 | |
|     }
 | |
| 
 | |
|     /// @dev Reverts an encoded rich revert reason `errorData`.
 | |
|     /// @param errorData ABI encoded error data.
 | |
|     function rrevert(bytes memory errorData) internal pure {
 | |
|         assembly ("memory-safe") {
 | |
|             revert(add(errorData, 0x20), mload(errorData))
 | |
|         }
 | |
|     }
 | |
| }
 |