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.
- package/README.md +69 -40
- package/dist/src/hooks/network.d.ts.map +1 -1
- package/dist/src/hooks/network.js +59 -5
- package/dist/src/hooks/network.js.map +1 -1
- package/dist/src/server.d.ts +37 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +42 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/services/base.d.ts +32 -0
- package/dist/src/services/base.d.ts.map +1 -0
- package/dist/src/services/base.js +34 -0
- package/dist/src/services/base.js.map +1 -0
- package/dist/src/services/index.d.ts +3 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +3 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/webapp.d.ts +40 -0
- package/dist/src/services/webapp.d.ts.map +1 -0
- package/dist/src/services/webapp.js +190 -0
- package/dist/src/services/webapp.js.map +1 -0
- package/dist/src/type-extensions.d.ts +1 -2
- package/dist/src/type-extensions.d.ts.map +1 -1
- package/dist/src/utils.d.ts +18 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +70 -0
- package/dist/src/utils.js.map +1 -0
- package/package.json +3 -1
- package/src/explorer/dist/1029.bundle.js +1 -0
- package/src/explorer/dist/1035.bundle.js +1 -0
- package/src/explorer/dist/1061.bundle.js +1 -0
- package/src/explorer/dist/1078.bundle.js +1 -0
- package/src/explorer/dist/1158.bundle.js +1 -0
- package/src/explorer/dist/1165.bundle.js +1 -0
- package/src/explorer/dist/1195.bundle.js +1 -0
- package/src/explorer/dist/1224.bundle.js +1 -0
- package/src/explorer/dist/1247.bundle.js +1 -0
- package/src/explorer/dist/1302.bundle.js +1 -0
- package/src/explorer/dist/1319.bundle.js +1 -0
- package/src/explorer/dist/1408.bundle.js +1 -0
- package/src/explorer/dist/1453.bundle.js +1 -0
- package/src/explorer/dist/1473.bundle.js +1 -0
- package/src/explorer/dist/1476.bundle.js +1 -0
- package/src/explorer/dist/1496.bundle.js +1 -0
- package/src/explorer/dist/1538.bundle.js +1 -0
- package/src/explorer/dist/1611.bundle.js +1 -0
- package/src/explorer/dist/1672.bundle.js +1 -0
- package/src/explorer/dist/1709.bundle.js +1 -0
- package/src/explorer/dist/1824.bundle.js +1 -0
- package/src/explorer/dist/1837.bundle.js +1 -0
- package/src/explorer/dist/1889.bundle.js +1 -0
- package/src/explorer/dist/1975.bundle.js +1 -0
- package/src/explorer/dist/1978.bundle.js +1 -0
- package/src/explorer/dist/1979.bundle.js +1 -0
- package/src/explorer/dist/2011.bundle.js +1 -0
- package/src/explorer/dist/2016.bundle.js +1 -0
- package/src/explorer/dist/2026.bundle.js +1 -0
- package/src/explorer/dist/2062.bundle.js +1 -0
- package/src/explorer/dist/2108.bundle.js +1 -0
- package/src/explorer/dist/2149.bundle.js +1 -0
- package/src/explorer/dist/2161.bundle.js +1 -0
- package/src/explorer/dist/2306.bundle.js +1 -0
- package/src/explorer/dist/2387.bundle.js +1 -0
- package/src/explorer/dist/2391.bundle.js +1 -0
- package/src/explorer/dist/2412.bundle.js +1 -0
- package/src/explorer/dist/2487.bundle.js +1 -0
- package/src/explorer/dist/2565.bundle.js +1 -0
- package/src/explorer/dist/2603.bundle.js +1 -0
- package/src/explorer/dist/261.bundle.js +1 -0
- package/src/explorer/dist/2658.bundle.js +1 -0
- package/src/explorer/dist/2688.bundle.js +1 -0
- package/src/explorer/dist/2692.bundle.js +1 -0
- package/src/explorer/dist/279.bundle.js +1 -0
- package/src/explorer/dist/2808.bundle.js +1 -0
- package/src/explorer/dist/2838.bundle.js +1 -0
- package/src/explorer/dist/2850.bundle.js +1 -0
- package/src/explorer/dist/2864.bundle.js +1 -0
- package/src/explorer/dist/2896.bundle.js +1 -0
- package/src/explorer/dist/2901.bundle.js +1 -0
- package/src/explorer/dist/2931.bundle.js +1 -0
- package/src/explorer/dist/3006.bundle.js +1 -0
- package/src/explorer/dist/3137.bundle.js +1 -0
- package/src/explorer/dist/3214.bundle.js +1 -0
- package/src/explorer/dist/3235.bundle.js +1 -0
- package/src/explorer/dist/3339.bundle.js +1 -0
- package/src/explorer/dist/3377.bundle.js +1 -0
- package/src/explorer/dist/3438.bundle.js +1 -0
- package/src/explorer/dist/3461.bundle.js +1 -0
- package/src/explorer/dist/3469.bundle.js +1 -0
- package/src/explorer/dist/3509.bundle.js +1 -0
- package/src/explorer/dist/3558.bundle.js +1 -0
- package/src/explorer/dist/3564.bundle.js +1 -0
- package/src/explorer/dist/3698.bundle.js +1 -0
- package/src/explorer/dist/3723.bundle.js +1 -0
- package/src/explorer/dist/3781.bundle.js +1 -0
- package/src/explorer/dist/3855.bundle.js +1 -0
- package/src/explorer/dist/3967.bundle.js +1 -0
- package/src/explorer/dist/3999.bundle.js +1 -0
- package/src/explorer/dist/4006.bundle.js +1 -0
- package/src/explorer/dist/4052.bundle.js +1 -0
- package/src/explorer/dist/4067.bundle.js +1 -0
- package/src/explorer/dist/4163.bundle.js +1 -0
- package/src/explorer/dist/4230.bundle.js +1 -0
- package/src/explorer/dist/4386.bundle.js +1 -0
- package/src/explorer/dist/4449.bundle.js +1 -0
- package/src/explorer/dist/4477.bundle.js +1 -0
- package/src/explorer/dist/4554.bundle.js +1 -0
- package/src/explorer/dist/4590.bundle.js +1 -0
- package/src/explorer/dist/4714.bundle.js +1 -0
- package/src/explorer/dist/4725.bundle.js +1 -0
- package/src/explorer/dist/4736.bundle.js +1 -0
- package/src/explorer/dist/4739.bundle.js +1 -0
- package/src/explorer/dist/4748.bundle.js +1 -0
- package/src/explorer/dist/4778.bundle.js +1 -0
- package/src/explorer/dist/4794.bundle.js +1 -0
- package/src/explorer/dist/4882.bundle.js +1 -0
- package/src/explorer/dist/4933.bundle.js +1 -0
- package/src/explorer/dist/4953.bundle.js +1 -0
- package/src/explorer/dist/4987.bundle.js +1 -0
- package/src/explorer/dist/5036.bundle.js +1 -0
- package/src/explorer/dist/5133.bundle.js +1 -0
- package/src/explorer/dist/5179.bundle.js +1 -0
- package/src/explorer/dist/5195.bundle.js +1 -0
- package/src/explorer/dist/5214.bundle.js +1 -0
- package/src/explorer/dist/5267.bundle.js +1 -0
- package/src/explorer/dist/5327.bundle.js +1 -0
- package/src/explorer/dist/5372.bundle.js +1 -0
- package/src/explorer/dist/5410.bundle.js +1 -0
- package/src/explorer/dist/5420.bundle.js +1 -0
- package/src/explorer/dist/5426.bundle.js +1 -0
- package/src/explorer/dist/5452.bundle.js +1 -0
- package/src/explorer/dist/5518.bundle.js +1 -0
- package/src/explorer/dist/5619.bundle.js +1 -0
- package/src/explorer/dist/5664.bundle.js +1 -0
- package/src/explorer/dist/5732.bundle.js +1 -0
- package/src/explorer/dist/5776.bundle.js +1 -0
- package/src/explorer/dist/579.bundle.js +1 -0
- package/src/explorer/dist/5806.bundle.js +1 -0
- package/src/explorer/dist/5823.bundle.js +1 -0
- package/src/explorer/dist/5935.bundle.js +1 -0
- package/src/explorer/dist/5937.bundle.js +1 -0
- package/src/explorer/dist/5943.bundle.js +1 -0
- package/src/explorer/dist/6014.bundle.js +1 -0
- package/src/explorer/dist/6040.bundle.js +1 -0
- package/src/explorer/dist/6099.bundle.js +1 -0
- package/src/explorer/dist/6187.bundle.js +1 -0
- package/src/explorer/dist/6188.bundle.js +1 -0
- package/src/explorer/dist/622.bundle.js +1 -0
- package/src/explorer/dist/6228.bundle.js +1 -0
- package/src/explorer/dist/6237.bundle.js +1 -0
- package/src/explorer/dist/6302.bundle.js +1 -0
- package/src/explorer/dist/6348.bundle.js +1 -0
- package/src/explorer/dist/6355.bundle.js +1 -0
- package/src/explorer/dist/6377.bundle.js +1 -0
- package/src/explorer/dist/6407.bundle.js +1 -0
- package/src/explorer/dist/6426.bundle.js +1 -0
- package/src/explorer/dist/6482.bundle.js +1 -0
- package/src/explorer/dist/650.bundle.js +1 -0
- package/src/explorer/dist/6530.bundle.js +1 -0
- package/src/explorer/dist/6561.bundle.js +1 -0
- package/src/explorer/dist/6618.bundle.js +1 -0
- package/src/explorer/dist/6689.bundle.js +1 -0
- package/src/explorer/dist/669.bundle.js +1 -0
- package/src/explorer/dist/6714.bundle.js +1 -0
- package/src/explorer/dist/6717.bundle.js +1 -0
- package/src/explorer/dist/6728.bundle.js +1 -0
- package/src/explorer/dist/676.bundle.js +1 -0
- package/src/explorer/dist/6780.bundle.js +1 -0
- package/src/explorer/dist/6791.bundle.js +1 -0
- package/src/explorer/dist/6828.bundle.js +1 -0
- package/src/explorer/dist/6926.bundle.js +1 -0
- package/src/explorer/dist/6929.bundle.js +1 -0
- package/src/explorer/dist/6952.bundle.js +1 -0
- package/src/explorer/dist/6982.bundle.js +1 -0
- package/src/explorer/dist/6983.bundle.js +1 -0
- package/src/explorer/dist/6984.bundle.js +1 -0
- package/src/explorer/dist/70.bundle.js +1 -0
- package/src/explorer/dist/7007.bundle.js +1 -0
- package/src/explorer/dist/7218.bundle.js +1 -0
- package/src/explorer/dist/7243.bundle.js +1 -0
- package/src/explorer/dist/7281.bundle.js +1 -0
- package/src/explorer/dist/7350.bundle.js +1 -0
- package/src/explorer/dist/7450.bundle.js +1 -0
- package/src/explorer/dist/7469.bundle.js +1 -0
- package/src/explorer/dist/7552.bundle.js +1 -0
- package/src/explorer/dist/7612.bundle.js +1 -0
- package/src/explorer/dist/7656.bundle.js +1 -0
- package/src/explorer/dist/7736.bundle.js +1 -0
- package/src/explorer/dist/7833.bundle.js +1 -0
- package/src/explorer/dist/7835.bundle.js +1 -0
- package/src/explorer/dist/787.bundle.js +1 -0
- package/src/explorer/dist/7887.bundle.js +1 -0
- package/src/explorer/dist/797791b8ae7fd556ee6a.js +1 -0
- package/src/explorer/dist/8127.bundle.js +1 -0
- package/src/explorer/dist/8293.bundle.js +1 -0
- package/src/explorer/dist/8365.bundle.js +1 -0
- package/src/explorer/dist/8397.bundle.js +1 -0
- package/src/explorer/dist/8455.bundle.js +1 -0
- package/src/explorer/dist/8564.bundle.js +1 -0
- package/src/explorer/dist/8602.bundle.js +1 -0
- package/src/explorer/dist/877.bundle.js +1 -0
- package/src/explorer/dist/8776.bundle.js +1 -0
- package/src/explorer/dist/8842.bundle.js +1 -0
- package/src/explorer/dist/9146.bundle.js +1 -0
- package/src/explorer/dist/9190.bundle.js +1 -0
- package/src/explorer/dist/9236.bundle.js +1 -0
- package/src/explorer/dist/9375.bundle.js +1 -0
- package/src/explorer/dist/9380.bundle.js +1 -0
- package/src/explorer/dist/9385.bundle.js +1 -0
- package/src/explorer/dist/9390.bundle.js +1 -0
- package/src/explorer/dist/9466.bundle.js +1 -0
- package/src/explorer/dist/9503.bundle.js +1 -0
- package/src/explorer/dist/9624.bundle.js +1 -0
- package/src/explorer/dist/9788.bundle.js +1 -0
- package/src/explorer/dist/9865.bundle.js +1 -0
- package/src/explorer/dist/9907.bundle.js +1 -0
- package/src/explorer/dist/9936.bundle.js +1 -0
- package/src/explorer/dist/bundle.js +1 -0
- package/src/explorer/dist/images/paymentHelp1.35dff52e41e22e90d91c.png +0 -0
- package/src/explorer/dist/images/paymentHelp2.08d778959310485fefce.png +0 -0
- package/src/explorer/dist/images/paymentHelp3.9908702eec7bdcd83f69.png +0 -0
- package/src/explorer/dist/index.html +26 -0
- package/src/explorer/dist/manifest.json +25 -0
- package/src/explorer/dist/openscan-logo.png +0 -0
- package/src/explorer/dist/robots.txt +3 -0
- package/src/hooks/network.ts +69 -5
- package/src/server.ts +83 -0
- package/src/services/base.ts +53 -0
- package/src/services/index.ts +2 -0
- package/src/services/webapp.ts +227 -0
- package/src/type-extensions.ts +1 -2
- package/src/utils.ts +83 -0
- package/dist/src/hooks/hre.d.ts +0 -4
- package/dist/src/hooks/hre.d.ts.map +0 -1
- package/dist/src/hooks/hre.js +0 -9
- package/dist/src/hooks/hre.js.map +0 -1
- package/dist/src/hooks/logger.d.ts +0 -4
- package/dist/src/hooks/logger.d.ts.map +0 -1
- package/dist/src/hooks/logger.js +0 -23
- package/dist/src/hooks/logger.js.map +0 -1
- package/dist/src/tasks/my-task.d.ts +0 -7
- package/dist/src/tasks/my-task.d.ts.map +0 -1
- package/dist/src/tasks/my-task.js +0 -4
- package/dist/src/tasks/my-task.js.map +0 -1
- package/dist/src/utils/console-wrapper.d.ts +0 -7
- package/dist/src/utils/console-wrapper.d.ts.map +0 -1
- package/dist/src/utils/console-wrapper.js +0 -54
- 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
|
-
|
|
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
|
-
|
|
41
|
+
Simply start your Hardhat node:
|
|
27
42
|
|
|
28
43
|
```bash
|
|
29
|
-
npx hardhat
|
|
44
|
+
npx hardhat node
|
|
30
45
|
```
|
|
31
46
|
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
url: "http://localhost:3030",
|
|
50
|
-
chainId:
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Transaction
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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;
|
|
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 {
|
|
12
|
-
|
|
13
|
-
|
|
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/${
|
|
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":"
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/hooks/network.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAuB,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE3D,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,uCAAuC;AACvC,IAAI,YAAY,GAA0B,IAAI,CAAC;AAC/C,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B;;;;;GAKG;AACH,KAAK,UAAU,WAAW,CAAC,OAAe;IACxC,IAAI,CAAC;QACH,8CAA8C;QAC9C,MAAM,aAAa,GAAG,MAAM,eAAe,EAAE,CAAC;QAC9C,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;QACJ,CAAC;QAED,0BAA0B;QAC1B,YAAY,GAAG,oBAAoB,EAAE,CAAC;QACtC,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;QAE5B,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,EAAG,CAAC;QAE/C,OAAO,CAAC,GAAG,CAAC,2BAA2B,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,CAA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/**
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|