Use composite domains for sites ENS domains to rely on root domain from .env

This commit is contained in:
Theo 2023-10-05 14:23:16 -07:00
parent c1401b4a6e
commit b2d65fdd14
2 changed files with 12 additions and 5 deletions

@ -30,7 +30,12 @@ export const packageRepos = {
"merkle-root-updater": "merkle-root-updater." + packagesDomain, "merkle-root-updater": "merkle-root-updater." + packagesDomain,
} as const; } as const;
export const sitesENS = ["tornadocash.eth", "nova.tornadocash.eth", "relayers-ui.tornadocash.eth", "docs.tornadocash.eth"] as const; export const sitesENS = [
rootTornadoDomain,
"nova." + rootTornadoDomain,
"relayers-ui." + rootTornadoDomain,
"docs." + rootTornadoDomain,
] as const;
export const knownIpfsResources = [ export const knownIpfsResources = [
`https://ipfs.io/ipfs/`, `https://ipfs.io/ipfs/`,

@ -26,7 +26,9 @@ export async function getENSDomainContenthash(domain: string): Promise<string> {
} }
export async function getV1Cids(domains: Domains): Promise<IPFSCids> { export async function getV1Cids(domains: Domains): Promise<IPFSCids> {
const promises = Object.entries(domains).map(([repoName, domain]) => (async () => [repoName, await getENSDomainContenthash(domain)])()); const promises = Object.entries(domains).map(([repoName, domain]) =>
(async () => [repoName, await getENSDomainContenthash(domain as string)])()
);
const result = await Promise.allSettled(promises); const result = await Promise.allSettled(promises);
const ipfsCids = result.reduce((acc, res) => { const ipfsCids = result.reduce((acc, res) => {
if (res.status === "rejected") console.error(res.reason); if (res.status === "rejected") console.error(res.reason);
@ -38,12 +40,12 @@ export async function getV1Cids(domains: Domains): Promise<IPFSCids> {
return ipfsCids; return ipfsCids;
} }
export async function downloadGitRepoFromIpfs(repoFolder: string, repoName: string, repoHash: string, retryAttempt: number = 0) { export async function downloadGitRepoFromIpfs(reposFolder: string, repoName: string, repoHash: string, retryAttempt: number = 0) {
if (retryAttempt > knownIpfsResources.length) return console.error(`Cannot download ${repoName}, all known IPFS gateaways checked.`); if (retryAttempt > knownIpfsResources.length) return console.error(`Cannot download ${repoName}, all known IPFS gateaways checked.`);
try { try {
await git.clone(knownIpfsResources[retryAttempt] + repoHash, path.join(repoFolder, repoName)); await git.clone(knownIpfsResources[retryAttempt] + repoHash, path.join(reposFolder, repoName));
} catch (e) { } catch (e) {
console.error(`Cannot download ${repoName} from ${knownIpfsResources[retryAttempt]}, retry with other gateaway...`); console.error(`Cannot download ${repoName} from ${knownIpfsResources[retryAttempt]}, retry with other gateaway...`);
downloadGitRepoFromIpfs(repoFolder, repoName, repoHash, retryAttempt++); downloadGitRepoFromIpfs(reposFolder, repoName, repoHash, retryAttempt++);
} }
} }