account.adoc 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. :github-icon: pass:[<svg class="icon"><use href="#github-icon"/></svg>]
  2. :xref-ERC4337Utils-parseValidationData-uint256-: xref:account.adoc#ERC4337Utils-parseValidationData-uint256-
  3. :xref-ERC4337Utils-packValidationData-address-uint48-uint48-: xref:account.adoc#ERC4337Utils-packValidationData-address-uint48-uint48-
  4. :xref-ERC4337Utils-packValidationData-bool-uint48-uint48-: xref:account.adoc#ERC4337Utils-packValidationData-bool-uint48-uint48-
  5. :xref-ERC4337Utils-combineValidationData-uint256-uint256-: xref:account.adoc#ERC4337Utils-combineValidationData-uint256-uint256-
  6. :xref-ERC4337Utils-getValidationData-uint256-: xref:account.adoc#ERC4337Utils-getValidationData-uint256-
  7. :xref-ERC4337Utils-hash-struct-PackedUserOperation-address-uint256-: xref:account.adoc#ERC4337Utils-hash-struct-PackedUserOperation-address-uint256-
  8. :xref-ERC4337Utils-factory-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-factory-struct-PackedUserOperation-
  9. :xref-ERC4337Utils-factoryData-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-factoryData-struct-PackedUserOperation-
  10. :xref-ERC4337Utils-verificationGasLimit-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-verificationGasLimit-struct-PackedUserOperation-
  11. :xref-ERC4337Utils-callGasLimit-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-callGasLimit-struct-PackedUserOperation-
  12. :xref-ERC4337Utils-maxPriorityFeePerGas-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-maxPriorityFeePerGas-struct-PackedUserOperation-
  13. :xref-ERC4337Utils-maxFeePerGas-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-maxFeePerGas-struct-PackedUserOperation-
  14. :xref-ERC4337Utils-gasPrice-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-gasPrice-struct-PackedUserOperation-
  15. :xref-ERC4337Utils-paymaster-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-paymaster-struct-PackedUserOperation-
  16. :xref-ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-
  17. :xref-ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-
  18. :xref-ERC4337Utils-paymasterData-struct-PackedUserOperation-: xref:account.adoc#ERC4337Utils-paymasterData-struct-PackedUserOperation-
  19. :xref-ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256: xref:account.adoc#ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256
  20. :xref-ERC4337Utils-SIG_VALIDATION_FAILED-uint256: xref:account.adoc#ERC4337Utils-SIG_VALIDATION_FAILED-uint256
  21. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  22. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  23. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  24. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  25. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  26. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  27. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  28. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  29. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  30. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  31. :PackedUserOperation: pass:normal[xref:interfaces.adoc#PackedUserOperation[`PackedUserOperation`]]
  32. :xref-ERC7579Utils-execSingle-bytes-ExecType-: xref:account.adoc#ERC7579Utils-execSingle-bytes-ExecType-
  33. :xref-ERC7579Utils-execBatch-bytes-ExecType-: xref:account.adoc#ERC7579Utils-execBatch-bytes-ExecType-
  34. :xref-ERC7579Utils-execDelegateCall-bytes-ExecType-: xref:account.adoc#ERC7579Utils-execDelegateCall-bytes-ExecType-
  35. :xref-ERC7579Utils-encodeMode-CallType-ExecType-ModeSelector-ModePayload-: xref:account.adoc#ERC7579Utils-encodeMode-CallType-ExecType-ModeSelector-ModePayload-
  36. :xref-ERC7579Utils-decodeMode-Mode-: xref:account.adoc#ERC7579Utils-decodeMode-Mode-
  37. :xref-ERC7579Utils-encodeSingle-address-uint256-bytes-: xref:account.adoc#ERC7579Utils-encodeSingle-address-uint256-bytes-
  38. :xref-ERC7579Utils-decodeSingle-bytes-: xref:account.adoc#ERC7579Utils-decodeSingle-bytes-
  39. :xref-ERC7579Utils-encodeDelegate-address-bytes-: xref:account.adoc#ERC7579Utils-encodeDelegate-address-bytes-
  40. :xref-ERC7579Utils-decodeDelegate-bytes-: xref:account.adoc#ERC7579Utils-decodeDelegate-bytes-
  41. :xref-ERC7579Utils-encodeBatch-struct-Execution---: xref:account.adoc#ERC7579Utils-encodeBatch-struct-Execution---
  42. :xref-ERC7579Utils-decodeBatch-bytes-: xref:account.adoc#ERC7579Utils-decodeBatch-bytes-
  43. :xref-ERC7579Utils-ERC7579TryExecuteFail-uint256-bytes-: xref:account.adoc#ERC7579Utils-ERC7579TryExecuteFail-uint256-bytes-
  44. :xref-ERC7579Utils-ERC7579UnsupportedCallType-CallType-: xref:account.adoc#ERC7579Utils-ERC7579UnsupportedCallType-CallType-
  45. :xref-ERC7579Utils-ERC7579UnsupportedExecType-ExecType-: xref:account.adoc#ERC7579Utils-ERC7579UnsupportedExecType-ExecType-
  46. :xref-ERC7579Utils-ERC7579MismatchedModuleTypeId-uint256-address-: xref:account.adoc#ERC7579Utils-ERC7579MismatchedModuleTypeId-uint256-address-
  47. :xref-ERC7579Utils-ERC7579UninstalledModule-uint256-address-: xref:account.adoc#ERC7579Utils-ERC7579UninstalledModule-uint256-address-
  48. :xref-ERC7579Utils-ERC7579AlreadyInstalledModule-uint256-address-: xref:account.adoc#ERC7579Utils-ERC7579AlreadyInstalledModule-uint256-address-
  49. :xref-ERC7579Utils-ERC7579UnsupportedModuleType-uint256-: xref:account.adoc#ERC7579Utils-ERC7579UnsupportedModuleType-uint256-
  50. :xref-ERC7579Utils-ERC7579DecodingError--: xref:account.adoc#ERC7579Utils-ERC7579DecodingError--
  51. :xref-ERC7579Utils-CALLTYPE_SINGLE-CallType: xref:account.adoc#ERC7579Utils-CALLTYPE_SINGLE-CallType
  52. :xref-ERC7579Utils-CALLTYPE_BATCH-CallType: xref:account.adoc#ERC7579Utils-CALLTYPE_BATCH-CallType
  53. :xref-ERC7579Utils-CALLTYPE_DELEGATECALL-CallType: xref:account.adoc#ERC7579Utils-CALLTYPE_DELEGATECALL-CallType
  54. :xref-ERC7579Utils-EXECTYPE_DEFAULT-ExecType: xref:account.adoc#ERC7579Utils-EXECTYPE_DEFAULT-ExecType
  55. :xref-ERC7579Utils-EXECTYPE_TRY-ExecType: xref:account.adoc#ERC7579Utils-EXECTYPE_TRY-ExecType
  56. :CallType: pass:normal[xref:account.adoc#CallType[`CallType`]]
  57. :ExecType: pass:normal[xref:account.adoc#ExecType[`ExecType`]]
  58. = Account
  59. [.readme-notice]
  60. NOTE: This document is better viewed at https://docs.openzeppelin.com/contracts/api/account
  61. This directory includes contracts to build accounts for ERC-4337.
  62. == Utilities
  63. :SIG_VALIDATION_SUCCESS: pass:normal[xref:#ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256[`++SIG_VALIDATION_SUCCESS++`]]
  64. :SIG_VALIDATION_FAILED: pass:normal[xref:#ERC4337Utils-SIG_VALIDATION_FAILED-uint256[`++SIG_VALIDATION_FAILED++`]]
  65. :parseValidationData: pass:normal[xref:#ERC4337Utils-parseValidationData-uint256-[`++parseValidationData++`]]
  66. :packValidationData: pass:normal[xref:#ERC4337Utils-packValidationData-address-uint48-uint48-[`++packValidationData++`]]
  67. :packValidationData: pass:normal[xref:#ERC4337Utils-packValidationData-bool-uint48-uint48-[`++packValidationData++`]]
  68. :combineValidationData: pass:normal[xref:#ERC4337Utils-combineValidationData-uint256-uint256-[`++combineValidationData++`]]
  69. :getValidationData: pass:normal[xref:#ERC4337Utils-getValidationData-uint256-[`++getValidationData++`]]
  70. :hash: pass:normal[xref:#ERC4337Utils-hash-struct-PackedUserOperation-address-uint256-[`++hash++`]]
  71. :factory: pass:normal[xref:#ERC4337Utils-factory-struct-PackedUserOperation-[`++factory++`]]
  72. :factoryData: pass:normal[xref:#ERC4337Utils-factoryData-struct-PackedUserOperation-[`++factoryData++`]]
  73. :verificationGasLimit: pass:normal[xref:#ERC4337Utils-verificationGasLimit-struct-PackedUserOperation-[`++verificationGasLimit++`]]
  74. :callGasLimit: pass:normal[xref:#ERC4337Utils-callGasLimit-struct-PackedUserOperation-[`++callGasLimit++`]]
  75. :maxPriorityFeePerGas: pass:normal[xref:#ERC4337Utils-maxPriorityFeePerGas-struct-PackedUserOperation-[`++maxPriorityFeePerGas++`]]
  76. :maxFeePerGas: pass:normal[xref:#ERC4337Utils-maxFeePerGas-struct-PackedUserOperation-[`++maxFeePerGas++`]]
  77. :gasPrice: pass:normal[xref:#ERC4337Utils-gasPrice-struct-PackedUserOperation-[`++gasPrice++`]]
  78. :paymaster: pass:normal[xref:#ERC4337Utils-paymaster-struct-PackedUserOperation-[`++paymaster++`]]
  79. :paymasterVerificationGasLimit: pass:normal[xref:#ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-[`++paymasterVerificationGasLimit++`]]
  80. :paymasterPostOpGasLimit: pass:normal[xref:#ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-[`++paymasterPostOpGasLimit++`]]
  81. :paymasterData: pass:normal[xref:#ERC4337Utils-paymasterData-struct-PackedUserOperation-[`++paymasterData++`]]
  82. [.contract]
  83. [[ERC4337Utils]]
  84. === `++ERC4337Utils++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.2.0/contracts/account/utils/draft-ERC4337Utils.sol[{github-icon},role=heading-link]
  85. [.hljs-theme-light.nopadding]
  86. ```solidity
  87. import "@openzeppelin/contracts/account/utils/draft-ERC4337Utils.sol";
  88. ```
  89. Library with common ERC-4337 utility functions.
  90. See https://eips.ethereum.org/EIPS/eip-4337[ERC-4337].
  91. [.contract-index]
  92. .Functions
  93. --
  94. * {xref-ERC4337Utils-parseValidationData-uint256-}[`++parseValidationData(validationData)++`]
  95. * {xref-ERC4337Utils-packValidationData-address-uint48-uint48-}[`++packValidationData(aggregator, validAfter, validUntil)++`]
  96. * {xref-ERC4337Utils-packValidationData-bool-uint48-uint48-}[`++packValidationData(sigSuccess, validAfter, validUntil)++`]
  97. * {xref-ERC4337Utils-combineValidationData-uint256-uint256-}[`++combineValidationData(validationData1, validationData2)++`]
  98. * {xref-ERC4337Utils-getValidationData-uint256-}[`++getValidationData(validationData)++`]
  99. * {xref-ERC4337Utils-hash-struct-PackedUserOperation-address-uint256-}[`++hash(self, entrypoint, chainid)++`]
  100. * {xref-ERC4337Utils-factory-struct-PackedUserOperation-}[`++factory(self)++`]
  101. * {xref-ERC4337Utils-factoryData-struct-PackedUserOperation-}[`++factoryData(self)++`]
  102. * {xref-ERC4337Utils-verificationGasLimit-struct-PackedUserOperation-}[`++verificationGasLimit(self)++`]
  103. * {xref-ERC4337Utils-callGasLimit-struct-PackedUserOperation-}[`++callGasLimit(self)++`]
  104. * {xref-ERC4337Utils-maxPriorityFeePerGas-struct-PackedUserOperation-}[`++maxPriorityFeePerGas(self)++`]
  105. * {xref-ERC4337Utils-maxFeePerGas-struct-PackedUserOperation-}[`++maxFeePerGas(self)++`]
  106. * {xref-ERC4337Utils-gasPrice-struct-PackedUserOperation-}[`++gasPrice(self)++`]
  107. * {xref-ERC4337Utils-paymaster-struct-PackedUserOperation-}[`++paymaster(self)++`]
  108. * {xref-ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-}[`++paymasterVerificationGasLimit(self)++`]
  109. * {xref-ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-}[`++paymasterPostOpGasLimit(self)++`]
  110. * {xref-ERC4337Utils-paymasterData-struct-PackedUserOperation-}[`++paymasterData(self)++`]
  111. --
  112. [.contract-index]
  113. .Internal Variables
  114. --
  115. * {xref-ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256}[`++uint256 constant SIG_VALIDATION_SUCCESS++`]
  116. * {xref-ERC4337Utils-SIG_VALIDATION_FAILED-uint256}[`++uint256 constant SIG_VALIDATION_FAILED++`]
  117. --
  118. [.contract-item]
  119. [[ERC4337Utils-parseValidationData-uint256-]]
  120. ==== `[.contract-item-name]#++parseValidationData++#++(uint256 validationData) → address aggregator, uint48 validAfter, uint48 validUntil++` [.item-kind]#internal#
  121. Parses the validation data into its components. See {packValidationData}.
  122. [.contract-item]
  123. [[ERC4337Utils-packValidationData-address-uint48-uint48-]]
  124. ==== `[.contract-item-name]#++packValidationData++#++(address aggregator, uint48 validAfter, uint48 validUntil) → uint256++` [.item-kind]#internal#
  125. Packs the validation data into a single uint256. See {parseValidationData}.
  126. [.contract-item]
  127. [[ERC4337Utils-packValidationData-bool-uint48-uint48-]]
  128. ==== `[.contract-item-name]#++packValidationData++#++(bool sigSuccess, uint48 validAfter, uint48 validUntil) → uint256++` [.item-kind]#internal#
  129. Same as {packValidationData}, but with a boolean signature success flag.
  130. [.contract-item]
  131. [[ERC4337Utils-combineValidationData-uint256-uint256-]]
  132. ==== `[.contract-item-name]#++combineValidationData++#++(uint256 validationData1, uint256 validationData2) → uint256++` [.item-kind]#internal#
  133. Combines two validation data into a single one.
  134. The `aggregator` is set to {SIG_VALIDATION_SUCCESS} if both are successful, while
  135. the `validAfter` is the maximum and the `validUntil` is the minimum of both.
  136. [.contract-item]
  137. [[ERC4337Utils-getValidationData-uint256-]]
  138. ==== `[.contract-item-name]#++getValidationData++#++(uint256 validationData) → address aggregator, bool outOfTimeRange++` [.item-kind]#internal#
  139. Returns the aggregator of the `validationData` and whether it is out of time range.
  140. [.contract-item]
  141. [[ERC4337Utils-hash-struct-PackedUserOperation-address-uint256-]]
  142. ==== `[.contract-item-name]#++hash++#++(struct PackedUserOperation self, address entrypoint, uint256 chainid) → bytes32++` [.item-kind]#internal#
  143. Computes the hash of a user operation for a given entrypoint and chainid.
  144. [.contract-item]
  145. [[ERC4337Utils-factory-struct-PackedUserOperation-]]
  146. ==== `[.contract-item-name]#++factory++#++(struct PackedUserOperation self) → address++` [.item-kind]#internal#
  147. Returns `factory` from the {PackedUserOperation}, or address(0) if the initCode is empty or not properly formatted.
  148. [.contract-item]
  149. [[ERC4337Utils-factoryData-struct-PackedUserOperation-]]
  150. ==== `[.contract-item-name]#++factoryData++#++(struct PackedUserOperation self) → bytes++` [.item-kind]#internal#
  151. Returns `factoryData` from the {PackedUserOperation}, or empty bytes if the initCode is empty or not properly formatted.
  152. [.contract-item]
  153. [[ERC4337Utils-verificationGasLimit-struct-PackedUserOperation-]]
  154. ==== `[.contract-item-name]#++verificationGasLimit++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  155. Returns `verificationGasLimit` from the {PackedUserOperation}.
  156. [.contract-item]
  157. [[ERC4337Utils-callGasLimit-struct-PackedUserOperation-]]
  158. ==== `[.contract-item-name]#++callGasLimit++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  159. Returns `callGasLimit` from the {PackedUserOperation}.
  160. [.contract-item]
  161. [[ERC4337Utils-maxPriorityFeePerGas-struct-PackedUserOperation-]]
  162. ==== `[.contract-item-name]#++maxPriorityFeePerGas++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  163. Returns the first section of `gasFees` from the {PackedUserOperation}.
  164. [.contract-item]
  165. [[ERC4337Utils-maxFeePerGas-struct-PackedUserOperation-]]
  166. ==== `[.contract-item-name]#++maxFeePerGas++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  167. Returns the second section of `gasFees` from the {PackedUserOperation}.
  168. [.contract-item]
  169. [[ERC4337Utils-gasPrice-struct-PackedUserOperation-]]
  170. ==== `[.contract-item-name]#++gasPrice++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  171. Returns the total gas price for the {PackedUserOperation} (ie. `maxFeePerGas` or `maxPriorityFeePerGas + basefee`).
  172. [.contract-item]
  173. [[ERC4337Utils-paymaster-struct-PackedUserOperation-]]
  174. ==== `[.contract-item-name]#++paymaster++#++(struct PackedUserOperation self) → address++` [.item-kind]#internal#
  175. Returns the first section of `paymasterAndData` from the {PackedUserOperation}.
  176. [.contract-item]
  177. [[ERC4337Utils-paymasterVerificationGasLimit-struct-PackedUserOperation-]]
  178. ==== `[.contract-item-name]#++paymasterVerificationGasLimit++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  179. Returns the second section of `paymasterAndData` from the {PackedUserOperation}.
  180. [.contract-item]
  181. [[ERC4337Utils-paymasterPostOpGasLimit-struct-PackedUserOperation-]]
  182. ==== `[.contract-item-name]#++paymasterPostOpGasLimit++#++(struct PackedUserOperation self) → uint256++` [.item-kind]#internal#
  183. Returns the third section of `paymasterAndData` from the {PackedUserOperation}.
  184. [.contract-item]
  185. [[ERC4337Utils-paymasterData-struct-PackedUserOperation-]]
  186. ==== `[.contract-item-name]#++paymasterData++#++(struct PackedUserOperation self) → bytes++` [.item-kind]#internal#
  187. Returns the fourth section of `paymasterAndData` from the {PackedUserOperation}.
  188. [.contract-item]
  189. [[ERC4337Utils-SIG_VALIDATION_SUCCESS-uint256]]
  190. ==== `uint256 [.contract-item-name]#++SIG_VALIDATION_SUCCESS++#` [.item-kind]#internal constant#
  191. For simulation purposes, validateUserOp (and validatePaymasterUserOp) return this value on success.
  192. [.contract-item]
  193. [[ERC4337Utils-SIG_VALIDATION_FAILED-uint256]]
  194. ==== `uint256 [.contract-item-name]#++SIG_VALIDATION_FAILED++#` [.item-kind]#internal constant#
  195. For simulation purposes, validateUserOp (and validatePaymasterUserOp) must return this value in case of signature failure, instead of revert.
  196. :CALLTYPE_SINGLE: pass:normal[xref:#ERC7579Utils-CALLTYPE_SINGLE-CallType[`++CALLTYPE_SINGLE++`]]
  197. :CALLTYPE_BATCH: pass:normal[xref:#ERC7579Utils-CALLTYPE_BATCH-CallType[`++CALLTYPE_BATCH++`]]
  198. :CALLTYPE_DELEGATECALL: pass:normal[xref:#ERC7579Utils-CALLTYPE_DELEGATECALL-CallType[`++CALLTYPE_DELEGATECALL++`]]
  199. :EXECTYPE_DEFAULT: pass:normal[xref:#ERC7579Utils-EXECTYPE_DEFAULT-ExecType[`++EXECTYPE_DEFAULT++`]]
  200. :EXECTYPE_TRY: pass:normal[xref:#ERC7579Utils-EXECTYPE_TRY-ExecType[`++EXECTYPE_TRY++`]]
  201. :ERC7579TryExecuteFail: pass:normal[xref:#ERC7579Utils-ERC7579TryExecuteFail-uint256-bytes-[`++ERC7579TryExecuteFail++`]]
  202. :ERC7579UnsupportedCallType: pass:normal[xref:#ERC7579Utils-ERC7579UnsupportedCallType-CallType-[`++ERC7579UnsupportedCallType++`]]
  203. :ERC7579UnsupportedExecType: pass:normal[xref:#ERC7579Utils-ERC7579UnsupportedExecType-ExecType-[`++ERC7579UnsupportedExecType++`]]
  204. :ERC7579MismatchedModuleTypeId: pass:normal[xref:#ERC7579Utils-ERC7579MismatchedModuleTypeId-uint256-address-[`++ERC7579MismatchedModuleTypeId++`]]
  205. :ERC7579UninstalledModule: pass:normal[xref:#ERC7579Utils-ERC7579UninstalledModule-uint256-address-[`++ERC7579UninstalledModule++`]]
  206. :ERC7579AlreadyInstalledModule: pass:normal[xref:#ERC7579Utils-ERC7579AlreadyInstalledModule-uint256-address-[`++ERC7579AlreadyInstalledModule++`]]
  207. :ERC7579UnsupportedModuleType: pass:normal[xref:#ERC7579Utils-ERC7579UnsupportedModuleType-uint256-[`++ERC7579UnsupportedModuleType++`]]
  208. :ERC7579DecodingError: pass:normal[xref:#ERC7579Utils-ERC7579DecodingError--[`++ERC7579DecodingError++`]]
  209. :execSingle: pass:normal[xref:#ERC7579Utils-execSingle-bytes-ExecType-[`++execSingle++`]]
  210. :execBatch: pass:normal[xref:#ERC7579Utils-execBatch-bytes-ExecType-[`++execBatch++`]]
  211. :execDelegateCall: pass:normal[xref:#ERC7579Utils-execDelegateCall-bytes-ExecType-[`++execDelegateCall++`]]
  212. :encodeMode: pass:normal[xref:#ERC7579Utils-encodeMode-CallType-ExecType-ModeSelector-ModePayload-[`++encodeMode++`]]
  213. :decodeMode: pass:normal[xref:#ERC7579Utils-decodeMode-Mode-[`++decodeMode++`]]
  214. :encodeSingle: pass:normal[xref:#ERC7579Utils-encodeSingle-address-uint256-bytes-[`++encodeSingle++`]]
  215. :decodeSingle: pass:normal[xref:#ERC7579Utils-decodeSingle-bytes-[`++decodeSingle++`]]
  216. :encodeDelegate: pass:normal[xref:#ERC7579Utils-encodeDelegate-address-bytes-[`++encodeDelegate++`]]
  217. :decodeDelegate: pass:normal[xref:#ERC7579Utils-decodeDelegate-bytes-[`++decodeDelegate++`]]
  218. :encodeBatch: pass:normal[xref:#ERC7579Utils-encodeBatch-struct-Execution---[`++encodeBatch++`]]
  219. :decodeBatch: pass:normal[xref:#ERC7579Utils-decodeBatch-bytes-[`++decodeBatch++`]]
  220. [.contract]
  221. [[ERC7579Utils]]
  222. === `++ERC7579Utils++` link:https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.2.0/contracts/account/utils/draft-ERC7579Utils.sol[{github-icon},role=heading-link]
  223. [.hljs-theme-light.nopadding]
  224. ```solidity
  225. import "@openzeppelin/contracts/account/utils/draft-ERC7579Utils.sol";
  226. ```
  227. Library with common ERC-7579 utility functions.
  228. See https://eips.ethereum.org/EIPS/eip-7579[ERC-7579].
  229. [.contract-index]
  230. .Functions
  231. --
  232. * {xref-ERC7579Utils-execSingle-bytes-ExecType-}[`++execSingle(executionCalldata, execType)++`]
  233. * {xref-ERC7579Utils-execBatch-bytes-ExecType-}[`++execBatch(executionCalldata, execType)++`]
  234. * {xref-ERC7579Utils-execDelegateCall-bytes-ExecType-}[`++execDelegateCall(executionCalldata, execType)++`]
  235. * {xref-ERC7579Utils-encodeMode-CallType-ExecType-ModeSelector-ModePayload-}[`++encodeMode(callType, execType, selector, payload)++`]
  236. * {xref-ERC7579Utils-decodeMode-Mode-}[`++decodeMode(mode)++`]
  237. * {xref-ERC7579Utils-encodeSingle-address-uint256-bytes-}[`++encodeSingle(target, value, callData)++`]
  238. * {xref-ERC7579Utils-decodeSingle-bytes-}[`++decodeSingle(executionCalldata)++`]
  239. * {xref-ERC7579Utils-encodeDelegate-address-bytes-}[`++encodeDelegate(target, callData)++`]
  240. * {xref-ERC7579Utils-decodeDelegate-bytes-}[`++decodeDelegate(executionCalldata)++`]
  241. * {xref-ERC7579Utils-encodeBatch-struct-Execution---}[`++encodeBatch(executionBatch)++`]
  242. * {xref-ERC7579Utils-decodeBatch-bytes-}[`++decodeBatch(executionCalldata)++`]
  243. --
  244. [.contract-index]
  245. .Events
  246. --
  247. * {xref-ERC7579Utils-ERC7579TryExecuteFail-uint256-bytes-}[`++ERC7579TryExecuteFail(batchExecutionIndex, returndata)++`]
  248. --
  249. [.contract-index]
  250. .Errors
  251. --
  252. * {xref-ERC7579Utils-ERC7579UnsupportedCallType-CallType-}[`++ERC7579UnsupportedCallType(callType)++`]
  253. * {xref-ERC7579Utils-ERC7579UnsupportedExecType-ExecType-}[`++ERC7579UnsupportedExecType(execType)++`]
  254. * {xref-ERC7579Utils-ERC7579MismatchedModuleTypeId-uint256-address-}[`++ERC7579MismatchedModuleTypeId(moduleTypeId, module)++`]
  255. * {xref-ERC7579Utils-ERC7579UninstalledModule-uint256-address-}[`++ERC7579UninstalledModule(moduleTypeId, module)++`]
  256. * {xref-ERC7579Utils-ERC7579AlreadyInstalledModule-uint256-address-}[`++ERC7579AlreadyInstalledModule(moduleTypeId, module)++`]
  257. * {xref-ERC7579Utils-ERC7579UnsupportedModuleType-uint256-}[`++ERC7579UnsupportedModuleType(moduleTypeId)++`]
  258. * {xref-ERC7579Utils-ERC7579DecodingError--}[`++ERC7579DecodingError()++`]
  259. --
  260. [.contract-index]
  261. .Internal Variables
  262. --
  263. * {xref-ERC7579Utils-CALLTYPE_SINGLE-CallType}[`++CallType constant CALLTYPE_SINGLE++`]
  264. * {xref-ERC7579Utils-CALLTYPE_BATCH-CallType}[`++CallType constant CALLTYPE_BATCH++`]
  265. * {xref-ERC7579Utils-CALLTYPE_DELEGATECALL-CallType}[`++CallType constant CALLTYPE_DELEGATECALL++`]
  266. * {xref-ERC7579Utils-EXECTYPE_DEFAULT-ExecType}[`++ExecType constant EXECTYPE_DEFAULT++`]
  267. * {xref-ERC7579Utils-EXECTYPE_TRY-ExecType}[`++ExecType constant EXECTYPE_TRY++`]
  268. --
  269. [.contract-item]
  270. [[ERC7579Utils-execSingle-bytes-ExecType-]]
  271. ==== `[.contract-item-name]#++execSingle++#++(bytes executionCalldata, ExecType execType) → bytes[] returnData++` [.item-kind]#internal#
  272. Executes a single call.
  273. [.contract-item]
  274. [[ERC7579Utils-execBatch-bytes-ExecType-]]
  275. ==== `[.contract-item-name]#++execBatch++#++(bytes executionCalldata, ExecType execType) → bytes[] returnData++` [.item-kind]#internal#
  276. Executes a batch of calls.
  277. [.contract-item]
  278. [[ERC7579Utils-execDelegateCall-bytes-ExecType-]]
  279. ==== `[.contract-item-name]#++execDelegateCall++#++(bytes executionCalldata, ExecType execType) → bytes[] returnData++` [.item-kind]#internal#
  280. Executes a delegate call.
  281. [.contract-item]
  282. [[ERC7579Utils-encodeMode-CallType-ExecType-ModeSelector-ModePayload-]]
  283. ==== `[.contract-item-name]#++encodeMode++#++(CallType callType, ExecType execType, ModeSelector selector, ModePayload payload) → Mode mode++` [.item-kind]#internal#
  284. Encodes the mode with the provided parameters. See {decodeMode}.
  285. [.contract-item]
  286. [[ERC7579Utils-decodeMode-Mode-]]
  287. ==== `[.contract-item-name]#++decodeMode++#++(Mode mode) → CallType callType, ExecType execType, ModeSelector selector, ModePayload payload++` [.item-kind]#internal#
  288. Decodes the mode into its parameters. See {encodeMode}.
  289. [.contract-item]
  290. [[ERC7579Utils-encodeSingle-address-uint256-bytes-]]
  291. ==== `[.contract-item-name]#++encodeSingle++#++(address target, uint256 value, bytes callData) → bytes executionCalldata++` [.item-kind]#internal#
  292. Encodes a single call execution. See {decodeSingle}.
  293. [.contract-item]
  294. [[ERC7579Utils-decodeSingle-bytes-]]
  295. ==== `[.contract-item-name]#++decodeSingle++#++(bytes executionCalldata) → address target, uint256 value, bytes callData++` [.item-kind]#internal#
  296. Decodes a single call execution. See {encodeSingle}.
  297. [.contract-item]
  298. [[ERC7579Utils-encodeDelegate-address-bytes-]]
  299. ==== `[.contract-item-name]#++encodeDelegate++#++(address target, bytes callData) → bytes executionCalldata++` [.item-kind]#internal#
  300. Encodes a delegate call execution. See {decodeDelegate}.
  301. [.contract-item]
  302. [[ERC7579Utils-decodeDelegate-bytes-]]
  303. ==== `[.contract-item-name]#++decodeDelegate++#++(bytes executionCalldata) → address target, bytes callData++` [.item-kind]#internal#
  304. Decodes a delegate call execution. See {encodeDelegate}.
  305. [.contract-item]
  306. [[ERC7579Utils-encodeBatch-struct-Execution---]]
  307. ==== `[.contract-item-name]#++encodeBatch++#++(struct Execution[] executionBatch) → bytes executionCalldata++` [.item-kind]#internal#
  308. Encodes a batch of executions. See {decodeBatch}.
  309. [.contract-item]
  310. [[ERC7579Utils-decodeBatch-bytes-]]
  311. ==== `[.contract-item-name]#++decodeBatch++#++(bytes executionCalldata) → struct Execution[] executionBatch++` [.item-kind]#internal#
  312. Decodes a batch of executions. See {encodeBatch}.
  313. NOTE: This function runs some checks and will throw a {ERC7579DecodingError} if the input is not properly formatted.
  314. [.contract-item]
  315. [[ERC7579Utils-ERC7579TryExecuteFail-uint256-bytes-]]
  316. ==== `[.contract-item-name]#++ERC7579TryExecuteFail++#++(uint256 batchExecutionIndex, bytes returndata)++` [.item-kind]#event#
  317. Emits when an {EXECTYPE_TRY} execution fails.
  318. [.contract-item]
  319. [[ERC7579Utils-ERC7579UnsupportedCallType-CallType-]]
  320. ==== `[.contract-item-name]#++ERC7579UnsupportedCallType++#++(CallType callType)++` [.item-kind]#error#
  321. The provided {CallType} is not supported.
  322. [.contract-item]
  323. [[ERC7579Utils-ERC7579UnsupportedExecType-ExecType-]]
  324. ==== `[.contract-item-name]#++ERC7579UnsupportedExecType++#++(ExecType execType)++` [.item-kind]#error#
  325. The provided {ExecType} is not supported.
  326. [.contract-item]
  327. [[ERC7579Utils-ERC7579MismatchedModuleTypeId-uint256-address-]]
  328. ==== `[.contract-item-name]#++ERC7579MismatchedModuleTypeId++#++(uint256 moduleTypeId, address module)++` [.item-kind]#error#
  329. The provided module doesn't match the provided module type.
  330. [.contract-item]
  331. [[ERC7579Utils-ERC7579UninstalledModule-uint256-address-]]
  332. ==== `[.contract-item-name]#++ERC7579UninstalledModule++#++(uint256 moduleTypeId, address module)++` [.item-kind]#error#
  333. The module is not installed.
  334. [.contract-item]
  335. [[ERC7579Utils-ERC7579AlreadyInstalledModule-uint256-address-]]
  336. ==== `[.contract-item-name]#++ERC7579AlreadyInstalledModule++#++(uint256 moduleTypeId, address module)++` [.item-kind]#error#
  337. The module is already installed.
  338. [.contract-item]
  339. [[ERC7579Utils-ERC7579UnsupportedModuleType-uint256-]]
  340. ==== `[.contract-item-name]#++ERC7579UnsupportedModuleType++#++(uint256 moduleTypeId)++` [.item-kind]#error#
  341. The module type is not supported.
  342. [.contract-item]
  343. [[ERC7579Utils-ERC7579DecodingError--]]
  344. ==== `[.contract-item-name]#++ERC7579DecodingError++#++()++` [.item-kind]#error#
  345. Input calldata not properly formatted and possibly malicious.
  346. [.contract-item]
  347. [[ERC7579Utils-CALLTYPE_SINGLE-CallType]]
  348. ==== `CallType [.contract-item-name]#++CALLTYPE_SINGLE++#` [.item-kind]#internal constant#
  349. A single `call` execution.
  350. [.contract-item]
  351. [[ERC7579Utils-CALLTYPE_BATCH-CallType]]
  352. ==== `CallType [.contract-item-name]#++CALLTYPE_BATCH++#` [.item-kind]#internal constant#
  353. A batch of `call` executions.
  354. [.contract-item]
  355. [[ERC7579Utils-CALLTYPE_DELEGATECALL-CallType]]
  356. ==== `CallType [.contract-item-name]#++CALLTYPE_DELEGATECALL++#` [.item-kind]#internal constant#
  357. A `delegatecall` execution.
  358. [.contract-item]
  359. [[ERC7579Utils-EXECTYPE_DEFAULT-ExecType]]
  360. ==== `ExecType [.contract-item-name]#++EXECTYPE_DEFAULT++#` [.item-kind]#internal constant#
  361. Default execution type that reverts on failure.
  362. [.contract-item]
  363. [[ERC7579Utils-EXECTYPE_TRY-ExecType]]
  364. ==== `ExecType [.contract-item-name]#++EXECTYPE_TRY++#` [.item-kind]#internal constant#
  365. Execution type that does not revert on failure.