Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

readme and contributing edited. added badges #130

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 7 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ DSNP is a fast-moving environment. When creating bug reports, feature
requests, or pull requests, it's important to be familiar and
up-to-date with:

* [DSNP Specs](https://github.com/LibertyDSNP/spec) for how the DSNP works
* [DSNP Specs](https://github.com/LibertyDSNP/spec) for how the DSNP works.

* [DSNP SDK](https://github.com/LibertyDSNP/sdk-ts) for integration with the DSNP
* [DSNP SDK](https://github.com/LibertyDSNP/sdk-ts) for integration with the DSNP.

## Reporting

Expand All @@ -30,14 +30,6 @@ issue](https://github.com/LibertyDSNP/example-client/issues) about it,
of course). Make sure to **tag the new issue as a bug**, and follow
the `Bug Report` template.

A "bug" is any one of the following things:

* Broken or non-functional code
* Unexpected or clearly unintentional results
* Security vulnerabilities
* Out-of-date code/dependencies/documentation
* Inconsistencies in the documentation or the code

### Features

To suggest an enhancement or new feature, please [create a new issue
Expand All @@ -47,13 +39,6 @@ thing](https://github.com/LibertyDSNP/example-client/issues)). Make
sure to **tag it as a feature request**, and follow the `Feature
Request` template.

A "feature request" is any one of the following things:

* New functionality for the Example Client
* Expanded use of existing functionality
* A suggestion to use more up-to-date tools/resources
* An expansion of or addition to the documentation

## Contributing

### Conventions
Expand All @@ -69,13 +54,13 @@ automatically, but if yours doesn't, you can run them manually with

The main conventions you need to know about are:

* All code written in Typescript with as much type specificity as possible.
* All code is written in Typescript with as much type specificity as possible.

* Styling for visual components. [Check the Style Guide](https://github.com/LibertyDSNP/example-client/blob/main/STYLING.md)
* Styling for visual components. [Check the Style Guide](https://github.com/LibertyDSNP/example-client/blob/main/STYLING.md).

* Use of the [BEM](https://en.bem.info/methodology/quick-start/) methodology for CSS classes
* Use of the [BEM](https://en.bem.info/methodology/quick-start/) methodology for CSS classes.

* Use of [React Hooks](https://reactjs.org/docs/hooks-intro.html) in components
* Use of [React Hooks](https://reactjs.org/docs/hooks-intro.html) in components.

* Testing of all added components using [Jest](https://jestjs.io) and [Enzyme](https://enzymejs.github.io/enzyme/).

Expand All @@ -93,7 +78,7 @@ Run tests locally with 'npm run test'.
All PRs must follow the `Pull Request` template. To be approved and
merged, a PR must meet these requirements:

1. The test must pass CI/CD done through Github Actions
1. The test must pass CI/CD done through Github Actions.
2. The changes must be rebased on the `main` branch before merging.

## Help
Expand Down
68 changes: 49 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# DSNP Example Client

[![Latest release](https://img.shields.io/github/release/LibertyDSNP/example-client)](https://github.com/LibertyDSNP/example-client/releases)

[![example workflow](https://github.com/LibertyDSNP/example-client/actions/workflows/main.yml/badge.svg)](https://github.com/LibertyDSNP/example-client/actions)

This is an example client to help developers learn how to work with the [Distributed Social Networking Protocol(DSNP)](https://spec.dsnp.org/) and its [SDK](https://www.dsnp.org/sdk).
This client's purpose is to be simple and comprehensible for developers, not to have all the functionality and user-interface polish of an application intended for widespread general usage.

Expand Down Expand Up @@ -70,31 +74,57 @@ We will change to an official version of Enzyme when a compatible released versi

The following steps should get you up and running quickly (assuming a working knowledge of NPM and Git):

* Clone the example-client repository: `git clone git@github.com:LibertyDSNP/example-client.git`
* Clone the example-client repository: `git clone git@github.com:LibertyDSNP/example-client.git`.

* Install the correct npm and node version. We recommend using asdf: `asdf install`
* Install the correct npm and node version, which can be found in the `.tool-versions` file. The maintainers use `asdf` for managing node and npm versions.

* Install the modules: `npm install`
* Install Static Server modules `cd ./static-server && npm install`
* Install the modules: `npm install`.
* Install Static Server modules `cd ./static-server && npm install`.

* Copy `.env.example` to `.env` and edit as needed.

* Start the Static Server: `cd ./static-server && npm run start`
* Switch to a separate terminal and start the Static Server: `cd ./static-server && npm run start`.

* Start up site locally: `npm run start`.

* Start up site locally: `npm run start`
* Visit http://localhost:3000 (or whatever your configured port is).

* Visit http://localhost:3000 (or whatever your configured port is)
* Follow Example Client's MetaMask Setup Instructions shown at the above URL.

You can run the test suite with 'npm run test'.

### Local deployment

**Use local deployment for development of the Example Client and testing the code.**

For local deployment, you will be running the Example Client, Static Server, and Contracts.

To launch it, follow the instructions below:

* Clone the Contracts repository: `git clone git@github.com:LibertyDSNP/contracts.git`.
* Follow contracts/README.md to Deploy Hardhat Network Locally.
* Follow the Example Client Deployment instructions above.
* Connect to the `http://localhost:8545` RPC URL through MetaMask.


### Docker-based deployment

The Docker container is set up in such a way that the Static Server will serve the Example Client. To launch it, run the following commands:
**Use Docker-based deployment for development of the Example Client and testing the code.**

To launch it, run the following commands:

* `docker build --build-arg REACT_APP_UPLOAD_HOST="" --build-arg REACT_APP_CHAIN_ID={REACT_APP_CHAIN_ID_VALUE} --build-arg REACT_APP_CHAIN_NAME={REACT_APP_CHAIN_NAME_VALUE} --build-arg REACT_APP_CHAIN_HOST={REACT_APP_CHAIN_HOST} --build-arg REACT_APP_TORUS_BUILD_ENV={REACT_APP_TORUS_BUILD_ENV_VALUE} . -t example-client`

* `docker run --init --rm -p 8080:8080 -v {name_for_volume}:/app/static-server/public example-client`

#### Environment Variable Definitions

* `REACT_APP_CHAIN_ID_VALUE` : 31337 or 0x7a69
* `REACT_APP_CHAIN_NAME_VALUE` : (user's choice)
* `REACT_APP_CHAIN_HOST` : http://localhost:8545
* `REACT_APP_TORUS_BUILD_ENV_VALUE` : ???
* `name_for_volume` : ??

#### Docker Builds

A new Docker image will be pushed from our [GitHub repository](https://github.com/LibertyDSNP/example-client) to our [Docker hub](https://hub.docker.com/r/dsnp/example-client) when a new Git tag is created. Tags have the format `docker/*`, e.g.,`docker/v1.0.0`.
Expand All @@ -111,20 +141,20 @@ In Metamask, click on the **Account** icon from the extension.
Then go to **Settings --> Advanced**, scroll down a little and click **Reset Account**. Do this for each connected account.

* **Still seeing old events after resetting chain** - If you're running static-server, it needs to be stopped.
Then delete all the batch files it stored with `rm static-server/public/0x*`
Then delete all the batch files it stored with `rm static-server/public/0x*`.

* **How do I restart example-app with an empty chain and no events?** - For best results, in this order, do the following:
1. Logout of the app from your browser.
1. Kill the example-app with ^C (If you haven't changed the code and just want to delete and recreate all posts, you can skip this step.)
1. Kill static-server same way
1. Delete static-server batch files with `rm static-server/public/0x*`
1. Go to the contracts repo and kill hardhat node (^C)
1. Restart hardhat node: `npx hardhat node`
1. Redeploy the contracts: `npm run deploy:localhost`
1. Reset your test accounts in Metamask
1. Restart example-app/static server: `npm run start` from within static-server
1. Optionally, rerun populate script from example-app, if you want to quickly populate some accounts and events: `node script/populate`
1. If you stopped the example-app, restart it: `npm run start`
1. Kill the example-app with ^C (If you haven't changed the code and just want to delete and recreate all posts, you can skip this step.).
1. Kill the static-server same way.
1. Delete the static-server batch files with `rm static-server/public/0x*`.
1. Go to the contracts repo and kill the hardhat node (^C).
1. Restart the hardhat node: `npx hardhat node`.
1. Redeploy the contracts: `npm run deploy:localhost`.
1. Reset your test accounts in Metamask.
1. Restart example-app/static server: `npm run start` from within static-server.
1. Optionally, rerun populate script from example-app, if you want to quickly populate some accounts and events: `node script/populate`.
1. If you stopped the example-app, restart it: `npm run start`.

You should now be able to login to the app, and view and create posts.

Expand Down