Skip to content

Commit

Permalink
utils/deployment-artifacts-to-app-env: remove CHAIN_ID
Browse files Browse the repository at this point in the history
Other CHAIN_* parameters are needed anyway, so this is usually defined
elsewhere.
  • Loading branch information
bpierre committed Apr 12, 2024
1 parent 0bcce1d commit 2ef4ad5
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 2ef4ad5

Please sign in to comment.