diff --git a/apps/sdk-hardhat-integration/hardhat.config.ts b/apps/sdk-hardhat-integration/hardhat.config.ts index dc4ab723d..b762f5bce 100644 --- a/apps/sdk-hardhat-integration/hardhat.config.ts +++ b/apps/sdk-hardhat-integration/hardhat.config.ts @@ -89,7 +89,8 @@ const config: HardhatUserConfig = { }, debug: true, gasPayer: { - delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' + gasPayerServiceUrl: + 'https://sponsor-testnet.vechain.energy/by/269' }, enableDelegation: true, gas: 'auto', @@ -115,7 +116,7 @@ const config: HardhatUserConfig = { }, debug: true, gasPayer: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, enableDelegation: true, diff --git a/packages/hardhat-plugin/tests/helpers/fixture.ts b/packages/hardhat-plugin/tests/helpers/fixture.ts index 1f94e86c1..715f42e78 100644 --- a/packages/hardhat-plugin/tests/helpers/fixture.ts +++ b/packages/hardhat-plugin/tests/helpers/fixture.ts @@ -38,9 +38,10 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa157' ], delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5', - delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' + gasPayerServiceUrl: + 'https://sponsor-testnet.vechain.energy/by/269' } }, expectedAddresses: [ @@ -73,9 +74,10 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ '0x7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa157' ], delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5', - delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' + gasPayerServiceUrl: + 'https://sponsor-testnet.vechain.energy/by/269' } }, expectedAddresses: [ @@ -114,9 +116,10 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ initialIndex: 0 }, delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5', - delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' + gasPayerServiceUrl: + 'https://sponsor-testnet.vechain.energy/by/269' } }, expectedAddresses: [ diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index f8dd628d2..2c202c67f 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -88,14 +88,14 @@ So you can run the rpc-proxy with: #### Use delegation - `-e, --enableDelegation`: Whether to enable delegation. -- `--delegatorPrivateKey `: The private key of the delegator. -- `-d, --delegatorUrl `: The URL of the delegator. - - -e.g.- `npx rpc-proxy -e --delegatorPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` - OR `npx rpc-proxy --enableDelegation --delegatorPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` - - -e.g.- `npx rpc-proxy -e -d https://sponsor-testnet.vechain.energy/by/...` - OR `npx rpc-proxy --enableDelegation --delegatorUrl https://sponsor-testnet.vechain.energy/by/...` - - **NOTE**: --delegatorPrivateKey and --delegatorUrl are mutually exclusive. - - **NOTE**: if --enableDelegation is used, --delegatorPrivateKey OR --delegatorUrl MUST be used. +- `--gasPayerPrivateKey `: The private key of the gasPayer. +- `-s, --gasPayerServiceUrl `: The URL of the gasPayer. + - -e.g.- `npx rpc-proxy -e --gasPayerPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` + OR `npx rpc-proxy --enableDelegation --gasPayerPrivateKey 8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158` + - -e.g.- `npx rpc-proxy -e -s https://sponsor-testnet.vechain.energy/by/...` + OR `npx rpc-proxy --enableDelegation --gasPayerServiceUrl https://sponsor-testnet.vechain.energy/by/...` + - **NOTE**: --gasPayerPrivateKey and --gasPayerServiceUrl are mutually exclusive. + - **NOTE**: if --enableDelegation is used, --gasPayerPrivateKey OR --gasPayerServiceUrl MUST be used. ## Configuration file @@ -153,7 +153,7 @@ Simple testnet configuration with a gasPayer private key: "initialIndex": 0 }, "gasPayer": { - "delegatorPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" + "gasPayerPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" }, "enableDelegation": true } @@ -171,7 +171,7 @@ Simple testnet configuration with a gasPayer private url: "initialIndex": 0 }, "gasPayer": { - "delegatorUrl": "https://sponsor-testnet.vechain.energy/by/..." + "gasPayerServiceUrl": "https://sponsor-testnet.vechain.energy/by/..." }, "enableDelegation": true } diff --git a/packages/rpc-proxy/src/utils/args-validator/args-validator-and-getter.ts b/packages/rpc-proxy/src/utils/args-validator/args-validator-and-getter.ts index d49b68e64..c6a1e9dc5 100644 --- a/packages/rpc-proxy/src/utils/args-validator/args-validator-and-getter.ts +++ b/packages/rpc-proxy/src/utils/args-validator/args-validator-and-getter.ts @@ -145,31 +145,31 @@ const ArgsValidatorAndGetter = { ): Config => { // Both delegation fields are provided - throw an error if ( - options.delegatorPrivateKey !== undefined && - options.delegatorUrl !== undefined && - options.delegatorPrivateKey !== null && - options.delegatorUrl !== null + options.gasPayerPrivateKey !== undefined && + options.gasPayerServiceUrl !== undefined && + options.gasPayerPrivateKey !== null && + options.gasPayerServiceUrl !== null ) { throw new InvalidCommandLineArguments( 'ArgsValidatorAndGetter.delegation()', - 'Both gasPayer private key and gasPayer URL are provided. Only one can be provided', + 'Both gasPayer private key and gasPayer service URL are provided. Only one can be provided', { - flag: '{--delegatorPrivateKey}, {-d , --delegatorUrl}', - value: `{value not provided for security reason} , {${options.delegatorUrl as string}}` + flag: '{--gasPayerPrivateKey}, {-s , --gasPayerServiceUrl}', + value: `{value not provided for security reason} , {${options.gasPayerServiceUrl as string}}` } ); } // Delegation is made with a private key if ( - options.delegatorPrivateKey !== undefined && - options.delegatorPrivateKey !== null + options.gasPayerPrivateKey !== undefined && + options.gasPayerPrivateKey !== null ) { return { ...currentConfiguration, gasPayer: { - gasPayerPrivateKey: ArgsValidator.delegatorPrivateKey( - options.delegatorPrivateKey as string + gasPayerPrivateKey: ArgsValidator.gasPayerPrivateKey( + options.gasPayerPrivateKey as string ) } }; @@ -177,14 +177,14 @@ const ArgsValidatorAndGetter = { // Delegation is made with a gasPayer URL if ( - options.delegatorUrl !== undefined && - options.delegatorUrl !== null + options.gasPayerServiceUrl !== undefined && + options.gasPayerServiceUrl !== null ) { return { ...currentConfiguration, gasPayer: { - gasPayerServiceUrl: ArgsValidator.delegatorUrl( - options.delegatorUrl as string + gasPayerServiceUrl: ArgsValidator.gasPayerServiceUrl( + options.gasPayerServiceUrl as string ) } }; diff --git a/packages/rpc-proxy/src/utils/args-validator/args-validator.ts b/packages/rpc-proxy/src/utils/args-validator/args-validator.ts index e4a500b15..b09ba5bc9 100644 --- a/packages/rpc-proxy/src/utils/args-validator/args-validator.ts +++ b/packages/rpc-proxy/src/utils/args-validator/args-validator.ts @@ -3,8 +3,8 @@ import { checkValidConfigurationFile } from '../config-validator'; import { isValidAccountsAsListOfPrivateKeys, isValidCount, - isValidDelegatorPrivateKey, - isValidDelegatorUrl, + isValidGasPayerPrivateKey, + isValidGasPayerServiceUrl, isValidMnemonic, isValidPort, isValidUrl @@ -252,54 +252,57 @@ const ArgsValidator = { /** * Delegate configuration - * Validate 'delegatorPrivateKey' configuration field. + * Validate 'gasPayerPrivateKey' configuration field. * - * @param delegatorPrivateKey Delegator private key to validate - * @returns Delegator private key if provided AND valid, null otherwise + * @param gasPayerPrivateKey The gasPayer private key to validate + * @returns The gasPayer private key if provided AND valid, null otherwise */ - delegatorPrivateKey: (delegatorPrivateKey: string): string => { + gasPayerPrivateKey: (gasPayerPrivateKey: string): string => { if ( - !isValidDelegatorPrivateKey(delegatorPrivateKey) || - delegatorPrivateKey === '' + !isValidGasPayerPrivateKey(gasPayerPrivateKey) || + gasPayerPrivateKey === '' ) { throw new InvalidCommandLineArguments( - 'ArgsValidator.delegatorPrivateKey()', + 'ArgsValidator.gasPayerPrivateKey()', 'An invalid gasPayer private key provided.', { - flag: '--delegatorPrivateKey', + flag: '--gasPayerPrivateKey', value: 'Value will not be shown for security reasons' } ); } console.log( - `[rpc-proxy]: Delegator private key provided with command line options` + `[rpc-proxy]: The gasPayer private key provided with command line options` ); - return delegatorPrivateKey; + return gasPayerPrivateKey; }, /* - * Validate 'delgatorUrl' configuration field + * Validate 'gasPayerServiceUrl' configuration field * - * @param delegatorUrl Delegator URL to validate - * @returns Delegator URL if provided AND valid, null otherwise + * @param gasPayerServiceUrl The gasPayer service URL to validate + * @returns The gasPayer service URL if provided AND valid, null otherwise */ - delegatorUrl: (delegatorUrl: string): string => { - if (!isValidDelegatorUrl(delegatorUrl) || delegatorUrl === '') { + gasPayerServiceUrl: (gasPayerServiceUrl: string): string => { + if ( + !isValidGasPayerServiceUrl(gasPayerServiceUrl) || + gasPayerServiceUrl === '' + ) { throw new InvalidCommandLineArguments( - 'ArgsValidator.delegatorUrl()', + 'ArgsValidator.gasPayerServiceUrl()', 'Invalid gasPayer url provided. The parameter must be a valid url', { - flag: '-d , --delegatorUrl', - value: delegatorUrl + flag: '-s , --gasPayerServiceUrl', + value: gasPayerServiceUrl } ); } console.log( - `[rpc-proxy]: Delegator url provided with command line options: ${delegatorUrl}` + `[rpc-proxy]: The gasPayer service url provided with command line options: ${gasPayerServiceUrl}` ); - return delegatorUrl; + return gasPayerServiceUrl; } }; diff --git a/packages/rpc-proxy/src/utils/args/args-options.ts b/packages/rpc-proxy/src/utils/args/args-options.ts index a8418ffdf..0b9a3b148 100644 --- a/packages/rpc-proxy/src/utils/args/args-options.ts +++ b/packages/rpc-proxy/src/utils/args/args-options.ts @@ -15,8 +15,8 @@ import { Command, Option, type OptionValues } from 'commander'; * rpc-proxy {--mnemonicInitialIndex} - Initial index to start deriving accounts from the mnemonic * * rpc-proxy {-e|--enableDelegation} - Enable delegation - * rpc-proxy {--delegatorPrivateKey} - Delegator private key - * rpc-proxy {-d|--delegatorUrl} - Delegator URL + * rpc-proxy {--gasPayerPrivateKey} - The gasPayer private key + * rpc-proxy {-s|--gasPayerServiceUrl} - The gasPayer service URL * * rpc-proxy {-v|--verbose} - Enable verbose logging * @@ -77,17 +77,20 @@ function getOptionsFromCommandLine( // Enable delegation boolean .addOption(new Option('-e, --enableDelegation', 'Enable delegation')) - // Delegator configuration (private key) + // The gasPayer configuration (private key) .addOption( new Option( - '--delegatorPrivateKey ', - 'Delegator private key' + '--gasPayerPrivateKey ', + 'The gasPayer private key' ) ) - // Delegator configuration (url) + // The gasPayer configuration (url) .addOption( - new Option('-d, --delegatorUrl ', 'Delegator URL') + new Option( + '-s, --gasPayerServiceUrl ', + 'The gasPayer service URL' + ) ) // Enable verbose logging diff --git a/packages/rpc-proxy/src/utils/args/args-parser.ts b/packages/rpc-proxy/src/utils/args/args-parser.ts index 6b6b2c1c7..ae9f747c4 100644 --- a/packages/rpc-proxy/src/utils/args/args-parser.ts +++ b/packages/rpc-proxy/src/utils/args/args-parser.ts @@ -86,9 +86,9 @@ function parseAndGetFinalConfig( ) { throw new InvalidCommandLineArguments( '_checkIfConfigurationFileHasCorrectStructure()', - `Invalid configuration: Delegation cannot be enabled without a delegator`, + `Invalid configuration: Delegation cannot be enabled without a gasPayer`, { - flag: '--enableDelegation , --delegatorPrivateKey, --delegatorUrl', + flag: '--enableDelegation , --gasPayerPrivateKey, --gasPayerServiceUrl', value: `${options.enableDelegation}, Not provided, Not provided` } ); diff --git a/packages/rpc-proxy/src/utils/args/env-to-args.ts b/packages/rpc-proxy/src/utils/args/env-to-args.ts index ef4b6bc12..0b3d868f1 100644 --- a/packages/rpc-proxy/src/utils/args/env-to-args.ts +++ b/packages/rpc-proxy/src/utils/args/env-to-args.ts @@ -49,11 +49,15 @@ function getArgsFromEnv(): string[] { 'ENABLE_DELEGATION' ), getCliFieldFromEnv( - '--delegatorPrivateKey', - process.env.DELEGATOR_PRIVATE_KEY, - 'DELEGATOR_PRIVATE_KEY' + '--gasPayerPrivateKey', + process.env.GAS_PAYER_PRIVATE_KEY, + 'GAS_PAYER_PRIVATE_KEY' + ), + getCliFieldFromEnv( + '-s', + process.env.GAS_PAYER_SERVICE_URL, + 'GAS_PAYER_SERVICE_URL' ), - getCliFieldFromEnv('-d', process.env.DELEGATOR_URL, 'DELEGATOR_URL'), getCliFieldFromEnv('-v', process.env.VERBOSE, 'VERBOSE'), getCliFieldFromEnv( '-c', diff --git a/packages/rpc-proxy/src/utils/config-validator/config-validator.ts b/packages/rpc-proxy/src/utils/config-validator/config-validator.ts index 0929fb3ad..974f01008 100644 --- a/packages/rpc-proxy/src/utils/config-validator/config-validator.ts +++ b/packages/rpc-proxy/src/utils/config-validator/config-validator.ts @@ -8,8 +8,8 @@ import type { Config } from '../../types'; import { isValidAccountsAsListOfPrivateKeys, isValidAccountsAsMnemonic, - isValidDelegatorPrivateKey, - isValidDelegatorUrl, + isValidGasPayerPrivateKey, + isValidGasPayerServiceUrl, isValidPort, isValidUrl } from '../validators'; @@ -138,11 +138,11 @@ function _checkIfConfigurationFileHasCorrectStructure(filePath: string): void { // Invalid gasPayer private key if ( configFile.gasPayer.gasPayerPrivateKey !== undefined && - !isValidDelegatorPrivateKey(configFile.gasPayer.gasPayerPrivateKey) + !isValidGasPayerPrivateKey(configFile.gasPayer.gasPayerPrivateKey) ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', - `Invalid delegator private key in configuration file: ${absolutePath}. Delegator private key must be a valid private key`, + `Invalid gasPayer private key in configuration file: ${absolutePath}. The gasPayer private key must be a valid private key`, { filePath } @@ -152,11 +152,11 @@ function _checkIfConfigurationFileHasCorrectStructure(filePath: string): void { // Invalid gasPayer url if ( configFile.gasPayer.gasPayerServiceUrl !== undefined && - !isValidDelegatorUrl(configFile.gasPayer.gasPayerServiceUrl) + !isValidGasPayerServiceUrl(configFile.gasPayer.gasPayerServiceUrl) ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', - `Invalid delegator url in configuration file: ${absolutePath}. Delegator url must be a valid URL`, + `Invalid gasPayer service url in configuration file: ${absolutePath}. DThe gasPayer service url must be a valid URL`, { filePath } diff --git a/packages/rpc-proxy/src/utils/validators/validators.ts b/packages/rpc-proxy/src/utils/validators/validators.ts index fcb7a5cb7..bfbeafa8b 100644 --- a/packages/rpc-proxy/src/utils/validators/validators.ts +++ b/packages/rpc-proxy/src/utils/validators/validators.ts @@ -91,7 +91,7 @@ function isValidAccountsAsMnemonic(account: { * @param url - URL to check * @returns True if the url is valid, false otherwise */ -function isValidDelegatorUrl(url: string): boolean { +function isValidGasPayerServiceUrl(url: string): boolean { return isValidUrl(url); } @@ -100,7 +100,7 @@ function isValidDelegatorUrl(url: string): boolean { * @param privateKey - Private key to check * @returns True if the private key is valid, false otherwise */ -function isValidDelegatorPrivateKey(privateKey: string): boolean { +function isValidGasPayerPrivateKey(privateKey: string): boolean { return isValidAccountsAsListOfPrivateKeys([privateKey]); } @@ -112,6 +112,6 @@ export { isValidCount, isValidInitialIndex, isValidAccountsAsMnemonic, - isValidDelegatorUrl, - isValidDelegatorPrivateKey + isValidGasPayerServiceUrl, + isValidGasPayerPrivateKey }; diff --git a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json index 906ffa786..201bb834c 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json @@ -7,7 +7,7 @@ "initialIndex": 0 }, "gasPayer": { - "delegatorPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" + "gasPayerPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" }, "enableDelegation": false } diff --git a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json index aaacb8706..23235098d 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json @@ -7,7 +7,7 @@ "initialIndex": 0 }, "gasPayer": { - "delegatorUrl": "https://testnet.vechain.org" + "gasPayerServiceUrl": "https://testnet.vechain.org" }, "enableDelegation": false } diff --git a/packages/rpc-proxy/tests/fixture.ts b/packages/rpc-proxy/tests/fixture.ts index e8e1d6e68..9ea13c858 100644 --- a/packages/rpc-proxy/tests/fixture.ts +++ b/packages/rpc-proxy/tests/fixture.ts @@ -81,7 +81,7 @@ const invalidParametersConfigurationFilePathFixture = { 'invalid-accounts-mnemonics-proxy-config-5.json' ) ], - 'invalid-delegator': [ + 'invalid-gasPayer': [ path.join( _configFilesDirectory, 'invalid-gas-payer-proxy-config-1.json' diff --git a/packages/rpc-proxy/tests/utils/args/args-options.unit.test.ts b/packages/rpc-proxy/tests/utils/args/args-options.unit.test.ts index c06f943d5..85f2fe581 100644 --- a/packages/rpc-proxy/tests/utils/args/args-options.unit.test.ts +++ b/packages/rpc-proxy/tests/utils/args/args-options.unit.test.ts @@ -159,17 +159,17 @@ describe('Args options tests', () => { [ 'path', 'program', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ] ].forEach((args) => { - const delegatorPrivateKeyOption = getOptionsFromCommandLine( + const gasPayerPrivateKeyOption = getOptionsFromCommandLine( '1.0.0', args ); - expect(delegatorPrivateKeyOption).toBeDefined(); - expect(delegatorPrivateKeyOption.delegatorPrivateKey).toBe( + expect(gasPayerPrivateKeyOption).toBeDefined(); + expect(gasPayerPrivateKeyOption.gasPayerPrivateKey).toBe( '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ); }); @@ -181,17 +181,22 @@ describe('Args options tests', () => { test('Should be able to parse the gasPayer URL option', () => { [ // Normal syntax - ['path', 'program', '--delegatorUrl', 'http://localhost:8080'], + [ + 'path', + 'program', + '--gasPayerServiceUrl', + 'http://localhost:8080' + ], // Short syntax - ['path', 'program', '-d', 'http://localhost:8080'] + ['path', 'program', '-s', 'http://localhost:8080'] ].forEach((args) => { - const delegatorUrlOption = getOptionsFromCommandLine( + const gasPayerServiceUrlOption = getOptionsFromCommandLine( '1.0.0', args ); - expect(delegatorUrlOption).toBeDefined(); - expect(delegatorUrlOption.delegatorUrl).toBe( + expect(gasPayerServiceUrlOption).toBeDefined(); + expect(gasPayerServiceUrlOption.gasPayerServiceUrl).toBe( 'http://localhost:8080' ); }); diff --git a/packages/rpc-proxy/tests/utils/args/args-parser.unit.test.ts b/packages/rpc-proxy/tests/utils/args/args-parser.unit.test.ts index 501721aad..592d9a23b 100644 --- a/packages/rpc-proxy/tests/utils/args/args-parser.unit.test.ts +++ b/packages/rpc-proxy/tests/utils/args/args-parser.unit.test.ts @@ -195,7 +195,7 @@ describe('Args parser tests', () => { 'path', 'program', '--enableDelegation', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ], // Short syntax @@ -203,7 +203,7 @@ describe('Args parser tests', () => { 'path', 'program', '-e', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ] ].forEach((args) => { @@ -220,26 +220,31 @@ describe('Args parser tests', () => { }); /** - * Should be able to delegation options from command line arguments (delegatorPrivateKey and delegatorUrl fields) AND get the configuration + * Should be able to delegation options from command line arguments (gasPayerPrivateKey and gasPayerServiceUrl fields) AND get the configuration */ test('Should be able to get the delegation options from command line arguments AND get the configuration', () => { [ - // Delegator private key + // The gasPayer private key // Normal syntax [ 'path', 'program', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ], - // Delegator URL + // The gasPayer service URL // Normal syntax - ['path', 'program', '--delegatorUrl', 'http://localhost:8080'], + [ + 'path', + 'program', + '--gasPayerServiceUrl', + 'http://localhost:8080' + ], // Short syntax - ['path', 'program', '-d', 'http://localhost:8080'] + ['path', 'program', '-s', 'http://localhost:8080'] ].forEach((args) => { // Get options const options = getOptionsFromCommandLine('1.0.0', args); @@ -582,7 +587,7 @@ describe('Args parser tests', () => { }); /** - * Should NOT be able to parse delegation options from command line arguments (delegatorPrivateKey and delegatorUrl fields) AND get the configuration + * Should NOT be able to parse delegation options from command line arguments (gasPayerPrivateKey and gasPayerServiceUrl fields) AND get the configuration */ test('Should be NOT able to parse delegation options from command line arguments AND get the configuration', () => { [ @@ -592,40 +597,40 @@ describe('Args parser tests', () => { [ 'path', 'program', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158', - '--delegatorUrl', + '--gasPayerServiceUrl', 'http://localhost:8080' ], // Short syntax [ 'path', 'program', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158', - '-d', + '-s', 'http://localhost:8080' ], // Invalid fields // Normal syntax - ['path', 'program', '--delegatorPrivateKey', 'INVALID'], + ['path', 'program', '--gasPayerPrivateKey', 'INVALID'], // Normal syntax - ['path', 'program', '--delegatorUrl', 'INVALID'], + ['path', 'program', '--gasPayerServiceUrl', 'INVALID'], // Short syntax - ['path', 'program', '-d', 'INVALID'], + ['path', 'program', '-s', 'INVALID'], // Empty fields // Normal syntax - ['path', 'program', '--delegatorPrivateKey', ''], + ['path', 'program', '--gasPayerPrivateKey', ''], // Normal syntax - ['path', 'program', '--delegatorUrl', ''], + ['path', 'program', '--gasPayerServiceUrl', ''], // Short syntax - ['path', 'program', '-d', ''], + ['path', 'program', '-s', ''], // Enable delegation without the gasPayer diff --git a/packages/rpc-proxy/tests/utils/args/env-to-args-positive-cases.unit.test.ts b/packages/rpc-proxy/tests/utils/args/env-to-args-positive-cases.unit.test.ts index b0419b38a..86da520ca 100644 --- a/packages/rpc-proxy/tests/utils/args/env-to-args-positive-cases.unit.test.ts +++ b/packages/rpc-proxy/tests/utils/args/env-to-args-positive-cases.unit.test.ts @@ -17,8 +17,8 @@ describe('Environment variables to command line arguments positive cases', () => process.env.MNEMONIC_COUNT = '10'; process.env.MNEMONIC_INITIAL_INDEX = '0'; process.env.ENABLE_DELEGATION = 'true'; - process.env.DELEGATOR_PRIVATE_KEY = '0x1234567890abcdef'; - process.env.DELEGATOR_URL = 'http://localhost:8669'; + process.env.GAS_PAYER_PRIVATE_KEY = '0x1234567890abcdef'; + process.env.GAS_PAYER_SERVICE_URL = 'http://localhost:8669'; process.env.VERBOSE = 'true'; process.env.CONFIGURATION_FILE = 'config.json'; }); @@ -50,9 +50,9 @@ describe('Environment variables to command line arguments positive cases', () => '0', '-e', 'true', - '--delegatorPrivateKey', + '--gasPayerPrivateKey', '0x1234567890abcdef', - '-d', + '-s', 'http://localhost:8669', '-v', 'true', diff --git a/packages/rpc-proxy/tests/utils/config-validator/config-validator.unit.test.ts b/packages/rpc-proxy/tests/utils/config-validator/config-validator.unit.test.ts index 88734ce35..0499c3884 100644 --- a/packages/rpc-proxy/tests/utils/config-validator/config-validator.unit.test.ts +++ b/packages/rpc-proxy/tests/utils/config-validator/config-validator.unit.test.ts @@ -123,7 +123,7 @@ describe('Configuration file validator', () => { */ test('Should not be able to parse a configuration file with invalid gasPayer', () => { invalidParametersConfigurationFilePathFixture[ - 'invalid-delegator' + 'invalid-gasPayer' ].forEach((filePath) => { console.log(filePath); expect(() => {