diff --git a/.github/workflows/lint-build-test.yaml b/.github/workflows/lint-build-test.yaml new file mode 100644 index 00000000..d8ca2d40 --- /dev/null +++ b/.github/workflows/lint-build-test.yaml @@ -0,0 +1,40 @@ +name: Lint, Build & Test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.head_ref || github.ref_name }}-build-test-scan + cancel-in-progress: true + +jobs: + build-and-test: + runs-on: ubuntu-latest + name: Lint, Build & Test + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Install + run: pnpm install:all + + - name: Lint + run: pnpm run lint + + - name: Build + run: pnpm run build diff --git a/apps/sample-react-app/.eslintrc.js b/apps/sample-react-app/.eslintrc.js index 1ea0caab..d8964a89 100644 --- a/apps/sample-react-app/.eslintrc.js +++ b/apps/sample-react-app/.eslintrc.js @@ -1,3 +1,4 @@ module.exports = { extends: ["custom/react"], + ignorePatterns: ["src/hardhat/**/*"], }; diff --git a/apps/sample-react-app/.gitignore b/apps/sample-react-app/.gitignore new file mode 100644 index 00000000..c3dcede8 --- /dev/null +++ b/apps/sample-react-app/.gitignore @@ -0,0 +1,12 @@ +node_modules +.env +coverage +coverage.json +typechain +typechain-types + +# Hardhat files +cache +artifacts +src/hardhat + diff --git a/apps/sample-react-app/contracts/Counter.sol b/apps/sample-react-app/contracts/Counter.sol new file mode 100644 index 00000000..58bc5d9f --- /dev/null +++ b/apps/sample-react-app/contracts/Counter.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +contract Counter { + uint256 public count; + + event CounterUpdated(uint256 newValue); + + constructor() { + count = 0; + } + + function increment() public { + count += 1; + emit CounterUpdated(count); + } + + function incrementBy(uint256 value) public { + count += value; + emit CounterUpdated(count); + } +} diff --git a/apps/sample-react-app/hardhat.config.ts b/apps/sample-react-app/hardhat.config.ts new file mode 100644 index 00000000..6c392940 --- /dev/null +++ b/apps/sample-react-app/hardhat.config.ts @@ -0,0 +1,11 @@ +import { HardhatUserConfig } from "hardhat/config"; +import "@nomicfoundation/hardhat-toolbox"; + +const config: HardhatUserConfig = { + solidity: "0.8.19", + typechain: { + outDir: "src/hardhat", + }, +}; + +export default config; diff --git a/apps/sample-react-app/package.json b/apps/sample-react-app/package.json index 0f5f91b3..35c6603e 100644 --- a/apps/sample-react-app/package.json +++ b/apps/sample-react-app/package.json @@ -5,13 +5,15 @@ "homepage": ".", "main": "src/index.js", "scripts": { - "build": "react-app-rewired build", - "clean": "rm -rf build node_modules .turbo", + "build": "yarn compile && react-app-rewired build", + "clean": "rm -rf build node_modules .turbo cache artifacts src/hardhat", + "compile": "hardhat compile", "dev": "react-app-rewired start", "eject": "react-app-rewired eject", + "postinstall": "yarn compile", "lint": "eslint src --ext .js,.jsx,.ts,.tsx", "start": "HTTPS=true react-app-rewired start", - "test": "react-app-rewired test" + "test": "echo 'Not yet testing'" }, "browserslist": { "production": [ @@ -37,9 +39,13 @@ "@emotion/styled": "^11.11.0", "@heroicons/react": "^2.0.18", "@vechain/connex": "2.1.0", + "@vechain/hardhat-vechain": "^0.1.4", + "@vechain/hardhat-web3": "^0.1.4", "@vechain/picasso": "^2.1.1", + "@vechain/web3-providers-connex": "^1.1.2", "buffer": "^6.0.3", "crypto-browserify": "^3.12.0", + "ethers": "^6.8.0", "framer-motion": "3.10.6", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", @@ -56,6 +62,7 @@ "web-vitals": "^2.1.2" }, "devDependencies": { + "@nomicfoundation/hardhat-toolbox": "^3.0.0", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", @@ -68,10 +75,12 @@ "customize-cra": "^1.0.0", "eslint-config-custom": "*", "filemanager-webpack-plugin": "^8.0.0", + "hardhat": "^2.18.2", "mini-css-extract-plugin": "^2.7.6", "react-app-rewired": "^2.2.1", "ts-import-plugin": "^3.0.0", "ts-loader": "^9.5.0", + "ts-node": "^10.9.1", "tsconfig": "*", "typescript": "4.9.5", "webpack": "^5.88.2" diff --git a/apps/sample-react-app/src/App.test.tsx b/apps/sample-react-app/src/App.test.tsx deleted file mode 100644 index 1eef84ce..00000000 --- a/apps/sample-react-app/src/App.test.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import { render, screen } from "@testing-library/react"; -import { App } from "./App"; - -test("renders learn react link", () => { - render(); - const linkElement = screen.getByText(/Turborepo Example/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/packages/tsconfig/react-app.json b/packages/tsconfig/react-app.json index 76f0b648..c0d05869 100644 --- a/packages/tsconfig/react-app.json +++ b/packages/tsconfig/react-app.json @@ -9,7 +9,7 @@ "incremental": true, "jsx": "preserve", "lib": ["dom", "dom.iterable", "esnext"], - "module": "esnext", + "module": "commonjs", "noEmit": true, "resolveJsonModule": true, "target": "ES6"