Giter VIP home page Giter VIP logo

explorer's Introduction

Archived

This repository is no longer used for the helium blockchain explorer. The new codebase is in the network-explorer repository

Helium Blockchain Explorer

Code that powers the official Helium Blockchain Explorer.

Development and Contribution

Any and all contributions from the community are encouraged.

  • Guidelines for how to contribute to this repository are here.
  • Discussion about the development and usage of the Helium Blockchain Explorer takes place in the official Helium Discord Server, specifically in the #explorer channel. Join us!
  • For a list of issues and prioritization, please go to our Project page.

Getting Started

  1. First, clone the repository to your local machine and navigate into the folder. For example:
git clone https://github.com/helium/explorer.git
cd explorer
  1. Second, install all the dependencies:
yarn
  1. Edit your environment variables
NEXT_PUBLIC_MAPBOX_KEY=pk.ey[...the rest of your access token...]
  • Rename the file ".env" (delete ".sample" from the file name)
  1. Then run the development server:
yarn dev
# or
npm run dev

And open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file and save your changes.

  1. Create a new logically-named branch. For example:
git checkout -b witness-list-enhancements
  1. Push your changes to GitHub and create a PR against the master branch, linking the PR to any relevant issues.

Styling

Right now, the Explorer is styled using a combination of the Ant Design system, inline styles, and classes found in the /styles/Explorer.css file.

Ant Design is a really powerful way to quickly implement various complex UI elements that would take a long time to build manually (e.g.: tables with pagination, date pickers, search bars) as well as common UI elements that have a lot of nuance in functionality (e.g.: checkboxes, buttons, tooltips, etc.) But sometimes systems like Ant can be very limiting and opinionated when it comes to customizing those UI elements. And systems like Ant Design can also become hard to work with when something like their column and row system doesn't quite align with the way you think a layout should look, or you want to remove or add extra padding somewhere for example.

And on the other hand, inline styles are a nice option for keeping the styles attached to the JSX code, and for conditionally styling things based on some logic. But inline styles don't allow for media queries, which are increasingly necessary to create a good mobile-first experience.

As the Explorer website becomes more mature and the broader Helium product family adopts a more cohesive design, customizing UI elements in a consistent way across the Explorer will become more necessary, especially considering that around 50% of the Explorer's visitors are visiting from mobile devices. Because everything Helium makes is intended to become open-source over time, ensuring that the design stays consistent across the entire family of Helium products (the Hotspot app, Console, helium.com, etc.) can become difficult the more one-off solutions are used to fix specific UI problems.

So in order to help us minimize the following things in Explorer:

  • hardcoded hex colors, font sizes, font weights, padding and margin values
  • long CSS files with confusing media queries, inconsistent class and ID names
  • one-off solutions to override or fight against design systems like Ant

we are trying out TailwindCSS. There is a /tailwind.config.js file at the root of the project which defines things like the website's color palette, breakpoints (sm, md, lg, xl), and in the future, things like font sizes, font weights, spacing tokens, and whatever else makes sense to include.

Moving the Explorer's styling code to Tailwind will be a gradual transition, and it might turn out that Tailwind isn't the best fit for Explorer in the end, in which case this section of the README will be updated accordingly.

How to use Tailwind

The Tailwind docs are a really great resource for getting up to speed quickly on the syntax, but here is a brief example to show the power of Tailwind. Something like this is common to see in the Explorer codebase right now:

<div
  style={{
    display: 'flex',
    flexDirection: 'row',
    backgroundColor: '#222E46',
    alignItems: 'center',
    justifyContent: 'center',
    maxWidth: 1200,
    margin: '0 auto',
    padding: '16px 32px',
  }}
>
  <p
    style={{
      color: '#FFFFFF',
      fontSize: 16,
    }}
  >
    Example text
  </p>
  <p
    style={{
      color: '#EEEEEE',
      fontSize: 16,
    }}
  >
    Example text
  </p>
</div>

In Tailwind, the same code could be written like this:

<div className="flex flex-row bg-navy-500 items-center justify-center max-w-xl mx-auto py-4 px-8">
  <p className="text-white">Example text</p>
</div>

But the real power of Tailwind shows when you want to change the styling between mobile and desktop screen sizes.

In the first code snippet above, to make the styling different between screen sizes, you'd need to do something like this:

<div
  className='container'
  // ^^^ come up with a logical class name and add it
  style={{
    display: 'flex',
    flexDirection: 'row',
    // ^^^ delete this row
    backgroundColor: '#222E46',
    alignItems: 'center',
    justifyContent: 'center',
    maxWidth: 1200,
    margin: '0 auto',
    padding: '16px 32px',
  }}>

and then add some CSS code like this:

.container {
  flex-direction: row;
}

@media screen and (max-width: 576px) {
  .container {
    flex-direction: column;
  }
}

