Giter VIP home page Giter VIP logo

polkadot-js / apps Goto Github PK

View Code? Open in Web Editor NEW
1.7K 64.0 1.5K 315.81 MB

Basic Polkadot/Substrate UI for interacting with a Polkadot and Substrate node. This is the main user-facing application, allowing access to all features available on Substrate chains.

Home Page: https://dotapps.io

License: Apache License 2.0

JavaScript 0.14% HTML 0.02% TypeScript 99.83% Dockerfile 0.01% Shell 0.01%
polkadot substrate polkadot-js ui blockchain wallet

apps's Introduction

@polkadot/apps

A Portal into the Polkadot and Substrate networks. Provides a view and interaction layer from a browser.

This can be accessed as a hosted application via https://polkadot.js.org/apps/ or you can access the IPFS hosted version via https://polkadot.js.org/apps/ipfs (via hash) or https://dotapps.io (via ipns) to explore any of the supported Polkadot and Substrate chains.

If you run one or more IPFS node(s), pinning the UI (which only gets updated on releases) will make it faster for you and others. You can find details about that below in the IPFS chapter below.

Important If you are a chain developer and would like to add support for your chain to the UI, all the local configuration (API types, settings, logos) can be customized in the apps-config package, complete with instructions of what goes where.

Overview

The repo is split into a number of packages, each representing an application.

Development

Contributions are welcome!

To start off, this repo (along with others in the @polkadot family) uses yarn workspaces to organize the code. As such, after cloning dependencies should be installed via yarn, not via npm, the latter will result in broken dependencies.

To get started -

  1. Clone the repo locally, via git clone https://github.com/polkadot-js/apps <optional local path>
  2. Ensure that you have a recent LTS version of Node.js, for development purposes Node >= 16 is recommended.
  3. Ensure that you have a recent version of Yarn, for development purposes Yarn >= 1.22 is required.
  4. Install the dependencies by running yarn
  5. Ready! Now you can launch the UI (assuming you have a local Polkadot Node running), via yarn run start
  6. Access the UI via http://localhost:3000

Docker

You can run a docker container via -

docker run --rm -it --name polkadot-ui -e WS_URL=ws://someip:9944 -p 80:80 jacogr/polkadot-js-apps:latest

To build a docker container containing local changes -

docker build -t jacogr/polkadot-js-apps -f docker/Dockerfile .

When using these Docker commands, you can access the UI via http://localhost:80 (or just http://localhost)

IPFS

IPFS allows sharing files in a decentralized manner in a similar fashion the polkadot network exchanges blocks. IPFS works best when many nodes seed the same data. Nodes can seed specific data by pinning them.

You can pin with the following command:

curl -s https://polkadot.js.org/apps/ipfs/pin.json | jq -jr .IpfsHash | xargs -0 -I CID ipfs pin add --progress CID

Here is a script you can save as /usr/local/bin/polkadotjs-ipfs-pin.sh:

#!/usr/bin/env bash

IPFS='/usr/local/bin/ipfs'
curl -s https://polkadot.js.org/apps/ipfs/pin.json | jq -jr .IpfsHash | xargs -0 -I CID $IPFS pin add --progress CID

I suggest to run the script once. The output should be similar to (the CID/Hash will very likely be different though):

$ /usr/local/bin/polkadotjs-ipfs-pin.sh
pinned QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW recursively

Now that you know the CID (hash), you can check whether the data is already pinned or not:

$ ipfs pin ls | grep QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW
QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW recursive

Now that we know it works, we can automate that with a cron task. Run crontab -e. If you see only comments, append the following to the file and save:

SHELL=/bin/bash
HOME=/
0 * * * * /usr/local/bin/polkadotjs-ipfs-pin.sh >/dev/null 2>&1

Now our script will run every hours at minute '0' (8:00, 9:00, etc...). To check, we can unpin temporarily:

$ ipfs pin rm QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW
unpinned QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW

Now asking for the CID confirms that is it not there.

$ ipfs pin ls QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW
Error: path 'QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW' is not pinned

Wait until the your cron task runs and try again:

$ ipfs pin ls QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW
QmNYAbzaE8kRAf68YiN3ZuUxgdwroeav3JhicsHsG5b2oW recursive

