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

Minor fixes -- Maintenance #78

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 2.1.9

* Updated dependencies
* Fixed a bug when the cache was not saved if the `cache` directory did not exist
* Exported `TransactionStorage`, `VerificationStorage`, and `ArtifactStorage` for convenience

## Version 2.1.8

* Fixed a bug where remote chain metadata overwrote the local one.
Expand Down
50 changes: 25 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/hardhat-migrate",
"version": "2.1.8",
"version": "2.1.9",
"description": "Automatic deployment and verification of smart contracts",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down Expand Up @@ -51,11 +51,11 @@
]
},
"dependencies": {
"@nomicfoundation/hardhat-ethers": "3.0.5",
"@nomicfoundation/hardhat-verify": "2.0.4",
"@nomicfoundation/hardhat-ethers": "3.0.6",
"@nomicfoundation/hardhat-verify": "2.0.8",
"@nomiclabs/hardhat-truffle5": "2.0.7",
"axios": "1.6.7",
"ethers": "6.11.1",
"axios": "1.7.2",
"ethers": "6.13.1",
"ora": "5.4.1"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { Migrator } from "./migrator/Migrator";
import { Verifier } from "./verifier/Verifier";

export { Deployer } from "./deployer/Deployer";
export { UserStorage } from "./tools/storage/MigrateStorage";
export { PublicReporter as Reporter } from "./tools/reporters/PublicReporter";
export { UserStorage, TransactionStorage, VerificationStorage, ArtifactStorage } from "./tools/storage/MigrateStorage";

extendConfig(migrateConfigExtender);

Expand Down
11 changes: 10 additions & 1 deletion src/tools/storage/MigrateStorage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { existsSync, readFileSync, writeFileSync, rmSync } from "fs";
import { existsSync, readFileSync, writeFileSync, rmSync, mkdirSync } from "fs";

import { lazyObject } from "hardhat/plugins";

Expand All @@ -10,12 +10,17 @@ import { StorageNamespaces } from "../../types/tools";

@catchError
class BaseStorage {
private readonly _directory = "cache";
private readonly _fileName = ".migrate.storage.json";

protected _state: Record<string, any>;

constructor(private _namespace: string = StorageNamespaces.Storage) {
this._state = this.readFullStateFromFile()[this._namespace] || {};

if (!existsSync(this.filePath())) {
this._saveStateToFile();
}
}

public deleteStateFile(): void {
Expand Down Expand Up @@ -49,6 +54,10 @@ class BaseStorage {

fileSate[this._namespace] = this._state;

if (!existsSync(this._directory)) {
mkdirSync(this._directory, { recursive: true });
}

writeFileSync(this.filePath(), toJSON(fileSate), {
flag: "w",
encoding: "utf8",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/deployer/base-contract-interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe("deployer", () => {
const signer = (await deployer.getSigner()) as any;

await expect(deployer.deploy(ConstructorWithArguments__factory, [signer], {})).to.be.rejectedWith(
`Deployer.deploy(): MinimalContract.deploy(): MinimalContract._createDeployTransaction(): invalid BigNumberish value (argument="value", value="<SignerWithAddress 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266>", code=INVALID_ARGUMENT, version=6.11.1)`,
`Deployer.deploy(): MinimalContract.deploy(): MinimalContract._createDeployTransaction(): invalid BigNumberish value (argument="value", value="<SignerWithAddress 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266>", code=INVALID_ARGUMENT, version=6.13.1)`,
);
});

Expand Down
Loading