Skip to content

Commit

Permalink
🏎️ Migrate to turbo and pnpm (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-tarczynski authored Apr 10, 2024
1 parent ec909c0 commit ee226c9
Show file tree
Hide file tree
Showing 11 changed files with 17,163 additions and 17,147 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ tsconfig.tsbuildinfo
# Eslint cache
.eslintcache

# Build files
.turbo

# Generated by Certora
.certora_*
.last_confs
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
## Running Hardhat node
Change directory to `packages/contracts` and execute:
```shell
yarn node:run
pnpm node:run
```
This will start a Hardhat node, deploy the contracts and place initial bids using the first twenty auto-generated accounts.

## Custom tasks
A number of custom Hardhat tasks were defined to aid testing.

### Managing local node
- `yarn node:increase-time [--value <INT>]` - increase block time by *value* seconds, defaults to six hour
- `yarn node:accounts` - print a list of available accounts
- `pnpm node:increase-time [--value <INT>]` - increase block time by *value* seconds, defaults to six hour
- `pnpm node:accounts` - print a list of available accounts

### Interacting with AuctionRaffle contract

#### Hardhat
- `yarn hardhat:bid --account <STRING> --amount <STRING>` - using *account* place bid of *amount* ETH
- `yarn hardhat:bid-random --amount <INT> [--account <INT>]` - using randomly generated accounts place *amount* of bids using funds from account with index *account* (defaults to `0`)
- `yarn hardhat:settle-auction` - settle auction
- `yarn hardhat:settle-raffle` - settle raffle using random numbers
- `yarn hardhat:settle` - increase time, settle auction and raffle
- `pnpm hardhat:bid --account <STRING> --amount <STRING>` - using *account* place bid of *amount* ETH
- `pnpm hardhat:bid-random --amount <INT> [--account <INT>]` - using randomly generated accounts place *amount* of bids using funds from account with index *account* (defaults to `0`)
- `pnpm hardhat:settle-auction` - settle auction
- `pnpm hardhat:settle-raffle` - settle raffle using random numbers
- `pnpm hardhat:settle` - increase time, settle auction and raffle

#### Arbitrum Rinkeby
- `yarn rinkeby:generate-dotenv [--path <STRING>] [--count <INT>]` - generate .env file needed for other tasks, *path* - output path, *count* - number of private keys to generate
- `yarn rinkeby:transfer-ether` - transfer ether from `DEPLOYER` to `PRIVATE_KEYS` accounts
- `yarn rinkeby:init-bids` - place initial bids using `PRIVATE_KEYS` accounts
- `pnpm rinkeby:generate-dotenv [--path <STRING>] [--count <INT>]` - generate .env file needed for other tasks, *path* - output path, *count* - number of private keys to generate
- `pnpm rinkeby:transfer-ether` - transfer ether from `DEPLOYER` to `PRIVATE_KEYS` accounts
- `pnpm rinkeby:init-bids` - place initial bids using `PRIVATE_KEYS` accounts

#### Ethereum Mainnet
- `yarn ethereum:generate-random-numbers --blocks <ARRAY> --secret <STRING>` - generate random numbers for raffle settlement, *blocks* - array of block numbers from which extract block hash (e.g. "[1234, 5678]"), *secret* - secret number represented as 32 bytes hex string
- `pnpm ethereum:generate-random-numbers --blocks <ARRAY> --secret <STRING>` - generate random numbers for raffle settlement, *blocks* - array of block numbers from which extract block hash (e.g. "[1234, 5678]"), *secret* - secret number represented as 32 bytes hex string

16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
"name": "devcon-raffle",
"private": true,
"version": "0.0.1",
"packageManager": "[email protected]",
"scripts": {
"lint": "wsrun -c lint",
"build": "wsrun -te -c build",
"test": "wsrun -c test",
"verify": "wsrun -m -c verify",
"lint": "turbo lint",
"build": "turbo build",
"test": "turbo test",
"verify": "turbo verify",
"update": "git submodule update --remote"
},
"workspaces": [
"packages/contracts",
"packages/frontend",
"packages/next-frontend"
],
"devDependencies": {
"wsrun": "^5.2.4"
"turbo": "^1.13.2"
}
}
11 changes: 6 additions & 5 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
"main": "build/types/index.ts",
"types": "build/index.ts",
"scripts": {
"preinstall": "npx only-allow pnpm",
"clean": "rm -rf ./build",
"typecheck": "tsc --noEmit",
"lint:sol": "solhint 'contracts/**/*.sol' && prettylint 'contracts/**/*.sol'",
"lint:ts": "eslint '{test,scripts}/**/*.ts' -c .eslintrc.typescript.js --cache",
"lint": "yarn run lint:sol && yarn run lint:ts",
"lint:fix": "prettier 'contracts/**/*.sol' --write --loglevel error && yarn run lint:ts --fix",
"lint": "pnpm run lint:sol && pnpm run lint:ts",
"lint:fix": "prettier 'contracts/**/*.sol' --write --loglevel error && pnpm run lint:ts --fix",
"build:sol": "waffle .waffle.json",
"build:types": "typechain --target ethers-v5 --outDir build/types 'build/*.json' > /dev/null && echo 'Typechain generated'",
"build:waffle": "yarn run clean && yarn run build:sol && yarn run build:types && bash ./scripts/indexBuild.sh",
"build:waffle": "pnpm run clean && pnpm run build:sol && pnpm run build:types && bash ./scripts/indexBuild.sh",
"build": "hardhat compile && bash ./scripts/indexBuild.sh",
"build-test": "yarn run build && yarn run test",
"build-test": "pnpm run build && pnpm run test",
"test": "mocha 'test/**/*.test.ts'",
"test:e2e": "mocha 'test/**/*.e2e.ts'",
"test:hardhat": "hardhat test",
Expand All @@ -29,7 +30,7 @@
"hardhat:bid-random": "hardhat --network localhost bid-random",
"hardhat:settle-auction": "hardhat --network localhost settle-auction",
"hardhat:settle-raffle": "hardhat --network localhost settle-raffle",
"hardhat:settle": "yarn node:increase-time && yarn hardhat:settle-auction && yarn hardhat:settle-raffle",
"hardhat:settle": "pnpm node:increase-time && pnpm hardhat:settle-auction && pnpm hardhat:settle-raffle",
"rinkeby:generate-dotenv": "hardhat generate-dotenv",
"rinkeby:transfer-ether": "hardhat --network rinkeby transfer-ether",
"rinkeby:init-bids": "hardhat --network rinkeby init-bids",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/scripts/mars/marsDeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if [[ "$(git status --porcelain)" ]]; then
fi

if [[ "$(git log --pretty=format:'%H' -n 1)" != "$(cat ./build/canary.hash)" ]]; then
echo "Error: Build canary does not match current commit hash. Please run yarn build."
echo "Error: Build canary does not match current commit hash. Please run pnpm build."
exit 1
fi

Expand All @@ -59,7 +59,7 @@ target_file_name="$(basename -- ${DEPLOY_SCRIPT})"
target_log="-${target_file_name%.*}"
timestamp_log="-$(date +%s)"

yarn mars
pnpm mars
ts-node ${DEPLOY_SCRIPT} \
--waffle-config ./.waffle.json \
${args} \
Expand Down
7 changes: 4 additions & 3 deletions packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
"version": "0.0.1",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "yarn lint:prettier --check && yarn lint:eslint",
"lint:fix": "yarn lint:prettier --write --loglevel warn && yarn lint:eslint --fix",
"lint": "pnpm lint:prettier --check && pnpm lint:eslint",
"lint:fix": "pnpm lint:prettier --write --loglevel warn && pnpm lint:eslint --fix",
"lint:eslint": "eslint './{src,test}/**/*.{ts,tsx}' --cache",
"lint:prettier": "prettier './{src,test}/**/*.{ts,tsx}'",
"test": "jest"
},
"dependencies": {
"@coinbase/wallet-sdk": "^3.0.11",
"@devcon-raffle/contracts": "0.0.1",
"@devcon-raffle/contracts": "workspace:*",
"@ethersproject/abi": "^5.6.0",
"@ethersproject/bignumber": "^5.5.0",
"@ethersproject/constants": "^5.6.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/next-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "yarn next dev",
"build": "yarn next build",
"start": "yarn next start",
"lint": "yarn next lint"
"preinstall": "npx only-allow pnpm",
"dev": "pnpm next dev",
"build": "pnpm next build",
"start": "pnpm next start",
"lint": "pnpm next lint"
},
"dependencies": {
"react": "^18",
Expand Down
Loading

0 comments on commit ee226c9

Please sign in to comment.