openscan-hardhat-links 0.0.2 → 0.0.4

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 (247) hide show
  1. package/README.md +69 -40
  2. package/dist/src/hooks/network.d.ts.map +1 -1
  3. package/dist/src/hooks/network.js +59 -5
  4. package/dist/src/hooks/network.js.map +1 -1
  5. package/dist/src/server.d.ts +37 -0
  6. package/dist/src/server.d.ts.map +1 -0
  7. package/dist/src/server.js +42 -0
  8. package/dist/src/server.js.map +1 -0
  9. package/dist/src/services/base.d.ts +32 -0
  10. package/dist/src/services/base.d.ts.map +1 -0
  11. package/dist/src/services/base.js +34 -0
  12. package/dist/src/services/base.js.map +1 -0
  13. package/dist/src/services/index.d.ts +3 -0
  14. package/dist/src/services/index.d.ts.map +1 -0
  15. package/dist/src/services/index.js +3 -0
  16. package/dist/src/services/index.js.map +1 -0
  17. package/dist/src/services/webapp.d.ts +40 -0
  18. package/dist/src/services/webapp.d.ts.map +1 -0
  19. package/dist/src/services/webapp.js +190 -0
  20. package/dist/src/services/webapp.js.map +1 -0
  21. package/dist/src/type-extensions.d.ts +1 -2
  22. package/dist/src/type-extensions.d.ts.map +1 -1
  23. package/dist/src/utils.d.ts +18 -0
  24. package/dist/src/utils.d.ts.map +1 -0
  25. package/dist/src/utils.js +70 -0
  26. package/dist/src/utils.js.map +1 -0
  27. package/package.json +3 -1
  28. package/src/explorer/dist/1029.bundle.js +1 -0
  29. package/src/explorer/dist/1035.bundle.js +1 -0
  30. package/src/explorer/dist/1061.bundle.js +1 -0
  31. package/src/explorer/dist/1078.bundle.js +1 -0
  32. package/src/explorer/dist/1158.bundle.js +1 -0
  33. package/src/explorer/dist/1165.bundle.js +1 -0
  34. package/src/explorer/dist/1195.bundle.js +1 -0
  35. package/src/explorer/dist/1224.bundle.js +1 -0
  36. package/src/explorer/dist/1247.bundle.js +1 -0
  37. package/src/explorer/dist/1302.bundle.js +1 -0
  38. package/src/explorer/dist/1319.bundle.js +1 -0
  39. package/src/explorer/dist/1408.bundle.js +1 -0
  40. package/src/explorer/dist/1453.bundle.js +1 -0
  41. package/src/explorer/dist/1473.bundle.js +1 -0
  42. package/src/explorer/dist/1476.bundle.js +1 -0
  43. package/src/explorer/dist/1496.bundle.js +1 -0
  44. package/src/explorer/dist/1538.bundle.js +1 -0
  45. package/src/explorer/dist/1611.bundle.js +1 -0
  46. package/src/explorer/dist/1672.bundle.js +1 -0
  47. package/src/explorer/dist/1709.bundle.js +1 -0
  48. package/src/explorer/dist/1824.bundle.js +1 -0
  49. package/src/explorer/dist/1837.bundle.js +1 -0
  50. package/src/explorer/dist/1889.bundle.js +1 -0
  51. package/src/explorer/dist/1975.bundle.js +1 -0
  52. package/src/explorer/dist/1978.bundle.js +1 -0
  53. package/src/explorer/dist/1979.bundle.js +1 -0
  54. package/src/explorer/dist/2011.bundle.js +1 -0
  55. package/src/explorer/dist/2016.bundle.js +1 -0
  56. package/src/explorer/dist/2026.bundle.js +1 -0
  57. package/src/explorer/dist/2062.bundle.js +1 -0
  58. package/src/explorer/dist/2108.bundle.js +1 -0
  59. package/src/explorer/dist/2149.bundle.js +1 -0
  60. package/src/explorer/dist/2161.bundle.js +1 -0
  61. package/src/explorer/dist/2306.bundle.js +1 -0
  62. package/src/explorer/dist/2387.bundle.js +1 -0
  63. package/src/explorer/dist/2391.bundle.js +1 -0
  64. package/src/explorer/dist/2412.bundle.js +1 -0
  65. package/src/explorer/dist/2487.bundle.js +1 -0
  66. package/src/explorer/dist/2565.bundle.js +1 -0
  67. package/src/explorer/dist/2603.bundle.js +1 -0
  68. package/src/explorer/dist/261.bundle.js +1 -0
  69. package/src/explorer/dist/2658.bundle.js +1 -0
  70. package/src/explorer/dist/2688.bundle.js +1 -0
  71. package/src/explorer/dist/2692.bundle.js +1 -0
  72. package/src/explorer/dist/279.bundle.js +1 -0
  73. package/src/explorer/dist/2808.bundle.js +1 -0
  74. package/src/explorer/dist/2838.bundle.js +1 -0
  75. package/src/explorer/dist/2850.bundle.js +1 -0
  76. package/src/explorer/dist/2864.bundle.js +1 -0
  77. package/src/explorer/dist/2896.bundle.js +1 -0
  78. package/src/explorer/dist/2901.bundle.js +1 -0
  79. package/src/explorer/dist/2931.bundle.js +1 -0
  80. package/src/explorer/dist/3006.bundle.js +1 -0
  81. package/src/explorer/dist/3137.bundle.js +1 -0
  82. package/src/explorer/dist/3214.bundle.js +1 -0
  83. package/src/explorer/dist/3235.bundle.js +1 -0
  84. package/src/explorer/dist/3339.bundle.js +1 -0
  85. package/src/explorer/dist/3377.bundle.js +1 -0
  86. package/src/explorer/dist/3438.bundle.js +1 -0
  87. package/src/explorer/dist/3461.bundle.js +1 -0
  88. package/src/explorer/dist/3469.bundle.js +1 -0
  89. package/src/explorer/dist/3509.bundle.js +1 -0
  90. package/src/explorer/dist/3558.bundle.js +1 -0
  91. package/src/explorer/dist/3564.bundle.js +1 -0
  92. package/src/explorer/dist/3698.bundle.js +1 -0
  93. package/src/explorer/dist/3723.bundle.js +1 -0
  94. package/src/explorer/dist/3781.bundle.js +1 -0
  95. package/src/explorer/dist/3855.bundle.js +1 -0
  96. package/src/explorer/dist/3967.bundle.js +1 -0
  97. package/src/explorer/dist/3999.bundle.js +1 -0
  98. package/src/explorer/dist/4006.bundle.js +1 -0
  99. package/src/explorer/dist/4052.bundle.js +1 -0
  100. package/src/explorer/dist/4067.bundle.js +1 -0
  101. package/src/explorer/dist/4163.bundle.js +1 -0
  102. package/src/explorer/dist/4230.bundle.js +1 -0
  103. package/src/explorer/dist/4386.bundle.js +1 -0
  104. package/src/explorer/dist/4449.bundle.js +1 -0
  105. package/src/explorer/dist/4477.bundle.js +1 -0
  106. package/src/explorer/dist/4554.bundle.js +1 -0
  107. package/src/explorer/dist/4590.bundle.js +1 -0
  108. package/src/explorer/dist/4714.bundle.js +1 -0
  109. package/src/explorer/dist/4725.bundle.js +1 -0
  110. package/src/explorer/dist/4736.bundle.js +1 -0
  111. package/src/explorer/dist/4739.bundle.js +1 -0
  112. package/src/explorer/dist/4748.bundle.js +1 -0
  113. package/src/explorer/dist/4778.bundle.js +1 -0
  114. package/src/explorer/dist/4794.bundle.js +1 -0
  115. package/src/explorer/dist/4882.bundle.js +1 -0
  116. package/src/explorer/dist/4933.bundle.js +1 -0
  117. package/src/explorer/dist/4953.bundle.js +1 -0
  118. package/src/explorer/dist/4987.bundle.js +1 -0
  119. package/src/explorer/dist/5036.bundle.js +1 -0
  120. package/src/explorer/dist/5133.bundle.js +1 -0
  121. package/src/explorer/dist/5179.bundle.js +1 -0
  122. package/src/explorer/dist/5195.bundle.js +1 -0
  123. package/src/explorer/dist/5214.bundle.js +1 -0
  124. package/src/explorer/dist/5267.bundle.js +1 -0
  125. package/src/explorer/dist/5327.bundle.js +1 -0
  126. package/src/explorer/dist/5372.bundle.js +1 -0
  127. package/src/explorer/dist/5410.bundle.js +1 -0
  128. package/src/explorer/dist/5420.bundle.js +1 -0
  129. package/src/explorer/dist/5426.bundle.js +1 -0
  130. package/src/explorer/dist/5452.bundle.js +1 -0
  131. package/src/explorer/dist/5518.bundle.js +1 -0
  132. package/src/explorer/dist/5619.bundle.js +1 -0
  133. package/src/explorer/dist/5664.bundle.js +1 -0
  134. package/src/explorer/dist/5732.bundle.js +1 -0
  135. package/src/explorer/dist/5776.bundle.js +1 -0
  136. package/src/explorer/dist/579.bundle.js +1 -0
  137. package/src/explorer/dist/5806.bundle.js +1 -0
  138. package/src/explorer/dist/5823.bundle.js +1 -0
  139. package/src/explorer/dist/5935.bundle.js +1 -0
  140. package/src/explorer/dist/5937.bundle.js +1 -0
  141. package/src/explorer/dist/5943.bundle.js +1 -0
  142. package/src/explorer/dist/6014.bundle.js +1 -0
  143. package/src/explorer/dist/6040.bundle.js +1 -0
  144. package/src/explorer/dist/6099.bundle.js +1 -0
  145. package/src/explorer/dist/6187.bundle.js +1 -0
  146. package/src/explorer/dist/6188.bundle.js +1 -0
  147. package/src/explorer/dist/622.bundle.js +1 -0
  148. package/src/explorer/dist/6228.bundle.js +1 -0
  149. package/src/explorer/dist/6237.bundle.js +1 -0
  150. package/src/explorer/dist/6302.bundle.js +1 -0
  151. package/src/explorer/dist/6348.bundle.js +1 -0
  152. package/src/explorer/dist/6355.bundle.js +1 -0
  153. package/src/explorer/dist/6377.bundle.js +1 -0
  154. package/src/explorer/dist/6407.bundle.js +1 -0
  155. package/src/explorer/dist/6426.bundle.js +1 -0
  156. package/src/explorer/dist/6482.bundle.js +1 -0
  157. package/src/explorer/dist/650.bundle.js +1 -0
  158. package/src/explorer/dist/6530.bundle.js +1 -0
  159. package/src/explorer/dist/6561.bundle.js +1 -0
  160. package/src/explorer/dist/6618.bundle.js +1 -0
  161. package/src/explorer/dist/6689.bundle.js +1 -0
  162. package/src/explorer/dist/669.bundle.js +1 -0
  163. package/src/explorer/dist/6714.bundle.js +1 -0
  164. package/src/explorer/dist/6717.bundle.js +1 -0
  165. package/src/explorer/dist/6728.bundle.js +1 -0
  166. package/src/explorer/dist/676.bundle.js +1 -0
  167. package/src/explorer/dist/6780.bundle.js +1 -0
  168. package/src/explorer/dist/6791.bundle.js +1 -0
  169. package/src/explorer/dist/6828.bundle.js +1 -0
  170. package/src/explorer/dist/6926.bundle.js +1 -0
  171. package/src/explorer/dist/6929.bundle.js +1 -0
  172. package/src/explorer/dist/6952.bundle.js +1 -0
  173. package/src/explorer/dist/6982.bundle.js +1 -0
  174. package/src/explorer/dist/6983.bundle.js +1 -0
  175. package/src/explorer/dist/6984.bundle.js +1 -0
  176. package/src/explorer/dist/70.bundle.js +1 -0
  177. package/src/explorer/dist/7007.bundle.js +1 -0
  178. package/src/explorer/dist/7218.bundle.js +1 -0
  179. package/src/explorer/dist/7243.bundle.js +1 -0
  180. package/src/explorer/dist/7281.bundle.js +1 -0
  181. package/src/explorer/dist/7350.bundle.js +1 -0
  182. package/src/explorer/dist/7450.bundle.js +1 -0
  183. package/src/explorer/dist/7469.bundle.js +1 -0
  184. package/src/explorer/dist/7552.bundle.js +1 -0
  185. package/src/explorer/dist/7612.bundle.js +1 -0
  186. package/src/explorer/dist/7656.bundle.js +1 -0
  187. package/src/explorer/dist/7736.bundle.js +1 -0
  188. package/src/explorer/dist/7833.bundle.js +1 -0
  189. package/src/explorer/dist/7835.bundle.js +1 -0
  190. package/src/explorer/dist/787.bundle.js +1 -0
  191. package/src/explorer/dist/7887.bundle.js +1 -0
  192. package/src/explorer/dist/797791b8ae7fd556ee6a.js +1 -0
  193. package/src/explorer/dist/8127.bundle.js +1 -0
  194. package/src/explorer/dist/8293.bundle.js +1 -0
  195. package/src/explorer/dist/8365.bundle.js +1 -0
  196. package/src/explorer/dist/8397.bundle.js +1 -0
  197. package/src/explorer/dist/8455.bundle.js +1 -0
  198. package/src/explorer/dist/8564.bundle.js +1 -0
  199. package/src/explorer/dist/8602.bundle.js +1 -0
  200. package/src/explorer/dist/877.bundle.js +1 -0
  201. package/src/explorer/dist/8776.bundle.js +1 -0
  202. package/src/explorer/dist/8842.bundle.js +1 -0
  203. package/src/explorer/dist/9146.bundle.js +1 -0
  204. package/src/explorer/dist/9190.bundle.js +1 -0
  205. package/src/explorer/dist/9236.bundle.js +1 -0
  206. package/src/explorer/dist/9375.bundle.js +1 -0
  207. package/src/explorer/dist/9380.bundle.js +1 -0
  208. package/src/explorer/dist/9385.bundle.js +1 -0
  209. package/src/explorer/dist/9390.bundle.js +1 -0
  210. package/src/explorer/dist/9466.bundle.js +1 -0
  211. package/src/explorer/dist/9503.bundle.js +1 -0
  212. package/src/explorer/dist/9624.bundle.js +1 -0
  213. package/src/explorer/dist/9788.bundle.js +1 -0
  214. package/src/explorer/dist/9865.bundle.js +1 -0
  215. package/src/explorer/dist/9907.bundle.js +1 -0
  216. package/src/explorer/dist/9936.bundle.js +1 -0
  217. package/src/explorer/dist/bundle.js +1 -0
  218. package/src/explorer/dist/images/paymentHelp1.35dff52e41e22e90d91c.png +0 -0
  219. package/src/explorer/dist/images/paymentHelp2.08d778959310485fefce.png +0 -0
  220. package/src/explorer/dist/images/paymentHelp3.9908702eec7bdcd83f69.png +0 -0
  221. package/src/explorer/dist/index.html +26 -0
  222. package/src/explorer/dist/manifest.json +25 -0
  223. package/src/explorer/dist/openscan-logo.png +0 -0
  224. package/src/explorer/dist/robots.txt +3 -0
  225. package/src/hooks/network.ts +69 -5
  226. package/src/server.ts +83 -0
  227. package/src/services/base.ts +53 -0
  228. package/src/services/index.ts +2 -0
  229. package/src/services/webapp.ts +227 -0
  230. package/src/type-extensions.ts +1 -2
  231. package/src/utils.ts +83 -0
  232. package/dist/src/hooks/hre.d.ts +0 -4
  233. package/dist/src/hooks/hre.d.ts.map +0 -1
  234. package/dist/src/hooks/hre.js +0 -9
  235. package/dist/src/hooks/hre.js.map +0 -1
  236. package/dist/src/hooks/logger.d.ts +0 -4
  237. package/dist/src/hooks/logger.d.ts.map +0 -1
  238. package/dist/src/hooks/logger.js +0 -23
  239. package/dist/src/hooks/logger.js.map +0 -1
  240. package/dist/src/tasks/my-task.d.ts +0 -7
  241. package/dist/src/tasks/my-task.d.ts.map +0 -1
  242. package/dist/src/tasks/my-task.js +0 -4
  243. package/dist/src/tasks/my-task.js.map +0 -1
  244. package/dist/src/utils/console-wrapper.d.ts +0 -7
  245. package/dist/src/utils/console-wrapper.d.ts.map +0 -1
  246. package/dist/src/utils/console-wrapper.js +0 -54
  247. package/dist/src/utils/console-wrapper.js.map +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # `openscan-hardhat-links`
