This project is the frontend of Swapy Exchange.
Currently there are 2 options to run the Swapy Electron Dapp in development mode:
- Run the web app locally connected to the testnet (Rinkeby or Ropsten).
- Run the web app locally connected to a local blockchain using Ganache.
Clone the repo:
git clone https://github.com/SwapyNetwork/swapy-exchange.git
Install the dependencies:
npm i
Create an env.json
file from the sample.env.json
that we provide:
cp sample.env.json env.json
Edit the env.json
to include your infura key for the HTTP_PROVIDER:
{
- "HTTP_PROVIDER": "infuraAddress",
+ "HTTP_PROVIDER": "https://rinkeby.infura.io/yourInfuraKey",
"TEST_RPC_PROVIDER": "http://localhost:8545",
"WS_PROVIDER": "infuraAddress",
"BLOCK_EXPLORER_URL": "https://rinkeby.etherscan.io/address/",
"ENV": "testnet",
"NETWORK_ID": "4",
"NETWORK_NAME": "rinkeby"
}
Notice that we're connecting to Rinkeby. To connect on Ropsten, use the NETWORK_ID = 3
and update the other variables.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Optionally, we provide a Dockerfile to run the app using the testnet. To buildit and run it, follow these steps:
Create your Dockerfile from our sample:
cp docker/sample.Dockerfile docker/Dockerfile
Edit the Docker file to include your infura provider in the env variables at line 9:
ENV SWAPY_PROTOCOL_REPOSITORY https://github.com/swapynetwork/swapy-exchange-protocol
ENV SWAPY_EXCHANGE_REPOSITORY https://github.com/swapynetwork/swapy-exchange
ENV SWAPY_EXCHANGE_VERSION master
ENV NETWORK_NAME rinkeby
ENV NETWORK_ID 4
+ ENV HTTP_PROVIDER "https://rinkeby.infura.io/yourkey"
ENV WS_PROVIDER ""
ENV TEST_RPC_PROVIDER "http://localhost:8545"
ENV DAPP_ENV test
ENV SWAPY_USER swapy
ENV SWAPY_PASSWORD 123456
ENV SWAPY_HOME /home/${SWAPY_USER}
Build the Docker container (it may take a while)
sudo docker build -t swapy-exchange docker/
Run the Docker container
sudo docker run -t swapy-exchange
Navigate to http://localhost:4200/
.
Clone and follow the instructions to install locally swapy-exchange-protocol and build the Smart Contracts.
Clone this repository under the same directory.
|- swapy-exchange
|- swapy-exchange-protocol
Copy the contracts:
cd swapy-exchange && npm run copy
Create an env.json
file from the sample.env.json
that we provide:
cp sample.env.json env.json
Edit the env.json
to include the correct variables:
{
"HTTP_PROVIDER": "",
"TEST_RPC_PROVIDER": "http://localhost:8545",
"WS_PROVIDER": "",
"BLOCK_EXPLORER_URL": "",
"ENV": "dev",
"NETWORK_ID": "",
"NETWORK_NAME": "ganache",
}
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
Before running the tests make sure you are serving the app via ng serve
.