mirror of https://github.com/crytic/slither
Merge pull request #2550 from crytic/dev-require-error
Add support custom errors in requirepull/2568/head
commit
29ca19a613
Binary file not shown.
@ -0,0 +1,5 @@ |
||||
{ |
||||
"TestToken": { |
||||
"transferWithRequireError(address,uint256)": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n}\n" |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
pragma solidity 0.8.27; |
||||
|
||||
/// Insufficient balance for transfer. Needed `required` but only |
||||
/// `available` available. |
||||
/// @param available balance available. |
||||
/// @param required requested amount to transfer. |
||||
error InsufficientBalance(uint256 available, uint256 required); |
||||
|
||||
contract TestToken { |
||||
mapping(address => uint) balance; |
||||
function transferWithRequireError(address to, uint256 amount) public { |
||||
require( |
||||
balance[msg.sender] >= amount, |
||||
InsufficientBalance(balance[msg.sender], amount) |
||||
); |
||||
balance[msg.sender] -= amount; |
||||
balance[to] += amount; |
||||
} |
||||
// ... |
||||
} |
Loading…
Reference in new issue