Skip to content

Latest commit

 

History

History
191 lines (146 loc) · 2.76 KB

SETUP.md

File metadata and controls

191 lines (146 loc) · 2.76 KB

Global dependencies: node and nvm

Step 1: NVM

echo "v16.14.0" > .nvmrc
nvm use

Step 2: .gitignore

echo "node_modules\n.DS_Store\ntypechain\n.env\n" > .gitignore

Step 3: Yarn

npm install -g yarn
yarn init --yes

Add export PATH="$(yarn global bin):$PATH" to .bashrc or .zshrc

Step 4: Lerna

yarn global add lerna
lerna init

Add to lerna.json

{
  "packages": [
    "packages/*"
  ],
  "version": "0.0.1",
  "npmClient": "yarn",
  "useWorkspaces": true
}

Add to package.json

{
  "private": true,
  "workspaces": [
    "packages/*"
  ],
  "scripts": {
    "test": "lerna run test",
    "new-version": "lerna version --conventional-commits --yes",
    "diff": "lerna diff"
  }
}

Step 4: Conventional Commits

yarn add -D -W git-cz

Step 5: Typescript

yarn global add typescript

Step 6: Init Frontend DApps

cd packages
yarn add -D -W create-react-app create-react-library
yarn create react-app glider --template typescript
yarn create react-app rooms --template typescript
lerna bootstrap

Step 7: Smart contracts

mkdir smart-contracts && cd $_
yarn init

Edit package.json

{
  "name": "stays-smart-contracts",
  "version": "0.0.1",
  "license": "GPL3"
}

Hardhat

yarn add -D hardhat
yarn run hardhat # > Create an empty hardhat.config.js

Typescript

yarn add -D ts-node chai @types/node @types/mocha @types/chai @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai [email protected] @typechain/hardhat @typechain/ethers-v5
tsc --init
mv hardhat.config.js hardhat.config.ts

Change tsconfig.json to:

{
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "outDir": "dist"
  },
  "include": ["./scripts", "./test", "./typechain"],
  "files": ["./hardhat.config.ts"]
}

Change hardhat.config.ts to

import '@typechain/hardhat'
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'

module.exports = {
  solidity: {
    version: '0.8.8'
  }
}

Structure

mkdir contracts test

Step 8: Documentation Package

cd packages
mkdir docs && cd $_
yarn init --yes
echo "# Stays: on-chain bookings" > README.md

Edit package.json

{
  "name": "stays-docs",
  "version": "0.0.1",
  "license": "MIT"
}

Step 9: ESLint and Prettier

Add the following configuration

"devDependencies": {
  "@windingtree/eslint-config": "^0.0.1",
  "@windingtree/prettier-config": "^0.0.1"
}

to:

  • packages/rooms/package.json
  • packages/glider/package.json
  • packages/smart-contracts/package.json

and then:

lerna bootstrap