Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live update transactions and overview on address page #333

Merged
merged 27 commits into from
Jul 3, 2018

Conversation

Stamates
Copy link
Contributor

@Stamates Stamates commented Jun 21, 2018

Resolves #30
Resolves #31

Motivation

Adds channel setup to handle live update rendering of new transactions and balance updates on the address page to prepare for when the backend pub/sub is in place.

Changelog

Enhancements

  • Initial wireup of channel updates to address transactions list and overview section to allow for live updates when the backend pub/sub system is in place to notify when a new transaction is validated.

Notes

This is only a stubbed out implementation and will require the following process to test:

  1. Run iex -S mix phx.server
  2. Wait for the server to run and navigate to 0xe2ac1c6843a33f81ae4935e5ef1277a392990381 address page (transactions tab)
  3. Hit enter in the console that's running the server to get an iex> prompt
  4. Copy and paste the code below and hit enter. Hit the up arrow to re-run the last broadcast line anytime you want a new live update.

Code for testing live update of transactions

{:ok, hash} = Explorer.Chain.string_to_transaction_hash("0xcdb45d3183664e732946f5c035e68aa3478983b126707fcd7a2c219b5075a87b")

{:ok, transaction} = Explorer.Chain.hash_to_transaction(hash, [ necessity_by_association: %{ block: :required, from_address: :optional, to_address: :optional } ])

ExplorerWeb.Endpoint.broadcast!("addresses:0xe2ac1c6843a33f81ae4935e5ef1277a392990381", "transaction", %{transaction: transaction})

Code for testing live update of overview (Note: this will change stored balance for the addresss)

{:ok, [hash]} = Explorer.Chain.update_balances([%{
      fetched_balance: 100,
      fetched_balance_block_number: 3106891,
      hash: 0xe2ac1c6843a33f81ae4935e5ef1277a392990381
    }])

{:ok, updated_address} = Explorer.Chain.hash_to_address(hash)

ExplorerWeb.Endpoint.broadcast!("addresses:#{hash}", "overview", %{address: updated_address, exchange_rate: %Explorer.ExchangeRates.Token{}, transaction_count: 1})

import $ from 'jquery'
import socket from '../socket'

if (window.page === 'address') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could use something to control this page scope, something like https://www.npmjs.com/package/@lucasmazza/page ? WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find, we'll take a look!

@coveralls
Copy link

coveralls commented Jun 22, 2018

Coverage Status

Coverage increased (+0.2%) to 94.551% when pulling 5281dcb on live-update-transactions-on-address-page-#31 into 56b6010 on master.

@jimmay5469 jimmay5469 changed the title Live update transactions on address page #31 Live update transactions on address page - WIP Jun 22, 2018
@jimmay5469
Copy link
Contributor

We've decided to add some code to this to handle missed messages and also to handle when a large quantity of transactions comes in at once. I marked it WIP for now, we'll let everyone know when it is ready again for review.

@jimmay5469 jimmay5469 self-assigned this Jun 22, 2018
@jimmay5469 jimmay5469 changed the title Live update transactions on address page - WIP [WIP] Live update transactions on address page Jun 22, 2018
@jimmay5469 jimmay5469 force-pushed the live-update-transactions-on-address-page-#31 branch from a728ea3 to 7e7e187 Compare June 25, 2018 14:51
@Stamates Stamates force-pushed the live-update-transactions-on-address-page-#31 branch 3 times, most recently from 90e5594 to 0e45905 Compare June 26, 2018 14:34
@jimmay5469 jimmay5469 changed the title [WIP] Live update transactions on address page [WIP] Live update transactions and overview on address page Jun 26, 2018
@jimmay5469 jimmay5469 force-pushed the live-update-transactions-on-address-page-#31 branch from f65500e to 1d98b02 Compare June 27, 2018 15:36
@Stamates Stamates changed the title [WIP] Live update transactions and overview on address page Live update transactions and overview on address page Jun 27, 2018
@tmecklem tmecklem mentioned this pull request Jun 28, 2018
@jimmay5469
Copy link
Contributor

This is no longer WIP, would you mind reviewing @amandasposito or @igorffs?

@jimmay5469 jimmay5469 force-pushed the live-update-transactions-on-address-page-#31 branch from 891b6ca to b2db49f Compare July 2, 2018 14:35
@@ -6,7 +6,7 @@ defmodule ExplorerWeb.AddressInternalTransactionController do
use ExplorerWeb, :controller

import ExplorerWeb.AddressController, only: [transaction_count: 1]
import ExplorerWeb.Chain, only: [paging_options: 1, next_page_params: 2, split_list_by_page: 1]
import ExplorerWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did the number change to 3? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we had to send in the existing params so that we can append them (so we maintain existing params like filter), thus the arity increased to 3

tmecklem and others added 3 commits July 3, 2018 09:43
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Tim Mecklem <timothy@mecklem.com>
Co-authored-by: Tim Mecklem <timothy@mecklem.com>
Stamates and others added 24 commits July 3, 2018 09:43
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Stamates <stamates@hotmail.com>
@jimmay5469 jimmay5469 force-pushed the live-update-transactions-on-address-page-#31 branch from b2db49f to 5281dcb Compare July 3, 2018 13:45
@jimmay5469 jimmay5469 merged commit c749a8e into master Jul 3, 2018
@ghost ghost removed the in progress label Jul 3, 2018
@jimmay5469 jimmay5469 deleted the live-update-transactions-on-address-page-#31 branch July 3, 2018 13:59
@vbaranov vbaranov mentioned this pull request Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants