viem 2.17.11 → 2.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (470) hide show
  1. package/CHANGELOG.md +20 -2
  2. package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js +6 -0
  3. package/_cjs/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -0
  4. package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +688 -0
  5. package/_cjs/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -0
  6. package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js +704 -0
  7. package/_cjs/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -0
  8. package/_cjs/account-abstraction/accounts/toSmartAccount.js +93 -0
  9. package/_cjs/account-abstraction/accounts/toSmartAccount.js.map +1 -0
  10. package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js +24 -0
  11. package/_cjs/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -0
  12. package/_cjs/account-abstraction/accounts/types.js +3 -0
  13. package/_cjs/account-abstraction/accounts/types.js.map +1 -0
  14. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +37 -0
  15. package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -0
  16. package/_cjs/account-abstraction/actions/bundler/getSupportedEntryPoints.js +7 -0
  17. package/_cjs/account-abstraction/actions/bundler/getSupportedEntryPoints.js.map +1 -0
  18. package/_cjs/account-abstraction/actions/bundler/getUserOperation.js +22 -0
  19. package/_cjs/account-abstraction/actions/bundler/getUserOperation.js.map +1 -0
  20. package/_cjs/account-abstraction/actions/bundler/getUserOperationReceipt.js +15 -0
  21. package/_cjs/account-abstraction/actions/bundler/getUserOperationReceipt.js.map +1 -0
  22. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js +239 -0
  23. package/_cjs/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -0
  24. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js +36 -0
  25. package/_cjs/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -0
  26. package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +48 -0
  27. package/_cjs/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
  28. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js +34 -0
  29. package/_cjs/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -0
  30. package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js +34 -0
  31. package/_cjs/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -0
  32. package/_cjs/account-abstraction/clients/createBundlerClient.js +18 -0
  33. package/_cjs/account-abstraction/clients/createBundlerClient.js.map +1 -0
  34. package/_cjs/account-abstraction/clients/createPaymasterClient.js +17 -0
  35. package/_cjs/account-abstraction/clients/createPaymasterClient.js.map +1 -0
  36. package/_cjs/account-abstraction/clients/decorators/bundler.js +24 -0
  37. package/_cjs/account-abstraction/clients/decorators/bundler.js.map +1 -0
  38. package/_cjs/account-abstraction/clients/decorators/paymaster.js +12 -0
  39. package/_cjs/account-abstraction/clients/decorators/paymaster.js.map +1 -0
  40. package/_cjs/account-abstraction/constants/abis.js +1318 -0
  41. package/_cjs/account-abstraction/constants/abis.js.map +1 -0
  42. package/_cjs/account-abstraction/constants/address.js +6 -0
  43. package/_cjs/account-abstraction/constants/address.js.map +1 -0
  44. package/_cjs/account-abstraction/errors/bundler.js +813 -0
  45. package/_cjs/account-abstraction/errors/bundler.js.map +1 -0
  46. package/_cjs/account-abstraction/errors/userOperation.js +91 -0
  47. package/_cjs/account-abstraction/errors/userOperation.js.map +1 -0
  48. package/_cjs/account-abstraction/index.js +90 -0
  49. package/_cjs/account-abstraction/index.js.map +1 -0
  50. package/_cjs/account-abstraction/types/account.js +3 -0
  51. package/_cjs/account-abstraction/types/account.js.map +1 -0
  52. package/_cjs/account-abstraction/types/entryPointVersion.js +3 -0
  53. package/_cjs/account-abstraction/types/entryPointVersion.js.map +1 -0
  54. package/_cjs/account-abstraction/types/rpc.js +3 -0
  55. package/_cjs/account-abstraction/types/rpc.js.map +1 -0
  56. package/_cjs/account-abstraction/types/userOperation.js +3 -0
  57. package/_cjs/account-abstraction/types/userOperation.js.map +1 -0
  58. package/_cjs/account-abstraction/utils/errors/getBundlerError.js +186 -0
  59. package/_cjs/account-abstraction/utils/errors/getBundlerError.js.map +1 -0
  60. package/_cjs/account-abstraction/utils/errors/getUserOperationError.js +87 -0
  61. package/_cjs/account-abstraction/utils/errors/getUserOperationError.js.map +1 -0
  62. package/_cjs/account-abstraction/utils/formatters/userOperation.js +24 -0
  63. package/_cjs/account-abstraction/utils/formatters/userOperation.js.map +1 -0
  64. package/_cjs/account-abstraction/utils/formatters/userOperationGas.js +18 -0
  65. package/_cjs/account-abstraction/utils/formatters/userOperationGas.js.map +1 -0
  66. package/_cjs/account-abstraction/utils/formatters/userOperationReceipt.js +18 -0
  67. package/_cjs/account-abstraction/utils/formatters/userOperationReceipt.js.map +1 -0
  68. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js +43 -0
  69. package/_cjs/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -0
  70. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js +88 -0
  71. package/_cjs/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -0
  72. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js +44 -0
  73. package/_cjs/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -0
  74. package/_cjs/accounts/index.js.map +1 -1
  75. package/_cjs/accounts/privateKeyToAccount.js +4 -0
  76. package/_cjs/accounts/privateKeyToAccount.js.map +1 -1
  77. package/_cjs/accounts/toAccount.js +1 -0
  78. package/_cjs/accounts/toAccount.js.map +1 -1
  79. package/_cjs/accounts/utils/parseAccount.js.map +1 -1
  80. package/_cjs/accounts/utils/sign.js +8 -2
  81. package/_cjs/accounts/utils/sign.js.map +1 -1
  82. package/_cjs/accounts/utils/signMessage.js +1 -3
  83. package/_cjs/accounts/utils/signMessage.js.map +1 -1
  84. package/_cjs/accounts/utils/signTypedData.js +2 -3
  85. package/_cjs/accounts/utils/signTypedData.js.map +1 -1
  86. package/_cjs/actions/public/getLogs.js +2 -1
  87. package/_cjs/actions/public/getLogs.js.map +1 -1
  88. package/_cjs/actions/wallet/sendTransaction.js +35 -22
  89. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  90. package/_cjs/actions/wallet/signMessage.js +1 -1
  91. package/_cjs/actions/wallet/signMessage.js.map +1 -1
  92. package/_cjs/actions/wallet/signTransaction.js +1 -2
  93. package/_cjs/actions/wallet/signTransaction.js.map +1 -1
  94. package/_cjs/actions/wallet/signTypedData.js +1 -1
  95. package/_cjs/actions/wallet/signTypedData.js.map +1 -1
  96. package/_cjs/chains/definitions/bobaSepolia.js +1 -0
  97. package/_cjs/chains/definitions/bobaSepolia.js.map +1 -1
  98. package/_cjs/chains/definitions/cronoszkEVMTestnet.js +24 -0
  99. package/_cjs/chains/definitions/cronoszkEVMTestnet.js.map +1 -0
  100. package/_cjs/chains/index.js +8 -6
  101. package/_cjs/chains/index.js.map +1 -1
  102. package/_cjs/constants/abis.js +0 -3
  103. package/_cjs/constants/abis.js.map +1 -1
  104. package/_cjs/constants/address.js +3 -1
  105. package/_cjs/constants/address.js.map +1 -1
  106. package/_cjs/errors/account.js +17 -2
  107. package/_cjs/errors/account.js.map +1 -1
  108. package/_cjs/errors/contract.js +1 -1
  109. package/_cjs/errors/contract.js.map +1 -1
  110. package/_cjs/errors/rpc.js +6 -6
  111. package/_cjs/errors/rpc.js.map +1 -1
  112. package/_cjs/errors/version.js +1 -1
  113. package/_cjs/errors/version.js.map +1 -1
  114. package/_cjs/index.js +5 -3
  115. package/_cjs/index.js.map +1 -1
  116. package/_cjs/types/eip1193.js.map +1 -1
  117. package/_cjs/utils/abi/parseEventLogs.js +70 -2
  118. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  119. package/_cjs/utils/buildRequest.js +4 -2
  120. package/_cjs/utils/buildRequest.js.map +1 -1
  121. package/_cjs/utils/errors/getNodeError.js +1 -2
  122. package/_cjs/utils/errors/getNodeError.js.map +1 -1
  123. package/_cjs/utils/index.js +3 -1
  124. package/_cjs/utils/index.js.map +1 -1
  125. package/_cjs/utils/signature/serializeErc6492Signature.js +6 -2
  126. package/_cjs/utils/signature/serializeErc6492Signature.js.map +1 -1
  127. package/_cjs/utils/signature/serializeSignature.js +6 -2
  128. package/_cjs/utils/signature/serializeSignature.js.map +1 -1
  129. package/_cjs/utils/signature/verifyHash.js +10 -0
  130. package/_cjs/utils/signature/verifyHash.js.map +1 -0
  131. package/_esm/account-abstraction/accounts/createWebAuthnCredential.js +3 -0
  132. package/_esm/account-abstraction/accounts/createWebAuthnCredential.js.map +1 -0
  133. package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js +709 -0
  134. package/_esm/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.js.map +1 -0
  135. package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js +718 -0
  136. package/_esm/account-abstraction/accounts/implementations/toSoladySmartAccount.js.map +1 -0
  137. package/_esm/account-abstraction/accounts/toSmartAccount.js +96 -0
  138. package/_esm/account-abstraction/accounts/toSmartAccount.js.map +1 -0
  139. package/_esm/account-abstraction/accounts/toWebAuthnAccount.js +26 -0
  140. package/_esm/account-abstraction/accounts/toWebAuthnAccount.js.map +1 -0
  141. package/_esm/account-abstraction/accounts/types.js +2 -0
  142. package/_esm/account-abstraction/accounts/types.js.map +1 -0
  143. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +61 -0
  144. package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -0
  145. package/_esm/account-abstraction/actions/bundler/getSupportedEntryPoints.js +25 -0
  146. package/_esm/account-abstraction/actions/bundler/getSupportedEntryPoints.js.map +1 -0
  147. package/_esm/account-abstraction/actions/bundler/getUserOperation.js +42 -0
  148. package/_esm/account-abstraction/actions/bundler/getUserOperation.js.map +1 -0
  149. package/_esm/account-abstraction/actions/bundler/getUserOperationReceipt.js +35 -0
  150. package/_esm/account-abstraction/actions/bundler/getUserOperationReceipt.js.map +1 -0
  151. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js +323 -0
  152. package/_esm/account-abstraction/actions/bundler/prepareUserOperation.js.map +1 -0
  153. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js +60 -0
  154. package/_esm/account-abstraction/actions/bundler/sendUserOperation.js.map +1 -0
  155. package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js +68 -0
  156. package/_esm/account-abstraction/actions/bundler/waitForUserOperationReceipt.js.map +1 -0
  157. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js +56 -0
  158. package/_esm/account-abstraction/actions/paymaster/getPaymasterData.js.map +1 -0
  159. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js +56 -0
  160. package/_esm/account-abstraction/actions/paymaster/getPaymasterStubData.js.map +1 -0
  161. package/_esm/account-abstraction/clients/createBundlerClient.js +15 -0
  162. package/_esm/account-abstraction/clients/createBundlerClient.js.map +1 -0
  163. package/_esm/account-abstraction/clients/createPaymasterClient.js +14 -0
  164. package/_esm/account-abstraction/clients/createPaymasterClient.js.map +1 -0
  165. package/_esm/account-abstraction/clients/decorators/bundler.js +21 -0
  166. package/_esm/account-abstraction/clients/decorators/bundler.js.map +1 -0
  167. package/_esm/account-abstraction/clients/decorators/paymaster.js +9 -0
  168. package/_esm/account-abstraction/clients/decorators/paymaster.js.map +1 -0
  169. package/_esm/account-abstraction/constants/abis.js +1315 -0
  170. package/_esm/account-abstraction/constants/abis.js.map +1 -0
  171. package/_esm/account-abstraction/constants/address.js +3 -0
  172. package/_esm/account-abstraction/constants/address.js.map +1 -0
  173. package/_esm/account-abstraction/errors/bundler.js +774 -0
  174. package/_esm/account-abstraction/errors/bundler.js.map +1 -0
  175. package/_esm/account-abstraction/errors/userOperation.js +84 -0
  176. package/_esm/account-abstraction/errors/userOperation.js.map +1 -0
  177. package/_esm/account-abstraction/index.js +31 -0
  178. package/_esm/account-abstraction/index.js.map +1 -0
  179. package/_esm/account-abstraction/types/account.js +2 -0
  180. package/_esm/account-abstraction/types/account.js.map +1 -0
  181. package/_esm/account-abstraction/types/entryPointVersion.js +2 -0
  182. package/_esm/account-abstraction/types/entryPointVersion.js.map +1 -0
  183. package/_esm/account-abstraction/types/rpc.js +2 -0
  184. package/_esm/account-abstraction/types/rpc.js.map +1 -0
  185. package/_esm/account-abstraction/types/userOperation.js +2 -0
  186. package/_esm/account-abstraction/types/userOperation.js.map +1 -0
  187. package/_esm/account-abstraction/utils/errors/getBundlerError.js +183 -0
  188. package/_esm/account-abstraction/utils/errors/getBundlerError.js.map +1 -0
  189. package/_esm/account-abstraction/utils/errors/getUserOperationError.js +85 -0
  190. package/_esm/account-abstraction/utils/errors/getUserOperationError.js.map +1 -0
  191. package/_esm/account-abstraction/utils/formatters/userOperation.js +21 -0
  192. package/_esm/account-abstraction/utils/formatters/userOperation.js.map +1 -0
  193. package/_esm/account-abstraction/utils/formatters/userOperationGas.js +15 -0
  194. package/_esm/account-abstraction/utils/formatters/userOperationGas.js.map +1 -0
  195. package/_esm/account-abstraction/utils/formatters/userOperationReceipt.js +15 -0
  196. package/_esm/account-abstraction/utils/formatters/userOperationReceipt.js.map +1 -0
  197. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js +40 -0
  198. package/_esm/account-abstraction/utils/formatters/userOperationRequest.js.map +1 -0
  199. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js +85 -0
  200. package/_esm/account-abstraction/utils/userOperation/getUserOperationHash.js.map +1 -0
  201. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js +41 -0
  202. package/_esm/account-abstraction/utils/userOperation/toPackedUserOperation.js.map +1 -0
  203. package/_esm/accounts/index.js.map +1 -1
  204. package/_esm/accounts/privateKeyToAccount.js +4 -0
  205. package/_esm/accounts/privateKeyToAccount.js.map +1 -1
  206. package/_esm/accounts/toAccount.js +2 -0
  207. package/_esm/accounts/toAccount.js.map +1 -1
  208. package/_esm/accounts/utils/parseAccount.js.map +1 -1
  209. package/_esm/accounts/utils/sign.js +9 -3
  210. package/_esm/accounts/utils/sign.js.map +1 -1
  211. package/_esm/accounts/utils/signMessage.js +1 -3
  212. package/_esm/accounts/utils/signMessage.js.map +1 -1
  213. package/_esm/accounts/utils/signTypedData.js +2 -3
  214. package/_esm/accounts/utils/signTypedData.js.map +1 -1
  215. package/_esm/actions/public/getLogs.js +2 -1
  216. package/_esm/actions/public/getLogs.js.map +1 -1
  217. package/_esm/actions/wallet/sendTransaction.js +37 -24
  218. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  219. package/_esm/actions/wallet/signMessage.js +1 -1
  220. package/_esm/actions/wallet/signMessage.js.map +1 -1
  221. package/_esm/actions/wallet/signTransaction.js +1 -2
  222. package/_esm/actions/wallet/signTransaction.js.map +1 -1
  223. package/_esm/actions/wallet/signTypedData.js +1 -1
  224. package/_esm/actions/wallet/signTypedData.js.map +1 -1
  225. package/_esm/chains/definitions/bobaSepolia.js +1 -0
  226. package/_esm/chains/definitions/bobaSepolia.js.map +1 -1
  227. package/_esm/chains/definitions/cronoszkEVMTestnet.js +21 -0
  228. package/_esm/chains/definitions/cronoszkEVMTestnet.js.map +1 -0
  229. package/_esm/chains/index.js +1 -0
  230. package/_esm/chains/index.js.map +1 -1
  231. package/_esm/constants/abis.js +0 -3
  232. package/_esm/constants/abis.js.map +1 -1
  233. package/_esm/constants/address.js +2 -0
  234. package/_esm/constants/address.js.map +1 -1
  235. package/_esm/errors/account.js +15 -1
  236. package/_esm/errors/account.js.map +1 -1
  237. package/_esm/errors/contract.js +1 -1
  238. package/_esm/errors/contract.js.map +1 -1
  239. package/_esm/errors/rpc.js +6 -6
  240. package/_esm/errors/rpc.js.map +1 -1
  241. package/_esm/errors/version.js +1 -1
  242. package/_esm/errors/version.js.map +1 -1
  243. package/_esm/index.js +1 -0
  244. package/_esm/index.js.map +1 -1
  245. package/_esm/types/eip1193.js.map +1 -1
  246. package/_esm/utils/abi/parseEventLogs.js +72 -2
  247. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  248. package/_esm/utils/buildRequest.js +4 -2
  249. package/_esm/utils/buildRequest.js.map +1 -1
  250. package/_esm/utils/errors/getNodeError.js +1 -2
  251. package/_esm/utils/errors/getNodeError.js.map +1 -1
  252. package/_esm/utils/index.js +1 -0
  253. package/_esm/utils/index.js.map +1 -1
  254. package/_esm/utils/signature/serializeErc6492Signature.js +6 -2
  255. package/_esm/utils/signature/serializeErc6492Signature.js.map +1 -1
  256. package/_esm/utils/signature/serializeSignature.js +6 -2
  257. package/_esm/utils/signature/serializeSignature.js.map +1 -1
  258. package/_esm/utils/signature/verifyHash.js +19 -0
  259. package/_esm/utils/signature/verifyHash.js.map +1 -0
  260. package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts +2 -0
  261. package/_types/account-abstraction/accounts/createWebAuthnCredential.d.ts.map +1 -0
  262. package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts +648 -0
  263. package/_types/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.d.ts.map +1 -0
  264. package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts +464 -0
  265. package/_types/account-abstraction/accounts/implementations/toSoladySmartAccount.d.ts.map +1 -0
  266. package/_types/account-abstraction/accounts/toSmartAccount.d.ts +14 -0
  267. package/_types/account-abstraction/accounts/toSmartAccount.d.ts.map +1 -0
  268. package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts +32 -0
  269. package/_types/account-abstraction/accounts/toWebAuthnAccount.d.ts.map +1 -0
  270. package/_types/account-abstraction/accounts/types.d.ts +174 -0
  271. package/_types/account-abstraction/accounts/types.d.ts.map +1 -0
  272. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts +62 -0
  273. package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -0
  274. package/_types/account-abstraction/actions/bundler/getSupportedEntryPoints.d.ts +30 -0
  275. package/_types/account-abstraction/actions/bundler/getSupportedEntryPoints.d.ts.map +1 -0
  276. package/_types/account-abstraction/actions/bundler/getUserOperation.d.ts +57 -0
  277. package/_types/account-abstraction/actions/bundler/getUserOperation.d.ts.map +1 -0
  278. package/_types/account-abstraction/actions/bundler/getUserOperationReceipt.d.ts +39 -0
  279. package/_types/account-abstraction/actions/bundler/getUserOperationReceipt.d.ts.map +1 -0
  280. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts +106 -0
  281. package/_types/account-abstraction/actions/bundler/prepareUserOperation.d.ts.map +1 -0
  282. package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts +60 -0
  283. package/_types/account-abstraction/actions/bundler/sendUserOperation.d.ts.map +1 -0
  284. package/_types/account-abstraction/actions/bundler/waitForUserOperationReceipt.d.ts +52 -0
  285. package/_types/account-abstraction/actions/bundler/waitForUserOperationReceipt.d.ts.map +1 -0
  286. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts +49 -0
  287. package/_types/account-abstraction/actions/paymaster/getPaymasterData.d.ts.map +1 -0
  288. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts +55 -0
  289. package/_types/account-abstraction/actions/paymaster/getPaymasterStubData.d.ts.map +1 -0
  290. package/_types/account-abstraction/clients/createBundlerClient.d.ts +66 -0
  291. package/_types/account-abstraction/clients/createBundlerClient.d.ts.map +1 -0
  292. package/_types/account-abstraction/clients/createPaymasterClient.d.ts +27 -0
  293. package/_types/account-abstraction/clients/createPaymasterClient.d.ts.map +1 -0
  294. package/_types/account-abstraction/clients/decorators/bundler.d.ts +206 -0
  295. package/_types/account-abstraction/clients/decorators/bundler.d.ts.map +1 -0
  296. package/_types/account-abstraction/clients/decorators/paymaster.d.ts +60 -0
  297. package/_types/account-abstraction/clients/decorators/paymaster.d.ts.map +1 -0
  298. package/_types/account-abstraction/constants/abis.d.ts +1468 -0
  299. package/_types/account-abstraction/constants/abis.d.ts.map +1 -0
  300. package/_types/account-abstraction/constants/address.d.ts +3 -0
  301. package/_types/account-abstraction/constants/address.d.ts.map +1 -0
  302. package/_types/account-abstraction/errors/bundler.d.ts +391 -0
  303. package/_types/account-abstraction/errors/bundler.d.ts.map +1 -0
  304. package/_types/account-abstraction/errors/userOperation.d.ts +41 -0
  305. package/_types/account-abstraction/errors/userOperation.d.ts.map +1 -0
  306. package/_types/account-abstraction/index.d.ts +34 -0
  307. package/_types/account-abstraction/index.d.ts.map +1 -0
  308. package/_types/account-abstraction/types/account.d.ts +11 -0
  309. package/_types/account-abstraction/types/account.d.ts.map +1 -0
  310. package/_types/account-abstraction/types/entryPointVersion.d.ts +9 -0
  311. package/_types/account-abstraction/types/entryPointVersion.d.ts.map +1 -0
  312. package/_types/account-abstraction/types/rpc.d.ts +9 -0
  313. package/_types/account-abstraction/types/rpc.d.ts.map +1 -0
  314. package/_types/account-abstraction/types/userOperation.d.ts +157 -0
  315. package/_types/account-abstraction/types/userOperation.d.ts.map +1 -0
  316. package/_types/account-abstraction/utils/errors/getBundlerError.d.ts +8 -0
  317. package/_types/account-abstraction/utils/errors/getBundlerError.d.ts.map +1 -0
  318. package/_types/account-abstraction/utils/errors/getUserOperationError.d.ts +15 -0
  319. package/_types/account-abstraction/utils/errors/getUserOperationError.d.ts.map +1 -0
  320. package/_types/account-abstraction/utils/formatters/userOperation.d.ts +6 -0
  321. package/_types/account-abstraction/utils/formatters/userOperation.d.ts.map +1 -0
  322. package/_types/account-abstraction/utils/formatters/userOperationGas.d.ts +6 -0
  323. package/_types/account-abstraction/utils/formatters/userOperationGas.d.ts.map +1 -0
  324. package/_types/account-abstraction/utils/formatters/userOperationReceipt.d.ts +6 -0
  325. package/_types/account-abstraction/utils/formatters/userOperationReceipt.d.ts.map +1 -0
  326. package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts +7 -0
  327. package/_types/account-abstraction/utils/formatters/userOperationRequest.d.ts.map +1 -0
  328. package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts +13 -0
  329. package/_types/account-abstraction/utils/userOperation/getUserOperationHash.d.ts.map +1 -0
  330. package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts +3 -0
  331. package/_types/account-abstraction/utils/userOperation/toPackedUserOperation.d.ts.map +1 -0
  332. package/_types/accounts/index.d.ts.map +1 -1
  333. package/_types/accounts/privateKeyToAccount.d.ts +2 -1
  334. package/_types/accounts/privateKeyToAccount.d.ts.map +1 -1
  335. package/_types/accounts/toAccount.d.ts.map +1 -1
  336. package/_types/accounts/types.d.ts +14 -7
  337. package/_types/accounts/types.d.ts.map +1 -1
  338. package/_types/accounts/utils/parseAccount.d.ts +1 -1
  339. package/_types/accounts/utils/parseAccount.d.ts.map +1 -1
  340. package/_types/accounts/utils/sign.d.ts +9 -6
  341. package/_types/accounts/utils/sign.d.ts.map +1 -1
  342. package/_types/accounts/utils/signMessage.d.ts +1 -2
  343. package/_types/accounts/utils/signMessage.d.ts.map +1 -1
  344. package/_types/accounts/utils/signTypedData.d.ts +1 -2
  345. package/_types/accounts/utils/signTypedData.d.ts.map +1 -1
  346. package/_types/actions/public/getLogs.d.ts.map +1 -1
  347. package/_types/actions/wallet/sendTransaction.d.ts +2 -1
  348. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  349. package/_types/actions/wallet/signMessage.d.ts.map +1 -1
  350. package/_types/actions/wallet/signTransaction.d.ts.map +1 -1
  351. package/_types/chains/definitions/bobaSepolia.d.ts +1 -1
  352. package/_types/chains/definitions/bobaSepolia.d.ts.map +1 -1
  353. package/_types/chains/definitions/cronoszkEVMTestnet.d.ts +35 -0
  354. package/_types/chains/definitions/cronoszkEVMTestnet.d.ts.map +1 -0
  355. package/_types/chains/definitions/lisk.d.ts +2 -2
  356. package/_types/chains/definitions/playfiAlbireo.d.ts +2 -2
  357. package/_types/chains/definitions/zkSync.d.ts +2 -2
  358. package/_types/chains/definitions/zkSyncInMemoryNode.d.ts +2 -2
  359. package/_types/chains/definitions/zkSyncLocalNode.d.ts +2 -2
  360. package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +2 -2
  361. package/_types/chains/definitions/zkSyncTestnet.d.ts +2 -2
  362. package/_types/chains/index.d.ts +1 -0
  363. package/_types/chains/index.d.ts.map +1 -1
  364. package/_types/clients/decorators/public.d.ts +1 -1
  365. package/_types/clients/decorators/public.d.ts.map +1 -1
  366. package/_types/constants/abis.d.ts +0 -3
  367. package/_types/constants/abis.d.ts.map +1 -1
  368. package/_types/constants/address.d.ts +2 -0
  369. package/_types/constants/address.d.ts.map +1 -1
  370. package/_types/errors/account.d.ts +11 -0
  371. package/_types/errors/account.d.ts.map +1 -1
  372. package/_types/errors/rpc.d.ts +9 -3
  373. package/_types/errors/rpc.d.ts.map +1 -1
  374. package/_types/errors/version.d.ts +1 -1
  375. package/_types/errors/version.d.ts.map +1 -1
  376. package/_types/index.d.ts +5 -3
  377. package/_types/index.d.ts.map +1 -1
  378. package/_types/types/eip1193.d.ts +239 -2
  379. package/_types/types/eip1193.d.ts.map +1 -1
  380. package/_types/types/multicall.d.ts +1 -1
  381. package/_types/types/multicall.d.ts.map +1 -1
  382. package/_types/utils/abi/parseEventLogs.d.ts +9 -3
  383. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  384. package/_types/utils/buildRequest.d.ts.map +1 -1
  385. package/_types/utils/errors/getNodeError.d.ts.map +1 -1
  386. package/_types/utils/formatters/transaction.d.ts +1 -1
  387. package/_types/utils/index.d.ts +1 -0
  388. package/_types/utils/index.d.ts.map +1 -1
  389. package/_types/utils/signature/hashTypedData.d.ts +2 -2
  390. package/_types/utils/signature/hashTypedData.d.ts.map +1 -1
  391. package/_types/utils/signature/serializeErc6492Signature.d.ts +7 -4
  392. package/_types/utils/signature/serializeErc6492Signature.d.ts.map +1 -1
  393. package/_types/utils/signature/serializeSignature.d.ts +8 -2
  394. package/_types/utils/signature/serializeSignature.d.ts.map +1 -1
  395. package/_types/utils/signature/verifyHash.d.ts +30 -0
  396. package/_types/utils/signature/verifyHash.d.ts.map +1 -0
  397. package/_types/zksync/chainConfig.d.ts +2 -2
  398. package/_types/zksync/formatters.d.ts +2 -2
  399. package/account-abstraction/accounts/createWebAuthnCredential.ts +7 -0
  400. package/account-abstraction/accounts/implementations/toCoinbaseSmartAccount.ts +817 -0
  401. package/account-abstraction/accounts/implementations/toSoladySmartAccount.ts +794 -0
  402. package/account-abstraction/accounts/toSmartAccount.ts +126 -0
  403. package/account-abstraction/accounts/toWebAuthnAccount.ts +56 -0
  404. package/account-abstraction/accounts/types.ts +208 -0
  405. package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +170 -0
  406. package/account-abstraction/actions/bundler/getSupportedEntryPoints.ts +33 -0
  407. package/account-abstraction/actions/bundler/getUserOperation.ts +85 -0
  408. package/account-abstraction/actions/bundler/getUserOperationReceipt.ts +64 -0
  409. package/account-abstraction/actions/bundler/prepareUserOperation.ts +637 -0
  410. package/account-abstraction/actions/bundler/sendUserOperation.ts +149 -0
  411. package/account-abstraction/actions/bundler/waitForUserOperationReceipt.ts +139 -0
  412. package/account-abstraction/actions/paymaster/getPaymasterData.ts +135 -0
  413. package/account-abstraction/actions/paymaster/getPaymasterStubData.ts +138 -0
  414. package/account-abstraction/clients/createBundlerClient.ts +155 -0
  415. package/account-abstraction/clients/createPaymasterClient.ts +78 -0
  416. package/account-abstraction/clients/decorators/bundler.ts +296 -0
  417. package/account-abstraction/clients/decorators/paymaster.ts +81 -0
  418. package/account-abstraction/constants/abis.ts +1404 -0
  419. package/account-abstraction/constants/address.ts +4 -0
  420. package/account-abstraction/errors/bundler.ts +781 -0
  421. package/account-abstraction/errors/userOperation.ts +111 -0
  422. package/account-abstraction/index.ts +228 -0
  423. package/account-abstraction/package.json +6 -0
  424. package/account-abstraction/types/account.ts +21 -0
  425. package/account-abstraction/types/entryPointVersion.ts +24 -0
  426. package/account-abstraction/types/rpc.ts +29 -0
  427. package/account-abstraction/types/userOperation.ts +262 -0
  428. package/account-abstraction/utils/errors/getBundlerError.ts +309 -0
  429. package/account-abstraction/utils/errors/getUserOperationError.ts +153 -0
  430. package/account-abstraction/utils/formatters/userOperation.ts +31 -0
  431. package/account-abstraction/utils/formatters/userOperationGas.ts +26 -0
  432. package/account-abstraction/utils/formatters/userOperationReceipt.ts +24 -0
  433. package/account-abstraction/utils/formatters/userOperationRequest.ts +53 -0
  434. package/account-abstraction/utils/userOperation/getUserOperationHash.ts +138 -0
  435. package/account-abstraction/utils/userOperation/toPackedUserOperation.ts +64 -0
  436. package/accounts/index.ts +1 -0
  437. package/accounts/privateKeyToAccount.ts +5 -0
  438. package/accounts/toAccount.ts +3 -0
  439. package/accounts/types.ts +34 -12
  440. package/accounts/utils/parseAccount.ts +6 -3
  441. package/accounts/utils/sign.ts +24 -8
  442. package/accounts/utils/signMessage.ts +1 -7
  443. package/accounts/utils/signTypedData.ts +2 -7
  444. package/actions/public/getLogs.ts +2 -1
  445. package/actions/wallet/sendTransaction.ts +48 -27
  446. package/actions/wallet/signMessage.ts +2 -1
  447. package/actions/wallet/signTransaction.ts +1 -2
  448. package/actions/wallet/signTypedData.ts +1 -1
  449. package/chains/definitions/bobaSepolia.ts +1 -0
  450. package/chains/definitions/cronoszkEVMTestnet.ts +21 -0
  451. package/chains/index.ts +1 -0
  452. package/clients/decorators/public.ts +1 -1
  453. package/constants/abis.ts +0 -3
  454. package/constants/address.ts +4 -0
  455. package/errors/account.ts +22 -1
  456. package/errors/contract.ts +1 -1
  457. package/errors/rpc.ts +6 -6
  458. package/errors/version.ts +1 -1
  459. package/index.ts +20 -3
  460. package/package.json +7 -1
  461. package/types/eip1193.ts +314 -2
  462. package/types/multicall.ts +1 -1
  463. package/utils/abi/parseEventLogs.ts +103 -14
  464. package/utils/buildRequest.ts +4 -2
  465. package/utils/errors/getNodeError.ts +1 -2
  466. package/utils/index.ts +6 -0
  467. package/utils/signature/hashTypedData.ts +6 -6
  468. package/utils/signature/serializeErc6492Signature.ts +17 -8
  469. package/utils/signature/serializeSignature.ts +24 -4
  470. package/utils/signature/verifyHash.ts +54 -0
