Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ Note that `API_URL` should be set to the publicly-reachable URL where the user's
Elements-only configuration:

- `IS_ELEMENTS` - set to `1` to indicate this is an Elements-based chain (enables asset issuance and Elements-specific features)
- `SHOW_PEG_DATA` - set to `1` to show dashboard peg data and fetch its API resources (enabled by the Liquid mainnet and regtest flavors; custom pegged chains must opt in)
- `SHOW_HIGH_VALUE_ASSETS` - set to `1` to show circulating values for selected assets on the Liquid mainnet dashboard (enabled by the Liquid mainnet flavor)
- `NATIVE_ASSET_ID` - the ID of the native asset used to pay fees (defaults to `6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a11eec381c526d`, the asset id for BTC)
- `BLIND_PREFIX` - the base58 address prefix byte used for confidential addresses (defaults to `12`)
Expand Down
51 changes: 1 addition & 50 deletions client/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ import { isBitcoinNetwork } from './lib/network'
import getPrivacyAnalysis from './lib/privacy-analysis'
import {
highValueAssetDefinitions,
nativeAssetId,
blockTxsPerPage,
blocksPerPage,
difficultyPeriod,
pollIntervalsMs,
showHighValueAssets,
showPegData,
blockGridTransactionSelectEvent
} from './const'
import {
Expand Down Expand Up @@ -243,14 +241,6 @@ export default function main(
hasFocus,
pollingEnabled
)
, recoverableReply = cat => O.merge(
reply(cat).map(value => ({ value, succeeded: true }))
, extractErrors(HTTP.select(cat)).mapTo({ succeeded: false }))
.scan((state, result) => result.succeeded
? { value: result.value, error: false }
: { ...state, error: true }
, { value: null, error: false })
.startWith({ value: null, error: false })
, on = (sel, ev, opt={}) => DOM.select(sel).events(ev, opt)
, click = sel => on(sel, 'click').map(e => e.ownerTarget.dataset)

Expand Down Expand Up @@ -449,26 +439,6 @@ export default function main(
})

