Skip to content

Commit 92d924d

Browse files
authored
Merge pull request #17 from mdtanrikulu/fix/anvil-rpc-env
use anvil rpc env variable in package script
2 parents ce514f8 + eebc551 commit 92d924d

4 files changed

Lines changed: 41 additions & 2 deletions

File tree

mock-contract-deployer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"scripts": {
55
"start": "pnpm run start:deploy-contracts",
6-
"start:deploy-contracts": "wait-port anvil:8545 && tsx src/index.ts"
6+
"start:deploy-contracts": "tsx src/helpers/wait-anvil.ts && tsx src/index.ts"
77
},
88
"dependencies": {
99
"viem": "^2.9.9"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import waitPort from 'wait-port';
2+
3+
const url = new URL(process.env.ANVIL_RPC || 'http://anvil:8545');
4+
5+
(async () => {
6+
const ok = await waitPort({
7+
host: url.hostname,
8+
port: parseInt(url.port || '80'),
9+
timeout: 10000, // 10s timeout
10+
output: 'silent',
11+
});
12+
13+
if (!ok) {
14+
console.error(`❌ Timed out waiting for ${url.hostname}:${url.port}`);
15+
process.exit(1);
16+
}
17+
18+
console.log(`✅ ${url.hostname}:${url.port} is available`);
19+
})();

mock-verifying-paymaster/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "mock-paymaster",
33
"private": true,
44
"scripts": {
5-
"start": "wait-port anvil:8545 && ts-node src/index.ts"
5+
"start": "tsx src/helpers/wait-anvil.ts && tsx src/index.ts"
66
},
77
"dependencies": {
88
"@fastify/cors": "^9.0.1",
@@ -18,6 +18,7 @@
1818
"@biomejs/biome": "^1.9.4",
1919
"@types/node": "^20.12.4",
2020
"ts-node": "^10.9.2",
21+
"tsx": "^4.19.3",
2122
"wait-port": "^1.0.4"
2223
}
2324
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import waitPort from 'wait-port';
2+
3+
const url = new URL(process.env.ANVIL_RPC || 'http://anvil:8545');
4+
5+
(async () => {
6+
const ok = await waitPort({
7+
host: url.hostname,
8+
port: parseInt(url.port || '80'),
9+
timeout: 10000, // 10s timeout
10+
output: 'silent',
11+
});
12+
13+
if (!ok) {
14+
console.error(`❌ Timed out waiting for ${url.hostname}:${url.port}`);
15+
process.exit(1);
16+
}
17+
18+
console.log(`✅ ${url.hostname}:${url.port} is available`);
19+
})();

0 commit comments

Comments
 (0)