@@ -0,0 +1,323 @@
1
+ import { parseAccount, } from '../../../accounts/utils/parseAccount.js';
2
+ import { estimateFeesPerGas, } from '../../../actions/public/estimateFeesPerGas.js';
3
+ import { AccountNotFoundError } from '../../../errors/account.js';
4
+ import { encodeFunctionData, } from '../../../utils/abi/encodeFunctionData.js';
5
+ import { concat } from '../../../utils/data/concat.js';
6
+ import { getAction } from '../../../utils/getAction.js';
7
+ import { parseGwei } from '../../../utils/unit/parseGwei.js';
8
+ import { getPaymasterData as getPaymasterData_, } from '../paymaster/getPaymasterData.js';
9
+ import { getPaymasterStubData as getPaymasterStubData_, } from '../paymaster/getPaymasterStubData.js';
10
+ import { estimateUserOperationGas, } from './estimateUserOperationGas.js';
11
+ const defaultParameters = [
12
+ 'factory',
13
+ 'fees',
14
+ 'gas',
15
+ 'paymaster',
16
+ 'nonce',
17
+ 'signature',
18
+ ];
19
+ /**
20
+ * Prepares a User Operation and fills in missing properties.
21
+ *
22
+ * - Docs: https://viem.sh/actions/bundler/prepareUserOperation
23
+ *
24
+ * @param args - {@link PrepareUserOperationParameters}
25
+ * @returns The User Operation. {@link PrepareUserOperationReturnType}
26
+ *
27
+ * @example
28
+ * import { createBundlerClient, http } from 'viem'
29
+ * import { toSmartAccount } from 'viem/accounts'
30
+ * import { mainnet } from 'viem/chains'
31
+ * import { prepareUserOperation } from 'viem/actions'
32
+ *
33
+ * const account = await toSmartAccount({ ... })
34
+ *
35
+ * const client = createBundlerClient({
36
+ * chain: mainnet,
37
+ * transport: http(),
38
+ * })
39
+ *
40
+ * const request = await prepareUserOperation(client, {
41
+ * account,
42
+ * calls: [{ to: '0x...', value: parseEther('1') }],
43
+ * })
44
+ */
45
+ export async function prepareUserOperation(client, parameters_) {
46
+ const parameters = parameters_;
47
+ const { account: account_ = client.account, parameters: properties = defaultParameters, } = parameters;
48
+ ////////////////////////////////////////////////////////////////////////////////
49
+ // Assert that an Account is defined.
50
+ ////////////////////////////////////////////////////////////////////////////////
51
+ if (!account_)
52
+ throw new AccountNotFoundError();
53
+ const account = parseAccount(account_);
54
+ ////////////////////////////////////////////////////////////////////////////////
55
+ // Declare typed Bundler Client.
56
+ ////////////////////////////////////////////////////////////////////////////////
57
+ const bundlerClient = client;
58
+ ////////////////////////////////////////////////////////////////////////////////
59
+ // Declare Paymaster properties.
60
+ ////////////////////////////////////////////////////////////////////////////////
61
+ const paymaster = parameters.paymaster ?? bundlerClient?.paymaster;
62
+ const paymasterAddress = typeof paymaster === 'string' ? paymaster : undefined;
63
+ const { getPaymasterStubData, getPaymasterData } = (() => {
64
+ // If `paymaster: true`, we will assume the Bundler Client supports Paymaster Actions.
65
+ if (paymaster === true)
66
+ return {
67
+ getPaymasterStubData: (parameters) => getAction(bundlerClient, getPaymasterStubData_, 'getPaymasterStubData')(parameters),
68
+ getPaymasterData: (parameters) => getAction(bundlerClient, getPaymasterData_, 'getPaymasterData')(parameters),
69
+ };
70
+ // If Actions are passed to `paymaster` (via Paymaster Client or directly), we will use them.
71
+ if (typeof paymaster === 'object') {
72
+ const { getPaymasterStubData, getPaymasterData } = paymaster;
73
+ return {
74
+ getPaymasterStubData: (getPaymasterData && getPaymasterStubData
75
+ ? getPaymasterStubData
76
+ : getPaymasterData),
77
+ getPaymasterData: getPaymasterData && getPaymasterStubData
78
+ ? getPaymasterData
79
+ : undefined,
80
+ };
81
+ }
82
+ // No Paymaster functions.
83
+ return {
84
+ getPaymasterStubData: undefined,
85
+ getPaymasterData: undefined,
86
+ };
87
+ })();
88
+ const paymasterContext = parameters.paymasterContext
89
+ ? parameters.paymasterContext
90
+ : bundlerClient?.paymasterContext;
91
+ ////////////////////////////////////////////////////////////////////////////////
92
+ // Set up the User Operation request.
93
+ ////////////////////////////////////////////////////////////////////////////////
94
+ let request = {
95
+ ...parameters,
96
+ paymaster: paymasterAddress,
97
+ sender: account.address,
98
+ };
99
+ ////////////////////////////////////////////////////////////////////////////////
100
+ // Concurrently prepare properties required to fill the User Operation.
101
+ ////////////////////////////////////////////////////////////////////////////////
102
+ const [callData, factory, fees, nonce, signature] = await Promise.all([
103
+ (async () => {
104
+ if (parameters.calls)
105
+ return account.encodeCalls(parameters.calls.map((call_) => {
106
+ const call = call_;
107
+ if ('abi' in call)
108
+ return {
109
+ data: encodeFunctionData(call),
110
+ to: call.to,
111
+ value: call.value,
112
+ };
113
+ return call;
114
+ }));
115
+ return parameters.callData;
116
+ })(),
117
+ (async () => {
118
+ if (!properties.includes('factory'))
119
+ return undefined;
120
+ if (parameters.initCode)
121
+ return { initCode: parameters.initCode };
122
+ if (parameters.factory && parameters.factoryData) {
123
+ return {
124
+ factory: parameters.factory,
125
+ factoryData: parameters.factoryData,
126
+ };
127
+ }
128
+ const { factory, factoryData } = await account.getFactoryArgs();
129
+ if (account.entryPoint.version === '0.6')
130
+ return {
131
+ initCode: factory && factoryData ? concat([factory, factoryData]) : undefined,
132
+ };
133
+ return {
134
+ factory,
135
+ factoryData,
136
+ };
137
+ })(),
138
+ (async () => {
139
+ if (!properties.includes('fees'))
140
+ return undefined;
141
+ // If the Bundler Client has a `estimateFeesPerGas` hook, run it.
142
+ if (bundlerClient?.userOperation?.estimateFeesPerGas) {
143
+ const fees = await bundlerClient.userOperation.estimateFeesPerGas({
144
+ account,
145
+ bundlerClient,
146
+ userOperation: request,
147
+ });
148
+ request = {
149
+ ...request,
150
+ ...fees,
151
+ };
152
+ }
153
+ // If we have sufficient properties for fees, return them.
154
+ if (typeof parameters.maxFeePerGas === 'bigint' &&
155
+ typeof parameters.maxPriorityFeePerGas === 'bigint')
156
+ return request;
157
+ // Otherwise, we will need to estimate the fees to fill the fee properties.
158
+ try {
159
+ const client_ = 'client' in client ? client.client : client;
160
+ const fees = await getAction(client_, estimateFeesPerGas, 'estimateFeesPerGas')({
161
+ chain: client_.chain,
162
+ type: 'eip1559',
163
+ });
164
+ return {
165
+ maxFeePerGas: typeof parameters.maxFeePerGas === 'bigint'
166
+ ? parameters.maxFeePerGas
167
+ : BigInt(
168
+ // Bundlers unfortunately have strict rules on fee prechecks – we will need to set a generous buffer.
169
+ Math.max(Number(2n * fees.maxFeePerGas), Number(parseGwei('3')))),
170
+ maxPriorityFeePerGas: typeof parameters.maxPriorityFeePerGas === 'bigint'
171
+ ? parameters.maxPriorityFeePerGas
172
+ : BigInt(
173
+ // Bundlers unfortunately have strict rules on fee prechecks – we will need to set a generous buffer.
174
+ Math.max(Number(2n * fees.maxPriorityFeePerGas), Number(parseGwei('1')))),
175
+ };
176
+ }
177
+ catch {
178
+ return undefined;
179
+ }
180
+ })(),
181
+ (async () => {
182
+ if (!properties.includes('nonce'))
183
+ return undefined;
184
+ if (typeof parameters.nonce === 'bigint')
185
+ return parameters.nonce;
186
+ return account.getNonce();
187
+ })(),
188
+ (async () => {
189
+ if (!properties.includes('signature'))
190
+ return undefined;
191
+ return account.getStubSignature();
192
+ })(),
193
+ ]);
194
+ ////////////////////////////////////////////////////////////////////////////////
195
+ // Fill User Operation with the prepared properties from above.
196
+ ////////////////////////////////////////////////////////////////////////////////
197
+ if (typeof callData !== 'undefined')
198
+ request.callData = callData;
199
+ if (typeof factory !== 'undefined')
200
+ request = { ...request, ...factory };
201
+ if (typeof fees !== 'undefined')
202
+ request = { ...request, ...fees };
203
+ if (typeof nonce !== 'undefined')
204
+ request.nonce = nonce;
205
+ if (typeof signature !== 'undefined')
206
+ request.signature = signature;
207
+ ////////////////////////////////////////////////////////////////////////////////
208
+ // `initCode` is required to be filled with EntryPoint 0.6.
209
+ ////////////////////////////////////////////////////////////////////////////////
210
+ // If no `initCode` is provided, we use an empty bytes string.
211
+ if (account.entryPoint.version === '0.6' && !request.initCode)
212
+ request.initCode = '0x';
213
+ ////////////////////////////////////////////////////////////////////////////////
214
+ // Fill User Operation with paymaster-related properties for **gas estimation**.
215
+ ////////////////////////////////////////////////////////////////////////////////
216
+ // console.log('wat')
217
+ // If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
218
+ // User Operation properties required to estimate the User Operation gas.
219
+ let isPaymasterPopulated = false;
220
+ if (properties.includes('paymaster') &&
221
+ getPaymasterStubData &&
222
+ !paymasterAddress &&
223
+ !parameters.paymasterAndData) {
224
+ const { isFinal = false, sponsor, ...paymasterArgs } = await getPaymasterStubData({
225
+ chainId: client.chain.id,
226
+ entryPointAddress: account.entryPoint.address,
227
+ context: paymasterContext,
228
+ ...request,
229
+ });
230
+ isPaymasterPopulated = isFinal;
231
+ request = {
232
+ ...request,
233
+ ...paymasterArgs,
234
+ };
235
+ }
236
+ ////////////////////////////////////////////////////////////////////////////////
237
+ // `paymasterAndData` is required to be filled with EntryPoint 0.6.
238
+ ////////////////////////////////////////////////////////////////////////////////
239
+ // If no `paymasterAndData` is provided, we use an empty bytes string.
240
+ if (account.entryPoint.version === '0.6' && !request.paymasterAndData)
241
+ request.paymasterAndData = '0x';
242
+ ////////////////////////////////////////////////////////////////////////////////
243
+ // Fill User Operation with gas-related properties.
244
+ ////////////////////////////////////////////////////////////////////////////////
245
+ if (properties.includes('gas')) {
246
+ // If the Account has opinionated gas estimation logic, run the `estimateGas` hook and
247
+ // fill the request with the prepared gas properties.
248
+ if (account.userOperation?.estimateGas) {
249
+ const gas = await account.userOperation.estimateGas(request);
250
+ request = {
251
+ ...request,
252
+ ...gas,
253
+ };
254
+ }
255
+ // If not all the gas properties are already populated, we will need to estimate the gas
256
+ // to fill the gas properties.
257
+ if (typeof request.callGasLimit === 'undefined' ||
258
+ typeof request.preVerificationGas === 'undefined' ||
259
+ typeof request.verificationGasLimit === 'undefined' ||
260
+ (request.paymaster &&
261
+ typeof request.paymasterPostOpGasLimit === 'undefined') ||
262
+ (request.paymaster &&
263
+ typeof request.paymasterVerificationGasLimit === 'undefined')) {
264
+ const gas = await getAction(client, estimateUserOperationGas, 'estimateUserOperationGas')({
265
+ account,
266
+ // Some Bundlers fail if nullish gas values are provided for gas estimation :') –
267
+ // so we will need to set a default zeroish value.
268
+ callGasLimit: 0n,
269
+ preVerificationGas: 0n,
270
+ verificationGasLimit: 0n,
271
+ ...(request.paymaster
272
+ ? {
273
+ paymasterPostOpGasLimit: 0n,
274
+ paymasterVerificationGasLimit: 0n,
275
+ }
276
+ : {}),
277
+ ...request,
278
+ });
279
+ request = {
280
+ ...request,
281
+ callGasLimit: request.callGasLimit ?? gas.callGasLimit,
282
+ preVerificationGas: request.preVerificationGas ?? gas.preVerificationGas,
283
+ verificationGasLimit: request.verificationGasLimit ?? gas.verificationGasLimit,
284
+ paymasterPostOpGasLimit: request.paymasterPostOpGasLimit ?? gas.paymasterPostOpGasLimit,
285
+ paymasterVerificationGasLimit: request.paymasterVerificationGasLimit ??
286
+ gas.paymasterVerificationGasLimit,
287
+ };
288
+ }
289
+ }
290
+ ////////////////////////////////////////////////////////////////////////////////
291
+ // Fill User Operation with paymaster-related properties for **sending** the User Operation.
292
+ ////////////////////////////////////////////////////////////////////////////////
293
+ // If the User Operation is intended to be sponsored, we will need to fill the paymaster-related
294
+ // User Operation properties required to send the User Operation.
295
+ if (properties.includes('paymaster') &&
296
+ getPaymasterData &&
297
+ !paymasterAddress &&
298
+ !parameters.paymasterAndData &&
299
+ !isPaymasterPopulated) {
300
+ // Retrieve paymaster-related User Operation properties to be used for **sending** the User Operation.
301
+ const paymaster = await getPaymasterData({
302
+ chainId: client.chain.id,
303
+ entryPointAddress: account.entryPoint.address,
304
+ context: paymasterContext,
305
+ ...request,
306
+ });
307
+ request = {
308
+ ...request,
309
+ ...paymaster,
310
+ };
311
+ }
312
+ ////////////////////////////////////////////////////////////////////////////////
313
+ // Remove redundant properties that do not conform to the User Operation schema.
314
+ ////////////////////////////////////////////////////////////////////////////////
315
+ delete request.calls;
316
+ delete request.parameters;
317
+ delete request.paymasterContext;
318
+ if (typeof request.paymaster !== 'string')
319
+ delete request.paymaster;
320
+ ////////////////////////////////////////////////////////////////////////////////
321
+ return request;
322
+ }
323
+ //# sourceMappingURL=prepareUserOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareUserOperation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../../accounts/utils/parseAccount.js';
2
+ import { AccountNotFoundError } from '../../../errors/account.js';
3
+ import { getAction } from '../../../utils/getAction.js';
4
+ import { getUserOperationError } from '../../utils/errors/getUserOperationError.js';
5
+ import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
6
+ import { prepareUserOperation, } from './prepareUserOperation.js';
7
+ /**
8
+ * Broadcasts a User Operation to the Bundler.
9
+ *
10
+ * - Docs: https://viem.sh/actions/bundler/sendUserOperation
11
+ *
12
+ * @param client - Client to use
13
+ * @param parameters - {@link SendUserOperationParameters}
14
+ * @returns The User Operation hash. {@link SendUserOperationReturnType}
15
+ *
16
+ * @example
17
+ * import { createBundlerClient, http, parseEther } from 'viem'
18
+ * import { mainnet } from 'viem/chains'
19
+ * import { toSmartAccount } from 'viem/accounts'
20
+ * import { sendUserOperation } from 'viem/actions'
21
+ *
22
+ * const account = await toSmartAccount({ ... })
23
+ *
24
+ * const bundlerClient = createBundlerClient({
25
+ * chain: mainnet,
26
+ * transport: http(),
27
+ * })
28
+ *
29
+ * const values = await sendUserOperation(bundlerClient, {
30
+ * account,
31
+ * calls: [{ to: '0x...', value: parseEther('1') }],
32
+ * })
33
+ */
34
+ export async function sendUserOperation(client, parameters) {
35
+ const { account: account_ = client.account } = parameters;
36
+ if (!account_)
37
+ throw new AccountNotFoundError();
38
+ const account = parseAccount(account_);
39
+ const request = await getAction(client, prepareUserOperation, 'prepareUserOperation')(parameters);
40
+ const signature = parameters.signature ||
41
+ (await account.signUserOperation(request));
42
+ const rpcParameters = formatUserOperationRequest({
43
+ ...request,
44
+ signature,
45
+ });
46
+ try {
47
+ return await client.request({
48
+ method: 'eth_sendUserOperation',
49
+ params: [rpcParameters, account.entryPoint.address],
50
+ }, { retryCount: 0 });
51
+ }
52
+ catch (error) {
53
+ throw getUserOperationError(error, {
54
+ ...request,
55
+ calls: parameters.calls,
56
+ signature,
57
+ });
58
+ }
59
+ }
60
+ //# sourceMappingURL=sendUserOperation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sendUserOperation.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/sendUserOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAA;AAGtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAOjE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAgBvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AACnF,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AACvD,OAAO,EAGL,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AA0ClC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAKrC,MAAqD,EACrD,UAAwE;IAExE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,GAAG,UAAU,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,oBAAoB,EAAE,CAAA;IAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAA;IAEtC,MAAM,OAAO,GAAG,MAAM,SAAS,CAC7B,MAAM,EACN,oBAAoB,EACpB,sBAAsB,CACvB,CAAC,UAAuD,CAAC,CAAA;IAE1D,MAAM,SAAS,GACb,UAAU,CAAC,SAAS;QACpB,CAAC,MAAM,OAAO,CAAC,iBAAiB,CAAC,OAAwB,CAAC,CAAC,CAAA;IAE7D,MAAM,aAAa,GAAG,0BAA0B,CAAC;QAC/C,GAAG,OAAO;QACV,SAAS;KACO,CAAC,CAAA;IAEnB,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,OAAO,CACzB;YACE,MAAM,EAAE,uBAAuB;YAC/B,MAAM,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;SACpD,EACD,EAAE,UAAU,EAAE,CAAC,EAAE,CAClB,CAAA;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,qBAAqB,CAAC,KAAkB,EAAE;YAC9C,GAAI,OAAyB;YAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,SAAS;SACV,CAAC,CAAA;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { getAction } from '../../../utils/getAction.js';
2
+ import { observe } from '../../../utils/observe.js';
3
+ import { poll } from '../../../utils/poll.js';
4
+ import { stringify } from '../../../utils/stringify.js';
5
+ import { WaitForUserOperationReceiptTimeoutError, } from '../../errors/userOperation.js';
6
+ import { getUserOperationReceipt, } from './getUserOperationReceipt.js';
7
+ /**
8
+ * Waits for the User Operation to be included on a [Block](https://viem.sh/docs/glossary/terms#block) (one confirmation), and then returns the User Operation receipt.
9
+ *
10
+ * - Docs: https://viem.sh/docs/actions/bundler/waitForUserOperationReceipt
11
+ *
12
+ * @param client - Client to use
13
+ * @param parameters - {@link WaitForUserOperationReceiptParameters}
14
+ * @returns The receipt. {@link WaitForUserOperationReceiptReturnType}
15
+ *
16
+ * @example
17
+ * import { createBundlerClient, http } from 'viem'
18
+ * import { mainnet } from 'viem/chains'
19
+ * import { waitForUserOperationReceipt } from 'viem/actions'
20
+ *
21
+ * const client = createBundlerClient({
22
+ * chain: mainnet,
23
+ * transport: http(),
24
+ * })
25
+ *
26
+ * const receipt = await waitForUserOperationReceipt(client, {
27
+ * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',
28
+ * })
29
+ */
30
+ export function waitForUserOperationReceipt(client, parameters) {
31
+ const { hash, pollingInterval = client.pollingInterval, retryCount, timeout = 120_000, } = parameters;
32
+ let count = 0;
33
+ const observerId = stringify([
34
+ 'waitForUserOperationReceipt',
35
+ client.uid,
36
+ hash,
37
+ ]);
38
+ return new Promise((resolve, reject) => {
39
+ const unobserve = observe(observerId, { resolve, reject }, (emit) => {
40
+ const done = (fn) => {
41
+ unpoll();
42
+ fn();
43
+ unobserve();
44
+ };
45
+ const unpoll = poll(async () => {
46
+ if (retryCount && count >= retryCount)
47
+ done(() => emit.reject(new WaitForUserOperationReceiptTimeoutError({ hash })));
48
+ try {
49
+ const receipt = await getAction(client, getUserOperationReceipt, 'getUserOperationReceipt')({ hash });
50
+ done(() => emit.resolve(receipt));
51
+ }
52
+ catch (err) {
53
+ const error = err;
54
+ if (error.name !== 'UserOperationReceiptNotFoundError')
55
+ done(() => emit.reject(error));
56
+ }
57
+ count++;
58
+ }, {
59
+ emitOnBegin: true,
60
+ interval: pollingInterval,
61
+ });
62
+ if (timeout)
63
+ setTimeout(() => done(() => emit.reject(new WaitForUserOperationReceiptTimeoutError({ hash }))), timeout);
64
+ return unpoll;
65
+ });
66
+ });
67
+ }
68
+ //# sourceMappingURL=waitForUserOperationReceipt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"waitForUserOperationReceipt.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/bundler/waitForUserOperationReceipt.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EAAyB,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAC1E,OAAO,EAAsB,IAAI,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACvD,OAAO,EACL,uCAAuC,GAExC,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EAEL,uBAAuB,GACxB,MAAM,8BAA8B,CAAA;AA4BrC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAAyB,EACzB,UAAiD;IAEjD,MAAM,EACJ,IAAI,EACJ,eAAe,GAAG,MAAM,CAAC,eAAe,EACxC,UAAU,EACV,OAAO,GAAG,OAAO,GAClB,GAAG,UAAU,CAAA;IAEd,IAAI,KAAK,GAAG,CAAC,CAAA;IAC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AE,CACH,IAAI,CAAC,GAAG,EAAE,CACR,IAAI,CAAC,MAAM,CACT,IAAI,uCAAuC,CAAC,EAAE,IAAI,EAAE,CAAC,CACtD,CACF,EACH,OAAO,CACR,CAAA;YAEH,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { hexToBigInt } from '../../../utils/encoding/fromHex.js';
2
+ import { numberToHex } from '../../../utils/encoding/toHex.js';
3
+ import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
4
+ /**
5
+ * Retrieves paymaster-related User Operation properties to be used for sending the User Operation.
6
+ *
7
+ * - Docs: https://viem.sh/account-abstraction/actions/paymaster/getPaymasterData
8
+ *
9
+ * @param client - Client to use
10
+ * @param parameters - {@link GetPaymasterDataParameters}
11
+ * @returns Paymaster-related User Operation properties. {@link GetPaymasterDataReturnType}
12
+ *
13
+ * @example
14
+ * import { http } from 'viem'
15
+ * import { createPaymasterClient, getPaymasterData } from 'viem/account-abstraction'
16
+ *
17
+ * const paymasterClient = createPaymasterClient({
18
+ * transport: http('https://...'),
19
+ * })
20
+ *
21
+ * const userOperation = { ... }
22
+ *
23
+ * const values = await getPaymasterData(paymasterClient, {
24
+ * chainId: 1,
25
+ * entryPointAddress: '0x...',
26
+ * ...userOperation,
27
+ * })
28
+ */
29
+ export async function getPaymasterData(client, parameters) {
30
+ const { chainId, entryPointAddress, context, ...userOperation } = parameters;
31
+ const request = formatUserOperationRequest(userOperation);
32
+ const { paymasterPostOpGasLimit, paymasterVerificationGasLimit, ...rest } = await client.request({
33
+ method: 'pm_getPaymasterData',
34
+ params: [
35
+ {
36
+ ...request,
37
+ callGasLimit: request.callGasLimit ?? '0x0',
38
+ verificationGasLimit: request.verificationGasLimit ?? '0x0',
39
+ preVerificationGas: request.preVerificationGas ?? '0x0',
40
+ },
41
+ entryPointAddress,
42
+ numberToHex(chainId),
43
+ context,
44
+ ],
45
+ });
46
+ return {
47
+ ...rest,
48
+ ...(paymasterPostOpGasLimit && {
49
+ paymasterPostOpGasLimit: hexToBigInt(paymasterPostOpGasLimit),
50
+ }),
51
+ ...(paymasterVerificationGasLimit && {
52
+ paymasterVerificationGasLimit: hexToBigInt(paymasterVerificationGasLimit),
53
+ }),
54
+ };
55
+ }
56
+ //# sourceMappingURL=getPaymasterData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPaymasterData.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/paymaster/getPaymasterData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAE9D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AAmEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAyB,EACzB,UAAsC;IAEtC,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,CAAA;IAC5E,MAAM,OAAO,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAA;IACzD,MAAM,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,GAAG,IAAI,EAAE,GACvE,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,qBAAqB;QAC7B,MAAM,EAAE;YACN;gBACE,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;gBAC3C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;gBAC3D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;aACxD;YACD,iBAAiB;YACjB,WAAW,CAAC,OAAO,CAAC;YACpB,OAAO;SACR;KACF,CAAC,CAAA;IACJ,OAAO;QACL,GAAG,IAAI;QACP,GAAG,CAAC,uBAAuB,IAAI;YAC7B,uBAAuB,EAAE,WAAW,CAAC,uBAAuB,CAAC;SAC9D,CAAC;QACF,GAAG,CAAC,6BAA6B,IAAI;YACnC,6BAA6B,EAAE,WAAW,CAAC,6BAA6B,CAAC;SAC1E,CAAC;KACsC,CAAA;AAC5C,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { hexToBigInt } from '../../../utils/encoding/fromHex.js';
2
+ import { numberToHex } from '../../../utils/encoding/toHex.js';
3
+ import { formatUserOperationRequest, } from '../../utils/formatters/userOperationRequest.js';
4
+ /**
5
+ * Retrieves paymaster-related User Operation properties to be used for gas estimation.
6
+ *
7
+ * - Docs: https://viem.sh/account-abstraction/actions/paymaster/getPaymasterStubData
8
+ *
9
+ * @param client - Client to use
10
+ * @param parameters - {@link GetPaymasterStubDataParameters}
11
+ * @returns Paymaster-related User Operation properties. {@link GetPaymasterStubDataReturnType}
12
+ *
13
+ * @example
14
+ * import { http } from 'viem'
15
+ * import { createPaymasterClient, getPaymasterStubData } from 'viem/account-abstraction'
16
+ *
17
+ * const paymasterClient = createPaymasterClient({
18
+ * transport: http('https://...'),
19
+ * })
20
+ *
21
+ * const userOperation = { ... }
22
+ *
23
+ * const values = await getPaymasterStubData(paymasterClient, {
24
+ * chainId: 1,
25
+ * entryPointAddress: '0x...',
26
+ * ...userOperation,
27
+ * })
28
+ */
29
+ export async function getPaymasterStubData(client, parameters) {
30
+ const { chainId, entryPointAddress, context, ...userOperation } = parameters;
31
+ const request = formatUserOperationRequest(userOperation);
32
+ const { paymasterPostOpGasLimit, paymasterVerificationGasLimit, ...rest } = await client.request({
33
+ method: 'pm_getPaymasterStubData',
34
+ params: [
35
+ {
36
+ ...request,
37
+ callGasLimit: request.callGasLimit ?? '0x0',
38
+ verificationGasLimit: request.verificationGasLimit ?? '0x0',
39
+ preVerificationGas: request.preVerificationGas ?? '0x0',
40
+ },
41
+ entryPointAddress,
42
+ numberToHex(chainId),
43
+ context,
44
+ ],
45
+ });
46
+ return {
47
+ ...rest,
48
+ ...(paymasterPostOpGasLimit && {
49
+ paymasterPostOpGasLimit: hexToBigInt(paymasterPostOpGasLimit),
50
+ }),
51
+ ...(paymasterVerificationGasLimit && {
52
+ paymasterVerificationGasLimit: hexToBigInt(paymasterVerificationGasLimit),
53
+ }),
54
+ };
55
+ }
56
+ //# sourceMappingURL=getPaymasterStubData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPaymasterStubData.js","sourceRoot":"","sources":["../../../../account-abstraction/actions/paymaster/getPaymasterStubData.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAE9D,OAAO,EAEL,0BAA0B,GAC3B,MAAM,gDAAgD,CAAA;AAsEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAyB,EACzB,UAA0C;IAE1C,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,GAAG,UAAU,CAAA;IAC5E,MAAM,OAAO,GAAG,0BAA0B,CAAC,aAAa,CAAC,CAAA;IACzD,MAAM,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,GAAG,IAAI,EAAE,GACvE,MAAM,MAAM,CAAC,OAAO,CAAC;QACnB,MAAM,EAAE,yBAAyB;QACjC,MAAM,EAAE;YACN;gBACE,GAAG,OAAO;gBACV,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;gBAC3C,oBAAoB,EAAE,OAAO,CAAC,oBAAoB,IAAI,KAAK;gBAC3D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,KAAK;aACxD;YACD,iBAAiB;YACjB,WAAW,CAAC,OAAO,CAAC;YACpB,OAAO;SACR;KACF,CAAC,CAAA;IACJ,OAAO;QACL,GAAG,IAAI;QACP,GAAG,CAAC,uBAAuB,IAAI;YAC7B,uBAAuB,EAAE,WAAW,CAAC,uBAAuB,CAAC;SAC9D,CAAC;QACF,GAAG,CAAC,6BAA6B,IAAI;YACnC,6BAA6B,EAAE,WAAW,CAAC,6BAA6B,CAAC;SAC1E,CAAC;KAC0C,CAAA;AAChD,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { createClient, } from '../../clients/createClient.js';
2
+ import { bundlerActions } from './decorators/bundler.js';
3
+ export function createBundlerClient(parameters) {
4
+ const { client: client_, key = 'bundler', name = 'Bundler Client', paymaster, paymasterContext, transport, userOperation, } = parameters;
5
+ const client = Object.assign(createClient({
6
+ ...parameters,
7
+ chain: parameters.chain ?? client_?.chain,
8
+ key,
9
+ name,
10
+ transport,
11
+ type: 'bundlerClient',
12
+ }), { client: client_, paymaster, paymasterContext, userOperation });
13
+ return client.extend(bundlerActions);
14
+ }
15
+ //# sourceMappingURL=createBundlerClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBundlerClient.js","sourceRoot":"","sources":["../../../account-abstraction/clients/createBundlerClient.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,YAAY,GACb,MAAM,+BAA+B,CAAA;AAStC,OAAO,EAAuB,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAmH7E,MAAM,UAAU,mBAAmB,CACjC,UAA+B;IAE/B,MAAM,EACJ,MAAM,EAAE,OAAO,EACf,GAAG,GAAG,SAAS,EACf,IAAI,GAAG,gBAAgB,EACvB,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,aAAa,GACd,GAAG,UAAU,CAAA;IACd,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,YAAY,CAAC;QACX,GAAG,UAAU;QACb,KAAK,EAAE,UAAU,CAAC,KAAK,IAAI,OAAO,EAAE,KAAK;QACzC,GAAG;QACH,IAAI;QACJ,SAAS;QACT,IAAI,EAAE,eAAe;KACtB,CAAC,EACF,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,CAChE,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAQ,CAAA;AAC7C,CAAC"}