Skip to content

Commit 20423ac

Browse files
committed
Merge main into escrow formatting
2 parents 1211cbc + 4e0954f commit 20423ac

21 files changed

Lines changed: 741 additions & 32 deletions

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dev": "vite",
99
"build": "vite build",
1010
"preview": "vite preview",
11-
"test": "node --import tsx --test src/demo/trace-health-check.test.ts src/lib/config.test.ts src/lib/chain.test.ts src/dashboard/fixture-health-check.test.ts src/lib/round-status.test.ts src/components/dashboard/RoundStatusCard.test.tsx",
11+
"test": "node --import tsx --test src/demo/trace-health-check.test.ts src/lib/config.test.ts src/lib/chain.test.ts src/dashboard/fixture-health-check.test.ts src/lib/round-status.test.ts src/components/dashboard/RoundStatusCard.test.tsx src/hooks/useDashboardData.test.ts",
1212
"typecheck": "tsc --noEmit -p tsconfig.json"
1313
},
1414
"dependencies": {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import assert from "node:assert/strict";
2+
import { test } from "node:test";
3+
4+
import { isStale } from "./useDashboardData";
5+
6+
// Mirrors STALE_THRESHOLD_MS in useDashboardData.ts (5 minutes). Kept as a
7+
// local constant rather than imported so these tests pin the *contract*
8+
// (fresh below the threshold, stale above it) without depending on that
9+
// value being exported.
10+
const STALE_THRESHOLD_MS = 5 * 60 * 1000;
11+
const NOW_MS = Date.parse("2026-06-15T12:00:00.000Z");
12+
13+
test("invalid or missing timestamps are treated as stale", () => {
14+
assert.equal(isStale("not-a-date", NOW_MS), true, "unparseable string");
15+
assert.equal(isStale("", NOW_MS), true, "empty string");
16+
assert.equal(isStale("abcdef", NOW_MS), true, "garbage string");
17+
assert.equal(isStale("2026-13-45T00:00:00Z", NOW_MS), true, "invalid calendar date");
18+
assert.equal(isStale(null, NOW_MS), true, "null");
19+
assert.equal(isStale(undefined, NOW_MS), true, "undefined");
20+
});
21+
22+
test("valid fresh timestamps are not stale", () => {
23+
const fetchedAt = new Date(NOW_MS - 30_000).toISOString(); // 30s ago
24+
assert.equal(isStale(fetchedAt, NOW_MS), false);
25+
});
26+
27+
test("valid old timestamps beyond the threshold are stale", () => {
28+
const fetchedAt = new Date(NOW_MS - STALE_THRESHOLD_MS - 60_000).toISOString(); // 6 min ago
29+
assert.equal(isStale(fetchedAt, NOW_MS), true);
30+
});
31+
32+
test("a timestamp equal to now is fresh", () => {
33+
const fetchedAt = new Date(NOW_MS).toISOString();
34+
assert.equal(isStale(fetchedAt, NOW_MS), false);
35+
});
36+
37+
test("a future timestamp is fresh (unchanged pre-existing behavior)", () => {
38+
const fetchedAt = new Date(NOW_MS + 60_000).toISOString(); // 1 min in the future
39+
assert.equal(isStale(fetchedAt, NOW_MS), false);
40+
});
41+
42+
test("boundary: exactly at the stale threshold is still fresh (strict greater-than)", () => {
43+
const fetchedAt = new Date(NOW_MS - STALE_THRESHOLD_MS).toISOString();
44+
assert.equal(isStale(fetchedAt, NOW_MS), false);
45+
});
46+
47+
test("boundary: one millisecond past the stale threshold is stale", () => {
48+
const fetchedAt = new Date(NOW_MS - STALE_THRESHOLD_MS - 1).toISOString();
49+
assert.equal(isStale(fetchedAt, NOW_MS), true);
50+
});
51+
52+
test("boundary: one millisecond inside the stale threshold is fresh", () => {
53+
const fetchedAt = new Date(NOW_MS - STALE_THRESHOLD_MS + 1).toISOString();
54+
assert.equal(isStale(fetchedAt, NOW_MS), false);
55+
});

apps/web/src/hooks/useDashboardData.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,27 @@ export interface UseDashboardDataResult {
1616
refetch: () => void;
1717
}
1818

19-
function isStale(fetchedAt: string, nowMs: number): boolean {
19+
/**
20+
* Determine whether dashboard data fetched at `fetchedAt` should be treated
21+
* as stale relative to `nowMs`.
22+
*
23+
* A missing or unparseable `fetchedAt` is treated as stale rather than
24+
* fresh: `Date.parse()` returns `NaN` for invalid input, and every
25+
* comparison against `NaN` (including `>`) evaluates to `false` in
26+
* JavaScript -- so without an explicit check, malformed timestamp data
27+
* would silently be reported as fresh instead of triggering the staleness
28+
* warning it's meant to guard against.
29+
*/
30+
export function isStale(fetchedAt: string | null | undefined, nowMs: number): boolean {
31+
if (!fetchedAt) {
32+
return true;
33+
}
34+
2035
const fetchedTime = Date.parse(fetchedAt);
36+
if (!Number.isFinite(fetchedTime)) {
37+
return true;
38+
}
39+
2140
return nowMs - fetchedTime > STALE_THRESHOLD_MS;
2241
}
2342

apps/web/src/pages/LandingPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function LandingPage({
4848
<div className="landing-nav-actions">
4949
<span className="landing-status-pill winner">Hack Privacy #1</span>
5050
<span className="landing-status-pill">testnet · live</span>
51-
<a href="https://github.com/karagozemin/Sub-Rosa" target="_blank" rel="noreferrer">
51+
<a href="https://github.com/Sub-Rosa-Issue/sub-rosa-issue" target="_blank" rel="noreferrer">
5252
GitHub
5353
</a>
5454
<a href="#/dashboard" className="secondary-action compact">

docs/CV_LABS_APPLICATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ twice.
213213

214214
## Evidence Links
215215

216-
- Repository: https://github.com/karagozemin/Sub-Rosa
216+
- Repository: https://github.com/Sub-Rosa-Issue/sub-rosa-issue
217217
- Mainnet contract:
218218
https://stellar.expert/explorer/public/contract/CA7KSDEYJEPGZEB2ZROTLUWKQQ6GIRIQNGG6Z745MZ34QHP4UJPWODEX
219219
- SCF #44 round:

docs/INSTAWARDS_SOW.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
### Supporting Links (Existing Work)
2424

25-
- GitHub repo: https://github.com/karagozemin/Sub-Rosa
25+
- GitHub repo: https://github.com/Sub-Rosa-Issue/sub-rosa-issue
2626
- Live demo: https://sub-rosa-web.vercel.app
2727
- Demo video: https://youtu.be/NDuR5B2ztQo
28-
- Architecture: https://github.com/karagozemin/Sub-Rosa/blob/main/ARCHITECTURE.md
28+
- Architecture: https://github.com/Sub-Rosa-Issue/sub-rosa-issue/blob/main/ARCHITECTURE.md
2929
- Pitch deck: https://gamma.app/docs/SUB-ROSA-g8o9ulvc7nezz4j?mode=doc
3030

3131
---

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,15 @@
4040
"mainnet:verify": "bash packages/sdk/scripts/mainnet-verify.sh",
4141
"mainnet:micro": "bash packages/sdk/scripts/mainnet-micro.sh",
4242
"tlock:test": "pnpm --filter @sub-rosa/tlock test",
43+
"tlock:typecheck": "pnpm --filter @sub-rosa/tlock typecheck",
44+
"drand-tools:test": "pnpm --filter @sub-rosa/drand-tools test",
45+
"drand-tools:typecheck": "pnpm --filter @sub-rosa/drand-tools typecheck",
4346
"keeper:test": "pnpm --filter @sub-rosa/keeper test",
47+
"keeper:typecheck": "pnpm --filter @sub-rosa/keeper typecheck",
4448
"keeper:e2e": "bash services/keeper/scripts/keeper-e2e.sh",
4549
"keeper:watch": "pnpm --filter @sub-rosa/keeper watch",
50+
"receipt-cli:test": "pnpm --filter @sub-rosa/receipt-cli test",
51+
"receipt-cli:typecheck": "pnpm --filter @sub-rosa/receipt-cli typecheck",
4652
"lifecycle:e2e": "bash services/keeper/scripts/lifecycle-e2e.sh",
4753
"appraisal:test": "pnpm --filter @sub-rosa/appraisal-api test",
4854
"appraisal:typecheck": "pnpm --filter @sub-rosa/appraisal-api typecheck",
@@ -53,6 +59,7 @@
5359
"agents:e2e": "bash services/agent/scripts/agents-e2e.sh",
5460
"template:fixture": "pnpm --filter @sub-rosa/auction-template fixture",
5561
"template:testnet": "bash services/auction-template/testnet.sh",
62+
"template:test": "pnpm --filter @sub-rosa/auction-template test",
5663
"template:typecheck": "pnpm --filter @sub-rosa/auction-template typecheck",
5764
"web:dev": "pnpm --filter @sub-rosa/web dev",
5865
"web:build": "pnpm --filter @sub-rosa/web build",

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"repository": {
1717
"type": "git",
18-
"url": "https://github.com/karagozemin/Sub-Rosa.git",
18+
"url": "https://github.com/Sub-Rosa-Issue/sub-rosa-issue.git",
1919
"directory": "packages/sdk"
2020
},
2121
"main": "src/index.ts",

packages/tlock/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
],
1616
"repository": {
1717
"type": "git",
18-
"url": "https://github.com/karagozemin/Sub-Rosa.git",
18+
"url": "https://github.com/Sub-Rosa-Issue/sub-rosa-issue.git",
1919
"directory": "packages/tlock"
2020
},
2121
"main": "src/index.ts",
2222
"scripts": {
23-
"test": "node --import tsx --test src/commitment.test.ts src/payload.test.ts src/auditor.test.ts src/auditor-recovery-cli.test.ts src/bls.test.ts src/seal.test.ts src/freshness.test.ts src/quicknet.test.ts",
23+
"test": "node --import tsx --test src/commitment.test.ts src/payload.test.ts src/auditor.test.ts src/auditor-recovery-cli.test.ts src/bls.test.ts src/seal.test.ts src/freshness.test.ts src/quicknet.test.ts src/validate.test.ts",
2424
"test:quicknet": "node --import tsx --test src/quicknet.test.ts",
25-
"test:unit": "node --import tsx --test src/commitment.test.ts src/payload.test.ts src/auditor.test.ts src/auditor-recovery-cli.test.ts src/bls.test.ts src/freshness.test.ts src/quicknet.test.ts",
25+
"test:unit": "node --import tsx --test src/commitment.test.ts src/payload.test.ts src/auditor.test.ts src/auditor-recovery-cli.test.ts src/bls.test.ts src/freshness.test.ts src/quicknet.test.ts src/validate.test.ts",
2626
"test:seal": "node --import tsx --test src/seal.test.ts",
2727
"recover:identities": "node --import tsx src/recover-identities.cli.ts",
2828
"typecheck": "tsc --noEmit -p tsconfig.json"

packages/tlock/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ export {
3434

3535
export { drandSignatureToSoroban, encodeG1Soroban } from "./bls.js";
3636

37+
export {
38+
assertChainInfo,
39+
assertBeacon,
40+
type RawChainInfo,
41+
type RawBeacon,
42+
} from "./validate.js";
43+
3744
export {
3845
sealBid,
3946
openBid,

0 commit comments

Comments
 (0)