Skip to content

Commit

Permalink
Merge pull request #115 from liquity/app-env-contracts-only
Browse files Browse the repository at this point in the history
utils/deployment-artifacts-to-app-env: remove CHAIN_ID

Other CHAIN_* parameters are needed anyway, so this is usually defined elsewhere.
  • Loading branch information
bpierre authored Apr 12, 2024
2 parents 0bcce1d + 2ef4ad5 commit bcdf04f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions contracts/utils/deployment-artifacts-to-app-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ Options:
`;

const ZAddress = z.string().regex(/^0x[0-9a-fA-F]{40}$/);

const ZDeploymentContext = z.object({
options: z.object({
chainId: z.number(),
rpcUrl: z.string(),
}),
deployedContracts: z.record(ZAddress),
});

Expand All @@ -45,12 +40,12 @@ export async function main() {
process.exit(1);
}

const deploymentContext = parseDeploymentContext(
const { deployedContracts } = parseDeploymentContext(
await fs.readFile(options.inputJsonPath, "utf-8"),
);

const outputEnv = objectToEnvironmentVariables(
deploymentContextToAppEnvVariables(deploymentContext),
deployedContractsToAppEnvVariables(deployedContracts),
);

await fs.ensureFile(options.outputEnvPath);
Expand All @@ -70,10 +65,8 @@ function objectToEnvironmentVariables(object: Record<string, unknown>) {
.join("\n");
}

function deploymentContextToAppEnvVariables({ deployedContracts, options }: DeploymentContext) {
const appEnvVariables: Record<string, string> = {
NEXT_PUBLIC_CHAIN_ID: String(options.chainId),
};
function deployedContractsToAppEnvVariables(deployedContracts: DeploymentContext["deployedContracts"]) {
const appEnvVariables: Record<string, string> = {};

for (const [contractName, address] of Object.entries(deployedContracts)) {
const envVarName = contractNameToAppEnvVariable(contractName);
Expand Down

0 comments on commit bcdf04f

Please sign in to comment.