Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Envio to feat/pnpm #1

Merged
merged 43 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0b26a0a
update gh actions, gitignore, husky, lintstage
technophile-04 Jul 20, 2023
8f05ef1
add pnpm workspace and lock file
technophile-04 Jul 21, 2023
2764620
generate pnpm-lock.yaml per workspace
technophile-04 Jul 24, 2023
72bfa68
add use-hooks patch
technophile-04 Jul 24, 2023
38a1bd0
remove --immutable from gh-workflow
technophile-04 Jul 24, 2023
fe3bce4
setup pnpm in gh workflow
technophile-04 Jul 24, 2023
0676079
add downloading Git reference back
technophile-04 Jul 26, 2023
c23d19d
updater packageManger version in package.json
technophile-04 Jul 26, 2023
7debabc
add preinstall script
technophile-04 Jul 27, 2023
97766bf
use glob pattern for workspace
technophile-04 Jul 27, 2023
7f102c5
put back OG deploy command
technophile-04 Aug 1, 2023
08719f4
fix localStorage patch, update pnpm version to 8.6.12
technophile-04 Aug 7, 2023
3342794
update gh-actions to use pnpm run while running scripts
technophile-04 Aug 7, 2023
b0691ee
add abitype
technophile-04 Sep 3, 2023
1e70e0c
add check for pnpm version >=8.7.1 & use shorthand -F instead of --fi…
technophile-04 Sep 8, 2023
9361335
update readme with lowercase pnpm and mention version
technophile-04 Sep 8, 2023
3b7a4c2
Fix pnpm installation link
carletex Sep 14, 2023
71f88ab
use node v18 in actions
technophile-04 Sep 24, 2023
147eaab
update abitype ovveride path
technophile-04 Sep 24, 2023
ab6b757
add use-hooks patch
technophile-04 Jul 24, 2023
4ba29fd
fix localStorage patch, update pnpm version to 8.6.12
technophile-04 Aug 7, 2023
eb0d81b
fix deploy to hardhat:deploy according to readme
JonoPrest Oct 16, 2023
07519b7
add envio-indexer from template
JonoPrest Oct 16, 2023
55c14a1
Update template for custom contract
JonoPrest Oct 16, 2023
99fc7f6
Update indexer code
JonoPrest Oct 17, 2023
0abfc10
Update workspace config for working envio
JonoPrest Oct 17, 2023
6bc02e2
Fix event value param
JonoPrest Oct 17, 2023
9c4f6ea
Add commands to package.json and readme
JonoPrest Oct 17, 2023
1b51c6c
Remove unused abi file
JonoPrest Oct 17, 2023
6d3b9be
WIP adding envio-data component
JonoPrest Oct 17, 2023
949d239
Fix: use correct package name for envio commands
JonoPrest Oct 18, 2023
503573b
fix: envio data component styling
JonoPrest Oct 18, 2023
87d81cb
Type coercing address and removing husky for failed linting
JonoPrest Oct 18, 2023
b3a7c1f
Add greeting deployment script
JonoPrest Oct 18, 2023
b7a2538
Fix: index 0 not clickable in table
JonoPrest Oct 18, 2023
c77f638
Add padding for small screens
JonoPrest Oct 18, 2023
33df812
Fix readme
JonoPrest Oct 19, 2023
38b0adb
Updated pnpm.lock
JonoPrest Oct 19, 2023
9720868
Update packages/hardhat/deploy/01_add_greeting.ts
JonoPrest Oct 19, 2023
0ac54be
Tweak message to say contract interaction
JonoPrest Oct 19, 2023
18841df
Remove console log
JonoPrest Oct 19, 2023
1cfe7b7
Fix readme
JonoPrest Oct 19, 2023
df573e5
add dotenv and concurrently for gql codegen
JonoPrest Oct 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,34 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [16.x]
node: [18.x]

steps:
- name: Checkout
uses: actions/checkout@master

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup node env
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache : yarn
cache: pnpm

- name: Install dependencies
run: yarn install --immutable
run: pnpm install

- name: Run hardhat node, deploy contracts (& generate contracts typescript output)
run: yarn chain & yarn deploy
run: pnpm run chain & pnpm run deploy

- name: Run nextjs lint
run: yarn next:lint --max-warnings=0
run: pnpm run next:lint --max-warnings=0

- name: Check typings on nextjs
run: yarn next:check-types
run: pnpm run next:check-types

- name: Run hardhat lint
run: yarn hardhat:lint --max-warnings=0
run: pnpm run hardhat:lint --max-warnings=0
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
node_modules

# dependencies, yarn, etc
# yarn / eslint
# pnpm
pnpm-debug.log*
pnpm-error.log*
.pnpm-debug.log*

# yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# eslint
.eslintcache

