Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
docs: roll v1.0.0
Browse files Browse the repository at this point in the history
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
PaulRBerg committed Jul 31, 2021
1 parent bac7d2d commit 5f0680e
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 29 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
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
2 changes: 1 addition & 1 deletion README.md
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.
3 changes: 3 additions & 0 deletions contracts/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# files
.DS_Store
.npmignore
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@ethersproject/providers": "^5.4.0",
"@typechain/ethers-v5": "^7.0.1",
"@typechain/hardhat": "^2.1.0",
"@types/fs-extra": "^9.0.12",
"@types/node": "^15.12.5",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
Expand All @@ -29,21 +30,26 @@
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"ethers": "^5.4.0",
"fs-extra": "^10.0.0",
"hardhat": "^2.4.1",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
"pinst": "^2.1.6",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.11",
"shelljs": "^0.8.4",
"solhint": "^3.3.6",
"solhint-plugin-prettier": "^0.0.5",
"tempy": "^1.0.1",
"ts-generator": "^0.1.1",
"ts-node": "^10.0.0",
"typechain": "^5.1.1",
"typescript": "~4.2.4"
},
"files": [
"/contracts"
"/artifacts",
"/contracts",
"/typechain"
],
"keywords": [
"blockchain",
Expand Down
76 changes: 76 additions & 0 deletions scripts/prepare-package.ts
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);
});
Loading

0 comments on commit 5f0680e

Please sign in to comment.