Files
explore/next.config.js
T
zeekay 2abb742d55 feat(explore): fee burn + staking rewards panel, from one balance
creditTxFee credits floor(fee/2) to the fee reward vault 0x0100..0002 and leaves
the rest credited to no account at all. The vault has no code and no key, so its
balance only grows, and it is BOTH counters at once: rewards accrued exactly, and
supply burned to within one wei per transaction. One eth_getBalance is the whole
data set — no indexer, no event log, no receipts. That is the panel.

Reads are one batched JSON-RPC round trip (vault balance, coinbase balance, head
block, eth_getChainConfig), polled every 30s.

Decimals: the divisor is 10^18, NOT 10^9. nLUX is the P-Chain staking unit; this
is a C-Chain EVM balance from eth_getBalance, i.e. wei, and it goes through the
one canonical path (NativeCoinValue -> config.chain.currency.decimals). Pinned by
a test against live mainnet: the coinbase holds 3867543864740765677447 wei =
3,867.54 LUX. At 10^9 it would print 3.87 trillion LUX, about double the supply.
Same class of bug as 1b6e86a16, one billion times larger.

Honest about the zero. Mainnet's config has no feeSplitTimestamp, so the split has
never fired and nothing is deflationary. The panel says exactly that, tags itself
"Not active", and shows where the fees really go: the coinbase 0x0100..0000, which
has no code and no key either, so its 3,867 LUX is stranded, not burned.

Two traps the tests pin:
  - The gate reads the HEAD BLOCK's timestamp, mirroring IsFeeSplit(blockTime).
    Devnet's feeSplitTimestamp has passed in wall-clock terms while its C-Chain
    sits at height 0 — wall clock would report a burn that never happened.
  - Burn is zero before activation, never the raw vault balance. The vault is a
    plain account; anyone can transfer into it, and calling that "burned" invents
    the deflation this panel exists to report honestly. Unverifiable state prints
    a dash, never a zero.

It lives on the home overview, not /stats: guards.stats 404s the whole /stats
route when the stats microservice is not configured, and burn is a chain fact that
owes nothing to an indexer. Not gated on the primary network either — it reads
whichever chain it is pointed at and reports that chain's own state.

Chart: the vault balance sampled once per new block, deduplicated on block number
and capped at 240 points. There is no cheaper honest source — the nodes prune, so
eth_getBalance one block back already answers "missing trie node", and
api-explore.lux.network serves 404 for every path including /.

next.config.js: `next dev` runs Turbopack, which never read the webpack() block, so
every `import Icon from 'icons/*.svg'` resolved to a static-image object and React
threw "Element type is invalid ... but got: object" — Hint, ChartWidget,
toolkit/next/link and BackToButton all import SVGs directly, so the dev server had
been rendering an error page instead of the app. Same loader, declared for both
bundlers.

Verified against live mainnet 96369 in a real browser, not by HTTP status:
  panel renders "Not active", "LUX burned 0", "Staking rewards accrued 0",
  "Held by the fee coinbase 3,867.5496 LUX", "read at block #1,098,193";
  exactly one batched RPC call carrying all four methods; 0px mobile overflow.
The active and scheduled branches, which mainnet cannot exercise, were driven with
a stubbed RPC: "Active" copy, both counters at the vault balance, coinbase card
correctly hidden, and the chart drawing after three samples.

17 unit tests, 288 in the suite, all green. Typecheck unchanged at 223
pre-existing errors, none in these files.
2026-07-27 12:25:48 -07:00

86 lines
3.0 KiB
JavaScript

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.BUNDLE_ANALYZER === 'true',
});
const withRoutes = require('nextjs-routes/config')({
outDir: 'nextjs',
});
const headers = require('./nextjs/headers');
const redirects = require('./nextjs/redirects');
const rewrites = require('./nextjs/rewrites');
/** @type {import('next').NextConfig} */
const moduleExports = {
transpilePackages: [
'react-syntax-highlighter',
'@luxfi/ui',
'@hanzogui/core',
'@hanzogui/tooltip',
'@hanzogui/popover',
'@hanzogui/text',
'@hanzogui/dialog',
'@hanzogui/web',
],
reactStrictMode: true,
// `next dev` runs Turbopack, which does not read the webpack() block below, so
// every `import Icon from 'icons/*.svg'` resolved to a static-image OBJECT and
// React threw "Element type is invalid … but got: object". That crashed the
// whole page for any component importing an SVG directly — Hint, ChartWidget,
// toolkit/next/link, FilterInput, BackToButton — i.e. most of the app, in dev
// only. Same loader, declared once per bundler, so dev renders what prod ships.
turbopack: {
rules: {
'*.svg': { loaders: [ '@svgr/webpack' ], as: '*.js' },
},
},
webpack(config) {
config.module.rules.push(
{
test: /\.svg$/,
use: [ '@svgr/webpack' ],
},
);
config.resolve.fallback = { fs: false, net: false, tls: false, async_hooks: false };
config.resolve.alias = {
...config.resolve.alias,
// MetaMask SDK tries to import this RN module; stub it out for web.
'@react-native-async-storage/async-storage': false,
};
config.externals.push('pino-pretty', 'lokijs', 'encoding');
config.experiments = { ...config.experiments, topLevelAwait: true };
// Tell webpack the target supports async/await so it stops warning about top-level await
// Top-level await is belong to ES2017 specification that is adopted by all major browsers and Node.js.
config.output.environment = {
...config.output.environment,
asyncFunction: true,
};
return config;
},
// NOTE: all config functions should be static and not depend on any environment variables
// since all variables will be passed to the app only at runtime and there is now way to change Next.js config at this time
// if you are stuck and strongly believe what you need some sort of flexibility here please fill free to join the discussion
// https://github.com/blockscout/frontend/discussions/167
rewrites,
redirects,
headers,
typescript: {
// @luxfi/ui + @hanzogui type mismatches with existing codebase.
ignoreBuildErrors: true,
},
output: 'standalone',
outputFileTracingRoot: __dirname,
productionBrowserSourceMaps: false,
serverExternalPackages: ["@opentelemetry/sdk-node", "@opentelemetry/auto-instrumentations-node"],
experimental: {
staleTimes: {
dynamic: 30,
'static': 180,
},
},
};
module.exports = withBundleAnalyzer(withRoutes(moduleExports));