Use composite domains for sites ENS domains to rely on root domain from .env
This commit is contained in:
parent
c1401b4a6e
commit
b2d65fdd14
@ -30,7 +30,12 @@ export const packageRepos = {
|
||||
"merkle-root-updater": "merkle-root-updater." + packagesDomain,
|
||||
} 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 = [
|
||||
`https://ipfs.io/ipfs/`,
|
||||
|
@ -26,7 +26,9 @@ export async function getENSDomainContenthash(domain: string): Promise<string> {
|
||||
}
|
||||
|
||||
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 ipfsCids = result.reduce((acc, res) => {
|
||||
if (res.status === "rejected") console.error(res.reason);
|
||||
@ -38,12 +40,12 @@ export async function getV1Cids(domains: Domains): Promise<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.`);
|
||||
try {
|
||||
await git.clone(knownIpfsResources[retryAttempt] + repoHash, path.join(repoFolder, repoName));
|
||||
await git.clone(knownIpfsResources[retryAttempt] + repoHash, path.join(reposFolder, repoName));
|
||||
} catch (e) {
|
||||
console.error(`Cannot download ${repoName} from ${knownIpfsResources[retryAttempt]}, retry with other gateaway...`);
|
||||
downloadGitRepoFromIpfs(repoFolder, repoName, repoHash, retryAttempt++);
|
||||
downloadGitRepoFromIpfs(reposFolder, repoName, repoHash, retryAttempt++);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user