// dashboard
, dashboardPegAsset$ = !showPegData
? O.of({ value: null, error: false })
: recoverableReply('dashboard-peg-asset')
, dashboardPegChainTxs$ = !showPegData
? O.of({ value: null, error: false })
: recoverableReply('dashboard-peg-chain-txs')
, dashboardPegMempoolTxs$ = !showPegData
? O.of({ value: null, error: false })
: recoverableReply('dashboard-peg-mempool-txs')
, dashboardPegState$ = O.combineLatest(
dashboardPegAsset$
, dashboardPegChainTxs$
, dashboardPegMempoolTxs$
, (asset, chainTxs, mempoolTxs) => ({
asset: asset.value
, txs: chainTxs.value != null && mempoolTxs.value != null
? [ ...mempoolTxs.value, ...chainTxs.value ]
: null
, error: asset.error || chainTxs.error || mempoolTxs.error
}))
, dashboardHighValueAssets$ = !showHighValueAssets
? O.of({})
: O.merge(...highValueAssetDefinitions.reduce((replies, asset) => [
Expand All @@ -495,12 +465,10 @@ export default function main(
, dashboardState$ = O.combineLatest(
blocks$,
mempoolRecent$,
dashboardPegState$,
dashboardHighValueAssets$,
(blks, txs, peg, highValueAssets) => ({
(blks, txs, highValueAssets) => ({
dashblocks: blks.slice(0, 5),
dashTxs: txs.slice(0, 11),
peg,
highValueAssets
}))

Expand Down Expand Up @@ -757,21 +725,10 @@ export default function main(
)
.mapTo( { category: 'recent', method: 'GET', path: '/mempool/recent', bg: true })

// refresh pending peg transactions on the standard cadence
, !showPegData ? O.empty() :
pollViewing(pollIntervalsMs.standard, 'dashBoard', view$)
.mapTo({ category: 'dashboard-peg-mempool-txs', method: 'GET', path: `/asset/${nativeAssetId}/txs/mempool`, bg: true })

// the market chart contains hourly samples and uses the slow cadence
, pollViewing(pollIntervalsMs.slow, 'dashBoard', view$)
.mapTo({ category: 'bitcoin-market-chart', method: 'GET', path: bitcoinMarketChartUrl, bg: true })

// confirmed peg state changes only when a new block arrives
, !showPegData ? O.empty() :
dashboardNewBlock$.flatMap(_ =>
[{ category: 'dashboard-peg-asset', method: 'GET', path: `/asset/${nativeAssetId}`, bg: true }
, { category: 'dashboard-peg-chain-txs', method: 'GET', path: `/asset/${nativeAssetId}/txs/chain`, bg: true }])

// Refresh the pending block template while the dashboard remains open. A new
// tip resets the cadence and waits for electrs' block cache to refresh.
, blockTemplatePoll$
Expand All @@ -783,12 +740,6 @@ export default function main(
, { category: 'mempool', method: 'GET', path: '/mempool' }
, { category: 'bitcoin-market-chart', method: 'GET', path: bitcoinMarketChartUrl, bg: true }])

// fetch peg data only when opening an Elements dashboard
, !showPegData ? O.empty() :
goHome$.flatMap(_ => [{ category: 'dashboard-peg-asset', method: 'GET', path: `/asset/${nativeAssetId}`, bg: true }
, { category: 'dashboard-peg-chain-txs', method: 'GET', path: `/asset/${nativeAssetId}/txs/chain`, bg: true }
, { category: 'dashboard-peg-mempool-txs', method: 'GET', path: `/asset/${nativeAssetId}/txs/mempool`, bg: true }])

// fetch asset stats and USD prices only while viewing the Liquid dashboard
, !showHighValueAssets ? O.empty() :
O.merge(goHome$, pollViewing(pollIntervalsMs.slow, 'dashBoard', view$))
Expand Down
2 changes: 0 additions & 2 deletions client/src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const liquidNativeAssetId = '6f0279e9ed041c3d710a9f57d0c02928416460c4b722ae3457a
export const nativeAssetId = process.env.NATIVE_ASSET_ID || liquidNativeAssetId
export const nativeAssetLabel = process.env.NATIVE_ASSET_LABEL || 'BTC'
export const nativeAssetName = process.env.NATIVE_ASSET_NAME || 'Bitcoin'
export const showPegData = !!process.env.IS_ELEMENTS && process.env.SHOW_PEG_DATA == '1'

export const highValueAssetDefinitions = [
{
Expand Down Expand Up @@ -64,4 +63,3 @@ export const showHighValueAssets = !!process.env.IS_ELEMENTS

// Elements only
export const assetTxsPerPage = 25
export const pegTxsPerPage = 25
27 changes: 0 additions & 27 deletions client/src/lib/peg.js

This file was deleted.

12 changes: 3 additions & 9 deletions client/src/views/home.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import layout from "./layout";
import { blks } from "./blocks";
import { transactions } from "./transactions";
import { pegInfo } from "./peg-info";
import { overview } from "./overview";
import { feeMarket } from "./fee-market";
import difficultyAdjustment from "./difficulty-adjustment";
import { isBitcoinNetwork } from "../lib/network";
import { showHighValueAssets, showPegData } from "../const";
import { showHighValueAssets } from "../const";
import { highValueAssets } from "../components/high-value-assets";

const isTouch = process.browser && "ontouchstart" in window;
Expand All @@ -15,19 +14,14 @@ const homeLayout = (body, { t, activeTab, ...S }) =>
layout(body, { t, isTouch, activeTab, ...S });

export const dashBoard = ({ t, blocks, dashboardState, loading, ...S }) => {
const { dashblocks, dashTxs, peg = {}, highValueAssets: highValueAssetData } = dashboardState || {};
const { dashblocks, dashTxs, highValueAssets: highValueAssetData } = dashboardState || {};

return homeLayout(
<div className="home-page" key="dashBoard">
{overview({ blocks: dashblocks, t, ...S })}
{blks(dashblocks, true, { t, ...S })}
{isBitcoinNetwork ? feeMarket({ t, ...S }) : ""}
<div className="dashboard-transaction-section">
{transactions(dashTxs, true, { t, ...S })}
{showPegData
? pegInfo(peg.asset, peg.txs, { t, ...S, error: peg.error })
: ""}
</div>
{transactions(dashTxs, true, { t, ...S })}
{!isBitcoinNetwork ? feeMarket({ t, ...S }) : ""}
{isBitcoinNetwork
? difficultyAdjustment({ blocks: dashblocks, t, ...S })
Expand Down
Loading
Loading