Resolve manifest via the mystic reference only

Drop the hardcoded MANIFEST_TX_ID fallback from the app, the deploy script
and the metadata prerender. The mystic reference now points at the manifest
that includes arweave-for-ao, so the UI picks up new ships without a code
change.
This commit is contained in:
fn
2026-09-03 16:50:16 +01:00
parent e57f80bad5
commit 3618d0aa2d
4 changed files with 16 additions and 59 deletions

View File

@@ -12,8 +12,7 @@ const DEFAULTS = {
BLOG_SITE_URL: "https://hyperzine.xyz",
BLOG_DEFAULT_DESCRIPTION: "hyperzine",
ARWEAVE_GATEWAY: "https://arweave.net",
MANIFEST_REFERENCE_NAME: "",
MANIFEST_TX_ID: ""
MANIFEST_REFERENCE_NAME: ""
};
const asObject = (value) => (typeof value === "object" && value !== null ? value : null);
@@ -54,8 +53,7 @@ const parseConfig = async () => {
BLOG_SITE_URL: pick("BLOG_SITE_URL"),
BLOG_DEFAULT_DESCRIPTION: pick("BLOG_DEFAULT_DESCRIPTION"),
ARWEAVE_GATEWAY: pick("ARWEAVE_GATEWAY"),
MANIFEST_REFERENCE_NAME: pick("MANIFEST_REFERENCE_NAME"),
MANIFEST_TX_ID: pick("MANIFEST_TX_ID")
MANIFEST_REFERENCE_NAME: pick("MANIFEST_REFERENCE_NAME")
};
};
@@ -121,10 +119,10 @@ const parseManifest = (input) => {
});
};
const fetchManifestPosts = async (manifestTxId) => {
const fetchManifestPosts = async (config, manifestTxId) => {
if (!manifestTxId) return [];
const url = `https://arweave.net/${manifestTxId}`;
const response = await fetch(url, { cache: "no-store" });
const gateway = (config.ARWEAVE_GATEWAY || DEFAULTS.ARWEAVE_GATEWAY).replace(/\/+$/, "");
const response = await fetch(`${gateway}/${manifestTxId}`, { cache: "no-store" });
if (!response.ok) throw new Error(`Manifest fetch failed (${response.status})`);
const payload = await response.json();
const posts = parseManifest(payload);
@@ -132,36 +130,17 @@ const fetchManifestPosts = async (manifestTxId) => {
};
const resolveManifestTxId = async (config) => {
if (config.MANIFEST_REFERENCE_NAME) {
try {
const names = new ReferenceClient({ gateway: config.ARWEAVE_GATEWAY || DEFAULTS.ARWEAVE_GATEWAY });
const value = await names.resolveName(config.MANIFEST_REFERENCE_NAME);
if (typeof value === "string" && value.length > 0) return value;
throw new Error(`Reference ${config.MANIFEST_REFERENCE_NAME} did not resolve to a manifest id`);
} catch (error) {
console.warn(
`[prerender-meta] Falling back to configured manifest; reference ${config.MANIFEST_REFERENCE_NAME} failed: ${error.message}`
);
}
}
return config.MANIFEST_TX_ID;
if (!config.MANIFEST_REFERENCE_NAME) return "";
const names = new ReferenceClient({ gateway: config.ARWEAVE_GATEWAY || DEFAULTS.ARWEAVE_GATEWAY });
const value = await names.resolveName(config.MANIFEST_REFERENCE_NAME);
if (typeof value === "string" && value.length > 0) return value;
throw new Error(`Reference ${config.MANIFEST_REFERENCE_NAME} did not resolve to a manifest id`);
};
const fetchCurrentManifestPosts = async (config) => {
const manifestTxId = await resolveManifestTxId(config);
if (!manifestTxId) return [];
try {
return (await fetchManifestPosts(manifestTxId)).posts;
} catch (error) {
if (!config.MANIFEST_REFERENCE_NAME || manifestTxId === config.MANIFEST_TX_ID) throw error;
console.warn(
`[prerender-meta] Falling back to configured manifest; reference manifest ${manifestTxId} failed: ${error.message}`
);
}
return config.MANIFEST_TX_ID ? (await fetchManifestPosts(config.MANIFEST_TX_ID)).posts : [];
return (await fetchManifestPosts(config, manifestTxId)).posts;
};
const buildMetaTags = ({