diff --git a/packages/config-service/src/commands/printEnvs.ts b/packages/config-service/src/commands/printEnvs.ts index fb392098fd..cfde9dd5f0 100644 --- a/packages/config-service/src/commands/printEnvs.ts +++ b/packages/config-service/src/commands/printEnvs.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/config-service/src/services/globalConfig.ts b/packages/config-service/src/services/globalConfig.ts index a15955482f..8df62aa2e6 100644 --- a/packages/config-service/src/services/globalConfig.ts +++ b/packages/config-service/src/services/globalConfig.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ type TypeStrToType = Tstr extends 'string' : never; type GetTypeStrOfKey = K extends keyof typeof _CONFIG - ? typeof _CONFIG[K]['type'] + ? typeof _CONFIG[K]['type'] : never; export type TypeOfKey = TypeStrToType>; @@ -767,40 +767,6 @@ const _CONFIG = { export type ConfigKey = keyof typeof _CONFIG; -export class ConfigService { - private static config: typeof _CONFIG = _CONFIG; - - public static get(name: K): TypeOfKey | undefined { - const configItem = this.config[name]; - if (!configItem) { - return undefined; - } - - const value = process.env[configItem.envName]; - - if (value === undefined) { - return configItem.defaultValue as TypeOfKey; - } - - switch (configItem.type) { - case 'boolean': - return (value.toLowerCase() === 'true') as TypeOfKey; - case 'number': - return Number(value) as TypeOfKey; - case 'string': - return value as TypeOfKey; - case 'array': - try { - return JSON.parse(value) as TypeOfKey; - } catch { - return undefined; - } - default: - return undefined; - } - } -} - export class GlobalConfig { public static readonly ENTRIES: Record = _CONFIG; } diff --git a/packages/config-service/src/services/index.ts b/packages/config-service/src/services/index.ts index 77c5dce266..2b0e9efea8 100644 --- a/packages/config-service/src/services/index.ts +++ b/packages/config-service/src/services/index.ts @@ -21,9 +21,10 @@ import dotenv from 'dotenv'; import findConfig from 'find-config'; import pino from 'pino'; + +import type { ConfigKey, TypeOfKey } from './globalConfig'; import { LoggerService } from './loggerService'; import { ValidationService } from './validationService'; -import type { ConfigKey } from './globalConfig'; const mainLogger = pino({ name: 'hedera-json-rpc-relay', @@ -98,7 +99,7 @@ export class ConfigService { * @param name string * @returns string | undefined */ - public static get(name: ConfigKey): string | number | boolean | null | undefined { - return this.getInstance().envs[name]; + public static get(name: K): TypeOfKey | undefined { + return this.getInstance().envs[name] as TypeOfKey | undefined; } } diff --git a/packages/config-service/src/services/loggerService.ts b/packages/config-service/src/services/loggerService.ts index 027fe7f447..5f5a5e346d 100644 --- a/packages/config-service/src/services/loggerService.ts +++ b/packages/config-service/src/services/loggerService.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/lib/types/ITracerConfig.ts b/packages/relay/src/lib/types/ITracerConfig.ts index 7cec49efd9..6f92ccbbb2 100644 --- a/packages/relay/src/lib/types/ITracerConfig.ts +++ b/packages/relay/src/lib/types/ITracerConfig.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/lib/types/ITracerConfigWrapper.ts b/packages/relay/src/lib/types/ITracerConfigWrapper.ts index dc444fd38d..3499c2f913 100644 --- a/packages/relay/src/lib/types/ITracerConfigWrapper.ts +++ b/packages/relay/src/lib/types/ITracerConfigWrapper.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/lib/types/ITransactionReceipt.ts b/packages/relay/src/lib/types/ITransactionReceipt.ts index a208da06f4..c42b7cf56d 100644 --- a/packages/relay/src/lib/types/ITransactionReceipt.ts +++ b/packages/relay/src/lib/types/ITransactionReceipt.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/lib/types/RequestDetails.ts b/packages/relay/src/lib/types/RequestDetails.ts index 206d325b98..5d557d2151 100644 --- a/packages/relay/src/lib/types/RequestDetails.ts +++ b/packages/relay/src/lib/types/RequestDetails.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/lib/types/index.ts b/packages/relay/src/lib/types/index.ts index dc048c8dca..2ca506dbf4 100644 --- a/packages/relay/src/lib/types/index.ts +++ b/packages/relay/src/lib/types/index.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/logsBloomUtils.ts b/packages/relay/src/logsBloomUtils.ts index e7e94cab3b..f0e6cd29f2 100644 --- a/packages/relay/src/logsBloomUtils.ts +++ b/packages/relay/src/logsBloomUtils.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/receiptsRootUtils.ts b/packages/relay/src/receiptsRootUtils.ts index 841b8798ed..c9603de699 100644 --- a/packages/relay/src/receiptsRootUtils.ts +++ b/packages/relay/src/receiptsRootUtils.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/src/utils.ts b/packages/relay/src/utils.ts index 9da3d0ec4d..8851442652 100644 --- a/packages/relay/src/utils.ts +++ b/packages/relay/src/utils.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/tests/lib/logsBloomUtils.spec.ts b/packages/relay/tests/lib/logsBloomUtils.spec.ts index 4ec141c1e1..4046d07097 100644 --- a/packages/relay/tests/lib/logsBloomUtils.spec.ts +++ b/packages/relay/tests/lib/logsBloomUtils.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/tests/lib/receiptsRootUtils.spec.ts b/packages/relay/tests/lib/receiptsRootUtils.spec.ts index 4bd417b291..36e6f26acd 100644 --- a/packages/relay/tests/lib/receiptsRootUtils.spec.ts +++ b/packages/relay/tests/lib/receiptsRootUtils.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/relay/tests/lib/utils.spec.ts b/packages/relay/tests/lib/utils.spec.ts index 27b9347844..a34fdea02f 100644 --- a/packages/relay/tests/lib/utils.spec.ts +++ b/packages/relay/tests/lib/utils.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/src/koaJsonRpc/lib/IJsonRpcRequest.ts b/packages/server/src/koaJsonRpc/lib/IJsonRpcRequest.ts index 91e7a85649..7f78ec1b91 100644 --- a/packages/server/src/koaJsonRpc/lib/IJsonRpcRequest.ts +++ b/packages/server/src/koaJsonRpc/lib/IJsonRpcRequest.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/src/koaJsonRpc/lib/IJsonRpcResponse.ts b/packages/server/src/koaJsonRpc/lib/IJsonRpcResponse.ts index debce1547a..ba14478890 100644 --- a/packages/server/src/koaJsonRpc/lib/IJsonRpcResponse.ts +++ b/packages/server/src/koaJsonRpc/lib/IJsonRpcResponse.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/tests/acceptance/hbarLimiter.spec.ts b/packages/server/tests/acceptance/hbarLimiter.spec.ts index 2824a63f0f..10b78bdaf7 100644 --- a/packages/server/tests/acceptance/hbarLimiter.spec.ts +++ b/packages/server/tests/acceptance/hbarLimiter.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - *Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/tests/clients/githubClient.ts b/packages/server/tests/clients/githubClient.ts index 932ef7ca17..b08d287713 100644 --- a/packages/server/tests/clients/githubClient.ts +++ b/packages/server/tests/clients/githubClient.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/tests/types/GitHubContext.ts b/packages/server/tests/types/GitHubContext.ts index 22c949939d..355bbcefe4 100644 --- a/packages/server/tests/types/GitHubContext.ts +++ b/packages/server/tests/types/GitHubContext.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/packages/server/tests/types/HeapDifferenceStatistics.ts b/packages/server/tests/types/HeapDifferenceStatistics.ts index ce96510525..db67e82b62 100644 --- a/packages/server/tests/types/HeapDifferenceStatistics.ts +++ b/packages/server/tests/types/HeapDifferenceStatistics.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/waffle-example/test/samplecontract.test.mjs b/tools/waffle-example/test/samplecontract.test.mjs index 76401a2b1b..7609cfa1b1 100644 --- a/tools/waffle-example/test/samplecontract.test.mjs +++ b/tools/waffle-example/test/samplecontract.test.mjs @@ -2,7 +2,7 @@ * * Hedera Waffle Project * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/App.tsx b/tools/wagmi-example/src/App.tsx index 27d7efb8a8..63a0f15360 100644 --- a/tools/wagmi-example/src/App.tsx +++ b/tools/wagmi-example/src/App.tsx @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/components/Contract.tsx b/tools/wagmi-example/src/components/Contract.tsx index e6b8c015bf..4f9cea022c 100644 --- a/tools/wagmi-example/src/components/Contract.tsx +++ b/tools/wagmi-example/src/components/Contract.tsx @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/components/Profile.tsx b/tools/wagmi-example/src/components/Profile.tsx index be417b05b9..41389a77a5 100644 --- a/tools/wagmi-example/src/components/Profile.tsx +++ b/tools/wagmi-example/src/components/Profile.tsx @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/hooks/use-balance.ts b/tools/wagmi-example/src/hooks/use-balance.ts index f37e00e00d..78b7c546ff 100644 --- a/tools/wagmi-example/src/hooks/use-balance.ts +++ b/tools/wagmi-example/src/hooks/use-balance.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/hooks/use-deploy.ts b/tools/wagmi-example/src/hooks/use-deploy.ts index 15f47e3a69..27c249e859 100644 --- a/tools/wagmi-example/src/hooks/use-deploy.ts +++ b/tools/wagmi-example/src/hooks/use-deploy.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/main.tsx b/tools/wagmi-example/src/main.tsx index 6b10f73ae7..cda3a08d7e 100644 --- a/tools/wagmi-example/src/main.tsx +++ b/tools/wagmi-example/src/main.tsx @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tools/wagmi-example/src/wagmi.ts b/tools/wagmi-example/src/wagmi.ts index 687a33605f..21a4f2d3df 100644 --- a/tools/wagmi-example/src/wagmi.ts +++ b/tools/wagmi-example/src/wagmi.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay - Wagmi Example * - * Copyright (C) 2022-2024 Hedera Hashgraph, LLC + * Copyright (C) 2024 Hedera Hashgraph, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.