mirror of
https://github.com/selfxyz/self.git
synced 2026-01-13 00:28:17 -05:00
* refactor: use singular ETHERSCAN_API_KEY in .env Etherscan has unified all keys of associated explorers like Celoscan into a singular key rather than different keys for different networks. * refactor: use one .env instead of separate .env.test + .env files * refactor: deploy contracts with runs of 1000 instead of 200 Decreases gas cost of function calls on deployed contracts * clean: remove duplicate/redundant deploy modules + scripts * clean: cleanup empty script file * refactor: cleanup default network of scripts Read network from .env instead of using defaults of alfajores (outdated) or staging * clean: remove references to Alfajores, replace with Sepolia * chore: add default .env variables * chore: update build-all script to include aardhaar circuit * chore: update broken Powers of Tau download link (use iden3) * chore: remove duplicate script * fix: use stable version 18 for disclose circuits * test: update test import paths to allow for .ts version of generateProof * test: fix broken tests * test: uncomment critical code for registration, change error names to updated names, fix broken import paths, update disclose tests for new scope generation/handling * fix: broken import path * test: fix Airdrop tests to use V2 logic * docs: update docs for necessary prerequisite programs * chore: yarn prettier formatting * fix: CI errors occuring when deploying contracts as can't read .env Using a dummy key for CI builds * chore: yarn prettier * refactor: change runs to 100000
74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import * as path from "path";
|
|
import * as fs from "fs";
|
|
|
|
export const ATTESTATION_ID = {
|
|
E_PASSPORT: "0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
EU_ID_CARD: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
};
|
|
|
|
export const ATTESTATION_TO_REGISTRY = {
|
|
E_PASSPORT: "DeployRegistryModule#IdentityRegistry",
|
|
EU_ID_CARD: "DeployIdCardRegistryModule#IdentityRegistry",
|
|
};
|
|
|
|
export const NETWORK_TO_CHAIN_ID: Record<string, string> = {
|
|
localhost: "31337",
|
|
hardhat: "31337",
|
|
celoSepolia: "11142220",
|
|
celo: "42220",
|
|
mainnet: "42220",
|
|
staging: "11142220",
|
|
};
|
|
|
|
export const CHAIN_ID_TO_SAVED_REPO: Record<string, string> = {
|
|
"42220": "prod",
|
|
"11142220": "staging",
|
|
};
|
|
|
|
export const getChainId = (network: string): string => {
|
|
const chainId = NETWORK_TO_CHAIN_ID[network];
|
|
console.log(`Network '${network}' mapped to Chain ID: ${chainId}`);
|
|
return chainId;
|
|
};
|
|
|
|
export const getSavedRepo = (network: string): string => {
|
|
const repoName = CHAIN_ID_TO_SAVED_REPO[NETWORK_TO_CHAIN_ID[network]];
|
|
return repoName;
|
|
};
|
|
|
|
export const getDeployedAddresses = (repoName: string): any => {
|
|
const addresses_path = path.join(__dirname, `../ignition/deployments/${repoName}/deployed_addresses.json`);
|
|
return JSON.parse(fs.readFileSync(addresses_path, "utf-8"));
|
|
};
|
|
export const getContractAbi = (repoName: string, deploymentArtifactName: string): any => {
|
|
const abi_path = path.join(__dirname, `../ignition/deployments/${repoName}/artifacts/${deploymentArtifactName}.json`);
|
|
return JSON.parse(fs.readFileSync(abi_path, "utf-8")).abi;
|
|
};
|
|
|
|
export function getContractAddress(exactName: string, deployedAddresses: any): any {
|
|
if (exactName in deployedAddresses) {
|
|
return deployedAddresses[exactName];
|
|
}
|
|
throw Error(`No contract address found for ${exactName}`);
|
|
}
|
|
|
|
// Console colors
|
|
const colors = {
|
|
reset: "\x1b[0m",
|
|
red: "\x1b[31m",
|
|
green: "\x1b[32m",
|
|
yellow: "\x1b[33m",
|
|
blue: "\x1b[34m",
|
|
magenta: "\x1b[35m",
|
|
cyan: "\x1b[36m",
|
|
white: "\x1b[37m",
|
|
};
|
|
|
|
export const log = {
|
|
info: (msg: string) => console.log(`${colors.blue}[INFO]${colors.reset} ${msg}`),
|
|
success: (msg: string) => console.log(`${colors.green}[SUCCESS]${colors.reset} ${msg}`),
|
|
warning: (msg: string) => console.log(`${colors.yellow}[WARNING]${colors.reset} ${msg}`),
|
|
error: (msg: string) => console.log(`${colors.red}[ERROR]${colors.reset} ${msg}`),
|
|
step: (msg: string) => console.log(`${colors.magenta}[STEP]${colors.reset} ${msg}`),
|
|
};
|