draft-IERC6093.sol 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. /**
  4. * @dev Standard ERC20 Errors
  5. * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
  6. */
  7. interface IERC20Errors {
  8. /**
  9. * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
  10. * @param sender Address whose tokens are being transferred.
  11. * @param balance Current balance for the interacting account.
  12. * @param needed Minimum amount required to perform a transfer.
  13. */
  14. error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
  15. /**
  16. * @dev Indicates a failure with the token `sender`. Used in transfers.
  17. * @param sender Address whose tokens are being transferred.
  18. */
  19. error ERC20InvalidSender(address sender);
  20. /**
  21. * @dev Indicates a failure with the token `receiver`. Used in transfers.
  22. * @param receiver Address to which tokens are being transferred.
  23. */
  24. error ERC20InvalidReceiver(address receiver);
  25. /**
  26. * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
  27. * @param spender Address that may be allowed to operate on tokens without being their owner.
  28. * @param allowance Amount of tokens a `spender` is allowed to operate with.
  29. * @param needed Minimum amount required to perform a transfer.
  30. */
  31. error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
  32. /**
  33. * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
  34. * @param approver Address initiating an approval operation.
  35. */
  36. error ERC20InvalidApprover(address approver);
  37. /**
  38. * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
  39. * @param spender Address that may be allowed to operate on tokens without being their owner.
  40. */
  41. error ERC20InvalidSpender(address spender);
  42. }
  43. /**
  44. * @dev Standard ERC721 Errors
  45. * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
  46. */
  47. interface IERC721Errors {
  48. /**
  49. * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
  50. * Used in balance queries.
  51. * @param owner Address of the current owner of a token.
  52. */
  53. error ERC721InvalidOwner(address owner);
  54. /**
  55. * @dev Indicates a `tokenId` whose `owner` is the zero address.
  56. * @param tokenId Identifier number of a token.
  57. */
  58. error ERC721NonexistentToken(uint256 tokenId);
  59. /**
  60. * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
  61. * @param sender Address whose tokens are being transferred.
  62. * @param tokenId Identifier number of a token.
  63. * @param owner Address of the current owner of a token.
  64. */
  65. error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
  66. /**
  67. * @dev Indicates a failure with the token `sender`. Used in transfers.
  68. * @param sender Address whose tokens are being transferred.
  69. */
  70. error ERC721InvalidSender(address sender);
  71. /**
  72. * @dev Indicates a failure with the token `receiver`. Used in transfers.
  73. * @param receiver Address to which tokens are being transferred.
  74. */
  75. error ERC721InvalidReceiver(address receiver);
  76. /**
  77. * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
  78. * @param operator Address that may be allowed to operate on tokens without being their owner.
  79. * @param tokenId Identifier number of a token.
  80. */
  81. error ERC721InsufficientApproval(address operator, uint256 tokenId);
  82. /**
  83. * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
  84. * @param approver Address initiating an approval operation.
  85. */
  86. error ERC721InvalidApprover(address approver);
  87. /**
  88. * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
  89. * @param operator Address that may be allowed to operate on tokens without being their owner.
  90. */
  91. error ERC721InvalidOperator(address operator);
  92. }
  93. /**
  94. * @dev Standard ERC1155 Errors
  95. * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
  96. */
  97. interface IERC1155Errors {
  98. /**
  99. * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
  100. * @param sender Address whose tokens are being transferred.
  101. * @param balance Current balance for the interacting account.
  102. * @param needed Minimum amount required to perform a transfer.
  103. * @param tokenId Identifier number of a token.
  104. */
  105. error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
  106. /**
  107. * @dev Indicates a failure with the token `sender`. Used in transfers.
  108. * @param sender Address whose tokens are being transferred.
  109. */
  110. error ERC1155InvalidSender(address sender);
  111. /**
  112. * @dev Indicates a failure with the token `receiver`. Used in transfers.
  113. * @param receiver Address to which tokens are being transferred.
  114. */
  115. error ERC1155InvalidReceiver(address receiver);
  116. /**
  117. * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
  118. * @param operator Address that may be allowed to operate on tokens without being their owner.
  119. * @param owner Address of the current owner of a token.
  120. */
  121. error ERC1155MissingApprovalForAll(address operator, address owner);
  122. /**
  123. * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
  124. * @param approver Address initiating an approval operation.
  125. */
  126. error ERC1155InvalidApprover(address approver);
  127. /**
  128. * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
  129. * @param operator Address that may be allowed to operate on tokens without being their owner.
  130. */
  131. error ERC1155InvalidOperator(address operator);
  132. /**
  133. * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
  134. * Used in batch transfers.
  135. * @param idsLength Length of the array of token identifiers
  136. * @param valuesLength Length of the array of token amounts
  137. */
  138. error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
  139. }