draft-IERC6093.sol 6.4 KB

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