Skip to content

Commit

Permalink
Rename default to defaultValue for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Aug 12, 2024
1 parent 22c6fa1 commit 9ca19c8
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/aztec_start_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface AztecStartOption {

export const getOptions = (namespace: string, configMappings: Record<string, ConfigMapping>) => {
const options: AztecStartOption[] = [];
for (const [key, { env, default: def, parseEnv, description, printDefault }] of Object.entries(configMappings)) {
for (const [key, { env, defaultValue: def, parseEnv, description, printDefault }] of Object.entries(configMappings)) {
if (universalOptions.includes(key)) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/bot/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
env: 'BOT_PRIVATE_KEY',
description: 'Signing private key for the sender account.',
parseEnv: (val: string) => Fr.fromString(val),
default: Fr.random(),
defaultValue: Fr.random(),
},
recipientEncryptionSecret: {
env: 'BOT_RECIPIENT_ENCRYPTION_SECRET',
description: 'Encryption secret for a recipient account.',
parseEnv: (val: string) => Fr.fromString(val),
default: Fr.fromString('0xcafecafe'),
defaultValue: Fr.fromString('0xcafecafe'),
},
tokenSalt: {
env: 'BOT_TOKEN_SALT',
description: 'Salt for the token contract deployment.',
parseEnv: (val: string) => Fr.fromString(val),
default: Fr.fromString('1'),
defaultValue: Fr.fromString('1'),
},
txIntervalSeconds: {
env: 'BOT_TX_INTERVAL_SECONDS',
Expand All @@ -74,7 +74,7 @@ export const botConfigMappings: ConfigMappingsType<BotConfig> = {
env: 'BOT_FEE_PAYMENT_METHOD',
description: 'How to handle fee payments. (Options: fee_juice, none)',
parseEnv: val => (val as 'fee_juice' | 'none') || undefined,
default: 'none',
defaultValue: 'none',
},
noStart: {
env: 'BOT_NO_START',
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/ethereum/src/l1_reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export const l1ReaderConfigMappings: ConfigMappingsType<L1ReaderConfig> = {
l1ChainId: {
env: 'L1_CHAIN_ID',
parseEnv: (val: string) => +val,
default: 31337,
defaultValue: 31337,
description: 'The chain ID of the ethereum host.',
},
// NOTE: Special case for l1Contracts
l1Contracts: {
description: 'The deployed L1 contract addresses',
default: l1ContractAddressesMapping,
defaultValue: l1ContractAddressesMapping,
},
};
18 changes: 10 additions & 8 deletions yarn-project/foundation/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export { EnvVar } from './env_var.js';
export interface ConfigMapping {
env?: EnvVar;
parseEnv?: (val: string) => any;
default?: any;
defaultValue?: any;
printDefault?: (val: any) => string;
description: string;
isBoolean?: boolean;
Expand All @@ -22,7 +22,7 @@ export function getConfigFromMappings<T>(configMappings: ConfigMappingsType<T>):

for (const key in configMappings) {
if (configMappings[key]) {
const { env, parseEnv, default: def } = configMappings[key];
const { env, parseEnv, defaultValue: def } = configMappings[key];
// Special case for L1 contract addresses which is an object of config values
if (key === 'l1Contracts' && def) {
(config as any)[key] = getConfigFromMappings(def);
Expand Down Expand Up @@ -60,10 +60,10 @@ export function filterConfigMappings<T, K extends keyof T>(
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
* @returns Object with parseEnv and default values for a numerical config value
*/
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'default'> {
export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
return {
parseEnv: (val: string) => safeParseNumber(val, defaultVal),
default: defaultVal,
defaultValue: defaultVal,
};
}

Expand All @@ -72,10 +72,12 @@ export function numberConfigHelper(defaultVal: number): Pick<ConfigMapping, 'par
* @param defaultVal - The default value to use if the environment variable is not set or is invalid
* @returns Object with parseEnv and default values for a boolean config value
*/
export function booleanConfigHelper(defaultVal = false): Pick<ConfigMapping, 'parseEnv' | 'default' | 'isBoolean'> {
export function booleanConfigHelper(
defaultVal = false,
): Required<Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'>> {
return {
parseEnv: (val: string) => ['1', 'true', 'TRUE'].includes(val),
default: defaultVal,
defaultValue: defaultVal,
isBoolean: true,
};
}
Expand Down Expand Up @@ -119,8 +121,8 @@ export function getDefaultConfig<T>(configMappings: ConfigMappingsType<T>): T {
const defaultConfig = {} as T;

for (const key in configMappings) {
if (configMappings[key] && configMappings[key].default !== undefined) {
(defaultConfig as any)[key] = configMappings[key].default;
if (configMappings[key] && configMappings[key].defaultValue !== undefined) {
(defaultConfig as any)[key] = configMappings[key].defaultValue;
}
}

Expand Down
6 changes: 3 additions & 3 deletions yarn-project/p2p/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
},
tcpListenAddress: {
env: 'TCP_LISTEN_ADDR',
default: '0.0.0.0:40400',
defaultValue: '0.0.0.0:40400',
description: 'The listen address for TCP. Format: <IP_ADDRESS>:<PORT>.',
},
udpListenAddress: {
env: 'UDP_LISTEN_ADDR',
default: '0.0.0.0:40400',
defaultValue: '0.0.0.0:40400',
description: 'The listen address for UDP. Format: <IP_ADDRESS>:<PORT>.',
},
tcpAnnounceAddress: {
Expand All @@ -142,7 +142,7 @@ export const p2pConfigMappings: ConfigMappingsType<P2PConfig> = {
transactionProtocol: {
env: 'P2P_TX_PROTOCOL',
description: 'Protocol identifier for transaction gossiping.',
default: '/aztec/0.1.0',
defaultValue: '/aztec/0.1.0',
},
minPeerCount: {
env: 'P2P_MIN_PEERS',
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/sequencer-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
allowedInSetup: {
env: 'SEQ_ALLOWED_SETUP_FN',
parseEnv: (val: string) => parseSequencerAllowList(val),
default: getDefaultAllowedSetupFunctions(),
defaultValue: getDefaultAllowedSetupFunctions(),
description: 'The list of functions calls allowed to run in setup',
printDefault: () =>
'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
},
allowedInTeardown: {
env: 'SEQ_ALLOWED_TEARDOWN_FN',
parseEnv: (val: string) => parseSequencerAllowList(val),
default: getDefaultAllowedTeardownFunctions(),
defaultValue: getDefaultAllowedTeardownFunctions(),
description: 'The list of functions calls allowed to run teardown',
printDefault: () => 'FPC.pay_refund, FPC.pay_refund_with_shielded_rebate',
},
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/sequencer-client/src/publisher/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ export const getTxSenderConfigMappings: (
l1ChainId: {
env: 'L1_CHAIN_ID',
parseEnv: (val: string) => +val,
default: 31337,
defaultValue: 31337,
description: 'The chain ID of the ethereum host.',
},
publisherPrivateKey: {
env: `${scope}_PUBLISHER_PRIVATE_KEY`,
description: 'The private key to be used by the publisher.',
parseEnv: (val: string) => (val ? `0x${val.replace('0x', '')}` : NULL_KEY),
default: NULL_KEY,
defaultValue: NULL_KEY,
},
requiredConfirmations: {
env: `${scope}_REQUIRED_CONFIRMATIONS`,
parseEnv: (val: string) => +val,
default: 1,
defaultValue: 1,
description: 'The number of confirmations required.',
},
});
Expand All @@ -61,7 +61,7 @@ export const getPublisherConfigMappings: (scope: 'PROVER' | 'SEQ') => ConfigMapp
l1PublishRetryIntervalMS: {
env: `${scope}_PUBLISH_RETRY_INTERVAL_MS`,
parseEnv: (val: string) => +val,
default: 1000,
defaultValue: 1000,
description: 'The interval to wait between publish retries.',
},
});
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/telemetry-client/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export const telemetryClientConfigMappings: ConfigMappingsType<TelemetryClientCo
serviceName: {
env: 'OTEL_SERVICE_NAME',
description: 'The URL of the telemetry collector',
default: 'aztec',
defaultValue: 'aztec',
},
networkName: {
env: 'NETWORK_NAME',
description: 'The network ID of the telemetry service',
default: 'local',
defaultValue: 'local',
},
};

Expand Down
4 changes: 2 additions & 2 deletions yarn-project/world-state/src/synchronizer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export const worldStateConfigMappings: ConfigMappingsType<WorldStateConfig> = {
worldStateBlockCheckIntervalMS: {
env: 'WS_BLOCK_CHECK_INTERVAL_MS',
parseEnv: (val: string) => +val,
default: 100,
defaultValue: 100,
description: 'The frequency in which to check.',
},
l2QueueSize: {
env: 'WS_L2_BLOCK_QUEUE_SIZE',
parseEnv: (val: string) => +val,
default: 1000,
defaultValue: 1000,
description: 'Size of queue of L2 blocks to store.',
},
worldStateProvenBlocksOnly: {
Expand Down

0 comments on commit 9ca19c8

Please sign in to comment.