Tada! This is now automatic and you may forget it.

If you are curious and want to know how many people seed the UI on IPFS, here is the magic command (it may take a while to return the answer as ipfs will search for about 1 minute):

ipfs dht findprovs QmTejwB7mJPBHBoqubjzHSgSxfLMcjnZA3LFefqoQc87VJ | wc -l

If you are current about the content of what you just pinned, you may use the following command:

$ ipfs ls QmTejwB7mJPBHBoqubjzHSgSxfLMcjnZA3LFefqoQc87VJ
QmPJGyqVCcXm238noz7TZDByyGa35qqc8g6sfyXF3KDXZ3 38078   favicon.ico
QmdouVsVE9rMVB84Cy1ehVi1LAGW1fKcqqQxSEjgxJrv7H 668     index.html
QmWHcGf1JCFZCYjZsw52vM5RiJVbcNpX1fo2NyoBKBvtuf -       ipfs/
QmT6NwDsJzMyBs6bMq845nMumeJWbixBfNXA9hdAhAMdSG -       locales/
QmcgiZpwvpT1E1dkSS3zr5je89rZRVocNKPebgWhn3JVTC 2178582 main.ce05dfca.js
QmdnEtuhFDyw5Tjr82bFPzyveFrbkYjJAnUvBvzwT18YGG 337     manifest.json
QmW7gDKHbmtD7sRTqsvyo84bDpyYPZR3w1wQo8pme2q5HC -       next/
Qmd8UnRQiBobm4qb6dhiC1HoQ7SvwZrWJenoN3JPEV3iiF 480594  polkadotjs.3af757ad.js
QmUfXPMfNys8Y8dekuankBx7BHiSAjALCpBDKH6F5DdcNm 628284  react.0cecb00d.css
QmSEgXdQbC1ek9Td1mHy3BRvJpfWHm9zQYegTgAUj1QC4g 924156  react.8f083b49.js
QmfGBgFe2aqf83Wv21m9k5DH2ew89CDj4tydoxJWdK6NNL 1552    runtime.3d77e510.js
QmYPa8jcHH7gfopMALr5XTW4i1QM2xgVBe3NeP11y3tErA -       static/
QmeYBC5EgbccC8NEwXC2rvbd93YiHtTM5xYzqCDohXerDf 859984  vendor.8b793a81.js

Desktop App

The main advantage of using Desktop App is that it by default stores encrypted accounts on the filesystem instead of browser's local storage. Local storage is susceptible to attacks using XSS (Cross-Site Scripting). There's no such risk when with files stored on disk.

The desktop app uses the Electron framework. It provides the same features as web app, the only difference being different account storage.

The accounts are stored in the following directories:

  • Mac: ~/Library/Application Support/polkadot-apps/polkadot-accounts
  • Linux: ~/.config/polkadot-apps/polkadot-accounts (or $XDG_CONFIG_HOME/polkadot-apps/polkadot-accounts if $XDG_CONFIG_HOME is defined)
  • Windows: %APPDATA%\polkadot-apps\polkadot-accounts

For more details on the desktop app, head over to Electron package README.

apps's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apps's Issues

Change ui-react/IdentityIcon to PureComponent

Current implementation is probably a bit anti-pattern-ish. (Trying to shoe-horn in a functional component - especially the append is fragile. Do it with a proper component & in-class refs)

Add additional metadata on accounts/addresses

Goal:

We want to be able to manage the accounts and addresses better, so the user actually have a better way of categorizing their accounts and, at first glance, be able to see what the account/address relates to.

Background:

With the number of icons, accounts and addresses in the system, it is quite difficult to, at first glance, be able to see what this relates to. On Alexander, my setup has 12+ accounts (for various purposes), and it can be difficult to spot the "right one".

The suggestion here is to to add additional metadata to the saved keyring infomation, initially just focussed on labels that the user can add.

