Skip to content

Commit

Permalink
chore: prepend 0x to operator address
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Yanev <victor.yanev@limechain.tech>
  • Loading branch information
victor-yanev committed Dec 16, 2024
1 parent f71eaf6 commit 7764413
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/relay/src/lib/services/hbarLimitService/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { AccountId, Hbar } from '@hashgraph/sdk';
import { Logger } from 'pino';
import { Counter, Gauge, Registry } from 'prom-client';

import { prepend0x } from '../../../formatters';
import { Utils } from '../../../utils';
import constants from '../../constants';
import { EvmAddressHbarSpendingPlanRepository } from '../../db/repositories/hbarLimiter/evmAddressHbarSpendingPlanRepository';
Expand Down Expand Up @@ -101,9 +102,9 @@ export class HbarLimitService implements IHbarLimitService {
const operatorId = ConfigService.get('OPERATOR_ID_MAIN');
const operatorKey = ConfigService.get('OPERATOR_KEY_MAIN');
if (operatorId) {
this.operatorAddress = AccountId.fromString(operatorId as string).toSolidityAddress();
this.setOperatorAddress(AccountId.fromString(operatorId as string).toSolidityAddress());
} else if (operatorKey) {
this.operatorAddress = Utils.createPrivateKeyBasedOnFormat(operatorKey as string).publicKey.toEvmAddress();
this.setOperatorAddress(Utils.createPrivateKeyBasedOnFormat(operatorKey as string).publicKey.toEvmAddress());

Check warning on line 107 in packages/relay/src/lib/services/hbarLimitService/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/relay/src/lib/services/hbarLimitService/index.ts#L107

Added line #L107 was not covered by tests
}

const totalBudget = HbarLimitService.TIER_LIMITS[SubscriptionTier.OPERATOR];
Expand Down Expand Up @@ -176,7 +177,7 @@ export class HbarLimitService implements IHbarLimitService {
* @param {string} operatorAddress - The EVM address of the operator.
*/
setOperatorAddress(operatorAddress: string) {
this.operatorAddress = operatorAddress;
this.operatorAddress = prepend0x(operatorAddress);
}

/**
Expand Down

0 comments on commit 7764413

Please sign in to comment.