Vue, JavaScript, blockchain, Web3

Overview

Web DEXTF Ðapp

Project structure

dapp-web
  + docs
  + jsdoc
  + node_modules
  + public
  + src
  ...

Project setup

yarn install

See the Troubleshooting in case of errors.

Compiles and hot-reloads for development & starts backend server

yarn run start

Compiles and minifies for production

To compile:

yarn run build

For the minification:

Due to a bug in the SetProtocol modules we cannot minify everything (or the Kyber operationds fail). For this reason we minify "manually" all chunks except the vendors chunk.

Run this to create the minification statements:

cd ./dist/js
for file in *.js; do printf '%s\n' "'minify': 'minify ./dist/js/$file > ./dist/js/minified/$file',"; done

Add the statements to the scripts section of the package.json (except the chunk-vendors*.js file):

"scripts": {
  "minify1": "minify ./dist/js/app.300d8bdc.js > ./dist/js/minified/app.300d8bdc.js",
  "minify2": "minify ./dist/js/chunk-27f3efef.2ba9367f.js > ./dist/js/minified/chunk-27f3efef.2ba9367f.js",
  ...
}

Next do the minifications:

yarn minify1
yarn minify2
...

Finally copy the minified files and get rid of the minified folder.

See the Troubleshooting in case of errors.

Run your tests

yarn run test

Lints and fixes files

yarn run lint

VueJS configuration

See Configuration Reference.

API documentation

We use JSDoc 3 to generate the API documentation.

To install globally:

yarn global add jsdoc

