Skip to content
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

Ensure hardhat can download solidity #30

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"prettier": "prettier '**/*.{ts,json,sol,md}' --check",
"prettier:fix": "npm run prettier -- --write",
"format": "npm run prettier:fix && npm run lint:fix",
"test": "npx lerna run test:ci --stream",
"build": "npx lerna run build"
"test": "HARDHAT_CLEAN=true npx lerna run test:ci --stream",
"build": "npx lerna run build",
"pub": "lerna publish from-package"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, but I wanted to add the command we use to publish.

},
"devDependencies": {
"@types/chai": "^4.3.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/local/registry/contracts/TablelandTables.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
pragma solidity 0.8.19;

// Need to have this so the tests can deploy a registry
import "@tableland/evm/contracts/TablelandTables.sol";
22 changes: 21 additions & 1 deletion packages/local/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,17 @@ class LocalTableland {
// wait until initialization is done
await waitForReady(registryReadyEvent, this.initEmitter);

await new Promise((resolve) => setTimeout(resolve, 5000));
if (process.env.HARDHAT_CLEAN) {
console.log("HARDHAT_CLEAN env set, cleaning hardhat");
await new Promise((resolve) => setTimeout(resolve, 1));
this.#_cleanHardhat();
}

this._deployRegistry();

const deployed = await this.#_ensureRegistry();

// If the deploy process failed silently we will try to clean hardhat and re-deploy
if (!deployed) {
throw new Error(
"deploying registry contract failed, cannot start network"
Expand Down Expand Up @@ -241,6 +247,20 @@ class LocalTableland {
);
}

#_cleanHardhat(): void {
// Deploy the Registry to the Hardhat node
logSync(
spawnSync(
isWindows() ? "npx.cmd" : "npx",
["hardhat", "clean", "--global"],
{
cwd: this.registryDir,
}
),
!inDebugMode()
);
}

async #_ensureRegistry(): Promise<boolean> {
const provider = getDefaultProvider(
`http://127.0.0.1:${this.registryPort}`
Expand Down