In Tailwind, you could accomplish the same thing without having to come up with a new class name or adding any CSS by simply changing the first few utility classes in the above div to read like this:

<div className='flex flex-col sm:flex-row ...

That might seem confusing at first glance, but another reason Tailwind is powerful is because it encourages us as frontend developers to take a mobile-first approach when styling things. The above set of utility classes in plain English translates to:

flex direction is "column", but if the screen size is bigger than "small" (mobile), flex-direction is "row"

Another nice use case for Tailwind is styling things conditionally while keeping the design system tokens intact. For example:

<p
  className={`font-bold text-xl ${
    status === 'online' ? 'text-green-400' : 'text-red-400'
  }`}
>
  {status}
</p>

The syntax takes some getting used to, and sometimes the class names can start to get unwieldy, but the utility class model fits really nicely with components, so any time you find yourself repeating a string of Tailwind utility classes is probably a good time to encapsulate that JSX as a component.

Questions

If you run into any issues or you have any questions about how to get started contributing, feel free to reach out on the #explorer channel in the official Helium Community Discord server!

Learn More

This is a Next.js project.

To learn more about Next.js, take a look at the following resources:

explorer's People

Contributors

abhay avatar allenan avatar amirhaleem avatar bogardo avatar cokes518 avatar danielcolinjames avatar dependabot[bot] avatar filoozom avatar fredev avatar guiferrpereira avatar illperipherals avatar jthiller avatar jwendig avatar kevinwassermann94 avatar madninja avatar matthewcarlreetz avatar mohdimran001 avatar mrccodes avatar mugoosse avatar mvidaldp avatar mykolakolotylo avatar nickhough avatar petermain avatar pharkmillups avatar philltran avatar robputt avatar talitrus avatar tyler-whitman avatar vulet avatar webuti avatar

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

explorer's Issues

Table overflow on mobile

In the account page the activity table overflow the layout on mobile phones.

Schermata 2020-09-02 alle 04 03 15

PR #14 try to solve this by making the table scrollable

When clicking back to home page, data doesn't refresh

When you click on the Helium logo in the left of the nav bar from another view, sometimes the data in the main table on the home page doesn't update, so it shows every stat with a 0. Not sure exactly what the steps are to reproduce, but I've seen it a couple times now.

Update summary section on home page

This section should also be made a little bit more mobile friendly, with padding at smaller screen sizes for example, and between the two sections of the summary box

Hotspot Checklist

As a user, tell me when each Hotspot has completed the following. This gives me a good idea of what steps my hotspot needs to complete before it can fully mine.

  1. Hotspot synced block height (use API)
  • is the block height of the hotspot close to the tip of the blockchain? (within 10 blocks)
    • if yes, checkmark. if not, show block height
  1. Is the Hotspot online? (use API)
  • if yes, checkmark
  1. Issued a Challenge (walk the ledger/look for a receipt)
  • has the Hotspot ever issued a challenge?
  • was it rewarded for the challenge?
    • if yes, checkmark
  1. Witnessed a challenge (walk the ledger/look for a receipt)
  • has the Hotspot ever witnessed a challenge?
  • was it rewarded for witnessing?
    • if yes, checkmark
  1. witness list (use API)
  • does the Hotspot have a witness list, right now?
    • tell the user to use the witness list checkbox to visually confirm on a map
  1. Participated in PoC (walk the ledger/look for a receipt)
  • has the hotspot ever participated in a challenge?
  • was it rewarded for it?
    • if yes, checkmark

Note: designs will not be provided for this feature. we feel this is simple enough to display and will leave it up to the developer.

Loading state for Blockchain stats

Sometimes the API takes a little longer than expected and the explorer makes me nervous with all the zeroes.

image

Would love to add some loader states for those values as they are coming back.

Witness List Shadow

The witness list seems to have a shadow on the right (see below picture)
shadow is in: .ant-table-ping-right:not(.ant-table-has-fix-right) .ant-table-container::after
image

Account reward total sometimes incorrect

When viewing my account reward total, I noticed the rewards don't always match what the mobile app says. I suspect it's a caching issue as a few page refreshes seems to resolve it.

Show Hotspot names and distances in Witness List

Each Hotspot has a witness list in explorer and their locations are displayed in a map. It'd be great if we can also see the list of Hotspots in a table with their name (linked to their respective Hotspot page) and distance away in miles (or km).

We can also display the Hotspot name, on-hover, to each witness in the map.

Data Credits stat on homepage might need reconsidering

Right now the "Data Credits spent (30d)" stat on the home page isn't including transactions and staking fees. Those fees are now being returned by the /stats endpoint, under fees, and broken down over day, week, month.

We should figure out the best way to approach showing these fees, as we could technically add it to the existing field, but it should probably be possible to break down that number in some way, to see the different split (staking, transactions, data transfer).

