@powerhousedao/connect 1.0.0-dev.221 → 1.0.0-dev.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/dist/assets/ArrowFilledRight-64XHqK_h.js +7 -0
  2. package/dist/assets/ArrowLeft-cTTfZFZ1.js +7 -0
  3. package/dist/assets/ArrowUp-DZrDe-Bp.js +7 -0
  4. package/dist/assets/BarChart-DT4puBXm.js +7 -0
  5. package/dist/assets/BaseArrowLeft-G433oBpP.js +7 -0
  6. package/dist/assets/BaseArrowRight-cpxwDGIe.js +7 -0
  7. package/dist/assets/Braces-CJktWttT.js +7 -0
  8. package/dist/assets/Branch-iPu-a2T3.js +7 -0
  9. package/dist/assets/BrickGlobe-BZrrYdL4.js +7 -0
  10. package/dist/assets/Briefcase-XpuJYuUR.js +7 -0
  11. package/dist/assets/Calendar-Dt0VwGrR.js +7 -0
  12. package/dist/assets/CalendarTime-CwwzsmKX.js +7 -0
  13. package/dist/assets/Caret-ZEgiNBNU.js +7 -0
  14. package/dist/assets/CaretDown-DP6bOwI2.js +7 -0
  15. package/dist/assets/CaretLeft-BD_N0UUw.js +7 -0
  16. package/dist/assets/CaretRight-DWPoTF9X.js +7 -0
  17. package/dist/assets/CaretSort-Bw0XHsjI.js +7 -0
  18. package/dist/assets/Check-cqhfhLxP.js +7 -0
  19. package/dist/assets/CheckCircle-DH9iEyZM.js +7 -0
  20. package/dist/assets/CheckCircleFill-DXFYGKQ5.js +7 -0
  21. package/dist/assets/Checkmark-9n4byVGp.js +7 -0
  22. package/dist/assets/ChevronDown-DvTsRsq2.js +7 -0
  23. package/dist/assets/Circle-B2Lns-7w.js +7 -0
  24. package/dist/assets/CircleInfo-1kjSg19s.js +7 -0
  25. package/dist/assets/Clock-BGRQRM60.js +7 -0
  26. package/dist/assets/ClockFill-Bvmknv7u.js +7 -0
  27. package/dist/assets/CloudSlash-DPvYwLm3.js +7 -0
  28. package/dist/assets/Collapse-D5jXkhQz.js +7 -0
  29. package/dist/assets/Connect-DZiPc2IO.js +7 -0
  30. package/dist/assets/ConnectSmall-C4hYVYQO.js +7 -0
  31. package/dist/assets/Copy-CoVU9BJY.js +7 -0
  32. package/dist/assets/Created-DzIi8Oqs.js +7 -0
  33. package/dist/assets/CrossCircle-Cz9Xbcsr.js +7 -0
  34. package/dist/assets/Danger-DkDnPFWT.js +7 -0
  35. package/dist/assets/Discord-C9rQaS93.js +7 -0
  36. package/dist/assets/Drive-gptzvasW.js +7 -0
  37. package/dist/assets/Duplicated-C2v6xG93.js +7 -0
  38. package/dist/assets/Edit-BWdYDo8C.js +7 -0
  39. package/dist/assets/Ellipsis-_Yp_-wDZ.js +7 -0
  40. package/dist/assets/Error-Bf2pG8sD.js +7 -0
  41. package/dist/assets/Exclamation-DLUhwcPI.js +7 -0
  42. package/dist/assets/File-C3wkPB_r.js +7 -0
  43. package/dist/assets/FilesEarmark-CgUelQay.js +7 -0
  44. package/dist/assets/FolderClose-BvAQd6IG.js +7 -0
  45. package/dist/assets/FolderOpen-Bma1Ngbb.js +7 -0
  46. package/dist/assets/FolderPlus-Dn00AVa8.js +7 -0
  47. package/dist/assets/Forum-C-dTIstS.js +7 -0
  48. package/dist/assets/Gear-B58aepsd.js +7 -0
  49. package/dist/assets/Github-YaYviWSS.js +7 -0
  50. package/dist/assets/Globe-BGlyCRpD.js +7 -0
  51. package/dist/assets/GlobeWww-B1pUKxRP.js +7 -0
  52. package/dist/assets/Hdd-Bk7BpLL-.js +7 -0
  53. package/dist/assets/History-CDfNjY3P.js +7 -0
  54. package/dist/assets/InfoSquare-CLtlquCL.js +7 -0
  55. package/dist/assets/Link-BHshUK_k.js +7 -0
  56. package/dist/assets/Linkedin-BSk0sey6.js +7 -0
  57. package/dist/assets/Lock-BFCeokdp.js +7 -0
  58. package/dist/assets/M-V6iG_x6o.js +7 -0
  59. package/dist/assets/Modified-D04FuhUt.js +7 -0
  60. package/dist/assets/Moved-D3mS-uot.js +7 -0
  61. package/dist/assets/PackageManager-1Wpl0DVS.js +7 -0
  62. package/dist/assets/Pencil-aiwjx26f.js +7 -0
  63. package/dist/assets/People-CgDbL4kS.js +7 -0
  64. package/dist/assets/PeopleFill-CUgqKMA4.js +7 -0
  65. package/dist/assets/Person-B0cfH7KV.js +7 -0
  66. package/dist/assets/Pin-CeMtNsZD.js +7 -0
  67. package/dist/assets/PinFilled-DsQqlbF3.js +7 -0
  68. package/dist/assets/Plus-CtnpCWqG.js +7 -0
  69. package/dist/assets/PlusCircle-BOEotEGi.js +7 -0
  70. package/dist/assets/PlusSquare-fWkZh3-r.js +7 -0
  71. package/dist/assets/PowerhouseLogoSmall-CgaHbPzx.js +7 -0
  72. package/dist/assets/Project-D33G_Tlb.js +7 -0
  73. package/dist/assets/QuestionSquare-Cilqw-NF.js +7 -0
  74. package/dist/assets/RedoArrow-BZg6K-nT.js +7 -0
  75. package/dist/assets/Reload-DSYHnfCV.js +7 -0
  76. package/dist/assets/Removed-B35cyBgu.js +7 -0
  77. package/dist/assets/Renown-DdF-DRzW.js +7 -0
  78. package/dist/assets/RenownHover-ayMKqS2y.js +7 -0
  79. package/dist/assets/Ring-DDC_wea5.js +7 -0
  80. package/dist/assets/Save-BqsDjvWT.js +7 -0
  81. package/dist/assets/Search-BmJu6qh2.js +7 -0
  82. package/dist/assets/Server-BsTH0P96.js +7 -0
  83. package/dist/assets/Settings-wzKf1ItW.js +7 -0
  84. package/dist/assets/Synced-BREnp3Gk.js +7 -0
  85. package/dist/assets/Syncing-oLFcuSQr.js +7 -0
  86. package/dist/assets/Tabler-Dd4wGhvu.js +7 -0
  87. package/dist/assets/Trash-C2Az1OA8.js +7 -0
  88. package/dist/assets/TrashFill-Cop-3QYY.js +7 -0
  89. package/dist/assets/TreeViewSlash-C5vFO1Yq.js +7 -0
  90. package/dist/assets/TriangleDown-BJdJslsa.js +7 -0
  91. package/dist/assets/VariantArrowLeft-DfAacH04.js +7 -0
  92. package/dist/assets/VerticalDots-B4dDMl7Z.js +7 -0
  93. package/dist/assets/WarningFill-Drxpmg7X.js +7 -0
  94. package/dist/assets/XTwitter-C0dxLb5W.js +7 -0
  95. package/dist/assets/Xmark-DZtv823K.js +7 -0
  96. package/dist/assets/XmarkLight-BYzxLa1T.js +7 -0
  97. package/dist/assets/Youtube-DnhnDSfB.js +7 -0
  98. package/dist/assets/{app-B8nf-deX.js → app-CTigHfYe.js} +58836 -60638
  99. package/dist/assets/app-Cln9uYMI.css +1242 -0
  100. package/dist/assets/app-loader-BY0bGSIq.css +5397 -0
  101. package/dist/assets/app-loader-DyNwL34W.js +31007 -0
  102. package/dist/assets/{ccip-BLPIQK-p.js → ccip-H9r68nMy.js} +8 -5
  103. package/dist/assets/connect-loader-CvOC68Ih.mp4 +0 -0
  104. package/dist/assets/content-DKRyIOSC.js +3909 -0
  105. package/dist/assets/home-bg-BEhF9NuW.png +0 -0
  106. package/dist/assets/{index-C6rLvt8a.js → index-1eSbLJ8N.js} +278 -41
  107. package/dist/assets/{index-DWpJ5RMK.js → index-ClLjsnWF.js} +3 -3
  108. package/dist/assets/{index-BGTpM-hv.js → index-U2JOCFbk.js} +4 -7
  109. package/dist/assets/{main.Bikg5D0d.js → main.DW-SDHrh.js} +1 -1
  110. package/dist/assets/powerhouse-rounded-CeKGGUG4.png +0 -0
  111. package/dist/assets/renown-short-hover-BiSLBV7L.png +0 -0
  112. package/dist/assets/rwa-report-Bb0W5-ac.png +0 -0
  113. package/dist/assets/style-CQ-MDl3w.css +1662 -0
  114. package/dist/assets/types-b4BfZ8ti.js +102 -0
  115. package/dist/hmr.js +1 -8
  116. package/dist/index.html +6 -6
  117. package/dist/modules/@powerhousedao/reactor-browser/{chunk-7K3IYNHM.js → chunk-AF3TNTAG.js} +1 -1
  118. package/dist/modules/@powerhousedao/reactor-browser/{chunk-2JKTZCPP.js → chunk-IFKFX4E7.js} +1 -1
  119. package/dist/modules/@powerhousedao/reactor-browser/{chunk-22MXJF6S.js → chunk-KDBDV2ML.js} +1 -1
  120. package/dist/modules/@powerhousedao/reactor-browser/{chunk-LX4MYGDV.js → chunk-OS3WZ4EZ.js} +1 -1
  121. package/dist/modules/@powerhousedao/reactor-browser/{chunk-QDQLULSM.js → chunk-YBWJLG4N.js} +1 -1
  122. package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
  123. package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
  124. package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +3 -3
  125. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
  126. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
  127. package/dist/modules/@powerhousedao/reactor-browser/index.js +5 -5
  128. package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
  129. package/dist/vite-envs.sh +1 -1
  130. package/package.json +22 -21
  131. package/scripts/install-packages.js +9 -0
  132. package/dist/assets/ArrowFilledRight-DR0hNbwn.js +0 -7
  133. package/dist/assets/ArrowLeft-B0Xj8PvP.js +0 -15
  134. package/dist/assets/ArrowUp-CwtCJqy6.js +0 -7
  135. package/dist/assets/BarChart-nVfxphhs.js +0 -7
  136. package/dist/assets/BaseArrowLeft-C8cn--_E.js +0 -7
  137. package/dist/assets/BaseArrowRight-D3q0C2-y.js +0 -7
  138. package/dist/assets/Braces-B9gXulWt.js +0 -17
  139. package/dist/assets/Branch-DWau4RYZ.js +0 -7
  140. package/dist/assets/BrickGlobe-Dz0dBSi2.js +0 -7
  141. package/dist/assets/Briefcase-CvO1rhlH.js +0 -7
  142. package/dist/assets/Calendar-BUcLO8hE.js +0 -7
  143. package/dist/assets/CalendarTime-DPWILM_L.js +0 -27
  144. package/dist/assets/Caret-DhnOHiAk.js +0 -7
  145. package/dist/assets/CaretDown-Dlfvehxg.js +0 -14
  146. package/dist/assets/CaretLeft-a4NLMV88.js +0 -27
  147. package/dist/assets/CaretRight-B5YZKpzX.js +0 -27
  148. package/dist/assets/CaretSort-Ct9KtNAH.js +0 -14
  149. package/dist/assets/Check-DFFCZvyb.js +0 -7
  150. package/dist/assets/CheckCircle-D0cadyWB.js +0 -23
  151. package/dist/assets/CheckCircleFill-D9omvoi2.js +0 -7
  152. package/dist/assets/Checkmark-B9Fhan_U.js +0 -14
  153. package/dist/assets/ChevronDown-C2q5ewWu.js +0 -15
  154. package/dist/assets/Circle-DvbXQBRR.js +0 -7
  155. package/dist/assets/CircleInfo-B-ZX0ilU.js +0 -40
  156. package/dist/assets/Clock-DZfefmeN.js +0 -26
  157. package/dist/assets/ClockFill-CABo21fb.js +0 -7
  158. package/dist/assets/CloudSlash-CMWY3Yiz.js +0 -7
  159. package/dist/assets/Collapse-B6so4C4x.js +0 -7
  160. package/dist/assets/Connect-BwTXbdDU.js +0 -16
  161. package/dist/assets/ConnectSmall-QnqlDdXI.js +0 -24
  162. package/dist/assets/Copy-B6zR-spv.js +0 -14
  163. package/dist/assets/Created-DFpCpnA0.js +0 -30
  164. package/dist/assets/CrossCircle-CqWwlop8.js +0 -27
  165. package/dist/assets/Danger-pz0IZ9ht.js +0 -18
  166. package/dist/assets/Discord-BBOYl-Cv.js +0 -31
  167. package/dist/assets/Drive-U3vNMpII.js +0 -7
  168. package/dist/assets/Duplicated-8BQyTQTq.js +0 -39
  169. package/dist/assets/Edit-Csq3Kjo4.js +0 -17
  170. package/dist/assets/Ellipsis-9SpKcRLu.js +0 -7
  171. package/dist/assets/Error-Aw8n4vvA.js +0 -7
  172. package/dist/assets/Exclamation-BrTZuGoh.js +0 -10
  173. package/dist/assets/File-CZLnU7sR.js +0 -24
  174. package/dist/assets/FilesEarmark-BFvgl_Tg.js +0 -7
  175. package/dist/assets/FolderClose-CKAhNitU.js +0 -13
  176. package/dist/assets/FolderOpen-BeUyXyGp.js +0 -7
  177. package/dist/assets/FolderPlus-vsjvCtD1.js +0 -7
  178. package/dist/assets/Forum-D9m-5WTT.js +0 -22
  179. package/dist/assets/Gear-yPrII5SD.js +0 -7
  180. package/dist/assets/Github-CD-46ylo.js +0 -24
  181. package/dist/assets/Globe-31ZjNNZd.js +0 -7
  182. package/dist/assets/GlobeWww-NUl-mssK.js +0 -22
  183. package/dist/assets/Hdd-iEstELlC.js +0 -7
  184. package/dist/assets/History-Bqbk20Zf.js +0 -7
  185. package/dist/assets/InfoSquare-PvIdwYp_.js +0 -7
  186. package/dist/assets/Link-CkpgSxML.js +0 -14
  187. package/dist/assets/Linkedin-CwtjXXnu.js +0 -22
  188. package/dist/assets/Lock-iwF_5hIn.js +0 -7
  189. package/dist/assets/M-JPfHvUlx.js +0 -22
  190. package/dist/assets/Modified-DJa3zTii.js +0 -29
  191. package/dist/assets/Moved-Bj3ueg6N.js +0 -42
  192. package/dist/assets/PackageManager-ByYYO-CH.js +0 -17
  193. package/dist/assets/Pencil-B5DNXkv2.js +0 -7
  194. package/dist/assets/People-DWpcpRpZ.js +0 -7
  195. package/dist/assets/PeopleFill-BxcdOZRn.js +0 -23
  196. package/dist/assets/Person-Dd4QCiac.js +0 -7
  197. package/dist/assets/Pin-DSN6BBS6.js +0 -24
  198. package/dist/assets/PinFilled-Du7ciT8p.js +0 -35
  199. package/dist/assets/Plus-dRXu8yLK.js +0 -7
  200. package/dist/assets/PlusCircle-kj00UDxx.js +0 -7
  201. package/dist/assets/PlusSquare-CASzVJ_x.js +0 -24
  202. package/dist/assets/PowerhouseLogoSmall-C7rkb4Ku.js +0 -14
  203. package/dist/assets/Project-BLYGn5jD.js +0 -7
  204. package/dist/assets/QuestionSquare-hGUPKN7o.js +0 -17
  205. package/dist/assets/RedoArrow-C1UsCGGt.js +0 -7
  206. package/dist/assets/Reload-Clzg07Z8.js +0 -14
  207. package/dist/assets/Removed-BdJpuaHB.js +0 -29
  208. package/dist/assets/Renown-BQJirg5w.js +0 -15
  209. package/dist/assets/RenownHover-CIsVCjKE.js +0 -21
  210. package/dist/assets/Ring-BnzZk41B.js +0 -7
  211. package/dist/assets/Save-DB-qMoQ6.js +0 -7
  212. package/dist/assets/Search-C4fgASd0.js +0 -7
  213. package/dist/assets/Server-DdLkUTUf.js +0 -7
  214. package/dist/assets/Settings-XVLcCNRw.js +0 -24
  215. package/dist/assets/Synced-Dp7j8Wr1.js +0 -7
  216. package/dist/assets/Syncing-B3eGgW4P.js +0 -7
  217. package/dist/assets/Tabler-Dv8tnKMX.js +0 -39
  218. package/dist/assets/Trash-GSQzjB0i.js +0 -7
  219. package/dist/assets/TrashFill-D7pcPl3s.js +0 -7
  220. package/dist/assets/TreeViewSlash-vQKVapHr.js +0 -43
  221. package/dist/assets/TriangleDown-eodKDfJJ.js +0 -25
  222. package/dist/assets/VariantArrowLeft-DMEp2hza.js +0 -7
  223. package/dist/assets/VerticalDots-BKEnBm9D.js +0 -7
  224. package/dist/assets/WarningFill-CDTwbvyA.js +0 -7
  225. package/dist/assets/XTwitter-BT5khtsS.js +0 -22
  226. package/dist/assets/Xmark-D0fieu2C.js +0 -14
  227. package/dist/assets/XmarkLight-XhDqUkWV.js +0 -7
  228. package/dist/assets/Youtube-CN2M5XHi.js +0 -24
  229. package/dist/assets/app-loader-BDXofohd.js +0 -2850
  230. package/dist/assets/app-loader-DaEnUcee.css +0 -1585
  231. package/dist/assets/browser-DZJ42QJ_.js +0 -69
  232. package/dist/assets/browser-E-4rGFna.js +0 -21739
  233. package/dist/assets/content-Bov1x3ah.js +0 -7679
  234. package/dist/assets/getEnsName-DVtbpogo.js +0 -3736
  235. package/dist/assets/isAddressEqual-HNfnZOzP.js +0 -11
  236. package/dist/assets/react-error-boundary.esm-BjyDQG6F.js +0 -927
  237. package/dist/assets/root-BsPsBTqn.js +0 -788
  238. package/dist/assets/router-CyGnAURP.js +0 -636
