diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f905dc..40c103b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 2.0.0-alpha.12 + +* Added ability to accept Overrides as second parameter to the `deploy` function. + ## Version 2.0.0-alpha.11 * Initially, the fully qualified name is used to retrieve a contract from the Transaction Storage. diff --git a/README.md b/README.md index c3dc0cd3..e962b724 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,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 --only 2 +npx hardhat migrate --network sepolia --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. @@ -127,13 +127,7 @@ In this case, migrations 1 through 2 (both) will be applied without the automati > _This plugin has a `migrate:verify` task, to learn how to use it, see the example project._ -#### You can manually verify contracts - -```console -npx hardhat verify --network goerli DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1" -``` - -Other examples of manual contract verification can be found here [@nomicfoundation/hardhat-verify](https://www.npmjs.com/package/@nomicfoundation/hardhat-verify) --> +--> ## How it works @@ -146,7 +140,7 @@ The plugin includes the following packages to perform the deployment and verific The core of this plugin is migration files, you can specify the migration route that suits you best. -You can find an example of migration files in the sample project. +[//]: # (You can find an example of migration files in the sample project.) ### Migration Lifecycle @@ -166,21 +160,12 @@ Under the hood, it uses `ContractFactory` from [@ethers](https://www.npmjs.com/p Returns the deployed contract instance. -- **Link function** - -Used for backward compatibility with Truffle migrations. - -The link function of the `TruffleContract` class from the [@nomiclabs/hardhat-truffle5](https://www.npmjs.com/package/@nomiclabs/hardhat-truffle5) -package is used to link external libraries to a contract. - ### Verifier For a list of parameters that affect the verification process, see [Parameter Explanation](https://github.com/dl-solarity/hardhat-migrate#parameter-explanation). If verification fails, the `attempts` parameter indicates how many additional requests will be made before the migration process is terminated. - - ## Known limitations - This plugin, as well as the [Hardhat Toolbox](https://hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox) plugin, use the [@nomicfoundation/hardhat-verify](https://www.npmjs.com/package/@nomicfoundation/hardhat-verify) plugin internally, so both of these plugins cannot be imported at the same time. A quick fix is to manually import the needed plugins that ToolBox imports. diff --git a/package-lock.json b/package-lock.json index 6d3274fb..d4e1c872 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@solarity/hardhat-migrate", - "version": "2.0.0-alpha.6", + "version": "2.0.0-alpha.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@solarity/hardhat-migrate", - "version": "2.0.0-alpha.6", + "version": "2.0.0-alpha.12", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 8471734d..28b48897 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@solarity/hardhat-migrate", - "version": "2.0.0-alpha.11", + "version": "2.0.0-alpha.12", "description": "Automatic deployment and verification of smart contracts", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/deployer/Deployer.ts b/src/deployer/Deployer.ts index ce93cd18..8eaa00ba 100644 --- a/src/deployer/Deployer.ts +++ b/src/deployer/Deployer.ts @@ -27,14 +27,18 @@ export class Deployer { public async deploy( contract: Instance | (T extends Truffle.Contract ? T : never), - args: TypedArgs = [] as TypedArgs, + argsOrParameters: OverridesAndLibs | TypedArgs = [] as TypedArgs, parameters: OverridesAndLibs = {}, ): Promise { const adapter = this._resolveAdapter(contract); - const minimalContract = await adapter.fromInstance(contract, parameters); - const contractAddress = await minimalContract.deploy(args, parameters); + if (!Array.isArray(argsOrParameters)) { + parameters = argsOrParameters; + argsOrParameters = [] as TypedArgs; + } + + const contractAddress = await minimalContract.deploy(argsOrParameters as TypedArgs, parameters); return adapter.toInstance(contract, contractAddress, parameters); } diff --git a/test/fixture-projects/hardhat-project-minimal-ethers/deploy/1_deploy.ts b/test/fixture-projects/hardhat-project-minimal-ethers/deploy/1_deploy.ts index 98f02a3a..a17e5426 100644 --- a/test/fixture-projects/hardhat-project-minimal-ethers/deploy/1_deploy.ts +++ b/test/fixture-projects/hardhat-project-minimal-ethers/deploy/1_deploy.ts @@ -4,9 +4,9 @@ import { Deployer } from "../../../../src/deployer/Deployer"; export = async (deployer: Deployer) => { const ContractWithConstructorArguments = await getContractFactory("ContractWithConstructorArguments"); - // let contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], { - // gasLimit: 1000000, - // }); + let contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], { + gasLimit: 1000000, + }); - // await contract.name(); + await contract.name(); }; diff --git a/test/fixture-projects/hardhat-project-minimal-typechain-truffle/deploy/1_deploy.ts b/test/fixture-projects/hardhat-project-minimal-typechain-truffle/deploy/1_deploy.ts index 9d81b879..f0aca40c 100644 --- a/test/fixture-projects/hardhat-project-minimal-typechain-truffle/deploy/1_deploy.ts +++ b/test/fixture-projects/hardhat-project-minimal-typechain-truffle/deploy/1_deploy.ts @@ -3,8 +3,9 @@ import { Deployer } from "../../../../src/deployer/Deployer"; const ContractWithConstructorArguments = artifacts.require("ContractWithConstructorArguments"); export = async (deployer: Deployer) => { - // let contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], { - // gasLimit: 1000000, - // }); - // await contract.name(); + let contract = await deployer.deploy(ContractWithConstructorArguments, ["hello"], { + gasLimit: 1000000, + }); + + await contract.name(); };