Commit cfac6f24 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #6317 from ethereum-optimism/cleanup/delete-unused-package

packages: remove unused package hardhat-deploy-config
parents ea1162e1 6d36ab52
......@@ -123,7 +123,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -141,7 +141,6 @@ jobs:
- "packages/contracts-bedrock/node_modules"
- "packages/core-utils/node_modules"
- "packages/fault-detector/node_modules"
- "packages/hardhat-deploy-config/node_modules"
- "packages/replica-healthcheck/node_modules"
- "packages/sdk/node_modules"
- run:
......@@ -342,7 +341,7 @@ jobs:
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,hardhat-deploy-config
patterns: contracts-bedrock
# TODO remove me after ci builder updated
- run:
name: Install pnpm package manager
......@@ -351,7 +350,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -385,7 +384,7 @@ jobs:
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,hardhat-deploy-config
patterns: contracts-bedrock
# TODO remove me after ci builder updated
- run:
name: Install pnpm package manager
......@@ -394,7 +393,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -421,7 +420,7 @@ jobs:
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,hardhat-deploy-config
patterns: contracts-bedrock
# TODO remove me after ci builder updated
- run:
name: Install pnpm package manager
......@@ -430,7 +429,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -506,7 +505,7 @@ jobs:
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,hardhat-deploy-config
patterns: contracts-bedrock
# TODO remove me after ci builder updated
- run:
name: Install pnpm package manager
......@@ -515,7 +514,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -540,7 +539,7 @@ jobs:
keys:
- pnpm-packages-v2-{{ checksum "pnpm-lock.yaml" }}
- check-changed:
patterns: contracts-bedrock,hardhat-deploy-config
patterns: contracts-bedrock
# TODO remove me after ci builder updated
- run:
name: Install pnpm package manager
......@@ -549,7 +548,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -575,7 +574,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -619,7 +618,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -651,7 +650,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -693,7 +692,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -775,7 +774,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -861,7 +860,7 @@ jobs:
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install yarn package manager
command: |
......@@ -1030,18 +1029,18 @@ jobs:
- run:
name: Install NVM
command: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc
nvm --version
nvm --version
- run:
name: Install Node
command: |
nvm install
nvm install
nvm use && node --version && npm --version
# TODO remove me after ci builder updated
# A github dep clones-with-immutable-args is installed via github
# packages installed via npm via github automatically run postpack scripts
# their postpack script happens to use yarn so we need it here
# their postpack script happens to use yarn so we need it here
- run:
name: Install Package managers
command: |
......
......@@ -5,7 +5,6 @@
/packages/core-utils @ethereum-optimism/legacy-reviewers
/packages/chain-mon @smartcontracts
/packages/fault-detector @ethereum-optimism/devxpod
/packages/hardhat-deploy-config @ethereum-optimism/legacy-reviewers
/packages/replica-healthcheck @ethereum-optimism/legacy-reviewers
/packages/sdk @ethereum-optimism/devxpod
/packages/atst @ethereum-optimism/devxpod
......
ignores: [
"@babel/eslint-parser",
"@typescript-eslint/parser",
"eslint-plugin-import",
"eslint-plugin-unicorn",
"eslint-plugin-jsdoc",
"eslint-plugin-prefer-arrow",
"eslint-plugin-react",
"@typescript-eslint/eslint-plugin",
"eslint-config-prettier",
"eslint-plugin-prettier",
"chai"
]
module.exports = {
extends: '../../.eslintrc.js',
}
module.exports = {
...require('../../.prettierrc.js'),
};
# @eth-optimism/hardhat-deploy-config
## 0.2.6
### Patch Changes
- 5cf646bab: Add getter for other network's deploy config
## 0.2.5
### Patch Changes
- 1d3c749a2: Bumps the version of ts-node used
## 0.2.4
### Patch Changes
- dd5ab8c0: Allow `paths` to be unset in hardhat config
## 0.2.3
### Patch Changes
- 7215f4ce: Bump ethers to 5.7.0 globally
## 0.2.2
### Patch Changes
- 6ce47f38: Support JSON-formatted deploy configs
## 0.2.1
### Patch Changes
- 2fd0a2fe: Use lazyObject
- 89d01f2e: Update dev deps
## 0.2.0
### Minor Changes
- 27234f68: Initial release of hardhat-deploy-config
### Patch Changes
- a320e744: Properly exports DeployConfigSpec type
- 29ff7462: Revert es target back to 2017
(The MIT License)
Copyright 2020-2021 Optimism
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# @eth-optimism/hardhat-deploy-config
`hardhat-deploy-config` is a simple plugin that adds support for global deploy configuration values.
## Installation
```
pnpm i @eth-optimism/hardhat-deploy-config
```
{
"name": "@eth-optimism/hardhat-deploy-config",
"version": "0.2.6",
"description": "[Optimism] Hardhat deploy configuration plugin",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
"files": [
"dist/*"
],
"scripts": {
"test:coverage": "echo 'No tests defined.'",
"build": "tsc -p tsconfig.json",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"lint": "pnpm lint:fix && pnpm lint:check",
"pre-commit": "lint-staged",
"lint:fix": "pnpm lint:check --fix",
"lint:check": "eslint . --max-warnings=0"
},
"keywords": [
"optimism",
"ethereum",
"hardhat",
"deploy",
"config",
"plugin"
],
"homepage": "https://github.com/ethereum-optimism/optimism/tree/develop/packages/hardhat-deploy-config#readme",
"license": "MIT",
"author": "Optimism PBC",
"repository": {
"type": "git",
"url": "https://github.com/ethereum-optimism/optimism.git"
},
"devDependencies": {
"ethers": "^5.7.0",
"ts-node": "^10.9.1",
"hardhat": "^2.9.6"
}
}
import './type-extensions'
import './plugin'
import * as path from 'path'
import * as fs from 'fs'
import { extendEnvironment, extendConfig } from 'hardhat/config'
import {
HardhatConfig,
HardhatRuntimeEnvironment,
HardhatUserConfig,
} from 'hardhat/types'
import { lazyObject, lazyFunction } from 'hardhat/plugins'
import { ethers } from 'ethers'
// From: https://github.com/wighawag/hardhat-deploy/blob/master/src/index.ts#L63-L76
const normalizePath = (
config: HardhatConfig,
userPath: string | undefined,
defaultPath: string
): string => {
if (userPath === undefined) {
userPath = path.join(config.paths.root, defaultPath)
} else {
if (!path.isAbsolute(userPath)) {
userPath = path.normalize(path.join(config.paths.root, userPath))
}
}
return userPath
}
const getDeployConfig = (
dir: string,
network: string
): { [key: string]: any } => {
let config: any
try {
const base = `${dir}/${network}`
if (fs.existsSync(`${base}.ts`)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
config = require(`${base}.ts`).default
} else if (fs.existsSync(`${base}.json`)) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
config = require(`${base}.json`)
} else {
throw new Error('not found')
}
} catch (err) {
throw new Error(
`error while loading deploy config for network: ${network}, ${err}`
)
}
return config
}
export const loadDeployConfig = (hre: HardhatRuntimeEnvironment): any => {
const paths = hre.config.paths.deployConfig
const conf = getDeployConfig(paths, hre.network.name)
const spec = parseDeployConfig(hre, conf)
return new Proxy(spec, {
get: (target, prop) => {
if (target.hasOwnProperty(prop)) {
return target[prop]
}
// Explicitly throw if the property is not found
throw new Error(
`property does not exist in deploy config: ${String(prop)}`
)
},
})
}
export const parseDeployConfig = (
hre: HardhatRuntimeEnvironment,
config: any
): any => {
// Create a clone of the config object. Shallow clone is fine because none of the input options
// are expected to be objects or functions etc.
const parsed = { ...config }
// If the deployConfigSpec is not provided, do no validation
if (!hre.config.deployConfigSpec) {
return parsed
}
for (const [key, spec] of Object.entries(hre.config.deployConfigSpec)) {
// Make sure the value is defined, or use a default.
if (parsed[key] === undefined) {
if ('default' in spec) {
parsed[key] = spec.default
} else {
throw new Error(
`deploy config is missing required field: ${key} (${spec.type})`
)
}
} else {
// Make sure the default has the correct type.
if (spec.type === 'address') {
if (!ethers.utils.isAddress(parsed[key])) {
throw new Error(
`deploy config field: ${key} is not of type ${spec.type}: ${parsed[key]}`
)
}
} else if (typeof parsed[key] !== spec.type) {
throw new Error(
`deploy config field: ${key} is not of type ${spec.type}: ${parsed[key]}`
)
}
}
}
return parsed
}
extendConfig(
(config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
config.paths.deployConfig = normalizePath(
config,
userConfig.paths?.deployConfig,
'deploy-config'
)
}
)
extendEnvironment((hre) => {
hre.deployConfig = lazyObject(() => loadDeployConfig(hre))
hre.getDeployConfig = lazyFunction(() => {
const paths = hre.config.paths.deployConfig
return (network: string) => getDeployConfig(paths, network)
})
})
import 'hardhat/types/runtime'
import 'hardhat/types/config'
import { DeployConfigSpec } from './types'
declare module 'hardhat/types/config' {
interface HardhatUserConfig {
deployConfigSpec?: DeployConfigSpec<any>
}
interface HardhatConfig {
deployConfigSpec?: DeployConfigSpec<any>
}
interface ProjectPathsUserConfig {
deployConfig?: string
}
interface ProjectPathsConfig {
deployConfig?: string
}
}
declare module 'hardhat/types/runtime' {
interface HardhatRuntimeEnvironment {
deployConfig: {
[key: string]: any
}
getDeployConfig(network: string): { [key: string]: any }
}
}
export type DeployConfigSpec<
TDeployConfig extends {
[key: string]: any
}
> = {
[K in keyof TDeployConfig]: {
type: 'address' | 'number' | 'string' | 'boolean'
default?: any
}
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": [
"src/**/*"
]
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment