diff --git a/packages/config-service/src/services/globalConfig.ts b/packages/config-service/src/services/globalConfig.ts index f44eda0c8b..c34b1dc594 100644 --- a/packages/config-service/src/services/globalConfig.ts +++ b/packages/config-service/src/services/globalConfig.ts @@ -18,6 +18,46 @@ * */ +// Type mapping utility that converts string representations of types +// (e.g., 'string', 'boolean', 'number', 'array') to their corresponding +// TypeScript types. This allows for dynamic type resolution based on +// configuration definitions. +// Example: +// - 'string' -> string +// - 'boolean' -> boolean +// - 'number' -> number +// - 'array' -> unknown[] +type StringTypeToActualType = Tstr extends 'string' + ? string + : Tstr extends 'boolean' + ? boolean + : Tstr extends 'number' + ? number + : Tstr extends 'array' + ? unknown[] + : never; + +// This type extracts the type string associated with a specific key +// in the _CONFIG object. It checks if the provided key K is a valid +// key in _CONFIG. If it is, it retrieves the 'type' property of the +// corresponding configuration object; otherwise, it resolves to 'never'. +// Example: +// - For key 'CHAIN_ID', it returns 'string' if defined in _CONFIG. +// - For an invalid key 'INVALID_KEY', it returns never. +type ExtractTypeStringFromKey = K extends keyof typeof _CONFIG ? (typeof _CONFIG)[K]['type'] : never; + +// This type maps a configuration key K to its corresponding TypeScript type. +// It first uses ExtractTypeStringFromKey to get the type string and then +// converts that string to the actual TypeScript type using StringTypeToActualType. +// Example: +// - GetTypeOfConfigKey<'CHAIN_ID'> would resolve to string. +// - GetTypeOfConfigKey<'BATCH_REQUESTS_ENABLED'> would resolve to boolean. +export type GetTypeOfConfigKey = StringTypeToActualType>; + +// Interface defining the structure of a configuration property. +// Each property includes the environment variable name, its type, +// whether it is required, and its default value. +// Example of a ConfigProperty: export interface ConfigProperty { envName: string; type: string; @@ -25,722 +65,736 @@ export interface ConfigProperty { defaultValue: string | number | boolean | null; } +// Configuration object defining various properties and their metadata. +// Each property is an object that contains information about the environment variable, +// its type, whether it is required, and its default value. +// Example of a configuration entry: +const _CONFIG = { + BATCH_REQUESTS_ENABLED: { + envName: 'BATCH_REQUESTS_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + BATCH_REQUESTS_MAX_SIZE: { + envName: 'BATCH_REQUESTS_MAX_SIZE', + type: 'number', + required: false, + defaultValue: null, + }, + CACHE_MAX: { + envName: 'CACHE_MAX', + type: 'number', + required: false, + defaultValue: null, + }, + CACHE_TTL: { + envName: 'CACHE_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + CHAIN_ID: { + envName: 'CHAIN_ID', + type: 'string', + required: true, + defaultValue: null, + }, + CLIENT_TRANSPORT_SECURITY: { + envName: 'CLIENT_TRANSPORT_SECURITY', + type: 'boolean', + required: false, + defaultValue: null, + }, + CONSENSUS_MAX_EXECUTION_TIME: { + envName: 'CONSENSUS_MAX_EXECUTION_TIME', + type: 'number', + required: false, + defaultValue: null, + }, + CONTRACT_CALL_GAS_LIMIT: { + envName: 'CONTRACT_CALL_GAS_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + CONTRACT_QUERY_TIMEOUT_RETRIES: { + envName: 'CONTRACT_QUERY_TIMEOUT_RETRIES', + type: 'number', + required: false, + defaultValue: null, + }, + DEBUG_API_ENABLED: { + envName: 'DEBUG_API_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + DEFAULT_RATE_LIMIT: { + envName: 'DEFAULT_RATE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + DEV_MODE: { + envName: 'DEV_MODE', + type: 'boolean', + required: false, + defaultValue: null, + }, + E2E_RELAY_HOST: { + envName: 'E2E_RELAY_HOST', + type: 'string', + required: false, + defaultValue: 'http://localhost:7546', + }, + E2E_SERVER_PORT: { + envName: 'E2E_SERVER_PORT', + type: 'number', + required: false, + defaultValue: null, + }, + ESTIMATE_GAS_THROWS: { + envName: 'ESTIMATE_GAS_THROWS', + type: 'boolean', + required: false, + defaultValue: null, + }, + ETH_BLOCK_NUMBER_CACHE_TTL_MS: { + envName: 'ETH_BLOCK_NUMBER_CACHE_TTL_MS', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_CALL_ACCEPTED_ERRORS: { + envName: 'ETH_CALL_ACCEPTED_ERRORS', + type: 'array', + required: false, + defaultValue: null, + }, + ETH_CALL_CACHE_TTL: { + envName: 'ETH_CALL_CACHE_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_CALL_CONSENSUS_SELECTORS: { + envName: 'ETH_CALL_CONSENSUS_SELECTORS', + type: 'array', + required: false, + defaultValue: null, + }, + ETH_CALL_DEFAULT_TO_CONSENSUS_NODE: { + envName: 'ETH_CALL_DEFAULT_TO_CONSENSUS_NODE', + type: 'boolean', + required: false, + defaultValue: null, + }, + ETH_FEE_HISTORY_FIXED: { + envName: 'ETH_FEE_HISTORY_FIXED', + type: 'boolean', + required: false, + defaultValue: null, + }, + ETH_GET_BALANCE_CACHE_TTL_MS: { + envName: 'ETH_GET_BALANCE_CACHE_TTL_MS', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_GET_GAS_PRICE_CACHE_TTL_MS: { + envName: 'ETH_GET_GAS_PRICE_CACHE_TTL_MS', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_GET_LOGS_BLOCK_RANGE_LIMIT: { + envName: 'ETH_GET_LOGS_BLOCK_RANGE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_GET_TRANSACTION_COUNT_CACHE_TTL: { + envName: 'ETH_GET_TRANSACTION_COUNT_CACHE_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE: { + envName: 'ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE', + type: 'number', + required: false, + defaultValue: null, + }, + HEDERA_SPECIFIC_REVERT_STATUSES: { + envName: 'HEDERA_SPECIFIC_REVERT_STATUSES', + type: 'string', + required: false, + defaultValue: '["WRONG_NONCE", "INVALID_ACCOUNT_ID"]', + }, + FEE_HISTORY_MAX_RESULTS: { + envName: 'FEE_HISTORY_MAX_RESULTS', + type: 'number', + required: false, + defaultValue: null, + }, + FILE_APPEND_CHUNK_SIZE: { + envName: 'FILE_APPEND_CHUNK_SIZE', + type: 'number', + required: false, + defaultValue: null, + }, + FILE_APPEND_MAX_CHUNKS: { + envName: 'FILE_APPEND_MAX_CHUNKS', + type: 'number', + required: false, + defaultValue: null, + }, + FILTER_API_ENABLED: { + envName: 'FILTER_API_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + FILTER_TTL: { + envName: 'FILTER_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + GAS_PRICE_PERCENTAGE_BUFFER: { + envName: 'GAS_PRICE_PERCENTAGE_BUFFER', + type: 'number', + required: false, + defaultValue: null, + }, + GAS_PRICE_TINY_BAR_BUFFER: { + envName: 'GAS_PRICE_TINY_BAR_BUFFER', + type: 'number', + required: false, + defaultValue: null, + }, + GET_RECORD_DEFAULT_TO_CONSENSUS_NODE: { + envName: 'GET_RECORD_DEFAULT_TO_CONSENSUS_NODE', + type: 'boolean', + required: false, + defaultValue: null, + }, + GH_ACCESS_TOKEN: { + envName: 'GH_ACCESS_TOKEN', + type: 'string', + required: false, + defaultValue: null, + }, + GITHUB_PR_NUMBER: { + envName: 'GITHUB_PR_NUMBER', + type: 'string', + required: false, + defaultValue: null, + }, + GITHUB_REPOSITORY: { + envName: 'GITHUB_REPOSITORY', + type: 'string', + required: false, + defaultValue: null, + }, + GITHUB_TOKEN: { + envName: 'GITHUB_TOKEN', + type: 'string', + required: false, + defaultValue: null, + }, + HAPI_CLIENT_DURATION_RESET: { + envName: 'HAPI_CLIENT_DURATION_RESET', + type: 'number', + required: false, + defaultValue: null, + }, + HAPI_CLIENT_ERROR_RESET: { + envName: 'HAPI_CLIENT_ERROR_RESET', + type: 'array', + required: false, + defaultValue: null, + }, + HAPI_CLIENT_TRANSACTION_RESET: { + envName: 'HAPI_CLIENT_TRANSACTION_RESET', + type: 'number', + required: false, + defaultValue: null, + }, + HBAR_RATE_LIMIT_BASIC: { + envName: 'HBAR_RATE_LIMIT_BASIC', + type: 'number', + required: false, + defaultValue: 1_120_000_000, // 11.2 hbar + }, + HBAR_RATE_LIMIT_EXTENDED: { + envName: 'HBAR_RATE_LIMIT_EXTENDED', + type: 'number', + required: false, + defaultValue: 3_200_000_000, // 32 hbar + }, + HBAR_RATE_LIMIT_PRIVILEGED: { + envName: 'HBAR_RATE_LIMIT_PRIVILEGED', + type: 'number', + required: false, + defaultValue: 8_000_000_000, // 80 hbar + }, + HBAR_RATE_LIMIT_DURATION: { + envName: 'HBAR_RATE_LIMIT_DURATION', + type: 'number', + required: false, + defaultValue: 86_400_000, // 24 hours + }, + HBAR_RATE_LIMIT_TINYBAR: { + envName: 'HBAR_RATE_LIMIT_TINYBAR', + type: 'number', + required: false, + defaultValue: 800_000_000_000, // 8000 hbar + }, + HEDERA_NETWORK: { + envName: 'HEDERA_NETWORK', + type: 'string', + required: true, + defaultValue: null, + }, + HBAR_SPENDING_PLANS_CONFIG: { + envName: 'HBAR_SPENDING_PLANS_CONFIG', + type: 'string', + required: false, + defaultValue: 'spendingPlansConfig.json', + }, + INITIAL_BALANCE: { + envName: 'INITIAL_BALANCE', + type: 'number', + required: false, + defaultValue: null, + }, + INPUT_SIZE_LIMIT: { + envName: 'INPUT_SIZE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + LIMIT_DURATION: { + envName: 'LIMIT_DURATION', + type: 'number', + required: false, + defaultValue: null, + }, + LOCAL_NODE: { + envName: 'LOCAL_NODE', + type: 'boolean', + required: false, + defaultValue: null, + }, + LOG_LEVEL: { + envName: 'LOG_LEVEL', + type: 'string', + required: false, + defaultValue: null, + }, + MAX_BLOCK_RANGE: { + envName: 'MAX_BLOCK_RANGE', + type: 'number', + required: false, + defaultValue: null, + }, + MEMWATCH_ENABLED: { + envName: 'MEMWATCH_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + MIRROR_NODE_AGENT_CACHEABLE_DNS: { + envName: 'MIRROR_NODE_AGENT_CACHEABLE_DNS', + type: 'boolean', + required: false, + defaultValue: null, + }, + MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX: { + envName: 'MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_CONTRACT_RESULTS_PG_MAX: { + envName: 'MIRROR_NODE_CONTRACT_RESULTS_PG_MAX', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_HTTP_KEEP_ALIVE: { + envName: 'MIRROR_NODE_HTTP_KEEP_ALIVE', + type: 'boolean', + required: false, + defaultValue: null, + }, + MIRROR_NODE_HTTP_KEEP_ALIVE_MSECS: { + envName: 'MIRROR_NODE_HTTP_KEEP_ALIVE_MSECS', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_HTTP_MAX_SOCKETS: { + envName: 'MIRROR_NODE_HTTP_MAX_SOCKETS', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_HTTP_MAX_TOTAL_SOCKETS: { + envName: 'MIRROR_NODE_HTTP_MAX_TOTAL_SOCKETS', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_HTTP_SOCKET_TIMEOUT: { + envName: 'MIRROR_NODE_HTTP_SOCKET_TIMEOUT', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_LIMIT_PARAM: { + envName: 'MIRROR_NODE_LIMIT_PARAM', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_MAX_REDIRECTS: { + envName: 'MIRROR_NODE_MAX_REDIRECTS', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_RETRIES: { + envName: 'MIRROR_NODE_RETRIES', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_RETRIES_DEVMODE: { + envName: 'MIRROR_NODE_RETRIES_DEVMODE', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_RETRY_CODES: { + envName: 'MIRROR_NODE_RETRY_CODES', + type: 'array', + required: false, + defaultValue: null, + }, + MIRROR_NODE_RETRY_DELAY: { + envName: 'MIRROR_NODE_RETRY_DELAY', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_RETRY_DELAY_DEVMODE: { + envName: 'MIRROR_NODE_RETRY_DELAY_DEVMODE', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_REQUEST_RETRY_COUNT: { + envName: 'MIRROR_NODE_REQUEST_RETRY_COUNT', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_TIMEOUT: { + envName: 'MIRROR_NODE_TIMEOUT', + type: 'number', + required: false, + defaultValue: null, + }, + MIRROR_NODE_URL: { + envName: 'MIRROR_NODE_URL', + type: 'string', + required: true, + defaultValue: null, + }, + MIRROR_NODE_URL_HEADER_X_API_KEY: { + envName: 'MIRROR_NODE_URL_HEADER_X_API_KEY', + type: 'array', + required: false, + defaultValue: null, + }, + MIRROR_NODE_URL_WEB3: { + envName: 'MIRROR_NODE_URL_WEB3', + type: 'string', + required: false, + defaultValue: null, + }, + MULTI_SET: { + envName: 'MULTI_SET', + type: 'boolean', + required: false, + defaultValue: null, + }, + // the actual env var in the node process is npm_package_version + npm_package_version: { + envName: 'npm_package_version', + type: 'string', + required: true, + defaultValue: null, + }, + OPERATOR_ID_ETH_SENDRAWTRANSACTION: { + envName: 'OPERATOR_ID_ETH_SENDRAWTRANSACTION', + type: 'string', + required: false, + defaultValue: null, + }, + OPERATOR_ID_MAIN: { + envName: 'OPERATOR_ID_MAIN', + type: 'string', + required: true, + defaultValue: null, + }, + OPERATOR_KEY_ETH_SENDRAWTRANSACTION: { + envName: 'OPERATOR_KEY_ETH_SENDRAWTRANSACTION', + type: 'string', + required: false, + defaultValue: null, + }, + OPERATOR_KEY_FORMAT: { + envName: 'OPERATOR_KEY_FORMAT', + type: 'string', + required: false, + defaultValue: null, + }, + OPERATOR_KEY_MAIN: { + envName: 'OPERATOR_KEY_MAIN', + type: 'string', + required: true, + defaultValue: null, + }, + RATE_LIMIT_DISABLED: { + envName: 'RATE_LIMIT_DISABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + REDIS_ENABLED: { + envName: 'REDIS_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + REDIS_RECONNECT_DELAY_MS: { + envName: 'REDIS_RECONNECT_DELAY_MS', + type: 'number', + required: false, + defaultValue: null, + }, + REDIS_URL: { + envName: 'REDIS_URL', + type: 'string', + required: false, + defaultValue: 'redis://127.0.0.1:6379', + }, + REQUEST_ID_IS_OPTIONAL: { + envName: 'REQUEST_ID_IS_OPTIONAL', + type: 'boolean', + required: false, + defaultValue: null, + }, + SDK_REQUEST_TIMEOUT: { + envName: 'SDK_REQUEST_TIMEOUT', + type: 'number', + required: false, + defaultValue: null, + }, + SEND_RAW_TRANSACTION_SIZE_LIMIT: { + envName: 'SEND_RAW_TRANSACTION_SIZE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + SERVER_HOST: { + envName: 'SERVER_HOST', + type: 'string', + required: false, + defaultValue: null, + }, + SERVER_PORT: { + envName: 'SERVER_PORT', + type: 'number', + required: false, + defaultValue: 7546, + }, + SERVER_REQUEST_TIMEOUT_MS: { + envName: 'SERVER_REQUEST_TIMEOUT_MS', + type: 'number', + required: false, + defaultValue: null, + }, + SUBSCRIPTIONS_ENABLED: { + envName: 'SUBSCRIPTIONS_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + TEST: { + envName: 'TEST', + type: 'boolean', + required: false, + defaultValue: null, + }, + TEST_GAS_PRICE_DEVIATION: { + envName: 'TEST_GAS_PRICE_DEVIATION', + type: 'number', + required: false, + defaultValue: null, + }, + TEST_INITIAL_ACCOUNT_STARTING_BALANCE: { + envName: 'TEST_INITIAL_ACCOUNT_STARTING_BALANCE', + type: 'number', + required: false, + defaultValue: null, + }, + TEST_TRANSACTION_RECORD_COST_TOLERANCE: { + envName: 'TEST_TRANSACTION_RECORD_COST_TOLERANCE', + type: 'number', + required: false, + defaultValue: null, + }, + TEST_WS_SERVER: { + envName: 'TEST_WS_SERVER', + type: 'boolean', + required: false, + defaultValue: null, + }, + TIER_1_RATE_LIMIT: { + envName: 'TIER_1_RATE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + TIER_2_RATE_LIMIT: { + envName: 'TIER_2_RATE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + TIER_3_RATE_LIMIT: { + envName: 'TIER_3_RATE_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + TX_DEFAULT_GAS: { + envName: 'TX_DEFAULT_GAS', + type: 'number', + required: false, + defaultValue: null, + }, + USE_ASYNC_TX_PROCESSING: { + envName: 'USE_ASYNC_TX_PROCESSING', + type: 'boolean', + required: false, + defaultValue: false, + }, + WEB_SOCKET_HTTP_PORT: { + envName: 'WEB_SOCKET_HTTP_PORT', + type: 'number', + required: false, + defaultValue: 8547, + }, + WEB_SOCKET_PORT: { + envName: 'WEB_SOCKET_PORT', + type: 'number', + required: false, + defaultValue: 8546, + }, + WRITE_SNAPSHOT_ON_MEMORY_LEAK: { + envName: 'WRITE_SNAPSHOT_ON_MEMORY_LEAK', + type: 'boolean', + required: false, + defaultValue: null, + }, + WS_BATCH_REQUESTS_ENABLED: { + envName: 'WS_BATCH_REQUESTS_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + WS_BATCH_REQUESTS_MAX_SIZE: { + envName: 'WS_BATCH_REQUESTS_MAX_SIZE', + type: 'number', + required: false, + defaultValue: null, + }, + WS_CACHE_TTL: { + envName: 'WS_CACHE_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + WS_CONNECTION_LIMIT: { + envName: 'WS_CONNECTION_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, + WS_CONNECTION_LIMIT_PER_IP: { + envName: 'WS_CONNECTION_LIMIT_PER_IP', + type: 'number', + required: false, + defaultValue: null, + }, + WS_MAX_INACTIVITY_TTL: { + envName: 'WS_MAX_INACTIVITY_TTL', + type: 'number', + required: false, + defaultValue: null, + }, + WS_MULTIPLE_ADDRESSES_ENABLED: { + envName: 'WS_MULTIPLE_ADDRESSES_ENABLED', + type: 'boolean', + required: false, + defaultValue: null, + }, + WS_NEW_HEADS_ENABLED: { + envName: 'WS_NEW_HEADS_ENABLED', + type: 'boolean', + required: false, + defaultValue: true, + }, + WS_PING_INTERVAL: { + envName: 'WS_PING_INTERVAL', + type: 'number', + required: false, + defaultValue: null, + }, + WS_POLLING_INTERVAL: { + envName: 'WS_POLLING_INTERVAL', + type: 'number', + required: false, + defaultValue: null, + }, + WS_RELAY_URL: { + envName: 'WS_RELAY_URL', + type: 'string', + required: false, + defaultValue: 'ws://127.0.0.1:8546', + }, + WS_SAME_SUB_FOR_SAME_EVENT: { + envName: 'WS_SAME_SUB_FOR_SAME_EVENT', + type: 'boolean', + required: false, + defaultValue: null, + }, + WS_SUBSCRIPTION_LIMIT: { + envName: 'WS_SUBSCRIPTION_LIMIT', + type: 'number', + required: false, + defaultValue: null, + }, +} as const satisfies { [key: string]: ConfigProperty }; // Ensures _CONFIG is read-only and conforms to the ConfigProperty structure + +export type ConfigKey = keyof typeof _CONFIG; + export class GlobalConfig { - public static readonly ENTRIES: Record = { - BATCH_REQUESTS_ENABLED: { - envName: 'BATCH_REQUESTS_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - BATCH_REQUESTS_MAX_SIZE: { - envName: 'BATCH_REQUESTS_MAX_SIZE', - type: 'number', - required: false, - defaultValue: null, - }, - CACHE_MAX: { - envName: 'CACHE_MAX', - type: 'number', - required: false, - defaultValue: null, - }, - CACHE_TTL: { - envName: 'CACHE_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - CHAIN_ID: { - envName: 'CHAIN_ID', - type: 'string', - required: true, - defaultValue: null, - }, - CLIENT_TRANSPORT_SECURITY: { - envName: 'CLIENT_TRANSPORT_SECURITY', - type: 'boolean', - required: false, - defaultValue: null, - }, - CONSENSUS_MAX_EXECUTION_TIME: { - envName: 'CONSENSUS_MAX_EXECUTION_TIME', - type: 'number', - required: false, - defaultValue: null, - }, - CONTRACT_CALL_GAS_LIMIT: { - envName: 'CONTRACT_CALL_GAS_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - CONTRACT_QUERY_TIMEOUT_RETRIES: { - envName: 'CONTRACT_QUERY_TIMEOUT_RETRIES', - type: 'number', - required: false, - defaultValue: null, - }, - DEBUG_API_ENABLED: { - envName: 'DEBUG_API_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - DEFAULT_RATE_LIMIT: { - envName: 'DEFAULT_RATE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - DEV_MODE: { - envName: 'DEV_MODE', - type: 'boolean', - required: false, - defaultValue: null, - }, - E2E_RELAY_HOST: { - envName: 'E2E_RELAY_HOST', - type: 'string', - required: false, - defaultValue: 'http://localhost:7546', - }, - E2E_SERVER_PORT: { - envName: 'E2E_SERVER_PORT', - type: 'number', - required: false, - defaultValue: null, - }, - ESTIMATE_GAS_THROWS: { - envName: 'ESTIMATE_GAS_THROWS', - type: 'boolean', - required: false, - defaultValue: null, - }, - ETH_BLOCK_NUMBER_CACHE_TTL_MS: { - envName: 'ETH_BLOCK_NUMBER_CACHE_TTL_MS', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_CALL_ACCEPTED_ERRORS: { - envName: 'ETH_CALL_ACCEPTED_ERRORS', - type: 'array', - required: false, - defaultValue: null, - }, - ETH_CALL_CACHE_TTL: { - envName: 'ETH_CALL_CACHE_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_CALL_CONSENSUS_SELECTORS: { - envName: 'ETH_CALL_CONSENSUS_SELECTORS', - type: 'array', - required: false, - defaultValue: null, - }, - ETH_CALL_DEFAULT_TO_CONSENSUS_NODE: { - envName: 'ETH_CALL_DEFAULT_TO_CONSENSUS_NODE', - type: 'boolean', - required: false, - defaultValue: null, - }, - ETH_FEE_HISTORY_FIXED: { - envName: 'ETH_FEE_HISTORY_FIXED', - type: 'boolean', - required: false, - defaultValue: null, - }, - ETH_GET_BALANCE_CACHE_TTL_MS: { - envName: 'ETH_GET_BALANCE_CACHE_TTL_MS', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_GET_GAS_PRICE_CACHE_TTL_MS: { - envName: 'ETH_GET_GAS_PRICE_CACHE_TTL_MS', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_GET_LOGS_BLOCK_RANGE_LIMIT: { - envName: 'ETH_GET_LOGS_BLOCK_RANGE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_GET_TRANSACTION_COUNT_CACHE_TTL: { - envName: 'ETH_GET_TRANSACTION_COUNT_CACHE_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE: { - envName: 'ETH_GET_TRANSACTION_COUNT_MAX_BLOCK_RANGE', - type: 'number', - required: false, - defaultValue: null, - }, - HEDERA_SPECIFIC_REVERT_STATUSES: { - envName: 'HEDERA_SPECIFIC_REVERT_STATUSES', - type: 'string', - required: false, - defaultValue: '["WRONG_NONCE", "INVALID_ACCOUNT_ID"]', - }, - FEE_HISTORY_MAX_RESULTS: { - envName: 'FEE_HISTORY_MAX_RESULTS', - type: 'number', - required: false, - defaultValue: null, - }, - FILE_APPEND_CHUNK_SIZE: { - envName: 'FILE_APPEND_CHUNK_SIZE', - type: 'number', - required: false, - defaultValue: null, - }, - FILE_APPEND_MAX_CHUNKS: { - envName: 'FILE_APPEND_MAX_CHUNKS', - type: 'number', - required: false, - defaultValue: null, - }, - FILTER_API_ENABLED: { - envName: 'FILTER_API_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - FILTER_TTL: { - envName: 'FILTER_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - GAS_PRICE_PERCENTAGE_BUFFER: { - envName: 'GAS_PRICE_PERCENTAGE_BUFFER', - type: 'number', - required: false, - defaultValue: null, - }, - GAS_PRICE_TINY_BAR_BUFFER: { - envName: 'GAS_PRICE_TINY_BAR_BUFFER', - type: 'number', - required: false, - defaultValue: null, - }, - GET_RECORD_DEFAULT_TO_CONSENSUS_NODE: { - envName: 'GET_RECORD_DEFAULT_TO_CONSENSUS_NODE', - type: 'boolean', - required: false, - defaultValue: null, - }, - GH_ACCESS_TOKEN: { - envName: 'GH_ACCESS_TOKEN', - type: 'string', - required: false, - defaultValue: null, - }, - GITHUB_PR_NUMBER: { - envName: 'GITHUB_PR_NUMBER', - type: 'string', - required: false, - defaultValue: null, - }, - GITHUB_REPOSITORY: { - envName: 'GITHUB_REPOSITORY', - type: 'string', - required: false, - defaultValue: null, - }, - GITHUB_TOKEN: { - envName: 'GITHUB_TOKEN', - type: 'string', - required: false, - defaultValue: null, - }, - HAPI_CLIENT_DURATION_RESET: { - envName: 'HAPI_CLIENT_DURATION_RESET', - type: 'number', - required: false, - defaultValue: null, - }, - HAPI_CLIENT_ERROR_RESET: { - envName: 'HAPI_CLIENT_ERROR_RESET', - type: 'array', - required: false, - defaultValue: null, - }, - HAPI_CLIENT_TRANSACTION_RESET: { - envName: 'HAPI_CLIENT_TRANSACTION_RESET', - type: 'number', - required: false, - defaultValue: null, - }, - HBAR_RATE_LIMIT_BASIC: { - envName: 'HBAR_RATE_LIMIT_BASIC', - type: 'number', - required: false, - defaultValue: 1_120_000_000, // 11.2 hbar - }, - HBAR_RATE_LIMIT_EXTENDED: { - envName: 'HBAR_RATE_LIMIT_EXTENDED', - type: 'number', - required: false, - defaultValue: 3_200_000_000, // 32 hbar - }, - HBAR_RATE_LIMIT_PRIVILEGED: { - envName: 'HBAR_RATE_LIMIT_PRIVILEGED', - type: 'number', - required: false, - defaultValue: 8_000_000_000, // 80 hbar - }, - HBAR_RATE_LIMIT_DURATION: { - envName: 'HBAR_RATE_LIMIT_DURATION', - type: 'number', - required: false, - defaultValue: 86_400_000, // 24 hours - }, - HBAR_RATE_LIMIT_TINYBAR: { - envName: 'HBAR_RATE_LIMIT_TINYBAR', - type: 'number', - required: false, - defaultValue: 800_000_000_000, // 8000 hbar - }, - HEDERA_NETWORK: { - envName: 'HEDERA_NETWORK', - type: 'string', - required: true, - defaultValue: null, - }, - HBAR_SPENDING_PLANS_CONFIG: { - envName: 'HBAR_SPENDING_PLANS_CONFIG', - type: 'string', - required: false, - defaultValue: 'spendingPlansConfig.json', - }, - INITIAL_BALANCE: { - envName: 'INITIAL_BALANCE', - type: 'number', - required: false, - defaultValue: null, - }, - INPUT_SIZE_LIMIT: { - envName: 'INPUT_SIZE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - LIMIT_DURATION: { - envName: 'LIMIT_DURATION', - type: 'number', - required: false, - defaultValue: null, - }, - LOCAL_NODE: { - envName: 'LOCAL_NODE', - type: 'boolean', - required: false, - defaultValue: null, - }, - LOG_LEVEL: { - envName: 'LOG_LEVEL', - type: 'string', - required: false, - defaultValue: null, - }, - MAX_BLOCK_RANGE: { - envName: 'MAX_BLOCK_RANGE', - type: 'number', - required: false, - defaultValue: null, - }, - MEMWATCH_ENABLED: { - envName: 'MEMWATCH_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - MIRROR_NODE_AGENT_CACHEABLE_DNS: { - envName: 'MIRROR_NODE_AGENT_CACHEABLE_DNS', - type: 'boolean', - required: false, - defaultValue: null, - }, - MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX: { - envName: 'MIRROR_NODE_CONTRACT_RESULTS_LOGS_PG_MAX', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_CONTRACT_RESULTS_PG_MAX: { - envName: 'MIRROR_NODE_CONTRACT_RESULTS_PG_MAX', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_HTTP_KEEP_ALIVE: { - envName: 'MIRROR_NODE_HTTP_KEEP_ALIVE', - type: 'boolean', - required: false, - defaultValue: null, - }, - MIRROR_NODE_HTTP_KEEP_ALIVE_MSECS: { - envName: 'MIRROR_NODE_HTTP_KEEP_ALIVE_MSECS', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_HTTP_MAX_SOCKETS: { - envName: 'MIRROR_NODE_HTTP_MAX_SOCKETS', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_HTTP_MAX_TOTAL_SOCKETS: { - envName: 'MIRROR_NODE_HTTP_MAX_TOTAL_SOCKETS', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_HTTP_SOCKET_TIMEOUT: { - envName: 'MIRROR_NODE_HTTP_SOCKET_TIMEOUT', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_LIMIT_PARAM: { - envName: 'MIRROR_NODE_LIMIT_PARAM', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_MAX_REDIRECTS: { - envName: 'MIRROR_NODE_MAX_REDIRECTS', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_RETRIES: { - envName: 'MIRROR_NODE_RETRIES', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_RETRIES_DEVMODE: { - envName: 'MIRROR_NODE_RETRIES_DEVMODE', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_RETRY_CODES: { - envName: 'MIRROR_NODE_RETRY_CODES', - type: 'array', - required: false, - defaultValue: null, - }, - MIRROR_NODE_RETRY_DELAY: { - envName: 'MIRROR_NODE_RETRY_DELAY', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_RETRY_DELAY_DEVMODE: { - envName: 'MIRROR_NODE_RETRY_DELAY_DEVMODE', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_REQUEST_RETRY_COUNT: { - envName: 'MIRROR_NODE_REQUEST_RETRY_COUNT', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_TIMEOUT: { - envName: 'MIRROR_NODE_TIMEOUT', - type: 'number', - required: false, - defaultValue: null, - }, - MIRROR_NODE_URL: { - envName: 'MIRROR_NODE_URL', - type: 'string', - required: true, - defaultValue: null, - }, - MIRROR_NODE_URL_HEADER_X_API_KEY: { - envName: 'MIRROR_NODE_URL_HEADER_X_API_KEY', - type: 'array', - required: false, - defaultValue: null, - }, - MIRROR_NODE_URL_WEB3: { - envName: 'MIRROR_NODE_URL_WEB3', - type: 'string', - required: false, - defaultValue: null, - }, - MULTI_SET: { - envName: 'MULTI_SET', - type: 'boolean', - required: false, - defaultValue: null, - }, - // the actual env var in the node process is npm_package_version - npm_package_version: { - envName: 'npm_package_version', - type: 'string', - required: true, - defaultValue: null, - }, - OPERATOR_ID_ETH_SENDRAWTRANSACTION: { - envName: 'OPERATOR_ID_ETH_SENDRAWTRANSACTION', - type: 'string', - required: false, - defaultValue: null, - }, - OPERATOR_ID_MAIN: { - envName: 'OPERATOR_ID_MAIN', - type: 'string', - required: true, - defaultValue: null, - }, - OPERATOR_KEY_ETH_SENDRAWTRANSACTION: { - envName: 'OPERATOR_KEY_ETH_SENDRAWTRANSACTION', - type: 'string', - required: false, - defaultValue: null, - }, - OPERATOR_KEY_FORMAT: { - envName: 'OPERATOR_KEY_FORMAT', - type: 'string', - required: false, - defaultValue: null, - }, - OPERATOR_KEY_MAIN: { - envName: 'OPERATOR_KEY_MAIN', - type: 'string', - required: true, - defaultValue: null, - }, - RATE_LIMIT_DISABLED: { - envName: 'RATE_LIMIT_DISABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - REDIS_ENABLED: { - envName: 'REDIS_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - REDIS_RECONNECT_DELAY_MS: { - envName: 'REDIS_RECONNECT_DELAY_MS', - type: 'number', - required: false, - defaultValue: null, - }, - REDIS_URL: { - envName: 'REDIS_URL', - type: 'string', - required: false, - defaultValue: 'redis://127.0.0.1:6379', - }, - REQUEST_ID_IS_OPTIONAL: { - envName: 'REQUEST_ID_IS_OPTIONAL', - type: 'boolean', - required: false, - defaultValue: null, - }, - SDK_REQUEST_TIMEOUT: { - envName: 'SDK_REQUEST_TIMEOUT', - type: 'number', - required: false, - defaultValue: null, - }, - SEND_RAW_TRANSACTION_SIZE_LIMIT: { - envName: 'SEND_RAW_TRANSACTION_SIZE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - SERVER_PORT: { - envName: 'SERVER_PORT', - type: 'number', - required: false, - defaultValue: 7546, - }, - SERVER_REQUEST_TIMEOUT_MS: { - envName: 'SERVER_REQUEST_TIMEOUT_MS', - type: 'number', - required: false, - defaultValue: null, - }, - SUBSCRIPTIONS_ENABLED: { - envName: 'SUBSCRIPTIONS_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - TEST: { - envName: 'TEST', - type: 'boolean', - required: false, - defaultValue: null, - }, - TEST_GAS_PRICE_DEVIATION: { - envName: 'TEST_GAS_PRICE_DEVIATION', - type: 'number', - required: false, - defaultValue: null, - }, - TEST_INITIAL_ACCOUNT_STARTING_BALANCE: { - envName: 'TEST_INITIAL_ACCOUNT_STARTING_BALANCE', - type: 'number', - required: false, - defaultValue: null, - }, - TEST_TRANSACTION_RECORD_COST_TOLERANCE: { - envName: 'TEST_TRANSACTION_RECORD_COST_TOLERANCE', - type: 'number', - required: false, - defaultValue: null, - }, - TEST_WS_SERVER: { - envName: 'TEST_WS_SERVER', - type: 'boolean', - required: false, - defaultValue: null, - }, - TIER_1_RATE_LIMIT: { - envName: 'TIER_1_RATE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - TIER_2_RATE_LIMIT: { - envName: 'TIER_2_RATE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - TIER_3_RATE_LIMIT: { - envName: 'TIER_3_RATE_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - TX_DEFAULT_GAS: { - envName: 'TX_DEFAULT_GAS', - type: 'number', - required: false, - defaultValue: null, - }, - USE_ASYNC_TX_PROCESSING: { - envName: 'USE_ASYNC_TX_PROCESSING', - type: 'boolean', - required: false, - defaultValue: false, - }, - WEB_SOCKET_HTTP_PORT: { - envName: 'WEB_SOCKET_HTTP_PORT', - type: 'number', - required: false, - defaultValue: 8547, - }, - WEB_SOCKET_PORT: { - envName: 'WEB_SOCKET_PORT', - type: 'number', - required: false, - defaultValue: 8546, - }, - WRITE_SNAPSHOT_ON_MEMORY_LEAK: { - envName: 'WRITE_SNAPSHOT_ON_MEMORY_LEAK', - type: 'boolean', - required: false, - defaultValue: null, - }, - WS_BATCH_REQUESTS_ENABLED: { - envName: 'WS_BATCH_REQUESTS_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - WS_BATCH_REQUESTS_MAX_SIZE: { - envName: 'WS_BATCH_REQUESTS_MAX_SIZE', - type: 'number', - required: false, - defaultValue: null, - }, - WS_CACHE_TTL: { - envName: 'WS_CACHE_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - WS_CONNECTION_LIMIT: { - envName: 'WS_CONNECTION_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - WS_CONNECTION_LIMIT_PER_IP: { - envName: 'WS_CONNECTION_LIMIT_PER_IP', - type: 'number', - required: false, - defaultValue: null, - }, - WS_MAX_INACTIVITY_TTL: { - envName: 'WS_MAX_INACTIVITY_TTL', - type: 'number', - required: false, - defaultValue: null, - }, - WS_MULTIPLE_ADDRESSES_ENABLED: { - envName: 'WS_MULTIPLE_ADDRESSES_ENABLED', - type: 'boolean', - required: false, - defaultValue: null, - }, - WS_NEW_HEADS_ENABLED: { - envName: 'WS_NEW_HEADS_ENABLED', - type: 'boolean', - required: false, - defaultValue: true, - }, - WS_PING_INTERVAL: { - envName: 'WS_PING_INTERVAL', - type: 'number', - required: false, - defaultValue: null, - }, - WS_POLLING_INTERVAL: { - envName: 'WS_POLLING_INTERVAL', - type: 'number', - required: false, - defaultValue: null, - }, - WS_RELAY_URL: { - envName: 'WS_RELAY_URL', - type: 'string', - required: false, - defaultValue: 'ws://127.0.0.1:8546', - }, - WS_SAME_SUB_FOR_SAME_EVENT: { - envName: 'WS_SAME_SUB_FOR_SAME_EVENT', - type: 'boolean', - required: false, - defaultValue: null, - }, - WS_SUBSCRIPTION_LIMIT: { - envName: 'WS_SUBSCRIPTION_LIMIT', - type: 'number', - required: false, - defaultValue: null, - }, - }; + 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 1ed30abaef..48688ad880 100644 --- a/packages/config-service/src/services/index.ts +++ b/packages/config-service/src/services/index.ts @@ -22,6 +22,7 @@ import dotenv from 'dotenv'; import findConfig from 'find-config'; import pino from 'pino'; +import type { ConfigKey, GetTypeOfConfigKey } from './globalConfig'; import { LoggerService } from './loggerService'; import { ValidationService } from './validationService'; @@ -97,7 +98,7 @@ export class ConfigService { * @param name string * @returns string | undefined */ - public static get(name: string): string | number | boolean | null | undefined { - return this.getInstance().envs[name]; + public static get(name: K): GetTypeOfConfigKey | undefined { + return this.getInstance().envs[name] as GetTypeOfConfigKey | undefined; } } diff --git a/packages/config-service/tests/src/services/configService.spec.ts b/packages/config-service/tests/src/services/configService.spec.ts index ab7e062d7b..48d4fb0ed3 100644 --- a/packages/config-service/tests/src/services/configService.spec.ts +++ b/packages/config-service/tests/src/services/configService.spec.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. @@ -21,6 +21,7 @@ import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { ConfigService } from '../../../src/services'; +import type { ConfigKey } from '../../../src/services/globalConfig'; chai.use(chaiAsPromised); @@ -55,7 +56,7 @@ describe('ConfigService tests', async function () { }); it('should return undefined for non-existing variable', async () => { - const res = ConfigService.get('NON_EXISTING_VAR'); + const res = ConfigService.get('NON_EXISTING_VAR' as ConfigKey); expect(res).to.equal(undefined); }); diff --git a/packages/config-service/tests/src/services/loggerService.spec.ts b/packages/config-service/tests/src/services/loggerService.spec.ts index e33faa0f14..dc311f687c 100644 --- a/packages/config-service/tests/src/services/loggerService.spec.ts +++ b/packages/config-service/tests/src/services/loggerService.spec.ts @@ -47,7 +47,7 @@ describe('LoggerService tests', async function () { }); it('should be able to return plain information', async () => { - const envName = GlobalConfig.ENTRIES.CHAIN_ID.envName; + const envName = 'CHAIN_ID'; const res = ConfigService.get(envName); expect(LoggerService.maskUpEnv(envName, res)).to.equal(`${envName} = ${res}`); diff --git a/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts b/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts index 9383d40ed9..ddc1c57785 100644 --- a/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts +++ b/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-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/eth/eth-config.ts b/packages/relay/tests/lib/eth/eth-config.ts index 98077f00fd..647e304c7b 100644 --- a/packages/relay/tests/lib/eth/eth-config.ts +++ b/packages/relay/tests/lib/eth/eth-config.ts @@ -19,6 +19,9 @@ */ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; + +import { nanOrNumberTo0x,numberTo0x } from '../../../dist/formatters'; +import constants from '../../../src/lib/constants'; import { defaultDetailedContractResultByHash, defaultEvmAddress, @@ -29,8 +32,6 @@ import { mockData, toHex, } from '../../helpers'; -import { numberTo0x, nanOrNumberTo0x } from '../../../dist/formatters'; -import constants from '../../../src/lib/constants'; export const BLOCK_TRANSACTION_COUNT = 77; export const GAS_USED_1 = 200000; diff --git a/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts b/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts index 1c8552fe4d..46f75dbe88 100644 --- a/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts +++ b/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts @@ -135,7 +135,7 @@ describe('@ethSendRawTransaction eth_sendRawTransaction spec', async function () }, receiver_sig_required: false, }; - const useAsyncTxProcessing = ConfigService.get('USE_ASYNC_TX_PROCESSING') as boolean; + const useAsyncTxProcessing = ConfigService.get('USE_ASYNC_TX_PROCESSING'); beforeEach(() => { clock = useFakeTimers(); diff --git a/packages/relay/tests/lib/mirrorNodeClient.spec.ts b/packages/relay/tests/lib/mirrorNodeClient.spec.ts index 481c81dfc5..48b9c263fa 100644 --- a/packages/relay/tests/lib/mirrorNodeClient.spec.ts +++ b/packages/relay/tests/lib/mirrorNodeClient.spec.ts @@ -22,10 +22,6 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services' import axios, { AxiosInstance } from 'axios'; import MockAdapter from 'axios-mock-adapter'; import { BigNumber } from 'bignumber.js'; -import { expect } from 'chai'; -import { ethers } from 'ethers'; -import pino from 'pino'; -import { Registry } from 'prom-client'; import { MirrorNodeClientError, predefined } from '../../src'; import { MirrorNodeClient } from '../../src/lib/clients'; @@ -34,6 +30,9 @@ import { SDKClientError } from '../../src/lib/errors/SDKClientError'; import { CacheService } from '../../src/lib/services/cacheService/cacheService'; import { MirrorNodeTransactionRecord, RequestDetails } from '../../src/lib/types'; import { mockData, random20BytesAddress, withOverriddenEnvsInMochaTest } from '../helpers'; +import { expect } from 'chai'; +import { Registry } from 'prom-client'; +import pino from 'pino'; describe('MirrorNodeClient', async function () { this.timeout(20000); @@ -162,7 +161,7 @@ describe('MirrorNodeClient', async function () { withOverriddenEnvsInMochaTest({ MIRROR_NODE_URL_HEADER_X_API_KEY: 'abc123iAManAPIkey' }, () => { it('Can provide custom x-api-key header', async () => { const mirrorNodeInstanceOverridden = new MirrorNodeClient( - ConfigService.get('MIRROR_NODE_URL') || '', + ConfigService.get('MIRROR_NODE_URL' as ConfigKey) || '', logger.child({ name: `mirror-node` }), registry, cacheService, diff --git a/packages/relay/tests/lib/net.spec.ts b/packages/relay/tests/lib/net.spec.ts index 9299aed62e..056ca44c3f 100644 --- a/packages/relay/tests/lib/net.spec.ts +++ b/packages/relay/tests/lib/net.spec.ts @@ -41,7 +41,7 @@ describe('Net', async function () { }); it('should execute "net_version"', function () { - const hederaNetwork: string = (ConfigService.get('HEDERA_NETWORK') || '{}').toLowerCase(); + const hederaNetwork: string = ((ConfigService.get('HEDERA_NETWORK')) || '{}').toLowerCase(); let expectedNetVersion = ConfigService.get('CHAIN_ID') || constants.CHAIN_IDS[hederaNetwork] || '298'; if (expectedNetVersion.startsWith('0x')) expectedNetVersion = parseInt(expectedNetVersion, 16).toString(); diff --git a/packages/relay/tests/lib/openrpc.spec.ts b/packages/relay/tests/lib/openrpc.spec.ts index 94293092ed..fd3ff03dbc 100644 --- a/packages/relay/tests/lib/openrpc.spec.ts +++ b/packages/relay/tests/lib/openrpc.spec.ts @@ -122,7 +122,7 @@ describe('Open RPC Specification', function () { const cacheService = new CacheService(logger.child({ name: `cache` }), registry); // @ts-ignore mirrorNodeInstance = new MirrorNodeClient( - ConfigService.get('MIRROR_NODE_URL') || '', + ConfigService.get('MIRROR_NODE_URL' as ConfigKey) || '', logger.child({ name: `mirror-node` }), registry, cacheService, diff --git a/packages/relay/tests/lib/poller.spec.ts b/packages/relay/tests/lib/poller.spec.ts index 245e302e84..75333a38f8 100644 --- a/packages/relay/tests/lib/poller.spec.ts +++ b/packages/relay/tests/lib/poller.spec.ts @@ -19,12 +19,13 @@ */ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; -import { EthImpl } from '../../src/lib/eth'; import { expect } from 'chai'; import pino from 'pino'; -import { Poller } from '../../src/lib/poller'; -import sinon from 'sinon'; import { Registry } from 'prom-client'; +import sinon from 'sinon'; + +import { EthImpl } from '../../src/lib/eth'; +import { Poller } from '../../src/lib/poller'; const logger = pino({ level: 'trace' }); @@ -187,7 +188,9 @@ describe('Polling', async function () { ), ).to.equal(true); expect( - loggerSpy.calledWith(`Poller: Starting polling with interval=${ConfigService.get('WS_POLLING_INTERVAL')}`), + loggerSpy.calledWith( + `Poller: Starting polling with interval=${ConfigService.get('WS_POLLING_INTERVAL')}`, + ), ).to.equal(true); }); diff --git a/packages/relay/tests/lib/sdkClient.spec.ts b/packages/relay/tests/lib/sdkClient.spec.ts index 0b159666bc..d30f46e507 100644 --- a/packages/relay/tests/lib/sdkClient.spec.ts +++ b/packages/relay/tests/lib/sdkClient.spec.ts @@ -148,7 +148,7 @@ describe('SdkClient', async function () { // mirror node client mirrorNodeClient = new MirrorNodeClient( - ConfigService.get('MIRROR_NODE_URL') || '', + (ConfigService.get('MIRROR_NODE_URL')) || '', logger.child({ name: `mirror-node` }), registry, new CacheService(logger.child({ name: `cache` }), registry), @@ -2743,7 +2743,7 @@ describe('SdkClient', async function () { }); it('Should execute getTransferAmountSumForAccount() to calculate transactionFee by only transfers that are paid by the specify accountId', () => { - const accountId = ConfigService.get('OPERATOR_ID_MAIN') || ''; + const accountId = (ConfigService.get('OPERATOR_ID_MAIN')) || ''; const mockedTxRecord = getMockedTransactionRecord(EthereumTransaction.name, true); const transactionFee = sdkClient.getTransferAmountSumForAccount(mockedTxRecord, accountId); diff --git a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts index 5a97deeecb..fe05b346a7 100644 --- a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts +++ b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts @@ -2,7 +2,7 @@ * * Hedera JSON RPC Relay * - * Copyright (C) 2024 Hedera Hashgraph, LLC + * Copyright (C) 2022-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/services/metricService/metricService.spec.ts b/packages/relay/tests/lib/services/metricService/metricService.spec.ts index 356ac89eb7..84074ae315 100644 --- a/packages/relay/tests/lib/services/metricService/metricService.spec.ts +++ b/packages/relay/tests/lib/services/metricService/metricService.spec.ts @@ -144,15 +144,15 @@ describe('Metric Service', function () { before(() => { // consensus node client - const hederaNetwork = ConfigService.get('HEDERA_NETWORK')! as string; + const hederaNetwork = ConfigService.get('HEDERA_NETWORK')!; if (hederaNetwork in constants.CHAIN_IDS) { client = Client.forName(hederaNetwork); } else { client = Client.forNetwork(JSON.parse(hederaNetwork)); } client = client.setOperator( - AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN')! as string), - Utils.createPrivateKeyBasedOnFormat(ConfigService.get('OPERATOR_KEY_MAIN')! as string), + AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN')!), + Utils.createPrivateKeyBasedOnFormat(ConfigService.get('OPERATOR_KEY_MAIN')!), ); // mirror node client @@ -165,7 +165,7 @@ describe('Metric Service', function () { timeout: 20 * 1000, }); mirrorNodeClient = new MirrorNodeClient( - (ConfigService.get('MIRROR_NODE_URL') as string) || '', + (ConfigService.get('MIRROR_NODE_URL')) || '', logger.child({ name: `mirror-node` }), registry, new CacheService(logger.child({ name: `cache` }), registry), diff --git a/packages/server/tests/acceptance/conformityTests.spec.ts b/packages/server/tests/acceptance/conformityTests.spec.ts index d758ebc949..46bb0d4976 100644 --- a/packages/server/tests/acceptance/conformityTests.spec.ts +++ b/packages/server/tests/acceptance/conformityTests.spec.ts @@ -1,4 +1,4 @@ -/* +/*- * * Hedera JSON RPC Relay * diff --git a/packages/server/tests/acceptance/hbarLimiter.spec.ts b/packages/server/tests/acceptance/hbarLimiter.spec.ts index 42cad4c56f..e6d185068c 100644 --- a/packages/server/tests/acceptance/hbarLimiter.spec.ts +++ b/packages/server/tests/acceptance/hbarLimiter.spec.ts @@ -31,7 +31,7 @@ import { ITransfer, RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/ty import { SpendingPlanConfig } from '@hashgraph/json-rpc-relay/src/lib/types/spendingPlanConfig'; import { estimateFileTransactionsFee, overrideEnvsInMochaDescribe } from '@hashgraph/json-rpc-relay/tests/helpers'; import { expect } from 'chai'; -import dotenv, { config } from 'dotenv'; +import { config } from 'dotenv'; import { BaseContract, ethers } from 'ethers'; import findConfig from 'find-config'; import fs from 'fs'; @@ -126,7 +126,9 @@ describe('@hbarlimiter HBAR Limiter Acceptance Tests', function () { return contract; }; - const transactionReecordCostTolerance = Number(ConfigService.get(`TEST_TRANSACTION_RECORD_COST_TOLERANCE`) || 0.02); + const transactionReecordCostTolerance = Number( + ConfigService.get('TEST_TRANSACTION_RECORD_COST_TOLERANCE' as ConfigKey) || 0.02, + ); const verifyRemainingLimit = (expectedCost: number, remainingHbarsBefore: number, remainingHbarsAfter: number) => { const delta = transactionReecordCostTolerance * expectedCost; @@ -738,7 +740,7 @@ describe('@hbarlimiter HBAR Limiter Acceptance Tests', function () { }; describe('given a valid JSON file with pre-configured spending plans', async () => { - const SPENDING_PLANS_CONFIG_FILE = ConfigService.get('HBAR_SPENDING_PLANS_CONFIG') as string; + const SPENDING_PLANS_CONFIG_FILE = ConfigService.get('HBAR_SPENDING_PLANS_CONFIG'); const configPath = findConfig(SPENDING_PLANS_CONFIG_FILE); if (configPath) { @@ -898,7 +900,7 @@ describe('@hbarlimiter HBAR Limiter Acceptance Tests', function () { return { ...aliasAccount, hbarSpendingPlan: accountAliasPlan.hbarSpendingPlan }; }); - const totalHbarBudget = ConfigService.get(`HBAR_RATE_LIMIT_TINYBAR`) as number; + const totalHbarBudget = ConfigService.get('HBAR_RATE_LIMIT_TINYBAR'); let totalHbarSpent = totalHbarBudget - Number(await metrics.get(testConstants.METRICS.REMAINING_HBAR_LIMIT)); diff --git a/packages/server/tests/acceptance/index.spec.ts b/packages/server/tests/acceptance/index.spec.ts index db5a4739df..2ea9538378 100644 --- a/packages/server/tests/acceptance/index.spec.ts +++ b/packages/server/tests/acceptance/index.spec.ts @@ -23,8 +23,9 @@ import dotenv from 'dotenv'; import path from 'path'; dotenv.config({ path: path.resolve(__dirname, '../../../../.env') }); -// Constants +// External resources import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +// Constants import constants from '@hashgraph/json-rpc-relay/dist/lib/constants'; import { app as wsApp } from '@hashgraph/json-rpc-ws-server/dist/webSocketServer'; // Hashgraph SDK diff --git a/packages/server/tests/acceptance/rateLimiter.spec.ts b/packages/server/tests/acceptance/rateLimiter.spec.ts index 679536dc64..a1154e927b 100644 --- a/packages/server/tests/acceptance/rateLimiter.spec.ts +++ b/packages/server/tests/acceptance/rateLimiter.spec.ts @@ -20,11 +20,12 @@ // Assertions and constants from local resources -import Assertions from '../helpers/assertions'; -import testConstants from '../../tests/helpers/constants'; -import relayConstants from '@hashgraph/json-rpc-relay/dist/lib/constants'; import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import relayConstants from '@hashgraph/json-rpc-relay/dist/lib/constants'; + +import testConstants from '../../tests/helpers/constants'; import RelayClient from '../clients/relayClient'; +import Assertions from '../helpers/assertions'; describe('@ratelimiter Rate Limiters Acceptance Tests', function () { this.timeout(480 * 1000); // 480 seconds @@ -36,9 +37,9 @@ describe('@ratelimiter Rate Limiters Acceptance Tests', function () { let requestId: string; const TIER_2_RATE_LIMIT = - (ConfigService.get('TIER_2_RATE_LIMIT') as unknown as number) || relayConstants.DEFAULT_RATE_LIMIT.TIER_2; + (ConfigService.get('TIER_2_RATE_LIMIT')) || relayConstants.DEFAULT_RATE_LIMIT.TIER_2; const LIMIT_DURATION = - (ConfigService.get('LIMIT_DURATION') as unknown as number) || relayConstants.DEFAULT_RATE_LIMIT.DURATION; + (ConfigService.get('LIMIT_DURATION')) || relayConstants.DEFAULT_RATE_LIMIT.DURATION; describe('RPC Rate Limiter Acceptance Tests', () => { const sendMultipleRequests = async (method: string, params: any[], threshold: number) => { diff --git a/packages/server/tests/acceptance/rpc_batch1.spec.ts b/packages/server/tests/acceptance/rpc_batch1.spec.ts index ac244feb48..3ca08c04b6 100644 --- a/packages/server/tests/acceptance/rpc_batch1.spec.ts +++ b/packages/server/tests/acceptance/rpc_batch1.spec.ts @@ -72,7 +72,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () { let account2Address: string; let expectedGasPrice: string; - const CHAIN_ID = (ConfigService.get('CHAIN_ID') as string) || '0x12a'; + const CHAIN_ID = (ConfigService.get('CHAIN_ID')) || '0x12a'; const requestId = 'rpc_batch1Test'; const requestIdPrefix = Utils.formatRequestIdMessage(requestId); const requestDetails = JSON.stringify(new RequestDetails({ requestId: 'rpc_batch1Test', ipAddress: '0.0.0.0' })); @@ -85,7 +85,7 @@ describe('@api-batch-1 RPC Server Acceptance Tests', function () { ); const gasPriceDeviation = parseFloat((ConfigService.get('TEST_GAS_PRICE_DEVIATION') ?? '0.2') as string); const sendRawTransaction = relay.sendRawTransaction; - const useAsyncTxProcessing = ConfigService.get('USE_ASYNC_TX_PROCESSING') as boolean; + const useAsyncTxProcessing = ConfigService.get('USE_ASYNC_TX_PROCESSING'); /** * resolves long zero addresses to EVM addresses by querying mirror node diff --git a/packages/server/tests/acceptance/serverConfig.spec.ts b/packages/server/tests/acceptance/serverConfig.spec.ts index a9c4086dc7..d80a755850 100644 --- a/packages/server/tests/acceptance/serverConfig.spec.ts +++ b/packages/server/tests/acceptance/serverConfig.spec.ts @@ -17,9 +17,10 @@ * limitations under the License. * */ +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { expect } from 'chai'; + import { Utils } from '../helpers/utils'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; describe('@server-config Server Configuration Options Coverage', function () { describe('Koa Server Timeout', () => { diff --git a/packages/server/tests/integration/server.spec.ts b/packages/server/tests/integration/server.spec.ts index 4b40136921..47577126ab 100644 --- a/packages/server/tests/integration/server.spec.ts +++ b/packages/server/tests/integration/server.spec.ts @@ -21,17 +21,15 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { ConfigServiceTestHelper } from '../../../config-service/tests/configServiceTestHelper'; ConfigServiceTestHelper.appendEnvsFromPath(__dirname + '/test.env'); +import { predefined, RelayImpl } from '@hashgraph/json-rpc-relay'; +import { MirrorNodeClient } from '@hashgraph/json-rpc-relay/dist/lib/clients'; import Axios, { AxiosInstance } from 'axios'; import { expect } from 'chai'; -import sinon from 'sinon'; import { Server } from 'http'; +import Koa from 'koa'; +import sinon from 'sinon'; import { GCProfiler } from 'v8'; -import Assertions from '../helpers/assertions'; -import { TracerType, Validator } from '../../src/validator'; -import RelayCalls from '../../tests/helpers/constants'; -import * as Constants from '../../src/validator/constants'; -import { Utils } from '../helpers/utils'; -import { predefined, RelayImpl } from '@hashgraph/json-rpc-relay'; + import { contractAddress1, contractAddress2, @@ -40,8 +38,11 @@ import { overrideEnvsInMochaDescribe, withOverriddenEnvsInMochaTest, } from '../../../relay/tests/helpers'; -import { MirrorNodeClient } from '@hashgraph/json-rpc-relay/dist/lib/clients'; -import Koa from 'koa'; +import { TracerType, Validator } from '../../src/validator'; +import * as Constants from '../../src/validator/constants'; +import RelayCalls from '../../tests/helpers/constants'; +import Assertions from '../helpers/assertions'; +import { Utils } from '../helpers/utils'; const MISSING_PARAM_ERROR = 'Missing value for required parameter'; diff --git a/packages/ws-server/tests/acceptance/batchRequest.spec.ts b/packages/ws-server/tests/acceptance/batchRequest.spec.ts index 9295708856..0a55083ae7 100644 --- a/packages/ws-server/tests/acceptance/batchRequest.spec.ts +++ b/packages/ws-server/tests/acceptance/batchRequest.spec.ts @@ -19,11 +19,12 @@ */ // external resources +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import { predefined } from '@hashgraph/json-rpc-relay/dist'; import { expect } from 'chai'; import { ethers, WebSocketProvider } from 'ethers'; + import { WsTestConstant, WsTestHelper } from '../helper'; -import { predefined } from '@hashgraph/json-rpc-relay/dist'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; describe('@web-socket-batch-request Batch Requests', async function () { const METHOD_NAME = 'batch_request'; diff --git a/packages/ws-server/tests/acceptance/getTransactionByHash.spec.ts b/packages/ws-server/tests/acceptance/getTransactionByHash.spec.ts index 4b1f4d0a9c..c787afbe1b 100644 --- a/packages/ws-server/tests/acceptance/getTransactionByHash.spec.ts +++ b/packages/ws-server/tests/acceptance/getTransactionByHash.spec.ts @@ -19,17 +19,18 @@ */ // external resources -import { expect } from 'chai'; -import { ethers, WebSocketProvider } from 'ethers'; -import { WsTestConstant, WsTestHelper } from '../helper'; +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters'; +import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; import { ONE_TINYBAR_IN_WEI_HEX } from '@hashgraph/json-rpc-relay/tests/lib/eth/eth-config'; -import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; -import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient'; import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; -import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; +import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; +import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import { expect } from 'chai'; +import { ethers, WebSocketProvider } from 'ethers'; + +import { WsTestConstant, WsTestHelper } from '../helper'; describe('@web-socket-batch-2 eth_getTransactionByHash', async function () { const METHOD_NAME = 'eth_getTransactionByHash'; diff --git a/packages/ws-server/tests/acceptance/getTransactionCount.spec.ts b/packages/ws-server/tests/acceptance/getTransactionCount.spec.ts index 278f6cf97f..8407572064 100644 --- a/packages/ws-server/tests/acceptance/getTransactionCount.spec.ts +++ b/packages/ws-server/tests/acceptance/getTransactionCount.spec.ts @@ -19,16 +19,17 @@ */ // external resources -import { expect } from 'chai'; -import { ethers, WebSocketProvider } from 'ethers'; -import { WsTestConstant, WsTestHelper } from '../helper'; -import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters'; -import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; -import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters'; +import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient'; import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; -import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; +import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; +import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import { expect } from 'chai'; +import { ethers, WebSocketProvider } from 'ethers'; + +import { WsTestConstant, WsTestHelper } from '../helper'; describe('@release @web-socket-batch-2 eth_getTransactionCount', async function () { const METHOD_NAME = 'eth_getTransactionCount'; diff --git a/packages/ws-server/tests/acceptance/getTransactionReceipt.spec.ts b/packages/ws-server/tests/acceptance/getTransactionReceipt.spec.ts index be26f3061b..edae3d0664 100644 --- a/packages/ws-server/tests/acceptance/getTransactionReceipt.spec.ts +++ b/packages/ws-server/tests/acceptance/getTransactionReceipt.spec.ts @@ -19,17 +19,18 @@ */ // external resources -import { expect } from 'chai'; -import { ethers, WebSocketProvider } from 'ethers'; -import { WsTestConstant, WsTestHelper } from '../helper'; +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters'; +import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; import { ONE_TINYBAR_IN_WEI_HEX } from '@hashgraph/json-rpc-relay/tests/lib/eth/eth-config'; -import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; -import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient'; import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; -import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; +import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; +import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import { expect } from 'chai'; +import { ethers, WebSocketProvider } from 'ethers'; + +import { WsTestConstant, WsTestHelper } from '../helper'; describe('@web-socket-batch-2 eth_getTransactionReceipt', async function () { const METHOD_NAME = 'eth_getTransactionReceipt'; diff --git a/packages/ws-server/tests/acceptance/index.spec.ts b/packages/ws-server/tests/acceptance/index.spec.ts index 60b91eb004..c2af1689f3 100644 --- a/packages/ws-server/tests/acceptance/index.spec.ts +++ b/packages/ws-server/tests/acceptance/index.spec.ts @@ -23,10 +23,12 @@ import dotenv from 'dotenv'; import path from 'path'; dotenv.config({ path: path.resolve(__dirname, '../../../../.env') }); -import { Server } from 'node:http'; - import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import constants from '@hashgraph/json-rpc-relay/dist/lib/constants'; +import { Server } from 'node:http'; + +import { ConfigName } from '@hashgraph/json-rpc-config-service/src/services/configName'; +import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; import { setServerTimeout } from '@hashgraph/json-rpc-server/dist/koaJsonRpc/lib/utils'; import app from '@hashgraph/json-rpc-server/dist/server'; import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient'; diff --git a/packages/ws-server/tests/acceptance/rateLimiter.spec.ts b/packages/ws-server/tests/acceptance/rateLimiter.spec.ts index 1607c5fa4a..0c2cd11e3d 100644 --- a/packages/ws-server/tests/acceptance/rateLimiter.spec.ts +++ b/packages/ws-server/tests/acceptance/rateLimiter.spec.ts @@ -19,13 +19,14 @@ */ // external resources -import { expect } from 'chai'; -import { WsTestHelper } from '../helper'; +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import relayConstants from '@hashgraph/json-rpc-relay/dist/lib/constants'; -import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; import { IPRateLimitExceeded } from '@hashgraph/json-rpc-server/dist/koaJsonRpc/lib/RpcError'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import { expect } from 'chai'; + import { ConfigServiceTestHelper } from '../../../config-service/tests/configServiceTestHelper'; +import { WsTestHelper } from '../helper'; describe('@web-socket-ratelimiter Rate Limit Tests', async function () { const rateLimitTier2 = Number(ConfigService.get('TIER_2_RATE_LIMIT') || relayConstants.DEFAULT_RATE_LIMIT.TIER_2); diff --git a/packages/ws-server/tests/acceptance/sendRawTransaction.spec.ts b/packages/ws-server/tests/acceptance/sendRawTransaction.spec.ts index bda0c5f2d4..85a107c16e 100644 --- a/packages/ws-server/tests/acceptance/sendRawTransaction.spec.ts +++ b/packages/ws-server/tests/acceptance/sendRawTransaction.spec.ts @@ -19,19 +19,20 @@ */ // external resources -import { expect } from 'chai'; -import { ethers, WebSocketProvider } from 'ethers'; -import { WsTestConstant, WsTestHelper } from '../helper'; +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { predefined } from '@hashgraph/json-rpc-relay/dist'; -import constants from '@hashgraph/json-rpc-relay/dist/lib/constants'; import { numberTo0x } from '@hashgraph/json-rpc-relay/dist/formatters'; -import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; -import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import constants from '@hashgraph/json-rpc-relay/dist/lib/constants'; +import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; import { ONE_TINYBAR_IN_WEI_HEX } from '@hashgraph/json-rpc-relay/tests/lib/eth/eth-config'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import MirrorClient from '@hashgraph/json-rpc-server/tests/clients/mirrorClient'; import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; -import { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; +import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; +import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; +import { expect } from 'chai'; +import { ethers, WebSocketProvider } from 'ethers'; + +import { WsTestConstant, WsTestHelper } from '../helper'; describe('@web-socket-batch-2 eth_sendRawTransaction', async function () { const METHOD_NAME = 'eth_sendRawTransaction'; diff --git a/packages/ws-server/tests/acceptance/subscribe.spec.ts b/packages/ws-server/tests/acceptance/subscribe.spec.ts index 479705e632..4395a06af1 100644 --- a/packages/ws-server/tests/acceptance/subscribe.spec.ts +++ b/packages/ws-server/tests/acceptance/subscribe.spec.ts @@ -19,20 +19,21 @@ */ // external resources -import WebSocket from 'ws'; -import { ethers } from 'ethers'; -import chai, { expect } from 'chai'; -import { WsTestHelper } from '../helper'; -import { solidity } from 'ethereum-waffle'; -import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; -import Constants from '@hashgraph/json-rpc-server/tests/helpers/constants'; +import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { predefined, WebSocketError } from '@hashgraph/json-rpc-relay/dist'; +import LogContractJson from '@hashgraph/json-rpc-server/tests/contracts/Logs.json'; +import IERC20Json from '@hashgraph/json-rpc-server/tests/contracts/openzeppelin/IERC20.json'; import Assertions from '@hashgraph/json-rpc-server/tests/helpers/assertions'; import assertions from '@hashgraph/json-rpc-server/tests/helpers/assertions'; -import LogContractJson from '@hashgraph/json-rpc-server/tests/contracts/Logs.json'; +import Constants from '@hashgraph/json-rpc-server/tests/helpers/constants'; +import { Utils } from '@hashgraph/json-rpc-server/tests/helpers/utils'; import { AliasAccount } from '@hashgraph/json-rpc-server/tests/types/AliasAccount'; -import IERC20Json from '@hashgraph/json-rpc-server/tests/contracts/openzeppelin/IERC20.json'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import chai, { expect } from 'chai'; +import { solidity } from 'ethereum-waffle'; +import { ethers } from 'ethers'; +import WebSocket from 'ws'; + +import { WsTestHelper } from '../helper'; chai.use(solidity); diff --git a/tools/brownie-example/LICENSE b/tools/brownie-example/LICENSE index b902617e1b..56eb59cd28 100644 --- a/tools/brownie-example/LICENSE +++ b/tools/brownie-example/LICENSE @@ -1,7 +1,6 @@ Hedera Brownie Example 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. You may obtain a copy of the License at