Skip to content
Open
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
6 changes: 4 additions & 2 deletions client/src/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '@babel/polyfill'
import { Observable as O } from './rxjs'
import { asap } from 'rxjs/scheduler/asap'
import {setAdapt} from '@cycle/run/lib/adapt';

import { getMempoolDepth, getConfEstimate, calcSegwitFeeGains } from './lib/fees'
Expand Down Expand Up @@ -957,8 +958,9 @@ export default function main(
, moreSTxs$.map(d => ({ category: 'asset-txs-more', method: 'GET', path: `/asset/${d.asset_id}/txs/chain/${d.last_txid}` }))
).map(setBase)

// DOM sink
, vdom$ = state$.map(S => S.view && views[S.view](S) || null)
// A route change emits several intermediate states in one turn. Render the settled state.
, renderState$ = process.browser ? state$.auditTime(0, asap) : state$
, vdom$ = renderState$.map(S => S.view && views[S.view](S) || null)

// localStorage sink
, store$ = O.merge(
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/info-stat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const InfoStat = ({ title, value } = {}) => (
export const InfoStat = ({ title, value, valueTitle } = {}) => (
<div className="info-stat">
<div className="info-stat-title">{title}</div>
<div className="info-stat-value">{value}</div>
<div className="info-stat-value" attrs={valueTitle ? { title: valueTitle } : {}}>{value}</div>
</div>
);
1 change: 1 addition & 0 deletions client/src/rxjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'rxjs/add/observable/timer'
import 'rxjs/add/observable/fromEvent'
import 'rxjs/add/observable/from'

import 'rxjs/add/operator/auditTime'
import 'rxjs/add/operator/filter'
import 'rxjs/add/operator/map'
import 'rxjs/add/operator/mapTo'
Expand Down
48 changes: 38 additions & 10 deletions client/src/views/addr.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { last } from "../util";
import layout from "./layout";
import { txBox } from "./tx";
import { formatSat, formatSatWithUsd, formatNumber } from "./util";
import { formatSat, formatSatWithUsd, formatNumber, formatUsd, satsToUsd } from "./util";
import { addrTxsPerPage as perPage, maxMempoolTxs } from "../const";
import loader from "../components/loading";
import { AddressHamburgerIcon, CopyIcon } from "../components/icons";
Expand Down Expand Up @@ -71,7 +71,7 @@ export default ({
[
<div className="addr-page">
<div className="table address-table">
<div>
<div className="address-summary">
<div className="table-header">
<div className="table-header-icon-container">
<AddressHamburgerIcon />
Expand Down Expand Up @@ -103,10 +103,12 @@ export default ({
<InfoStat
title={t`Total tx count`}
value={formatNumber(total_txs)}
valueTitle={formatNumber(total_txs)}
/>
<InfoStat
title={t`Confirmed tx count`}
value={formatNumber(chain_stats.tx_count)}
valueTitle={formatNumber(chain_stats.tx_count)}
/>
<InfoStat
title={t`Confirmed received`}
Expand All @@ -116,6 +118,12 @@ export default ({
t,
S,
)}
valueTitle={txosText(
chain_stats.funded_txo_count,
chain_stats.funded_txo_sum,
t,
S,
)}
/>
<InfoStat
title={t`Confirmed spent`}
Expand All @@ -125,10 +133,17 @@ export default ({
t,
S,
)}
valueTitle={txosText(
chain_stats.spent_txo_count,
chain_stats.spent_txo_sum,
t,
S,
)}
/>
<InfoStat
title={t`Confirmed unspent`}
value={fmtTxos(chain_utxo_count, chain_utxo_sum, t, S)}
valueTitle={txosText(chain_utxo_count, chain_utxo_sum, t, S)}
/>
</div>
</div>
Expand Down Expand Up @@ -232,9 +247,23 @@ export default ({
);
};

const outputsLabel = (count, t) =>
count > 0 ? t`${formatNumber(count)} outputs` : t`No outputs`;

const txosText = (count, sum, t, S) => {
const outputs = outputsLabel(count, t);

if (!Number.isFinite(sum)) return outputs;
if (count <= 0) return outputs;

const usd = isBitcoinOrLiquidMainnet ? satsToUsd(sum, S.bitcoinPrice) : null;
const amount = `${formatSat(sum)} (${outputs})`;

return usd == null ? amount : `${amount}\n${formatUsd(usd)}`;
};

const fmtTxos = (count, sum, t, S, usdBelowOutputs = false) => {
const outputs =
count > 0 ? t`${formatNumber(count)} outputs` : t`No outputs`;
const outputs = outputsLabel(count, t);

if (!Number.isFinite(sum)) return outputs;
if (count <= 0) return outputs;
Expand All @@ -252,12 +281,11 @@ const fmtTxos = (count, sum, t, S, usdBelowOutputs = false) => {
</span>
);

return (
<span className="address-output-summary">
{formatSatWithUsd(sum, { t, ...S })}
<span className="address-output-count">({outputs})</span>
</span>
);
return formatSatWithUsd(sum, { t, ...S }, [
<span className="address-output-amount">{formatSat(sum)}</span>,
" ",
<span className="address-output-count">({outputs})</span>,
]);
};

const pagingNav = (
Expand Down
18 changes: 10 additions & 8 deletions client/src/views/pending-block-details-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,17 @@ const PendingBlockDetailsCard = ({

<div className="pending-block-details">
<div className="pending-block-details-card-header">
<p className="block-number">{t`Next Block`}</p>
<div className="pending-block-details-card-heading">
<p className="block-number">{t`Next Block`}</p>

<p className="pending-block-timestamp">
{block ? (
<ExpectedBlockTime timestamp={block.timestamp} t={t} />
) : (
"-"
)}
</p>
<p className="pending-block-timestamp">
{block ? (
<ExpectedBlockTime timestamp={block.timestamp} t={t} />
) : (
"-"
)}
</p>
</div>
<button
aria-expanded={detailsOpen ? "true" : "false"}
className="pending-block-details-button"
Expand Down
9 changes: 6 additions & 3 deletions client/src/views/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ export const formatUsd = (value, fallback='N/A') =>
})} USD`
: fallback

export const satsToUsd = (satoshis, bitcoinPrice) =>
Number.isFinite(satoshis) && Number.isFinite(bitcoinPrice) && bitcoinPrice >= 0
? (satoshis / satoshisPerBitcoin) * bitcoinPrice
: null

// Without a price, leave the USD line blank instead of an N/A line per amount.
export const formatSatWithUsd = (sats, { bitcoinPrice, t } = {}, primary = formatSat(sats)) => {
if (!isBitcoinOrLiquidMainnet) return primary
Expand All @@ -50,9 +55,7 @@ export const formatSatWithUsd = (sats, { bitcoinPrice, t } = {}, primary = forma
return <AmountWithUsd primary={primary} secondary={t ? t`N/A` : 'N/A'} />
}

const usd = Number.isFinite(satoshis) && Number.isFinite(bitcoinPrice) && bitcoinPrice >= 0
? (satoshis / satoshisPerBitcoin) * bitcoinPrice
: null
const usd = satsToUsd(satoshis, bitcoinPrice)

return <AmountWithUsd primary={primary} secondary={usd == null ? null : formatUsd(usd)} />
}
Expand Down
95 changes: 95 additions & 0 deletions scripts/subset-fonts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env python3
"""Split Inter into per-script WOFF2 subsets and write their @font-face rules.

Browsers only download the subsets whose unicode-range matches text on the
page, so most visits fetch the Latin file alone. Every glyph, weight and
OpenType feature of the source font is kept in exactly one subset; to use a
new weight or feature, update the CSS, not this script.

Requires fonttools and brotli (pip install fonttools brotli). The generated
files are committed, so builds do not need Python. Re-run after replacing the
source font:

python3 scripts/subset-fonts.py
"""

from pathlib import Path

from fontTools import subset
from fontTools.ttLib import TTFont

root = Path(__file__).resolve().parent.parent
source = root / "font-sources/Inter-VariableFont_opsz,wght.ttf"
output_dir = root / "www/font/Inter"
css_path = root / "www/css/foundation/fonts-inter.css"

# Ranges follow the Google Fonts subsets for Inter. "symbols" collects every
# remaining code point in the font so nothing falls back to a system font.
# Symbols rendered by the UI (≤, the ⌘ search hint and the ▲▼ sort arrows) are
# added to "latin" so the larger symbols subset is not downloaded for them.
subsets = {
"latin": "0000-00FF,0131,0152-0153,02BB-02BC,02C6,02DA,02DC,0304,0308,0329,"
"2000-206F,20AC,2122,2191,2193,2212,2215,2264,2318,25B2,25BC,FEFF,FFFD",
"latin-ext": "0100-02BA,02BD-02C5,02C7-02CC,02CE-02D7,02DD-02FF,0304,0308,0329,"
"1D00-1DBF,1E00-1E9F,1EA0-1EF9,1EF2-1EFF,2020,20A0-20AB,20AD-20C0,"
"2113,2C60-2C7F,A720-A7FF",
"cyrillic": "0301,0400-052F,1C80-1C8A,20B4,2116,2DE0-2DFF,A640-A69F,FE2E-FE2F",
"greek": "0370-0377,037A-037F,0384-038A,038C,038E-03A1,03A3-03FF,1F00-1FFF",
}


def parse_ranges(ranges):
codepoints = set()
for part in ranges.split(","):
start, _, end = part.partition("-")
codepoints.update(range(int(start, 16), int(end or start, 16) + 1))
return codepoints


def format_ranges(codepoints):
ranges = []
for codepoint in sorted(codepoints):
if ranges and codepoint == ranges[-1][1] + 1:
ranges[-1][1] = codepoint
else:
ranges.append([codepoint, codepoint])
return ", ".join(f"U+{start:04X}" if start == end else f"U+{start:04X}-{end:04X}"
for start, end in ranges)


def main():
font = TTFont(source)
available = set(font.getBestCmap())
weight = next(axis for axis in font["fvar"].axes if axis.axisTag == "wght")
ranges = {name: parse_ranges(value) & available for name, value in subsets.items()}
ranges["symbols"] = available - set().union(*ranges.values())

output_dir.mkdir(parents=True, exist_ok=True)
rules = []
for name, codepoints in ranges.items():
filename = f"inter-{name}.woff2"
options = subset.Options(layout_features=["*"], name_IDs=["*"],
name_languages=["*"], notdef_outline=True)
subset_font = TTFont(source)
subsetter = subset.Subsetter(options)
subsetter.populate(unicodes=codepoints)
subsetter.subset(subset_font)
subset_font.flavor = "woff2"
subset_font.save(output_dir / filename)
rules.append(f"""/* {name} */
@font-face {{
font-family: Inter;
font-style: normal;
font-weight: {weight.minValue:g} {weight.maxValue:g};
font-display: swap;
src: url("font/Inter/{filename}") format("woff2");
unicode-range: {format_ranges(codepoints)};
}}
""")

css_path.write_text("/* Generated by scripts/subset-fonts.py. Do not edit by hand. */\n\n"
+ "\n".join(rules))


if __name__ == "__main__":
main()
25 changes: 25 additions & 0 deletions www/css/components/pending-block-details-card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.pending-block-details-card-header {
display: flex;
gap: 8px;
align-items: center;
min-height: 20px;
}

/* The heading wraps internally so the Details button keeps its own column. */
.pending-block-details-card-heading {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0px 8px;
min-width: 0;
}

.pending-block-timestamp {
display: flex;
align-items: center;
gap: 8px;
margin: 0;
color: var(--foreground-muted);
font-size: 14px;
font-weight: 400;
}
51 changes: 51 additions & 0 deletions www/css/foundation/fonts-inter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Generated by scripts/subset-fonts.py. Do not edit by hand. */

/* latin */
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("font/Inter/inter-latin.woff2") format("woff2");
unicode-range: U+0000, U+0020-007E, U+00A0-00AC, U+00AE-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+2000-200B, U+2010-2027, U+202F-2055, U+2057, U+205F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2264, U+2318, U+25B2, U+25BC, U+FEFF;
}

/* latin-ext */
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("font/Inter/inter-latin-ext.woff2") format("woff2");
unicode-range: U+0100-0148, U+014A-01C3, U+01C5-0254, U+0256-027B, U+027E-0284, U+0286-0290, U+0292-02A4, U+02A6-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+1D00, U+1D0D, U+1D1B, U+1D43, U+1D47-1D49, U+1D4D, U+1D4F-1D50, U+1D52, U+1D56-1D58, U+1D5B, U+1D62-1D65, U+1D9C, U+1DA0, U+1DBB, U+1DBF, U+1E00-1E9B, U+1E9D-1EFF, U+2020, U+20A0-20AB, U+20AD-20AF, U+20B1-20B5, U+20B8-20BA, U+20BC-20BF, U+2113, U+2C7C, U+2C7F, U+A7FF;
}

/* cyrillic */
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("font/Inter/inter-cyrillic.woff2") format("woff2");
unicode-range: U+0301, U+0400-0479, U+0480-049D, U+04A0-04FF, U+052F, U+20B4, U+2116, U+2DFF, U+A69F;
}

/* greek */
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("font/Inter/inter-greek.woff2") format("woff2");
unicode-range: U+0374-0376, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03D7, U+03DC-03DD, U+03F0-03F6, U+03F9-03FA, U+03FC-03FF, U+1F00-1F15, U+1F18-1F1D, U+1F20-1F45, U+1F48-1F4D, U+1F50-1F57, U+1F59, U+1F5B, U+1F5D, U+1F5F-1F7D, U+1F80-1FB4, U+1FB6-1FC4, U+1FC6-1FD3, U+1FD6-1FDB, U+1FDD-1FEF, U+1FF2-1FF4, U+1FF6-1FFE;
}

/* symbols */
@font-face {
font-family: Inter;
font-style: normal;
font-weight: 100 900;
font-display: swap;
src: url("font/Inter/inter-symbols.woff2") format("woff2");
unicode-range: U+02CD, U+02D8-02D9, U+02DB, U+0300, U+0302-0303, U+0306-0307, U+0309-030A, U+030C, U+030F, U+0313, U+0315, U+031B, U+0323, U+0326-0328, U+032C, U+0337-0338, U+0342-0343, U+0346-036F, U+0E3F, U+1DC0-1DF5, U+1DFC-1DFF, U+2070-2071, U+2074-208E, U+2090-209C, U+20DB-20DE, U+20E8, U+20F0, U+2100-2101, U+2103, U+2105-2106, U+2109, U+2117, U+211E-2121, U+2126, U+212A-212B, U+212E, U+2132, U+213B, U+214D, U+2150-217F, U+2183-2186, U+2189, U+2190, U+2192, U+2194-2199, U+21A9-21AA, U+21B0-21B1, U+21B3-21B5, U+21BA-21BB, U+21D0, U+21D2, U+21D4, U+21DE-21DF, U+21E4-21E5, U+21E7, U+21EA, U+2202, U+2205-2206, U+220F, U+2211, U+221A, U+221E, U+222B, U+2236, U+2248, U+2260, U+2265, U+2295-2298, U+2303-2305, U+2325-2327, U+232B, U+2380, U+2387, U+238B, U+23CE-23CF, U+2423, U+2460-2468, U+24B6-24CF, U+24EA, U+25A0-25A2, U+25AA, U+25B3, U+25B6-25B7, U+25BA-25BB, U+25BD, U+25C0-25C1, U+25C4-25C7, U+25CA-25CB, U+25CF, U+25E6, U+25EF, U+2600, U+2605-2606, U+263C, U+2661, U+2665, U+26A0, U+2713, U+2717, U+2756, U+2764, U+2780-2788, U+27EF, U+27F5-27FA, U+2913, U+2A38, U+2B06, U+2B12-2B13, U+2B1C, U+2B24, U+2E18, U+A92E, U+E000, U+E002-E05E, U+E06A-E0BD, U+E0C8-E0CC, U+E0DC-E0E6, U+E0F3-E0F5, U+E106, U+E109-E10A, U+E10C-E10F, U+E111-E113, U+E117-E118, U+E121-E122, U+E124, U+E12A-E15E, U+E163, U+E1C3, U+E1D2-E1DF, U+E1E1-E2DC, U+EE01-EE07, U+EE09-EE0A, U+EE0C-EE12, U+EE14, U+EE17, U+EE1D-EE45, U+EE47-EE84, U+EE87-EED6, U+EED8-EEE1, U+F6C3, U+1F12F-1F149, U+1F16A-1F16B, U+1F850, U+1F852;
}
Loading