More cards
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
import type { Article } from './protocol.ts';
|
||||
|
||||
// Original summaries and verified English Wikipedia page IDs. Not simulated live responses.
|
||||
// Fixed original preview cards for an empty interface; consensus does not mint these.
|
||||
export const STARTER_ARTICLES: Article[] = [
|
||||
{ pageId: 22780, title: 'Octopus', extract: 'An octopus is a soft-bodied marine mollusc with eight arms. These remarkable animals use camouflage, problem-solving, and jet propulsion to navigate their world.', category: 'Nature', revisionId: 0, source: 'offline', url: 'https://en.wikipedia.org/?curid=22780', image: 'https://upload.wikimedia.org/wikipedia/commons/5/57/Octopus2.jpg' },
|
||||
{ pageId: 736, title: 'Albert Einstein', extract: 'Albert Einstein was a theoretical physicist whose work on relativity transformed our understanding of space, time, and gravity. He received the 1921 Nobel Prize in Physics.', category: 'People', revisionId: 0, source: 'offline', url: 'https://en.wikipedia.org/?curid=736', image: 'https://upload.wikimedia.org/wikipedia/commons/2/28/Albert_Einstein_Head_cleaned.jpg' },
|
||||
|
||||
@@ -25,6 +25,29 @@ export interface PageEnrichment {
|
||||
stats: { attention: number | null; depth: number; reach: number };
|
||||
}
|
||||
|
||||
/** Immutable numeric Wikipedia metrics committed to a minted block. */
|
||||
export type MintStatsSnapshot = {
|
||||
capturedAt: string;
|
||||
revisionId: number;
|
||||
pageBytes: number;
|
||||
languageCount: number;
|
||||
languagesTruncated: boolean;
|
||||
pageviews: PageEnrichment['pageviews'];
|
||||
stats: PageEnrichment['stats'];
|
||||
};
|
||||
|
||||
export function snapshotStats(data: PageEnrichment): MintStatsSnapshot {
|
||||
return {
|
||||
capturedAt: new Date().toISOString(),
|
||||
revisionId: data.revisionId,
|
||||
pageBytes: data.pageBytes,
|
||||
languageCount: data.languageCount,
|
||||
languagesTruncated: data.languagesTruncated,
|
||||
pageviews: { ...data.pageviews, months: data.pageviews.months.map(item => ({ ...item })) },
|
||||
stats: { ...data.stats },
|
||||
};
|
||||
}
|
||||
|
||||
/** Attention uses the latest completed month's views, not the six-month total. */
|
||||
export function deriveStats(pageBytes: number, languageCount: number, monthlyViews: number | null): PageEnrichment['stats'] {
|
||||
const score = (value: number, scale: number) => {
|
||||
|
||||
+15
-6
@@ -1,19 +1,21 @@
|
||||
import type { Article } from './protocol.ts';
|
||||
import type { MintStatsSnapshot } from './enrichment.ts';
|
||||
|
||||
export const NETWORK = 'wikideck-randomx-testnet-2' as const;
|
||||
export const NETWORK = 'wikideck-randomx-testnet-4' as const;
|
||||
export const CONSENSUS = {
|
||||
version: 2, targetSeconds: 30, retargetInterval: 10, medianWindow: 11,
|
||||
version: 4, targetSeconds: 30, retargetInterval: 10, medianWindow: 11,
|
||||
commitments: 'sha256-domain-separated-counted-merkle-v1', randomx: '1.2.1', powEndian: 'big',
|
||||
maxFutureSeconds: 120, epochBlocks: 2048, epochDelay: 64,
|
||||
maxTransactions: 64, coinbaseMaturity: 2, maxBlockBytes: 64 * 1024,
|
||||
articleSource: 'wikipedia-random-with-image-and-stats-v1',
|
||||
} as const;
|
||||
export type NftTransfer = {
|
||||
network: typeof NETWORK; chainId: string; cardHash: string; from: string; to: string;
|
||||
sequence: number; publicKey: string; signature: string;
|
||||
};
|
||||
export type BlockHeader = {
|
||||
version: 2; network: typeof NETWORK; chainId: string; height: number;
|
||||
previousHash: string; createdAt: number; article: Article;
|
||||
version: 4; network: typeof NETWORK; chainId: string; height: number;
|
||||
previousHash: string; createdAt: number; article: Article; statsSnapshot: MintStatsSnapshot;
|
||||
owner: string; publicKey: string; nonce: number; target: string; key: string;
|
||||
transactionsRoot: string; stateRoot: string;
|
||||
};
|
||||
@@ -27,7 +29,7 @@ export type NftState = Record<string, { owner: string; sequence: number; mintedH
|
||||
export type TestnetSnapshot = {
|
||||
network: typeof NETWORK; chainId: string; genesis: string; tip: string; cumulativeWork: string;
|
||||
blocks: TestnetBlock[]; transfers: NftTransfer[]; pendingTransfers: NftTransfer[];
|
||||
nextArticle: Article; peers: number; algorithm: 'RandomX'; maturity: number;
|
||||
peers: number; algorithm: 'RandomX'; maturity: number;
|
||||
};
|
||||
export function nftTransferMessage(t: Omit<NftTransfer, 'publicKey' | 'signature'>): string {
|
||||
return JSON.stringify([NETWORK, 'nft-transfer', t.chainId, t.cardHash, t.from, t.to, t.sequence]);
|
||||
@@ -35,9 +37,16 @@ export function nftTransferMessage(t: Omit<NftTransfer, 'publicKey' | 'signature
|
||||
export function articleTuple(a: Article): unknown[] {
|
||||
return [a.pageId, a.revisionId, a.title, a.extract, a.image ?? '', a.url, a.source, a.category];
|
||||
}
|
||||
export function statsSnapshotTuple(s: MintStatsSnapshot): unknown[] {
|
||||
return [s.capturedAt, s.revisionId, s.pageBytes, s.languageCount, s.languagesTruncated,
|
||||
[s.pageviews.status, s.pageviews.months.map(item => [item.month, item.views]), s.pageviews.latestMonth,
|
||||
s.pageviews.total, s.pageviews.dailyAverage, s.pageviews.trendPercent],
|
||||
[s.stats.attention, s.stats.depth, s.stats.reach]];
|
||||
}
|
||||
export function headerMessage(h: BlockHeader): string {
|
||||
return JSON.stringify([NETWORK, h.version, h.chainId, h.height, h.previousHash, h.createdAt,
|
||||
articleTuple(h.article), h.owner, h.publicKey, h.target, h.key, h.transactionsRoot, h.stateRoot]);
|
||||
articleTuple(h.article), statsSnapshotTuple(h.statsSnapshot), h.owner, h.publicKey,
|
||||
h.target, h.key, h.transactionsRoot, h.stateRoot]);
|
||||
}
|
||||
export function blockClaimMessage(hash: string): string {
|
||||
return JSON.stringify([NETWORK, 'block-claim', hash]);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Browser/Node WebCrypto only: this module never reads storage or sends data.
|
||||
const NETWORK = 'wikideck-randomx-testnet-2';
|
||||
const NETWORK = 'wikideck-randomx-testnet-4';
|
||||
const ITERATIONS = 600_000;
|
||||
const MAX_BYTES = 32 * 1024;
|
||||
const encoder = new TextEncoder();
|
||||
@@ -7,7 +7,7 @@ const encoder = new TextEncoder();
|
||||
export type WalletBackup = {
|
||||
format: 'wikideck-wallet-backup';
|
||||
version: 1;
|
||||
network: 'wikideck-randomx-testnet-2';
|
||||
network: 'wikideck-randomx-testnet-4';
|
||||
kdf: 'PBKDF2-SHA256';
|
||||
iterations: 600000;
|
||||
cipher: 'AES-256-GCM';
|
||||
|
||||
Reference in New Issue
Block a user