Skip to content

Commit 097b3af

Browse files
committed
chore: resolve comments
Signed-off-by: nikolay <n.atanasow94@gmail.com>
1 parent d0fb9f4 commit 097b3af

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Unless you need to set a non-default value, it is recommended to only populate o
9292
| `OPCODELOGGER_ENABLED` | "true" | Whether the `opcodeLogger` tracer is enabled for a call to `debug_traceTransaction`. This setting should match the value `hiero.mirror.web3.opcode.tracer.enabled` in the Mirror Node used. See [HIP-801](https://hips.hedera.com/hip/hip-801) for more information. |
9393
| `PAYMASTER_ENABLED` | "false" | Flag to enable or disable the Paymaster functionally |
9494
| `PAYMASTER_WHITELIST` | "[]" | List of "to" addresses that will have fully subsidized transactions if the gasPrice was set to 0 by the signer |
95-
| `PAYMASTER_ACCOUNTS` | "[]" | List of potential paymaster accounts that can be used alongside or instead of the default operator. Allows multiple paymasters without deploying separate instances per contract or address. Each entry defines [[accountId, type ("HEX_ECDSA", "HEX_ED25519"), key, allowance], [account, type, key, allowance]], e.g. `PAYMASTER_ACCOUNTS=[["0.0.9303","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","80"],["0.0.5644","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","100"]]` |
95+
| `PAYMASTER_ACCOUNTS` | "[]" | List of potential paymaster accounts that can be used alongside or instead of the default operator. Allows multiple paymasters without deploying separate instances per contract or address. Each entry defines [[accountId, type ("HEX_ECDSA", "HEX_ED25519"), key, allowanceInHBAR], [account, type, key, allowanceInHBAR]], e.g. `PAYMASTER_ACCOUNTS=[["0.0.9303","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","80"],["0.0.5644","HEX_ECDSA","0x0000000000000000000000000000000000000000000000000000000000000000","350"]]` |
9696
| `PAYMASTER_ACCOUNTS_WHITELISTS` | "[]" | Defines the address (smart contract or account) whitelists for each paymaster account. Each entry maps a paymaster account to an array of addresses it can pay for. Duplicates are overridden by the last configured paymaster. Each entry defines [[accountId, [addressA, addressB]], e.g. `PAYMASTER_ACCOUNTS_WHITELISTS=[["0.0.9303",["0x0000000000000000000000000000000000000062","0x0000000000000000000000000000000000000320"]],["0.0.5644",["0x0000000000000000000000000000000000000001"]]]` |
9797
| `READ_ONLY` | "false" | Starts the JSON-RPC Relay in Read-Only mode. In Read-Only mode, write operations, _e.g._, `eth_sendRawTransaction` or query operations to the Consensus Node will trigger an `Unsupported operation` error. |
9898
| `REDIS_ENABLED` | "true" | Enable usage of Redis as shared cache |

packages/config-service/src/services/loggerService.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22

3+
import { PaymasterAccount } from '@hashgraph/json-rpc-relay/dist/lib/services';
4+
35
import { ConfigKey, GlobalConfig } from './globalConfig';
46

57
export class LoggerService {
@@ -14,15 +16,21 @@ export class LoggerService {
1416
* @param envName
1517
* @param envValue
1618
*/
17-
static maskUpEnv(envName: string, envValue: string | undefined): string {
19+
static maskUpEnv(envName: string, envValue: string | undefined | string[][]): string {
1820
const isSensitiveField: boolean = (this.SENSITIVE_FIELDS as string[]).indexOf(envName) > -1;
1921
const isKnownSecret: boolean =
20-
GlobalConfig.ENTRIES[envName].type === 'string' && !!this.GITHUB_SECRET_PATTERN.exec(envValue ?? '');
22+
GlobalConfig.ENTRIES[envName].type === 'string' &&
23+
typeof envValue === 'string' &&
24+
!!this.GITHUB_SECRET_PATTERN.exec(envValue ?? '');
2125

2226
if (isSensitiveField || isKnownSecret) {
2327
return `${envName} = **********`;
2428
}
2529

30+
if (envName === 'PAYMASTER_ACCOUNTS') {
31+
return `${envName} = [${(envValue as PaymasterAccount[]).map((a) => `[${a[0]},${a[1]},**********,${a[3]}]`)}]`;
32+
}
33+
2634
return `${envName} = ${envValue}`;
2735
}
2836
}

packages/config-service/tests/src/services/loggerService.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,30 @@ describe('LoggerService tests', async function () {
2424

2525
expect(LoggerService.maskUpEnv(envName, res)).to.equal(`${envName} = ${res}`);
2626
});
27+
28+
it('should mast private keys in PAYMASTER_ACCOUNTS', async () => {
29+
const paymaster0 = [
30+
'0.0.801',
31+
'HEX_ECDSA',
32+
'0x1111111111111111111111111111111111111111111111111111111111111111',
33+
'300',
34+
];
35+
const paymaster1 = [
36+
'0.0.802',
37+
'HEX_ECDSA',
38+
'0x2222222222222222222222222222222222222222222222222222222222222222',
39+
'200',
40+
];
41+
const res = LoggerService.maskUpEnv('PAYMASTER_ACCOUNTS', [paymaster0, paymaster1]);
42+
43+
expect(res).to.contain(paymaster0[0]);
44+
expect(res).to.contain(paymaster1[0]);
45+
expect(res).to.contain(paymaster0[3]);
46+
expect(res).to.contain(paymaster1[3]);
47+
48+
expect(res.match(/\*{10}/g).length).to.equal(2);
49+
expect(res.match(/HEX_ECDSA/g).length).to.equal(2);
50+
expect(res).to.not.contain(paymaster0[2]);
51+
expect(res).to.not.contain(paymaster1[2]);
52+
});
2753
});

0 commit comments

Comments
 (0)