npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@warren-bank/dapp-frontend

v1.1.0

Published

command-line tool to initialize a Dapp frontend with a complete development toolchain

Downloads

48

Readme

dapp-frontend

Description:

Command-line tool to initialize a Dapp frontend with a complete development toolchain.

Eventually, several toolchains will be available from which to select. Currently, the following are implemented:

  • react
    • React + Sass + Webpack
    • file watchers that trigger Webpack to rebundle .js and .css
    • http server (localhost:3000)
  • ng2
    • Angular 2 + Sass + Webpack
    • file watchers that trigger Webpack to rebundle .js and .css
    • http server (localhost:3000)

Within each toolchain, the example Dapp is a rewrite of the MetaCoin Dapp that's used as an example (boilerplate) by Truffle.

Installation:

npm install -g @warren-bank/dapp-frontend
npm install -g @warren-bank/dapp-deploy

# needed to initialize the `react` toolchain
npm install -g create-react-app
npm install -g node-sass

# no additional global dependencies are needed to initialize the `ng2` toolchain

Example:

# start: Ethereum JSON-RPC server
mnemonic='foo bar baz'
lxterminal -e testrpc -m "$mnemonic"

# create a new/empty frontend project directory
mkdir ~/react_frontend_dapp
cd ~/react_frontend_dapp

# initialize a new frontend (boilerplate) project having a `react` toolchain
dapp frontend react

# notes:
#   - in the example projects, compiled contracts are located within the frontend dapp workspace.
#   - in a more realistic workflow, compiled contracts would be located in `@dapphub/dapp` project workspace (./out) separate from the frontend
#   - contract deployment requires: *.abi, *.bin
#   - frontend (web3.js) requires: *.abi.json, *.deployed.json

backend_contracts_dir='./src/contracts/dapp-backend'
compiled_contracts_dir="${backend_contracts_dir}/out"

frontend_contracts_dir='./src/contracts'

# optional:
# recompile all Solidity contracts
rm ${compiled_contracts_dir}/*
(cd $backend_contracts_dir; dapp build)

# optional, required if Solidity contracts were recompiled:
# delete all frontend ABI data and save a fresh copy: *.abi.json
rm ${frontend_contracts_dir}/*.abi.json
cp ${compiled_contracts_dir}/*.abi ${frontend_contracts_dir}/
rename 's/\.abi$/.abi.json/' ${frontend_contracts_dir}/*.abi

# optional:
# delete metadata for all previous contract deployments
rm ${frontend_contracts_dir}/*.deployed.json
# optional, required if a new instance of `testrpc` was started:
# deploy contracts and save metadata: *.deployed.json
dapp deploy -i $compiled_contracts_dir -O $frontend_contracts_dir'/{{contract}}.deployed.json'

# start: http server and file watcher (.js, .css)
lxterminal -e npm start

# start: file watcher (.scss)
# notes:
#   - at launch, it will recompile (.scss => .css)
#   - the new .css bundle will trigger webpack to rebundle the .js
#   - this new .js bundle will contain the updated contract deployment addresses
#   - the browser will display 10000 "MetaCoin" tokens as available balance (in account index #0)
lxterminal -e npm run watch-css

# open Dapp in Chromium browser w/ "MetaMask" extension
# in "MetaMask":
#   - Localhost 8545
#   - Settings > Reveal Seed Words
#         produces the $mnemonic used to initialize `testrpc`
# this ensures that both Ethereum clients are sharing the same accounts (on the same blockchain)
xdg-open 'http://localhost:3000/'

Notes (regarding the previous Example):

  • the example was intended to illustrate the general procedure to initialize a new project using the "React" toolchain
  • the procedure to initialize the "Angular 2" toolchain is nearly identical.
    • in this case, however, the file watcher for SASS (.scss) stylesheets is started along with the other watchers (.js, .css) when npm start is run
    • no separate command (ex: npm run watch-css) is needed to do so

Usage:

$ dapp-frontend --help

dapp-frontend command <directory_path>

Commands:
  react                                              initialize toolchain: 'React'
  ng2                                                initialize toolchain: 'Angular 2'

Options:
  --help                                             Show help [boolean]

Examples:
  dapp-frontend react ~/react_frontend_dapp          toolchain: 'React'
                                                     directory path: '~/react_frontend_dapp'
  dapp-frontend react                                toolchain: 'React'
                                                     directory path: '.'

copyright: Warren Bank <github.com/warren-bank>
license: GPLv2

Notes:

  • This tool is intended to complement the dapphub/dapp toolchain, but it has no dependency on dapp.
  • It uses vanilla web3.js to communicate with an Ethereum JSON-RPC server.
  • It uses ABI data (.abi.json) to generate contract objects in javascript. This data is produced by the Solidity compiler (solc).
  • It uses the addresses of deployed contracts (.deployed.json) to associate contract objects with the usable instances that exist in the blockchain. This data is produced by dapp-deploy.

Dependencies:

  • As indicated in the Install instructions, some toolchains may require additional global dependencies
  • note: this may change..

Executables:

  • When dapp is installed, this tool can be invoked by the command: dapp frontend command <directory_path>
  • When used standalone, it can be invoked by the command: dapp-frontend command <directory_path>
  • Additionally, each toolchain can be invoked directly:
    • "React":create-react-dapp <directory_path>
    • "Angular 2":create-ng2-dapp <directory_path>

Legal: