diff --git a/packages/config-service/src/services/globalConfig.ts b/packages/config-service/src/services/globalConfig.ts index f44eda0c8b..8df62aa2e6 100644 --- a/packages/config-service/src/services/globalConfig.ts +++ b/packages/config-service/src/services/globalConfig.ts @@ -18,6 +18,22 @@ * */ +type TypeStrToType = Tstr extends 'string' + ? string + : Tstr extends 'boolean' + ? boolean + : Tstr extends 'number' + ? number + : Tstr extends 'array' + ? unknown[] + : never; + +type GetTypeStrOfKey = K extends keyof typeof _CONFIG + ? typeof _CONFIG[K]['type'] + : never; + +export type TypeOfKey = TypeStrToType>; + export interface ConfigProperty { envName: string; type: string; @@ -25,8 +41,7 @@ export interface ConfigProperty { defaultValue: string | number | boolean | null; } -export class GlobalConfig { - public static readonly ENTRIES: Record = { +const _CONFIG = { BATCH_REQUESTS_ENABLED: { envName: 'BATCH_REQUESTS_ENABLED', type: 'boolean', @@ -568,6 +583,12 @@ export class GlobalConfig { required: false, defaultValue: null, }, + SERVER_HOST: { + envName: 'SERVER_HOST', + type: 'string', + required: false, + defaultValue: null, + }, SERVER_PORT: { envName: 'SERVER_PORT', type: 'number', @@ -742,5 +763,10 @@ export class GlobalConfig { required: false, defaultValue: null, }, - }; +} satisfies { [key: string]: ConfigProperty }; + +export type ConfigKey = keyof typeof _CONFIG; + +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 eb8bae306b..2b0e9efea8 100644 --- a/packages/config-service/src/services/index.ts +++ b/packages/config-service/src/services/index.ts @@ -21,6 +21,8 @@ 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'; @@ -97,7 +99,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): TypeOfKey | undefined { + return this.getInstance().envs[name] as TypeOfKey | 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..428e75979d 100644 --- a/packages/config-service/tests/src/services/loggerService.spec.ts +++ b/packages/config-service/tests/src/services/loggerService.spec.ts @@ -47,8 +47,8 @@ describe('LoggerService tests', async function () { }); it('should be able to return plain information', async () => { - const envName = GlobalConfig.ENTRIES.CHAIN_ID.envName; - const res = ConfigService.get(envName); + const envName = 'CHAIN_ID'; + const res = ConfigService.get(envName) as string | undefined; 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 e33f77c8ec..957e3be9ac 100644 --- a/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts +++ b/packages/relay/tests/lib/config/hbarSpendingPlanConfigService.spec.ts @@ -1,4 +1,4 @@ -/* +/*- * * Hedera JSON RPC Relay * 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_common.spec.ts b/packages/relay/tests/lib/eth/eth_common.spec.ts index 9fc13ccf25..8a2dda285e 100644 --- a/packages/relay/tests/lib/eth/eth_common.spec.ts +++ b/packages/relay/tests/lib/eth/eth_common.spec.ts @@ -20,9 +20,10 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { expect, use } from 'chai'; -import { Registry } from 'prom-client'; -import pino from 'pino'; import chaiAsPromised from 'chai-as-promised'; +import pino from 'pino'; +import { Registry } from 'prom-client'; + import { RelayImpl } from '../../../src'; import { RequestDetails } from '../../../src/lib/types'; diff --git a/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts b/packages/relay/tests/lib/eth/eth_sendRawTransaction.spec.ts index 28970ef870..fa90b63713 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/hapiService.spec.ts b/packages/relay/tests/lib/hapiService.spec.ts index d93b6d07d5..0db52b3dc3 100644 --- a/packages/relay/tests/lib/hapiService.spec.ts +++ b/packages/relay/tests/lib/hapiService.spec.ts @@ -85,7 +85,9 @@ describe('HAPI Service', async function () { withOverriddenEnvsInMochaTest({ HAPI_CLIENT_TRANSACTION_RESET: 2 }, () => { it('should be able to reinitialise SDK instance upon reaching transaction limit', async function () { hapiService = new HAPIService(logger, registry, cacheService, eventEmitter, hbarLimitService); - expect(hapiService.getTransactionCount()).to.eq(parseInt(ConfigService.get('HAPI_CLIENT_TRANSACTION_RESET')!)); + expect(hapiService.getTransactionCount()).to.eq( + parseInt(ConfigService.get('HAPI_CLIENT_TRANSACTION_RESET')!), + ); const oldClientInstance = hapiService.getMainClientInstance(); let oldSDKInstance = hapiService.getSDKClient(); // decrease transaction limit by taking the instance @@ -105,7 +107,9 @@ describe('HAPI Service', async function () { withOverriddenEnvsInMochaTest({ HAPI_CLIENT_DURATION_RESET: 100 }, () => { it('should be able to reinitialise SDK instance upon reaching time limit', async function () { hapiService = new HAPIService(logger, registry, cacheService, eventEmitter, hbarLimitService); - expect(hapiService.getTimeUntilReset()).to.eq(parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')!)); + expect(hapiService.getTimeUntilReset()).to.eq( + parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')!), + ); const oldClientInstance = hapiService.getMainClientInstance(); await new Promise((r) => setTimeout(r, 200)); // await to reach time limit @@ -113,7 +117,9 @@ describe('HAPI Service', async function () { const newSDKInstance = hapiService.getSDKClient(); const newClientInstance = hapiService.getMainClientInstance(); - expect(hapiService.getTimeUntilReset()).to.eq(parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')!)); + expect(hapiService.getTimeUntilReset()).to.eq( + parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')), + ); expect(oldSDKInstance).to.not.be.equal(newSDKInstance); expect(oldClientInstance).to.not.be.equal(newClientInstance); }); @@ -122,7 +128,9 @@ describe('HAPI Service', async function () { withOverriddenEnvsInMochaTest({ HAPI_CLIENT_ERROR_RESET: '[50]' }, () => { it('should be able to reinitialise SDK instance upon error status code encounter', async function () { hapiService = new HAPIService(logger, registry, cacheService, eventEmitter, hbarLimitService); - expect(hapiService.getErrorCodes()[0]).to.eq(JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0]); + expect(hapiService.getErrorCodes()[0]).to.eq( + JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0], + ); const oldClientInstance = hapiService.getMainClientInstance(); const oldSDKInstance = hapiService.getSDKClient(); @@ -132,7 +140,9 @@ describe('HAPI Service', async function () { expect(oldSDKInstance).to.not.be.equal(newSDKInstance); expect(oldClientInstance).to.not.be.equal(newClientInstance); - expect(hapiService.getErrorCodes()[0]).to.eq(JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0]); + expect(hapiService.getErrorCodes()[0]).to.eq( + JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0], + ); }); }); @@ -146,15 +156,21 @@ describe('HAPI Service', async function () { it('should be able to reset all counter upon reinitialization of the SDK Client', async function () { hapiService = new HAPIService(logger, registry, cacheService, eventEmitter, hbarLimitService); - expect(hapiService.getErrorCodes()[0]).to.eq(JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0]); + expect(hapiService.getErrorCodes()[0]).to.eq( + JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0], + ); const oldClientInstance = hapiService.getMainClientInstance(); const oldSDKInstance = hapiService.getSDKClient(); hapiService.decrementErrorCounter(errorStatus); const newSDKInstance = hapiService.getSDKClient(); const newClientInstance = hapiService.getMainClientInstance(); - expect(hapiService.getTimeUntilReset()).to.eq(parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')!)); - expect(hapiService.getErrorCodes()[0]).to.eq(JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0]); + expect(hapiService.getTimeUntilReset()).to.eq( + parseInt(ConfigService.get('HAPI_CLIENT_DURATION_RESET')!), + ); + expect(hapiService.getErrorCodes()[0]).to.eq( + JSON.parse(ConfigService.get('HAPI_CLIENT_ERROR_RESET')!)[0], + ); expect(hapiService.getTransactionCount()).to.eq( parseInt(ConfigService.get('HAPI_CLIENT_TRANSACTION_RESET')!) - 1, ); // one less because we took the instance once and decreased the counter @@ -204,7 +220,9 @@ describe('HAPI Service', async function () { () => { it('should not be able to reinitialise and decrement counters, if it is disabled', async function () { hapiService = new HAPIService(logger, registry, cacheService, eventEmitter, hbarLimitService); - expect(hapiService.getTransactionCount()).to.eq(parseInt(ConfigService.get('HAPI_CLIENT_TRANSACTION_RESET')!)); + expect(hapiService.getTransactionCount()).to.eq( + parseInt(ConfigService.get('HAPI_CLIENT_TRANSACTION_RESET')!), + ); const oldClientInstance = hapiService.getMainClientInstance(); const oldSDKInstance = hapiService.getSDKClient(); diff --git a/packages/relay/tests/lib/mirrorNodeClient.spec.ts b/packages/relay/tests/lib/mirrorNodeClient.spec.ts index 9e9d2fda21..d08d899e68 100644 --- a/packages/relay/tests/lib/mirrorNodeClient.spec.ts +++ b/packages/relay/tests/lib/mirrorNodeClient.spec.ts @@ -167,7 +167,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')) || '', 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 8458d19d10..0458480deb 100644 --- a/packages/relay/tests/lib/net.spec.ts +++ b/packages/relay/tests/lib/net.spec.ts @@ -40,7 +40,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 1ca3274505..0ed459e712 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')) || '', 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 43e26cc3d4..b406d4942b 100644 --- a/packages/relay/tests/lib/sdkClient.spec.ts +++ b/packages/relay/tests/lib/sdkClient.spec.ts @@ -102,7 +102,7 @@ describe('SdkClient', async function () { overrideEnvsInMochaDescribe({ GET_RECORD_DEFAULT_TO_CONSENSUS_NODE: true }); before(() => { - const hederaNetwork = ConfigService.get('HEDERA_NETWORK')!; + const hederaNetwork = ConfigService.get('HEDERA_NETWORK')! as string; if (hederaNetwork in constants.CHAIN_IDS) { client = Client.forName(hederaNetwork); } else { @@ -110,8 +110,8 @@ describe('SdkClient', async function () { } client = client.setOperator( - AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN')!), - Utils.createPrivateKeyBasedOnFormat(ConfigService.get('OPERATOR_KEY_MAIN')!), + AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN')! as string), + Utils.createPrivateKeyBasedOnFormat(ConfigService.get('OPERATOR_KEY_MAIN')! as string), ); const duration = constants.HBAR_RATE_LIMIT_DURATION; eventEmitter = new EventEmitter(); @@ -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/debugService/debug.spec.ts b/packages/relay/tests/lib/services/debugService/debug.spec.ts index 7b46dc9675..5e3a339f90 100644 --- a/packages/relay/tests/lib/services/debugService/debug.spec.ts +++ b/packages/relay/tests/lib/services/debugService/debug.spec.ts @@ -19,22 +19,23 @@ */ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; +import MockAdapter from 'axios-mock-adapter'; import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import MockAdapter from 'axios-mock-adapter'; +import pino from 'pino'; import { Registry } from 'prom-client'; + +import { predefined } from '../../../../src'; +import { strip0x } from '../../../../src/formatters'; import { MirrorNodeClient } from '../../../../src/lib/clients'; -import pino from 'pino'; +import { IOpcodesResponse } from '../../../../src/lib/clients/models/IOpcodesResponse'; import { TracerType } from '../../../../src/lib/constants'; -import { DebugService } from '../../../../src/lib/services/debugService'; -import { getQueryParams, withOverriddenEnvsInMochaTest } from '../../../helpers'; -import RelayAssertions from '../../../assertions'; -import { predefined } from '../../../../src'; import { CacheService } from '../../../../src/lib/services/cacheService/cacheService'; +import { DebugService } from '../../../../src/lib/services/debugService'; import { CommonService } from '../../../../src/lib/services/ethService'; -import { IOpcodesResponse } from '../../../../src/lib/clients/models/IOpcodesResponse'; -import { strip0x } from '../../../../src/formatters'; import { RequestDetails } from '../../../../src/lib/types'; +import RelayAssertions from '../../../assertions'; +import { getQueryParams, withOverriddenEnvsInMochaTest } from '../../../helpers'; chai.use(chaiAsPromised); diff --git a/packages/relay/tests/lib/services/eth/filter.spec.ts b/packages/relay/tests/lib/services/eth/filter.spec.ts index 60b0c0217b..e56b6a6c0b 100644 --- a/packages/relay/tests/lib/services/eth/filter.spec.ts +++ b/packages/relay/tests/lib/services/eth/filter.spec.ts @@ -21,11 +21,17 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import MockAdapter from 'axios-mock-adapter'; import { expect } from 'chai'; +import pino from 'pino'; import { Registry } from 'prom-client'; +import { v4 as uuid } from 'uuid'; + +import { predefined } from '../../../../src'; import { MirrorNodeClient } from '../../../../src/lib/clients'; -import pino from 'pino'; import constants from '../../../../src/lib/constants'; +import { CacheService } from '../../../../src/lib/services/cacheService/cacheService'; import { CommonService, FilterService } from '../../../../src/lib/services/ethService'; +import { RequestDetails } from '../../../../src/lib/types'; +import RelayAssertions from '../../../assertions'; import { defaultBlock, defaultEvmAddress, @@ -34,11 +40,6 @@ import { toHex, withOverriddenEnvsInMochaTest, } from '../../../helpers'; -import RelayAssertions from '../../../assertions'; -import { predefined } from '../../../../src'; -import { CacheService } from '../../../../src/lib/services/cacheService/cacheService'; -import { RequestDetails } from '../../../../src/lib/types'; -import { v4 as uuid } from 'uuid'; const logger = pino(); const registry = new Registry(); diff --git a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts index 0b857e6297..7d475e8d1a 100644 --- a/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts +++ b/packages/relay/tests/lib/services/hbarLimitService/hbarLimitService.spec.ts @@ -1,4 +1,4 @@ -/* +/*- * * Hedera JSON RPC Relay * @@ -61,7 +61,7 @@ describe('HBAR Rate Limit Service', function () { const mockPlanId = uuidV4(randomBytes(16)); const todayAtMidnight = new Date().setHours(0, 0, 0, 0); const operatorAddress = prepend0x( - AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN') as string).toSolidityAddress(), + AccountId.fromString(ConfigService.get('OPERATOR_ID_MAIN')).toSolidityAddress(), ); const requestDetails = new RequestDetails({ requestId: 'hbarLimitServiceTest', ipAddress: mockIpAddress }); diff --git a/packages/relay/tests/lib/services/metricService/metricService.spec.ts b/packages/relay/tests/lib/services/metricService/metricService.spec.ts index 3462192000..fb22cf052d 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/relay/tests/lib/web3.spec.ts b/packages/relay/tests/lib/web3.spec.ts index 30fda3912a..6d746d874d 100644 --- a/packages/relay/tests/lib/web3.spec.ts +++ b/packages/relay/tests/lib/web3.spec.ts @@ -20,8 +20,9 @@ import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; import { expect } from 'chai'; -import { Registry } from 'prom-client'; import pino from 'pino'; +import { Registry } from 'prom-client'; + import { RelayImpl } from '../../src'; import { withOverriddenEnvsInMochaTest } from '../helpers'; 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 a805d066fc..10b78bdaf7 100644 --- a/packages/server/tests/acceptance/hbarLimiter.spec.ts +++ b/packages/server/tests/acceptance/hbarLimiter.spec.ts @@ -73,8 +73,8 @@ describe('@hbarlimiter HBAR Limiter Acceptance Tests', function () { metrics: MetricsClient; relayIsLocal: boolean; } = global; - const mockTTL = (ConfigService.get('HBAR_RATE_LIMIT_DURATION') as number) || 86400000; // 1 day - const operatorAccount = (ConfigService.get('OPERATOR_ID_MAIN') as string) || DOT_ENV.OPERATOR_ID_MAIN || ''; + const mockTTL = (ConfigService.get('HBAR_RATE_LIMIT_DURATION')) || 86400000; // 1 day + const operatorAccount = (ConfigService.get('OPERATOR_ID_MAIN')) || DOT_ENV.OPERATOR_ID_MAIN || ''; const fileAppendChunkSize = Number(ConfigService.get('FILE_APPEND_CHUNK_SIZE')) || 5120; const requestId = 'hbarLimiterTest'; const requestDetails = new RequestDetails({ requestId: requestId, ipAddress: '0.0.0.0' }); @@ -127,7 +127,7 @@ 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') || 0.02); const verifyRemainingLimit = (expectedCost: number, remainingHbarsBefore: number, remainingHbarsAfter: number) => { const delta = transactionReecordCostTolerance * expectedCost; @@ -739,7 +739,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) { @@ -899,7 +899,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 619c388225..659617df06 100644 --- a/packages/server/tests/acceptance/index.spec.ts +++ b/packages/server/tests/acceptance/index.spec.ts @@ -18,38 +18,33 @@ * */ // 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 +import { AccountId, Hbar } from '@hashgraph/sdk'; import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; import dotenv from 'dotenv'; +// Other external resources +import fs from 'fs'; +import { Server } from 'http'; import path from 'path'; import pino from 'pino'; -import chaiAsPromised from 'chai-as-promised'; import { GCProfiler } from 'v8'; -// Other external resources -import fs from 'fs'; - -// Clients -import ServicesClient from '../clients/servicesClient'; -import MirrorClient from '../clients/mirrorClient'; -import RelayClient from '../clients/relayClient'; -import MetricsClient from '../clients/metricsClient'; - // Server related import app from '../../dist/server'; -import { app as wsApp } from '@hashgraph/json-rpc-ws-server/dist/webSocketServer'; - -// Hashgraph SDK -import { AccountId, Hbar } from '@hashgraph/sdk'; - -// Constants -import constants from '@hashgraph/json-rpc-relay/dist/lib/constants'; - +import { setServerTimeout } from '../../src/koaJsonRpc/lib/utils'; +import MetricsClient from '../clients/metricsClient'; +import MirrorClient from '../clients/mirrorClient'; +import RelayClient from '../clients/relayClient'; +// Clients +import ServicesClient from '../clients/servicesClient'; // Utils and types import { Utils } from '../helpers/utils'; import { AliasAccount } from '../types/AliasAccount'; -import { setServerTimeout } from '../../src/koaJsonRpc/lib/utils'; -import { ConfigService } from '@hashgraph/json-rpc-config-service/dist/services'; -import { Server } from 'http'; chai.use(chaiAsPromised); dotenv.config({ path: path.resolve(__dirname, '../../../../.env') }); 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 0c41b43478..3d8c6f6a4b 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 6cb0202326..88d477fbc8 100644 --- a/packages/ws-server/tests/acceptance/index.spec.ts +++ b/packages/ws-server/tests/acceptance/index.spec.ts @@ -17,25 +17,26 @@ * limitations under the License. * */ -import chai from 'chai'; -import path from 'path'; -import pino from 'pino'; -import dotenv from 'dotenv'; -import chaiAsPromised from 'chai-as-promised'; -import fs from 'fs'; -import { AccountId, Hbar } from '@hashgraph/sdk'; -import app from '@hashgraph/json-rpc-server/dist/server'; +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 RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; +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'; -import { app as wsApp } from '@hashgraph/json-rpc-ws-server/dist/webSocketServer'; +import RelayClient from '@hashgraph/json-rpc-server/tests/clients/relayClient'; import ServicesClient from '@hashgraph/json-rpc-server/tests/clients/servicesClient'; 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 { RequestDetails } from '@hashgraph/json-rpc-relay/dist/lib/types'; -import { Server } from 'node:http'; -import { setServerTimeout } from '@hashgraph/json-rpc-server/dist/koaJsonRpc/lib/utils'; +import { app as wsApp } from '@hashgraph/json-rpc-ws-server/dist/webSocketServer'; +import { AccountId, Hbar } from '@hashgraph/sdk'; +import chai from 'chai'; +import chaiAsPromised from 'chai-as-promised'; +import dotenv from 'dotenv'; +import fs from 'fs'; +import path from 'path'; +import pino from 'pino'; chai.use(chaiAsPromised); 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