Skip to content

Commit

Permalink
Merge pull request #50 from oxen-io/dev
Browse files Browse the repository at this point in the history
Staking Portal Release: Exit & Liquidation
  • Loading branch information
Aerilym authored Sep 18, 2024
2 parents 8f92e7d + 6248492 commit 930111a
Show file tree
Hide file tree
Showing 98 changed files with 3,597 additions and 1,412 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Builds
on:
- pull_request

jobs:
builds:
runs-on: ubuntu-latest

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

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version-file: '.tool-versions'

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Set environment variables
run: |
grep '^export ' ./apps/staking/scripts/mock-build-env.sh | sed 's/export //' >> $GITHUB_ENV
- name: Run builds
run: pnpm build
42 changes: 42 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Linting
on:
- push
- pull_request

jobs:
linting:
runs-on: ubuntu-latest

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

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version-file: '.tool-versions'

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run linter
run: pnpm lint
42 changes: 42 additions & 0 deletions .github/workflows/types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Type Checks
on:
- push
- pull_request

jobs:
type-checks:
runs-on: ubuntu-latest

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

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version-file: '.tool-versions'

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Run type checks
run: pnpm check-types
83 changes: 83 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Contributor Guidelines

## Advice for new contributors

Start small. The PRs most likely to be merged are the ones that make small, easily reviewed changes with clear and
specific intentions.