Actions:

  • Add the ability for the user to define custom labels (used either for accounts of addresses) - this can simply be an input with "pick from existing" or "add new"
  • Defined labels are saved in storage (basically anything defined in the accounts/addresses)
  • Re-use this component on accounts and addresses - as mentioned above, just another add/edit input
  • Save this information along with the account. The Keyring supports the meta fields so a "labels" array can just be added with no other overhead.
  • For the AddressSummary and AddressRow components, show the actual attached labels (as available) - this way it is useful wherever it is used in the UI

Optionally:

  • With the AddressRow, AddressSummary components, allow in-place adding of labels. So without adding an account to my addressbook, I can label it with a "+" (This can actually be a "quick add to addresses" functionality - so specify labels & name, save.

Follow-ups:

Once the above is in-place, we can start doing filtering through the UI based on labels. i.e. on staking, I can filter to see only the validators I am interested in, based on their labelling.

Cleanup CSS using PostCSS

(Low priority, just for when bored)

Now that we have PostCSS, we can cleanup the CSS nicely, as an example, https://github.com/polkadot-js/apps/blob/master/packages/ui-app/src/styles/components.css -

.ui--output {
  background: #f9f9f9;
  border-radius: 4px;
  border: 1px solid #f5f5f5;
  box-sizing: border-box;
  line-height: 1em;
  margin-bottom: 0.5em;
  padding: 0.75em 1em;
  position: relative;
  word-wrap: break-word;
 
  &.error {
    background: #fff6f6;
    border-color: #e0b4b4;
  } 

  .ui--output-button {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
  }
}

Nesting, variables, slowly does it.

Combine "unlock to sign" with packages/ui-signer

Currently we have duplicated logic. It would mean a bit of rework on the signer since it currently has a purpose of unlock, sign & submit, but from an overall perspective we don't want keychain management in multiple places.

Convert the hashing to libsodium-wasm for vanity addr

... not a high priority since the functionality is just a "o, this can be cool", however should bring in a nice boost which should make it actually useful. https://github.com/alexcrichton/wasm-sodium

(For the command-line app the generation uses natively compiled sodium (as available), it is faster.)

Probably seeing this bit as a POC, when done properly it is added to the @polkadot/util-crypto, however in that case we probably wnat native & wasm support. So for now, trial with just the vanitygen app.

polkadot-dev-yarn-only: command not found

I pulled the latest changes from the master branch and then switched to the latest Node.js version using NVM with nvm use v10.4.0. I then ran yarn install, but it gave the following error sh: polkadot-dev-yarn-only: command not found:

$ yarn
yarn install v0.24.6
(node:12387) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning "[email protected]" has unmet peer dependency "react@^15.0.0 || ^16.0.0".
[4/4] ๐Ÿ“ƒ  Building fresh packages...
$ polkadot-dev-yarn-only
sh: polkadot-dev-yarn-only: command not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

It's trying to run the line "postinstall": "polkadot-dev-yarn-only", in package.json.
I understand that the intention is that after installing the dependencies into the node_modules/ directory, it'd run indirectly via a shell script the Node.js CLI script that would then be available in ./node_modules/@polkadot/dev/scripts/polkadot-dev-yarn-only.js. When using "postinstall": "polkadot-dev-yarn-only", it tries to calling a binary executable file in node_modules/.bin named polkadot-dev-yarn-only but it doesn't exist and the shell script /node_modules/@polkadot/dev/scripts/polkadot-dev-yarn-only doesn't exist either.

author_submitExtrinsic encoding number[] on master

The serialisation of exterinsics now expects an array of bytes ([255, 245, 69, ..]) instead of a hex string (0xfff545...) - need to wait until a conclusion in reached and a fix is available. For now the enumerable accounts #102 is untested on master, where it actually has effect.

Basic governance app

(Still be be fully expanded)

  1. Shows a list of proposals (either for "general voting" or "council voting")
  2. Allows ability to see the votes, what it actually entails, the time left, etc.
  3. Allows the ability to make a vote on the proposal
  4. Shows own votes slightly differently, i.e. "yes, you have done this" vs "no, you are not involved"
    ...

Simple staking app

  • Allows users to stake/unstake
  • Allows a view of current validators + their balances
  • Allows a view of current intentions (i.e. accounts wishing to stake) + their balances
  • indication if any current accounts are validators and/or has the intention to stake (this probably goes on accounts/addresses as well)

Make telemetry visible as an app

As the telemetry is available, pull it in as an app - the front-end can be pulled-in, the back-end is hosted, i.e. it should connect to the same one. There are probably some smaller changes required on the telemetry app, i.e. not connecting by default to the host. For the most part, should just be a navigation entry and launching.

Not an immediate, telemetry UI should stabilise first.

@maciejhirsz Any additional comments here? (Don't do anything to change/adapt, but would like to explore the possibility in the future)

Unable to Create account due to colors package error

When running the latest version of polkadot-js, if I click "Create account" on the Accounts page it returns the following error in Chrome Inspector Console Uncaught TypeError: all.splice(...)[0].alpha(...).string is not a function

Add settings apps, e.g changing api endpoint

  1. Add settings app, packages/app-settings
  2. Allow configuration of WS endpoint, anything allowed (ws://|wss:// prefixed)
  3. Show 2 pre-configured options, one for poc-1 hosted node (wss://poc-1.polkadot.io:9944) and one for locally-running node (ws://127.0.0.1:9944)
  4. WS URL should be stored in localstorage - by default we probably want to pull in WS_URL env variable for the running-instance default.
  5. On changing and setting endpoint via setApiWsUrl (assuming we wrap with ui-react-rx/with/api we probably need to refresh - the API itself won't automatically refresh existing subscriptions (that needs to be fix at the API layer, probably more involved - phase II)

UI does not work in FF

Safari also not tested - Babel config is set properly, but none of the dev team has actually tried Chrome, alas, reports are there are some issues..

Use reactive store for account options

i.e.

const options = keyring.getOptions(type);

The above (and the actual comment around extending) does not bode well for things like the chain lookup where the options may change. This is the one place where a MobX (or alike) store can help - which obviously needs to be triggered in int's own right. (Possibly the trigger could be an observable instead of a store?)

What happens currently -

  1. Go to extrinsics page
  2. Start/stop node with dev chain
  3. Testing accounts don't immediately show up, rather leaving and entering the page makes them show

Better display of accounts/others in storage

i.e. currently a list of accounts will show the addresses, however probably should be expanded to show the actual identitycon as well.

Where param names as displayed, it can be "paramName = paramValue"

Basically take what we have and turn it from a "text-dump" into something that actually looks and feels usable

Account edit currently is a bit confusing...

This is just something small... however it is not very obvious that if you change the name the save becomes active. Most will expect to "click before doing". The functionality without extra clicks is not bad, however it is completely non-obvious.

Convert components to React.PureComponent

It is currently a (tiny bit) of mental gymnasics since it is not always clear when to use functional or PureComponent. (Well, it is - the latter has state and lifecycle methods). However, moving between files has some context-switching overhead.

It probably makes sense to convert all functional components to PureComponent - slightly less performant (?), however from a "this is how it is done" perspective it makes understanding and contributing easier.

(Not super important, however something to look at)

Show transaction fee when submitting transactions

staking.transactionFee() from storage should be included and shown on-screen when we are submitting an extrinsic. (i.e. it is probably useful to have a "total to be sent" display).

Especially in POC-1, this is confusing for some users - they transfer 1 DOT, however 101 gets deducted (100 DOT tx fee as set). For dev chains this is set to 1 DOT only, i.e. 2 gets deducted.

Unable to connect to PoC-2 using WebSockets

I am using the master branch for the latest version of Polkadot to run a Polkadot Node on my local machine. I am using it to connect to PoC-2 Testnet with polkadot --chain=poc-2 --ws-port=8081. Unfortunately it does not appear to be backwards compatible, as poc-1 is no longer an available value for the --chain CLI option in the latest version of Polkadot. If I then run the latest version of Polkadot.js apps portal front-end and try to connect it to PoC-2 using WebSockets with WS_URL=wss://poc-2.polkadot.io:9944 yarn run start and open http://localhost:3000/ in Chrome web browser it gives the following error in Chrome Inspector WebSocket connection to 'wss://poc-2.polkadot.io:9944/' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED. It only works if I connect to PoC-1 via WebSockets with WS_URL=wss://poc-1.polkadot.io:9944 yarn run start. How can I connect to PoC-2 via WebSockets?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.