draft-IERC6093.sol 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. /**
  4. * @dev Standard ERC20 Errors
  5. * Interface of the ERC6093 custom errors for ERC20 tokens
  6. * as defined in https://eips.ethereum.org/EIPS/eip-6093
  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 ERC721 Errors
  46. * Interface of the ERC6093 custom errors for ERC721 tokens
  47. * as defined in https://eips.ethereum.org/EIPS/eip-6093
  48. */
  49. interface IERC721Errors {
  50. /**
  51. * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
  52. * Used in balance queries.
  53. * @param owner Address of the current owner of a token.
  54. */
  55. error ERC721InvalidOwner(address owner);
  56. /**
  57. * @dev Indicates a `tokenId` whose `owner` is the zero address.
  58. * @param tokenId Identifier number of a token.
  59. */
  60. error ERC721NonexistentToken(uint256 tokenId);
  61. /**
  62. * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
  63. * @param sender Address whose tokens are being transferred.
  64. * @param tokenId Identifier number of a token.
  65. * @param owner Address of the current owner of a token.
  66. */
  67. error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
  68. /**
  69. * @dev Indicates a failure with the token `sender`. Used in transfers.
  70. * @param sender Address whose tokens are being transferred.
  71. */
  72. error ERC721InvalidSender(address sender);
  73. /**
  74. * @dev Indicates a failure with the token `receiver`. Used in transfers.
  75. * @param receiver Address to which tokens are being transferred.
  76. */
  77. error ERC721InvalidReceiver(address receiver);
  78. /**
  79. * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
  80. * @param operator Address that may be allowed to operate on tokens without being their owner.
  81. * @param tokenId Identifier number of a token.
  82. */
  83. error ERC721InsufficientApproval(address operator, uint256 tokenId);
  84. /**
  85. * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
  86. * @param approver Address initiating an approval operation.
  87. */
  88. error ERC721InvalidApprover(address approver);
  89. /**
  90. * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
  91. * @param operator Address that may be allowed to operate on tokens without being their owner.
  92. */
  93. error ERC721InvalidOperator(address operator);
  94. }
  95. /**
  96. * @dev Standard ERC1155 Errors
  97. * Interface of the ERC6093 custom errors for ERC1155 tokens
  98. * as defined in https://eips.ethereum.org/EIPS/eip-6093
  99. */
  100. interface IERC1155Errors {
  101. /**
  102. * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
  103. * @param sender Address whose tokens are being transferred.
  104. * @param balance Current balance for the interacting account.
  105. * @param needed Minimum amount required to perform a transfer.
  106. */
  107. error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
  108. /**
  109. * @dev Indicates a failure with the token `sender`. Used in transfers.
  110. * @param sender Address whose tokens are being transferred.
  111. */
  112. error ERC1155InvalidSender(address sender);
  113. /**
  114. * @dev Indicates a failure with the token `receiver`. Used in transfers.
  115. * @param receiver Address to which tokens are being transferred.
  116. */
  117. error ERC1155InvalidReceiver(address receiver);
  118. /**
  119. * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
  120. * @param operator Address that may be allowed to operate on tokens without being their owner.
  121. * @param owner Address of the current owner of a token.
  122. */
  123. error ERC1155InsufficientApprovalForAll(address operator, address owner);
  124. /**
  125. * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
  126. * @param approver Address initiating an approval operation.
  127. */
  128. error ERC1155InvalidApprover(address approver);
  129. /**
  130. * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
  131. * @param operator Address that may be allowed to operate on tokens without being their owner.
  132. */
  133. error ERC1155InvalidOperator(address operator);
  134. /**
  135. * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
  136. * Used in batch transfers.
  137. * @param idsLength Length of the array of token identifiers
  138. * @param valuesLength Length of the array of token amounts
  139. */
  140. error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
  141. }