2
2
 
3
- This is an example plugin that adds a task that prints a greeting.
3
+ A Hardhat plugin that automatically launches the OpenScan Explorer webapp and adds OpenScan links to all transaction logs.
4
4
 
5
5
  ## Installation
6
6
 
@@ -21,23 +21,40 @@ export default defineConfig({
21
21
  });
22
22
  ```
23
23
 
24
+ ## Features
25
+
26
+ This plugin provides two main features:
27
+
28
+ 1. **Automatic OpenScan Explorer Launch**: When you start the Hardhat node, the plugin automatically:
29
+ - Launches a local OpenScan Explorer webapp on port 3030
30
+ - Opens your default browser to <http://localhost:3030>
31
+ - Serves the explorer from the plugin's built-in webapp
32
+
33
+ 2. **OpenScan Links in Logs**: All transaction-related logs include clickable OpenScan links:
34
+ - Transaction hashes → OpenScan transaction view
35
+ - Addresses → OpenScan address view
36
+ - Blocks → OpenScan block view
37
+ - Contract deployments → OpenScan contract view
38
+
24
39
  ## Usage
25
40
 
26
- The plugin adds a new task called `my-task`. To run it, use the this command:
41
+ Simply start your Hardhat node:
27
42
 
28
43
  ```bash