It's a good idea to gauge interest in your intended work by finding or creating
a [GitHub Issue](https://github.com/oxen-io/websites/issues) for it.

You're most likely to have your pull request accepted if it addresses an
existing [GitHub Issue](https://github.com/oxen-io/websites/issues) marked with
the [good-first-issue](https://github.com/oxen-io/websites/labels/good%20first%20issue)
tag.

Of course, we encourage community developers to work on ANY issue, regardless of how it’s tagged, however, if you pick
up or create an issue without the “Good first issue” tag it would be best if you leave a comment on the issue so that
the team can give you any guidance required, especially around UI heavy features.

## Developer Tips

See the development section of the [README.md](README.md#development) in the root of the repository. And please read the
`README.md` of any app or package you are interested in contributing to.

## Tests

Please write tests! Each app and package has a `README.md` file that explains how to write and run tests for that app or
package.

You can run all tests at once with the following command:

```shell
pnpm test
```

## GitHub Actions

You can mock all the GitHub actions by running the following command:

```shell
pnpm gh
```

This will run the linting, type checking, unit tests, and build scripts for all apps and packages.

## Committing your changes

Before a commit is accepted the staged changes will be formatted using [prettier](https://prettier.io/) and linted
using [eslint](https://eslint.org/).

### Commit Message Convention

This project follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)

Commit messages will be checked using [husky](https://typicode.github.io/husky/#/)
and [commitlint](https://commitlint.js.org/).

## Pull requests

So you want to make a pull request? Please observe the following guidelines.

- First, make sure that your `pnpm test` and `pnpm build` run passes - it's very similar to what our Continuous
Integration servers do to test the app.
- Be sure to add and run tests!
- [Rebase](https://nathanleclaire.com/blog/2014/09/14/dont-be-scared-of-git-rebase/) your changes on the latest `dev`
branch, resolving any conflicts. This ensures that your changes will merge cleanly when you open your PR.
- Make sure the diff between `dev` and your branch contains only the minimal set of changes needed to implement your
feature or bugfix. This will make it easier for the person reviewing your code to approve the changes. Please do not
submit a PR with commented out code or unfinished features.
- Avoid meaningless or too-granular commits. If your branch contains commits like the lines of "Oops, reverted this
change" or "Just experimenting, will delete this later",
please [squash or rebase those changes away](https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history).
- Don't have too few commits. If you have a complicated or long-lived feature branch, it may make sense to break the
changes up into logical atomic chunks to aid in the review process.
- Provide a well written and nicely formatted commit message.
See [this blog post](http://chris.beams.io/posts/git-commit/) for some tips on formatting. As far as content, try to
include in your summary
1. What you changed
2. Why this change was made (including git issue # if appropriate)
3. Any relevant technical details or motivations for your implementation choices that may be helpful to someone
reviewing or auditing the commit history in the future. When in doubt, err on the side of a longer commit
message. Above all, spend some time with the repository. Follow the pull request template added to your pull
request description automatically. Take a look at recent approved pull requests, see how they did things.
98 changes: 81 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,53 @@ Session Websites is a collection of websites and libraries for the Session Web e

## Apps and Packages

This repository is a monorepo that contains multiple apps and packages. Each app and package is located in its own directory.
This repository is a monorepo that contains multiple apps and packages. Each app and package is located in its own
directory.

- `apps` directory contains all the apps.
- `packages` directory contains all the packages.

An app is a standalone application that can be run independently. A package is a library that can be used by other apps or packages.
An app is a standalone application that can be run independently. A package is a library that can be used by other apps
or packages.

This repository contains the following apps and packages:

- `staking`: Session Staking [Next.js](https://nextjs.org/) app.
- `@session/ui`: Session UI component library.
- `@session/eslint-config`: `eslint` configurations.
- `@session/typescript-config`: `tsconfig.json` configurations.
- `@session/contracts`: Session smart contract js library for interacting with the Session smart contracts.
- `@session/sent-staking-js`: Session Token Staking js library for interacting with the Session Token staking backend.
- `@session/wallet`: A wallet library for interacting with the Session Token.
- `@session/util`: A utility library for common functions.
- `@session/testing`: A testing library.
### Apps

- `staking`: Session Staking [Next.js](https://nextjs.org/) app. [Read more](apps/staking/README.md).

### Packages

- `@session/auth`: Auth package for handling third-party authentication
using [NextAuth.js](https://next-auth.js.org/). [Read more](packages/auth/README.md).
- `@session/contracts`: Session smart contract js library for interacting with the Session smart
contracts. [Read more](packages/contracts/README.md).
- `@session/eslint-config`: `eslint`
configurations. [Read more](packages/eslint-config/README.md). [Read more](packages/eslint-config/README.md).
- `@session/feture-flags`: Feature flags library for [Next.js](https://nextjs.org/) apps. Supporting client, server, and
remote flags. [Read more](packages/feature-flags/README.md).
- `@session/logger`: An opinionated logging wrapper. [Read more](packages/logger/README.md).
- `@session/sent-staking-js`: Session Token Staking js library for interacting with the Session Token staking
backend. [Read more](packages/sent-staking-js/README.md).
- `@session/testing`: A testing utility library. [Read more](packages/testing/README.md).
- `@session/typescript-config`: `tsconfig.json` configurations. [Read more](packages/typescript-config/README.md).
- `@session/ui`: Session UI component library is a collection of UI components for [Next.js](https://nextjs.org/) apps
and uses
[Tailwind CSS](https://tailwindcss.com/), [Radix UI](https://www.radix-ui.com/),
and [shadcn-ui](https://ui.shadcn.com/). [Read more](packages/ui/README.md).
- `@session/util`: A utility library for common functions. [Read more](packages/util/README.md).
- `@session/wallet`: A wallet library for interacting with the Session Token. [Read more](packages/wallet/README.md).

### Utilities

- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
- [Tailwind CSS](https://tailwindcss.com/) for styling
- [TypeScript](https://www.typescriptlang.org/) for static type checking.
- [ESLint](https://eslint.org/) for code linting.
- [Prettier](https://prettier.io) for code formatting.
- [Tailwind CSS](https://tailwindcss.com/) for styling.
- [Next.js](https://nextjs.org/) for server-side rendering.
- [shadcn-ui](https://ui.shadcn.com/) for UI components.
- [Radix UI](https://www.radix-ui.com/) for UI components.
- [Jest](https://jestjs.io/) for unit testing.

### Build

Expand All @@ -44,7 +66,11 @@ pnpm build
- [pnpm](https://pnpm.io/) (v9 or higher)
- [jq](https://jqlang.github.io/jq/) (see [jq for mac](https://formulae.brew.sh/formula/jq))

We recommend using a node version manager like [asdf](https://asdf-vm.com/) to manage your node versions. The `.tool-versions` file in the root of the project specifies the node version to use. We also have an `.nvmrc` file that specifies the same node version to use. You can enable support for [Using Existing Tool Version Files](https://asdf-vm.com/guide/getting-started.html#using-existing-tool-version-files) in asdf to use these files.
We recommend using a node version manager like [asdf](https://asdf-vm.com/) to manage your node versions. The
`.tool-versions` file in the root of the project specifies the node version to use. We also have an `.nvmrc` file that
specifies the same node version to use. You can enable support
for [Using Existing Tool Version Files](https://asdf-vm.com/guide/getting-started.html#using-existing-tool-version-files)
in asdf to use these files.

## Getting Started

Expand All @@ -56,6 +82,44 @@ pnpm install

This will install all the dependencies for all the apps and packages.

## Contributing

We welcome contributions to the Session Web Ecosystem. Please read our [contributing guidelines](CONTRIBUTING.md) for
more information on how to contribute.

## Development

You can find a `README.md` file in each app and package directory that explains how to develop and test that specific app or package.
You can find a `README.md` file in each app and package directory that explains how to develop and test that specific
app or package.

### Developer Telemetry

Some tools used in this repo have anonymous developer telemetry enabled by default. This is developer telemetry that
tools creators use to report usage from developers and does not apply to any apps created using these
tools. We
have disabled all telemetry, you can ensure developer telemetry is disabled in all packages by running
`pnpm check-telemetry`. We have disabled telemetry by aliasing the `turbo` command in the repository root with
`NEXT_TELEMETRY_DISABLED=1 DO_NOT_TRACK=1`.

- `NEXT_TELEMETRY_DISABLED=1` disables developer telemetry in nextjs.
- `DO_NOT_TRACK` disables telemetry in all packages that respect
the [Console Do Not Track (DNT) standard](https://consoledonottrack.com/)

## Testing

Our testing suite is a work in progress and any contributions are welcome.

### Jest

We use [Jest](https://jestjs.io/) for unit testing. You can run the tests with the following command:

```sh
pnpm test
```

### BrowserStack

This project is tested with BrowserStack.

[BrowserStack](https://browserstack.com/) is used for cross-browser, accessibility, and regression testing.

53 changes: 53 additions & 0 deletions apps/staking/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Session Staking

Session Staking is a [Next.js](https://nextjs.org/) app for managing and staking
to [Session Nodes](https://github.com/oxen-io/oxen-core).

## Getting Started

You can follow the generic instructions in the root [README.md](../../README.md#getting-started) to get started.

## Development

Running the app requires several environment variables to be set. See the [.env.local.template](.env.local.template)
file for a list
of required variables.

We recommend running the [Session Token Staking Backend](https://github.com/oxen-io/sent-staking-backend/) and
a [Session Node](https://github.com/oxen-io/oxen-core) yourself to ensure any changes you make will work
with the latest changes.

### Session Node

You'll need a [Session Node](https://github.com/oxen-io/oxen-core) to make RPC calls to, this node
does not need to be staked to and does not need to join the network as a participating node. You'll need to run the
following to start the node:

```shell
oxend --stagenet --lmq-public tcp://127.0.0.1:<PORT> --l2-provider https://sepolia-rollup.arbitrum.io/rpc
```

You can then set the `NEXT_PUBLIC_SENT_EXPLORER_API_URL` environment variable in your `.env.local` file to point to
the Session Node's RPC endpoint (`tcp://127.0.0.1:<PORT>` in the example above).

**Note:** You can use any available port for the node RPC endpoint, just make sure it's consistent in all places.

### Session Token Staking Backend

Set up the [Session Token Staking Backend](https://github.com/oxen-io/sent-staking-backend/) by following the
instructions in the [README.md](https://github.com/oxen-io/sent-staking-backend/blob/main/README.md).

Make sure the `config.py` file in the backend directory has the following values:

```python
stagenet_rpc = 'tcp://127.0.0.1:<PORT>'
```

You can then run the backend with the following command:

```shell
uwsgi --http 127.0.0.1:5000 --master -p 4 -w sent --callable app --fs-reload sent.py
```

You can then set the `NEXT_PUBLIC_SENT_STAKING_BACKEND_URL` environment variable in your `.env.local` file to point to
the Session Token Staking Backend's RPC endpoint (`http://127.0.0.1:5000` in the example above).
Loading

0 comments on commit 930111a

Please sign in to comment.