# Visual Studio Code
.vscode/**

# macOS
.DS_Store
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged --verbose
# pnpm lint-staged --verbose
6 changes: 3 additions & 3 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const path = require("path");

const buildNextEslintCommand = (filenames) =>
`yarn next:lint --fix --file ${filenames
`pnpm next:lint --fix --file ${filenames
.map((f) => path.relative(path.join("packages", "nextjs"), f))
.join(" --file ")}`;

const checkTypesNextCommand = () => "yarn next:check-types";
const checkTypesNextCommand = () => "pnpm next:check-types";

const buildHardhatEslintCommand = (filenames) =>
`yarn hardhat:lint-staged --fix ${filenames
`pnpm hardhat:lint-staged --fix ${filenames
.map((f) => path.relative(path.join("packages", "hardhat"), f))
.join(" ")}`;

Expand Down
9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

783 changes: 0 additions & 783 deletions .yarn/releases/yarn-3.2.3.cjs

This file was deleted.

11 changes: 0 additions & 11 deletions .yarnrc.yml

This file was deleted.

38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
Before you begin, you need to install the following tools:

- [Node (v18 LTS)](https://nodejs.org/en/download/)
- Yarn ([v1](https://classic.yarnpkg.com/en/docs/install/) or [v2+](https://yarnpkg.com/getting-started/install))
- [pnpm (v8.7.1+)](https://pnpm.io/installation)
- [docker](https://docs.docker.com/engine/install/)
- [Git](https://git-scm.com/downloads)

## Quickstart
Expand All @@ -32,45 +33,62 @@ To get started with Scaffold-ETH 2, follow the steps below:
```
git clone https://github.com/scaffold-eth/scaffold-eth-2.git
cd scaffold-eth-2
yarn install
pnpm install
```

2. Run a local network in the first terminal:

```
yarn chain
pnpm chain
```

This command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in `hardhat.config.ts`.

3. On a second terminal, deploy the test contract:

```
yarn deploy
pnpm hardhat:deploy
```

This command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script.
This command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `pnpm hardhat:deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script.

4. On a third terminal, start your NextJS app:
4. Ensure docker is running and then on a third terminal, start-up indexer:

```
yarn start
pnpm envio:codegen
```

and then:

```
pnpm envio:dev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add pnpm envio:codegen as init is never run when this is cloned

https://github.com/Float-Capital/indexer/issues/974

```

This will run a codegen for your configured envio indexer, it will install all required packages, handle db-migrations and graphql server, and begin indexing your smart contract events.

Visit the hasura console on: `http://localhost:8080`. You can see the realtime indexing of data in the "data" tab and use the graphql explorer to build queries.

For more info on writing/updating an indexer visit [docs.envio.dev/docs](https://docs.envio.dev/docs/overview).

5. On a fourth terminal, start your NextJS app:

```
pnpm start
```

Visit your app on: `http://localhost:3000`. You can interact with your smart contract using the contract component or the example ui in the frontend. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.

Run smart contract test with `yarn hardhat:test`
Run smart contract test with `pnpm hardhat:test`

- Edit your smart contract `YourContract.sol` in `packages/hardhat/contracts`
- Edit your frontend in `packages/nextjs/pages`
- Edit your deployment scripts in `packages/hardhat/deploy`
- Edit your envio indexer config.yaml, schema.graphql and EventHandlers.ts in `packages/envio-indexer`

## Documentation

Visit our [docs](https://docs.scaffoldeth.io) to learn how to start building with Scaffold-ETH 2.

To know more about its features, check out our [website](https://scaffoldeth.io).

## Contributing to Scaffold-ETH 2

We welcome contributions to Scaffold-ETH 2!
Expand Down
46 changes: 25 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,36 @@
]
},
"scripts": {
"account": "yarn workspace @se-2/hardhat account",
"chain": "yarn workspace @se-2/hardhat chain",
"fork": "yarn workspace @se-2/hardhat fork",
"deploy": "yarn workspace @se-2/hardhat deploy",
"verify": "yarn workspace @se-2/hardhat verify",
"compile": "yarn workspace @se-2/hardhat compile",
"generate": "yarn workspace @se-2/hardhat generate",
"hardhat:lint": "yarn workspace @se-2/hardhat lint",
"hardhat:lint-staged": "yarn workspace @se-2/hardhat lint-staged",
"hardhat:test": "yarn workspace @se-2/hardhat test",
"test": "yarn hardhat:test",
"start": "yarn workspace @se-2/nextjs dev",
"next:lint": "yarn workspace @se-2/nextjs lint",
"next:format": "yarn workspace @se-2/nextjs format",
"next:check-types": "yarn workspace @se-2/nextjs check-types",
"preinstall": "npx only-allow pnpm",
"account": "pnpm -F @se-2/hardhat run account",
"chain": "pnpm -F @se-2/hardhat run chain",
"fork": "pnpm -F @se-2/hardhat run fork",
"hardhat:deploy": "pnpm -F @se-2/hardhat run deploy",
"verify": "pnpm -F @se-2/hardhat run verify",
"compile": "pnpm -F @se-2/hardhat run compile",
"generate": "pnpm -F @se-2/hardhat run generate",
"hardhat:lint": "pnpm -F @se-2/hardhat run lint",
"hardhat:lint-staged": "pnpm -F @se-2/hardhat run lint-staged",
"hardhat:test": "pnpm -F @se-2/hardhat run test",
"envio:codegen": "pnpm -F @se-2/envio run codegen",
"envio:dev": "pnpm -F @se-2/envio run dev",
"envio:start": "pnpm -F @se-2/envio run start",
"start": "pnpm -F @se-2/nextjs run dev",
"next:lint": "pnpm -F @se-2/nextjs run lint",
"next:format": "pnpm -F @se-2/nextjs run format",
"next:check-types": "pnpm -F @se-2/nextjs run check-types",
"test": "pnpm -F @se-2/hardhat run test",
"postinstall": "husky install",
"precommit": "lint-staged",
"vercel": "yarn workspace @se-2/nextjs vercel",
"vercel:yolo": "yarn workspace @se-2/nextjs vercel:yolo"
"vercel": "pnpm -F @se-2/nextjs run vercel",
"vercel:yolo": "pnpm -F @se-2/nextjs run vercel:yolo"
},
"engines": {
"node": ">=16.14.0",
"pnpm": ">=8.7.1"
},
"packageManager": "[email protected]",
"devDependencies": {
"husky": "^8.0.1",
"lint-staged": "^13.0.3"
},
"resolutions": {
"usehooks-ts@^2.7.2": "patch:usehooks-ts@npm:^2.7.2#./.yarn/patches/usehooks-ts-npm-2.7.2-fceffe0e43.patch"
}
}
33 changes: 33 additions & 0 deletions packages/envio-indexer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
*.exe
*.obj
*.out
*.compile
*.native
*.byte
*.cmo
*.annot
*.cmi
*.cmx
*.cmt
*.cmti
*.cma
*.a
*.cmxa
*.obj
*~
*.annot
*.cmj
*.bak
lib/*
*.mlast
*.mliast
.vscode
.merlin
.bsb.lock
/node_modules/
benchmarks/
artifacts
cache
build
*.bs.js
generated
3 changes: 3 additions & 0 deletions packages/envio-indexer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Envio Greeter Template

*Please refer to the [documentation website](https://docs.envio.dev) for a thorough guide on all Envio indexer features*
15 changes: 15 additions & 0 deletions packages/envio-indexer/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: YourContract
description: YourContract indexer
networks:
- id: 31337 #Hardhat
start_block: 0
rpc_config:
url: http://127.0.0.1:8545 #rpc url for local hardhat network
contracts:
- name: Greeting
address: "0x5fbdb2315678afecb367f032d93f642f64180aa3"
handler: src/EventHandlers.ts
events:
- event: "GreetingChange(address indexed greetingSetter, string newGreeting, bool premium, uint256 value)"
requiredEntities:
- name: User
70 changes: 70 additions & 0 deletions packages/envio-indexer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

<!--
* Copyright (c) 2021 GraphQL Contributors
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<title>GraphiQL</title>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}

#graphiql {
height: 100vh;
}
</style>

<!--
This GraphiQL example depends on Promise and fetch, which are available in
modern browsers, but can be "polyfilled" for older browsers.
GraphiQL itself depends on React DOM.
If you do not want to rely on a CDN, you can host these files locally or
include them directly in your favored resource bundler.
-->
<script
src="https://unpkg.com/react@17/umd/react.development.js"
integrity="sha512-Vf2xGDzpqUOEIKO+X2rgTLWPY+65++WPwCHkX2nFMu9IcstumPsf/uKKRd5prX3wOu8Q0GBylRpsDB26R6ExOg=="
crossorigin="anonymous"
></script>
<script
src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
integrity="sha512-Wr9OKCTtq1anK0hq5bY3X/AvDI5EflDSAh0mE9gma+4hl+kXdTJPKZ3TwLMBcrgUeoY0s3dq9JjhCQc7vddtFg=="
crossorigin="anonymous"
></script>

<!--
These two files can be found in the npm module, however you may wish to
copy them directly into your environment, or perhaps include them in your
favored resource bundler.
-->
<link rel="stylesheet" href="https://unpkg.com/graphiql/graphiql.min.css" />
</head>

<body>
<div id="graphiql">Loading...</div>
<script
src="https://unpkg.com/graphiql/graphiql.min.js"
type="application/javascript"
></script>
<script>
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: GraphiQL.createFetcher({
url: 'http://localhost:8080/v1/graphql',
}),
defaultEditorToolsVisibility: true,
}),
document.getElementById('graphiql'),
);
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions packages/envio-indexer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@se-2/envio",
"version": "0.1.0",
"scripts": {
"clean": "tsc --clean",
"build": "tsc --build",
"watch": "tsc --watch",
"dev": "envio dev",
"codegen": "envio codegen",
"start": "ts-node generated/src/Index.bs.js"
},
"devDependencies": {
"@types/node": "^18.16.1",
"typescript": "^5.0.4"
},
"dependencies": {
"ts-node": "^10.9.1",
"envio": "0.0.20"
}
}
Loading
Loading