Skip to content

Commit

Permalink
add async decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
AlcibiadesCleinias committed Sep 4, 2023
1 parent 97cc570 commit d44157c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ PRIVATE_KEY=foo
# Your local or remote hardhat node.
GANACHE_AWS_RPC=http://foo.foo
TESTNET_SEPOLIA_RPC=http://foo.foo
# Others.
REPORT_GAS=<optional param; to disable del>
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ typechain-types/

.env
*frontend-clients-dist/

# Coverage
coverage.json
coverage
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ Additionally, to the basic **Hardhat Boilerplate**:
- [ ] migrate to pnpm - thus, you spend less time and work with last upd of npm.
- [x] add ci tests - thus, you show that you are concern about workable contract developments.
- [x] demo TokenContractClient - thus, you as a "backend" developer prepare client API class for the frontend
(api client class with accurate prepared methods, not raw contract calls).
(api client class with accurate prepared methods, not raw contract calls).
- [ ] Install deployment package and use
- [ ] add coverage report ci
- [ ] add gas report ci


### Typechain-types for Contracts
Expand Down
15 changes: 11 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import { config as dotEnvConfig } from "dotenv";
import { HardhatUserConfig } from "hardhat/config"
import "@nomicfoundation/hardhat-toolbox"
import { config as dotEnvConfig } from "dotenv"
// To work with coverage.
import "solidity-coverage"
// To work with eth-gas-reporter.
import "hardhat-gas-reporter"
// To load all available tasks you should it via manual import.
// Thus, we imported index.ts of the ./tasks module.
import "./tasks";
import "./tasks"

dotEnvConfig();

Expand Down Expand Up @@ -40,6 +44,9 @@ const config: HardhatUserConfig = {
chainId: 31337,
gasPrice: DEFAULT_GAS_PRICE,
},
},
gasReporter: {
enabled: !!(process.env.REPORT_GAS),
}
};

Expand Down
8 changes: 2 additions & 6 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import {artifacts, ethers, network} from "hardhat";
import * as path from "path";
import {Token} from "../typechain-types";
import {asyncRuntimeDecorator} from "./utils/asyncRuntimeDecorator";

async function main() {
// This is just a convenience check
Expand Down Expand Up @@ -59,9 +60,4 @@ function saveFrontendFiles(token) {
);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
asyncRuntimeDecorator(main)
10 changes: 10 additions & 0 deletions scripts/utils/asyncRuntimeDecorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type asyncRuntimeDecorator = (func: Function) => void

export const asyncRuntimeDecorator: asyncRuntimeDecorator = (func) => {
func()
.then(() => process.exit(0))
.catch((error: any) => {
console.error(error);
process.exit(1);
});
}

0 comments on commit d44157c

Please sign in to comment.