Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions gateway-contracts/tasks/utils/loadVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import path from "path";
import { ADDRESSES_DIR, GATEWAY_ADDRESSES_ENV_FILE_NAME } from "../../hardhat.config";
import { pascalCaseToAddressEnvVar } from "../utils";

// Get the required environment variable, throw an error if it's not set
// We only check if the variable is set, not if it's empty
// Get the required environment variable, throw an error if it's not set or empty
export function getRequiredEnvVar(name: string): string {
if (!(name in process.env)) {
throw new Error(`"${name}" env variable is not set`);
}
return process.env[name]!;
const value = process.env[name]!;
if (value.trim() === "") {
throw new Error(`"${name}" env variable is set but empty`);
}
return value;
}

// Get the required address from the environment variable, throw an error if it's not set
// We only check if the variable is set, not if it's empty
// Get the required address from the environment variable, throw an error if it's not set or empty
export function getRequiredAddressEnvVar(name: string): string {
const addressEnvVarName = pascalCaseToAddressEnvVar(name);
return getRequiredEnvVar(addressEnvVarName);
Expand Down
9 changes: 6 additions & 3 deletions host-contracts/tasks/utils/loadVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import path from 'path';

import { ADDRESSES_DIR, HOST_ADDRESSES_ENV_FILE_NAME } from '../../hardhat.config';

// Get the required environment variable, throw an error if it's not set
// We only check if the variable is set, not if it's empty
// Get the required environment variable, throw an error if it's not set or empty
export function getRequiredEnvVar(name: string): string {
if (!(name in process.env)) {
throw new Error(`"${name}" env variable is not set`);
}
return process.env[name]!;
const value = process.env[name]!;
if (value.trim() === '') {
throw new Error(`"${name}" env variable is set but empty`);
}
return value;
}

// Load the addresses as environment variables from the env file
Expand Down
9 changes: 6 additions & 3 deletions library-solidity/tasks/utils/loadVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import path from 'path';
const ADDRESSES_DIR = path.resolve(__dirname, '../../fhevmTemp/addresses');
const HOST_ADDRESSES_ENV_FILE_NAME = '.env.host';

// Get the required environment variable, throw an error if it's not set
// We only check if the variable is set, not if it's empty
// Get the required environment variable, throw an error if it's not set or empty
export function getRequiredEnvVar(name: string): string {
if (!(name in process.env)) {
throw new Error(`"${name}" env variable is not set`);
}
return process.env[name]!;
const value = process.env[name]!;
if (value.trim() === '') {
throw new Error(`"${name}" env variable is set but empty`);
}
return value;
}

// Load the addresses as environment variables from the env file
Expand Down
Loading