iov-one / ponferrada

Neuma Extension and Neuma Wallet
https://www.neuma.io/
Apache License 2.0
4 stars 5 forks source link

Ponferrada

The most beautiful UI in Blockchain.

Build Status

Packages

The Ponferrada repo is split in 6 packages:

Tools

Ponferrada is based on React and Redux. Also uses the power of iov-core to handle the crypto and blockchain communication.

IOV-Core

iov-core provides core functionality to all clients in a cross-platform typescript library.

In ponferrada, we use the following generic packages from iov-core:

And we use the following specific packages to connect to each blockchain:

Key Terms (high level)

For more detail, check keybase documentation into iov-core folder.

Interact with the extension

In case you want to make an app that interacts with the Neuma extension, here are some directions to do so.

The chrome.runtime.sendMessage method

The communication between an app and the extension makes use of the sendMessage method from the chrome.runtime API:

function sendMessage(extensionId: string, message: any, responseCallback?: (response: any) => void): void;

Extension request types

Further directions

There are a lot of helpers that you can set up in order to facilitate the interaction with the extension. You can check the communications folder of the wallet for a complete setup.

Contributing

We are more than happy to accept open source contributions. However, please try to work on existing issues or create an issue and get feedback from one of the main contributors before starting on a PR. If you don't know where to start, we try to tag "good first issues" that provide a nice way to get started with the ponferrada repo.

Development Environment

To get started, please go to the root directory and run:

yarn install
yarn build

Then open your chrome browser and add the new generated extension (the build folder)

  1. open the following link chrome://extensions/
  2. Turn on Developer mode
  3. Click load unpacked and go to the ponferrada/build folder
  4. You have the iov-ponferrada extension in your browser!

With the extension fully working, you may want to enable hot reloading of the changes you make to the extension by running:

cd packages/sanes-browser-extension/
yarn start

Testing

We take seriously the testing environment, performing three different types of tests:

Storybook & Snapshot testing

Used for generating JEST Snapshot tests, and also for develoing components and fast prototype iteration when condig routes. From main folder, run following command:

yarn storybook

For updating snapshots after some changes in order to make everything to work read the snapshot documentation

Jest

Main test stack. It is used to run DOM tests using react test-utils functionalities. From main folder, run following command:

yarn test

yarn test will run jest tests of the entire system. However, a number of tests do end-to-end integration and require a demo blockchain running locally to be completed. By default these are skipped, unless you set the CHAINS_ENABLED=1 environmental variable to signal they should be run.

If you want to run these locally, make sure you are on a system that supports docker and that your local user has rights to connect to docker (I often use a Linux Virtualbox just for this). You must have docker and docker-compose installed.

In case you are running MAC_OS you should do:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

brew install jq
brew install coreutils

# Add TMPDIR=/private/var/tmp before any bash script
# TMPDIR=/private/var/tmp bash ./scripts/test_start.sh

In such a case, you can run the full chain test suite from inside sanes-browser-extension package folder:

# start all blockchains and a local faucets that serves multiple tokens
./scripts/test_start.sh
export CHAINS_ENABLED=1

# you can run this a few times....
(cd packages/sanes-browser-extension/ && yarn test)

# stop them afterwards
unset CHAINS_ENABLED
./scripts/test_stop.sh

Puppeteer

Framework used for running e2e tests. It launches chrome instances with the extension installed and executes logic simulating human interaction. From main folder, run following command:

yarn test

For installing automatically the extension on each chrome's instance we have had to generate a fixed extension's id. For more details click here.

Internals

The extension package has been created using create-react-app extension, but we have had to modify some parts in order to allow Webpack's HMR while developing, and chrome extension's part integration. For more details read this.

License

This repository is licensed under the Apache License 2.0 (see NOTICE and LICENSE).