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

Alpha 3 #42

Merged
merged 42 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b8deedf
refactoring
RuslanProgrammer Oct 23, 2023
775a6b5
Merge pull request #40 from dl-solarity/bug/bugs
KyrylR Oct 23, 2023
60295d4
use wait instead of confirmations in the config
RuslanProgrammer Oct 25, 2023
8442323
change 'verify' parameter to the boolean flag
RuslanProgrammer Oct 25, 2023
b77e757
removed 'skipVerificationErrors' from config
RuslanProgrammer Oct 25, 2023
6743cf3
updated readme and help task
RuslanProgrammer Oct 25, 2023
ddd7fba
fixed attempts ussage during verification
RuslanProgrammer Oct 25, 2023
db6bd22
drafts of verify task
RuslanProgrammer Oct 25, 2023
20739dd
added 'chainId' to verifier
RuslanProgrammer Oct 25, 2023
928c704
deleting .storage if continiue == false
RuslanProgrammer Oct 25, 2023
90f76b0
added 'contractAddress' as optimial parameter to deployed()
RuslanProgrammer Oct 25, 2023
00c7c63
Review
KyrylR Oct 26, 2023
5d3e0f6
fixed verify task
RuslanProgrammer Oct 26, 2023
cd58040
applied wait for reporter
RuslanProgrammer Oct 26, 2023
5e947cd
fixed scope
RuslanProgrammer Oct 26, 2023
9882f20
added Handler inception to contracts factory (#41)
RuslanProgrammer Oct 27, 2023
64c79c3
added sendNative() (#43)
RuslanProgrammer Oct 27, 2023
1ce274e
Merge remote-tracking branch 'origin/develop' into fix/small-changes
RuslanProgrammer Oct 27, 2023
b555a98
config
RuslanProgrammer Oct 27, 2023
5a16060
Merge remote-tracking branch 'origin/develop' into fix/small-changes
RuslanProgrammer Oct 27, 2023
ffea2e2
fixed types
RuslanProgrammer Oct 27, 2023
798f9f6
added info to formatPendingTime()
RuslanProgrammer Oct 27, 2023
f5a5a2f
fixed verifier
RuslanProgrammer Oct 27, 2023
eefbd59
Sorted out imports
KyrylR Oct 27, 2023
c6e72a9
Used plain ethers for ContractFactory
KyrylR Oct 27, 2023
daae823
Drop direct ethers. Used custom provider instead.
KyrylR Oct 27, 2023
cccdd37
added 'address' property to BaseContract
RuslanProgrammer Oct 27, 2023
27378b3
Merge pull request #45 from dl-solarity/fix/small-changes
KyrylR Oct 27, 2023
42f5765
Deleted redundant VerificationProcessor
KyrylR Oct 27, 2023
5f810b6
Mentioned some insights
KyrylR Oct 27, 2023
f134b98
updated package.json
RuslanProgrammer Oct 27, 2023
6985038
Fixed bug with config
KyrylR Oct 27, 2023
de0bac3
Merge remote-tracking branch 'origin/develop' into develop
KyrylR Oct 27, 2023
a7f4791
Fixed UX reporter
KyrylR Oct 27, 2023
e50ed00
Refactored redundant setAsDeployed
KyrylR Oct 27, 2023
35d3f56
Clarified names
KyrylR Oct 27, 2023
5330ce1
trying get deployed contract by name first
RuslanProgrammer Oct 27, 2023
1fbf566
refactored
RuslanProgrammer Oct 27, 2023
5d310d3
Clarified names
KyrylR Oct 27, 2023
00b8955
Drop overbalanced logic
KyrylR Oct 27, 2023
b5724cc
Merge remote-tracking branch 'origin/develop' into develop
KyrylR Oct 27, 2023
a728339
Further renaming
KyrylR Oct 27, 2023
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
23 changes: 7 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ module.exports = {
to: -1,
only: -1,
skip: -1,
txConfirmations: 1,
verifyConfirmations: 0,
verify: "at-the-end",
wait: 1,
verify: false,
attempts: 0,
pathToMigrations: "./deploy",
skipVerificationErrors: ["already verified"],
force: false,
continuePreviousDeployment: false,
continue: false,
},
};
```
Expand All @@ -96,19 +94,12 @@ module.exports = {
- `to` : The migration number up to which the migration will be applied.
- `only` : The number of the migration that will be applied. **Overrides from and to parameters.**
- `skip`: The number of migration to skip. **Overrides only parameter.**
- `txConfirmations` : The number of confirmations to wait for after the transaction is mined.
- `verifyConfirmations` : The number of confirmations to wait for before sending a request to etherscan.
- `verify` : The strategy of verification. The user can choose between `immediately`, `at-the-end` and `none`.
- `immediately`: the verification will start immediately after the contract is deployed. However, the execution will wait `verifyConfirmations` number of blocks before sending a request to etherscan.
- `at-the-end`: the verification will start after all migrations are applied.
- `none`: the verification will not be performed.
- `wait` : The number of confirmations to wait for after the transaction is mined.
- `verify` : The flag indicating whether the contracts should be verified.
- `attempts`: The number of attempts to verify the contract.
- `pathToMigrations` : The path to the folder with the specified migrations.
- `skipVerificationErrors` : The user can specify custom verification errors that will be omitted and just be printed
to the log instead of stopping the program completely.
By default, if this parameter is not specified, the `already verified` error is omitted.
- `force` : The flag indicating whether the contracts compilation is forced.
- `continuePreviousDeployment` : The flag indicating whether the deployment should restore the state from the previous deployment.
- `continue` : The flag indicating whether the deployment should restore the state from the previous deployment.

### Deploying

Expand All @@ -117,7 +108,7 @@ You can set your own migrations and deploy the contracts to the network you want
#### With only parameter

```console
npx hardhat migrate --network goerli --verify immediately --only 2
npx hardhat migrate --network goerli --verify --only 2
```

In this case, only the migration that begins with digit 2 will be applied. The plugin will also try to automatically verify the deployed contracts.
Expand Down
31 changes: 28 additions & 3 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solarity/hardhat-migrate",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Automatic deployment and verification of smart contracts",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down Expand Up @@ -44,7 +44,6 @@
"@nomicfoundation/hardhat-verify": "1.1.1",
"@nomiclabs/hardhat-truffle5": "2.0.7",
"axios": "1.5.0",
"bignumber.js": "9.1.2",
"ora": "5.4.1"
},
"peerDependencies": {
Expand All @@ -69,7 +68,7 @@
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"ethers": "^6.7.1",
"ethers": "^6.8.0",
"hardhat": "^2.17.0",
"mocha": "^10.0.0",
"pinst": "^3.0.0",
Expand Down
48 changes: 40 additions & 8 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,28 @@ import { ConfigExtender } from "hardhat/types";

import { pluginName } from "./constants";

import { MigrateConfig, VerifyStrategy } from "./types/migrations";
import { MigrateConfig, MigrateVerifyConfig } from "./types/migrations";

const defaultConfig: MigrateConfig = {
from: -1,
to: -1,
only: -1,
skip: -1,
txConfirmations: 1,
verifyConfirmations: 0,
verify: VerifyStrategy.AtTheEnd,
attempts: 0,
wait: 1,
verify: false,
verifyParallel: 1,
verifyAttempts: 3,
pathToMigrations: "./deploy",
skipVerificationErrors: ["already verified"],
force: false,
continue: false,
};

const defaultVerifyConfig: MigrateVerifyConfig = {
inputFile: undefined,
parallel: 1,
attempts: 3,
};

export const migrateConfigExtender: ConfigExtender = (resolvedConfig, config) => {
resolvedConfig.migrate = mergeConfigs(config.migrate, defaultConfig);
};
Expand All @@ -34,14 +39,41 @@ export const mergeConfigs = (
return defaultConfig;
}

if (config.wait && config.wait < 1) {
throw new HardhatPluginError(pluginName, "config.migrate.wait must be greater than 0");
}

if (config.verifyParallel && config.verifyParallel < 1) {
throw new HardhatPluginError(pluginName, "config.migrate.verifyParallel must be greater than 0");
}

if (config.verifyAttempts && config.verifyAttempts < 1) {
throw new HardhatPluginError(pluginName, "config.migrate.verifyAttempts must be greater than 0");
}

if (config.pathToMigrations && !isRelativePath(config.pathToMigrations)) {
throw new HardhatPluginError(pluginName, "config.migrate.pathToMigrations must be a relative path");
}

return { ...defaultConfig, ...definedProps(config) };
};

const definedProps = (obj: Partial<MigrateConfig>): Partial<MigrateConfig> =>
Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined)) as Partial<MigrateConfig>;
export const extendVerifyConfigs = (config: Partial<MigrateVerifyConfig> | undefined): MigrateVerifyConfig => {
if (config === undefined) {
return defaultVerifyConfig;
}

if (config.parallel && config.parallel < 1) {
throw new HardhatPluginError(pluginName, "parallel must be greater than 0");
}

if (config.attempts && config.attempts < 1) {
throw new HardhatPluginError(pluginName, "attempts must be greater than 0");
}

return { ...defaultVerifyConfig, ...definedProps(config) };
};

const definedProps = (obj: any): any => Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));

const isRelativePath = (path?: string): boolean => path === undefined || !isAbsolute(path);
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const pluginName = "@solarity/hardhat-migrate";
export const TASK_MIGRATE = "migrate";
export const TASK_MIGRATE_VERIFY = "migrate:verify";
Loading