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

Docs: .md files #72

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
docs: readme files
  • Loading branch information
5A11 committed Sep 30, 2021
commit ca8f68406c3f837238dc836bfc8afda49411cf1c
10 changes: 10 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Authors

This is the official list of Fetch.ai authors for copyright purposes.

* Ali Hosseini <[email protected]> [5A11](https://github.com/5A11)
* Peter Bukva <[email protected]> [pbukva](https://github.com/pbukva)
* Jiří Vestfál <[email protected]> [MissingNO57](https://github.com/MissingNO57)
* Ed Fitzgerald <[email protected]> [ejfitzgerald](https://github.com/ejfitzgerald)
* Oleg Panasevych <[email protected]> [Panasevychol](https://github.com/panasevychol)

76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behaviour that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behaviour by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behaviour and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behaviour.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviours that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behaviour may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Contributing

Contributions to this library are welcome.

- If you want to report a bug or ask for features, you can check the [Issues page](https://github.com/fetchai/agents-aea/issues) and raise an issue.

- If you would like to contribute a bug fix or feature then [submit a Pull request](https://github.com/fetchai/agents-aea/pulls).
5A11 marked this conversation as resolved.
Show resolved Hide resolved

For other kinds of feedback, you can contact one of the
[authors](https://github.com/fetchai/agents-aea/blob/main/AUTHORS.md) by email.

Before reading on, please have a look at the [code of conduct](https://github.com/fetchai/agents-aea/blob/main/CODE_OF_CONDUCT.md).

## A few simple rules

- All Pull Requests should be opened against the `develop` branch. Do **not** open a Pull Request against `main`!

- Before working on a feature, reach out to one of the core developers or discuss the feature in an issue. The framework caters a diverse audience and new features require upfront coordination.

- Include unit tests for 100% coverage when you contribute new features, as they help to a) prove that your code works correctly, and b) guard against future breaking changes to lower the maintenance cost.

- Bug fixes also generally require unit tests, because the presence of bugs usually indicates insufficient test coverage.

- Keep API compatibility in mind when you change code in `cosmpy`. Above version `1.0.0`, breaking changes can happen across versions with different left digit. Below version `1.0.0`, they can happen across versions with different middle digit. Reviewers of your pull request will comment on any API compatibility issues.

- When you contribute a new feature to `cosmpy`, the maintenance burden is transferred to the core team. This means that the benefit of the contribution must be compared against the cost of maintaining the feature.

- Where possible, extend existing features instead of replacing one.

- All files must include a license header.

- Before committing and opening a PR, run all tests locally. This saves CI hours and ensures you only commit clean code.

## Contributing code

If you have improvements, send us your pull requests!

A team member will be assigned to review your pull requests. All tests are run as part of CI as well as various other checks (linters, static type checkers, security checkers, etc). If there are any problems, feedback is provided via GitHub. Once the pull requests is approved and passes continuous integration checks, you or a team member can merge it.

If you want to contribute, start working through the codebase, navigate to the Github [Issues page](https://github.com/fetchai/agents-aea/issues) tab and start looking through interesting issues. If you decide to start on an issue, leave a comment so that other people know that you're working on it. If you want to help out, but not alone, use the issue comment thread to coordinate.
5A11 marked this conversation as resolved.
Show resolved Hide resolved
180 changes: 115 additions & 65 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,90 @@
## Generate python types from Cosmos-SDK protobuf schemas
## Development setup

### Fetch Cosmos-SDK protobuf schema files
>NOTE: When updating to a different version of the Cosmos SDK (see the version currently used under `COSMOS_SDK_VERSION` in [Makefile](#Makefile])), you will need to perform this step once to fetch the relevant protobuf schema files:
The easiest way to get set up for development is to install Python `>=3.7` and `pipenv`, then run the following:
5A11 marked this conversation as resolved.
Show resolved Hide resolved

```bash
make fetch_proto_schema_source
make new_env_dev
pipenv shell
```

>NOTE: For this library to be functional, only the python types generated from protobuf schemas are required, not the schema files themselves.
## Development commands

There are various makefile commands which are helpful during development. Some of the more prominent ones are listed below:

- For linting:
```bash
make lint
```
- For static analysis:
```bash
make mypy
make pylint
```
- For code security analysis:
```bash
make security
```

- To run tests:
```bash
make test
```

## Generating python types from Cosmos SDK protobuf schemas

This library uses python types which are generated (using [Google's Protocol Buffers](https://developers.google.com/protocol-buffers/) compiler) from protocol buffer schemas in the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk).

5A11 marked this conversation as resolved.
Show resolved Hide resolved
When updating the Cosmos SDK version supported by this library (see the version currently used under `COSMOS_SDK_VERSION` in [Makefile](#Makefile])), you will need to fetch its corresponding protobuf schemas and generate their associated python types, replacing the existing ones.

>Note: This process has to be done only once when the Cosmos SDK version supported by this library is changed.

>Note: To generate python types from Cosmos SDK protobuf schemas, you will need [Google Protocol Buffers](https://developers.google.com/protocol-buffers/) compiler. A guide on how to install it can be found [here](https://fetchai.github.io/oef-sdk-python/user/install.html#protobuf-compiler).

Below are the steps you need to take in order to achieve this:

* Fetch the Cosmos SDK protobuf schema files:
```bash
make fetch_proto_schema_source
```

* Generate python types:
```bash
make generate_proto_types
```

>Note: For this library to be functional, only the python types generated from protobuf schemas are required, not the schema files themselves.
> The schema files are fetched on-demand only to enable the generation of python types.
> Therefore, the schema files are intentionally stored as **local** files and are **NOT** checked in to this repository to minimise its filesystem footprint.

### Generate python types
```bash
make generate_proto_types
```

## Setup a local Stargate node
## MakeFile Commands

The Makefile in this repo provides various useful commands that ease development. We will describe some of them here:

* `make lint`:
* applies `black`: code formatter
* applies `isort`: sorts imports
* runs `flake8`: linter
* runs `vulture`: detects unused code
* `make security`:
* runs `bandit`: finds common security issues in Python code
* runs `safety`: checks installed dependencies for known security vulnerabilities
* `make mypy`: runs `mypy`, a static type checker for python
* `make pylint`: runs `pylint`, a static type checker and linter for python
* tests:
* `make test`: runs all tests
* `make unit-test`: runs unit tests
* `make integration-test`: runs integration tests
* `make coverage-report`: produces the coverage report (you should run tests using one of the above commands first)
* `make clean`: removes temporary files and caches.
* `make new_env`: creates a new environment (cleans and installs in _normal_ mode)
* `make new_env_dev`: creates a new development environment (cleans and installs in _development_ mode)
* `make liccheck`: checks dependencies and reports any license issues
* `make copyright-check`: checks that files have the correct copyright headers
* documentation:
* `make generate-docs`: generates documentation from the source code
* `make open-docs`: opens `index.html` page of the documentation (if on Linux or MacOS).

## To setup a local Stargate node

### Preliminaries

Expand All @@ -35,68 +103,50 @@ You require Go version 15.0 or higher for your platform (see <a href="https://go
fetchd start
```

## Examples
## To run a local Stargate node in docker

### Preliminaries

- Install the package from source:
```bash
pipenv install
```
You require [Docker](https://docs.docker.com/get-docker/) for your platform.

- or in development mode:
```bash
pipenv install --dev
```
### Run the docker image

* Place the following entrypoint script somewhere in your system (e.g `~/fetchd_docker/fetchd_initialise.sh`):

- Launch a virtual environment
```bash
pipenv shell
#!/usr/bin/env bash

# variables
export VALIDATOR_KEY_NAME=validator
export BOB_KEY_NAME=bob
export VALIDATOR_MNEMONIC="erase weekend bid boss knee vintage goat syrup use tumble device album fortune water sweet maple kind degree toss owner crane half useless sleep"
export BOB_MNEMONIC="account snack twist chef razor sing gain birth check identify unable vendor model utility fragile stadium turtle sun sail enemy violin either keep fiction"
export PASSWORD="12345678"
export CHAIN_ID=testing
export DENOM_1=stake
export DENOM_2=atestfet

# Add keys
( echo "$VALIDATOR_MNEMONIC"; echo "$PASSWORD"; echo "$PASSWORD"; ) |fetchd keys add $VALIDATOR_KEY_NAME --recover
( echo "$BOB_MNEMONIC"; echo "$PASSWORD"; ) |fetchd keys add $BOB_KEY_NAME --recover

# Configure node
fetchd init --chain-id=$CHAIN_ID $CHAIN_ID
echo "$PASSWORD" |fetchd add-genesis-account $(fetchd keys show $VALIDATOR_KEY_NAME -a) 100000000000000000000000$DENOM_1
echo "$PASSWORD" |fetchd add-genesis-account $(fetchd keys show $BOB_KEY_NAME -a) 100000000000000000000000$DENOM_2
echo "$PASSWORD" |fetchd gentx $VALIDATOR_KEY_NAME 10000000000000000000000$DENOM_1 --chain-id $CHAIN_ID
fetchd collect-gentxs

# Enable rest-api
sed -i '/^\[api\]$/,/^\[/ s/^enable = false/enable = true/' ~/.fetchd/config/app.toml
sed -i '/^\[api\]$/,/^\[/ s/^swagger = false/swagger = true/' ~/.fetchd/config/app.toml

fetchd start
```

### Run Examples

- Query balance example using REST api
* Execute:
```bash
python src/examples/query_balance_rest_example.py
docker run -it --rm --entrypoint /scripts/<ENTRYPOINT_SCRIPT_NAME> -p 9090:9090 -p 1317:1317 -v <PATH_TO_ENTRYPOINT_SCRIPT>:/scripts/ fetchai/fetchd:0.8.4
```

- Send funds transaction example
- Using gRPC
```bash
python src/examples/tx_send_grpc_example.py
```
- Using REST api
```bash
python src/examples/tx_send_rest_example.py
```

- Contract deployment and interaction example
- Using gRPC
```bash
python src/examples/contract_interaction_grpc_example.py
```
- Using REST api
```bash
python src/examples/contract_interaction_rest_example.py
```

- Native tokens atomic swap example
- Using gRPC
```bash
python src/examples/tx_native_tokens_atomic_swap_grpc_example.py
```
- Using REST api
```bash
python src/examples/tx_native_tokens_atomic_swap_rest_example.py
```

- Atomic swap using ERC1155 contract example
- Using gRPC
```bash
python src/examples/atomic_swap_contract_grpc_example.py
```
- Using REST api
```bash
python src/examples/atomic_swap_contract_rest_example.py
```
where `<ENTRYPOINT_SCRIPT_NAME>` is the name of the entrypoint script (e.g.`fetchd_initialise.sh`) and `<PATH_TO_ENTRYPOINT_SCRIPT>` is the path to the directory you placed the script (e.g.`~/fetchd_docker/`).
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ lint:
flake8 $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py
vulture $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) $(PYCOSM_EXAMPLES_DIR) setup.py --exclude '*_pb2.py,*_pb2_grpc.py'

.PHONY: security
security:
bandit -r $(PYCOSM_SRC_DIR) $(PYCOSM_TESTS_DIR) --skip B101
bandit -r $(PYCOSM_EXAMPLES_DIR) --skip B101,B105
safety check -i 41002


.PHONY: check
check:
make black-check
Expand Down
Loading