-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random port on integrated devnet #202
base: master
Are you sure you want to change the base?
Changes from all commits
ff2cbd7
4781e7a
71e782d
abf2ada
78ff511
af7b7fb
77c1e37
ff9edad
25f19a6
8e75630
d615de6
42b9383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ CONFIG_FILE_NAME="hardhat.config.ts" | |
|
||
# setup example repo | ||
rm -rf starknet-hardhat-example | ||
git clone -b plugin --single-branch [email protected]:Shard-Labs/starknet-hardhat-example.git | ||
git clone -b release-0.7.0 --single-branch [email protected]:Shard-Labs/starknet-hardhat-example.git | ||
cd starknet-hardhat-example | ||
git log -n 1 | ||
npm install | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import { getWalletUtil } from "./extend-utils"; | |
import { createIntegratedDevnet } from "./external-server"; | ||
import { Recompiler } from "./recompiler"; | ||
import { version } from "../package.json"; | ||
import { getFreePort, isFreePort } from "./external-server/external-server"; | ||
|
||
function checkSourceExists(sourcePath: string): void { | ||
if (!fs.existsSync(sourcePath)) { | ||
|
@@ -343,14 +344,7 @@ async function handleContractVerification( | |
|
||
const bodyFormData = new FormData(); | ||
bodyFormData.append("compiler-version", args.compilerVersion); | ||
let accountContract; | ||
if (args.accountContract === "true") { | ||
accountContract = "true"; | ||
} else if (!args.accountContract || args.accountContract === "false") { | ||
accountContract = "false"; | ||
} else { | ||
throw new StarknetPluginError("--account-contract must be true or false"); | ||
} | ||
const accountContract = args.accountContract ? "true" : "false"; | ||
bodyFormData.append("account-contract", accountContract); | ||
bodyFormData.append("license", args.license || "No License (None)"); | ||
|
||
|
@@ -560,7 +554,15 @@ async function runWithDevnet(hre: HardhatRuntimeEnvironment, fn: () => Promise<u | |
return; | ||
} | ||
|
||
const devnet = createIntegratedDevnet(hre); | ||
const { hostname, port } = new URL(hre.config.starknet.networkUrl); | ||
const isPortFree = await isFreePort(parseInt(port)); | ||
if (!isPortFree) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this check? Couldn't it surprise the user if we just silently change the specified port. If the port is occupied, integrated-devnet spawner will inform the user about that, right? My understanding was that we should find a free port only if the user didn't provide a URL? Now I'm actually thinking, is it even possible for the user to omit the URL? Can the type extensions file be modified to allow that? |
||
const newPort = await getFreePort(); | ||
const networkUrl = `http://${hostname}:${newPort}`; | ||
hre.config.networks.integratedDevnet.url = networkUrl; | ||
hre.config.starknet.networkUrl = networkUrl; | ||
} | ||
const devnet = await createIntegratedDevnet(hre); | ||
|
||
await devnet.start(); | ||
await fn(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the user provided
--port
inargs
in hardhat config?