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

feat: migrate lib to packages #7

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
625dac9
part 1
groninge01 Sep 27, 2024
1c22634
remove this
groninge01 Sep 29, 2024
d5b3461
update imports part 2
groninge01 Sep 30, 2024
ef288dc
update tsconfig
groninge01 Sep 30, 2024
49e975b
update imports part 3
groninge01 Sep 30, 2024
0ed4bfd
update linting
groninge01 Sep 30, 2024
5cba81b
move prettier config to package
groninge01 Sep 30, 2024
1b40470
update eslint rule
groninge01 Sep 30, 2024
d03e2ea
run prettier --fix
groninge01 Sep 30, 2024
0bb758d
update tsconfig
groninge01 Sep 30, 2024
766e84e
update tsconfig again
groninge01 Sep 30, 2024
edac8a0
move for now
groninge01 Sep 30, 2024
4ceff50
fix tests
groninge01 Sep 30, 2024
cec455e
fix gh setup
groninge01 Sep 30, 2024
8fb19ce
move assets to lib
groninge01 Sep 30, 2024
a4996d4
fix most integration tests
groninge01 Sep 30, 2024
4da4d92
fix: tests network config mainnet import
agualis Oct 1, 2024
deaaa0f
fix: addresses in integration tests
agualis Oct 1, 2024
27399b9
fix: addresses in integration tests2
agualis Oct 1, 2024
cf5ab75
fix receipt hooks test
groninge01 Oct 1, 2024
23730c8
chore: change polygon upper case
agualis Oct 1, 2024
4ca2769
cleanup packages
groninge01 Oct 1, 2024
960dc89
fix test in frontend-v3 app
groninge01 Oct 1, 2024
3ec472f
put back tsconfig paths
groninge01 Oct 1, 2024
a31e250
fix unit tests
groninge01 Oct 2, 2024
272f7e4
move to lib package
groninge01 Oct 2, 2024
696ddf0
add beets app
groninge01 Oct 2, 2024
cdaea65
move license to root
groninge01 Oct 2, 2024
9616040
split navbar
groninge01 Oct 2, 2024
dca8cd2
split footer & logos
groninge01 Oct 2, 2024
6f63fef
add newline
groninge01 Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

**Describe the bug** A clear and concise description of what the bug is.
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
title: ""
labels: ""
assignees: ""
---

**Is your feature request related to a problem? Please describe.** A clear and concise description
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ runs:

- name: Generate api typings
shell: bash
run: pnpm graphql:gen
run: pnpm --filter lib graphql:gen
File renamed without changes.
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,49 @@
_This project uses `pnpm`, if you haven't already installed it you can find the documentation here:
https://pnpm.io/installation_