For now it might be okay to just combine the numbers into the current field, but some people might assume that number represents data credits spent on data transfer, or might be confused by the number getting quite a bit larger as soon as the change is implemented. But it also might be a bit unwieldy to add 2 new fields.

I'm thinking maybe something like this could be the best interim approach—3 different stats:

  • "Data Credits spent on data transfer"
  • "Data Credits spent on staking" (or maybe different wording)
  • "Data Credits spent on transactions"

Show Witnesses on hotspot page not behaving correctly

User reported:

Cannot see witnesses at explorer.helium.com for a specific hotspot without clicking a hash or block link and then hitting back on the browser? I use chrome and experience this on multiple devices (even after cache reset)

Make date listing consitent on Activity Table

Depending on the length of data, the data listing on Activity table sometimes wraps. I propose we choose a fontsize that works without wrapping for the maxium possible date width.

image

Mapbox flyTo() bug

I unintentionally introduced a small bug when adding the manual zoom +/- buttons in PR #54

Steps to reproduce:

  1. Go here: https://helium-explorer-pr-54.herokuapp.com/coverage (and wait for all hotspots to load)
  2. Click one of the hotspots in the sidebar
  3. While the map auto-zooms and pans to focus on it, click and drag the screen, so that the auto-zoom & pan gets cancelled / overridden by your input
  4. Click "< Back" in the top left of the hotspot selector sidebar
  5. Select a different hotspot from the list
  6. It should start to zoom/pan toward it, and then stop abruptly. It will work if you click it again, but it shouldn't be stopping there.

It only happens if you actually interrupt the zoom in step 3. If you let it complete fully by itself it works fine.

This is a bug I introduced, but without the new code I added that causes this bug, the zoom +/- buttons will be incrementing or decrementing what the zoom level was before the flyTo() event started, so I think that's more important in the short term.

The relevant bit of code is here:

let flying = false
if (selectedHotspots.length > 0) {
if (!this.state.map) return
if (!this.state.flyingComplete) {
if (!flying) {
this.state.map.flyTo({
center: [selectedHotspots[0].lng, selectedHotspots[0].lat],
zoom: 14,
})
// So that we know that the map is currently flying from one location to another
this.state.map.fire('flystart')
flying = true
}
if (flying) {
// While the flying event is happening, wait until it's completed
// (either by the user interrupting it, or once it reaches its end state)
this.state.map.once('moveend', (event) => {
// Once it's finished, reset the flying flag
flying = false
// Set the flyingComplete flag to true so this code chunk doesn't keep running
this.setState({ flyingComplete: true })
// Set zoom state variable to what the zoom level was when the flying event stopped
// Without setting this, the manual zoom +/- buttons would be incrementing or
// decrementing the zoom level from before the fly action started
this.setState({ zoom: [event.target.transform.tileZoom] })
})
}
}
}

GIF demonstrating the bug:
image

Difficult to get to specific hotspot's rewards

If I am a user interested in seeing the breakdown of a given hotspot's rewards, it is quite difficult to get from the hotspot's page to the actual reward entry inside the mining rewards txn.

e.g. for the hotspot gorgeus-purple-fox:

https://explorer.helium.com/hotspots/112STWVQvGHbSmPgc7J1f1dQ6ZqEtYScvHHdCFSXzXTvuoRxK2Vr

Screen Shot 2020-09-01 at 3 36 03 PM

There is a link to a recent mining reward txn:

https://explorer.helium.com/txns/j9VrzBSCWxctjEVS0KdyCa6TAZpLEM1jolrrMaVunKQ

Screen Shot 2020-09-01 at 3 37 09 PM

But clicking that link takes you to the top of a massive, 30+ page list, rather than jumping you to this particular hotspot's rewards inside that txn:

Screen Shot 2020-09-01 at 3 37 24 PM

Since this list is sorted by HNT quantity descending, I am able to find the specific hotspot's reward by taking the reward amount (0.05 HNT) and the owner address (14Mjr...), jumping randomly towards the end of the list since it's a small amount, then paging manually and using cmd-F/cmd-G until I found it

Screen Shot 2020-09-01 at 3 39 43 PM

Add links to next transaction and previous transaction buttons

These buttons didn't have hrefs assigned to them, so for now I figured it's better if the buttons don't show up, since it can be confusing (or dare I say annoying) for users to see buttons that seem like they'll do something and then have them not actually do that thing :)

I took a quick look at how to actually find the next and previous transactions given only the transaction hash, but I'm not sure how to do it (let alone efficiently, with as few API calls as possible), so it'll require a bit deeper look at some point.

I commented them out of the JSX for now.

Screen Shot 2020-10-06 at 5 30 03 PM

Show all hotspots within a H3 resolution that a Hotspot *could* see