29
- npx hardhat my-task
44
+ npx hardhat node
30
45
  ```
31
46
 
32
- You should see the following output:
33
-
34
- ```
35
- Hello, Hardhat!
36
- ```
47
+ The OpenScan Explorer will automatically launch and your browser will open to the explorer interface. All subsequent transactions will include OpenScan links in the console output
37
48
 
38
49
  ### Configuration
39
50
 
40
- You can configure the greeting that's printed by using the `myConfig` field in your Hardhat config. For example, you can have this config:
51
+ The plugin works out of the box with zero configuration required. The following settings are hardcoded:
52
+
53
+ - **Port**: 3030 (fixed, not configurable)
54
+ - **Auto-open browser**: Always enabled
55
+ - **Webapp path**: Automatically detected from plugin installation
56
+
57
+ You can optionally configure the OpenScan URL and chain ID if you want to customize the link format:
41
58
 
42
59
  ```ts
43
60
  import { defineConfig } from "hardhat/config";
@@ -45,39 +62,51 @@ import myPlugin from "openscan-hardhat-links";
45
62
 
46
63
  export default defineConfig({
47
64
  plugins: [myPlugin],
48
- OpenScan: {
49
- url: "http://localhost:3030",
50
- chainId: "31337",
65
+ openScan: {
66
+ url: "http://localhost:3030", // Optional: default is http://localhost:3030
67
+ chainId: 31337, // Optional: default is 31337
51
68
  },
52
- //...
53
69
  });
54
70
  ```
55
71
 
56
- ### RPC Methods calls logs
57
-
58
- This plugin adds some example code to log different network events. To see it in action, all you need to do is run your Hardhat tests, deployment, or a script.
59
-
60
- ```md
61
- eth_sendTransaction
62
- Contract deployment: Counter
63
- Contract address: 0x5fbdb2315678afecb367f032d93f642f64180aa3
64
- Transaction: 0xa938ef09640a71a454b58e457e4046253d10e2e88674b5e45d724519eb070566
65
- From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
66
- Value: 0 ETH
67
- Gas used: 263088 of 263088
68
- Block #1: 0x53bc103d906615c9b1790960a24ddf9a15e8decb3ed672ad2ec654fb1491397d
69
-
70
- Transaction: http://localhost:3030/31337/tx/0xa938ef09640a71a454b58e457e4046253d10e2e88674b5e45d724519eb070566
71
- From: http://localhost:3030/31337/address/0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
72
- Contract deployment detected
73
-
74
- eth_getTransactionReceipt
75
-
76
- Transaction Receipt:
77
- Transaction: http://localhost:3030/31337/tx/0xa938ef09640a71a454b58e457e4046253d10e2e88674b5e45d724519eb070566
78
- Block #1: http://localhost:3030/31337/block/0x53bc103d906615c9b1790960a24ddf9a15e8decb3ed672ad2ec654fb1491397d
79
- From: http://localhost:3030/31337/address/0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
80
- Gas used: 263088
81
- Status: Success
82
- Contract: http://localhost:3030/31337/address/0x5fbdb2315678afecb367f032d93f642f64180aa3
72
+ ## How It Works
73
+
74
+ ### Webapp Launch
75
+
76
+ The plugin hooks into Hardhat's network lifecycle using the `newConnection` hook. When the Hardhat node starts:
77
+
78
+ 1. The hook detects the first network connection
79
+ 2. Checks if port 3030 is available (fails fast if not)
80
+ 3. Starts a custom HTTP server serving static files from the built-in explorer webapp
81
+ 4. Opens your default browser to the explorer URL
82
+ 5. Logs a success message with a clickable link
83
+
84
+ The webapp continues running as long as the Hardhat node is active and automatically cleans up when the node stops.
85
+
86
+ ### Transaction Logging
87
+
88
+ The plugin uses the `onRequest` network hook to intercept all JSON-RPC requests. For relevant methods (like `eth_sendTransaction`, `eth_getTransactionReceipt`, etc.), it extracts transaction hashes, addresses, and block numbers, then outputs clickable OpenScan links to the console.
89
+
90
+ ## Requirements
91
+
92
+ - Hardhat 3.x
93
+ - Node.js 18+
94
+ - Port 3030 must be available
95
+
96
+ ## Troubleshooting
97
+
98
+ ### Port 3030 Already in Use
99
+
100
+ If you see an error about port 3030 being in use, you need to free up that port:
101
+
102
+ ```bash
103
+ # Find process using port 3030
104
+ lsof -i:3030
105
+
106
+ # Kill the process
107
+ kill -9 <PID>
83
108
  ```
109
+
110
+ ### Browser Doesn't Open Automatically
111
+
112
+ The plugin attempts to open your default browser automatically. If this fails, you can manually navigate to <http://localhost:3030>.
@@ -1 +1 @@
1
- {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/hooks/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;8BAU5C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAAvD,wBA0HE"}
1
+ {"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../../src/hooks/network.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,qBAAqB,CAAC;8BAkD5C,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAAvD,wBA8HE"}
@@ -1,16 +1,53 @@
1
+ import { createOpenscanServer } from "../server.js";
2
+ import { isPortAvailable, openBrowser } from "../utils.js";
1
3
  // Helper function to create clickable terminal links
2
4
  function createClickableLink(url, text) {
3
5
  const displayText = text || url;
4
6
  // OSC 8 escape sequence for hyperlinks: \e]8;;URL\e\\TEXT\e]8;;\e\\
5
7
  return `\x1b]8;;${url}\x1b\\${displayText}\x1b]8;;\x1b\\`;
6
8
  }
9
+ // Module-level state for webapp server
10
+ let webappServer = null;
11
+ let webappStarted = false;
12
+ /**
13
+ * Start the webapp server
14
+ * - Checks port 3030 availability (fail fast if occupied)
15
+ * - Starts server
16
+ * - Auto-opens browser
17
+ */
18
+ async function startWebapp(chainId) {
19
+ try {
20
+ // Check if port 3030 is available (fail fast)
21
+ const portAvailable = await isPortAvailable();
22
+ if (!portAvailable) {
23
+ throw new Error("Port 3030 is already in use. Please free the port and try again.");
24
+ }
25
+ // Create and start server
26
+ webappServer = createOpenscanServer();
27
+ await webappServer.listen();
28
+ const webappUrl = webappServer.getWebappUrl();
29
+ console.log(`\n🔍 OpenScan Explorer: ${createClickableLink(webappUrl)}`);
30
+ console.log(` Network: Chain ID ${chainId}\n`);
31
+ // Auto-open browser (always enabled)
32
+ await openBrowser(webappUrl);
33
+ }
34
+ catch (error) {
35
+ // Fail fast - throw error to stop execution
36
+ const message = error instanceof Error ? error.message : String(error);
37
+ throw new Error(`Failed to start OpenScan Explorer: ${message}`);
38
+ }
39
+ }
7
40
  export default async () => {
8
41
  const handlers = {
9
42
  async newConnection(context, next) {
10
43
  const connection = await next(context);
11
- const { url, chainId } = context.config.openScan;
12
- const openScanUrl = `${url}/${chainId}`;
13
- console.log(`OpenScan: ${createClickableLink(openScanUrl)}`);
44
+ const { chainId } = context.config.openScan;
45
+ // Start webapp on first connection (when Hardhat node starts)
46
+ // The network name is "default" for the built-in Hardhat network
47
+ if (!webappStarted && connection.networkName === "default") {
48
+ webappStarted = true;
49
+ await startWebapp(chainId);
50
+ }
14
51
  return connection;
15
52
  },
16
53
  async onRequest(context, networkConnection, jsonRpcRequest, next) {
@@ -38,10 +75,9 @@ export default async () => {
38
75
  const receipt = result?.result;
39
76
  if (receipt && receipt.blockNumber) {
40
77
  const txHash = receipt.transactionHash;
41
- const blockHash = receipt.blockHash;
42
78
  const blockNumber = parseInt(receipt.blockNumber, 16);
43
79
  const txUrl = `${url}/${chainId}/tx/${txHash}`;
44
- const blockUrl = `${url}/${chainId}/block/${blockHash}`;
80
+ const blockUrl = `${url}/${chainId}/block/${blockNumber}`;
45
81
  const fromUrl = `${url}/${chainId}/address/${receipt.from}`;
46
82
  console.log(`${" Transaction:".padEnd(18)}${createClickableLink(txUrl)}`);
47
83
  console.log(`${` Block #${blockNumber}:`.padEnd(18)}${createClickableLink(blockUrl)}`);
@@ -75,4 +111,22 @@ export default async () => {
75
111
  };
76
112
  return handlers;
77
113
  };
114
+ /**
115
+ * Cleanup on process exit
116
+ */
117
+ const cleanup = async () => {
118
+ if (webappServer) {
119
+ await webappServer.stop();
120
+ webappServer = null;
121
+ }
122
+ };
123
+ process.on("SIGINT", () => {
124
+ void cleanup();
125
+ });
126
+ process.on("SIGTERM", () => {
127
+ void cleanup();
128
+ });
129
+ process.on("exit", () => {
130
+ void cleanup();
131
+ });
78
132
  //# sourceMappingURL=network.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/hooks/network.ts"],"names":[],"mappings":"AAGA,qDAAqD;AACrD,SAAS,mBAAmB,CAAC,GAAW,EAAE,IAAa;IACrD,MAAM,WAAW,GAAG,IAAI,IAAI,GAAG,CAAC;IAChC,oEAAoE;IACpE,OAAO,WAAW,GAAG,SAAS,WAAW,gBAAgB,CAAC;AAC5D,CAAC;AAED,eAAe,KAAK,IAAoC,EAAE;IACxD,MAAM,QAAQ,GAA0B;QACtC,KAAK,CAAC,aAAa,CACjB,OAAoB,EACpB,IAE2C;YAE3C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YAEvC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;YACjD,MAAM,WAAW,GAAG,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;YACxC,OAAO,CAAC,GAAG,CAAC,aAAa,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAE7D,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,IAAI;YAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,iBAAiB,EAAE,cAAc,CAAC,CAAC;YAEtE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC;YAEjD,8CAA8C;YAC9C,IAAI,cAAc,CAAC,MAAM,KAAK,qBAAqB,EAAE,CAAC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I,EAAE,CAAC;QAC1B,YAAY,GAAG,IAAI,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACxB,KAAK,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,KAAK,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;IACtB,KAAK,OAAO,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { WebappService } from "./services/index.js";
2
+ /**
3
+ * OpenscanServer interface - manages webapp lifecycle
4
+ * Fixed configuration: port 3030, always auto-opens browser
5
+ */
6
+ export interface OpenscanServer {
7
+ /**
8
+ * Get references to running services
9
+ */
10
+ services(): {
11
+ webappService: WebappService | null;
12
+ };
13
+ /**
14
+ * Start the webapp server
15
+ */
16
+ listen(): Promise<void>;
17
+ /**
18
+ * Stop the webapp server
19
+ */
20
+ stop(): Promise<void>;
21
+ /**
22
+ * Get the webapp URL (always http://localhost:3030)
23
+ */
24
+ getWebappUrl(): string | null;
25
+ /**
26
+ * Get the webapp port (always 3030)
27
+ */
28
+ getWebappPort(): number;
29
+ }
30
+ /**
31
+ * Create an OpenscanServer instance
32
+ * Fixed dist path: packages/explorer/dist
33
+ * Fixed port: 3030
34
+ * Always auto-opens browser
35
+ */
36
+ export declare function createOpenscanServer(): OpenscanServer;
37
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,QAAQ,IAAI;QACV,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;KACrC,CAAC;IAEF;;OAEG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;OAEG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;IAE9B;;OAEG;IACH,aAAa,IAAI,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAoCrD"}
@@ -0,0 +1,42 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { WebappService } from "./services/index.js";
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ /**
7
+ * Create an OpenscanServer instance
8
+ * Fixed dist path: packages/explorer/dist
9
+ * Fixed port: 3030
10
+ * Always auto-opens browser
11
+ */
12
+ export function createOpenscanServer() {
13
+ let webappService = null;
14
+ // Fixed dist path relative to plugin location
15
+ // When compiled: packages/plugin/dist/src/server.js -> packages/plugin/dist/explorer
16
+ const distPath = path.resolve(__dirname, "../explorer");
17
+ return {
18
+ services() {
19
+ return { webappService };
20
+ },
21
+ async listen() {
22
+ // Create webapp service
23
+ webappService = new WebappService(distPath);
24
+ // Start service (will throw if fails - fail fast strategy)
25
+ await webappService.start();
26
+ await webappService.waitForReady();
27
+ },
28
+ async stop() {
29
+ if (webappService) {
30
+ await webappService.stop();
31
+ webappService = null;
32
+ }
33
+ },
34
+ getWebappUrl() {
35
+ return webappService ? `http://localhost:3030` : null;
36
+ },
37
+ getWebappPort() {
38
+ return 3030;
39
+ },
40
+ };
41
+ }
42
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAmC3C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,aAAa,GAAyB,IAAI,CAAC;IAE/C,8CAA8C;IAC9C,qFAAqF;IACrF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAExD,OAAO;QACL,QAAQ;YACN,OAAO,EAAE,aAAa,EAAE,CAAC;QAC3B,CAAC;QAED,KAAK,CAAC,MAAM;YACV,wBAAwB;YACxB,aAAa,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;YAE5C,2DAA2D;YAC3D,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;YAC5B,MAAM,aAAa,CAAC,YAAY,EAAE,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,IAAI;YACR,IAAI,aAAa,EAAE,CAAC;gBAClB,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;gBAC3B,aAAa,GAAG,IAAI,CAAC;YACvB,CAAC;QACH,CAAC;QAED,YAAY;YACV,OAAO,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;QACxD,CAAC;QAED,aAAa;YACX,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { ChildProcess } from "child_process";
2
+ /**
3
+ * Abstract base class for services (webapp server, external processes, etc.)
4
+ * Uses fixed port 3030 for webapp
5
+ */
6
+ export declare abstract class Service {
7
+ process: ChildProcess | null;
8
+ readonly port: number;
9
+ constructor();
10
+ /**
11
+ * Start the service
12
+ */
13
+ abstract start(): Promise<void>;
14
+ /**
15
+ * Stop the service and cleanup resources
16
+ */
17
+ abstract stop(): Promise<void>;
18
+ /**
19
+ * Wait for service to be ready (health check)
20
+ * @param maxAttempts - Maximum number of health check attempts
21
+ */
22
+ abstract waitForReady(maxAttempts?: number): Promise<void>;
23
+ /**
24
+ * Handle process exit events with proper logging
25
+ */
26
+ protected handleOnExit(name: string): (code: number | null, signal: NodeJS.Signals | null) => void;
27
+ /**
28
+ * Handle process errors with proper logging
29
+ */
30
+ protected handleOnError(name: string, reject: (reason?: Error) => void): (error: Error) => void;
31
+ }
32
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/services/base.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD;;;GAGG;AACH,8BAAsB,OAAO;IACpB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAQ;IAC3C,SAAgB,IAAI,EAAE,MAAM,CAAQ;;IAMpC;;OAEG;IACH,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1D;;OAEG;IACH,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,IACzB,MAAM,MAAM,GAAG,IAAI,EAAE,QAAQ,MAAM,CAAC,OAAO,GAAG,IAAI;IAS5D;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,KAAK,IAAI,IAC5D,OAAO,KAAK;CAKvB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Abstract base class for services (webapp server, external processes, etc.)
3
+ * Uses fixed port 3030 for webapp
4
+ */
5
+ export class Service {
6
+ process = null;
7
+ port = 3030;
8
+ constructor() {
9
+ // Fixed port 3030
10
+ }
11
+ /**
12
+ * Handle process exit events with proper logging
13
+ */
14
+ handleOnExit(name) {
15
+ return (code, signal) => {
16
+ if (signal) {
17
+ console.log(`[openscan] ${name} received ${signal}, exiting...`);
18
+ }
19
+ else if (code !== null && code !== 0) {
20
+ console.error(`[openscan] ${name} exited with code ${code}`);
21
+ }
22
+ };
23
+ }
24
+ /**
25
+ * Handle process errors with proper logging
26
+ */
27
+ handleOnError(name, reject) {
28
+ return (error) => {
29
+ console.error(`[openscan] Error starting ${name}: ${error.message}`);
30
+ reject(error);
31
+ };
32
+ }
33
+ }
34
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../../src/services/base.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAgB,OAAO;IACpB,OAAO,GAAwB,IAAI,CAAC;IAC3B,IAAI,GAAW,IAAI,CAAC;IAEpC;QACE,kBAAkB;IACpB,CAAC;IAkBD;;OAEG;IACO,YAAY,CAAC,IAAY;QACjC,OAAO,CAAC,IAAmB,EAAE,MAA6B,EAAE,EAAE;YAC5D,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,aAAa,MAAM,cAAc,CAAC,CAAC;YACnE,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACvC,OAAO,CAAC,KAAK,CAAC,cAAc,IAAI,qBAAqB,IAAI,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,aAAa,CAAC,IAAY,EAAE,MAAgC;QACpE,OAAO,CAAC,KAAY,EAAE,EAAE;YACtB,OAAO,CAAC,KAAK,CAAC,6BAA6B,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export { Service } from "./base.js";
2
+ export { WebappService } from "./webapp.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Service } from "./base.js";
2
+ export { WebappService } from "./webapp.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { Service } from "./base.js";
2
+ /**
3
+ * WebappService - Custom HTTP server for serving static files
4
+ * No external dependencies - uses only Node.js built-in modules
5
+ * Fixed port: 3030
6
+ */
7
+ export declare class WebappService extends Service {
8
+ private distPath;
9
+ private server;
10
+ constructor(distPath: string);
11
+ /**
12
+ * Start the HTTP server
13
+ */
14
+ start(): Promise<void>;
15
+ /**
16
+ * Stop the HTTP server
17
+ */
18
+ stop(): Promise<void>;
19
+ /**
20
+ * Wait for server to be ready by polling the health endpoint
21
+ */
22
+ waitForReady(maxAttempts?: number): Promise<void>;
23
+ /**
24
+ * Handle incoming HTTP requests
25
+ */
26
+ private handleRequest;
27
+ /**
28
+ * Serve a file with proper MIME type and caching headers
29
+ */
30
+ private serveFile;
31
+ /**
32
+ * Send 404 Not Found response
33
+ */
34
+ private send404;
35
+ /**
36
+ * Send 500 Internal Server Error response
37
+ */
38
+ private send500;
39
+ }
40
+ //# sourceMappingURL=webapp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webapp.d.ts","sourceRoot":"","sources":["../../../src/services/webapp.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBpC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,OAAO;IACxC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAA4B;gBAE9B,QAAQ,EAAE,MAAM;IAK5B;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4C5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAY3B;;OAEG;IACG,YAAY,CAAC,WAAW,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBnD;;OAEG;IACH,OAAO,CAAC,aAAa;IAgDrB;;OAEG;IACH,OAAO,CAAC,SAAS;IAgCjB;;OAEG;IACH,OAAO,CAAC,OAAO;IAKf;;OAEG;IACH,OAAO,CAAC,OAAO;CAIhB"}