_The monorepo uses [pnpm workspaces](https://pnpm.io/workspaces) along with Turborepo to manage build orchestration,
to learn more about Turborepo please see the
_The monorepo uses [pnpm workspaces](https://pnpm.io/workspaces) along with Turborepo to manage
build orchestration, to learn more about Turborepo please see the
[docs](https://turbo.build/repo/docs)._

## What's inside?

This monorepo includes the following apps & packages:

### Apps
- [apps/frontend-v3](https://github.com/balancer/frontend-monorepo/tree/main/apps/frontend-v3): The official web app for the Balancer protocol, hosted at [https://balancer.fi](https://balancer.fi).

- [apps/frontend-v3](https://github.com/balancer/frontend-monorepo/tree/main/apps/frontend-v3): The
official web app for the Balancer protocol, hosted at [https://balancer.fi](https://balancer.fi).

### Packages
- [packages/eslint-config](https://github.com/balancer/frontend-monorepo/tree/main/packages/eslint-config): eslint configurations.
- [packages/typescript-config](https://github.com/balancer/frontend-monorepo/tree/main/packages/typescript-config): Typescript config's used throughout the monorepo.

- [packages/eslint-config](https://github.com/balancer/frontend-monorepo/tree/main/packages/eslint-config):
eslint configurations.
- [packages/typescript-config](https://github.com/balancer/frontend-monorepo/tree/main/packages/typescript-config):
Typescript config's used throughout the monorepo.

## Getting started

To set up a local environment for development, first clone the repo and navigate
to it in your console:
To set up a local environment for development, first clone the repo and navigate to it in your
console:

```
git clone https://github.com/balancer/frontend-monorepo.git && cd frontend-monorepo
```

Then create a local environment variable file for the `frontend-v3` app.

```
cp apps/frontend-v3/.env.template apps/frontend-v3/.env.local
```

Install modules

```
pnpm install
```

Then spin up the dev environment with:

```
pnpm dev
```
Expand All @@ -57,35 +63,45 @@ pnpm build
### Testing

To test all apps and packages, run:

```
pnpm test:unit
// or
pnpm test:integration
```

### Install a package
If you want to install a new npm package in a sub application like `frontend-v3`
add the --filter option to your install command, e.g.:

If you want to install a new npm package in a sub application like `frontend-v3` add the --filter
option to your install command, e.g.:

```
pnpm add some-pkg --filter=frontend-v3
```

This filter should match the `name` attribute in the app or package package.json.

## Turborepo

### Remote Caching

Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.
Turborepo can use a technique known as
[Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache
artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines.

By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands:
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with
Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the
following commands:

```
npx turbo login
```

This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).
This will authenticate the Turborepo CLI with your
[Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview).

Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo:
Next, you can link your Turborepo to your Remote Cache by running the following command from the
root of your Turborepo:

```
npx turbo link
Expand Down
15 changes: 15 additions & 0 deletions apps/beets-frontend-v3/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
NEXT_PUBLIC_APP_ENV=dev
NEXT_PUBLIC_BALANCER_API_URL=https://api-v3.balancer.fi/graphql
NEXT_PUBLIC_WALLET_CONNECT_ID=1b6b722470b504a53cf011e1e629a9eb

# For wallet checks (optional)
PRIVATE_HYPERNATIVE_API_ID=xxx
PRIVATE_HYPERNATIVE_API_SECRET=xxx

# For fiat currency conversions (optional)
PRIVATE_CURRENCYAPI_KEY=xxx

# For integration tests and rpc proxy routes (optional)
NEXT_PRIVATE_ALCHEMY_KEY=xxx


2 changes: 2 additions & 0 deletions apps/beets-frontend-v3/.env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NEXT_PUBLIC_APP_ENV=test
NEXT_PUBLIC_BALANCER_API_URL=https://api-v3.balancer.fi/graphql
9 changes: 9 additions & 0 deletions apps/beets-frontend-v3/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: ['@repo/eslint-config/next.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
},
}
48 changes: 48 additions & 0 deletions apps/beets-frontend-v3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

.vscode
.idea

# Sentry Config File
.sentryclirc

# GrapgQL Codegen
/lib/shared/services/api/generated/

# Sentry Config File
.env.sentry-build-plugin
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm lint-staged --cwd apps/frontend-v3
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@repo/prettier-config"
1 change: 1 addition & 0 deletions apps/beets-frontend-v3/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.next/
43 changes: 43 additions & 0 deletions apps/beets-frontend-v3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Balancer frontend V3

## Getting Started

_This project uses `pnpm`, if you haven't already installed it you can find the documentation here:
https://pnpm.io/installation_

To setup the development environment, first clone the repo:

```bash
git clone https://github.com/balancer/frontend-v3.git && cd frontend-v3
```

Copy and rename the `.env.example` file to `.env.local`:

```bash
cp .env.example .env.local
```

Next, install dependencies:

```bash
pnpm install
```

Then, run the development server:

```bash
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## Testing

See [TESTING.md](./test/TESTING.md).

## Developing in Windows

To develop in Windows you need to use WSL2. Learn more about it
[here](https://learn.microsoft.com/en-us/windows/wsl/about).

With WSL2 all environment variables will be correctly set without having to use `cross-env`.
83 changes: 83 additions & 0 deletions apps/beets-frontend-v3/app/(app)/debug/alerts/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
'use client'

import { BalAlert } from '@repo/lib/shared/components/alerts/BalAlert'
import { BalAlertButton } from '@repo/lib/shared/components/alerts/BalAlertButton'
import { BalAlertContent } from '@repo/lib/shared/components/alerts/BalAlertContent'
import { useGlobalAlerts } from '@repo/lib/shared/components/alerts/GlobalAlertsProvider'
import { GenericError } from '@repo/lib/shared/components/errors/GenericError'
import { Button, VStack } from '@chakra-ui/react'

const exceptionName = 'Error fetching swap'
const exceptionMessage = `Execution reverted for an unknown reason. Raw Call Arguments:
to:0xE39B5e3B6D74016b2F6A9673D7d7493B6DF549d5
Docs: https://viem.sh/docs/contract/simulateContract Details: execution reverted Version:
viem@2.16.3`

class TestError extends Error {
constructor(name: string, message: string) {
super(message)
this.name = name
}
}

export default function Page() {
const { addAlert } = useGlobalAlerts()
return (
<VStack width="full">
<BalAlert content={<TitleWithButton title="Info alert" />} status="info" />
<BalAlert content={<TitleWithButton title="Warning alert" />} status="warning" />
<BalAlert content={<TitleWithButton title="Error alert" />} status="error" />
<BalAlert content={<TitleWithButton title="Success alert" />} status="success" />
<BalAlert
content="Warning alert with close button (soft warning)"
status="warning"
isSoftWarning
/>
<BalAlert
content="Error alert with learn more button link"
learnMoreLink="https://balancer.fi"
status="error"
/>
<BalAlert
content={
<BalAlertContent
title="Info alert"
description="With description in the next line (forceColumnMode)"
forceColumnMode
></BalAlertContent>
}
status="info"
/>

<GenericError
error={new TestError(exceptionName, exceptionMessage)}
maxWidth="500"
></GenericError>

<Button
onClick={() =>
addAlert({
id: 'debugAlert',
title: 'Global warning alert:',
description: 'with global description',
status: 'warning',
})
}
>
Show global warning alert
</Button>
</VStack>
)
}

function TitleWithButton({ title }: { title: string }) {
return (
<BalAlertContent
title={title}
description="Optional description"
tooltipLabel="Optional tooltip"
>
<BalAlertButton onClick={() => console.log('Clicked')}>Click me</BalAlertButton>
</BalAlertContent>
)
}
6 changes: 6 additions & 0 deletions apps/beets-frontend-v3/app/(app)/debug/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { DefaultPageContainer } from '@repo/lib/shared/components/containers/DefaultPageContainer'
import { PropsWithChildren } from 'react'

export default function DebugLayout({ children }: PropsWithChildren) {
return <DefaultPageContainer>{children}</DefaultPageContainer>
}
Loading
Loading