Skip to content

Commit

Permalink
chore: fix scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
petejkim committed Mar 21, 2022
1 parent 66e94d6 commit 985d03f
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 79 deletions.
3 changes: 2 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn prettier
yarn compile
yarn lint
34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,19 @@ Please refer to the tests for `.resolve` and `.resolveWithProof` in
CoinbaseResolver conforms to [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967)
and [EIP-1822](https://eips.ethereum.org/EIPS/eip-1822) for upgradeability.

## Requirements

- Node.js v16
- Yarn v1.22.x

## Usage

### Install dependencies

```sh
$ yarn install
```

### Compile

Compile the smart contracts with Hardhat:
Expand All @@ -46,33 +57,26 @@ Compile the smart contracts and generate TypeChain artifacts:
$ yarn typechain
```

### Lint Solidity

Lint the Solidity code:
### Lint

```sh
$ yarn lint:sol
$ yarn lint
```

### Lint TypeScript

Lint the TypeScript code:
### Test

```sh
$ yarn lint:ts
$ yarn test
```

### Test

Run the Mocha tests:
### Test Coverage

```sh
$ yarn test
$ yarn coverage
```

## Deployment
### Deployment

```sh
$ hardhat typechain
$ hardhat deploy:CoinbaseResolver --network <NETWORK>
$ yarn deploy --network <NETWORK>
```
3 changes: 0 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";

import "./tasks/accounts";
import "./tasks/deploy";

import { resolve } from "path";

import { config as dotenvConfig } from "dotenv";
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@
"/contracts"
],
"scripts": {
"accounts": "hardhat run src/scripts/accounts.ts",
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./src/types ./coverage.json",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "yarn typechain && hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\"",
"deploy": "hardhat deploy:Greeter",
"deploy": "hardhat run src/scripts/deploy.ts",
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
"lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .",
Expand Down
17 changes: 17 additions & 0 deletions src/scripts/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import "@nomiclabs/hardhat-ethers";
import hre from "hardhat";

async function main() {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(await account.getAddress());
}
}

main()
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});
53 changes: 53 additions & 0 deletions src/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { CoinbaseResolver__factory } from "../../src/types";
import "@nomiclabs/hardhat-ethers";
import hre from "hardhat";

async function main() {
const { ethers } = hre;

const deployer = (await ethers.getSigners())[0];

const resolverFactory = await ethers.getContractFactory("CoinbaseResolver");
const proxyFactory = await ethers.getContractFactory("ERC1967Proxy");

console.log("deploying implementation contract...");
const implementation = await resolverFactory.deploy();
await implementation.deployed();
console.log("-> deployed implementation contract at", implementation.address);

console.log("initializing implementation contract with dummy values...");
await implementation.initialize(ethers.constants.AddressZero, "", []);
console.log("-> initialized implementation contract");

const iCoinbaseResolver = CoinbaseResolver__factory.createInterface();

const proxyArgs = [
implementation.address,
iCoinbaseResolver.encodeFunctionData("initialize", [
deployer.address,
"http://localhost:3000/r/{sender}/{data}",
[deployer.address],
]),
];

console.log(
`deploying proxy contract (arguments: ${JSON.stringify(proxyArgs)})...`
);
const proxy = await proxyFactory.deploy(
implementation.address,
iCoinbaseResolver.encodeFunctionData("initialize", [
deployer.address,
"http://localhost:3000/r/{sender}/{data}",
[deployer.address],
])
);
await proxy.deployed();
console.log("-> deployed proxy contract at", proxy.address);
}

main()
.then(() => process.exit(0))
.catch((err) => {
console.error(err);
process.exit(1);
});
9 changes: 0 additions & 9 deletions tasks/accounts.ts

This file was deleted.

49 changes: 0 additions & 49 deletions tasks/deploy/CoinbaseResolver.ts

This file was deleted.

1 change: 0 additions & 1 deletion tasks/deploy/index.ts

This file was deleted.

0 comments on commit 985d03f

Please sign in to comment.