As a Hotspot owner, show me a list of all Hotspots around me that I could potentially witness so that I have a better understanding of who I can participate in challenges with, and whether I can witness at all.

At a resolution 7, with the area of the hexagon at approximately 2 squared miles, we can show a hexagon overlaid on the coverage map and highlight all the Hotspots within the area, similar to the witness list feature.

By comparing this list of Hotspots and the witness list, a Hotspot owner can attempt to optimize their Hotspot position and maximize mining potential.

Search bar is too tiny on mobile width

The search bar is too tiny to be useful on mobile width. We should restyle the header at the mobile responsive breakpoint in such a way that the search bar is fully visible. Maybe a search icon that animate/expands to a full bar? Or breaking the search bar onto its own line?

image

Make search bar more awesome

The search bar should feel more like an "awesome bar". It should autocomplete or give you prompts for types of things you can put it in. It could also be triggered by a keyboard shortcut, like / on GitHub. It might also remember your search history and suggest things you've searched for or visited recently. The search bar on console is maybe a good starting point for what to do here, and we could research some other sites/services to see how they handle search/autocomplete

DCs showing up on multiple hotspots

When data packets are being transmitted by a device that is in range of multiple hotspots, Explorer is showing the DCs on each of the hotspots activity.

This is causing the DC usage to have some duplicate values, which is then flowing through to the State Channels and inflating total DC usage.

Example (7.23.20): I sent approximately 470 DCs worth of data via a device that was in range of three devices. One device could hear almost every packet and the other two were intermittent. The DCs showing on explorer were:

Device 1 - 464
Device 2 - 199
Device 3 - 56
Total: 719

Unused variables and other console warnings should be tidied up

There are lots of console / terminal warnings when you run the project locally. Even if most of it gets fixed / ignored at build time, we should still clean it up for a better developer experience. Some of the warnings are things like adding alt tags for <img>s and things like <div> can't be a child of <p>

Should be pretty straightforward to tidy these up.

Bring in more network data on explorer home page

This data already exists - we should bring it into explorer to give a sense of network growth and usage until we can build out viz and graph with new explorer.

In Blockchain Stats - replace Total Hotspots with Hotspots Transferring Data

Above the Coverage Map:
Total Hotspots
New Hotspots (14d)
Countries
Cities

coverage stats

Transaction hashes

I am unaware if this is intentional or not, but the hashes that show on Explorer begin with the second character.
substring_1

Make site more mobile friendly

Right now there are a handful of spots across the Explorer that could use a little bit of reorganizing / reformatting to make them more mobile friendly.

Examples:
image

image

Add dynamic meta tags

Once #55 has been merged and the site is running on Next, one of the things we can do to take advantage of Next is have meta tags specific to each page.

One way to achieve this could be having a <MetaTags /> component that makes use of Next's <Head /> component and gets imported into each page, accepting the following props:

  • title
  • description
  • openGraphImageAbsoluteUrl

Then meta tags could be generated dynamically for each page. E.g.: each block detail page could generate meta tags like this (generated here):

<!-- COMMON TAGS -->
<meta charset="utf-8">
<title>Block 554,081 – Helium Explorer</title>
<!-- Search Engine -->
<meta name="description" content="Block 554,081 of the Helium blockchain contains 51 transactions and was generated on October 22nd at 12:10PM">
<meta name="image" content="https://explorer.helium.com/images/block-details-og.jpg">
<!-- Schema.org for Google -->
<meta itemprop="name" content="Block 554,081 – Helium Explorer">
<meta itemprop="description" content="Block 554,081 of the Helium blockchain contains 51 transactions and was generated on October 22nd at 12:10PM">
<meta itemprop="image" content="https://explorer.helium.com/images/block-details-og.jpg">
<!-- Twitter -->
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Block 554,081 – Helium Explorer">
<meta name="twitter:description" content="Block 554,081 of the Helium blockchain contains 51 transactions and was generated on October 22nd at 12:10PM">
<meta name="twitter:site" content="@helium">
<meta name="twitter:image:src" content="https://explorer.helium.com/images/block-details-og.jpg">
<!-- Open Graph general -->
<meta name="og:title" content="Block 554,081 – Helium Explorer">
<meta name="og:description" content="Block 554,081 of the Helium blockchain contains 51 transactions and was generated on October 22nd at 12:10PM">
<meta name="og:image" content="https://explorer.helium.com/images/block-details-og.jpg">
<meta name="og:url" content="https://explorer.helium.com/blocks/554081">
<meta name="og:site_name" content="Helium Explorer">
<meta name="og:locale" content="en_US">
<meta name="og:type" content="website">

So it would show up with a nice preview card when shared on Discord / Twitter / Facebook / wherever.

Wrong fees

When in the helium app, if you reassert a hotspot it will show 50k dc instead of 100k.

This can lead to confusion, as the blockchain explorer shows 100k.

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.