This repository has been archived by the owner on Aug 9, 2021. It is now read-only.
generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add fs-extra and tempy as dev deps build: prepare-package.ts script build: update yarn.lock chore: add .npmignore file in contracts folder docs: add flags to the top of README docs: add "artifacts" and "typechain" to files allowlist in package.json docs: changelog
- Loading branch information
Showing
6 changed files
with
246 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [1.0.0] - 2021-07-31 | ||
|
||
### Added | ||
|
||
- First release of the package. | ||
|
||
[1.0.0]: https://github.com/hifi-finance/hifi-proxy-target/releases/tag/v1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Hifi Proxy Target | ||
# Hifi Proxy Target [![Commitizen Friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/) [![License: LGPL3.0](https://img.shields.io/badge/license-LGPL3.0-yellow.svg)](https://opensource.org/licenses/lgpl-3.0) | ||
|
||
DSProxy target contract with scripts for the Hifi protocol. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# files | ||
.DS_Store | ||
.npmignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import path from "path"; | ||
|
||
import fsExtra from "fs-extra"; | ||
import hre from "hardhat"; | ||
import { Artifact } from "hardhat/types"; | ||
import tempy from "tempy"; | ||
|
||
const artifactsDir: string = path.join(__dirname, "..", "artifacts"); | ||
const contracts: string[] = ["HifiProxyTarget", "IHifiProxyTarget", "WethInterface"]; | ||
const tempArtifactsDir: string = tempy.directory(); | ||
const typeChainDir: string = path.join(__dirname, "..", "typechain"); | ||
const tempTypeChainDir: string = tempy.directory(); | ||
|
||
async function writeArtifactToFile(contractName: string): Promise<void> { | ||
const artifact: Artifact = await hre.artifacts.readArtifact(contractName); | ||
await fsExtra.writeJson(path.join(tempArtifactsDir, contractName + ".json"), artifact, { spaces: 2 }); | ||
} | ||
|
||
async function moveTypeChainBinding(contractName: string): Promise<void> { | ||
const bindingPath: string = path.join(typeChainDir, contractName + ".d.ts"); | ||
|
||
if (fsExtra.existsSync(bindingPath) == false) { | ||
throw new Error("TypeChain binding " + contractName + ".d.ts not found"); | ||
} | ||
|
||
await fsExtra.move(bindingPath, path.join(tempTypeChainDir, contractName + ".d.ts")); | ||
} | ||
|
||
async function prepareArtifacts(): Promise<void> { | ||
await fsExtra.ensureDir(tempArtifactsDir); | ||
const npmIgnorePath: string = path.join(tempArtifactsDir, ".npmignore"); | ||
await fsExtra.ensureFile(npmIgnorePath); | ||
await fsExtra.writeFile(npmIgnorePath, ".DS_Store\n.npmignore"); | ||
|
||
for (const contract of contracts) { | ||
await writeArtifactToFile(contract); | ||
} | ||
|
||
await fsExtra.remove(artifactsDir); | ||
await fsExtra.move(tempArtifactsDir, artifactsDir); | ||
} | ||
|
||
async function prepareTypeChainBindings(): Promise<void> { | ||
await fsExtra.ensureDir(tempTypeChainDir); | ||
|
||
for (const contract of contracts) { | ||
await moveTypeChainBinding(contract); | ||
} | ||
|
||
await fsExtra.remove(typeChainDir); | ||
await fsExtra.move(tempTypeChainDir, typeChainDir); | ||
} | ||
|
||
async function main(): Promise<void> { | ||
if (fsExtra.existsSync(artifactsDir) === false) { | ||
throw new Error("Please generate the Hardhat artifacts before running this script"); | ||
} | ||
|
||
if (fsExtra.existsSync(typeChainDir) === false) { | ||
throw new Error("Please generate the TypeChain bindings before running this script"); | ||
} | ||
|
||
await prepareArtifacts(); | ||
await prepareTypeChainBindings(); | ||
|
||
console.log("Contract artifacts and TypeChain bindings successfully prepared for npm"); | ||
} | ||
|
||
main() | ||
.then(() => process.exit(0)) | ||
.catch(async function (error: Error) { | ||
await fsExtra.remove(tempArtifactsDir); | ||
await fsExtra.remove(tempTypeChainDir); | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.