当前位置: 首页 > 软件库 > Web3 > 区块链 >

ethlance

授权协议 GPL-3.0 License
开发语言
所属分类 Web3、 区块链
软件类型 开源软件
地区 不详
投 递 者 公孙英飙
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Ethlance V.2 (Newlance)

Ethlance Version 2 is Currently in Development and is subject tochange before final release

Development

Here's a high level overview of the components involved in ethlance.

Prerequisites

The following tools are needed to run different parts making up the Ethlanceservice. Programming language tools (e.g. nodejs, python, etc.) may requirespecific versions. To simplify maintaining their versions,asdf version manager is a good tool Ethlanceproject also has .tool-versions described with appropriate versions

Run make check to determine whether you are missing any prerequisites

Setup Backend

Backend development requires:

  1. Postgres database server (provided by docker image)
  2. IPFS server running
  3. Ganache test net running
  • Contracts deployed to testnet
  1. CSS files to be watched & compiled
  2. Node.js server with Shadow CLJS for back-end running
  3. Node.js server with Shadow CLJS for front-end running
  4. Node.js server for GraphQL running

This is quite a few steps to run every time you start developing.To simplify that, a Procfile consuming tool like Foreman(has implementations in various languages) or Invoker can be used.

Then it's easy as

❯ foreman start
08:37:22 postgres.1         | started with pid 205427
08:37:22 ipfs.1             | started with pid 205428
08:37:22 testnet.1          | started with pid 205429
08:37:22 deploy_contracts.1 | started with pid 205433
08:37:22 css.1              | started with pid 205434
08:37:22 ui.1               | started with pid 205436
08:37:22 server.1           | started with pid 205439
08:37:22 graphql.1          | started with pid 205442
08:37:22 postgres.1         | docker run                                                       \
08:37:22 ipfs.1             | ipfs daemon
08:37:22 testnet.1          | npx ganache-cli -m district0x --host 0.0.0.0 --port 8549  -l 8000000
08:37:22 css.1              | ./ui/node_modules/less/bin/lessc resources/public/less/main.less resources/public/css/main.css
08:37:22 postgres.1
<...>

Initial Setup

Note: All instructions start in the root of the project directory

If this is a first time setup, or you accidentally ran make clean-all, you are required to re-install additional nodedependencies with:

Tested with GCC 6 & GCC 7, does not appear to work with GCC 8

make deps

If you're having issues with your environment, you can run this command:

make clean-all deps

First steps, showing example data

In order for the front-end to be able to have the JWT token (kept in LocalStorage), you must sign a transaction. Currently it can be done manually. Open REPL for UI:

lein repl :connect 54872
(shadow/repl :dev-ui)
(in-ns 'ethlance.ui.event.sign-in)
(re/dispatch [:user/sign-in])
  • this will show a pop up and using MetaMask you can create a transaction
  • after doing this successfully the UI graphql requests will have proper Authorization: Bearer ... header

Then to generate some example data you can use server REPL:

lein repl :connect 54872
(shadow/repl :dev-server)
(in-ns 'tests.graphql.generator)
(generate-for-address "0xafcf1a2bc71acf041c93012a2e552e31026dfeab")
  • for that the test namespace must be included in the server build (e.g. by adding [tests.graphql.generator :as test-data-generator] to ethlance.server.core)
  • alternatively you can submit the data manually through the forms

Additional Troubleshooting

  • Make sure you are using NodeJS LTS Version. (Latest LTS Version isv10.16.3 as of this posting)

  • GCC 8+ do not work with some of the district libraries. This mightchange in the future. Please use GCC Version 6, or GCC Version 7.

Testnet Server

Our local development environment requires a testnet in order to runsmart contracts. Ethlance Development uses ganache-cli with a defaultconfiguration.

$ make testnet # Run in a separate terminal

IPFS Server

IPFS is an essential technology in ensuring that large blobs of datacan be stored in a decentralized manner. After installing the ipfscommandline tool, you need to start up a daemon for development

ipfs daemon

Note: Might require additional configuration for CORS

ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
ipfs config --json Gateway.HTTPHeaders.Access-Control-Allow-Headers '["X-Requested-With"]'
ipfs config --json Gateway.Writable true

Deployment

Ethlance product can be prepared for deployment by running:

$ make build

This compiles everything and places it in the ./dist folder

After building, the production build can be run:

$ make run

Testing One-touch

To run all of the tests in a standalone test runner, you must firstbuild the solidity contracts, run an instance of the testnet server,and an instance of the IPFS daemon. The test runner can be run via:

  1. Watch test build (compiles test CLJS files)
  • ./bin/repl-run "(shadow/watch :server-tests) @(promise)"
  1. Run tests:
  • node server/tests/server-tests.js

Contributing

Anyone is welcome to contribute to the ethlance project, here are some brief guidelines:

  • Make sure to squash your commits
  • Reference issue numbers in your pull request
  • Rebase your changes on upstream (git remote add upstream https://github.com/madvas/ethlance.git) master before pushing (git pull --rebase upstream master)
  • Make changes in a separate well-named branch in your forked repolike improve-readme

相关阅读

相关文章

相关问答

相关文档