JSDoc comments should generally be placed immediately before the code being documented. Each comment must start with a /** sequence in order to be recognized by the JSDoc parser. Comments beginning with /*, /***, or more than 3 stars will be ignored. This is a feature to allow you to suppress parsing of comment blocks.

Special JSDoc tags can be used to give more information.

Example:

/**
  * Set the focus on an element after a given delay.
  * Note: if the element is disabled the focus is not set.
  * @param {string} elementName element to focus
  * @param {*} [ms=200] delay in milliseconds
  * @example:
  * setFocus('btnInvest', 100)
  */
  setFocus(elementName, ms = 200) {
  ...

We use better-docs as "documentation toolbox" (template), and it needs to be added to the jsdoc.json files:

"opts": {
  "template": "node_modules/better-docs"
}

Documentation website generation

yarn run generate-docs

The website will be generated in the docs folder.

Troubleshooting

node-gyp on new macOS versions

The latest version of the Command Line Tools for Xcode is required.

Check the version of the Command Line Tools as follows:

pkgutil --pkg-info=com.apple.pkg.CLTools_Executables

If necessary, install the latest version of Xcode and the Command Line Tools (Xcode > Open Developer Tool > More Developer Tools).

If this does not work refer to these installations notes. In particular conduct the acid test and then look for the Solutions chapter.

Start/Serve errors

If the port 8080 is already in use:

sudo lsof -i :8080
kill -9 <PID>

Install errors

ethereum/web3.js issue #2913

setprotocol.ls uses web3.js-1.0.0-beta.36 which uses web3-eth-accounts which uses scrypt.js that is a wrapper around scrypt (native code) with a fallback to scryptsy (pure JS).

scrypt is not maintained anymore and is incompatible with node 12.

During package installation with yarn lots of nasty errors are printed to the terminal even though scrypt.js installation will actually succeed since scrypt is an optional dependency. Note: compiling with npm does not throw any error, just because it enforces "engines" only at the top-level of the project (the project/repo you're working on, i.e. not with respect to its dependencies), while yarn enforces at any level in a project's dependency tree (i.e. with respect to its dependencies too).

General solutions:

  1. once available, use a most recent version of setprotocol.js which uses a newer version of web3 (>= 1.2.1 - see pull #2938) or
  2. downgrade to node 10 or
  3. use the minified browser version of web3 (here) and avoid compilation

Currently, in the context of this project (that depends on setprotocol.js) the only option is 2.

Build runs out of memory

The build process with yarn might end up with a:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

To solve this issue we need to:

  1. Use npm (Node Version Manager) Switch to node 12 that has a better memory management:
nvm use 12
  1. Set the NODE_OPTIONS environment variable and configure the JS Engine (V8) to limit the amount of 'unused' space that is held in memory:
export NODE_OPTIONS=--max_old_space_size=4096

Notes:

NODE_OPTIONS allows to set node's options; among them some allow to configure the underlying V8 Javascript engine (run node --v8-options for a list).

"Old space" is the biggest and most configurable section of V8's managed (aka garbage-collected) heap (i.e. where the JavaScript objects live), and the --max-old-space-size flag controls its maximum size. As memory consumption approaches the limit, V8 will spend more time on garbage collection in an effort to free unused memory. If heap memory consumption (i.e. live objects that the GC cannot free) exceeds the limit, V8 will crash your process (for lack of alternative), so you don't want to set it too low. Of course, if you set it too high, then the additional heap usage that V8 will allow might cause your overall system to run out of memory (and either swap or kill random processes, for lack of alternative).

  1. If/when developing with TypeScript, webpack uses a specialized type-checker plugin (fork-ts-checker-webpack-lugin - here). This article explains how to customize Vue CLI's built-in webpack.config to increase the Node.js memory limit:
// in the vue.config.js

const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const os = require('os');

const totalMem = os.totalmem() / 1024 / 1024;
const maxMem = totalMem / 2; // half of the memory to build fast
console.log(
  'Total Memory is',
  totalMem,
  'MB',
  ' => Set memory limit to',
  maxMem,
  'MB'
);

module.exports = {
  //......,
  chainWebpack: config => {
    config.plugin('fork-ts-checker').tap(args => {
      // modify the option with our value
      args[0].memoryLimit = maxMem;
      return args;
    });
  },
  //......
};

Node.js memory allocation failure (during yarn serve)

The serve process with yarn might end up with a memory allocation failure and an error like this:

<--- Last few GCs --->
31681 ms: Mark-sweep 654.1 (666.5) -> 492.5 (509.8) MB, 267.5 / 0.0 ms [allocation failure] [GC in old space requested].
31839 ms: Mark-sweep 492.5 (509.8) -> 492.2 (506.8) MB, 157.5 / 0.0 ms [allocation failure] [GC in old space requested].
31985 ms: Mark-sweep 492.2 (506.8) -> 492.2 (497.8) MB, 146.2 / 0.0 ms [last resort gc]. 32122 ms: Mark-sweep 492.2 (497.8) -> 492.2 (497.8) MB, 136.8 / 0.0 ms [last resort gc]. <--- JS stacktrace --->

In that case setting the NODE_OPTIONS environment variable might help:

export NODE_OPTIONS=--max_old_space_size=8000
You might also like...
Blockviz - A Cryptocurrency Market & Blockchain exploration, using on chain data combined with exchange data to get a sense of trends. 📊
Blockviz - A Cryptocurrency Market & Blockchain exploration, using on chain data combined with exchange data to get a sense of trends. 📊

Visualizations for Blockchain & Market Data Sample Block Start Development & Testing Locally Clone the repo and run npm install The repo development i

Store specific tweets on the Arweave blockchain on demand

permatweet Store specific tweets on the Arweave blockchain on demand. Develop Node version Make sure to use the node version specified in .nvmrc eithe

SolLinked is a decentralised application (dApp) that makes it simple to submit your achievements on the Solana Blockchain
SolLinked is a decentralised application (dApp) that makes it simple to submit your achievements on the Solana Blockchain

SolLinked is a decentralised application (dApp) that makes it simple to submit your achievements on the Solana Blockchain

Gun-vue – is where the peer-to-peer javascript database Gun meets the reactivity system of Vue 3

Vite + Vue + Gun p2p crypto graph db toolkit. Vue 3 composables, components, relay server, demo and more.

Vue shop App is a simple web application built using Vue js, HTML, CSS, and JavaScript
Vue shop App is a simple web application built using Vue js, HTML, CSS, and JavaScript

Vue shop App is a simple web application built using Vue js, HTML, CSS, and JavaScript

JavaScript and Vue based ICICB explorer.

JavaScript and Vue based ICICB explorer.

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Supporting Vue.js Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome ba

A javascript calculator built with Xstate and Vue
A javascript calculator built with Xstate and Vue

Xstate Vue Calculator Based on https://github.com/mukeshsoni/statechart-calculator, but upgraded to XState 4.x and moved to Vue 2.x with Vue Compositi

Vue mindee - a very opinionated JavaScript library that will help you build interactive canvas for computer vision detection use cases
Vue mindee - a very opinionated JavaScript library that will help you build interactive canvas for computer vision detection use cases

Check Vue mindee documentation for docs, guides, API and more! Introduction Vue mindee is a very opinionated JavaScript library that will help you bui

Owner
Hidden Helper
Hello, World!!! I am standing here to help.
Hidden Helper
Filscan browser is the filecoin blockchain browser and data service platform,It provides one-stop data services such as mining ranking, blockchain data query and visualization chart based on filecoin

Filscan browser is the filecoin blockchain browser and data service platform,It provides one-stop data services such as mining ranking, blockchain data query and visualization chart based on filecoin

Filscan Team 9 Jun 2, 2022
The fast web3 application toolkit ⚡️

Building modern web3 applications should be simple, elegant and fast. Origin is an attempt to solve that problem with a focus to promote best practices in a lightweight, opinionated base configuration.

Application Research Group 54 Aug 9, 2022
A single Web3 / Ethereum provider solution for all Wallets

Web3ModalVue A single Web3 / Ethereum provider solution for all Wallets Introduction Web3Modal is an easy-to-use library to help developers add suppor

Dog 96 Jan 1, 2023
Web3 with Nuxt, Moralis and TailwindCSS

Web3 using Nuxt, Moralis & TailwindCSS. Display a users balance, NFT Count and check if they own an NFT in your project.

Roy Barber 4 May 24, 2022
Bridge from web2 to web3 for dev.to users. code for dev.to x appwrite hackathon

bridge can get dev.to users' articles and let them deploy their articles to the permanent storage provided by Arweave so that they can make their artices be permanently hosted in blockchain and no one can change them, delete them, and let them can not be accessed.

v0phan1ee 1 Dec 7, 2022
A sleek Open-Source, Non-Custodial, and Multi-Chain Crypto/Web3 wallet.

Vulture is an open-source cryptocurrency wallet that aims to become a general interface for blockchain, primarily made for Aleph Zero, but with a strong focus on supporting multi-chain.

psycoders.club 5 Sep 6, 2022
A Web3 platform for all content creators to continue doing what we like and enjoy.

Bitcoffee is a CrowdFonding Dapp on the RSK network, in which anyone can raise funds for their personal interests, campaigns, charity funds, etc., as well as for their followers to follow their goals, this through the use of crypto assets such as RBTC or our own token (BITC).

Angel Lopez 6 Nov 3, 2022
A simple app explore ethereum blockchain with vuejs.

vuethexplore Vue project for ethereum blockchain explore. Usage clone the repo npm install npm run dev Test unit npm run unit e2e npm run e2e all n

Peter Lai 30 Oct 5, 2022
Cloud-native platform for building an NFT Marketplace on top of Algorand blockchain.

Built on OpenAlgoNFT OpenAlgoNFT is an open-source cloud-native platform for building an NFT Marketplace on top of Algorand blockchain. Learn more on

Ulam Labs 111 Dec 7, 2022
DTrip - Traveler's app on STEEM blockchain.

dtrip.app Web client for decentralized travel application. Based on STEEM and IPFS. Run for local development yarn run dev SPA version https://ipfs.io

DTrip 17 Nov 25, 2022