@@ -1,3736 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ccip-BLPIQK-p.js","assets/app-B8nf-deX.js","assets/main.Bikg5D0d.js","assets/app-loader-BDXofohd.js","assets/app-loader-DaEnUcee.css","assets/isAddressEqual-HNfnZOzP.js"])))=>i.map(i=>d[i]);
2
- import { B as BaseError$1, O as size, v as isHex, ab as SliceOffsetOutOfBoundsError, C as numberToHex, U as isAddress, V as InvalidAddressError, ac as padHex, ad as boolToHex, ae as IntegerOutOfRangeError, W as stringToHex, z as bytesToHex, F as parseAccount, af as InvalidBytesLengthError, ag as assertSize, y as hexToNumber, P as trim, ah as InvalidBytesBooleanError, x as hexToBigInt, A as hexToBytes, s as checksumAddress, q as keccak256, N as toBytes, T as stringify, ai as getContractAddress, aj as stringToBytes, ak as InternalRpcError, al as RpcRequestError, am as createBatchScheduler, w as toHex } from "./app-B8nf-deX.js";
3
- import { _ as __vitePreload } from "./main.Bikg5D0d.js";
4
- function formatAbiItem$1(abiItem, { includeName = false } = {}) {
5
- if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
6
- throw new InvalidDefinitionTypeError(abiItem.type);
7
- return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
8
- }
9
- function formatAbiParams(params, { includeName = false } = {}) {
10
- if (!params)
11
- return "";
12
- return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
13
- }
14
- function formatAbiParam(param, { includeName }) {
15
- if (param.type.startsWith("tuple")) {
16
- return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
17
- }
18
- return param.type + (includeName && param.name ? ` ${param.name}` : "");
19
- }
20
- class AbiConstructorNotFoundError extends BaseError$1 {
21
- constructor({ docsPath: docsPath2 }) {
22
- super([
23
- "A constructor was not found on the ABI.",
24
- "Make sure you are using the correct ABI and that the constructor exists on it."
25
- ].join("\n"), {
26
- docsPath: docsPath2,
27
- name: "AbiConstructorNotFoundError"
28
- });
29
- }
30
- }
31
- class AbiConstructorParamsNotFoundError extends BaseError$1 {
32
- constructor({ docsPath: docsPath2 }) {
33
- super([
34
- "Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
35
- "Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
36
- ].join("\n"), {
37
- docsPath: docsPath2,
38
- name: "AbiConstructorParamsNotFoundError"
39
- });
40
- }
41
- }
42
- class AbiDecodingDataSizeTooSmallError extends BaseError$1 {
43
- constructor({ data, params, size: size2 }) {
44
- super([`Data size of ${size2} bytes is too small for given parameters.`].join("\n"), {
45
- metaMessages: [
46
- `Params: (${formatAbiParams(params, { includeName: true })})`,
47
- `Data: ${data} (${size2} bytes)`
48
- ],
49
- name: "AbiDecodingDataSizeTooSmallError"
50
- });
51
- Object.defineProperty(this, "data", {
52
- enumerable: true,
53
- configurable: true,
54
- writable: true,
55
- value: void 0
56
- });
57
- Object.defineProperty(this, "params", {
58
- enumerable: true,
59
- configurable: true,
60
- writable: true,
61
- value: void 0
62
- });
63
- Object.defineProperty(this, "size", {
64
- enumerable: true,
65
- configurable: true,
66
- writable: true,
67
- value: void 0
68
- });
69
- this.data = data;
70
- this.params = params;
71
- this.size = size2;
72
- }
73
- }
74
- class AbiDecodingZeroDataError extends BaseError$1 {
75
- constructor() {
76
- super('Cannot decode zero data ("0x") with ABI parameters.', {
77
- name: "AbiDecodingZeroDataError"
78
- });
79
- }
80
- }
81
- class AbiEncodingArrayLengthMismatchError extends BaseError$1 {
82
- constructor({ expectedLength, givenLength, type }) {
83
- super([
84
- `ABI encoding array length mismatch for type ${type}.`,
85
- `Expected length: ${expectedLength}`,
86
- `Given length: ${givenLength}`
87
- ].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
88
- }
89
- }
90
- class AbiEncodingBytesSizeMismatchError extends BaseError$1 {
91
- constructor({ expectedSize, value }) {
92
- super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
93
- }
94
- }
95
- class AbiEncodingLengthMismatchError extends BaseError$1 {
96
- constructor({ expectedLength, givenLength }) {
97
- super([
98
- "ABI encoding params/values length mismatch.",
99
- `Expected length (params): ${expectedLength}`,
100
- `Given length (values): ${givenLength}`
101
- ].join("\n"), { name: "AbiEncodingLengthMismatchError" });
102
- }
103
- }
104
- class AbiErrorSignatureNotFoundError extends BaseError$1 {
105
- constructor(signature, { docsPath: docsPath2 }) {
106
- super([
107
- `Encoded error signature "${signature}" not found on ABI.`,
108
- "Make sure you are using the correct ABI and that the error exists on it.",
109
- `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${signature}.`
110
- ].join("\n"), {
111
- docsPath: docsPath2,
112
- name: "AbiErrorSignatureNotFoundError"
113
- });
114
- Object.defineProperty(this, "signature", {
115
- enumerable: true,
116
- configurable: true,
117
- writable: true,
118
- value: void 0
119
- });
120
- this.signature = signature;
121
- }
122
- }
123
- class AbiEventSignatureEmptyTopicsError extends BaseError$1 {
124
- constructor({ docsPath: docsPath2 }) {
125
- super("Cannot extract event signature from empty topics.", {
126
- docsPath: docsPath2,
127
- name: "AbiEventSignatureEmptyTopicsError"
128
- });
129
- }
130
- }
131
- class AbiEventSignatureNotFoundError extends BaseError$1 {
132
- constructor(signature, { docsPath: docsPath2 }) {
133
- super([
134
- `Encoded event signature "${signature}" not found on ABI.`,
135
- "Make sure you are using the correct ABI and that the event exists on it.",
136
- `You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
137
- ].join("\n"), {
138
- docsPath: docsPath2,
139
- name: "AbiEventSignatureNotFoundError"
140
- });
141
- }
142
- }
143
- class AbiEventNotFoundError extends BaseError$1 {
144
- constructor(eventName, { docsPath: docsPath2 } = {}) {
145
- super([
146
- `Event ${eventName ? `"${eventName}" ` : ""}not found on ABI.`,
147
- "Make sure you are using the correct ABI and that the event exists on it."
148
- ].join("\n"), {
149
- docsPath: docsPath2,
150
- name: "AbiEventNotFoundError"
151
- });
152
- }
153
- }
154
- class AbiFunctionNotFoundError extends BaseError$1 {
155
- constructor(functionName, { docsPath: docsPath2 } = {}) {
156
- super([
157
- `Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`,
158
- "Make sure you are using the correct ABI and that the function exists on it."
159
- ].join("\n"), {
160
- docsPath: docsPath2,
161
- name: "AbiFunctionNotFoundError"
162
- });
163
- }
164
- }
165
- class AbiFunctionOutputsNotFoundError extends BaseError$1 {
166
- constructor(functionName, { docsPath: docsPath2 }) {
167
- super([
168
- `Function "${functionName}" does not contain any \`outputs\` on ABI.`,
169
- "Cannot decode function result without knowing what the parameter types are.",
170
- "Make sure you are using the correct ABI and that the function exists on it."
171
- ].join("\n"), {
172
- docsPath: docsPath2,
173
- name: "AbiFunctionOutputsNotFoundError"
174
- });
175
- }
176
- }
177
- class AbiItemAmbiguityError extends BaseError$1 {
178
- constructor(x, y) {
179
- super("Found ambiguous types in overloaded ABI items.", {
180
- metaMessages: [
181
- `\`${x.type}\` in \`${formatAbiItem$1(x.abiItem)}\`, and`,
182
- `\`${y.type}\` in \`${formatAbiItem$1(y.abiItem)}\``,
183
- "",
184
- "These types encode differently and cannot be distinguished at runtime.",
185
- "Remove one of the ambiguous items in the ABI."
186
- ],
187
- name: "AbiItemAmbiguityError"
188
- });
189
- }
190
- }
191
- class BytesSizeMismatchError extends BaseError$1 {
192
- constructor({ expectedSize, givenSize }) {
193
- super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, {
194
- name: "BytesSizeMismatchError"
195
- });
196
- }
197
- }
198
- class DecodeLogDataMismatch extends BaseError$1 {
199
- constructor({ abiItem, data, params, size: size2 }) {
200
- super([
201
- `Data size of ${size2} bytes is too small for non-indexed event parameters.`
202
- ].join("\n"), {
203
- metaMessages: [
204
- `Params: (${formatAbiParams(params, { includeName: true })})`,
205
- `Data: ${data} (${size2} bytes)`
206
- ],
207
- name: "DecodeLogDataMismatch"
208
- });
209
- Object.defineProperty(this, "abiItem", {
210
- enumerable: true,
211
- configurable: true,
212
- writable: true,
213
- value: void 0
214
- });
215
- Object.defineProperty(this, "data", {
216
- enumerable: true,
217
- configurable: true,
218
- writable: true,
219
- value: void 0
220
- });
221
- Object.defineProperty(this, "params", {
222
- enumerable: true,
223
- configurable: true,
224
- writable: true,
225
- value: void 0
226
- });
227
- Object.defineProperty(this, "size", {
228
- enumerable: true,
229
- configurable: true,
230
- writable: true,
231
- value: void 0
232
- });
233
- this.abiItem = abiItem;
234
- this.data = data;
235
- this.params = params;
236
- this.size = size2;
237
- }
238
- }
239
- class DecodeLogTopicsMismatch extends BaseError$1 {
240
- constructor({ abiItem, param }) {
241
- super([
242
- `Expected a topic for indexed event parameter${param.name ? ` "${param.name}"` : ""} on event "${formatAbiItem$1(abiItem, { includeName: true })}".`
243
- ].join("\n"), { name: "DecodeLogTopicsMismatch" });
244
- Object.defineProperty(this, "abiItem", {
245
- enumerable: true,
246
- configurable: true,
247
- writable: true,
248
- value: void 0
249
- });
250
- this.abiItem = abiItem;
251
- }
252
- }
253
- class InvalidAbiEncodingTypeError extends BaseError$1 {
254
- constructor(type, { docsPath: docsPath2 }) {
255
- super([
256
- `Type "${type}" is not a valid encoding type.`,
257
- "Please provide a valid ABI type."
258
- ].join("\n"), { docsPath: docsPath2, name: "InvalidAbiEncodingType" });
259
- }
260
- }
261
- class InvalidAbiDecodingTypeError extends BaseError$1 {
262
- constructor(type, { docsPath: docsPath2 }) {
263
- super([
264
- `Type "${type}" is not a valid decoding type.`,
265
- "Please provide a valid ABI type."
266
- ].join("\n"), { docsPath: docsPath2, name: "InvalidAbiDecodingType" });
267
- }
268
- }
269
- class InvalidArrayError extends BaseError$1 {
270
- constructor(value) {
271
- super([`Value "${value}" is not a valid array.`].join("\n"), {
272
- name: "InvalidArrayError"
273
- });
274
- }
275
- }
276
- class InvalidDefinitionTypeError extends BaseError$1 {
277
- constructor(type) {
278
- super([
279
- `"${type}" is not a valid definition type.`,
280
- 'Valid types: "function", "event", "error"'
281
- ].join("\n"), { name: "InvalidDefinitionTypeError" });
282
- }
283
- }
284
- function concat(values) {
285
- if (typeof values[0] === "string")
286
- return concatHex(values);
287
- return concatBytes(values);
288
- }
289
- function concatBytes(values) {
290
- let length = 0;
291
- for (const arr of values) {
292
- length += arr.length;
293
- }
294
- const result = new Uint8Array(length);
295
- let offset = 0;
296
- for (const arr of values) {
297
- result.set(arr, offset);
298
- offset += arr.length;
299
- }
300
- return result;
301
- }
302
- function concatHex(values) {
303
- return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
304
- }
305
- function slice(value, start, end, { strict } = {}) {
306
- if (isHex(value, { strict: false }))
307
- return sliceHex(value, start, end, {
308
- strict
309
- });
310
- return sliceBytes(value, start, end, {
311
- strict
312
- });
313
- }
314
- function assertStartOffset(value, start) {
315
- if (typeof start === "number" && start > 0 && start > size(value) - 1)
316
- throw new SliceOffsetOutOfBoundsError({
317
- offset: start,
318
- position: "start",
319
- size: size(value)
320
- });
321
- }
322
- function assertEndOffset(value, start, end) {
323
- if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) {
324
- throw new SliceOffsetOutOfBoundsError({
325
- offset: end,
326
- position: "end",
327
- size: size(value)
328
- });
329
- }
330
- }
331
- function sliceBytes(value_, start, end, { strict } = {}) {
332
- assertStartOffset(value_, start);
333
- const value = value_.slice(start, end);
334
- if (strict)
335
- assertEndOffset(value, start, end);
336
- return value;
337
- }
338
- function sliceHex(value_, start, end, { strict } = {}) {
339
- assertStartOffset(value_, start);
340
- const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`;
341
- if (strict)
342
- assertEndOffset(value, start, end);
343
- return value;
344
- }
345
- const bytesRegex$1 = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
346
- const integerRegex$1 = /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
347
- function encodeAbiParameters(params, values) {
348
- if (params.length !== values.length)
349
- throw new AbiEncodingLengthMismatchError({
350
- expectedLength: params.length,
351
- givenLength: values.length
352
- });
353
- const preparedParams = prepareParams({
354
- params,
355
- values
356
- });
357
- const data = encodeParams(preparedParams);
358
- if (data.length === 0)
359
- return "0x";
360
- return data;
361
- }
362
- function prepareParams({ params, values }) {
363
- const preparedParams = [];
364
- for (let i = 0; i < params.length; i++) {
365
- preparedParams.push(prepareParam({ param: params[i], value: values[i] }));
366
- }
367
- return preparedParams;
368
- }
369
- function prepareParam({ param, value }) {
370
- const arrayComponents = getArrayComponents(param.type);
371
- if (arrayComponents) {
372
- const [length, type] = arrayComponents;
373
- return encodeArray(value, { length, param: { ...param, type } });
374
- }
375
- if (param.type === "tuple") {
376
- return encodeTuple(value, {
377
- param
378
- });
379
- }
380
- if (param.type === "address") {
381
- return encodeAddress(value);
382
- }
383
- if (param.type === "bool") {
384
- return encodeBool(value);
385
- }
386
- if (param.type.startsWith("uint") || param.type.startsWith("int")) {
387
- const signed = param.type.startsWith("int");
388
- const [, , size2 = "256"] = integerRegex$1.exec(param.type) ?? [];
389
- return encodeNumber(value, {
390
- signed,
391
- size: Number(size2)
392
- });
393
- }
394
- if (param.type.startsWith("bytes")) {
395
- return encodeBytes(value, { param });
396
- }
397
- if (param.type === "string") {
398
- return encodeString(value);
399
- }
400
- throw new InvalidAbiEncodingTypeError(param.type, {
401
- docsPath: "/docs/contract/encodeAbiParameters"
402
- });
403
- }
404
- function encodeParams(preparedParams) {
405
- let staticSize = 0;
406
- for (let i = 0; i < preparedParams.length; i++) {
407
- const { dynamic, encoded } = preparedParams[i];
408
- if (dynamic)
409
- staticSize += 32;
410
- else
411
- staticSize += size(encoded);
412
- }
413
- const staticParams = [];
414
- const dynamicParams = [];
415
- let dynamicSize = 0;
416
- for (let i = 0; i < preparedParams.length; i++) {
417
- const { dynamic, encoded } = preparedParams[i];
418
- if (dynamic) {
419
- staticParams.push(numberToHex(staticSize + dynamicSize, { size: 32 }));
420
- dynamicParams.push(encoded);
421
- dynamicSize += size(encoded);
422
- } else {
423
- staticParams.push(encoded);
424
- }
425
- }
426
- return concat([...staticParams, ...dynamicParams]);
427
- }
428
- function encodeAddress(value) {
429
- if (!isAddress(value))
430
- throw new InvalidAddressError({ address: value });
431
- return { dynamic: false, encoded: padHex(value.toLowerCase()) };
432
- }
433
- function encodeArray(value, { length, param }) {
434
- const dynamic = length === null;
435
- if (!Array.isArray(value))
436
- throw new InvalidArrayError(value);
437
- if (!dynamic && value.length !== length)
438
- throw new AbiEncodingArrayLengthMismatchError({
439
- expectedLength: length,
440
- givenLength: value.length,
441
- type: `${param.type}[${length}]`
442
- });
443
- let dynamicChild = false;
444
- const preparedParams = [];
445
- for (let i = 0; i < value.length; i++) {
446
- const preparedParam = prepareParam({ param, value: value[i] });
447
- if (preparedParam.dynamic)
448
- dynamicChild = true;
449
- preparedParams.push(preparedParam);
450
- }
451
- if (dynamic || dynamicChild) {
452
- const data = encodeParams(preparedParams);
453
- if (dynamic) {
454
- const length2 = numberToHex(preparedParams.length, { size: 32 });
455
- return {
456
- dynamic: true,
457
- encoded: preparedParams.length > 0 ? concat([length2, data]) : length2
458
- };
459
- }
460
- if (dynamicChild)
461
- return { dynamic: true, encoded: data };
462
- }
463
- return {
464
- dynamic: false,
465
- encoded: concat(preparedParams.map(({ encoded }) => encoded))
466
- };
467
- }
468
- function encodeBytes(value, { param }) {
469
- const [, paramSize] = param.type.split("bytes");
470
- const bytesSize = size(value);
471
- if (!paramSize) {
472
- let value_ = value;
473
- if (bytesSize % 32 !== 0)
474
- value_ = padHex(value_, {
475
- dir: "right",
476
- size: Math.ceil((value.length - 2) / 2 / 32) * 32
477
- });
478
- return {
479
- dynamic: true,
480
- encoded: concat([padHex(numberToHex(bytesSize, { size: 32 })), value_])
481
- };
482
- }
483
- if (bytesSize !== Number.parseInt(paramSize))
484
- throw new AbiEncodingBytesSizeMismatchError({
485
- expectedSize: Number.parseInt(paramSize),
486
- value
487
- });
488
- return { dynamic: false, encoded: padHex(value, { dir: "right" }) };
489
- }
490
- function encodeBool(value) {
491
- if (typeof value !== "boolean")
492
- throw new BaseError$1(`Invalid boolean value: "${value}" (type: ${typeof value}). Expected: \`true\` or \`false\`.`);
493
- return { dynamic: false, encoded: padHex(boolToHex(value)) };
494
- }
495
- function encodeNumber(value, { signed, size: size2 = 256 }) {
496
- if (typeof size2 === "number") {
497
- const max = 2n ** (BigInt(size2) - (signed ? 1n : 0n)) - 1n;
498
- const min = signed ? -max - 1n : 0n;
499
- if (value > max || value < min)
500
- throw new IntegerOutOfRangeError({
501
- max: max.toString(),
502
- min: min.toString(),
503
- signed,
504
- size: size2 / 8,
505
- value: value.toString()
506
- });
507
- }
508
- return {
509
- dynamic: false,
510
- encoded: numberToHex(value, {
511
- size: 32,
512
- signed
513
- })
514
- };
515
- }
516
- function encodeString(value) {
517
- const hexValue = stringToHex(value);
518
- const partsLength = Math.ceil(size(hexValue) / 32);
519
- const parts = [];
520
- for (let i = 0; i < partsLength; i++) {
521
- parts.push(padHex(slice(hexValue, i * 32, (i + 1) * 32), {
522
- dir: "right"
523
- }));
524
- }
525
- return {
526
- dynamic: true,
527
- encoded: concat([
528
- padHex(numberToHex(size(hexValue), { size: 32 })),
529
- ...parts
530
- ])
531
- };
532
- }
533
- function encodeTuple(value, { param }) {
534
- let dynamic = false;
535
- const preparedParams = [];
536
- for (let i = 0; i < param.components.length; i++) {
537
- const param_ = param.components[i];
538
- const index = Array.isArray(value) ? i : param_.name;
539
- const preparedParam = prepareParam({
540
- param: param_,
541
- value: value[index]
542
- });
543
- preparedParams.push(preparedParam);
544
- if (preparedParam.dynamic)
545
- dynamic = true;
546
- }
547
- return {
548
- dynamic,
549
- encoded: dynamic ? encodeParams(preparedParams) : concat(preparedParams.map(({ encoded }) => encoded))
550
- };
551
- }
552
- function getArrayComponents(type) {
553
- const matches = type.match(/^(.*)\[(\d+)?\]$/);
554
- return matches ? (
555
- // Return `null` if the array is dynamic.
556
- [matches[2] ? Number(matches[2]) : null, matches[1]]
557
- ) : void 0;
558
- }
559
- const docsPath$2 = "/docs/contract/encodeDeployData";
560
- function encodeDeployData(parameters) {
561
- const { abi, args, bytecode } = parameters;
562
- if (!args || args.length === 0)
563
- return bytecode;
564
- const description = abi.find((x) => "type" in x && x.type === "constructor");
565
- if (!description)
566
- throw new AbiConstructorNotFoundError({ docsPath: docsPath$2 });
567
- if (!("inputs" in description))
568
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath$2 });
569
- if (!description.inputs || description.inputs.length === 0)
570
- throw new AbiConstructorParamsNotFoundError({ docsPath: docsPath$2 });
571
- const data = encodeAbiParameters(description.inputs, args);
572
- return concatHex([bytecode, data]);
573
- }
574
- class NegativeOffsetError extends BaseError$1 {
575
- constructor({ offset }) {
576
- super(`Offset \`${offset}\` cannot be negative.`, {
577
- name: "NegativeOffsetError"
578
- });
579
- }
580
- }
581
- class PositionOutOfBoundsError extends BaseError$1 {
582
- constructor({ length, position }) {
583
- super(`Position \`${position}\` is out of bounds (\`0 < position < ${length}\`).`, { name: "PositionOutOfBoundsError" });
584
- }
585
- }
586
- class RecursiveReadLimitExceededError extends BaseError$1 {
587
- constructor({ count, limit }) {
588
- super(`Recursive read limit of \`${limit}\` exceeded (recursive read count: \`${count}\`).`, { name: "RecursiveReadLimitExceededError" });
589
- }
590
- }
591
- const staticCursor = {
592
- bytes: new Uint8Array(),
593
- dataView: new DataView(new ArrayBuffer(0)),
594
- position: 0,
595
- positionReadCount: /* @__PURE__ */ new Map(),
596
- recursiveReadCount: 0,
597
- recursiveReadLimit: Number.POSITIVE_INFINITY,
598
- assertReadLimit() {
599
- if (this.recursiveReadCount >= this.recursiveReadLimit)
600
- throw new RecursiveReadLimitExceededError({
601
- count: this.recursiveReadCount + 1,
602
- limit: this.recursiveReadLimit
603
- });
604
- },
605
- assertPosition(position) {
606
- if (position < 0 || position > this.bytes.length - 1)
607
- throw new PositionOutOfBoundsError({
608
- length: this.bytes.length,
609
- position
610
- });
611
- },
612
- decrementPosition(offset) {
613
- if (offset < 0)
614
- throw new NegativeOffsetError({ offset });
615
- const position = this.position - offset;
616
- this.assertPosition(position);
617
- this.position = position;
618
- },
619
- getReadCount(position) {
620
- return this.positionReadCount.get(position || this.position) || 0;
621
- },
622
- incrementPosition(offset) {
623
- if (offset < 0)
624
- throw new NegativeOffsetError({ offset });
625
- const position = this.position + offset;
626
- this.assertPosition(position);
627
- this.position = position;
628
- },
629
- inspectByte(position_) {
630
- const position = position_ ?? this.position;
631
- this.assertPosition(position);
632
- return this.bytes[position];
633
- },
634
- inspectBytes(length, position_) {
635
- const position = position_ ?? this.position;
636
- this.assertPosition(position + length - 1);
637
- return this.bytes.subarray(position, position + length);
638
- },
639
- inspectUint8(position_) {
640
- const position = position_ ?? this.position;
641
- this.assertPosition(position);
642
- return this.bytes[position];
643
- },
644
- inspectUint16(position_) {
645
- const position = position_ ?? this.position;
646
- this.assertPosition(position + 1);
647
- return this.dataView.getUint16(position);
648
- },
649
- inspectUint24(position_) {
650
- const position = position_ ?? this.position;
651
- this.assertPosition(position + 2);
652
- return (this.dataView.getUint16(position) << 8) + this.dataView.getUint8(position + 2);
653
- },
654
- inspectUint32(position_) {
655
- const position = position_ ?? this.position;
656
- this.assertPosition(position + 3);
657
- return this.dataView.getUint32(position);
658
- },
659
- pushByte(byte) {
660
- this.assertPosition(this.position);
661
- this.bytes[this.position] = byte;
662
- this.position++;
663
- },
664
- pushBytes(bytes) {
665
- this.assertPosition(this.position + bytes.length - 1);
666
- this.bytes.set(bytes, this.position);
667
- this.position += bytes.length;
668
- },
669
- pushUint8(value) {
670
- this.assertPosition(this.position);
671
- this.bytes[this.position] = value;
672
- this.position++;
673
- },
674
- pushUint16(value) {
675
- this.assertPosition(this.position + 1);
676
- this.dataView.setUint16(this.position, value);
677
- this.position += 2;
678
- },
679
- pushUint24(value) {
680
- this.assertPosition(this.position + 2);
681
- this.dataView.setUint16(this.position, value >> 8);
682
- this.dataView.setUint8(this.position + 2, value & 255);
683
- this.position += 3;
684
- },
685
- pushUint32(value) {
686
- this.assertPosition(this.position + 3);
687
- this.dataView.setUint32(this.position, value);
688
- this.position += 4;
689
- },
690
- readByte() {
691
- this.assertReadLimit();
692
- this._touch();
693
- const value = this.inspectByte();
694
- this.position++;
695
- return value;
696
- },
697
- readBytes(length, size2) {
698
- this.assertReadLimit();
699
- this._touch();
700
- const value = this.inspectBytes(length);
701
- this.position += size2 ?? length;
702
- return value;
703
- },
704
- readUint8() {
705
- this.assertReadLimit();
706
- this._touch();
707
- const value = this.inspectUint8();
708
- this.position += 1;
709
- return value;
710
- },
711
- readUint16() {
712
- this.assertReadLimit();
713
- this._touch();
714
- const value = this.inspectUint16();
715
- this.position += 2;
716
- return value;
717
- },
718
- readUint24() {
719
- this.assertReadLimit();
720
- this._touch();
721
- const value = this.inspectUint24();
722
- this.position += 3;
723
- return value;
724
- },
725
- readUint32() {
726
- this.assertReadLimit();
727
- this._touch();
728
- const value = this.inspectUint32();
729
- this.position += 4;
730
- return value;
731
- },
732
- get remaining() {
733
- return this.bytes.length - this.position;
734
- },
735
- setPosition(position) {
736
- const oldPosition = this.position;
737
- this.assertPosition(position);
738
- this.position = position;
739
- return () => this.position = oldPosition;
740
- },
741
- _touch() {
742
- if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
743
- return;
744
- const count = this.getReadCount();
745
- this.positionReadCount.set(this.position, count + 1);
746
- if (count > 0)
747
- this.recursiveReadCount++;
748
- }
749
- };
750
- function createCursor(bytes, { recursiveReadLimit = 8192 } = {}) {
751
- const cursor = Object.create(staticCursor);
752
- cursor.bytes = bytes;
753
- cursor.dataView = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
754
- cursor.positionReadCount = /* @__PURE__ */ new Map();
755
- cursor.recursiveReadLimit = recursiveReadLimit;
756
- return cursor;
757
- }
758
- class ChainDoesNotSupportContract extends BaseError$1 {
759
- constructor({ blockNumber, chain, contract }) {
760
- super(`Chain "${chain.name}" does not support contract "${contract.name}".`, {
761
- metaMessages: [
762
- "This could be due to any of the following:",
763
- ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [
764
- `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).`
765
- ] : [
766
- `- The chain does not have the contract "${contract.name}" configured.`
767
- ]
768
- ],
769
- name: "ChainDoesNotSupportContract"
770
- });
771
- }
772
- }
773
- class ClientChainNotConfiguredError extends BaseError$1 {
774
- constructor() {
775
- super("No chain was provided to the Client.", {
776
- name: "ClientChainNotConfiguredError"
777
- });
778
- }
779
- }
780
- class InvalidChainIdError extends BaseError$1 {
781
- constructor({ chainId }) {
782
- super(typeof chainId === "number" ? `Chain ID "${chainId}" is invalid.` : "Chain ID is invalid.", { name: "InvalidChainIdError" });
783
- }
784
- }
785
- const etherUnits = {
786
- gwei: 9,
787
- wei: 18
788
- };
789
- const gweiUnits = {
790
- ether: -9,
791
- wei: 9
792
- };
793
- function formatUnits(value, decimals) {
794
- let display = value.toString();
795
- const negative = display.startsWith("-");
796
- if (negative)
797
- display = display.slice(1);
798
- display = display.padStart(decimals, "0");
799
- let [integer, fraction] = [
800
- display.slice(0, display.length - decimals),
801
- display.slice(display.length - decimals)
802
- ];
803
- fraction = fraction.replace(/(0+)$/, "");
804
- return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`;
805
- }
806
- function formatGwei(wei, unit = "wei") {
807
- return formatUnits(wei, gweiUnits[unit]);
808
- }
809
- class ExecutionRevertedError extends BaseError$1 {
810
- constructor({ cause, message } = {}) {
811
- var _a;
812
- const reason = (_a = message == null ? void 0 : message.replace("execution reverted: ", "")) == null ? void 0 : _a.replace("execution reverted", "");
813
- super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, {
814
- cause,
815
- name: "ExecutionRevertedError"
816
- });
817
- }
818
- }
819
- Object.defineProperty(ExecutionRevertedError, "code", {
820
- enumerable: true,
821
- configurable: true,
822
- writable: true,
823
- value: 3
824
- });
825
- Object.defineProperty(ExecutionRevertedError, "nodeMessage", {
826
- enumerable: true,
827
- configurable: true,
828
- writable: true,
829
- value: /execution reverted/
830
- });
831
- class FeeCapTooHighError extends BaseError$1 {
832
- constructor({ cause, maxFeePerGas } = {}) {
833
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, {
834
- cause,
835
- name: "FeeCapTooHighError"
836
- });
837
- }
838
- }
839
- Object.defineProperty(FeeCapTooHighError, "nodeMessage", {
840
- enumerable: true,
841
- configurable: true,
842
- writable: true,
843
- value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/
844
- });
845
- class FeeCapTooLowError extends BaseError$1 {
846
- constructor({ cause, maxFeePerGas } = {}) {
847
- super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, {
848
- cause,
849
- name: "FeeCapTooLowError"
850
- });
851
- }
852
- }
853
- Object.defineProperty(FeeCapTooLowError, "nodeMessage", {
854
- enumerable: true,
855
- configurable: true,
856
- writable: true,
857
- value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/
858
- });
859
- class NonceTooHighError extends BaseError$1 {
860
- constructor({ cause, nonce } = {}) {
861
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause, name: "NonceTooHighError" });
862
- }
863
- }
864
- Object.defineProperty(NonceTooHighError, "nodeMessage", {
865
- enumerable: true,
866
- configurable: true,
867
- writable: true,
868
- value: /nonce too high/
869
- });
870
- class NonceTooLowError extends BaseError$1 {
871
- constructor({ cause, nonce } = {}) {
872
- super([
873
- `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`,
874
- "Try increasing the nonce or find the latest nonce with `getTransactionCount`."
875
- ].join("\n"), { cause, name: "NonceTooLowError" });
876
- }
877
- }
878
- Object.defineProperty(NonceTooLowError, "nodeMessage", {
879
- enumerable: true,
880
- configurable: true,
881
- writable: true,
882
- value: /nonce too low|transaction already imported|already known/
883
- });
884
- class NonceMaxValueError extends BaseError$1 {
885
- constructor({ cause, nonce } = {}) {
886
- super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause, name: "NonceMaxValueError" });
887
- }
888
- }
889
- Object.defineProperty(NonceMaxValueError, "nodeMessage", {
890
- enumerable: true,
891
- configurable: true,
892
- writable: true,
893
- value: /nonce has max value/
894
- });
895
- class InsufficientFundsError extends BaseError$1 {
896
- constructor({ cause } = {}) {
897
- super([
898
- "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."
899
- ].join("\n"), {
900
- cause,
901
- metaMessages: [
902
- "This error could arise when the account does not have enough funds to:",
903
- " - pay for the total gas fee,",
904
- " - pay for the value to send.",
905
- " ",
906
- "The cost of the transaction is calculated as `gas * gas fee + value`, where:",
907
- " - `gas` is the amount of gas needed for transaction to execute,",
908
- " - `gas fee` is the gas fee,",
909
- " - `value` is the amount of ether to send to the recipient."
910
- ],
911
- name: "InsufficientFundsError"
912
- });
913
- }
914
- }
915
- Object.defineProperty(InsufficientFundsError, "nodeMessage", {
916
- enumerable: true,
917
- configurable: true,
918
- writable: true,
919
- value: /insufficient funds|exceeds transaction sender account balance/
920
- });
921
- class IntrinsicGasTooHighError extends BaseError$1 {
922
- constructor({ cause, gas } = {}) {
923
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, {
924
- cause,
925
- name: "IntrinsicGasTooHighError"
926
- });
927
- }
928
- }
929
- Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", {
930
- enumerable: true,
931
- configurable: true,
932
- writable: true,
933
- value: /intrinsic gas too high|gas limit reached/
934
- });
935
- class IntrinsicGasTooLowError extends BaseError$1 {
936
- constructor({ cause, gas } = {}) {
937
- super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, {
938
- cause,
939
- name: "IntrinsicGasTooLowError"
940
- });
941
- }
942
- }
943
- Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", {
944
- enumerable: true,
945
- configurable: true,
946
- writable: true,
947
- value: /intrinsic gas too low/
948
- });
949
- class TransactionTypeNotSupportedError extends BaseError$1 {
950
- constructor({ cause }) {
951
- super("The transaction type is not supported for this chain.", {
952
- cause,
953
- name: "TransactionTypeNotSupportedError"
954
- });
955
- }
956
- }
957
- Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", {
958
- enumerable: true,
959
- configurable: true,
960
- writable: true,
961
- value: /transaction type not valid/
962
- });
963
- class TipAboveFeeCapError extends BaseError$1 {
964
- constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) {
965
- super([
966
- `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).`
967
- ].join("\n"), {
968
- cause,
969
- name: "TipAboveFeeCapError"
970
- });
971
- }
972
- }
973
- Object.defineProperty(TipAboveFeeCapError, "nodeMessage", {
974
- enumerable: true,
975
- configurable: true,
976
- writable: true,
977
- value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/
978
- });
979
- class UnknownNodeError extends BaseError$1 {
980
- constructor({ cause }) {
981
- super(`An error occurred while executing: ${cause == null ? void 0 : cause.shortMessage}`, {
982
- cause,
983
- name: "UnknownNodeError"
984
- });
985
- }
986
- }
987
- function formatEther(wei, unit = "wei") {
988
- return formatUnits(wei, etherUnits[unit]);
989
- }
990
- function prettyPrint(args) {
991
- const entries = Object.entries(args).map(([key, value]) => {
992
- if (value === void 0 || value === false)
993
- return null;
994
- return [key, value];
995
- }).filter(Boolean);
996
- const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0);
997
- return entries.map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`).join("\n");
998
- }
999
- class FeeConflictError extends BaseError$1 {
1000
- constructor() {
1001
- super([
1002
- "Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.",
1003
- "Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."
1004
- ].join("\n"), { name: "FeeConflictError" });
1005
- }
1006
- }
1007
- class InvalidLegacyVError extends BaseError$1 {
1008
- constructor({ v }) {
1009
- super(`Invalid \`v\` value "${v}". Expected 27 or 28.`, {
1010
- name: "InvalidLegacyVError"
1011
- });
1012
- }
1013
- }
1014
- class InvalidSerializableTransactionError extends BaseError$1 {
1015
- constructor({ transaction }) {
1016
- super("Cannot infer a transaction type from provided transaction.", {
1017
- metaMessages: [
1018
- "Provided Transaction:",
1019
- "{",
1020
- prettyPrint(transaction),
1021
- "}",
1022
- "",
1023
- "To infer the type, either provide:",
1024
- "- a `type` to the Transaction, or",
1025
- "- an EIP-1559 Transaction with `maxFeePerGas`, or",
1026
- "- an EIP-2930 Transaction with `gasPrice` & `accessList`, or",
1027
- "- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or",
1028
- "- an EIP-7702 Transaction with `authorizationList`, or",
1029
- "- a Legacy Transaction with `gasPrice`"
1030
- ],
1031
- name: "InvalidSerializableTransactionError"
1032
- });
1033
- }
1034
- }
1035
- class InvalidStorageKeySizeError extends BaseError$1 {
1036
- constructor({ storageKey }) {
1037
- super(`Size for storage key "${storageKey}" is invalid. Expected 32 bytes. Got ${Math.floor((storageKey.length - 2) / 2)} bytes.`, { name: "InvalidStorageKeySizeError" });
1038
- }
1039
- }
1040
- class TransactionNotFoundError extends BaseError$1 {
1041
- constructor({ blockHash, blockNumber, blockTag, hash: hash2, index }) {
1042
- let identifier = "Transaction";
1043
- if (blockTag && index !== void 0)
1044
- identifier = `Transaction at block time "${blockTag}" at index "${index}"`;
1045
- if (blockHash && index !== void 0)
1046
- identifier = `Transaction at block hash "${blockHash}" at index "${index}"`;
1047
- if (blockNumber && index !== void 0)
1048
- identifier = `Transaction at block number "${blockNumber}" at index "${index}"`;
1049
- if (hash2)
1050
- identifier = `Transaction with hash "${hash2}"`;
1051
- super(`${identifier} could not be found.`, {
1052
- name: "TransactionNotFoundError"
1053
- });
1054
- }
1055
- }
1056
- class TransactionReceiptNotFoundError extends BaseError$1 {
1057
- constructor({ hash: hash2 }) {
1058
- super(`Transaction receipt with hash "${hash2}" could not be found. The Transaction may not be processed on a block yet.`, {
1059
- name: "TransactionReceiptNotFoundError"
1060
- });
1061
- }
1062
- }
1063
- class WaitForTransactionReceiptTimeoutError extends BaseError$1 {
1064
- constructor({ hash: hash2 }) {
1065
- super(`Timed out while waiting for transaction with hash "${hash2}" to be confirmed.`, { name: "WaitForTransactionReceiptTimeoutError" });
1066
- }
1067
- }
1068
- function getNodeError(err, args) {
1069
- const message = (err.details || "").toLowerCase();
1070
- const executionRevertedError = err instanceof BaseError$1 ? err.walk((e) => (e == null ? void 0 : e.code) === ExecutionRevertedError.code) : err;
1071
- if (executionRevertedError instanceof BaseError$1)
1072
- return new ExecutionRevertedError({
1073
- cause: err,
1074
- message: executionRevertedError.details
1075
- });
1076
- if (ExecutionRevertedError.nodeMessage.test(message))
1077
- return new ExecutionRevertedError({
1078
- cause: err,
1079
- message: err.details
1080
- });
1081
- if (FeeCapTooHighError.nodeMessage.test(message))
1082
- return new FeeCapTooHighError({
1083
- cause: err,
1084
- maxFeePerGas: args == null ? void 0 : args.maxFeePerGas
1085
- });
1086
- if (FeeCapTooLowError.nodeMessage.test(message))
1087
- return new FeeCapTooLowError({
1088
- cause: err,
1089
- maxFeePerGas: args == null ? void 0 : args.maxFeePerGas
1090
- });
1091
- if (NonceTooHighError.nodeMessage.test(message))
1092
- return new NonceTooHighError({ cause: err, nonce: args == null ? void 0 : args.nonce });
1093
- if (NonceTooLowError.nodeMessage.test(message))
1094
- return new NonceTooLowError({ cause: err, nonce: args == null ? void 0 : args.nonce });
1095
- if (NonceMaxValueError.nodeMessage.test(message))
1096
- return new NonceMaxValueError({ cause: err, nonce: args == null ? void 0 : args.nonce });
1097
- if (InsufficientFundsError.nodeMessage.test(message))
1098
- return new InsufficientFundsError({ cause: err });
1099
- if (IntrinsicGasTooHighError.nodeMessage.test(message))
1100
- return new IntrinsicGasTooHighError({ cause: err, gas: args == null ? void 0 : args.gas });
1101
- if (IntrinsicGasTooLowError.nodeMessage.test(message))
1102
- return new IntrinsicGasTooLowError({ cause: err, gas: args == null ? void 0 : args.gas });
1103
- if (TransactionTypeNotSupportedError.nodeMessage.test(message))
1104
- return new TransactionTypeNotSupportedError({ cause: err });
1105
- if (TipAboveFeeCapError.nodeMessage.test(message))
1106
- return new TipAboveFeeCapError({
1107
- cause: err,
1108
- maxFeePerGas: args == null ? void 0 : args.maxFeePerGas,
1109
- maxPriorityFeePerGas: args == null ? void 0 : args.maxPriorityFeePerGas
1110
- });
1111
- return new UnknownNodeError({
1112
- cause: err
1113
- });
1114
- }
1115
- function extract(value_, { format }) {
1116
- if (!format)
1117
- return {};
1118
- const value = {};
1119
- function extract_(formatted2) {
1120
- const keys = Object.keys(formatted2);
1121
- for (const key of keys) {
1122
- if (key in value_)
1123
- value[key] = value_[key];
1124
- if (formatted2[key] && typeof formatted2[key] === "object" && !Array.isArray(formatted2[key]))
1125
- extract_(formatted2[key]);
1126
- }
1127
- }
1128
- const formatted = format(value_ || {});
1129
- extract_(formatted);
1130
- return value;
1131
- }
1132
- function defineFormatter(type, format) {
1133
- return ({ exclude, format: overrides }) => {
1134
- return {
1135
- exclude,
1136
- format: (args) => {
1137
- const formatted = format(args);
1138
- if (exclude) {
1139
- for (const key of exclude) {
1140
- delete formatted[key];
1141
- }
1142
- }
1143
- return {
1144
- ...formatted,
1145
- ...overrides(args)
1146
- };
1147
- },
1148
- type
1149
- };
1150
- };
1151
- }
1152
- const rpcTransactionType = {
1153
- legacy: "0x0",
1154
- eip2930: "0x1",
1155
- eip1559: "0x2",
1156
- eip4844: "0x3",
1157
- eip7702: "0x4"
1158
- };
1159
- function formatTransactionRequest(request) {
1160
- const rpcRequest = {};
1161
- if (typeof request.authorizationList !== "undefined")
1162
- rpcRequest.authorizationList = formatAuthorizationList(request.authorizationList);
1163
- if (typeof request.accessList !== "undefined")
1164
- rpcRequest.accessList = request.accessList;
1165
- if (typeof request.blobVersionedHashes !== "undefined")
1166
- rpcRequest.blobVersionedHashes = request.blobVersionedHashes;
1167
- if (typeof request.blobs !== "undefined") {
1168
- if (typeof request.blobs[0] !== "string")
1169
- rpcRequest.blobs = request.blobs.map((x) => bytesToHex(x));
1170
- else
1171
- rpcRequest.blobs = request.blobs;
1172
- }
1173
- if (typeof request.data !== "undefined")
1174
- rpcRequest.data = request.data;
1175
- if (typeof request.from !== "undefined")
1176
- rpcRequest.from = request.from;
1177
- if (typeof request.gas !== "undefined")
1178
- rpcRequest.gas = numberToHex(request.gas);
1179
- if (typeof request.gasPrice !== "undefined")
1180
- rpcRequest.gasPrice = numberToHex(request.gasPrice);
1181
- if (typeof request.maxFeePerBlobGas !== "undefined")
1182
- rpcRequest.maxFeePerBlobGas = numberToHex(request.maxFeePerBlobGas);
1183
- if (typeof request.maxFeePerGas !== "undefined")
1184
- rpcRequest.maxFeePerGas = numberToHex(request.maxFeePerGas);
1185
- if (typeof request.maxPriorityFeePerGas !== "undefined")
1186
- rpcRequest.maxPriorityFeePerGas = numberToHex(request.maxPriorityFeePerGas);
1187
- if (typeof request.nonce !== "undefined")
1188
- rpcRequest.nonce = numberToHex(request.nonce);
1189
- if (typeof request.to !== "undefined")
1190
- rpcRequest.to = request.to;
1191
- if (typeof request.type !== "undefined")
1192
- rpcRequest.type = rpcTransactionType[request.type];
1193
- if (typeof request.value !== "undefined")
1194
- rpcRequest.value = numberToHex(request.value);
1195
- return rpcRequest;
1196
- }
1197
- const defineTransactionRequest = /* @__PURE__ */ defineFormatter("transactionRequest", formatTransactionRequest);
1198
- function formatAuthorizationList(authorizationList) {
1199
- return authorizationList.map((authorization) => ({
1200
- address: authorization.contractAddress,
1201
- r: authorization.r,
1202
- s: authorization.s,
1203
- chainId: numberToHex(authorization.chainId),
1204
- nonce: numberToHex(authorization.nonce),
1205
- ...typeof authorization.yParity !== "undefined" ? { yParity: numberToHex(authorization.yParity) } : {},
1206
- ...typeof authorization.v !== "undefined" && typeof authorization.yParity === "undefined" ? { v: numberToHex(authorization.v) } : {}
1207
- }));
1208
- }
1209
- function getAction(client, actionFn, name) {
1210
- const action_implicit = client[actionFn.name];
1211
- if (typeof action_implicit === "function")
1212
- return action_implicit;
1213
- const action_explicit = client[name];
1214
- if (typeof action_explicit === "function")
1215
- return action_explicit;
1216
- return (params) => actionFn(client, params);
1217
- }
1218
- const maxUint16 = 2n ** 16n - 1n;
1219
- const maxUint256 = 2n ** 256n - 1n;
1220
- function assertRequest(args) {
1221
- const { account: account_, gasPrice, maxFeePerGas, maxPriorityFeePerGas, to } = args;
1222
- const account = account_ ? parseAccount(account_) : void 0;
1223
- if (account && !isAddress(account.address))
1224
- throw new InvalidAddressError({ address: account.address });
1225
- if (to && !isAddress(to))
1226
- throw new InvalidAddressError({ address: to });
1227
- if (typeof gasPrice !== "undefined" && (typeof maxFeePerGas !== "undefined" || typeof maxPriorityFeePerGas !== "undefined"))
1228
- throw new FeeConflictError();
1229
- if (maxFeePerGas && maxFeePerGas > maxUint256)
1230
- throw new FeeCapTooHighError({ maxFeePerGas });
1231
- if (maxPriorityFeePerGas && maxFeePerGas && maxPriorityFeePerGas > maxFeePerGas)
1232
- throw new TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
1233
- }
1234
- class AccountStateConflictError extends BaseError$1 {
1235
- constructor({ address }) {
1236
- super(`State for account "${address}" is set multiple times.`, {
1237
- name: "AccountStateConflictError"
1238
- });
1239
- }
1240
- }
1241
- class StateAssignmentConflictError extends BaseError$1 {
1242
- constructor() {
1243
- super("state and stateDiff are set on the same account.", {
1244
- name: "StateAssignmentConflictError"
1245
- });
1246
- }
1247
- }
1248
- function prettyStateMapping(stateMapping) {
1249
- return stateMapping.reduce((pretty, { slot, value }) => {
1250
- return `${pretty} ${slot}: ${value}
1251
- `;
1252
- }, "");
1253
- }
1254
- function prettyStateOverride(stateOverride) {
1255
- return stateOverride.reduce((pretty, { address, ...state }) => {
1256
- let val = `${pretty} ${address}:
1257
- `;
1258
- if (state.nonce)
1259
- val += ` nonce: ${state.nonce}
1260
- `;
1261
- if (state.balance)
1262
- val += ` balance: ${state.balance}
1263
- `;
1264
- if (state.code)
1265
- val += ` code: ${state.code}
1266
- `;
1267
- if (state.state) {
1268
- val += " state:\n";
1269
- val += prettyStateMapping(state.state);
1270
- }
1271
- if (state.stateDiff) {
1272
- val += " stateDiff:\n";
1273
- val += prettyStateMapping(state.stateDiff);
1274
- }
1275
- return val;
1276
- }, " State Override:\n").slice(0, -1);
1277
- }
1278
- function serializeStateMapping(stateMapping) {
1279
- if (!stateMapping || stateMapping.length === 0)
1280
- return void 0;
1281
- return stateMapping.reduce((acc, { slot, value }) => {
1282
- if (slot.length !== 66)
1283
- throw new InvalidBytesLengthError({
1284
- size: slot.length,
1285
- targetSize: 66,
1286
- type: "hex"
1287
- });
1288
- if (value.length !== 66)
1289
- throw new InvalidBytesLengthError({
1290
- size: value.length,
1291
- targetSize: 66,
1292
- type: "hex"
1293
- });
1294
- acc[slot] = value;
1295
- return acc;
1296
- }, {});
1297
- }
1298
- function serializeAccountStateOverride(parameters) {
1299
- const { balance, nonce, state, stateDiff, code } = parameters;
1300
- const rpcAccountStateOverride = {};
1301
- if (code !== void 0)
1302
- rpcAccountStateOverride.code = code;
1303
- if (balance !== void 0)
1304
- rpcAccountStateOverride.balance = numberToHex(balance);
1305
- if (nonce !== void 0)
1306
- rpcAccountStateOverride.nonce = numberToHex(nonce);
1307
- if (state !== void 0)
1308
- rpcAccountStateOverride.state = serializeStateMapping(state);
1309
- if (stateDiff !== void 0) {
1310
- if (rpcAccountStateOverride.state)
1311
- throw new StateAssignmentConflictError();
1312
- rpcAccountStateOverride.stateDiff = serializeStateMapping(stateDiff);
1313
- }
1314
- return rpcAccountStateOverride;
1315
- }
1316
- function serializeStateOverride(parameters) {
1317
- if (!parameters)
1318
- return void 0;
1319
- const rpcStateOverride = {};
1320
- for (const { address, ...accountState } of parameters) {
1321
- if (!isAddress(address, { strict: false }))
1322
- throw new InvalidAddressError({ address });
1323
- if (rpcStateOverride[address])
1324
- throw new AccountStateConflictError({ address });
1325
- rpcStateOverride[address] = serializeAccountStateOverride(accountState);
1326
- }
1327
- return rpcStateOverride;
1328
- }
1329
- const multicall3Abi = [
1330
- {
1331
- inputs: [
1332
- {
1333
- components: [
1334
- {
1335
- name: "target",
1336
- type: "address"
1337
- },
1338
- {
1339
- name: "allowFailure",
1340
- type: "bool"
1341
- },
1342
- {
1343
- name: "callData",
1344
- type: "bytes"
1345
- }
1346
- ],
1347
- name: "calls",
1348
- type: "tuple[]"
1349
- }
1350
- ],
1351
- name: "aggregate3",
1352
- outputs: [
1353
- {
1354
- components: [
1355
- {
1356
- name: "success",
1357
- type: "bool"
1358
- },
1359
- {
1360
- name: "returnData",
1361
- type: "bytes"
1362
- }
1363
- ],
1364
- name: "returnData",
1365
- type: "tuple[]"
1366
- }
1367
- ],
1368
- stateMutability: "view",
1369
- type: "function"
1370
- }
1371
- ];
1372
- const universalResolverErrors = [
1373
- {
1374
- inputs: [],
1375
- name: "ResolverNotFound",
1376
- type: "error"
1377
- },
1378
- {
1379
- inputs: [],
1380
- name: "ResolverWildcardNotSupported",
1381
- type: "error"
1382
- },
1383
- {
1384
- inputs: [],
1385
- name: "ResolverNotContract",
1386
- type: "error"
1387
- },
1388
- {
1389
- inputs: [
1390
- {
1391
- name: "returnData",
1392
- type: "bytes"
1393
- }
1394
- ],
1395
- name: "ResolverError",
1396
- type: "error"
1397
- },
1398
- {
1399
- inputs: [
1400
- {
1401
- components: [
1402
- {
1403
- name: "status",
1404
- type: "uint16"
1405
- },
1406
- {
1407
- name: "message",
1408
- type: "string"
1409
- }
1410
- ],
1411
- name: "errors",
1412
- type: "tuple[]"
1413
- }
1414
- ],
1415
- name: "HttpError",
1416
- type: "error"
1417
- }
1418
- ];
1419
- const universalResolverResolveAbi = [
1420
- ...universalResolverErrors,
1421
- {
1422
- name: "resolve",
1423
- type: "function",
1424
- stateMutability: "view",
1425
- inputs: [
1426
- { name: "name", type: "bytes" },
1427
- { name: "data", type: "bytes" }
1428
- ],
1429
- outputs: [
1430
- { name: "", type: "bytes" },
1431
- { name: "address", type: "address" }
1432
- ]
1433
- },
1434
- {
1435
- name: "resolve",
1436
- type: "function",
1437
- stateMutability: "view",
1438
- inputs: [
1439
- { name: "name", type: "bytes" },
1440
- { name: "data", type: "bytes" },
1441
- { name: "gateways", type: "string[]" }
1442
- ],
1443
- outputs: [
1444
- { name: "", type: "bytes" },
1445
- { name: "address", type: "address" }
1446
- ]
1447
- }
1448
- ];
1449
- const universalResolverReverseAbi = [
1450
- ...universalResolverErrors,
1451
- {
1452
- name: "reverse",
1453
- type: "function",
1454
- stateMutability: "view",
1455
- inputs: [{ type: "bytes", name: "reverseName" }],
1456
- outputs: [
1457
- { type: "string", name: "resolvedName" },
1458
- { type: "address", name: "resolvedAddress" },
1459
- { type: "address", name: "reverseResolver" },
1460
- { type: "address", name: "resolver" }
1461
- ]
1462
- },
1463
- {
1464
- name: "reverse",
1465
- type: "function",
1466
- stateMutability: "view",
1467
- inputs: [
1468
- { type: "bytes", name: "reverseName" },
1469
- { type: "string[]", name: "gateways" }
1470
- ],
1471
- outputs: [
1472
- { type: "string", name: "resolvedName" },
1473
- { type: "address", name: "resolvedAddress" },
1474
- { type: "address", name: "reverseResolver" },
1475
- { type: "address", name: "resolver" }
1476
- ]
1477
- }
1478
- ];
1479
- const textResolverAbi = [
1480
- {
1481
- name: "text",
1482
- type: "function",
1483
- stateMutability: "view",
1484
- inputs: [
1485
- { name: "name", type: "bytes32" },
1486
- { name: "key", type: "string" }
1487
- ],
1488
- outputs: [{ name: "", type: "string" }]
1489
- }
1490
- ];
1491
- const addressResolverAbi = [
1492
- {
1493
- name: "addr",
1494
- type: "function",
1495
- stateMutability: "view",
1496
- inputs: [{ name: "name", type: "bytes32" }],
1497
- outputs: [{ name: "", type: "address" }]
1498
- },
1499
- {
1500
- name: "addr",
1501
- type: "function",
1502
- stateMutability: "view",
1503
- inputs: [
1504
- { name: "name", type: "bytes32" },
1505
- { name: "coinType", type: "uint256" }
1506
- ],
1507
- outputs: [{ name: "", type: "bytes" }]
1508
- }
1509
- ];
1510
- const universalSignatureValidatorAbi = [
1511
- {
1512
- inputs: [
1513
- {
1514
- name: "_signer",
1515
- type: "address"
1516
- },
1517
- {
1518
- name: "_hash",
1519
- type: "bytes32"
1520
- },
1521
- {
1522
- name: "_signature",
1523
- type: "bytes"
1524
- }
1525
- ],
1526
- stateMutability: "nonpayable",
1527
- type: "constructor"
1528
- },
1529
- {
1530
- inputs: [
1531
- {
1532
- name: "_signer",
1533
- type: "address"
1534
- },
1535
- {
1536
- name: "_hash",
1537
- type: "bytes32"
1538
- },
1539
- {
1540
- name: "_signature",
1541
- type: "bytes"
1542
- }
1543
- ],
1544
- outputs: [
1545
- {
1546
- type: "bool"
1547
- }
1548
- ],
1549
- stateMutability: "nonpayable",
1550
- type: "function",
1551
- name: "isValidSig"
1552
- }
1553
- ];
1554
- function bytesToBigInt(bytes, opts = {}) {
1555
- if (typeof opts.size !== "undefined")
1556
- assertSize(bytes, { size: opts.size });
1557
- const hex = bytesToHex(bytes, opts);
1558
- return hexToBigInt(hex, opts);
1559
- }
1560
- function bytesToBool(bytes_, opts = {}) {
1561
- let bytes = bytes_;
1562
- if (typeof opts.size !== "undefined") {
1563
- assertSize(bytes, { size: opts.size });
1564
- bytes = trim(bytes);
1565
- }
1566
- if (bytes.length > 1 || bytes[0] > 1)
1567
- throw new InvalidBytesBooleanError(bytes);
1568
- return Boolean(bytes[0]);
1569
- }
1570
- function bytesToNumber(bytes, opts = {}) {
1571
- if (typeof opts.size !== "undefined")
1572
- assertSize(bytes, { size: opts.size });
1573
- const hex = bytesToHex(bytes, opts);
1574
- return hexToNumber(hex, opts);
1575
- }
1576
- function bytesToString(bytes_, opts = {}) {
1577
- let bytes = bytes_;
1578
- if (typeof opts.size !== "undefined") {
1579
- assertSize(bytes, { size: opts.size });
1580
- bytes = trim(bytes, { dir: "right" });
1581
- }
1582
- return new TextDecoder().decode(bytes);
1583
- }
1584
- function decodeAbiParameters(params, data) {
1585
- const bytes = typeof data === "string" ? hexToBytes(data) : data;
1586
- const cursor = createCursor(bytes);
1587
- if (size(bytes) === 0 && params.length > 0)
1588
- throw new AbiDecodingZeroDataError();
1589
- if (size(data) && size(data) < 32)
1590
- throw new AbiDecodingDataSizeTooSmallError({
1591
- data: typeof data === "string" ? data : bytesToHex(data),
1592
- params,
1593
- size: size(data)
1594
- });
1595
- let consumed = 0;
1596
- const values = [];
1597
- for (let i = 0; i < params.length; ++i) {
1598
- const param = params[i];
1599
- cursor.setPosition(consumed);
1600
- const [data2, consumed_] = decodeParameter(cursor, param, {
1601
- staticPosition: 0
1602
- });
1603
- consumed += consumed_;
1604
- values.push(data2);
1605
- }
1606
- return values;
1607
- }
1608
- function decodeParameter(cursor, param, { staticPosition }) {
1609
- const arrayComponents = getArrayComponents(param.type);
1610
- if (arrayComponents) {
1611
- const [length, type] = arrayComponents;
1612
- return decodeArray(cursor, { ...param, type }, { length, staticPosition });
1613
- }
1614
- if (param.type === "tuple")
1615
- return decodeTuple(cursor, param, { staticPosition });
1616
- if (param.type === "address")
1617
- return decodeAddress(cursor);
1618
- if (param.type === "bool")
1619
- return decodeBool(cursor);
1620
- if (param.type.startsWith("bytes"))
1621
- return decodeBytes(cursor, param, { staticPosition });
1622
- if (param.type.startsWith("uint") || param.type.startsWith("int"))
1623
- return decodeNumber(cursor, param);
1624
- if (param.type === "string")
1625
- return decodeString(cursor, { staticPosition });
1626
- throw new InvalidAbiDecodingTypeError(param.type, {
1627
- docsPath: "/docs/contract/decodeAbiParameters"
1628
- });
1629
- }
1630
- const sizeOfLength = 32;
1631
- const sizeOfOffset = 32;
1632
- function decodeAddress(cursor) {
1633
- const value = cursor.readBytes(32);
1634
- return [checksumAddress(bytesToHex(sliceBytes(value, -20))), 32];
1635
- }
1636
- function decodeArray(cursor, param, { length, staticPosition }) {
1637
- if (!length) {
1638
- const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
1639
- const start = staticPosition + offset;
1640
- const startOfData = start + sizeOfLength;
1641
- cursor.setPosition(start);
1642
- const length2 = bytesToNumber(cursor.readBytes(sizeOfLength));
1643
- const dynamicChild = hasDynamicChild(param);
1644
- let consumed2 = 0;
1645
- const value2 = [];
1646
- for (let i = 0; i < length2; ++i) {
1647
- cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed2));
1648
- const [data, consumed_] = decodeParameter(cursor, param, {
1649
- staticPosition: startOfData
1650
- });
1651
- consumed2 += consumed_;
1652
- value2.push(data);
1653
- }
1654
- cursor.setPosition(staticPosition + 32);
1655
- return [value2, 32];
1656
- }
1657
- if (hasDynamicChild(param)) {
1658
- const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
1659
- const start = staticPosition + offset;
1660
- const value2 = [];
1661
- for (let i = 0; i < length; ++i) {
1662
- cursor.setPosition(start + i * 32);
1663
- const [data] = decodeParameter(cursor, param, {
1664
- staticPosition: start
1665
- });
1666
- value2.push(data);
1667
- }
1668
- cursor.setPosition(staticPosition + 32);
1669
- return [value2, 32];
1670
- }
1671
- let consumed = 0;
1672
- const value = [];
1673
- for (let i = 0; i < length; ++i) {
1674
- const [data, consumed_] = decodeParameter(cursor, param, {
1675
- staticPosition: staticPosition + consumed
1676
- });
1677
- consumed += consumed_;
1678
- value.push(data);
1679
- }
1680
- return [value, consumed];
1681
- }
1682
- function decodeBool(cursor) {
1683
- return [bytesToBool(cursor.readBytes(32), { size: 32 }), 32];
1684
- }
1685
- function decodeBytes(cursor, param, { staticPosition }) {
1686
- const [_, size2] = param.type.split("bytes");
1687
- if (!size2) {
1688
- const offset = bytesToNumber(cursor.readBytes(32));
1689
- cursor.setPosition(staticPosition + offset);
1690
- const length = bytesToNumber(cursor.readBytes(32));
1691
- if (length === 0) {
1692
- cursor.setPosition(staticPosition + 32);
1693
- return ["0x", 32];
1694
- }
1695
- const data = cursor.readBytes(length);
1696
- cursor.setPosition(staticPosition + 32);
1697
- return [bytesToHex(data), 32];
1698
- }
1699
- const value = bytesToHex(cursor.readBytes(Number.parseInt(size2), 32));
1700
- return [value, 32];
1701
- }
1702
- function decodeNumber(cursor, param) {
1703
- const signed = param.type.startsWith("int");
1704
- const size2 = Number.parseInt(param.type.split("int")[1] || "256");
1705
- const value = cursor.readBytes(32);
1706
- return [
1707
- size2 > 48 ? bytesToBigInt(value, { signed }) : bytesToNumber(value, { signed }),
1708
- 32
1709
- ];
1710
- }
1711
- function decodeTuple(cursor, param, { staticPosition }) {
1712
- const hasUnnamedChild = param.components.length === 0 || param.components.some(({ name }) => !name);
1713
- const value = hasUnnamedChild ? [] : {};
1714
- let consumed = 0;
1715
- if (hasDynamicChild(param)) {
1716
- const offset = bytesToNumber(cursor.readBytes(sizeOfOffset));
1717
- const start = staticPosition + offset;
1718
- for (let i = 0; i < param.components.length; ++i) {
1719
- const component = param.components[i];
1720
- cursor.setPosition(start + consumed);
1721
- const [data, consumed_] = decodeParameter(cursor, component, {
1722
- staticPosition: start
1723
- });
1724
- consumed += consumed_;
1725
- value[hasUnnamedChild ? i : component == null ? void 0 : component.name] = data;
1726
- }
1727
- cursor.setPosition(staticPosition + 32);
1728
- return [value, 32];
1729
- }
1730
- for (let i = 0; i < param.components.length; ++i) {
1731
- const component = param.components[i];
1732
- const [data, consumed_] = decodeParameter(cursor, component, {
1733
- staticPosition
1734
- });
1735
- value[hasUnnamedChild ? i : component == null ? void 0 : component.name] = data;
1736
- consumed += consumed_;
1737
- }
1738
- return [value, consumed];
1739
- }
1740
- function decodeString(cursor, { staticPosition }) {
1741
- const offset = bytesToNumber(cursor.readBytes(32));
1742
- const start = staticPosition + offset;
1743
- cursor.setPosition(start);
1744
- const length = bytesToNumber(cursor.readBytes(32));
1745
- if (length === 0) {
1746
- cursor.setPosition(staticPosition + 32);
1747
- return ["", 32];
1748
- }
1749
- const data = cursor.readBytes(length, 32);
1750
- const value = bytesToString(trim(data));
1751
- cursor.setPosition(staticPosition + 32);
1752
- return [value, 32];
1753
- }
1754
- function hasDynamicChild(param) {
1755
- var _a;
1756
- const { type } = param;
1757
- if (type === "string")
1758
- return true;
1759
- if (type === "bytes")
1760
- return true;
1761
- if (type.endsWith("[]"))
1762
- return true;
1763
- if (type === "tuple")
1764
- return (_a = param.components) == null ? void 0 : _a.some(hasDynamicChild);
1765
- const arrayComponents = getArrayComponents(param.type);
1766
- if (arrayComponents && hasDynamicChild({ ...param, type: arrayComponents[1] }))
1767
- return true;
1768
- return false;
1769
- }
1770
- const hash = (value) => keccak256(toBytes(value));
1771
- function hashSignature(sig) {
1772
- return hash(sig);
1773
- }
1774
- const version = "1.0.8";
1775
- class BaseError extends Error {
1776
- constructor(shortMessage, args = {}) {
1777
- var _a;
1778
- const details = args.cause instanceof BaseError ? args.cause.details : ((_a = args.cause) == null ? void 0 : _a.message) ? args.cause.message : args.details;
1779
- const docsPath2 = args.cause instanceof BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
1780
- const message = [
1781
- shortMessage || "An error occurred.",
1782
- "",
1783
- ...args.metaMessages ? [...args.metaMessages, ""] : [],
1784
- ...docsPath2 ? [`Docs: https://abitype.dev${docsPath2}`] : [],
1785
- ...details ? [`Details: ${details}`] : [],
1786
- `Version: abitype@${version}`
1787
- ].join("\n");
1788
- super(message);
1789
- Object.defineProperty(this, "details", {
1790
- enumerable: true,
1791
- configurable: true,
1792
- writable: true,
1793
- value: void 0
1794
- });
1795
- Object.defineProperty(this, "docsPath", {
1796
- enumerable: true,
1797
- configurable: true,
1798
- writable: true,
1799
- value: void 0
1800
- });
1801
- Object.defineProperty(this, "metaMessages", {
1802
- enumerable: true,
1803
- configurable: true,
1804
- writable: true,
1805
- value: void 0
1806
- });
1807
- Object.defineProperty(this, "shortMessage", {
1808
- enumerable: true,
1809
- configurable: true,
1810
- writable: true,
1811
- value: void 0
1812
- });
1813
- Object.defineProperty(this, "name", {
1814
- enumerable: true,
1815
- configurable: true,
1816
- writable: true,
1817
- value: "AbiTypeError"
1818
- });
1819
- if (args.cause)
1820
- this.cause = args.cause;
1821
- this.details = details;
1822
- this.docsPath = docsPath2;
1823
- this.metaMessages = args.metaMessages;
1824
- this.shortMessage = shortMessage;
1825
- }
1826
- }
1827
- function execTyped(regex, string) {
1828
- const match = regex.exec(string);
1829
- return match == null ? void 0 : match.groups;
1830
- }
1831
- const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/;
1832
- const integerRegex = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;
1833
- const isTupleRegex = /^\(.+?\).*?$/;
1834
- const tupleRegex = /^tuple(?<array>(\[(\d*)\])*)$/;
1835
- function formatAbiParameter(abiParameter) {
1836
- let type = abiParameter.type;
1837
- if (tupleRegex.test(abiParameter.type) && "components" in abiParameter) {
1838
- type = "(";
1839
- const length = abiParameter.components.length;
1840
- for (let i = 0; i < length; i++) {
1841
- const component = abiParameter.components[i];
1842
- type += formatAbiParameter(component);
1843
- if (i < length - 1)
1844
- type += ", ";
1845
- }
1846
- const result = execTyped(tupleRegex, abiParameter.type);
1847
- type += `)${(result == null ? void 0 : result.array) ?? ""}`;
1848
- return formatAbiParameter({
1849
- ...abiParameter,
1850
- type
1851
- });
1852
- }
1853
- if ("indexed" in abiParameter && abiParameter.indexed)
1854
- type = `${type} indexed`;
1855
- if (abiParameter.name)
1856
- return `${type} ${abiParameter.name}`;
1857
- return type;
1858
- }
1859
- function formatAbiParameters(abiParameters) {
1860
- let params = "";
1861
- const length = abiParameters.length;
1862
- for (let i = 0; i < length; i++) {
1863
- const abiParameter = abiParameters[i];
1864
- params += formatAbiParameter(abiParameter);
1865
- if (i !== length - 1)
1866
- params += ", ";
1867
- }
1868
- return params;
1869
- }
1870
- function formatAbiItem(abiItem) {
1871
- var _a;
1872
- if (abiItem.type === "function")
1873
- return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== "nonpayable" ? ` ${abiItem.stateMutability}` : ""}${((_a = abiItem.outputs) == null ? void 0 : _a.length) ? ` returns (${formatAbiParameters(abiItem.outputs)})` : ""}`;
1874
- if (abiItem.type === "event")
1875
- return `event ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
1876
- if (abiItem.type === "error")
1877
- return `error ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
1878
- if (abiItem.type === "constructor")
1879
- return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === "payable" ? " payable" : ""}`;
1880
- if (abiItem.type === "fallback")
1881
- return `fallback() external${abiItem.stateMutability === "payable" ? " payable" : ""}`;
1882
- return "receive() external payable";
1883
- }
1884
- const errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
1885
- function isErrorSignature(signature) {
1886
- return errorSignatureRegex.test(signature);
1887
- }
1888
- function execErrorSignature(signature) {
1889
- return execTyped(errorSignatureRegex, signature);
1890
- }
1891
- const eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;
1892
- function isEventSignature(signature) {
1893
- return eventSignatureRegex.test(signature);
1894
- }
1895
- function execEventSignature(signature) {
1896
- return execTyped(eventSignatureRegex, signature);
1897
- }
1898
- const functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;
1899
- function isFunctionSignature(signature) {
1900
- return functionSignatureRegex.test(signature);
1901
- }
1902
- function execFunctionSignature(signature) {
1903
- return execTyped(functionSignatureRegex, signature);
1904
- }
1905
- const structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;
1906
- function isStructSignature(signature) {
1907
- return structSignatureRegex.test(signature);
1908
- }
1909
- function execStructSignature(signature) {
1910
- return execTyped(structSignatureRegex, signature);
1911
- }
1912
- const constructorSignatureRegex = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;
1913
- function isConstructorSignature(signature) {
1914
- return constructorSignatureRegex.test(signature);
1915
- }
1916
- function execConstructorSignature(signature) {
1917
- return execTyped(constructorSignatureRegex, signature);
1918
- }
1919
- const fallbackSignatureRegex = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;
1920
- function isFallbackSignature(signature) {
1921
- return fallbackSignatureRegex.test(signature);
1922
- }
1923
- function execFallbackSignature(signature) {
1924
- return execTyped(fallbackSignatureRegex, signature);
1925
- }
1926
- const receiveSignatureRegex = /^receive\(\) external payable$/;
1927
- function isReceiveSignature(signature) {
1928
- return receiveSignatureRegex.test(signature);
1929
- }
1930
- const eventModifiers = /* @__PURE__ */ new Set(["indexed"]);
1931
- const functionModifiers = /* @__PURE__ */ new Set([
1932
- "calldata",
1933
- "memory",
1934
- "storage"
1935
- ]);
1936
- class InvalidAbiItemError extends BaseError {
1937
- constructor({ signature }) {
1938
- super("Failed to parse ABI item.", {
1939
- details: `parseAbiItem(${JSON.stringify(signature, null, 2)})`,
1940
- docsPath: "/api/human#parseabiitem-1"
1941
- });
1942
- Object.defineProperty(this, "name", {
1943
- enumerable: true,
1944
- configurable: true,
1945
- writable: true,
1946
- value: "InvalidAbiItemError"
1947
- });
1948
- }
1949
- }
1950
- class UnknownTypeError extends BaseError {
1951
- constructor({ type }) {
1952
- super("Unknown type.", {
1953
- metaMessages: [
1954
- `Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`
1955
- ]
1956
- });
1957
- Object.defineProperty(this, "name", {
1958
- enumerable: true,
1959
- configurable: true,
1960
- writable: true,
1961
- value: "UnknownTypeError"
1962
- });
1963
- }
1964
- }
1965
- class UnknownSolidityTypeError extends BaseError {
1966
- constructor({ type }) {
1967
- super("Unknown type.", {
1968
- metaMessages: [`Type "${type}" is not a valid ABI type.`]
1969
- });
1970
- Object.defineProperty(this, "name", {
1971
- enumerable: true,
1972
- configurable: true,
1973
- writable: true,
1974
- value: "UnknownSolidityTypeError"
1975
- });
1976
- }
1977
- }
1978
- class InvalidParameterError extends BaseError {
1979
- constructor({ param }) {
1980
- super("Invalid ABI parameter.", {
1981
- details: param
1982
- });
1983
- Object.defineProperty(this, "name", {
1984
- enumerable: true,
1985
- configurable: true,
1986
- writable: true,
1987
- value: "InvalidParameterError"
1988
- });
1989
- }
1990
- }
1991
- class SolidityProtectedKeywordError extends BaseError {
1992
- constructor({ param, name }) {
1993
- super("Invalid ABI parameter.", {
1994
- details: param,
1995
- metaMessages: [
1996
- `"${name}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`
1997
- ]
1998
- });
1999
- Object.defineProperty(this, "name", {
2000
- enumerable: true,
2001
- configurable: true,
2002
- writable: true,
2003
- value: "SolidityProtectedKeywordError"
2004
- });
2005
- }
2006
- }
2007
- class InvalidModifierError extends BaseError {
2008
- constructor({ param, type, modifier }) {
2009
- super("Invalid ABI parameter.", {
2010
- details: param,
2011
- metaMessages: [
2012
- `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`
2013
- ]
2014
- });
2015
- Object.defineProperty(this, "name", {
2016
- enumerable: true,
2017
- configurable: true,
2018
- writable: true,
2019
- value: "InvalidModifierError"
2020
- });
2021
- }
2022
- }
2023
- class InvalidFunctionModifierError extends BaseError {
2024
- constructor({ param, type, modifier }) {
2025
- super("Invalid ABI parameter.", {
2026
- details: param,
2027
- metaMessages: [
2028
- `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`,
2029
- `Data location can only be specified for array, struct, or mapping types, but "${modifier}" was given.`
2030
- ]
2031
- });
2032
- Object.defineProperty(this, "name", {
2033
- enumerable: true,
2034
- configurable: true,
2035
- writable: true,
2036
- value: "InvalidFunctionModifierError"
2037
- });
2038
- }
2039
- }
2040
- class InvalidAbiTypeParameterError extends BaseError {
2041
- constructor({ abiParameter }) {
2042
- super("Invalid ABI parameter.", {
2043
- details: JSON.stringify(abiParameter, null, 2),
2044
- metaMessages: ["ABI parameter type is invalid."]
2045
- });
2046
- Object.defineProperty(this, "name", {
2047
- enumerable: true,
2048
- configurable: true,
2049
- writable: true,
2050
- value: "InvalidAbiTypeParameterError"
2051
- });
2052
- }
2053
- }
2054
- class InvalidSignatureError extends BaseError {
2055
- constructor({ signature, type }) {
2056
- super(`Invalid ${type} signature.`, {
2057
- details: signature
2058
- });
2059
- Object.defineProperty(this, "name", {
2060
- enumerable: true,
2061
- configurable: true,
2062
- writable: true,
2063
- value: "InvalidSignatureError"
2064
- });
2065
- }
2066
- }
2067
- class UnknownSignatureError extends BaseError {
2068
- constructor({ signature }) {
2069
- super("Unknown signature.", {
2070
- details: signature
2071
- });
2072
- Object.defineProperty(this, "name", {
2073
- enumerable: true,
2074
- configurable: true,
2075
- writable: true,
2076
- value: "UnknownSignatureError"
2077
- });
2078
- }
2079
- }
2080
- class InvalidStructSignatureError extends BaseError {
2081
- constructor({ signature }) {
2082
- super("Invalid struct signature.", {
2083
- details: signature,
2084
- metaMessages: ["No properties exist."]
2085
- });
2086
- Object.defineProperty(this, "name", {
2087
- enumerable: true,
2088
- configurable: true,
2089
- writable: true,
2090
- value: "InvalidStructSignatureError"
2091
- });
2092
- }
2093
- }
2094
- class CircularReferenceError extends BaseError {
2095
- constructor({ type }) {
2096
- super("Circular reference detected.", {
2097
- metaMessages: [`Struct "${type}" is a circular reference.`]
2098
- });
2099
- Object.defineProperty(this, "name", {
2100
- enumerable: true,
2101
- configurable: true,
2102
- writable: true,
2103
- value: "CircularReferenceError"
2104
- });
2105
- }
2106
- }
2107
- class InvalidParenthesisError extends BaseError {
2108
- constructor({ current, depth }) {
2109
- super("Unbalanced parentheses.", {
2110
- metaMessages: [
2111
- `"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.`
2112
- ],
2113
- details: `Depth "${depth}"`
2114
- });
2115
- Object.defineProperty(this, "name", {
2116
- enumerable: true,
2117
- configurable: true,
2118
- writable: true,
2119
- value: "InvalidParenthesisError"
2120
- });
2121
- }
2122
- }
2123
- function getParameterCacheKey(param, type, structs) {
2124
- let structKey = "";
2125
- if (structs)
2126
- for (const struct of Object.entries(structs)) {
2127
- if (!struct)
2128
- continue;
2129
- let propertyKey = "";
2130
- for (const property of struct[1]) {
2131
- propertyKey += `[${property.type}${property.name ? `:${property.name}` : ""}]`;
2132
- }
2133
- structKey += `(${struct[0]}{${propertyKey}})`;
2134
- }
2135
- if (type)
2136
- return `${type}:${param}${structKey}`;
2137
- return param;
2138
- }
2139
- const parameterCache = /* @__PURE__ */ new Map([
2140
- // Unnamed
2141
- ["address", { type: "address" }],
2142
- ["bool", { type: "bool" }],
2143
- ["bytes", { type: "bytes" }],
2144
- ["bytes32", { type: "bytes32" }],
2145
- ["int", { type: "int256" }],
2146
- ["int256", { type: "int256" }],
2147
- ["string", { type: "string" }],
2148
- ["uint", { type: "uint256" }],
2149
- ["uint8", { type: "uint8" }],
2150
- ["uint16", { type: "uint16" }],
2151
- ["uint24", { type: "uint24" }],
2152
- ["uint32", { type: "uint32" }],
2153
- ["uint64", { type: "uint64" }],
2154
- ["uint96", { type: "uint96" }],
2155
- ["uint112", { type: "uint112" }],
2156
- ["uint160", { type: "uint160" }],
2157
- ["uint192", { type: "uint192" }],
2158
- ["uint256", { type: "uint256" }],
2159
- // Named
2160
- ["address owner", { type: "address", name: "owner" }],
2161
- ["address to", { type: "address", name: "to" }],
2162
- ["bool approved", { type: "bool", name: "approved" }],
2163
- ["bytes _data", { type: "bytes", name: "_data" }],
2164
- ["bytes data", { type: "bytes", name: "data" }],
2165
- ["bytes signature", { type: "bytes", name: "signature" }],
2166
- ["bytes32 hash", { type: "bytes32", name: "hash" }],
2167
- ["bytes32 r", { type: "bytes32", name: "r" }],
2168
- ["bytes32 root", { type: "bytes32", name: "root" }],
2169
- ["bytes32 s", { type: "bytes32", name: "s" }],
2170
- ["string name", { type: "string", name: "name" }],
2171
- ["string symbol", { type: "string", name: "symbol" }],
2172
- ["string tokenURI", { type: "string", name: "tokenURI" }],
2173
- ["uint tokenId", { type: "uint256", name: "tokenId" }],
2174
- ["uint8 v", { type: "uint8", name: "v" }],
2175
- ["uint256 balance", { type: "uint256", name: "balance" }],
2176
- ["uint256 tokenId", { type: "uint256", name: "tokenId" }],
2177
- ["uint256 value", { type: "uint256", name: "value" }],
2178
- // Indexed
2179
- [
2180
- "event:address indexed from",
2181
- { type: "address", name: "from", indexed: true }
2182
- ],
2183
- ["event:address indexed to", { type: "address", name: "to", indexed: true }],
2184
- [
2185
- "event:uint indexed tokenId",
2186
- { type: "uint256", name: "tokenId", indexed: true }
2187
- ],
2188
- [
2189
- "event:uint256 indexed tokenId",
2190
- { type: "uint256", name: "tokenId", indexed: true }
2191
- ]
2192
- ]);
2193
- function parseSignature(signature, structs = {}) {
2194
- if (isFunctionSignature(signature))
2195
- return parseFunctionSignature(signature, structs);
2196
- if (isEventSignature(signature))
2197
- return parseEventSignature(signature, structs);
2198
- if (isErrorSignature(signature))
2199
- return parseErrorSignature(signature, structs);
2200
- if (isConstructorSignature(signature))
2201
- return parseConstructorSignature(signature, structs);
2202
- if (isFallbackSignature(signature))
2203
- return parseFallbackSignature(signature);
2204
- if (isReceiveSignature(signature))
2205
- return {
2206
- type: "receive",
2207
- stateMutability: "payable"
2208
- };
2209
- throw new UnknownSignatureError({ signature });
2210
- }
2211
- function parseFunctionSignature(signature, structs = {}) {
2212
- const match = execFunctionSignature(signature);
2213
- if (!match)
2214
- throw new InvalidSignatureError({ signature, type: "function" });
2215
- const inputParams = splitParameters(match.parameters);
2216
- const inputs = [];
2217
- const inputLength = inputParams.length;
2218
- for (let i = 0; i < inputLength; i++) {
2219
- inputs.push(parseAbiParameter(inputParams[i], {
2220
- modifiers: functionModifiers,
2221
- structs,
2222
- type: "function"
2223
- }));
2224
- }
2225
- const outputs = [];
2226
- if (match.returns) {
2227
- const outputParams = splitParameters(match.returns);
2228
- const outputLength = outputParams.length;
2229
- for (let i = 0; i < outputLength; i++) {
2230
- outputs.push(parseAbiParameter(outputParams[i], {
2231
- modifiers: functionModifiers,
2232
- structs,
2233
- type: "function"
2234
- }));
2235
- }
2236
- }
2237
- return {
2238
- name: match.name,
2239
- type: "function",
2240
- stateMutability: match.stateMutability ?? "nonpayable",
2241
- inputs,
2242
- outputs
2243
- };
2244
- }
2245
- function parseEventSignature(signature, structs = {}) {
2246
- const match = execEventSignature(signature);
2247
- if (!match)
2248
- throw new InvalidSignatureError({ signature, type: "event" });
2249
- const params = splitParameters(match.parameters);
2250
- const abiParameters = [];
2251
- const length = params.length;
2252
- for (let i = 0; i < length; i++)
2253
- abiParameters.push(parseAbiParameter(params[i], {
2254
- modifiers: eventModifiers,
2255
- structs,
2256
- type: "event"
2257
- }));
2258
- return { name: match.name, type: "event", inputs: abiParameters };
2259
- }
2260
- function parseErrorSignature(signature, structs = {}) {
2261
- const match = execErrorSignature(signature);
2262
- if (!match)
2263
- throw new InvalidSignatureError({ signature, type: "error" });
2264
- const params = splitParameters(match.parameters);
2265
- const abiParameters = [];
2266
- const length = params.length;
2267
- for (let i = 0; i < length; i++)
2268
- abiParameters.push(parseAbiParameter(params[i], { structs, type: "error" }));
2269
- return { name: match.name, type: "error", inputs: abiParameters };
2270
- }
2271
- function parseConstructorSignature(signature, structs = {}) {
2272
- const match = execConstructorSignature(signature);
2273
- if (!match)
2274
- throw new InvalidSignatureError({ signature, type: "constructor" });
2275
- const params = splitParameters(match.parameters);
2276
- const abiParameters = [];
2277
- const length = params.length;
2278
- for (let i = 0; i < length; i++)
2279
- abiParameters.push(parseAbiParameter(params[i], { structs, type: "constructor" }));
2280
- return {
2281
- type: "constructor",
2282
- stateMutability: match.stateMutability ?? "nonpayable",
2283
- inputs: abiParameters
2284
- };
2285
- }
2286
- function parseFallbackSignature(signature) {
2287
- const match = execFallbackSignature(signature);
2288
- if (!match)
2289
- throw new InvalidSignatureError({ signature, type: "fallback" });
2290
- return {
2291
- type: "fallback",
2292
- stateMutability: match.stateMutability ?? "nonpayable"
2293
- };
2294
- }
2295
- const abiParameterWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
2296
- const abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/;
2297
- const dynamicIntegerRegex = /^u?int$/;
2298
- function parseAbiParameter(param, options) {
2299
- var _a, _b;
2300
- const parameterCacheKey = getParameterCacheKey(param, options == null ? void 0 : options.type, options == null ? void 0 : options.structs);
2301
- if (parameterCache.has(parameterCacheKey))
2302
- return parameterCache.get(parameterCacheKey);
2303
- const isTuple = isTupleRegex.test(param);
2304
- const match = execTyped(isTuple ? abiParameterWithTupleRegex : abiParameterWithoutTupleRegex, param);
2305
- if (!match)
2306
- throw new InvalidParameterError({ param });
2307
- if (match.name && isSolidityKeyword(match.name))
2308
- throw new SolidityProtectedKeywordError({ param, name: match.name });
2309
- const name = match.name ? { name: match.name } : {};
2310
- const indexed = match.modifier === "indexed" ? { indexed: true } : {};
2311
- const structs = (options == null ? void 0 : options.structs) ?? {};
2312
- let type;
2313
- let components = {};
2314
- if (isTuple) {
2315
- type = "tuple";
2316
- const params = splitParameters(match.type);
2317
- const components_ = [];
2318
- const length = params.length;
2319
- for (let i = 0; i < length; i++) {
2320
- components_.push(parseAbiParameter(params[i], { structs }));
2321
- }
2322
- components = { components: components_ };
2323
- } else if (match.type in structs) {
2324
- type = "tuple";
2325
- components = { components: structs[match.type] };
2326
- } else if (dynamicIntegerRegex.test(match.type)) {
2327
- type = `${match.type}256`;
2328
- } else {
2329
- type = match.type;
2330
- if (!((options == null ? void 0 : options.type) === "struct") && !isSolidityType(type))
2331
- throw new UnknownSolidityTypeError({ type });
2332
- }
2333
- if (match.modifier) {
2334
- if (!((_b = (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.has) == null ? void 0 : _b.call(_a, match.modifier)))
2335
- throw new InvalidModifierError({
2336
- param,
2337
- type: options == null ? void 0 : options.type,
2338
- modifier: match.modifier
2339
- });
2340
- if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array))
2341
- throw new InvalidFunctionModifierError({
2342
- param,
2343
- type: options == null ? void 0 : options.type,
2344
- modifier: match.modifier
2345
- });
2346
- }
2347
- const abiParameter = {
2348
- type: `${type}${match.array ?? ""}`,
2349
- ...name,
2350
- ...indexed,
2351
- ...components
2352
- };
2353
- parameterCache.set(parameterCacheKey, abiParameter);
2354
- return abiParameter;
2355
- }
2356
- function splitParameters(params, result = [], current = "", depth = 0) {
2357
- const length = params.trim().length;
2358
- for (let i = 0; i < length; i++) {
2359
- const char = params[i];
2360
- const tail = params.slice(i + 1);
2361
- switch (char) {
2362
- case ",":
2363
- return depth === 0 ? splitParameters(tail, [...result, current.trim()]) : splitParameters(tail, result, `${current}${char}`, depth);
2364
- case "(":
2365
- return splitParameters(tail, result, `${current}${char}`, depth + 1);
2366
- case ")":
2367
- return splitParameters(tail, result, `${current}${char}`, depth - 1);
2368
- default:
2369
- return splitParameters(tail, result, `${current}${char}`, depth);
2370
- }
2371
- }
2372
- if (current === "")
2373
- return result;
2374
- if (depth !== 0)
2375
- throw new InvalidParenthesisError({ current, depth });
2376
- result.push(current.trim());
2377
- return result;
2378
- }
2379
- function isSolidityType(type) {
2380
- return type === "address" || type === "bool" || type === "function" || type === "string" || bytesRegex.test(type) || integerRegex.test(type);
2381
- }
2382
- const protectedKeywordsRegex = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
2383
- function isSolidityKeyword(name) {
2384
- return name === "address" || name === "bool" || name === "function" || name === "string" || name === "tuple" || bytesRegex.test(name) || integerRegex.test(name) || protectedKeywordsRegex.test(name);
2385
- }
2386
- function isValidDataLocation(type, isArray) {
2387
- return isArray || type === "bytes" || type === "string" || type === "tuple";
2388
- }
2389
- function parseStructs(signatures) {
2390
- const shallowStructs = {};
2391
- const signaturesLength = signatures.length;
2392
- for (let i = 0; i < signaturesLength; i++) {
2393
- const signature = signatures[i];
2394
- if (!isStructSignature(signature))
2395
- continue;
2396
- const match = execStructSignature(signature);
2397
- if (!match)
2398
- throw new InvalidSignatureError({ signature, type: "struct" });
2399
- const properties = match.properties.split(";");
2400
- const components = [];
2401
- const propertiesLength = properties.length;
2402
- for (let k = 0; k < propertiesLength; k++) {
2403
- const property = properties[k];
2404
- const trimmed = property.trim();
2405
- if (!trimmed)
2406
- continue;
2407
- const abiParameter = parseAbiParameter(trimmed, {
2408
- type: "struct"
2409
- });
2410
- components.push(abiParameter);
2411
- }
2412
- if (!components.length)
2413
- throw new InvalidStructSignatureError({ signature });
2414
- shallowStructs[match.name] = components;
2415
- }
2416
- const resolvedStructs = {};
2417
- const entries = Object.entries(shallowStructs);
2418
- const entriesLength = entries.length;
2419
- for (let i = 0; i < entriesLength; i++) {
2420
- const [name, parameters] = entries[i];
2421
- resolvedStructs[name] = resolveStructs(parameters, shallowStructs);
2422
- }
2423
- return resolvedStructs;
2424
- }
2425
- const typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;
2426
- function resolveStructs(abiParameters, structs, ancestors = /* @__PURE__ */ new Set()) {
2427
- const components = [];
2428
- const length = abiParameters.length;
2429
- for (let i = 0; i < length; i++) {
2430
- const abiParameter = abiParameters[i];
2431
- const isTuple = isTupleRegex.test(abiParameter.type);
2432
- if (isTuple)
2433
- components.push(abiParameter);
2434
- else {
2435
- const match = execTyped(typeWithoutTupleRegex, abiParameter.type);
2436
- if (!(match == null ? void 0 : match.type))
2437
- throw new InvalidAbiTypeParameterError({ abiParameter });
2438
- const { array, type } = match;
2439
- if (type in structs) {
2440
- if (ancestors.has(type))
2441
- throw new CircularReferenceError({ type });
2442
- components.push({
2443
- ...abiParameter,
2444
- type: `tuple${array ?? ""}`,
2445
- components: resolveStructs(structs[type] ?? [], structs, /* @__PURE__ */ new Set([...ancestors, type]))
2446
- });
2447
- } else {
2448
- if (isSolidityType(type))
2449
- components.push(abiParameter);
2450
- else
2451
- throw new UnknownTypeError({ type });
2452
- }
2453
- }
2454
- }
2455
- return components;
2456
- }
2457
- function parseAbi(signatures) {
2458
- const structs = parseStructs(signatures);
2459
- const abi = [];
2460
- const length = signatures.length;
2461
- for (let i = 0; i < length; i++) {
2462
- const signature = signatures[i];
2463
- if (isStructSignature(signature))
2464
- continue;
2465
- abi.push(parseSignature(signature, structs));
2466
- }
2467
- return abi;
2468
- }
2469
- function normalizeSignature(signature) {
2470
- let active = true;
2471
- let current = "";
2472
- let level = 0;
2473
- let result = "";
2474
- let valid = false;
2475
- for (let i = 0; i < signature.length; i++) {
2476
- const char = signature[i];
2477
- if (["(", ")", ","].includes(char))
2478
- active = true;
2479
- if (char === "(")
2480
- level++;
2481
- if (char === ")")
2482
- level--;
2483
- if (!active)
2484
- continue;
2485
- if (level === 0) {
2486
- if (char === " " && ["event", "function", ""].includes(result))
2487
- result = "";
2488
- else {
2489
- result += char;
2490
- if (char === ")") {
2491
- valid = true;
2492
- break;
2493
- }
2494
- }
2495
- continue;
2496
- }
2497
- if (char === " ") {
2498
- if (signature[i - 1] !== "," && current !== "," && current !== ",(") {
2499
- current = "";
2500
- active = false;
2501
- }
2502
- continue;
2503
- }
2504
- result += char;
2505
- current += char;
2506
- }
2507
- if (!valid)
2508
- throw new BaseError$1("Unable to normalize signature.");
2509
- return result;
2510
- }
2511
- const toSignature = (def) => {
2512
- const def_ = (() => {
2513
- if (typeof def === "string")
2514
- return def;
2515
- return formatAbiItem(def);
2516
- })();
2517
- return normalizeSignature(def_);
2518
- };
2519
- function toSignatureHash(fn) {
2520
- return hashSignature(toSignature(fn));
2521
- }
2522
- const toEventSelector = toSignatureHash;
2523
- const toFunctionSelector = (fn) => slice(toSignatureHash(fn), 0, 4);
2524
- function getAbiItem(parameters) {
2525
- const { abi, args = [], name } = parameters;
2526
- const isSelector = isHex(name, { strict: false });
2527
- const abiItems = abi.filter((abiItem) => {
2528
- if (isSelector) {
2529
- if (abiItem.type === "function")
2530
- return toFunctionSelector(abiItem) === name;
2531
- if (abiItem.type === "event")
2532
- return toEventSelector(abiItem) === name;
2533
- return false;
2534
- }
2535
- return "name" in abiItem && abiItem.name === name;
2536
- });
2537
- if (abiItems.length === 0)
2538
- return void 0;
2539
- if (abiItems.length === 1)
2540
- return abiItems[0];
2541
- let matchedAbiItem = void 0;
2542
- for (const abiItem of abiItems) {
2543
- if (!("inputs" in abiItem))
2544
- continue;
2545
- if (!args || args.length === 0) {
2546
- if (!abiItem.inputs || abiItem.inputs.length === 0)
2547
- return abiItem;
2548
- continue;
2549
- }
2550
- if (!abiItem.inputs)
2551
- continue;
2552
- if (abiItem.inputs.length === 0)
2553
- continue;
2554
- if (abiItem.inputs.length !== args.length)
2555
- continue;
2556
- const matched = args.every((arg, index) => {
2557
- const abiParameter = "inputs" in abiItem && abiItem.inputs[index];
2558
- if (!abiParameter)
2559
- return false;
2560
- return isArgOfType(arg, abiParameter);
2561
- });
2562
- if (matched) {
2563
- if (matchedAbiItem && "inputs" in matchedAbiItem && matchedAbiItem.inputs) {
2564
- const ambiguousTypes = getAmbiguousTypes(abiItem.inputs, matchedAbiItem.inputs, args);
2565
- if (ambiguousTypes)
2566
- throw new AbiItemAmbiguityError({
2567
- abiItem,
2568
- type: ambiguousTypes[0]
2569
- }, {
2570
- abiItem: matchedAbiItem,
2571
- type: ambiguousTypes[1]
2572
- });
2573
- }
2574
- matchedAbiItem = abiItem;
2575
- }
2576
- }
2577
- if (matchedAbiItem)
2578
- return matchedAbiItem;
2579
- return abiItems[0];
2580
- }
2581
- function isArgOfType(arg, abiParameter) {
2582
- const argType = typeof arg;
2583
- const abiParameterType = abiParameter.type;
2584
- switch (abiParameterType) {
2585
- case "address":
2586
- return isAddress(arg, { strict: false });
2587
- case "bool":
2588
- return argType === "boolean";
2589
- case "function":
2590
- return argType === "string";
2591
- case "string":
2592
- return argType === "string";
2593
- default: {
2594
- if (abiParameterType === "tuple" && "components" in abiParameter)
2595
- return Object.values(abiParameter.components).every((component, index) => {
2596
- return isArgOfType(Object.values(arg)[index], component);
2597
- });
2598
- if (/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(abiParameterType))
2599
- return argType === "number" || argType === "bigint";
2600
- if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))
2601
- return argType === "string" || arg instanceof Uint8Array;
2602
- if (/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(abiParameterType)) {
2603
- return Array.isArray(arg) && arg.every((x) => isArgOfType(x, {
2604
- ...abiParameter,
2605
- // Pop off `[]` or `[M]` from end of type
2606
- type: abiParameterType.replace(/(\[[0-9]{0,}\])$/, "")
2607
- }));
2608
- }
2609
- return false;
2610
- }
2611
- }
2612
- }
2613
- function getAmbiguousTypes(sourceParameters, targetParameters, args) {
2614
- for (const parameterIndex in sourceParameters) {
2615
- const sourceParameter = sourceParameters[parameterIndex];
2616
- const targetParameter = targetParameters[parameterIndex];
2617
- if (sourceParameter.type === "tuple" && targetParameter.type === "tuple" && "components" in sourceParameter && "components" in targetParameter)
2618
- return getAmbiguousTypes(sourceParameter.components, targetParameter.components, args[parameterIndex]);
2619
- const types = [sourceParameter.type, targetParameter.type];
2620
- const ambiguous = (() => {
2621
- if (types.includes("address") && types.includes("bytes20"))
2622
- return true;
2623
- if (types.includes("address") && types.includes("string"))
2624
- return isAddress(args[parameterIndex], { strict: false });
2625
- if (types.includes("address") && types.includes("bytes"))
2626
- return isAddress(args[parameterIndex], { strict: false });
2627
- return false;
2628
- })();
2629
- if (ambiguous)
2630
- return types;
2631
- }
2632
- return;
2633
- }
2634
- const docsPath$1 = "/docs/contract/decodeFunctionResult";
2635
- function decodeFunctionResult(parameters) {
2636
- const { abi, args, functionName, data } = parameters;
2637
- let abiItem = abi[0];
2638
- if (functionName) {
2639
- const item = getAbiItem({ abi, args, name: functionName });
2640
- if (!item)
2641
- throw new AbiFunctionNotFoundError(functionName, { docsPath: docsPath$1 });
2642
- abiItem = item;
2643
- }
2644
- if (abiItem.type !== "function")
2645
- throw new AbiFunctionNotFoundError(void 0, { docsPath: docsPath$1 });
2646
- if (!abiItem.outputs)
2647
- throw new AbiFunctionOutputsNotFoundError(abiItem.name, { docsPath: docsPath$1 });
2648
- const values = decodeAbiParameters(abiItem.outputs, data);
2649
- if (values && values.length > 1)
2650
- return values;
2651
- if (values && values.length === 1)
2652
- return values[0];
2653
- return void 0;
2654
- }
2655
- const docsPath = "/docs/contract/encodeFunctionData";
2656
- function prepareEncodeFunctionData(parameters) {
2657
- const { abi, args, functionName } = parameters;
2658
- let abiItem = abi[0];
2659
- if (functionName) {
2660
- const item = getAbiItem({
2661
- abi,
2662
- args,
2663
- name: functionName
2664
- });
2665
- if (!item)
2666
- throw new AbiFunctionNotFoundError(functionName, { docsPath });
2667
- abiItem = item;
2668
- }
2669
- if (abiItem.type !== "function")
2670
- throw new AbiFunctionNotFoundError(void 0, { docsPath });
2671
- return {
2672
- abi: [abiItem],
2673
- functionName: toFunctionSelector(formatAbiItem$1(abiItem))
2674
- };
2675
- }
2676
- function encodeFunctionData(parameters) {
2677
- const { args } = parameters;
2678
- const { abi, functionName } = (() => {
2679
- var _a;
2680
- if (parameters.abi.length === 1 && ((_a = parameters.functionName) == null ? void 0 : _a.startsWith("0x")))
2681
- return parameters;
2682
- return prepareEncodeFunctionData(parameters);
2683
- })();
2684
- const abiItem = abi[0];
2685
- const signature = functionName;
2686
- const data = "inputs" in abiItem && abiItem.inputs ? encodeAbiParameters(abiItem.inputs, args ?? []) : void 0;
2687
- return concatHex([signature, data ?? "0x"]);
2688
- }
2689
- function getChainContractAddress({ blockNumber, chain, contract: name }) {
2690
- var _a;
2691
- const contract = (_a = chain == null ? void 0 : chain.contracts) == null ? void 0 : _a[name];
2692
- if (!contract)
2693
- throw new ChainDoesNotSupportContract({
2694
- chain,
2695
- contract: { name }
2696
- });
2697
- if (blockNumber && contract.blockCreated && contract.blockCreated > blockNumber)
2698
- throw new ChainDoesNotSupportContract({
2699
- blockNumber,
2700
- chain,
2701
- contract: {
2702
- name,
2703
- blockCreated: contract.blockCreated
2704
- }
2705
- });
2706
- return contract.address;
2707
- }
2708
- const panicReasons = {
2709
- 1: "An `assert` condition failed.",
2710
- 17: "Arithmetic operation resulted in underflow or overflow.",
2711
- 18: "Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",
2712
- 33: "Attempted to convert to an invalid type.",
2713
- 34: "Attempted to access a storage byte array that is incorrectly encoded.",
2714
- 49: "Performed `.pop()` on an empty array",
2715
- 50: "Array index is out of bounds.",
2716
- 65: "Allocated too much memory or created an array which is too large.",
2717
- 81: "Attempted to call a zero-initialized variable of internal function type."
2718
- };
2719
- const solidityError = {
2720
- inputs: [
2721
- {
2722
- name: "message",
2723
- type: "string"
2724
- }
2725
- ],
2726
- name: "Error",
2727
- type: "error"
2728
- };
2729
- const solidityPanic = {
2730
- inputs: [
2731
- {
2732
- name: "reason",
2733
- type: "uint256"
2734
- }
2735
- ],
2736
- name: "Panic",
2737
- type: "error"
2738
- };
2739
- function decodeErrorResult(parameters) {
2740
- const { abi, data } = parameters;
2741
- const signature = slice(data, 0, 4);
2742
- if (signature === "0x")
2743
- throw new AbiDecodingZeroDataError();
2744
- const abi_ = [...abi || [], solidityError, solidityPanic];
2745
- const abiItem = abi_.find((x) => x.type === "error" && signature === toFunctionSelector(formatAbiItem$1(x)));
2746
- if (!abiItem)
2747
- throw new AbiErrorSignatureNotFoundError(signature, {
2748
- docsPath: "/docs/contract/decodeErrorResult"
2749
- });
2750
- return {
2751
- abiItem,
2752
- args: "inputs" in abiItem && abiItem.inputs && abiItem.inputs.length > 0 ? decodeAbiParameters(abiItem.inputs, slice(data, 4)) : void 0,
2753
- errorName: abiItem.name
2754
- };
2755
- }
2756
- function formatAbiItemWithArgs({ abiItem, args, includeFunctionName = true, includeName = false }) {
2757
- if (!("name" in abiItem))
2758
- return;
2759
- if (!("inputs" in abiItem))
2760
- return;
2761
- if (!abiItem.inputs)
2762
- return;
2763
- return `${includeFunctionName ? abiItem.name : ""}(${abiItem.inputs.map((input, i) => `${includeName && input.name ? `${input.name}: ` : ""}${typeof args[i] === "object" ? stringify(args[i]) : args[i]}`).join(", ")})`;
2764
- }
2765
- class CallExecutionError extends BaseError$1 {
2766
- constructor(cause, { account: account_, docsPath: docsPath2, chain, data, gas, gasPrice, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride }) {
2767
- var _a;
2768
- const account = account_ ? parseAccount(account_) : void 0;
2769
- let prettyArgs = prettyPrint({
2770
- from: account == null ? void 0 : account.address,
2771
- to,
2772
- value: typeof value !== "undefined" && `${formatEther(value)} ${((_a = chain == null ? void 0 : chain.nativeCurrency) == null ? void 0 : _a.symbol) || "ETH"}`,
2773
- data,
2774
- gas,
2775
- gasPrice: typeof gasPrice !== "undefined" && `${formatGwei(gasPrice)} gwei`,
2776
- maxFeePerGas: typeof maxFeePerGas !== "undefined" && `${formatGwei(maxFeePerGas)} gwei`,
2777
- maxPriorityFeePerGas: typeof maxPriorityFeePerGas !== "undefined" && `${formatGwei(maxPriorityFeePerGas)} gwei`,
2778
- nonce
2779
- });
2780
- if (stateOverride) {
2781
- prettyArgs += `
2782
- ${prettyStateOverride(stateOverride)}`;
2783
- }
2784
- super(cause.shortMessage, {
2785
- cause,
2786
- docsPath: docsPath2,
2787
- metaMessages: [
2788
- ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
2789
- "Raw Call Arguments:",
2790
- prettyArgs
2791
- ].filter(Boolean),
2792
- name: "CallExecutionError"
2793
- });
2794
- Object.defineProperty(this, "cause", {
2795
- enumerable: true,
2796
- configurable: true,
2797
- writable: true,
2798
- value: void 0
2799
- });
2800
- this.cause = cause;
2801
- }
2802
- }
2803
- class ContractFunctionExecutionError extends BaseError$1 {
2804
- constructor(cause, { abi, args, contractAddress, docsPath: docsPath2, functionName, sender }) {
2805
- const abiItem = getAbiItem({ abi, args, name: functionName });
2806
- const formattedArgs = abiItem ? formatAbiItemWithArgs({
2807
- abiItem,
2808
- args,
2809
- includeFunctionName: false,
2810
- includeName: false
2811
- }) : void 0;
2812
- const functionWithParams = abiItem ? formatAbiItem$1(abiItem, { includeName: true }) : void 0;
2813
- const prettyArgs = prettyPrint({
2814
- address: contractAddress && getContractAddress(contractAddress),
2815
- function: functionWithParams,
2816
- args: formattedArgs && formattedArgs !== "()" && `${[...Array((functionName == null ? void 0 : functionName.length) ?? 0).keys()].map(() => " ").join("")}${formattedArgs}`,
2817
- sender
2818
- });
2819
- super(cause.shortMessage || `An unknown error occurred while executing the contract function "${functionName}".`, {
2820
- cause,
2821
- docsPath: docsPath2,
2822
- metaMessages: [
2823
- ...cause.metaMessages ? [...cause.metaMessages, " "] : [],
2824
- prettyArgs && "Contract Call:",
2825
- prettyArgs
2826
- ].filter(Boolean),
2827
- name: "ContractFunctionExecutionError"
2828
- });
2829
- Object.defineProperty(this, "abi", {
2830
- enumerable: true,
2831
- configurable: true,
2832
- writable: true,
2833
- value: void 0
2834
- });
2835
- Object.defineProperty(this, "args", {
2836
- enumerable: true,
2837
- configurable: true,
2838
- writable: true,
2839
- value: void 0
2840
- });
2841
- Object.defineProperty(this, "cause", {
2842
- enumerable: true,
2843
- configurable: true,
2844
- writable: true,
2845
- value: void 0
2846
- });
2847
- Object.defineProperty(this, "contractAddress", {
2848
- enumerable: true,
2849
- configurable: true,
2850
- writable: true,
2851
- value: void 0
2852
- });
2853
- Object.defineProperty(this, "formattedArgs", {
2854
- enumerable: true,
2855
- configurable: true,
2856
- writable: true,
2857
- value: void 0
2858
- });
2859
- Object.defineProperty(this, "functionName", {
2860
- enumerable: true,
2861
- configurable: true,
2862
- writable: true,
2863
- value: void 0
2864
- });
2865
- Object.defineProperty(this, "sender", {
2866
- enumerable: true,
2867
- configurable: true,
2868
- writable: true,
2869
- value: void 0
2870
- });
2871
- this.abi = abi;
2872
- this.args = args;
2873
- this.cause = cause;
2874
- this.contractAddress = contractAddress;
2875
- this.functionName = functionName;
2876
- this.sender = sender;
2877
- }
2878
- }
2879
- class ContractFunctionRevertedError extends BaseError$1 {
2880
- constructor({ abi, data, functionName, message }) {
2881
- let cause;
2882
- let decodedData = void 0;
2883
- let metaMessages;
2884
- let reason;
2885
- if (data && data !== "0x") {
2886
- try {
2887
- decodedData = decodeErrorResult({ abi, data });
2888
- const { abiItem, errorName, args: errorArgs } = decodedData;
2889
- if (errorName === "Error") {
2890
- reason = errorArgs[0];
2891
- } else if (errorName === "Panic") {
2892
- const [firstArg] = errorArgs;
2893
- reason = panicReasons[firstArg];
2894
- } else {
2895
- const errorWithParams = abiItem ? formatAbiItem$1(abiItem, { includeName: true }) : void 0;
2896
- const formattedArgs = abiItem && errorArgs ? formatAbiItemWithArgs({
2897
- abiItem,
2898
- args: errorArgs,
2899
- includeFunctionName: false,
2900
- includeName: false
2901
- }) : void 0;
2902
- metaMessages = [
2903
- errorWithParams ? `Error: ${errorWithParams}` : "",
2904
- formattedArgs && formattedArgs !== "()" ? ` ${[...Array((errorName == null ? void 0 : errorName.length) ?? 0).keys()].map(() => " ").join("")}${formattedArgs}` : ""
2905
- ];
2906
- }
2907
- } catch (err) {
2908
- cause = err;
2909
- }
2910
- } else if (message)
2911
- reason = message;
2912
- let signature;
2913
- if (cause instanceof AbiErrorSignatureNotFoundError) {
2914
- signature = cause.signature;
2915
- metaMessages = [
2916
- `Unable to decode signature "${signature}" as it was not found on the provided ABI.`,
2917
- "Make sure you are using the correct ABI and that the error exists on it.",
2918
- `You can look up the decoded signature here: https://openchain.xyz/signatures?query=${signature}.`
2919
- ];
2920
- }
2921
- super(reason && reason !== "execution reverted" || signature ? [
2922
- `The contract function "${functionName}" reverted with the following ${signature ? "signature" : "reason"}:`,
2923
- reason || signature
2924
- ].join("\n") : `The contract function "${functionName}" reverted.`, {
2925
- cause,
2926
- metaMessages,
2927
- name: "ContractFunctionRevertedError"
2928
- });
2929
- Object.defineProperty(this, "data", {
2930
- enumerable: true,
2931
- configurable: true,
2932
- writable: true,
2933
- value: void 0
2934
- });
2935
- Object.defineProperty(this, "raw", {
2936
- enumerable: true,
2937
- configurable: true,
2938
- writable: true,
2939
- value: void 0
2940
- });
2941
- Object.defineProperty(this, "reason", {
2942
- enumerable: true,
2943
- configurable: true,
2944
- writable: true,
2945
- value: void 0
2946
- });
2947
- Object.defineProperty(this, "signature", {
2948
- enumerable: true,
2949
- configurable: true,
2950
- writable: true,
2951
- value: void 0
2952
- });
2953
- this.data = decodedData;
2954
- this.raw = data;
2955
- this.reason = reason;
2956
- this.signature = signature;
2957
- }
2958
- }
2959
- class ContractFunctionZeroDataError extends BaseError$1 {
2960
- constructor({ functionName }) {
2961
- super(`The contract function "${functionName}" returned no data ("0x").`, {
2962
- metaMessages: [
2963
- "This could be due to any of the following:",
2964
- ` - The contract does not have the function "${functionName}",`,
2965
- " - The parameters passed to the contract function may be invalid, or",
2966
- " - The address is not a contract."
2967
- ],
2968
- name: "ContractFunctionZeroDataError"
2969
- });
2970
- }
2971
- }
2972
- class CounterfactualDeploymentFailedError extends BaseError$1 {
2973
- constructor({ factory }) {
2974
- super(`Deployment for counterfactual contract call failed${factory ? ` for factory "${factory}".` : ""}`, {
2975
- metaMessages: [
2976
- "Please ensure:",
2977
- "- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).",
2978
- "- The `factoryData` is a valid encoded function call for contract deployment function on the factory."
2979
- ],
2980
- name: "CounterfactualDeploymentFailedError"
2981
- });
2982
- }
2983
- }
2984
- class RawContractError extends BaseError$1 {
2985
- constructor({ data, message }) {
2986
- super(message || "", { name: "RawContractError" });
2987
- Object.defineProperty(this, "code", {
2988
- enumerable: true,
2989
- configurable: true,
2990
- writable: true,
2991
- value: 3
2992
- });
2993
- Object.defineProperty(this, "data", {
2994
- enumerable: true,
2995
- configurable: true,
2996
- writable: true,
2997
- value: void 0
2998
- });
2999
- this.data = data;
3000
- }
3001
- }
3002
- function isNullUniversalResolverError(err, callType) {
3003
- var _a, _b, _c, _d, _e, _f;
3004
- if (!(err instanceof BaseError$1))
3005
- return false;
3006
- const cause = err.walk((e) => e instanceof ContractFunctionRevertedError);
3007
- if (!(cause instanceof ContractFunctionRevertedError))
3008
- return false;
3009
- if (((_a = cause.data) == null ? void 0 : _a.errorName) === "ResolverNotFound")
3010
- return true;
3011
- if (((_b = cause.data) == null ? void 0 : _b.errorName) === "ResolverWildcardNotSupported")
3012
- return true;
3013
- if (((_c = cause.data) == null ? void 0 : _c.errorName) === "ResolverNotContract")
3014
- return true;
3015
- if (((_d = cause.data) == null ? void 0 : _d.errorName) === "ResolverError")
3016
- return true;
3017
- if (((_e = cause.data) == null ? void 0 : _e.errorName) === "HttpError")
3018
- return true;
3019
- if ((_f = cause.reason) == null ? void 0 : _f.includes("Wildcard on non-extended resolvers is not supported"))
3020
- return true;
3021
- if (callType === "reverse" && cause.reason === panicReasons[50])
3022
- return true;
3023
- return false;
3024
- }
3025
- function encodedLabelToLabelhash(label) {
3026
- if (label.length !== 66)
3027
- return null;
3028
- if (label.indexOf("[") !== 0)
3029
- return null;
3030
- if (label.indexOf("]") !== 65)
3031
- return null;
3032
- const hash2 = `0x${label.slice(1, 65)}`;
3033
- if (!isHex(hash2))
3034
- return null;
3035
- return hash2;
3036
- }
3037
- function namehash(name) {
3038
- let result = new Uint8Array(32).fill(0);
3039
- if (!name)
3040
- return bytesToHex(result);
3041
- const labels = name.split(".");
3042
- for (let i = labels.length - 1; i >= 0; i -= 1) {
3043
- const hashFromEncodedLabel = encodedLabelToLabelhash(labels[i]);
3044
- const hashed = hashFromEncodedLabel ? toBytes(hashFromEncodedLabel) : keccak256(stringToBytes(labels[i]), "bytes");
3045
- result = keccak256(concat([result, hashed]), "bytes");
3046
- }
3047
- return bytesToHex(result);
3048
- }
3049
- function encodeLabelhash(hash2) {
3050
- return `[${hash2.slice(2)}]`;
3051
- }
3052
- function labelhash(label) {
3053
- const result = new Uint8Array(32).fill(0);
3054
- if (!label)
3055
- return bytesToHex(result);
3056
- return encodedLabelToLabelhash(label) || keccak256(stringToBytes(label));
3057
- }
3058
- function packetToBytes(packet) {
3059
- const value = packet.replace(/^\.|\.$/gm, "");
3060
- if (value.length === 0)
3061
- return new Uint8Array(1);
3062
- const bytes = new Uint8Array(stringToBytes(value).byteLength + 2);
3063
- let offset = 0;
3064
- const list = value.split(".");
3065
- for (let i = 0; i < list.length; i++) {
3066
- let encoded = stringToBytes(list[i]);
3067
- if (encoded.byteLength > 255)
3068
- encoded = stringToBytes(encodeLabelhash(labelhash(list[i])));
3069
- bytes[offset] = encoded.length;
3070
- bytes.set(encoded, offset + 1);
3071
- offset += encoded.length + 1;
3072
- }
3073
- if (bytes.byteLength !== offset + 1)
3074
- return bytes.slice(0, offset + 1);
3075
- return bytes;
3076
- }
3077
- const EXECUTION_REVERTED_ERROR_CODE = 3;
3078
- function getContractError(err, { abi, address, args, docsPath: docsPath2, functionName, sender }) {
3079
- const error = err instanceof RawContractError ? err : err instanceof BaseError$1 ? err.walk((err2) => "data" in err2) || err.walk() : {};
3080
- const { code, data, details, message, shortMessage } = error;
3081
- const cause = (() => {
3082
- if (err instanceof AbiDecodingZeroDataError)
3083
- return new ContractFunctionZeroDataError({ functionName });
3084
- if ([EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) && (data || details || message || shortMessage)) {
3085
- return new ContractFunctionRevertedError({
3086
- abi,
3087
- data: typeof data === "object" ? data.data : data,
3088
- functionName,
3089
- message: error instanceof RpcRequestError ? details : shortMessage ?? message
3090
- });
3091
- }
3092
- return err;
3093
- })();
3094
- return new ContractFunctionExecutionError(cause, {
3095
- abi,
3096
- args,
3097
- contractAddress: address,
3098
- docsPath: docsPath2,
3099
- functionName,
3100
- sender
3101
- });
3102
- }
3103
- const aggregate3Signature = "0x82ad56cb";
3104
- const deploylessCallViaBytecodeBytecode = "0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe";
3105
- const deploylessCallViaFactoryBytecode = "0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe";
3106
- const universalSignatureValidatorByteCode = "0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";
3107
- function getCallError(err, { docsPath: docsPath2, ...args }) {
3108
- const cause = (() => {
3109
- const cause2 = getNodeError(err, args);
3110
- if (cause2 instanceof UnknownNodeError)
3111
- return err;
3112
- return cause2;
3113
- })();
3114
- return new CallExecutionError(cause, {
3115
- docsPath: docsPath2,
3116
- ...args
3117
- });
3118
- }
3119
- async function call(client, args) {
3120
- var _a, _b, _c, _d;
3121
- const { account: account_ = client.account, batch = Boolean((_a = client.batch) == null ? void 0 : _a.multicall), blockNumber, blockTag = "latest", accessList, blobs, code, data: data_, factory, factoryData, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride, ...rest } = args;
3122
- const account = account_ ? parseAccount(account_) : void 0;
3123
- if (code && (factory || factoryData))
3124
- throw new BaseError$1("Cannot provide both `code` & `factory`/`factoryData` as parameters.");
3125
- if (code && to)
3126
- throw new BaseError$1("Cannot provide both `code` & `to` as parameters.");
3127
- const deploylessCallViaBytecode = code && data_;
3128
- const deploylessCallViaFactory = factory && factoryData && to && data_;
3129
- const deploylessCall = deploylessCallViaBytecode || deploylessCallViaFactory;
3130
- const data = (() => {
3131
- if (deploylessCallViaBytecode)
3132
- return toDeploylessCallViaBytecodeData({
3133
- code,
3134
- data: data_
3135
- });
3136
- if (deploylessCallViaFactory)
3137
- return toDeploylessCallViaFactoryData({
3138
- data: data_,
3139
- factory,
3140
- factoryData,
3141
- to
3142
- });
3143
- return data_;
3144
- })();
3145
- try {
3146
- assertRequest(args);
3147
- const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
3148
- const block = blockNumberHex || blockTag;
3149
- const rpcStateOverride = serializeStateOverride(stateOverride);
3150
- const chainFormat = (_d = (_c = (_b = client.chain) == null ? void 0 : _b.formatters) == null ? void 0 : _c.transactionRequest) == null ? void 0 : _d.format;
3151
- const format = chainFormat || formatTransactionRequest;
3152
- const request = format({
3153
- // Pick out extra data that might exist on the chain's transaction request type.
3154
- ...extract(rest, { format: chainFormat }),
3155
- from: account == null ? void 0 : account.address,
3156
- accessList,
3157
- blobs,
3158
- data,
3159
- gas,
3160
- gasPrice,
3161
- maxFeePerBlobGas,
3162
- maxFeePerGas,
3163
- maxPriorityFeePerGas,
3164
- nonce,
3165
- to: deploylessCall ? void 0 : to,
3166
- value
3167
- });
3168
- if (batch && shouldPerformMulticall({ request }) && !rpcStateOverride) {
3169
- try {
3170
- return await scheduleMulticall(client, {
3171
- ...request,
3172
- blockNumber,
3173
- blockTag
3174
- });
3175
- } catch (err) {
3176
- if (!(err instanceof ClientChainNotConfiguredError) && !(err instanceof ChainDoesNotSupportContract))
3177
- throw err;
3178
- }
3179
- }
3180
- const response = await client.request({
3181
- method: "eth_call",
3182
- params: rpcStateOverride ? [
3183
- request,
3184
- block,
3185
- rpcStateOverride
3186
- ] : [request, block]
3187
- });
3188
- if (response === "0x")
3189
- return { data: void 0 };
3190
- return { data: response };
3191
- } catch (err) {
3192
- const data2 = getRevertErrorData(err);
3193
- const { offchainLookup, offchainLookupSignature } = await __vitePreload(async () => {
3194
- const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-BLPIQK-p.js");
3195
- return { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 };
3196
- }, true ? __vite__mapDeps([0,1,2,3,4,5]) : void 0);
3197
- if (client.ccipRead !== false && (data2 == null ? void 0 : data2.slice(0, 10)) === offchainLookupSignature && to)
3198
- return { data: await offchainLookup(client, { data: data2, to }) };
3199
- if (deploylessCall && (data2 == null ? void 0 : data2.slice(0, 10)) === "0x101bb98d")
3200
- throw new CounterfactualDeploymentFailedError({ factory });
3201
- throw getCallError(err, {
3202
- ...args,
3203
- account,
3204
- chain: client.chain
3205
- });
3206
- }
3207
- }
3208
- function shouldPerformMulticall({ request }) {
3209
- const { data, to, ...request_ } = request;
3210
- if (!data)
3211
- return false;
3212
- if (data.startsWith(aggregate3Signature))
3213
- return false;
3214
- if (!to)
3215
- return false;
3216
- if (Object.values(request_).filter((x) => typeof x !== "undefined").length > 0)
3217
- return false;
3218
- return true;
3219
- }
3220
- async function scheduleMulticall(client, args) {
3221
- var _a;
3222
- const { batchSize = 1024, wait = 0 } = typeof ((_a = client.batch) == null ? void 0 : _a.multicall) === "object" ? client.batch.multicall : {};
3223
- const { blockNumber, blockTag = "latest", data, multicallAddress: multicallAddress_, to } = args;
3224
- let multicallAddress = multicallAddress_;
3225
- if (!multicallAddress) {
3226
- if (!client.chain)
3227
- throw new ClientChainNotConfiguredError();
3228
- multicallAddress = getChainContractAddress({
3229
- blockNumber,
3230
- chain: client.chain,
3231
- contract: "multicall3"
3232
- });
3233
- }
3234
- const blockNumberHex = blockNumber ? numberToHex(blockNumber) : void 0;
3235
- const block = blockNumberHex || blockTag;
3236
- const { schedule } = createBatchScheduler({
3237
- id: `${client.uid}.${block}`,
3238
- wait,
3239
- shouldSplitBatch(args2) {
3240
- const size2 = args2.reduce((size3, { data: data2 }) => size3 + (data2.length - 2), 0);
3241
- return size2 > batchSize * 2;
3242
- },
3243
- fn: async (requests) => {
3244
- const calls = requests.map((request) => ({
3245
- allowFailure: true,
3246
- callData: request.data,
3247
- target: request.to
3248
- }));
3249
- const calldata = encodeFunctionData({
3250
- abi: multicall3Abi,
3251
- args: [calls],
3252
- functionName: "aggregate3"
3253
- });
3254
- const data2 = await client.request({
3255
- method: "eth_call",
3256
- params: [
3257
- {
3258
- data: calldata,
3259
- to: multicallAddress
3260
- },
3261
- block
3262
- ]
3263
- });
3264
- return decodeFunctionResult({
3265
- abi: multicall3Abi,
3266
- args: [calls],
3267
- functionName: "aggregate3",
3268
- data: data2 || "0x"
3269
- });
3270
- }
3271
- });
3272
- const [{ returnData, success }] = await schedule({ data, to });
3273
- if (!success)
3274
- throw new RawContractError({ data: returnData });
3275
- if (returnData === "0x")
3276
- return { data: void 0 };
3277
- return { data: returnData };
3278
- }
3279
- function toDeploylessCallViaBytecodeData(parameters) {
3280
- const { code, data } = parameters;
3281
- return encodeDeployData({
3282
- abi: parseAbi(["constructor(bytes, bytes)"]),
3283
- bytecode: deploylessCallViaBytecodeBytecode,
3284
- args: [code, data]
3285
- });
3286
- }
3287
- function toDeploylessCallViaFactoryData(parameters) {
3288
- const { data, factory, factoryData, to } = parameters;
3289
- return encodeDeployData({
3290
- abi: parseAbi(["constructor(address, bytes, address, bytes)"]),
3291
- bytecode: deploylessCallViaFactoryBytecode,
3292
- args: [to, data, factory, factoryData]
3293
- });
3294
- }
3295
- function getRevertErrorData(err) {
3296
- var _a;
3297
- if (!(err instanceof BaseError$1))
3298
- return void 0;
3299
- const error = err.walk();
3300
- return typeof (error == null ? void 0 : error.data) === "object" ? (_a = error.data) == null ? void 0 : _a.data : error.data;
3301
- }
3302
- async function readContract(client, parameters) {
3303
- const { abi, address, args, functionName, ...rest } = parameters;
3304
- const calldata = encodeFunctionData({
3305
- abi,
3306
- args,
3307
- functionName
3308
- });
3309
- try {
3310
- const { data } = await getAction(client, call, "call")({
3311
- ...rest,
3312
- data: calldata,
3313
- to: address
3314
- });
3315
- return decodeFunctionResult({
3316
- abi,
3317
- args,
3318
- functionName,
3319
- data: data || "0x"
3320
- });
3321
- } catch (error) {
3322
- throw getContractError(error, {
3323
- abi,
3324
- address,
3325
- args,
3326
- docsPath: "/docs/contract/readContract",
3327
- functionName
3328
- });
3329
- }
3330
- }
3331
- class EnsAvatarInvalidMetadataError extends BaseError$1 {
3332
- constructor({ data }) {
3333
- super("Unable to extract image from metadata. The metadata may be malformed or invalid.", {
3334
- metaMessages: [
3335
- "- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.",
3336
- "",
3337
- `Provided data: ${JSON.stringify(data)}`
3338
- ],
3339
- name: "EnsAvatarInvalidMetadataError"
3340
- });
3341
- }
3342
- }
3343
- class EnsAvatarInvalidNftUriError extends BaseError$1 {
3344
- constructor({ reason }) {
3345
- super(`ENS NFT avatar URI is invalid. ${reason}`, {
3346
- name: "EnsAvatarInvalidNftUriError"
3347
- });
3348
- }
3349
- }
3350
- class EnsAvatarUriResolutionError extends BaseError$1 {
3351
- constructor({ uri }) {
3352
- super(`Unable to resolve ENS avatar URI "${uri}". The URI may be malformed, invalid, or does not respond with a valid image.`, { name: "EnsAvatarUriResolutionError" });
3353
- }
3354
- }
3355
- class EnsAvatarUnsupportedNamespaceError extends BaseError$1 {
3356
- constructor({ namespace }) {
3357
- super(`ENS NFT avatar namespace "${namespace}" is not supported. Must be "erc721" or "erc1155".`, { name: "EnsAvatarUnsupportedNamespaceError" });
3358
- }
3359
- }
3360
- const networkRegex = /(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/;
3361
- const ipfsHashRegex = /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/;
3362
- const base64Regex = /^data:([a-zA-Z\-/+]*);base64,([^"].*)/;
3363
- const dataURIRegex = /^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;
3364
- async function isImageUri(uri) {
3365
- try {
3366
- const res = await fetch(uri, { method: "HEAD" });
3367
- if (res.status === 200) {
3368
- const contentType = res.headers.get("content-type");
3369
- return contentType == null ? void 0 : contentType.startsWith("image/");
3370
- }
3371
- return false;
3372
- } catch (error) {
3373
- if (typeof error === "object" && typeof error.response !== "undefined") {
3374
- return false;
3375
- }
3376
- if (!globalThis.hasOwnProperty("Image"))
3377
- return false;
3378
- return new Promise((resolve) => {
3379
- const img = new Image();
3380
- img.onload = () => {
3381
- resolve(true);
3382
- };
3383
- img.onerror = () => {
3384
- resolve(false);
3385
- };
3386
- img.src = uri;
3387
- });
3388
- }
3389
- }
3390
- function getGateway(custom, defaultGateway) {
3391
- if (!custom)
3392
- return defaultGateway;
3393
- if (custom.endsWith("/"))
3394
- return custom.slice(0, -1);
3395
- return custom;
3396
- }
3397
- function resolveAvatarUri({ uri, gatewayUrls }) {
3398
- const isEncoded = base64Regex.test(uri);
3399
- if (isEncoded)
3400
- return { uri, isOnChain: true, isEncoded };
3401
- const ipfsGateway = getGateway(gatewayUrls == null ? void 0 : gatewayUrls.ipfs, "https://ipfs.io");
3402
- const arweaveGateway = getGateway(gatewayUrls == null ? void 0 : gatewayUrls.arweave, "https://arweave.net");
3403
- const networkRegexMatch = uri.match(networkRegex);
3404
- const { protocol, subpath, target, subtarget = "" } = (networkRegexMatch == null ? void 0 : networkRegexMatch.groups) || {};
3405
- const isIPNS = protocol === "ipns:/" || subpath === "ipns/";
3406
- const isIPFS = protocol === "ipfs:/" || subpath === "ipfs/" || ipfsHashRegex.test(uri);
3407
- if (uri.startsWith("http") && !isIPNS && !isIPFS) {
3408
- let replacedUri = uri;
3409
- if (gatewayUrls == null ? void 0 : gatewayUrls.arweave)
3410
- replacedUri = uri.replace(/https:\/\/arweave.net/g, gatewayUrls == null ? void 0 : gatewayUrls.arweave);
3411
- return { uri: replacedUri, isOnChain: false, isEncoded: false };
3412
- }
3413
- if ((isIPNS || isIPFS) && target) {
3414
- return {
3415
- uri: `${ipfsGateway}/${isIPNS ? "ipns" : "ipfs"}/${target}${subtarget}`,
3416
- isOnChain: false,
3417
- isEncoded: false
3418
- };
3419
- }
3420
- if (protocol === "ar:/" && target) {
3421
- return {
3422
- uri: `${arweaveGateway}/${target}${subtarget || ""}`,
3423
- isOnChain: false,
3424
- isEncoded: false
3425
- };
3426
- }
3427
- let parsedUri = uri.replace(dataURIRegex, "");
3428
- if (parsedUri.startsWith("<svg")) {
3429
- parsedUri = `data:image/svg+xml;base64,${btoa(parsedUri)}`;
3430
- }
3431
- if (parsedUri.startsWith("data:") || parsedUri.startsWith("{")) {
3432
- return {
3433
- uri: parsedUri,
3434
- isOnChain: true,
3435
- isEncoded: false
3436
- };
3437
- }
3438
- throw new EnsAvatarUriResolutionError({ uri });
3439
- }
3440
- function getJsonImage(data) {
3441
- if (typeof data !== "object" || !("image" in data) && !("image_url" in data) && !("image_data" in data)) {
3442
- throw new EnsAvatarInvalidMetadataError({ data });
3443
- }
3444
- return data.image || data.image_url || data.image_data;
3445
- }
3446
- async function getMetadataAvatarUri({ gatewayUrls, uri }) {
3447
- try {
3448
- const res = await fetch(uri).then((res2) => res2.json());
3449
- const image = await parseAvatarUri({
3450
- gatewayUrls,
3451
- uri: getJsonImage(res)
3452
- });
3453
- return image;
3454
- } catch {
3455
- throw new EnsAvatarUriResolutionError({ uri });
3456
- }
3457
- }
3458
- async function parseAvatarUri({ gatewayUrls, uri }) {
3459
- const { uri: resolvedURI, isOnChain } = resolveAvatarUri({ uri, gatewayUrls });
3460
- if (isOnChain)
3461
- return resolvedURI;
3462
- const isImage = await isImageUri(resolvedURI);
3463
- if (isImage)
3464
- return resolvedURI;
3465
- throw new EnsAvatarUriResolutionError({ uri });
3466
- }
3467
- function parseNftUri(uri_) {
3468
- let uri = uri_;
3469
- if (uri.startsWith("did:nft:")) {
3470
- uri = uri.replace("did:nft:", "").replace(/_/g, "/");
3471
- }
3472
- const [reference, asset_namespace, tokenID] = uri.split("/");
3473
- const [eip_namespace, chainID] = reference.split(":");
3474
- const [erc_namespace, contractAddress] = asset_namespace.split(":");
3475
- if (!eip_namespace || eip_namespace.toLowerCase() !== "eip155")
3476
- throw new EnsAvatarInvalidNftUriError({ reason: "Only EIP-155 supported" });
3477
- if (!chainID)
3478
- throw new EnsAvatarInvalidNftUriError({ reason: "Chain ID not found" });
3479
- if (!contractAddress)
3480
- throw new EnsAvatarInvalidNftUriError({
3481
- reason: "Contract address not found"
3482
- });
3483
- if (!tokenID)
3484
- throw new EnsAvatarInvalidNftUriError({ reason: "Token ID not found" });
3485
- if (!erc_namespace)
3486
- throw new EnsAvatarInvalidNftUriError({ reason: "ERC namespace not found" });
3487
- return {
3488
- chainID: Number.parseInt(chainID),
3489
- namespace: erc_namespace.toLowerCase(),
3490
- contractAddress,
3491
- tokenID
3492
- };
3493
- }
3494
- async function getNftTokenUri(client, { nft }) {
3495
- if (nft.namespace === "erc721") {
3496
- return readContract(client, {
3497
- address: nft.contractAddress,
3498
- abi: [
3499
- {
3500
- name: "tokenURI",
3501
- type: "function",
3502
- stateMutability: "view",
3503
- inputs: [{ name: "tokenId", type: "uint256" }],
3504
- outputs: [{ name: "", type: "string" }]
3505
- }
3506
- ],
3507
- functionName: "tokenURI",
3508
- args: [BigInt(nft.tokenID)]
3509
- });
3510
- }
3511
- if (nft.namespace === "erc1155") {
3512
- return readContract(client, {
3513
- address: nft.contractAddress,
3514
- abi: [
3515
- {
3516
- name: "uri",
3517
- type: "function",
3518
- stateMutability: "view",
3519
- inputs: [{ name: "_id", type: "uint256" }],
3520
- outputs: [{ name: "", type: "string" }]
3521
- }
3522
- ],
3523
- functionName: "uri",
3524
- args: [BigInt(nft.tokenID)]
3525
- });
3526
- }
3527
- throw new EnsAvatarUnsupportedNamespaceError({ namespace: nft.namespace });
3528
- }
3529
- async function parseAvatarRecord(client, { gatewayUrls, record }) {
3530
- if (/eip155:/i.test(record))
3531
- return parseNftAvatarUri(client, { gatewayUrls, record });
3532
- return parseAvatarUri({ uri: record, gatewayUrls });
3533
- }
3534
- async function parseNftAvatarUri(client, { gatewayUrls, record }) {
3535
- const nft = parseNftUri(record);
3536
- const nftUri = await getNftTokenUri(client, { nft });
3537
- const { uri: resolvedNftUri, isOnChain, isEncoded } = resolveAvatarUri({ uri: nftUri, gatewayUrls });
3538
- if (isOnChain && (resolvedNftUri.includes("data:application/json;base64,") || resolvedNftUri.startsWith("{"))) {
3539
- const encodedJson = isEncoded ? (
3540
- // if it is encoded, decode it
3541
- atob(resolvedNftUri.replace("data:application/json;base64,", ""))
3542
- ) : (
3543
- // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)
3544
- resolvedNftUri
3545
- );
3546
- const decoded = JSON.parse(encodedJson);
3547
- return parseAvatarUri({ uri: getJsonImage(decoded), gatewayUrls });
3548
- }
3549
- let uriTokenId = nft.tokenID;
3550
- if (nft.namespace === "erc1155")
3551
- uriTokenId = uriTokenId.replace("0x", "").padStart(64, "0");
3552
- return getMetadataAvatarUri({
3553
- gatewayUrls,
3554
- uri: resolvedNftUri.replace(/(?:0x)?{id}/, uriTokenId)
3555
- });
3556
- }
3557
- async function getEnsText(client, { blockNumber, blockTag, name, key, gatewayUrls, strict, universalResolverAddress: universalResolverAddress_ }) {
3558
- let universalResolverAddress = universalResolverAddress_;
3559
- if (!universalResolverAddress) {
3560
- if (!client.chain)
3561
- throw new Error("client chain not configured. universalResolverAddress is required.");
3562
- universalResolverAddress = getChainContractAddress({
3563
- blockNumber,
3564
- chain: client.chain,
3565
- contract: "ensUniversalResolver"
3566
- });
3567
- }
3568
- try {
3569
- const readContractParameters = {
3570
- address: universalResolverAddress,
3571
- abi: universalResolverResolveAbi,
3572
- functionName: "resolve",
3573
- args: [
3574
- toHex(packetToBytes(name)),
3575
- encodeFunctionData({
3576
- abi: textResolverAbi,
3577
- functionName: "text",
3578
- args: [namehash(name), key]
3579
- })
3580
- ],
3581
- blockNumber,
3582
- blockTag
3583
- };
3584
- const readContractAction = getAction(client, readContract, "readContract");
3585
- const res = gatewayUrls ? await readContractAction({
3586
- ...readContractParameters,
3587
- args: [...readContractParameters.args, gatewayUrls]
3588
- }) : await readContractAction(readContractParameters);
3589
- if (res[0] === "0x")
3590
- return null;
3591
- const record = decodeFunctionResult({
3592
- abi: textResolverAbi,
3593
- functionName: "text",
3594
- data: res[0]
3595
- });
3596
- return record === "" ? null : record;
3597
- } catch (err) {
3598
- if (strict)
3599
- throw err;
3600
- if (isNullUniversalResolverError(err, "resolve"))
3601
- return null;
3602
- throw err;
3603
- }
3604
- }
3605
- async function getEnsAvatar(client, { blockNumber, blockTag, assetGatewayUrls, name, gatewayUrls, strict, universalResolverAddress }) {
3606
- const record = await getAction(client, getEnsText, "getEnsText")({
3607
- blockNumber,
3608
- blockTag,
3609
- key: "avatar",
3610
- name,
3611
- universalResolverAddress,
3612
- gatewayUrls,
3613
- strict
3614
- });
3615
- if (!record)
3616
- return null;
3617
- try {
3618
- return await parseAvatarRecord(client, {
3619
- record,
3620
- gatewayUrls: assetGatewayUrls
3621
- });
3622
- } catch {
3623
- return null;
3624
- }
3625
- }
3626
- async function getEnsName(client, { address, blockNumber, blockTag, gatewayUrls, strict, universalResolverAddress: universalResolverAddress_ }) {
3627
- let universalResolverAddress = universalResolverAddress_;
3628
- if (!universalResolverAddress) {
3629
- if (!client.chain)
3630
- throw new Error("client chain not configured. universalResolverAddress is required.");
3631
- universalResolverAddress = getChainContractAddress({
3632
- blockNumber,
3633
- chain: client.chain,
3634
- contract: "ensUniversalResolver"
3635
- });
3636
- }
3637
- const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`;
3638
- try {
3639
- const readContractParameters = {
3640
- address: universalResolverAddress,
3641
- abi: universalResolverReverseAbi,
3642
- functionName: "reverse",
3643
- args: [toHex(packetToBytes(reverseNode))],
3644
- blockNumber,
3645
- blockTag
3646
- };
3647
- const readContractAction = getAction(client, readContract, "readContract");
3648
- const [name, resolvedAddress] = gatewayUrls ? await readContractAction({
3649
- ...readContractParameters,
3650
- args: [...readContractParameters.args, gatewayUrls]
3651
- }) : await readContractAction(readContractParameters);
3652
- if (address.toLowerCase() !== resolvedAddress.toLowerCase())
3653
- return null;
3654
- return name;
3655
- } catch (err) {
3656
- if (strict)
3657
- throw err;
3658
- if (isNullUniversalResolverError(err, "reverse"))
3659
- return null;
3660
- throw err;
3661
- }
3662
- }
3663
- export {
3664
- maxUint256 as $,
3665
- getAbiItem as A,
3666
- AbiEventNotFoundError as B,
3667
- formatAbiItem$1 as C,
3668
- toEventSelector as D,
3669
- encodeAbiParameters as E,
3670
- getContractError as F,
3671
- AbiEventSignatureEmptyTopicsError as G,
3672
- AbiEventSignatureNotFoundError as H,
3673
- InvalidSerializableTransactionError as I,
3674
- DecodeLogTopicsMismatch as J,
3675
- decodeAbiParameters as K,
3676
- AbiDecodingDataSizeTooSmallError as L,
3677
- DecodeLogDataMismatch as M,
3678
- TransactionReceiptNotFoundError as N,
3679
- multicall3Abi as O,
3680
- PositionOutOfBoundsError as P,
3681
- AbiDecodingZeroDataError as Q,
3682
- RawContractError as R,
3683
- formatAbiItem as S,
3684
- TransactionNotFoundError as T,
3685
- UnknownNodeError as U,
3686
- concat as V,
3687
- integerRegex$1 as W,
3688
- bytesRegex$1 as X,
3689
- BytesSizeMismatchError as Y,
3690
- sliceHex as Z,
3691
- InvalidChainIdError as _,
3692
- concatHex as a,
3693
- FeeCapTooHighError as a0,
3694
- TipAboveFeeCapError as a1,
3695
- slice as a2,
3696
- InvalidStorageKeySizeError as a3,
3697
- InvalidLegacyVError as a4,
3698
- deploylessCallViaBytecodeBytecode as a5,
3699
- WaitForTransactionReceiptTimeoutError as a6,
3700
- call as a7,
3701
- universalSignatureValidatorAbi as a8,
3702
- encodeDeployData as a9,
3703
- universalSignatureValidatorByteCode as aa,
3704
- CallExecutionError as ab,
3705
- getEnsText as ac,
3706
- getEnsName as ad,
3707
- getEnsAvatar as ae,
3708
- maxUint16 as af,
3709
- defineTransactionRequest as ag,
3710
- decodeErrorResult as ah,
3711
- formatEther as b,
3712
- createCursor as c,
3713
- defineFormatter as d,
3714
- getNodeError as e,
3715
- formatGwei as f,
3716
- getAction as g,
3717
- assertRequest as h,
3718
- formatTransactionRequest as i,
3719
- extract as j,
3720
- parseSignature as k,
3721
- parseStructs as l,
3722
- isStructSignature as m,
3723
- InvalidAbiItemError as n,
3724
- getChainContractAddress as o,
3725
- prettyPrint as p,
3726
- encodeFunctionData as q,
3727
- namehash as r,
3728
- serializeStateOverride as s,
3729
- addressResolverAbi as t,
3730
- packetToBytes as u,
3731
- universalResolverResolveAbi as v,
3732
- readContract as w,
3733
- decodeFunctionResult as x,
3734
- isNullUniversalResolverError as y,
3735
- getCallError as z
3736
- };