hardhat-deploy
Advanced tools
Comparing version 0.7.0-beta.15 to 0.7.0-beta.16
{ | ||
"name": "hardhat-deploy", | ||
"version": "0.7.0-beta.15", | ||
"version": "0.7.0-beta.16", | ||
"description": "Hardhat Plugin For Replicable Deployments And Tests", | ||
@@ -5,0 +5,0 @@ "repository": "github:wighawag/hardhat-deploy", |
175
README.md
@@ -90,3 +90,3 @@ [![hardhat](https://hardhat.org/hardhat-plugin-badge.svg?1)](https://hardhat.org) | ||
```js | ||
import "hardhat-deploy"; | ||
import 'hardhat-deploy'; | ||
``` | ||
@@ -154,4 +154,4 @@ | ||
methodIdentifiers?: any; | ||
diamondCut?: { address: string; sigs: string[] }[]; | ||
facets?: { address: string; sigs: string[] }[]; | ||
diamondCut?: {address: string; sigs: string[]}[]; | ||
facets?: {address: string; sigs: string[]}[]; | ||
storageLayout?: any; | ||
@@ -313,3 +313,3 @@ } | ||
- `getUnamedAccounts: () => Promise<string[]}>`: accounts which has no names, useful for test where you want to be sure that the account is not one of the predefined one | ||
- `getUnnamedAccounts: () => Promise<string[]}>`: accounts which has no names, useful for test where you want to be sure that the account is not one of the predefined one | ||
@@ -436,3 +436,3 @@ - `deployments`: contains functions to access past deployments or to save new ones, as well as helpers functions. | ||
```js | ||
const { deployments } = require("hardhat"); | ||
const {deployments} = require('hardhat'); | ||
const artifact = await deployments.getArtifact(artifactName); | ||
@@ -444,3 +444,3 @@ ``` | ||
```js | ||
const { deployments, ethers } = require("hardhat"); | ||
const {deployments, ethers} = require('hardhat'); | ||
const factory = await ethers.getContractFactory(artifactName); | ||
@@ -502,16 +502,11 @@ ``` | ||
```js | ||
module.exports = async ({ | ||
getNamedAccounts, | ||
deployments, | ||
getChainId, | ||
getUnamedAccounts | ||
}) => { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
module.exports = async ({getNamedAccounts, deployments, getChainId, getUnnamedAccounts}) => { | ||
const {deploy} = deployments; | ||
const {deployer} = await getNamedAccounts(); | ||
// the following will only deploy "GenericMetaTxProcessor" if the contract was never deployed or if the code changed since last deployment | ||
await deploy("GenericMetaTxProcessor", { | ||
await deploy('GenericMetaTxProcessor', { | ||
from: deployer, | ||
gas: 4000000, | ||
args: [] | ||
args: [], | ||
}); | ||
@@ -525,3 +520,3 @@ }; | ||
- `getUnamedAccounts`: function that return a promise to an array of accounts (which were not used in `getNamedAccounts`), useful for test where you want to be sure that the account is not one of the predefined one | ||
- `getUnnamedAccounts`: function that return a promise to an array of accounts (which were not used in `getNamedAccounts`), useful for test where you want to be sure that the account is not one of the predefined one | ||
@@ -668,3 +663,3 @@ - `deployments`, which contains functions to access past deployments or to save new ones, as well as helpers functions. | ||
name: string; | ||
contracts: { [name: string]: ContractExport }; | ||
contracts: {[name: string]: ContractExport}; | ||
} | ||
@@ -679,3 +674,3 @@ ``` | ||
export type MultiExport = { | ||
[chainId: string]: { [name: string]: Export } | ||
[chainId: string]: {[name: string]: Export}, | ||
}; | ||
@@ -701,8 +696,8 @@ ``` | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
await deploy("Greeter", { | ||
module.exports = async ({getNamedAccounts, deployments, getChainId}) => { | ||
const {deploy} = deployments; | ||
const {deployer} = await getNamedAccounts(); | ||
await deploy('Greeter', { | ||
from: deployer, | ||
proxy: true | ||
proxy: true, | ||
}); | ||
@@ -718,9 +713,9 @@ }; | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { | ||
const { deploy } = deployments; | ||
const { deployer } = await getNamedAccounts(); | ||
await deploy("Greeter", { | ||
module.exports = async ({getNamedAccounts, deployments, getChainId}) => { | ||
const {deploy} = deployments; | ||
const {deployer} = await getNamedAccounts(); | ||
await deploy('Greeter', { | ||
from: deployer, | ||
proxy: "postUpgrade", | ||
args: ["arg1", 2, 3] | ||
proxy: 'postUpgrade', | ||
args: ['arg1', 2, 3], | ||
}); | ||
@@ -735,12 +730,12 @@ }; | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { | ||
const { deploy } = deployments; | ||
const { deployer, greeterOwner } = await getNamedAccounts(); | ||
await deploy("Greeter", { | ||
module.exports = async ({getNamedAccounts, deployments, getChainId}) => { | ||
const {deploy} = deployments; | ||
const {deployer, greeterOwner} = await getNamedAccounts(); | ||
await deploy('Greeter', { | ||
from: deployer, | ||
proxy: { | ||
owner: greeterOwner, | ||
methodName: "postUpgrade" | ||
methodName: 'postUpgrade', | ||
}, | ||
args: ["arg1", 2, 3] | ||
args: ['arg1', 2, 3], | ||
}); | ||
@@ -765,9 +760,9 @@ }; | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { | ||
const { diamond } = deployments; | ||
const { deployer, diamondAdmin } = await getNamedAccounts(); | ||
await diamond.deploy("ADiamondContract", { | ||
module.exports = async ({getNamedAccounts, deployments, getChainId}) => { | ||
const {diamond} = deployments; | ||
const {deployer, diamondAdmin} = await getNamedAccounts(); | ||
await diamond.deploy('ADiamondContract', { | ||
from: deployer, | ||
owner: diamondAdmin, | ||
facets: ["Facet1", "Facet2", "Facet3"] | ||
facets: ['Facet1', 'Facet2', 'Facet3'], | ||
}); | ||
@@ -780,9 +775,9 @@ }; | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments, getChainId }) => { | ||
const { diamond } = deployments; | ||
const { deployer, diamondAdmin } = await getNamedAccounts(); | ||
await diamond.deploy("ADiamondContract", { | ||
module.exports = async ({getNamedAccounts, deployments, getChainId}) => { | ||
const {diamond} = deployments; | ||
const {deployer, diamondAdmin} = await getNamedAccounts(); | ||
await diamond.deploy('ADiamondContract', { | ||
from: diamondAdmin, // this need to be the diamondAdmin for upgrade | ||
owner: diamondAdmin, | ||
facets: ["NewFacet", "Facet2", "Facet3"] | ||
facets: ['NewFacet', 'Facet2', 'Facet3'], | ||
}); | ||
@@ -806,10 +801,10 @@ }; | ||
```js | ||
diamond.deploy("ADiamondContract", { | ||
diamond.deploy('ADiamondContract', { | ||
from: deployer, | ||
owner: diamondAdmin, | ||
facets: ["NewFacet", "Facet2", "Facet3"], | ||
facets: ['NewFacet', 'Facet2', 'Facet3'], | ||
execute: { | ||
methodName: "postUpgrade", | ||
args: ["one", 2, "0x3"] | ||
} | ||
methodName: 'postUpgrade', | ||
args: ['one', 2, '0x3'], | ||
}, | ||
}); | ||
@@ -835,13 +830,13 @@ ``` | ||
```js | ||
const { deployments } = require("hardhat"); | ||
const {deployments} = require('hardhat'); | ||
describe("Token", () => { | ||
describe('Token', () => { | ||
beforeEach(async () => { | ||
await deployments.fixture(); | ||
}); | ||
it("testing 1 2 3", async function() { | ||
const Token = await deployments.get("Token"); // Token is available because the fixture was executed | ||
it('testing 1 2 3', async function () { | ||
const Token = await deployments.get('Token'); // Token is available because the fixture was executed | ||
console.log(Token.address); | ||
const ERC721BidSale = await deployments.get("ERC721BidSale"); | ||
console.log({ ERC721BidSale }); | ||
const ERC721BidSale = await deployments.get('ERC721BidSale'); | ||
console.log({ERC721BidSale}); | ||
}); | ||
@@ -856,11 +851,11 @@ }); | ||
```js | ||
const { ethers, getNamedAccounts } = require("hardhat"); | ||
const {ethers, getNamedAccounts} = require('hardhat'); | ||
describe("Token", () => { | ||
describe('Token', () => { | ||
beforeEach(async () => { | ||
await deployments.fixture(); | ||
}); | ||
it("testing 1 2 3", async function() { | ||
const { tokenOwner } = await getNamedAccounts(); | ||
const TokenContract = await ethers.getContract("Token", tokenOwner); | ||
it('testing 1 2 3', async function () { | ||
const {tokenOwner} = await getNamedAccounts(); | ||
const TokenContract = await ethers.getContract('Token', tokenOwner); | ||
await TokenContract.mint(2); | ||
@@ -920,3 +915,3 @@ }); | ||
```js | ||
deployments.fixture("<specific tag>", { fallbackToGlobal: false }); | ||
deployments.fixture('<specific tag>', {fallbackToGlobal: false}); | ||
``` | ||
@@ -933,8 +928,8 @@ | ||
```js | ||
const hre = require("hardhat"); | ||
const { deployments, getNamedAccounts } = hre; | ||
const hre = require('hardhat'); | ||
const {deployments, getNamedAccounts} = hre; | ||
(async () => { | ||
console.log(await deployments.all()); | ||
console.log({ namedAccounts: await getNamedAccounts() }); | ||
console.log({namedAccounts: await getNamedAccounts()}); | ||
})(); | ||
@@ -964,38 +959,34 @@ ``` | ||
```js | ||
module.exports = async ({ getNamedAccounts, deployments }) => { | ||
const { deployIfDifferent, log } = deployments; | ||
module.exports = async ({getNamedAccounts, deployments}) => { | ||
const {deployIfDifferent, log} = deployments; | ||
const namedAccounts = await getNamedAccounts(); | ||
const { deployer } = namedAccounts; | ||
const deployResult = await deploy("Token", { | ||
const {deployer} = namedAccounts; | ||
const deployResult = await deploy('Token', { | ||
from: deployer, | ||
args: ["hello", 100] | ||
args: ['hello', 100], | ||
}); | ||
if (deployResult.newlyDeployed) { | ||
log( | ||
`contract Token deployed at ${deployResult.contract.address} using ${deployResult.receipt.gasUsed} gas` | ||
); | ||
log(`contract Token deployed at ${deployResult.contract.address} using ${deployResult.receipt.gasUsed} gas`); | ||
} | ||
}; | ||
module.exports.tags = ["Token"]; | ||
module.exports.tags = ['Token']; | ||
``` | ||
```js | ||
module.exports = async function({ getNamedAccounts, deployments }) { | ||
const { deployIfDifferent, log } = deployments; | ||
module.exports = async function ({getNamedAccounts, deployments}) { | ||
const {deployIfDifferent, log} = deployments; | ||
const namedAccounts = await getNamedAccounts(); | ||
const { deployer } = namedAccounts; | ||
const Token = await deployments.get("Token"); | ||
const deployResult = await deploy("Sale", { | ||
const {deployer} = namedAccounts; | ||
const Token = await deployments.get('Token'); | ||
const deployResult = await deploy('Sale', { | ||
from: deployer, | ||
contract: "ERC721BidSale", | ||
args: [Token.address, 1, 3600] | ||
contract: 'ERC721BidSale', | ||
args: [Token.address, 1, 3600], | ||
}); | ||
if (deployResult.newlyDeployed) { | ||
log( | ||
`contract Sale deployed at ${deployResult.contract.address} using ${deployResult.receipt.gasUsed} gas` | ||
); | ||
log(`contract Sale deployed at ${deployResult.contract.address} using ${deployResult.receipt.gasUsed} gas`); | ||
} | ||
}; | ||
module.exports.tags = ["Sale"]; | ||
module.exports.dependencies = ["Token"]; // this ensure the TOken script above is executed first, so `deployments.get('Token') succeeds | ||
module.exports.tags = ['Sale']; | ||
module.exports.dependencies = ['Token']; // this ensure the TOken script above is executed first, so `deployments.get('Token') succeeds | ||
``` | ||
@@ -1012,9 +1003,9 @@ | ||
```js | ||
module.exports = async function({ getNamedAccounts, deployments }) { | ||
const { deployIfDifferent, execute, log } = deployments; | ||
module.exports = async function ({getNamedAccounts, deployments}) { | ||
const {deployIfDifferent, execute, log} = deployments; | ||
const namedAccounts = await getNamedAccounts(); | ||
const { deployer, admin } = namedAccounts; | ||
await execute("Sale", { from: deployer }, "setAdmin", admin); | ||
const {deployer, admin} = namedAccounts; | ||
await execute('Sale', {from: deployer}, 'setAdmin', admin); | ||
}; | ||
module.exports.tags = ["Sale"]; | ||
module.exports.tags = ['Sale']; | ||
module.exports.runAtTheEnd = true; | ||
@@ -1021,0 +1012,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2220859
994