From ec5287b64bbb201d5b4711e4722257cc274e0483 Mon Sep 17 00:00:00 2001 From: lucanicoladebiasi Date: Thu, 13 Feb 2025 15:35:00 +0000 Subject: [PATCH] chore: BNC 2 backport --- .github/workflows/rpc-proxy-docker.yml | 14 ++-- apps/sdk-cloudflare-integration/src/index.ts | 2 +- apps/sdk-hardhat-integration/README.md | 6 +- .../sdk-hardhat-integration/hardhat.config.ts | 16 ++--- docker-compose.rpc-proxy.yml | 14 ++-- docker/rpc-proxy/Dockerfile | 4 +- docs/contracts.md | 5 +- docs/diagrams/architecture/transaction.md | 2 +- .../contracts/contract-delegation-ERC20.ts | 9 +-- ....ts => full-flow-gas-payer-private-key.ts} | 9 ++- ....ts => full-flow-gas-payer-service-url.ts} | 11 ++-- ...delegator.ts => full-flow-no-gas-payer.ts} | 4 +- docs/templates/transactions.md | 10 +-- docs/transactions.md | 19 +++--- packages/aws-kms-adapter/README.md | 14 ++-- .../aws-kms-adapter/src/KMSVeChainProvider.ts | 7 ++ .../aws-kms-adapter/src/KMSVeChainSigner.ts | 14 ++-- .../tests/KMSVeChainSigner.solo.test.ts | 6 +- .../tests/KMSVeChainSigner.testnet.test.ts | 2 +- packages/hardhat-plugin/README.md | 2 +- .../src/helpers/provider-helper.ts | 8 +-- packages/hardhat-plugin/src/index.ts | 2 +- .../hardhat-plugin/src/type-extensions.ts | 4 +- .../hardhat.config.ts | 3 +- .../hardhat.config.ts | 2 +- .../hardhat.config.ts | 2 +- .../hardhat.config.ts | 2 +- .../hardhat-plugin/tests/helpers/fixture.ts | 12 ++-- .../helpers/provider-helpers.unit.test.ts | 2 +- .../abstract-provider-internal-wallet.ts | 26 ++++---- .../provider-internal-base-wallet.ts | 8 +-- .../hd-wallet/provider-internal-hd-wallet.ts | 4 +- .../provider-internal-wallets/types.d.ts | 18 ++--- .../hardhat-provider/hardhat-provider.ts | 6 +- .../vechain-private-key-signer.ts | 16 ++--- .../src/thor-client/blocks/blocks-module.ts | 2 +- .../network/src/thor-client/blocks/types.d.ts | 5 ++ .../helpers/delegation-handler.ts | 64 +++++++++--------- .../src/thor-client/transactions/types.d.ts | 6 +- packages/network/tests/fixture.ts | 12 ++-- .../tests/provider/formatter/fixture.ts | 2 +- ...provider-internal-base-wallet.unit.test.ts | 59 ++++++++--------- .../hd-wallet/fixture.ts | 8 +-- .../provider-internal-hd-wallet.unit.test.ts | 8 +-- .../vechain/vechain-provider.testnet.test.ts | 2 +- .../eth_sendTransaction.solo.test.ts | 16 ++--- .../methods/eth_sendTransaction/fixture.ts | 6 +- .../eth_signTransaction.testnet.test.ts | 18 ++--- .../vechain-private-key-signer/fixture.ts | 18 ++--- .../vechain-private-key-signer.solo.test.ts | 4 +- ...vechain-private-key-signer.testnet.test.ts | 8 +-- .../tests/thor-client/blocks/fixture.ts | 2 +- .../contracts/contract.erc20.solo.test.ts | 26 ++++---- .../contracts/contract.erc20.testnet.test.ts | 8 +-- .../contracts/contract.event.solo.test.ts | 16 ++--- .../tests/thor-client/contracts/fixture.ts | 20 +++--- .../transactions/fixture-thorest.ts | 4 +- .../helpers/delegation-handler.unit.test.ts | 18 ++--- .../transactions/helpers/fixture.ts | 66 +++++++++---------- .../transactions-thorest.solo.test.ts | 2 +- packages/rpc-proxy/README.md | 15 +++-- packages/rpc-proxy/src/index.ts | 4 +- packages/rpc-proxy/src/types.d.ts | 4 +- .../args-validator-and-getter.ts | 12 ++-- .../utils/args-validator/args-validator.ts | 4 +- .../rpc-proxy/src/utils/args/args-parser.ts | 6 +- .../config-validator/config-validator.ts | 32 +++++---- .../src/utils/validators/validators.ts | 4 +- ...t-proxy-config-gas-payer-private-key.json} | 4 +- ...> correct-proxy-config-gas-payer-url.json} | 4 +- ... => invalid-gas-payer-proxy-config-1.json} | 6 +- ... => invalid-gas-payer-proxy-config-2.json} | 6 +- ... => invalid-gas-payer-proxy-config-3.json} | 8 +-- packages/rpc-proxy/tests/fixture.ts | 10 +-- .../utils/args/args-options.unit.test.ts | 8 +-- .../tests/utils/args/args-parser.unit.test.ts | 4 +- .../config-validator.unit.test.ts | 8 ++- 77 files changed, 418 insertions(+), 406 deletions(-) rename docs/examples/transactions/{full-flow-delegator-private-key.ts => full-flow-gas-payer-private-key.ts} (92%) rename docs/examples/transactions/{full-flow-delegator-url.ts => full-flow-gas-payer-service-url.ts} (90%) rename docs/examples/transactions/{full-flow-no-delegator.ts => full-flow-no-gas-payer.ts} (96%) rename packages/rpc-proxy/tests/config-files-fixtures/{correct-proxy-config-delegator-private-key.json => correct-proxy-config-gas-payer-private-key.json} (95%) rename packages/rpc-proxy/tests/config-files-fixtures/{correct-proxy-config-delegator-url.json => correct-proxy-config-gas-payer-url.json} (94%) rename packages/rpc-proxy/tests/config-files-fixtures/{invalid-delegator-proxy-config-2.json => invalid-gas-payer-proxy-config-1.json} (82%) rename packages/rpc-proxy/tests/config-files-fixtures/{invalid-delegator-proxy-config-1.json => invalid-gas-payer-proxy-config-2.json} (81%) rename packages/rpc-proxy/tests/config-files-fixtures/{invalid-delegator-proxy-config-3.json => invalid-gas-payer-proxy-config-3.json} (73%) diff --git a/.github/workflows/rpc-proxy-docker.yml b/.github/workflows/rpc-proxy-docker.yml index 099dac837..d1b6938f9 100644 --- a/.github/workflows/rpc-proxy-docker.yml +++ b/.github/workflows/rpc-proxy-docker.yml @@ -19,11 +19,11 @@ jobs: - name: Set up QEMU if: ${{ github.event_name != 'pull_request' }} uses: docker/setup-qemu-action@v3 - + - name: Set up Docker Buildx if: ${{ github.event_name != 'pull_request' }} uses: docker/setup-buildx-action@v3 - + - name: Login to Docker Hub if: ${{ github.event_name != 'pull_request' }} uses: docker/login-action@v3 @@ -36,7 +36,7 @@ jobs: uses: docker/metadata-action@v5 with: images: vechain/sdk-rpc-proxy - + - name: Build and export to Docker uses: docker/build-push-action@v6 with: @@ -48,8 +48,10 @@ jobs: - name: Create .trivyignore file # "cross-spawn" is resolved as version 7.0.5 but Trivy keeps showing the error - run: echo "CVE-2024-21538" > .trivyignore - + run: | + echo "CVE-2024-21538" > .trivyignore + echo "CVE-2024-13176" >> .trivyignore + - name: Run Trivy Scan uses: aquasecurity/trivy-action@master with: @@ -64,7 +66,7 @@ jobs: env: # See https://github.com/aquasecurity/trivy/discussions/7538 TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db:2 - + - name: Build and push if: ${{ github.event_name != 'pull_request' }} uses: docker/build-push-action@v6 diff --git a/apps/sdk-cloudflare-integration/src/index.ts b/apps/sdk-cloudflare-integration/src/index.ts index 27f949d67..72c253d98 100644 --- a/apps/sdk-cloudflare-integration/src/index.ts +++ b/apps/sdk-cloudflare-integration/src/index.ts @@ -35,7 +35,7 @@ export default { }; // Create private key - const privateKey = await Secp256k1.generatePrivateKey(); + const privateKey = Secp256k1.generatePrivateKey(); // 4 - Sign transaction const signedTransaction = Transaction.of(body).sign(privateKey); diff --git a/apps/sdk-hardhat-integration/README.md b/apps/sdk-hardhat-integration/README.md index 12a27bf20..51e7e3ecf 100644 --- a/apps/sdk-hardhat-integration/README.md +++ b/apps/sdk-hardhat-integration/README.md @@ -19,9 +19,9 @@ The `hardhat.config.js` is the main configuration file. By specifying the desire Note that: - The network name should contain `vechain`, otherwise, it may result in an error. -- In the network configuration, two additional fields can be added: `delegator` and `useDebug`. These fields allow for more customization and control over the network settings, catering to specific project requirements and preferences. +- In the network configuration, two additional fields can be added: `gasPayer` and `useDebug`. These fields allow for more customization and control over the network settings, catering to specific project requirements and preferences. - **Debug Mode**: The `debug` field enables or disables debug mode. - - **Delegator**: The `delegator` field allows you to delegate the transaction to a delegator. It supports two optional parameters: - **Delegator**: The `delegator` field allows you to delegate the transaction to a delegator. It supports two optional parameters: `delegatorPrivateKey` and `delegatorUrl`. + - **Delegator**: The `gasPayer` field allows you to delegate the transaction to a gasPayer. It supports two optional parameters: - **Delegator**: The `gasPayer` field allows you to delegate the transaction to a gasPayer. It supports two optional parameters: `delegatorPrivateKey` and `delegatorUrl`. - When configuring your Solidity compiler settings in hardhat.config.js, it's recommended to set the evmVersion to "Paris" for projects targeting the latest EVM functionalities. This setting ensures that the compiled bytecode is optimized for the most recent features and gas cost adjustments associated with the Paris EVM version. Using an EVM version other than "Paris" could potentially lead to issues with unsupported opcodes, especially if your contracts rely on newer EVM features introduced in or after the Paris update. -This flexibility in the configuration file allows developers to tailor their development experience and adapt it to the requirements of their projects, ensuring a smooth and efficient development process. \ No newline at end of file +This flexibility in the configuration file allows developers to tailor their development experience and adapt it to the requirements of their projects, ensuring a smooth and efficient development process. diff --git a/apps/sdk-hardhat-integration/hardhat.config.ts b/apps/sdk-hardhat-integration/hardhat.config.ts index ace8a7722..dc4ab723d 100644 --- a/apps/sdk-hardhat-integration/hardhat.config.ts +++ b/apps/sdk-hardhat-integration/hardhat.config.ts @@ -12,7 +12,7 @@ import { type HttpNetworkConfig } from 'hardhat/types'; * * They have custom parameters: * - debug: whether to enable debug mode - * - delegator: the delegator to use + * - gasPayer: the gasPayer to use * - enableDelegation: whether to enable fee delegation */ const config: HardhatUserConfig = { @@ -42,7 +42,7 @@ const config: HardhatUserConfig = { '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' ], debug: false, - delegator: undefined, + gasPayer: undefined, gas: 'auto', gasPrice: 'auto', gasMultiplier: 1, @@ -65,7 +65,7 @@ const config: HardhatUserConfig = { passphrase: 'vechainthor' }, debug: true, - delegator: undefined, + gasPayer: undefined, gas: 'auto', gasPrice: 'auto', gasMultiplier: 1, @@ -74,7 +74,7 @@ const config: HardhatUserConfig = { } satisfies HttpNetworkConfig, /** - * Testnet configuration - with delegator url + * Testnet configuration - with gasPayer url */ vechain_testnet_delegator_url: { // Testnet @@ -88,7 +88,7 @@ const config: HardhatUserConfig = { passphrase: 'vechainthor' }, debug: true, - delegator: { + gasPayer: { delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' }, enableDelegation: true, @@ -100,7 +100,7 @@ const config: HardhatUserConfig = { } satisfies HttpNetworkConfig, /** - * Testnet configuration - with delegator private key + * Testnet configuration - with gasPayer private key */ vechain_testnet_delegator_private_key: { // Testnet @@ -114,7 +114,7 @@ const config: HardhatUserConfig = { passphrase: 'vechainthor' }, debug: true, - delegator: { + gasPayer: { delegatorPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, @@ -137,7 +137,7 @@ const config: HardhatUserConfig = { ], debug: false, enableDelegation: false, - delegator: undefined, + gasPayer: undefined, gas: 'auto', gasPrice: 'auto', gasMultiplier: 1, diff --git a/docker-compose.rpc-proxy.yml b/docker-compose.rpc-proxy.yml index 799d3c0cf..e27d80dd1 100644 --- a/docker-compose.rpc-proxy.yml +++ b/docker-compose.rpc-proxy.yml @@ -65,7 +65,7 @@ services: # Default configuration for the RPC proxy service rpc-proxy: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile container_name: rpc-proxy @@ -80,7 +80,7 @@ services: # 1. Example of a custom configuration file for the RPC proxy service rpc-proxy-custom-config-file: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: @@ -95,7 +95,7 @@ services: # 2. Example of a custom parameters for the RPC proxy service rpc-proxy-custom-parameters: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: @@ -110,7 +110,7 @@ services: # 3. Example of a custom accounts for the RPC proxy service rpc-proxy-custom-accounts: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: @@ -125,7 +125,7 @@ services: # 3. Example of a custom mnemonic for the RPC proxy service rpc-proxy-custom-mnemonic: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: @@ -142,7 +142,7 @@ services: # 4. Example of a custom delegation by private key for the RPC proxy service rpc-proxy-with-delegation-by-private-key: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: @@ -161,7 +161,7 @@ services: # 5. Example of a custom delegation by url for the RPC proxy service rpc-proxy-with-delegation-by-url: - build: + build: context: . dockerfile: docker/rpc-proxy/Dockerfile environment: diff --git a/docker/rpc-proxy/Dockerfile b/docker/rpc-proxy/Dockerfile index 6a8a5cbbf..31abb6ca5 100644 --- a/docker/rpc-proxy/Dockerfile +++ b/docker/rpc-proxy/Dockerfile @@ -46,7 +46,7 @@ COPY --from=builder /app/package.json /app/package.json WORKDIR /app RUN yarn workspace @vechain/sdk-rpc-proxy install --production --frozen-lockfile --ignore-scripts --prefer-offline \ && yarn cache clean \ - && adduser -D rpc-proxy-user + && adduser -D rpc-proxy-user # Create a new user to run the app so we do not use root USER rpc-proxy-user @@ -54,4 +54,4 @@ USER rpc-proxy-user ENV RUNNING_WITH_DOCKER=true # Set the default command to use node to run the app -CMD ["node", "packages/rpc-proxy/dist/index.js"] \ No newline at end of file +CMD ["node", "packages/rpc-proxy/dist/index.js"] diff --git a/docs/contracts.md b/docs/contracts.md index df382fea5..6efabebd3 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -209,9 +209,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL); const provider = new VeChainProvider( thorSoloClient, new ProviderInternalBaseWallet([deployerAccount], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorPrivateKey: gasPayerAccount.privateKey + gasPayer: { + gasPayerPrivateKey: gasPayerAccount.privateKey } }), true diff --git a/docs/diagrams/architecture/transaction.md b/docs/diagrams/architecture/transaction.md index 35bade25a..75bf85503 100644 --- a/docs/diagrams/architecture/transaction.md +++ b/docs/diagrams/architecture/transaction.md @@ -34,7 +34,7 @@ classDiagram +Address origin +Uint8Array signature? +Transaction decode(Uint8Array rawTransaction, boolean isSigned)$ - +Blake2b256 getTransactionHash(Address delegator?) + +Blake2b256 getTransactionHash(Address gasPayer?) +VTHO intrinsicGas(TransactionClause[] clauses)$ +boolean isValidBody(TransactionBody body)$ +Transaction of(TransactionBody: body, Uint8Array signature?)$ diff --git a/docs/examples/contracts/contract-delegation-ERC20.ts b/docs/examples/contracts/contract-delegation-ERC20.ts index d5495c84e..d312e3d55 100644 --- a/docs/examples/contracts/contract-delegation-ERC20.ts +++ b/docs/examples/contracts/contract-delegation-ERC20.ts @@ -5,9 +5,7 @@ import { type ProviderInternalWalletAccount, THOR_SOLO_URL, ThorClient, - type TransactionReceipt, - VeChainProvider, - type VeChainSigner + VeChainProvider } from '@vechain/sdk-network'; import { expect } from 'expect'; @@ -36,9 +34,8 @@ const thorSoloClient = ThorClient.at(THOR_SOLO_URL); const provider = new VeChainProvider( thorSoloClient, new ProviderInternalBaseWallet([deployerAccount], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorPrivateKey: gasPayerAccount.privateKey + gasPayer: { + gasPayerPrivateKey: gasPayerAccount.privateKey } }), true diff --git a/docs/examples/transactions/full-flow-delegator-private-key.ts b/docs/examples/transactions/full-flow-gas-payer-private-key.ts similarity index 92% rename from docs/examples/transactions/full-flow-delegator-private-key.ts rename to docs/examples/transactions/full-flow-gas-payer-private-key.ts index 0187ec338..4ed50e7eb 100644 --- a/docs/examples/transactions/full-flow-delegator-private-key.ts +++ b/docs/examples/transactions/full-flow-gas-payer-private-key.ts @@ -15,7 +15,7 @@ import { } from '@vechain/sdk-network'; import { expect } from 'expect'; -// START_SNIPPET: FullFlowDelegatorPrivateKeySnippet +// START_SNIPPET: FullFlowGasPayerPrivateKeySnippet // 1 - Create the thor client const thorSoloClient = ThorClient.at(THOR_SOLO_URL, { @@ -50,9 +50,8 @@ const providerWithDelegationEnabled = new VeChainProvider( } ], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorPrivateKey: gasPayerAccount.privateKey + gasPayer: { + gasPayerPrivateKey: gasPayerAccount.privateKey } } ), @@ -115,7 +114,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction( sendTransactionResult.id ); -// END_SNIPPET: FullFlowDelegatorPrivateKeySnippet +// END_SNIPPET: FullFlowGasPayerPrivateKeySnippet // Check the signed transaction expect(delegatedSigned.isSigned).toEqual(true); diff --git a/docs/examples/transactions/full-flow-delegator-url.ts b/docs/examples/transactions/full-flow-gas-payer-service-url.ts similarity index 90% rename from docs/examples/transactions/full-flow-delegator-url.ts rename to docs/examples/transactions/full-flow-gas-payer-service-url.ts index 453414efe..f99552741 100644 --- a/docs/examples/transactions/full-flow-delegator-url.ts +++ b/docs/examples/transactions/full-flow-gas-payer-service-url.ts @@ -15,7 +15,7 @@ import { } from '@vechain/sdk-network'; import { expect } from 'expect'; -// START_SNIPPET: FullFlowDelegatorUrlSnippet +// START_SNIPPET: FullFlowGasPayerServiceUrlSnippet // 1 - Create the thor client const thorClient = ThorClient.at(TESTNET_URL, { @@ -54,9 +54,8 @@ const providerWithDelegationEnabled = new VeChainProvider( } ], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorUrl: gasPayerAccount.URL + gasPayer: { + gasPayerServiceUrl: gasPayerAccount.URL } } ), @@ -119,12 +118,12 @@ const txReceipt = await thorClient.transactions.waitForTransaction( sendTransactionResult.id ); -// END_SNIPPET: FullFlowDelegatorUrlSnippet +// END_SNIPPET: FullFlowGasPayerServiceUrlSnippet // Check the signed transaction expect(delegatedSigned.isSigned).toEqual(true); expect(delegatedSigned.isDelegated).toEqual(true); -// expect(signedTx.delegator).toEqual(gasPayerAccount.address); --- +// expect(signedTx.gasPayer).toEqual(gasPayerAccount.address); --- // Check the transaction receipt expect(txReceipt).toBeDefined(); diff --git a/docs/examples/transactions/full-flow-no-delegator.ts b/docs/examples/transactions/full-flow-no-gas-payer.ts similarity index 96% rename from docs/examples/transactions/full-flow-no-delegator.ts rename to docs/examples/transactions/full-flow-no-gas-payer.ts index a1f58b25d..61e42d5f9 100644 --- a/docs/examples/transactions/full-flow-no-delegator.ts +++ b/docs/examples/transactions/full-flow-no-gas-payer.ts @@ -15,7 +15,7 @@ import { } from '@vechain/sdk-network'; import { expect } from 'expect'; -// START_SNIPPET: FullFlowNoDelegatorSnippet +// START_SNIPPET: FullFlowNoGasPayerSnippet // 1 - Create the thor client const thorSoloClient = ThorClient.at(THOR_SOLO_URL, { @@ -95,7 +95,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction( sendTransactionResult.id ); -// END_SNIPPET: FullFlowNoDelegatorSnippet +// END_SNIPPET: FullFlowNoGasPayerSnippet // Check the transaction receipt expect(txReceipt).toBeDefined(); diff --git a/docs/templates/transactions.md b/docs/templates/transactions.md index 44873a724..b6ab47b12 100644 --- a/docs/templates/transactions.md +++ b/docs/templates/transactions.md @@ -54,15 +54,15 @@ In the following complete examples, we will explore the entire lifecycle of a Ve 1. **No Delegation (Signing Only with an Origin Private Key)**: In this scenario, we'll demonstrate the basic process of creating a transaction, signing it with the origin private key, and sending it to the VeChainThor blockchain without involving fee delegation. -[FullFlowNoDelegatorSnippet](examples/transactions/full-flow-no-delegator.ts) +[FullFlowNoGasPayerSnippet](examples/transactions/full-flow-no-gas-payer.ts) -2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (delegator), and we'll guide you through the steps of building, signing, and sending such a transaction. +2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (gasPayer), and we'll guide you through the steps of building, signing, and sending such a transaction. -[FullFlowDelegatorPrivateKeySnippet](examples/transactions/full-flow-delegator-private-key.ts) +[FullFlowGasPayerPrivateKeySnippet](examples/transactions/full-flow-gas-payer-private-key.ts) 3. **Delegation with URL**: This example will showcase the use of a delegation URL for fee delegation. The sender will specify a delegation URL in the `signTransaction` options, allowing a designated sponsor to pay the transaction fee. We'll cover the full process, from building clauses to verifying the transaction on-chain. -[FullFlowDelegatorUrlSnippet](examples/transactions/full-flow-delegator-url.ts) +[FullFlowGasPayerServiceUrlSnippet](examples/transactions/full-flow-gas-payer-service-url.ts) By examining these complete examples, developers can gain a comprehensive understanding of transaction handling in the VeChain SDK. Each example demonstrates the steps involved in initiating, signing, and sending transactions, as well as the nuances associated with fee delegation. @@ -78,4 +78,4 @@ Even when using the `simulateTransaction` method you can find the revert reason. [RevertReasonSimulationSnippet](examples/transactions/revert-reason-with-simulation.ts) -In this case there is only a `TransactionSimulationResult`, so no need to loop. \ No newline at end of file +In this case there is only a `TransactionSimulationResult`, so no need to loop. diff --git a/docs/transactions.md b/docs/transactions.md index f810c2fe4..c129064c8 100644 --- a/docs/transactions.md +++ b/docs/transactions.md @@ -368,7 +368,7 @@ In the following complete examples, we will explore the entire lifecycle of a Ve 1. **No Delegation (Signing Only with an Origin Private Key)**: In this scenario, we'll demonstrate the basic process of creating a transaction, signing it with the origin private key, and sending it to the VeChainThor blockchain without involving fee delegation. -```typescript { name=full-flow-no-delegator, category=example } +```typescript { name=full-flow-no-gas-payer, category=example } // 1 - Create the thor client const thorSoloClient = ThorClient.at(THOR_SOLO_URL, { isPollingEnabled: false @@ -448,9 +448,9 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction( ); ``` -2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (delegator), and we'll guide you through the steps of building, signing, and sending such a transaction. +2. **Delegation with Private Key**: Here, we'll extend the previous example by incorporating fee delegation. The transaction sender will delegate the transaction fee payment to another entity (gasPayer), and we'll guide you through the steps of building, signing, and sending such a transaction. -```typescript { name=full-flow-delegator-private-key, category=example } +```typescript { name=full-flow-gas-payer-private-key, category=example } // 1 - Create the thor client const thorSoloClient = ThorClient.at(THOR_SOLO_URL, { isPollingEnabled: false @@ -484,9 +484,8 @@ const providerWithDelegationEnabled = new VeChainProvider( } ], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorPrivateKey: gasPayerAccount.privateKey + gasPayer: { + gasPayerPrivateKey: gasPayerAccount.privateKey } } ), @@ -552,7 +551,7 @@ const txReceipt = await thorSoloClient.transactions.waitForTransaction( 3. **Delegation with URL**: This example will showcase the use of a delegation URL for fee delegation. The sender will specify a delegation URL in the `signTransaction` options, allowing a designated sponsor to pay the transaction fee. We'll cover the full process, from building clauses to verifying the transaction on-chain. -```typescript { name=full-flow-delegator-url, category=example } +```typescript { name=full-flow-gas-payer-service-url, category=example } // 1 - Create the thor client const thorClient = ThorClient.at(TESTNET_URL, { isPollingEnabled: false @@ -590,9 +589,8 @@ const providerWithDelegationEnabled = new VeChainProvider( } ], { - // The term `delegator` will be deprecated soon and renamed `gasPayer`. - delegator: { - delegatorUrl: gasPayerAccount.URL + gasPayer: { + gasPayerServiceUrl: gasPayerAccount.URL } } ), @@ -698,3 +696,4 @@ const revertReason = thorSoloClient.transactions.decodeRevertReason( ``` In this case there is only a `TransactionSimulationResult`, so no need to loop. + diff --git a/packages/aws-kms-adapter/README.md b/packages/aws-kms-adapter/README.md index 8a00b2290..d8909b812 100644 --- a/packages/aws-kms-adapter/README.md +++ b/packages/aws-kms-adapter/README.md @@ -7,7 +7,7 @@ The AWS KMS Adapter for VeChain SDK provides a secure way to sign transactions u - **Secure Key Management**: Use AWS KMS to securely manage and protect your private keys. - **Transaction Signing**: Sign VeChain transactions using keys stored in AWS KMS. - **Integration with VeChain SDK**: Seamlessly integrate with the VeChain SDK for blockchain interactions. -- **Sign and send transactions using a delegator key**: You can specify the key ID of a delegator key to leverage this VeChain feature for signing and sending transactions. +- **Sign and send transactions using a gasPayer key**: You can specify the key ID of a gasPayer key to leverage this VeChain feature for signing and sending transactions. ## Installation @@ -29,7 +29,7 @@ yarn test:integration To integrate this into your code, depending on how you plan to manage your AWS credentials, you can choose one of the following examples. -Within this repo, you can create a credentials file called `aws-credentials.json` with your custom credentials under the `tests` folder in case you want to give it a try before integrating with your project. A valid format would be as follows (it is an array in case you want to include a delegator key, assumed to be the second one): +Within this repo, you can create a credentials file called `aws-credentials.json` with your custom credentials under the `tests` folder in case you want to give it a try before integrating with your project. A valid format would be as follows (it is an array in case you want to include a gasPayer key, assumed to be the second one): ```json [ @@ -155,7 +155,7 @@ import { ### Delegation (provider) -You can also use delegation to sign your transactions. In this example the source of the delegation is a delegator which key is in KMS so requires a `KMSVeChainProvider`. +You can also use delegation to sign your transactions. In this example the source of the delegation is a gasPayer which key is in KMS so requires a `KMSVeChainProvider`. ```ts import { type KMSClientParameters, KMSVeChainProvider, KMSVeChainSigner } from '@vechain/sdk-aws-kms-adapter'; @@ -186,7 +186,7 @@ import { awsClientParameters ); - // Signer with delegator enabled + // Signer with gasPayer enabled const delegatorProvider = new KMSVeChainProvider( thorClient, delegatorAwsClientParameters @@ -200,7 +200,7 @@ import { // Returns the address related to the origin KMS key const address = await signerWithDelegator.getAddress(); - // Returns the address related to the delegator KMS key + // Returns the address related to the gasPayer KMS key const address = await signerWithDelegator.getAddress(true); ``` @@ -228,7 +228,7 @@ import { const thorClient = ThorClient.fromUrl(THOR_SOLO_URL); - // Signer with delegator enabled + // Signer with gasPayer enabled const provider = new KMSVeChainProvider( thorClient, awsClientParameters @@ -244,5 +244,5 @@ import { const address = await signerWithDelegator.getAddress(); // See /tests folder for more examples. This time we wont get the address - // of the delegator since there is no provider + // of the gasPayer since there is no provider ``` diff --git a/packages/aws-kms-adapter/src/KMSVeChainProvider.ts b/packages/aws-kms-adapter/src/KMSVeChainProvider.ts index 2e23419ce..f107524d8 100644 --- a/packages/aws-kms-adapter/src/KMSVeChainProvider.ts +++ b/packages/aws-kms-adapter/src/KMSVeChainProvider.ts @@ -117,7 +117,14 @@ class KMSVeChainProvider extends VeChainProvider { } return signOutput.Signature; + + return signOutput.Signature; } } export { KMSVeChainProvider, type KMSClientParameters }; + +} +} + +export { KMSVeChainProvider, type KMSClientParameters }; diff --git a/packages/aws-kms-adapter/src/KMSVeChainSigner.ts b/packages/aws-kms-adapter/src/KMSVeChainSigner.ts index 1550009a0..994655c76 100644 --- a/packages/aws-kms-adapter/src/KMSVeChainSigner.ts +++ b/packages/aws-kms-adapter/src/KMSVeChainSigner.ts @@ -56,7 +56,7 @@ class KMSVeChainSigner extends VeChainAbstractSigner { } else { throw new JSONRPCInvalidParams( 'KMSVeChainSigner.constructor', - 'The delegator object is not well formed, either provider or url should be provided.', + 'The gasPayer object is not well formed, either provider or url should be provided.', { delegator } ); } @@ -132,7 +132,7 @@ class KMSVeChainSigner extends VeChainAbstractSigner { /** * It returns the address associated with the signer. - * @param {boolean} fromDelegatorProvider (Optional) If true, the provider will be the delegator. + * @param {boolean} fromDelegatorProvider (Optional) If true, the provider will be the gasPayer. * @returns The address associated with the signer. */ public async getAddress( @@ -232,9 +232,9 @@ class KMSVeChainSigner extends VeChainAbstractSigner { } /** - * Concat the origin signature to the delegator signature if the delegator is set. + * Concat the origin signature to the gasPayer signature if the gasPayer is set. * @param {Transaction} transaction Transaction to sign. - * @returns Both signatures concatenated if the delegator is set, the origin signature otherwise. + * @returns Both signatures concatenated if the gasPayer is set, the origin signature otherwise. */ private async concatSignatureIfDelegation( transaction: Transaction @@ -246,7 +246,7 @@ class KMSVeChainSigner extends VeChainAbstractSigner { const originSignature = await this.buildVeChainSignatureFromPayload(transactionHash); - // We try first in case there is a delegator provider + // We try first in case there is a gasPayer provider if (this.kmsVeChainDelegatorProvider !== undefined) { const publicKeyDecoded = await this.getDecodedPublicKey(); const originAddress = Address.ofPublicKey(publicKeyDecoded); @@ -259,13 +259,13 @@ class KMSVeChainSigner extends VeChainAbstractSigner { ); return concatBytes(originSignature, delegatorSignature); } else if ( - // If not, we try with the delegator URL + // If not, we try with the gasPayer URL this.kmsVeChainDelegatorUrl !== undefined && this.provider !== undefined ) { const originAddress = await this.getAddress(); const delegatorSignature = await DelegationHandler({ - delegatorUrl: this.kmsVeChainDelegatorUrl + gasPayerServiceUrl: this.kmsVeChainDelegatorUrl }).getDelegationSignatureUsingUrl( transaction, originAddress, diff --git a/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts b/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts index 462a27168..9409f14f9 100644 --- a/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts +++ b/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts @@ -46,7 +46,7 @@ describe('KMSVeChainSigner - Thor Solo', () => { let signer: KMSVeChainSigner; /** - * KMSVeChainSigner with delegator instance + * KMSVeChainSigner with gasPayer instance */ let signerWithDelegator: KMSVeChainSigner; @@ -76,7 +76,7 @@ describe('KMSVeChainSigner - Thor Solo', () => { } thorClient = ThorClient.at(THOR_SOLO_URL); - // Signer with delegator disabled + // Signer with gasPayer disabled signer = new KMSVeChainSigner( new KMSVeChainProvider(thorClient, awsClientParameters) ); @@ -84,7 +84,7 @@ describe('KMSVeChainSigner - Thor Solo', () => { // This step should be removed once this is clarified https://github.com/localstack/localstack/issues/11678 await fundVTHO(thorClient, expectedAddress); - // Signer with delegator enabled + // Signer with gasPayer enabled const delegatorProvider = new KMSVeChainProvider( thorClient, delegatorAwsClientParameters diff --git a/packages/aws-kms-adapter/tests/KMSVeChainSigner.testnet.test.ts b/packages/aws-kms-adapter/tests/KMSVeChainSigner.testnet.test.ts index 9c9d8d6a8..062c593fe 100644 --- a/packages/aws-kms-adapter/tests/KMSVeChainSigner.testnet.test.ts +++ b/packages/aws-kms-adapter/tests/KMSVeChainSigner.testnet.test.ts @@ -36,7 +36,7 @@ describe('KMSVeChainSigner - Testnet', () => { let thorClient: ThorClient; /** - * KMSVeChainSigner with delegator instance + * KMSVeChainSigner with gasPayer instance */ let signerWithDelegator: KMSVeChainSigner; diff --git a/packages/hardhat-plugin/README.md b/packages/hardhat-plugin/README.md index 40b9285a8..e5ce5e6a9 100644 --- a/packages/hardhat-plugin/README.md +++ b/packages/hardhat-plugin/README.md @@ -63,7 +63,7 @@ const config: HardhatUserConfig = { passphrase: 'vechainthor' }, debug: true, - delegator: undefined, + gasPayer: undefined, gas: 'auto', gasPrice: 'auto', gasMultiplier: 1, diff --git a/packages/hardhat-plugin/src/helpers/provider-helper.ts b/packages/hardhat-plugin/src/helpers/provider-helper.ts index d5eba7e19..70c489fe7 100644 --- a/packages/hardhat-plugin/src/helpers/provider-helper.ts +++ b/packages/hardhat-plugin/src/helpers/provider-helper.ts @@ -61,9 +61,9 @@ const createWalletFromHardhatNetworkConfig = ( }; }), { - delegator: DelegationHandler( + gasPayer: DelegationHandler( (networkConfig as HttpNetworkConfig).delegator - ).delegatorOrUndefined() + ).gasPayerOrUndefined() } ); } @@ -75,9 +75,9 @@ const createWalletFromHardhatNetworkConfig = ( accountFromConfig.initialIndex, accountFromConfig.path, { - delegator: DelegationHandler( + gasPayer: DelegationHandler( (networkConfig as HttpNetworkConfig).delegator - ).delegatorOrUndefined() + ).gasPayerOrUndefined() } ); } diff --git a/packages/hardhat-plugin/src/index.ts b/packages/hardhat-plugin/src/index.ts index f63f4204c..0e1798e51 100644 --- a/packages/hardhat-plugin/src/index.ts +++ b/packages/hardhat-plugin/src/index.ts @@ -65,7 +65,7 @@ extendEnvironment((hre) => { title: 'You are operating on a non-vechain network', messages: [ 'Ensure your hardhat config file has a network that:', - '\t1. Is a VeChain valid network (set url and optionally delegator parameter)', + '\t1. Is a VeChain valid network (set url and optionally gasPayer parameter)', '\t2. Has the name of the network containing "vechain" (e.g. "vechain_mainnet", "vechain_testnet", "vechain_solo", ...)', '', 'This is required to use the VeChain provider and its functions.', diff --git a/packages/hardhat-plugin/src/type-extensions.ts b/packages/hardhat-plugin/src/type-extensions.ts index fdf3211ed..5ad75a5da 100644 --- a/packages/hardhat-plugin/src/type-extensions.ts +++ b/packages/hardhat-plugin/src/type-extensions.ts @@ -35,14 +35,14 @@ declare module 'hardhat/types/runtime' { /** * Hardhat config extension * - * - Add `delegator` to `HttpNetworkConfig` + * - Add `gasPayer` to `HttpNetworkConfig` * - Add `debug` to `HttpNetworkConfig` * - Add `enableDelegation` to `HttpNetworkConfig` */ declare module 'hardhat/types/config' { export interface HttpNetworkConfig { /** - * Delegate the transaction to a delegator. + * Delegate the transaction to a gasPayer. * * We can give following two optional parameters: * - delegatorPrivateKey: string diff --git a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-default-value-project/hardhat.config.ts b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-default-value-project/hardhat.config.ts index f279a1d50..cdd19b22b 100644 --- a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-default-value-project/hardhat.config.ts +++ b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-default-value-project/hardhat.config.ts @@ -30,7 +30,8 @@ const vechainTestNetwork: HttpNetworkConfig = { // Custom parameters delegator: { - delegatorPrivateKey: + // TO BE RENAMED WHEN BNC REFACTORING DONE. + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, debug: true, diff --git a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-no-value-project/hardhat.config.ts b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-no-value-project/hardhat.config.ts index 236d4b3df..e1e8b4466 100644 --- a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-no-value-project/hardhat.config.ts +++ b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-no-value-project/hardhat.config.ts @@ -30,7 +30,7 @@ const vechainTestNetwork: HttpNetworkConfig = { // Custom parameters delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, debug: true, diff --git a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-random-value-project/hardhat.config.ts b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-random-value-project/hardhat.config.ts index 5ed7c3679..b667a4ddc 100644 --- a/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-random-value-project/hardhat.config.ts +++ b/packages/hardhat-plugin/tests/hardhat-mock-projects/eth_getTransactionCount-random-value-project/hardhat.config.ts @@ -30,7 +30,7 @@ const vechainTestNetwork: HttpNetworkConfig = { // Custom parameters delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, debug: true, diff --git a/packages/hardhat-plugin/tests/hardhat-mock-projects/simple-vechain-hardhat-project/hardhat.config.ts b/packages/hardhat-plugin/tests/hardhat-mock-projects/simple-vechain-hardhat-project/hardhat.config.ts index e5aca1afb..c300f18b8 100644 --- a/packages/hardhat-plugin/tests/hardhat-mock-projects/simple-vechain-hardhat-project/hardhat.config.ts +++ b/packages/hardhat-plugin/tests/hardhat-mock-projects/simple-vechain-hardhat-project/hardhat.config.ts @@ -30,7 +30,7 @@ const vechainTestNetwork: HttpNetworkConfig = { // Custom parameters delegator: { - delegatorPrivateKey: + gasPayerPrivateKey: 'ea5383ac1f9e625220039a4afac6a7f868bf1ad4f48ce3a1dd78bd214ee4ace5' }, debug: true, diff --git a/packages/hardhat-plugin/tests/helpers/fixture.ts b/packages/hardhat-plugin/tests/helpers/fixture.ts index fbfb741d7..1f94e86c1 100644 --- a/packages/hardhat-plugin/tests/helpers/fixture.ts +++ b/packages/hardhat-plugin/tests/helpers/fixture.ts @@ -14,7 +14,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ expectedAddresses: [] }, { - test: 'Should return a wallet from an Array of private keys - no delegator', + test: 'Should return a wallet from an Array of private keys - no gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, @@ -29,7 +29,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ ] }, { - test: 'Should return a wallet from an Array of private keys - with delegator', + test: 'Should return a wallet from an Array of private keys - with gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, @@ -49,7 +49,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ ] }, { - test: 'Should return a wallet from an Array of private keys (with 0x prefix) - no delegator', + test: 'Should return a wallet from an Array of private keys (with 0x prefix) - no gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, @@ -64,7 +64,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ ] }, { - test: 'Should return a wallet from an Array of private keys (with 0x prefix) - with delegator', + test: 'Should return a wallet from an Array of private keys (with 0x prefix) - with gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, @@ -84,7 +84,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ ] }, { - test: 'Should return a wallet from an HDNode wallet - no delegator', + test: 'Should return a wallet from an HDNode wallet - no gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, @@ -102,7 +102,7 @@ const createWalletFromHardhatNetworkConfigPositiveCasesFixture = [ ] }, { - test: 'Should return a wallet from an HDNode wallet - with delegator', + test: 'Should return a wallet from an HDNode wallet - with gasPayer', networkConfig: { url: 'https://testnet.vechain.org', chainId: 74, diff --git a/packages/hardhat-plugin/tests/helpers/provider-helpers.unit.test.ts b/packages/hardhat-plugin/tests/helpers/provider-helpers.unit.test.ts index 146cdbf2a..ba28fbe21 100644 --- a/packages/hardhat-plugin/tests/helpers/provider-helpers.unit.test.ts +++ b/packages/hardhat-plugin/tests/helpers/provider-helpers.unit.test.ts @@ -27,7 +27,7 @@ describe('Provider Hardhat Helpers', () => { fixture.networkConfig as HttpNetworkConfig ); const addresses = await wallet.getAddresses(); - const delegator = await wallet.getDelegator(); + const delegator = await wallet.getGasPayer(); expect(addresses).toEqual(fixture.expectedAddresses); expect(delegator).toEqual( diff --git a/packages/network/src/provider/helpers/provider-internal-wallets/abstract-wallet/abstract-provider-internal-wallet.ts b/packages/network/src/provider/helpers/provider-internal-wallets/abstract-wallet/abstract-provider-internal-wallet.ts index 241aa5fad..c8f2dce48 100644 --- a/packages/network/src/provider/helpers/provider-internal-wallets/abstract-wallet/abstract-provider-internal-wallet.ts +++ b/packages/network/src/provider/helpers/provider-internal-wallets/abstract-wallet/abstract-provider-internal-wallet.ts @@ -26,24 +26,24 @@ abstract class AbstractProviderInternalWallet readonly accounts: ProviderInternalWalletAccount[]; /** - * Options for signing a transaction with delegator. + * Options for signing a transaction with gasPayer. */ - readonly delegator?: SignTransactionOptions; + readonly gasPayer?: SignTransactionOptions; /** * Create a new wallet. * * @param accounts List of accounts in the wallet. - * @param options Optional options for signing a transaction with delegator. + * @param options Optional options for signing a transaction with gasPayer. */ constructor( accounts: ProviderInternalWalletAccount[], options?: { - delegator?: SignTransactionOptions; + gasPayer?: SignTransactionOptions; } ) { this.accounts = accounts; - this.delegator = options?.delegator; + this.gasPayer = options?.gasPayer; } /** @@ -154,21 +154,21 @@ abstract class AbstractProviderInternalWallet } /** - * Get the options for signing a transaction with delegator (if any). + * Get the options for signing a transaction with gasPayer (if any). * - * @returns The options for signing a transaction with delegator. + * @returns The options for signing a transaction with gasPayer. */ - abstract getDelegator(): Promise; + abstract getGasPayer(): Promise; /** - * SYNC Version of getDelegator() + * SYNC Version of getGasPayer() * - * Get the options for signing a transaction with delegator (if any). + * Get the options for signing a transaction with gasPayer (if any). * - * @returns The options for signing a transaction with delegator. + * @returns The options for signing a transaction with gasPayer. */ - getDelegatorSync(): SignTransactionOptions | null { - return DelegationHandler(this.delegator).delegatorOrNull(); + getGasPayerSync(): SignTransactionOptions | null { + return DelegationHandler(this.gasPayer).gasPayerOrNull(); } } diff --git a/packages/network/src/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.ts b/packages/network/src/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.ts index 00d47ec33..5632dfc10 100644 --- a/packages/network/src/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.ts +++ b/packages/network/src/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.ts @@ -52,12 +52,12 @@ class ProviderInternalBaseWallet extends AbstractProviderInternalWallet { } /** - * Get the options for signing a transaction with delegator (if any). + * Get the options for signing a transaction with gasPayer (if any). * - * @returns The options for signing a transaction with delegator. + * @returns The options for signing a transaction with gasPayer. */ - async getDelegator(): Promise { - return await Promise.resolve(this.getDelegatorSync()); + async getGasPayer(): Promise { + return await Promise.resolve(this.getGasPayerSync()); } } diff --git a/packages/network/src/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.ts b/packages/network/src/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.ts index ccb30ba83..dd1253730 100644 --- a/packages/network/src/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.ts +++ b/packages/network/src/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.ts @@ -30,7 +30,7 @@ class ProviderInternalHDWallet extends ProviderInternalBaseWallet { * @param count - Number of accounts to generate. * @param initialIndex - Initial index of the accounts to generate. * @param derivationPath - Derivation path of the wallet. - * @param options - Options for signing a transaction with delegator. + * @param options - Options for signing a transaction with gasPayer. */ constructor( mnemonic: string[], @@ -38,7 +38,7 @@ class ProviderInternalHDWallet extends ProviderInternalBaseWallet { initialIndex: number = 0, derivationPath: string = HDKey.VET_DERIVATION_PATH, options?: { - delegator?: SignTransactionOptions; + gasPayer?: SignTransactionOptions; } ) { // Initialize the base wallet with the generated accounts diff --git a/packages/network/src/provider/helpers/provider-internal-wallets/types.d.ts b/packages/network/src/provider/helpers/provider-internal-wallets/types.d.ts index 995b8101f..07a8785cf 100644 --- a/packages/network/src/provider/helpers/provider-internal-wallets/types.d.ts +++ b/packages/network/src/provider/helpers/provider-internal-wallets/types.d.ts @@ -37,9 +37,9 @@ interface ProviderInternalWalletAccount { */ interface ProviderInternalWallet { /** - * Options for signing a transaction with delegator. + * Options for signing a transaction with gasPayer. */ - delegator?: SignTransactionOptions; + gasPayer?: SignTransactionOptions; /** * List of accounts in the wallet. @@ -113,20 +113,20 @@ interface ProviderInternalWallet { ) => ProviderInternalWalletAccount | null; /** - * Get the options for signing a transaction with delegator (if any). + * Get the options for signing a transaction with gasPayer (if any). * - * @returns The options for signing a transaction with delegator. + * @returns The options for signing a transaction with gasPayer. */ - getDelegator: () => Promise; + getGasPayer: () => Promise; /** - * SYNC Version of getDelegator() + * SYNC Version of getGasPayer() * - * Get the options for signing a transaction with delegator (if any). + * Get the options for signing a transaction with gasPayer (if any). * - * @returns The options for signing a transaction with delegator. + * @returns The options for signing a transaction with gasPayer. */ - getDelegatorSync: () => SignTransactionOptions | null; + getGasPayerSync: () => SignTransactionOptions | null; } export { type ProviderInternalWallet, type ProviderInternalWalletAccount }; diff --git a/packages/network/src/provider/providers/hardhat-provider/hardhat-provider.ts b/packages/network/src/provider/providers/hardhat-provider/hardhat-provider.ts index af22fd9a2..4824e838b 100644 --- a/packages/network/src/provider/providers/hardhat-provider/hardhat-provider.ts +++ b/packages/network/src/provider/providers/hardhat-provider/hardhat-provider.ts @@ -139,16 +139,16 @@ class HardhatVeChainProvider extends VeChainProvider { const accounts = await ( this.wallet as ProviderInternalWallet ).getAddresses(); - const delegator = await ( + const gasPayer = await ( this.wallet as ProviderInternalWallet - ).getDelegator(); + ).getGasPayer(); VeChainSDKLogger('log').log({ title: `Sending request - ${args.method}`, messages: [ `params: ${stringifyData(args.params)}`, `accounts: ${stringifyData(accounts)}`, - `delegator: ${stringifyData(delegator)}`, + `gasPayer: ${stringifyData(gasPayer)}`, `url: ${this.thorClient.httpClient.baseURL}` ] }); diff --git a/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts b/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts index 5aa256289..06e1ce75e 100644 --- a/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts +++ b/packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts @@ -104,13 +104,13 @@ class VeChainPrivateKeySigner extends VeChainAbstractSigner { } let gasPayer = DelegationHandler( - await this.provider.wallet?.getDelegator() - ).delegatorOrNull(); + await this.provider.wallet?.getGasPayer() + ).gasPayerOrNull(); // Override the gasPayer if the transaction has a delegation URL if (transactionToSign.delegationUrl !== undefined) { gasPayer = { - delegatorUrl: transactionToSign.delegationUrl + gasPayerServiceUrl: transactionToSign.delegationUrl }; } @@ -277,13 +277,13 @@ class VeChainPrivateKeySigner extends VeChainAbstractSigner { } /** - * Signs a transaction where the gas fee is paid by a delegator. + * Signs a transaction where the gas fee is paid by a gasPayer. * * @param unsignedTransactionBody - The unsigned transaction body to sign. * @param originPrivateKey - The private key of the origin account. * @param thorClient - The ThorClient instance. - * @param gasPayerOptions - Optional parameters for the request. Includes the `delegatorUrl` and `delegatorPrivateKey` fields. - * Only one of the following options can be specified: `delegatorUrl`, `delegatorPrivateKey`. + * @param gasPayerOptions - Optional parameters for the request. Includes the `gasPayerServiceUrl` and `gasPayerPrivateKey` fields. + * Only one of the following options can be specified: `gasPayerServiceUrl`, `gasPayerPrivateKey`. * @returns A promise that resolves to the signed transaction. * @throws {NotDelegatedTransaction} */ @@ -299,11 +299,11 @@ class VeChainPrivateKeySigner extends VeChainAbstractSigner { const unsignedTx = Transaction.of(unsignedTransactionBody); // Sign transaction with origin private key and gasPayer private key - if (gasPayerOptions?.delegatorPrivateKey !== undefined) + if (gasPayerOptions?.gasPayerPrivateKey !== undefined) return Hex.of( Transaction.of(unsignedTransactionBody).signAsSenderAndGasPayer( originPrivateKey, - HexUInt.of(gasPayerOptions?.delegatorPrivateKey).bytes + HexUInt.of(gasPayerOptions?.gasPayerPrivateKey).bytes ).encoded ).toString(); diff --git a/packages/network/src/thor-client/blocks/blocks-module.ts b/packages/network/src/thor-client/blocks/blocks-module.ts index e5fa65779..c5cf06122 100644 --- a/packages/network/src/thor-client/blocks/blocks-module.ts +++ b/packages/network/src/thor-client/blocks/blocks-module.ts @@ -287,7 +287,7 @@ class BlocksModule { /** * Retrieves all addresses involved in a given block. This includes beneficiary, signer, clauses, - * delegator, gas payer, origin, contract addresses, event addresses, and transfer recipients and senders. + * gas payer, origin, contract addresses, event addresses, and transfer recipients and senders. * * @param {ExpandedBlockDetail} block - The block object to extract addresses from. * diff --git a/packages/network/src/thor-client/blocks/types.d.ts b/packages/network/src/thor-client/blocks/types.d.ts index 10eb341cc..7c21129ca 100644 --- a/packages/network/src/thor-client/blocks/types.d.ts +++ b/packages/network/src/thor-client/blocks/types.d.ts @@ -211,6 +211,11 @@ interface TransactionsExpandedBlockDetail { */ origin: string; + /** + * Gas payer of the transaction. + */ + gasPayer: string; + /** * Nonce value for preventing replay attacks. */ diff --git a/packages/network/src/thor-client/transactions/helpers/delegation-handler.ts b/packages/network/src/thor-client/transactions/helpers/delegation-handler.ts index 2f43d16c3..6cb1cbed2 100644 --- a/packages/network/src/thor-client/transactions/helpers/delegation-handler.ts +++ b/packages/network/src/thor-client/transactions/helpers/delegation-handler.ts @@ -7,13 +7,13 @@ import { import { type HttpClient, HttpMethod } from '../../../http'; /** - * Retrieves the signature of a delegation transaction from a delegator given the endpoint + * Retrieves the signature of a delegation transaction from a gasPayer given the endpoint * from which to retrieve the signature. * * @see [Simple Gas Payer Standard](https://github.com/vechain/VIPs/blob/master/vips/VIP-201.md) * * @param tx - The transaction to delegate. - * @param delegatorUrl - The URL of the endpoint of the delegator. + * @param gasPayerServiceUrl - The URL of the endpoint of the gasPayer service. * @param originAddress - The address of the origin account. * @param httpClient - The HTTP client instance used for making HTTP requests. * @returns A promise that resolves to the signature of the delegation transaction. @@ -21,7 +21,7 @@ import { type HttpClient, HttpMethod } from '../../../http'; */ const _getDelegationSignature = async ( tx: Transaction, - delegatorUrl: string, + gasPayerServiceUrl: string, originAddress: string, httpClient: HttpClient ): Promise => { @@ -38,17 +38,21 @@ const _getDelegationSignature = async ( }; try { - const response = (await httpClient.http(HttpMethod.POST, delegatorUrl, { - body: sponsorRequestBody - })) as GetDelegationSignatureResult; + const response = (await httpClient.http( + HttpMethod.POST, + gasPayerServiceUrl, + { + body: sponsorRequestBody + } + )) as GetDelegationSignatureResult; return HexUInt.of(response.signature.slice(2)).bytes; } catch (error) { throw new NotDelegatedTransaction( '_getDelegationSignature()', - 'Delegation failed: Cannot get signature from delegator.', + 'Delegation failed: Cannot get signature from gasPayerUrl.', { - gasPayerUrl: delegatorUrl + gasPayerUrl: gasPayerServiceUrl }, error ); @@ -57,36 +61,36 @@ const _getDelegationSignature = async ( /** * Provide a set of utils for the delegation type. - * It is a mutual exclusion between delegatorPrivateKey and delegatorUrl. (@see SignTransactionOptions) + * It is a mutual exclusion between gasPayerPrivateKey and gasPayerServiceUrl. (@see SignTransactionOptions) * * The aim of this handler is to: * - Understand the kind of delegation and the delegation info * - Provide a method to get the delegation signature * - * @param delegator - The delegator options. + * @param gasPayer - The gasPayer options. */ const DelegationHandler = ( - delegator?: SignTransactionOptions | null + gasPayer?: SignTransactionOptions | null ): { isDelegated: () => boolean; - delegatorOrUndefined: () => SignTransactionOptions | undefined; - delegatorOrNull: () => SignTransactionOptions | null; + gasPayerOrUndefined: () => SignTransactionOptions | undefined; + gasPayerOrNull: () => SignTransactionOptions | null; getDelegationSignatureUsingUrl: ( tx: Transaction, originAddress: string, httpClient: HttpClient ) => Promise; } => { - // Check if delegator is undefined (null or undefined) - const delegatorIsUndefined = delegator === undefined || delegator === null; + // Check if gasPayer is undefined (null or undefined) + const gasPayerIsUndefined = gasPayer === undefined || gasPayer === null; // Check if is delegated by url const isDelegatedWithUrl = - !delegatorIsUndefined && delegator?.delegatorUrl !== undefined; + !gasPayerIsUndefined && gasPayer?.gasPayerServiceUrl !== undefined; // Check if is delegated by private key const isDelegatedWithPrivateKey = - !delegatorIsUndefined && delegator?.delegatorPrivateKey !== undefined; + !gasPayerIsUndefined && gasPayer?.gasPayerPrivateKey !== undefined; return { /** @@ -98,25 +102,25 @@ const DelegationHandler = ( isDelegatedWithUrl || isDelegatedWithPrivateKey, /** - * Get the delegator options or undefined. - * (if delegator is undefined or null). + * Get the gasPayer options or undefined. + * (if gasPayer is undefined or null). * - * @returns The delegator options or undefined. + * @returns The gasPayer options or undefined. */ - delegatorOrUndefined: (): SignTransactionOptions | undefined => - delegatorIsUndefined ? undefined : delegator, + gasPayerOrUndefined: (): SignTransactionOptions | undefined => + gasPayerIsUndefined ? undefined : gasPayer, /** - * Get the delegator options or null. - * (if delegator is undefined or null). + * Get the gasPayer options or null. + * (if gasPayer is undefined or null). * - * @returns The delegator options or null. + * @returns The gasPayer options or null. */ - delegatorOrNull: (): SignTransactionOptions | null => - delegatorIsUndefined ? null : delegator, + gasPayerOrNull: (): SignTransactionOptions | null => + gasPayerIsUndefined ? null : gasPayer, /** - * Retrieves the signature of a delegation transaction from a delegator given the endpoint + * Retrieves the signature of a delegation transaction from a gasPayer given the endpoint * from which to retrieve the signature. * * @see [Simple Gas Payer Standard](https://github.com/vechain/VIPs/blob/master/vips/VIP-201.md) @@ -136,14 +140,14 @@ const DelegationHandler = ( if (!isDelegatedWithUrl) { throw new NotDelegatedTransaction( 'DelegationHandler.getDelegationSignatureUsingUrl()', - 'Delegation with url failed: delegatorUrl is not defined.', + 'Delegation with url failed: gasPayerServiceUrl is not defined.', undefined ); } return await _getDelegationSignature( tx, - delegator?.delegatorUrl, + gasPayer?.gasPayerServiceUrl, originAddress, httpClient ); diff --git a/packages/network/src/thor-client/transactions/types.d.ts b/packages/network/src/thor-client/transactions/types.d.ts index 9ff3c1d01..955ecc439 100644 --- a/packages/network/src/thor-client/transactions/types.d.ts +++ b/packages/network/src/thor-client/transactions/types.d.ts @@ -91,8 +91,8 @@ interface TransactionBodyOptions { * Options for `signTransaction` method. */ type SignTransactionOptions = - | { delegatorUrl: string; delegatorPrivateKey?: never } - | { delegatorPrivateKey: string; delegatorUrl?: never }; + | { gasPayerServiceUrl: string; gasPayerPrivateKey?: never } + | { gasPayerPrivateKey: string; gasPayerServiceUrl?: never }; /** * Input options for: @@ -243,7 +243,7 @@ interface TransactionDetailRaw { type TransactionDetailNoRaw = TransactionBody & { id: string; origin: string; - delegator: string | null; + gasPayer: string | null; size: number; meta: TransactionMetadata; }; diff --git a/packages/network/tests/fixture.ts b/packages/network/tests/fixture.ts index 95d0cf6a5..f747ad520 100644 --- a/packages/network/tests/fixture.ts +++ b/packages/network/tests/fixture.ts @@ -43,10 +43,10 @@ const THOR_SOLO_ACCOUNTS_BASE_WALLET: ProviderInternalBaseWallet = ); /** - * Test accounts into wallet fixture with delegator + * Test accounts into wallet fixture with gasPayer */ -const THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR = ( - delegator: SignTransactionOptions +const THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER = ( + gasPayer: SignTransactionOptions ): ProviderInternalBaseWallet => new ProviderInternalBaseWallet( THOR_SOLO_ACCOUNTS.map((account) => ({ @@ -57,7 +57,7 @@ const THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR = ( address: account.address })), { - delegator + gasPayer: gasPayer } ); @@ -83,7 +83,7 @@ const TEST_ACCOUNTS = { TRANSACTION: { TRANSACTION_SENDER: THOR_SOLO_ACCOUNTS[1], TRANSACTION_RECEIVER: THOR_SOLO_ACCOUNTS[2], - DELEGATOR: THOR_SOLO_ACCOUNTS[3], + GAS_PAYER: THOR_SOLO_ACCOUNTS[3], CONTRACT_MANAGER: THOR_SOLO_ACCOUNTS[4] }, @@ -890,6 +890,6 @@ export { TESTNET_DELEGATE_URL, testNetwork, THOR_SOLO_ACCOUNTS_BASE_WALLET, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR, + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER, ZERO_ADDRESS }; diff --git a/packages/network/tests/provider/formatter/fixture.ts b/packages/network/tests/provider/formatter/fixture.ts index 1995c9e42..3fbba2314 100644 --- a/packages/network/tests/provider/formatter/fixture.ts +++ b/packages/network/tests/provider/formatter/fixture.ts @@ -325,7 +325,7 @@ const transactionFixtures = [ gasPriceCoef: 0, gas: 399535, origin: '0x8c59c63d6458c71b6ff88d57698437524a703084', - delegator: null, + gasPayer: null, nonce: '0x19b4782', dependsOn: null, size: 709, diff --git a/packages/network/tests/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.unit.test.ts b/packages/network/tests/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.unit.test.ts index 8d54c56fc..e071f3438 100644 --- a/packages/network/tests/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.unit.test.ts +++ b/packages/network/tests/provider/helpers/provider-internal-wallets/base-wallet/provider-internal-base-wallet.unit.test.ts @@ -159,63 +159,62 @@ describe('Base wallet tests', () => { }); /** - * Test 'getDelegator' function. + * Test 'getGasPayer' function. */ - describe('getDelegator sync and async version', () => { + describe('getGasPayer sync and async version', () => { /** - * Should be able to get the delegator options + * Should be able to get the gasPayer options */ - test('Should be able to get the delegator', async () => { - // Initialize delegator - const delegators: SignTransactionOptions[] = [ + test('Should be able to get the gasPayer', async () => { + // Initialize gasPayer + const gasPayers: SignTransactionOptions[] = [ { - delegatorPrivateKey: Hex.of( - await Secp256k1.generatePrivateKey() - ).digits + gasPayerPrivateKey: Hex.of(Secp256k1.generatePrivateKey()) + .digits }, { - delegatorUrl: + gasPayerServiceUrl: 'https://sponsor-testnet.vechain.energy/by/269' } ]; - for (const delegator of delegators) { - // Initialize a wallet with the accounts and delegator - const baseWalletWithDelegator = new ProviderInternalBaseWallet( + for (const gasPayer of gasPayers) { + // Initialize a wallet with the accounts and gasPayer + const baseWalletWithGasPayer = new ProviderInternalBaseWallet( accountsFixture, { - delegator + gasPayer: gasPayer } ); - // Get the delegator from the wallet - const currentDelegator = - await baseWalletWithDelegator.getDelegator(); - expect(currentDelegator).toEqual(delegator); + // Get the gasPayer from the wallet + const currentGasPayer = + await baseWalletWithGasPayer.getGasPayer(); + expect(currentGasPayer).toEqual(gasPayer); - // Get the delegator from the wallet synchronously - const currentDelegatorSync = - baseWalletWithDelegator.getDelegatorSync(); - expect(currentDelegatorSync).toEqual(delegator); + // Get the gasPayer from the wallet synchronously + const currentGasPayerSync = + baseWalletWithGasPayer.getGasPayerSync(); + expect(currentGasPayerSync).toEqual(gasPayer); - // Expect the delegators to be the same - expect(currentDelegator).toEqual(currentDelegatorSync); + // Expect the gasPayer to be the same + expect(currentGasPayer).toEqual(currentGasPayerSync); } }); /** - * Should get null if delegator is not set + * Should get null if gasPayer is not set */ - test('Should get null if delegator is not set', async () => { + test('Should get null if gasPayer is not set', async () => { // Initialize a wallet with the accounts - const baseWalletWithoutDelegator = new ProviderInternalBaseWallet( + const baseWalletWithoutGasPayer = new ProviderInternalBaseWallet( accountsFixture ); - // Get the delegator from the wallet that has no delegator - const delegator = await baseWalletWithoutDelegator.getDelegator(); + // Get the gasPayer from the wallet that has no gasPayer + const gasPayer = await baseWalletWithoutGasPayer.getGasPayer(); - expect(delegator).toBeNull(); + expect(gasPayer).toBeNull(); }); }); }); diff --git a/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/fixture.ts b/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/fixture.ts index 7b9a62dc5..a1e62a7d2 100644 --- a/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/fixture.ts +++ b/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/fixture.ts @@ -11,8 +11,8 @@ const hdNodeFixtures = [ path: HDKey.VET_DERIVATION_PATH, count: 5, initialIndex: 0, - delegator: { - delegatorPrivateKey: + gasPayer: { + gasPayerPrivateKey: '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions, expectedAddress: [ @@ -28,8 +28,8 @@ const hdNodeFixtures = [ 'vivid any call mammal mosquito budget midnight expose spirit approve reject system', count: 1, initialIndex: 6, - delegator: { - delegatorUrl: 'https://sponsor-testnet.vechain.energy/by/269' + gasPayer: { + gasPayerServiceUrl: 'https://sponsor-testnet.vechain.energy/by/269' } satisfies SignTransactionOptions, expectedAddress: ['0x8ef651aC457C9bf5206EC3D2cbD4232Df0438607'] }, diff --git a/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.unit.test.ts b/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.unit.test.ts index 5f22312e2..75fc9dbe3 100644 --- a/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.unit.test.ts +++ b/packages/network/tests/provider/helpers/provider-internal-wallets/hd-wallet/provider-internal-hd-wallet.unit.test.ts @@ -29,15 +29,15 @@ describe('ProviderInternalHDWallet wallet tests', () => { hdNodeFixture.count, hdNodeFixture.initialIndex, hdNodeFixture.path, - { delegator: hdNodeFixture.delegator } + { gasPayer: hdNodeFixture.gasPayer } ); const addresses = await hdWallet.getAddresses(); - const delegator = await hdWallet.getDelegator(); + const gasPayer = await hdWallet.getGasPayer(); expect(addresses).toEqual(hdNodeFixture.expectedAddress); - expect(delegator).toEqual( - DelegationHandler(delegator).delegatorOrNull() + expect(gasPayer).toEqual( + DelegationHandler(gasPayer).gasPayerOrNull() ); }); }); diff --git a/packages/network/tests/provider/providers/vechain/vechain-provider.testnet.test.ts b/packages/network/tests/provider/providers/vechain/vechain-provider.testnet.test.ts index 7684c8b18..4f531d54c 100644 --- a/packages/network/tests/provider/providers/vechain/vechain-provider.testnet.test.ts +++ b/packages/network/tests/provider/providers/vechain/vechain-provider.testnet.test.ts @@ -111,7 +111,7 @@ describe('VeChain provider tests - testnet', () => { /** * Return null signer if wallet is not defined */ - test('Should throw an error if delegation is enabled and delegator is not defined', async () => { + test('Should throw an error if delegation is enabled and gasPayer is not defined', async () => { const nullSigner = await provider.getSigner( '0x0000000000000000000000000000456e65726779' ); diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/eth_sendTransaction.solo.test.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/eth_sendTransaction.solo.test.ts index 86ed1be4b..0ab996977 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/eth_sendTransaction.solo.test.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/eth_sendTransaction.solo.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect, test } from '@jest/globals'; import { THOR_SOLO_ACCOUNTS_BASE_WALLET, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER } from '../../../../fixture'; import { ProviderInternalBaseWallet, @@ -12,7 +12,7 @@ import { VeChainProvider } from '../../../../../src'; import { - delegatorPrivateKeyFixture, + gasPayerPrivateKeyFixture, THOR_SOLO_ACCOUNTS_ETH_SEND_TRANSACTION_FIXTURE } from './fixture'; import { @@ -36,7 +36,7 @@ describe('RPC Mapper - eth_sendTransaction method tests', () => { * Provider instance */ let provider: VeChainProvider; - let providerWithDelegator: VeChainProvider; + let providerWithgasPayer: VeChainProvider; /** * Init thor client before each test @@ -51,12 +51,12 @@ describe('RPC Mapper - eth_sendTransaction method tests', () => { THOR_SOLO_ACCOUNTS_BASE_WALLET ); - // Init provider with delegator + // Init provider with gasPayer // @NOTE due to the fact we are testing on thor-solo, we can delegate ONLY with a private key! - providerWithDelegator = new VeChainProvider( + providerWithgasPayer = new VeChainProvider( thorClient, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR({ - delegatorPrivateKey: delegatorPrivateKeyFixture + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER({ + gasPayerPrivateKey: gasPayerPrivateKeyFixture }), true ); @@ -74,7 +74,7 @@ describe('RPC Mapper - eth_sendTransaction method tests', () => { test(`eth_sendTransaction - Should be able to send a transaction with value ${value} - ${delegated ? 'delegated case' : 'not delegated case'}`, async () => { // Get the provider to use depending on delegated or not const providerToUse = delegated - ? providerWithDelegator + ? providerWithgasPayer : provider; // Get the balance of the sender and the receiver before sending the transaction diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/fixture.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/fixture.ts index 8acb706d1..eabb1d864 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/fixture.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_sendTransaction/fixture.ts @@ -9,11 +9,11 @@ const THOR_SOLO_ACCOUNTS_ETH_SEND_TRANSACTION_FIXTURE = { }; /** - * Fixture for a delegator private key + * Fixture for a gasPayer private key */ -const delegatorPrivateKeyFixture = THOR_SOLO_ACCOUNTS[4].privateKey; +const gasPayerPrivateKeyFixture = THOR_SOLO_ACCOUNTS[4].privateKey; export { THOR_SOLO_ACCOUNTS_ETH_SEND_TRANSACTION_FIXTURE, - delegatorPrivateKeyFixture + gasPayerPrivateKeyFixture }; diff --git a/packages/network/tests/provider/rpc-mapper/methods/eth_signTransaction/eth_signTransaction.testnet.test.ts b/packages/network/tests/provider/rpc-mapper/methods/eth_signTransaction/eth_signTransaction.testnet.test.ts index 8f24c4df2..a0395286b 100644 --- a/packages/network/tests/provider/rpc-mapper/methods/eth_signTransaction/eth_signTransaction.testnet.test.ts +++ b/packages/network/tests/provider/rpc-mapper/methods/eth_signTransaction/eth_signTransaction.testnet.test.ts @@ -7,10 +7,10 @@ import { } from '../../../../../src'; import { THOR_SOLO_ACCOUNTS_BASE_WALLET, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER } from '../../../../fixture'; import { - delegatorPrivateKeyFixture, + gasPayerPrivateKeyFixture, THOR_SOLO_ACCOUNTS_ETH_SEND_TRANSACTION_FIXTURE } from '../eth_sendTransaction/fixture'; import { Hex } from '@vechain/sdk-core'; @@ -34,7 +34,7 @@ describe('RPC Mapper - eth_signTransaction method tests', () => { * Provider instance */ let provider: VeChainProvider; - let providerWithDelegator: VeChainProvider; + let providerWithGasPayer: VeChainProvider; /** * Init thor client before each test @@ -50,13 +50,13 @@ describe('RPC Mapper - eth_signTransaction method tests', () => { THOR_SOLO_ACCOUNTS_BASE_WALLET ); - // Init provider with delegator + // Init provider with gasPayer // @NOTE due to the fact we are testing on thor-solo, we can delegate ONLY with a private key! // @NOTE: Since we are testing the signature, we can use SOLO accounts with testnet! - providerWithDelegator = new VeChainProvider( + providerWithGasPayer = new VeChainProvider( thorClient, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR({ - delegatorPrivateKey: delegatorPrivateKeyFixture + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER({ + gasPayerPrivateKey: gasPayerPrivateKeyFixture }), true ); @@ -73,13 +73,13 @@ describe('RPC Mapper - eth_signTransaction method tests', () => { test( 'Should be able to sign transactions', async () => { - // Sign with the delegator OR not + // Sign with the gasPayer OR not for (const delegated of [true, false]) { // Value field of the transaction objects to sign for (const value of ['0x111', '0x222', '0x333']) { // Get the provider to use depending on delegated or not const providerToUse = delegated - ? providerWithDelegator + ? providerWithGasPayer : provider; // Send a transaction diff --git a/packages/network/tests/signer/signers/vechain-private-key-signer/fixture.ts b/packages/network/tests/signer/signers/vechain-private-key-signer/fixture.ts index 0c237f306..745a4fed1 100644 --- a/packages/network/tests/signer/signers/vechain-private-key-signer/fixture.ts +++ b/packages/network/tests/signer/signers/vechain-private-key-signer/fixture.ts @@ -52,7 +52,7 @@ interface TestCaseTypedData { /** * SignTransaction test cases - * Has both correct and incorrect for solo and an example of using delegatorUrl on testnet + * Has both correct and incorrect for solo and an example of using gasPayerServiceUrl on testnet */ const signTransactionTestCases = { solo: { @@ -86,8 +86,8 @@ const signTransactionTestCases = { 'Should sign a transaction with private key delegation', origin: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER, options: { - delegatorPrivateKey: - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.privateKey + gasPayerPrivateKey: + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.privateKey } satisfies SignTransactionOptions, isDelegated: true, expected: { @@ -117,20 +117,20 @@ const signTransactionTestCases = { incorrect: [ { description: - "Should throw error when delegator's private key is invalid", + "Should throw error when gasPayer's private key is invalid", origin: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER, options: { - delegatorPrivateKey: 'INVALID_PRIVATE_KEY' + gasPayerPrivateKey: 'INVALID_PRIVATE_KEY' } satisfies SignTransactionOptions, isDelegated: true, expectedError: InvalidDataType }, { description: - "Should throw error when using delegator url on solo network due to no server providing the delegator's signature through an endpoint", + "Should throw error when using gasPayer url on solo network due to no server providing the gasPayer's signature through an endpoint", origin: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER, options: { - delegatorUrl: 'https://example.com' + gasPayerServiceUrl: 'https://example.com' } satisfies SignTransactionOptions, isDelegated: true, expectedError: NotDelegatedTransaction @@ -143,7 +143,7 @@ const signTransactionTestCases = { description: 'Should sign a transaction with delegation url', origin: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER, options: { - delegatorUrl: TESTNET_DELEGATE_URL + gasPayerServiceUrl: TESTNET_DELEGATE_URL } satisfies SignTransactionOptions, isDelegated: true, expected: { @@ -170,7 +170,7 @@ const signTransactionTestCases = { incorrect: [ { description: - 'Should NOT sign a transaction with delegation when no delegator is provided', + 'Should NOT sign a transaction with delegation when no gasPayer is provided', origin: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER, options: undefined, isDelegated: true, diff --git a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.solo.test.ts b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.solo.test.ts index 9d509be29..57c89edd1 100644 --- a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.solo.test.ts +++ b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.solo.test.ts @@ -82,7 +82,7 @@ describe('VeChain base signer tests - solo', () => { new VeChainProvider( thorClient, new ProviderInternalBaseWallet([], { - delegator: options + gasPayer: options }), isDelegated ) @@ -140,7 +140,7 @@ describe('VeChain base signer tests - solo', () => { new VeChainProvider( thorClient, new ProviderInternalBaseWallet([], { - delegator: options + gasPayer: options }), true ) diff --git a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.testnet.test.ts b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.testnet.test.ts index fea5d7606..76277f75c 100644 --- a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.testnet.test.ts +++ b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.testnet.test.ts @@ -23,7 +23,7 @@ import { TESTING_CONTRACT_ABI, TESTING_CONTRACT_ADDRESS, THOR_SOLO_ACCOUNTS_BASE_WALLET, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER } from '../../../fixture'; import { signTransactionTestCases } from './fixture'; @@ -86,7 +86,7 @@ describe('VeChain base signer tests - testnet', () => { HexUInt.of(fixture.origin.privateKey).bytes, new VeChainProvider( thorClient, - THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_DELEGATOR( + THOR_SOLO_ACCOUNTS_BASE_WALLET_WITH_GAS_PAYER( fixture.options ), true @@ -121,7 +121,7 @@ describe('VeChain base signer tests - testnet', () => { // Sign the transaction const signedTransaction = await signer.signTransaction({ from: fixture.origin.address, - delegationUrl: fixture.options.delegatorUrl + delegationUrl: fixture.options.gasPayerServiceUrl }); expect(signedTransaction).toBeDefined(); @@ -173,7 +173,7 @@ describe('VeChain base signer tests - testnet', () => { new VeChainProvider( thorClient, new ProviderInternalBaseWallet([], { - delegator: options + gasPayer: options }), isDelegated ) diff --git a/packages/network/tests/thor-client/blocks/fixture.ts b/packages/network/tests/thor-client/blocks/fixture.ts index e543340ee..4b988b2af 100644 --- a/packages/network/tests/thor-client/blocks/fixture.ts +++ b/packages/network/tests/thor-client/blocks/fixture.ts @@ -212,7 +212,7 @@ const validExpandedBlockRevisions = [ gasPriceCoef: 0, gas: 21000, origin: '0x6b8d66568cbc7944798268aca153f426596d250a', - delegator: null, + delegator: null, // TO BE REMOVED WHEN BNC COMPLETE nonce: '0x4ec144ad97b4b079', dependsOn: null, size: 130, diff --git a/packages/network/tests/thor-client/contracts/contract.erc20.solo.test.ts b/packages/network/tests/thor-client/contracts/contract.erc20.solo.test.ts index 716943b21..98c47a474 100644 --- a/packages/network/tests/thor-client/contracts/contract.erc20.solo.test.ts +++ b/packages/network/tests/thor-client/contracts/contract.erc20.solo.test.ts @@ -55,9 +55,9 @@ describe('ThorClient - ERC20 Contracts', () => { } ], { - delegator: { - delegatorPrivateKey: - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.privateKey + gasPayer: { + gasPayerPrivateKey: + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.privateKey } } ), @@ -225,15 +225,15 @@ describe('ThorClient - ERC20 Contracts', () => { contract.setContractTransactOptions({ signTransactionOptions: { - delegatorPrivateKey: - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.privateKey + gasPayerPrivateKey: + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.privateKey }, isDelegated: true }); await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n ) ).wait(); @@ -258,7 +258,7 @@ describe('ThorClient - ERC20 Contracts', () => { const txResult = await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n ) ).wait(); @@ -267,7 +267,7 @@ describe('ThorClient - ERC20 Contracts', () => { expect( await contract.read.balanceOf( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address ) ).toEqual([1000n]); }, 10000); @@ -388,12 +388,12 @@ describe('ThorClient - ERC20 Contracts', () => { ), contract.clause.transfer( { comment: 'Transfer 1000 tokens' }, - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n ), contract.clause.transfer( { comment: 'Transfer 3000 tokens' }, - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 3000n ) ], @@ -408,7 +408,7 @@ describe('ThorClient - ERC20 Contracts', () => { TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address ), contract.clause.balanceOf( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address ) ] ); @@ -449,7 +449,7 @@ describe('ThorClient - ERC20 Contracts', () => { const txResult = await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n ) ).wait(); @@ -458,7 +458,7 @@ describe('ThorClient - ERC20 Contracts', () => { expect( await contract.read.balanceOf( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address ) ).toEqual([1000n]); }, 30000); diff --git a/packages/network/tests/thor-client/contracts/contract.erc20.testnet.test.ts b/packages/network/tests/thor-client/contracts/contract.erc20.testnet.test.ts index d6ab90733..ccac9efaa 100644 --- a/packages/network/tests/thor-client/contracts/contract.erc20.testnet.test.ts +++ b/packages/network/tests/thor-client/contracts/contract.erc20.testnet.test.ts @@ -44,8 +44,8 @@ describe('ThorClient - ERC20 Contracts on testnet', () => { } ], { - delegator: { - delegatorUrl: TESTNET_DELEGATE_URL + gasPayer: { + gasPayerServiceUrl: TESTNET_DELEGATE_URL } } ), @@ -69,7 +69,7 @@ describe('ThorClient - ERC20 Contracts on testnet', () => { const txResult = await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n ) ).wait(); @@ -87,7 +87,7 @@ describe('ThorClient - ERC20 Contracts on testnet', () => { )) as VeChainSigner, ERC20_CONTRACT_ADDRESS_ON_TESTNET, ABIContract.ofAbi(ERC20_ABI).getFunction('transfer'), - [TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, 1000n], + [TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1000n], { comment: 'test comment', delegationUrl: TESTNET_DELEGATE_URL diff --git a/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts b/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts index a7b26c9c7..7699a71a9 100644 --- a/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts +++ b/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts @@ -315,7 +315,7 @@ describe('ThorClient - ERC20 Contracts', () => { await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 5000n ) ).wait(); @@ -325,13 +325,13 @@ describe('ThorClient - ERC20 Contracts', () => { TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address ]); - const transferCriteriaDelegator = contract.criteria.Transfer([ + const transferCriteriaGasPayer = contract.criteria.Transfer([ undefined, - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address ]); const events = await thorSoloClient.logs.filterEventLogs({ - criteriaSet: [transferCriteria, transferCriteriaDelegator] + criteriaSet: [transferCriteria, transferCriteriaGasPayer] }); expect( @@ -400,7 +400,7 @@ describe('ThorClient - ERC20 Contracts', () => { await ( await contract.transact.transfer( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 5000n ) ).wait(); @@ -410,13 +410,13 @@ describe('ThorClient - ERC20 Contracts', () => { TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address ]); - const transferCriteriaDelegator = contract.criteria.Transfer([ + const transferCriteriaGasPayer = contract.criteria.Transfer([ undefined, - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address ]); const events = await thorSoloClient.logs.filterEventLogs({ - criteriaSet: [transferCriteria, transferCriteriaDelegator] + criteriaSet: [transferCriteria, transferCriteriaGasPayer] }); expect(events.map((x) => x.decodedData)).toEqual([ diff --git a/packages/network/tests/thor-client/contracts/fixture.ts b/packages/network/tests/thor-client/contracts/fixture.ts index cdd428f60..aa143b446 100644 --- a/packages/network/tests/thor-client/contracts/fixture.ts +++ b/packages/network/tests/thor-client/contracts/fixture.ts @@ -26,7 +26,7 @@ const depositContractBytecode: string = const sampleTwoValuesReturnBytecode: string = '0x608060405234801561001057600080fd5b506101ea806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630dbe671f1461003b5780634df7e3d01461005a575b600080fd5b610043610064565b604051610051929190610184565b60405180910390f35b6100626100a8565b005b6000606060016040518060400160405280600181526020017f6100000000000000000000000000000000000000000000000000000000000000815250915091509091565b600060606100b4610064565b80925081935050506100c4610064565b50809250506100d1610064565b9050809150505050565b6000819050919050565b6100ee816100db565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561012e578082015181840152602081019050610113565b60008484015250505050565b6000601f19601f8301169050919050565b6000610156826100f4565b61016081856100ff565b9350610170818560208601610110565b6101798161013a565b840191505092915050565b600060408201905061019960008301856100e5565b81810360208301526101ab818461014b565b9050939250505056fea26469706673582212201b347b344b0405eee69f8551d7f0dff5cb414de0237f3a6e9192c43efbf009ab64736f6c63430008140033'; -// to recharge the delegator, deposit to this address: 0xD4a88FE48909486B7A91ec821598d73740398337, lasts until 2024-05-10 +// to recharge the gasPayer, deposit to this address: 0xD4a88FE48909486B7A91ec821598d73740398337, lasts until 2024-05-10 const TESTNET_DELEGATE_URL = 'https://sponsor-testnet.vechain.energy/by/473'; const ERC20_CONTRACT_ADDRESS_ON_TESTNET = @@ -304,12 +304,12 @@ const erc721ContractTestCases: TestCase[] = [ description: 'should mint an NFT for the specific address of another user', functionName: 'mintItem', - params: [TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address], + params: [TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address], expected: [ '0x0000000000000000000000000000000000000000', Address.checksum( HexUInt.of( - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address.toLowerCase() + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address.toLowerCase() ) ), 2n @@ -334,9 +334,9 @@ const erc721ContractTestCases: TestCase[] = [ }, { description: - 'should get the current NFT balance of the DELEGATOR address', + 'should get the current NFT balance of the GAS_PAYER address', functionName: 'balanceOf', - params: [TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address], + params: [TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address], expected: { success: true, result: { @@ -348,11 +348,11 @@ const erc721ContractTestCases: TestCase[] = [ isReadOnly: true }, { - description: 'should transfer the NFT to DELEGATOR address', + description: 'should transfer the NFT to GAS_PAYER address', functionName: 'transferFrom', params: [ TEST_ACCOUNTS.TRANSACTION.CONTRACT_MANAGER.address, - TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, 1n ], expected: [ @@ -360,7 +360,7 @@ const erc721ContractTestCases: TestCase[] = [ HexUInt.of(TEST_ACCOUNTS.TRANSACTION.CONTRACT_MANAGER.address) ), Address.checksum( - HexUInt.of(TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address) + HexUInt.of(TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address) ), 1n ], @@ -384,9 +384,9 @@ const erc721ContractTestCases: TestCase[] = [ }, { description: - 'should get the current NFT balance of the DELEGATOR address', + 'should get the current NFT balance of the GAS_PAYER address', functionName: 'balanceOf', - params: [TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address], + params: [TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address], expected: { success: true, result: { diff --git a/packages/network/tests/thor-client/transactions/fixture-thorest.ts b/packages/network/tests/thor-client/transactions/fixture-thorest.ts index 6d70851e5..5e0c37fae 100644 --- a/packages/network/tests/thor-client/transactions/fixture-thorest.ts +++ b/packages/network/tests/thor-client/transactions/fixture-thorest.ts @@ -31,7 +31,7 @@ const transactionDetails = { gasPriceCoef: 0, gas: 41192, origin: '0x2d4ed6b8abd00bc2ef0bdb2258a946c214d9d0af', - delegator: null, + delegator: null, // TO BE REMOVED WHEN BNC REFACTORING DONE. nonce: '0x76eed751cef0e52d', dependsOn: null, size: 130, @@ -180,7 +180,7 @@ const sendTransactionErrors = { data: '0x' }, { - to: TEST_ACCOUNTS.TRANSACTION.DELEGATOR.address, + to: TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.address, value: 1000000, data: '0x' } diff --git a/packages/network/tests/thor-client/transactions/helpers/delegation-handler.unit.test.ts b/packages/network/tests/thor-client/transactions/helpers/delegation-handler.unit.test.ts index 0e4c584e2..45e30fc36 100644 --- a/packages/network/tests/thor-client/transactions/helpers/delegation-handler.unit.test.ts +++ b/packages/network/tests/thor-client/transactions/helpers/delegation-handler.unit.test.ts @@ -19,15 +19,15 @@ describe('Tests of DelegationHandler helper function', () => { * - It's a method that uses the network. * - It's already tested in the integration tests of transactions-module. */ - delegationHandlerFixture.forEach(({ testName, delegator, expected }) => { + delegationHandlerFixture.forEach(({ testName, gasPayer, expected }) => { test(testName, () => { - const delegationHandler = DelegationHandler(delegator); + const delegationHandler = DelegationHandler(gasPayer); expect(delegationHandler.isDelegated()).toBe(expected.isDelegated); - expect(delegationHandler.delegatorOrUndefined()).toEqual( - expected.delegatorOrUndefined + expect(delegationHandler.gasPayerOrUndefined()).toEqual( + expected.gasPayerOrUndefined ); - expect(delegationHandler.delegatorOrNull()).toEqual( - expected.delegatorOrNull + expect(delegationHandler.gasPayerOrNull()).toEqual( + expected.gasPayerOrNull ); }); }); @@ -37,12 +37,12 @@ describe('Tests of DelegationHandler helper function', () => { */ describe('Negative tests cases', () => { /** - *Should throw an error when get delegatorUrl if delegator url is not provided. + *Should throw an error when get gasPayerServiceUrl if gasPayer url is not provided. */ - test('Should throw an error when get delegatorUrl if delegator url is not provided', async () => { + test('Should throw an error when get gasPayerServiceUrl if gasPayer url is not provided', async () => { await expect(async () => { await DelegationHandler({ - delegatorPrivateKey: + gasPayerPrivateKey: '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' }).getDelegationSignatureUsingUrl( Transaction.of(TransactionFixture.delegated.body), diff --git a/packages/network/tests/thor-client/transactions/helpers/fixture.ts b/packages/network/tests/thor-client/transactions/helpers/fixture.ts index dc1a494c7..0268fbcd4 100644 --- a/packages/network/tests/thor-client/transactions/helpers/fixture.ts +++ b/packages/network/tests/thor-client/transactions/helpers/fixture.ts @@ -4,82 +4,82 @@ import { type SignTransactionOptions } from '../../../../src'; * Fixtures for delegation handler */ const delegationHandlerFixture = [ - // NOT Empty delegator - delegatorUrl + // NOT Empty gasPayer - gasPayerServiceUrl { testName: - 'Should be able to use DelegationHandler with not empty delegator - delegatorUrl', - delegator: { - delegatorUrl: 'http://localhost:8669' + 'Should be able to use DelegationHandler with not empty gasPayer - gasPayerServiceUrl', + gasPayer: { + gasPayerServiceUrl: 'http://localhost:8669' } satisfies SignTransactionOptions, expected: { isDelegated: true, - delegatorOrUndefined: { - delegatorUrl: 'http://localhost:8669' + gasPayerOrUndefined: { + gasPayerServiceUrl: 'http://localhost:8669' } satisfies SignTransactionOptions, - delegatorOrNull: { - delegatorUrl: 'http://localhost:8669' + gasPayerOrNull: { + gasPayerServiceUrl: 'http://localhost:8669' } satisfies SignTransactionOptions } }, - // NOT Empty delegator - delegatorPrivateKey + // NOT Empty gasPayer - gasPayerPrivateKey { testName: - 'Should be able to use DelegationHandler with not empty delegator - delegatorPrivateKey', - delegator: { - delegatorPrivateKey: + 'Should be able to use DelegationHandler with not empty gasPayer - gasPayerPrivateKey', + gasPayer: { + gasPayerPrivateKey: '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions, expected: { isDelegated: true, - delegatorOrUndefined: { - delegatorPrivateKey: + gasPayerOrUndefined: { + gasPayerPrivateKey: '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions, - delegatorOrNull: { - delegatorPrivateKey: + gasPayerOrNull: { + gasPayerPrivateKey: '7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions } }, - // NOT Empty delegator - delegatorPrivateKey (with 0x in front of the private key) + // NOT Empty gasPayer - gasPayerPrivateKey (with 0x in front of the private key) { testName: - 'Should be able to use DelegationHandler with not empty delegator - delegatorPrivateKey', - delegator: { - delegatorPrivateKey: + 'Should be able to use DelegationHandler with not empty gasPayer - gasPayerPrivateKey', + gasPayer: { + gasPayerPrivateKey: '0x7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions, expected: { isDelegated: true, - delegatorOrUndefined: { - delegatorPrivateKey: + gasPayerOrUndefined: { + gasPayerPrivateKey: '0x7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions, - delegatorOrNull: { - delegatorPrivateKey: + gasPayerOrNull: { + gasPayerPrivateKey: '0x7f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158' } satisfies SignTransactionOptions } }, - // Empty delegator - undefined + // Empty gasPayer - undefined { testName: - 'Should be able to use DelegationHandler with empty delegator - undefined', + 'Should be able to use DelegationHandler with empty gasPayer - undefined', expected: { isDelegated: false, - delegatorOrUndefined: undefined, - delegatorOrNull: null + gasPayerOrUndefined: undefined, + gasPayerOrNull: null } }, - // Empty delegator - null + // Empty gasPayer - null { testName: - 'Should be able to use DelegationHandler with empty delegator - null', - delegator: null, + 'Should be able to use DelegationHandler with empty gasPayer - null', + gasPayer: null, expected: { isDelegated: false, - delegatorOrUndefined: undefined, - delegatorOrNull: null + gasPayerOrUndefined: undefined, + gasPayerOrNull: null } } ]; diff --git a/packages/network/tests/thor-client/transactions/transactions-thorest.solo.test.ts b/packages/network/tests/thor-client/transactions/transactions-thorest.solo.test.ts index 0b3ede91f..83d177044 100644 --- a/packages/network/tests/thor-client/transactions/transactions-thorest.solo.test.ts +++ b/packages/network/tests/thor-client/transactions/transactions-thorest.solo.test.ts @@ -86,7 +86,7 @@ describe('ThorClient - Transactions Module', () => { HexUInt.of( TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER.privateKey ).bytes, - HexUInt.of(TEST_ACCOUNTS.TRANSACTION.DELEGATOR.privateKey) + HexUInt.of(TEST_ACCOUNTS.TRANSACTION.GAS_PAYER.privateKey) .bytes ).encoded; diff --git a/packages/rpc-proxy/README.md b/packages/rpc-proxy/README.md index 1a2da5390..e544710ae 100644 --- a/packages/rpc-proxy/README.md +++ b/packages/rpc-proxy/README.md @@ -141,7 +141,7 @@ Simple thor solo configuration with accounts as a list of private keys: } ``` -Simple testnet configuration with a delegator private key: +Simple testnet configuration with a gasPayer private key: ``` json { @@ -152,14 +152,14 @@ Simple testnet configuration with a delegator private key: "count": 10, "initialIndex": 0 }, - "delegator": { + "gasPayer": { "delegatorPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" }, "enableDelegation": true } ``` -Simple testnet configuration with a delegator private url: +Simple testnet configuration with a gasPayer private url: ``` json { @@ -170,7 +170,7 @@ Simple testnet configuration with a delegator private url: "count": 10, "initialIndex": 0 }, - "delegator": { + "gasPayer": { "delegatorUrl": "https://sponsor-testnet.vechain.energy/by/..." }, "enableDelegation": true @@ -183,9 +183,10 @@ To run the RPC proxy as a Docker container, follow these steps: ``` bash cd ../.. -docker build -f docker/rpc-proxy/Dockerfile . -t vechain-rpc-proxy -# We are assuming that the config.json file is placed at the same level as the project root -docker run -d -p 8545:8545 -v ./config.json:/app/config.json -t vechain-rpc-proxy +docker build -f docker/rpc-proxy/Dockerfile . -t vechain/sdk-rpc-proxy +# To replace the default config file, update the config.json file and start a terminal from the folder in which the file is located. +# DISCLAIMER: Make sure you replace the default config file before using it for production software. By default, the docker will point to testnet and use a known mnemonic. +docker run -d -p 8545:8545 -v ./config.json:/app/packages/rpc-proxy/config.json -t vechain/sdk-rpc-proxy ``` If you do not pass a config.json file, the default solo network standard configuration will be used. Make sure to diff --git a/packages/rpc-proxy/src/index.ts b/packages/rpc-proxy/src/index.ts index 27cb23ee7..069809810 100644 --- a/packages/rpc-proxy/src/index.ts +++ b/packages/rpc-proxy/src/index.ts @@ -70,7 +70,7 @@ function startProxy(): void { }; }), { - delegator: config.delegator + gasPayer: config.gasPayer } ) : new ProviderInternalHDWallet( @@ -78,7 +78,7 @@ function startProxy(): void { config.accounts.count, config.accounts.initialIndex, HDKey.VET_DERIVATION_PATH, - { delegator: config.delegator } + { gasPayer: config.gasPayer } ); const provider = new VeChainProvider( thorClient, diff --git a/packages/rpc-proxy/src/types.d.ts b/packages/rpc-proxy/src/types.d.ts index 11cb92bdc..32d904f27 100644 --- a/packages/rpc-proxy/src/types.d.ts +++ b/packages/rpc-proxy/src/types.d.ts @@ -27,9 +27,9 @@ interface Config { /** * - * Delegator configuration + * Gas-payer configuration */ - delegator?: SignTransactionOptions; + gasPayer?: SignTransactionOptions; /** * Enable verbose logging 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 6f45e960f..c29a9bd81 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 @@ -152,7 +152,7 @@ const ArgsValidatorAndGetter = { ) { throw new InvalidCommandLineArguments( 'ArgsValidatorAndGetter.delegation()', - 'Both delegator private key and delegator URL are provided. Only one can be provided', + 'Both gasPayer private key and gasPayer URL are provided. Only one can be provided', { flag: '{-dp , --delegatorPrivateKey}, {-du , --delegatorUrl}', value: `{value not provided for security reason} , {${options.delegatorUrl as string}}` @@ -167,23 +167,23 @@ const ArgsValidatorAndGetter = { ) { return { ...currentConfiguration, - delegator: { - delegatorPrivateKey: ArgsValidator.delegatorPrivateKey( + gasPayer: { + gasPayerPrivateKey: ArgsValidator.delegatorPrivateKey( options.delegatorPrivateKey as string ) } }; } - // Delegation is made with a delegator URL + // Delegation is made with a gasPayer URL if ( options.delegatorUrl !== undefined && options.delegatorUrl !== null ) { return { ...currentConfiguration, - delegator: { - delegatorUrl: ArgsValidator.delegatorUrl( + gasPayer: { + gasPayerServiceUrl: ArgsValidator.delegatorUrl( options.delegatorUrl 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 e41e6a28c..3b1f58ef7 100644 --- a/packages/rpc-proxy/src/utils/args-validator/args-validator.ts +++ b/packages/rpc-proxy/src/utils/args-validator/args-validator.ts @@ -264,7 +264,7 @@ const ArgsValidator = { ) { throw new InvalidCommandLineArguments( 'ArgsValidator.delegatorPrivateKey()', - 'An invalid delegator private key provided.', + 'An invalid gasPayer private key provided.', { flag: '-dp , --delegatorPrivateKey', value: 'Value will not be shown for security reasons' @@ -288,7 +288,7 @@ const ArgsValidator = { if (!isValidDelegatorUrl(delegatorUrl) || delegatorUrl === '') { throw new InvalidCommandLineArguments( 'ArgsValidator.delegatorUrl()', - 'Invalid delegator url provided. The parameter must be a valid url', + 'Invalid gasPayer url provided. The parameter must be a valid url', { flag: '-du , --delegatorUrl', value: delegatorUrl diff --git a/packages/rpc-proxy/src/utils/args/args-parser.ts b/packages/rpc-proxy/src/utils/args/args-parser.ts index d149be47e..6b6b2c1c7 100644 --- a/packages/rpc-proxy/src/utils/args/args-parser.ts +++ b/packages/rpc-proxy/src/utils/args/args-parser.ts @@ -70,7 +70,7 @@ function parseAndGetFinalConfig( options.enableDelegation as boolean; } - // B.8 - Get and validate delegator private key field + // B.8 - Get and validate gasPayer private key field configuration = ArgsValidatorAndGetter.delegation( options, configuration @@ -79,10 +79,10 @@ function parseAndGetFinalConfig( // C - Evaluate the semantic of the arguments. // NOTE: Here we know all the fields are valid. So we can check the semantics of the fields. - // Delegation cannot be enabled without a delegator + // Delegation cannot be enabled without a gasPayer if ( (configuration.enableDelegation as boolean) && - configuration.delegator === undefined + configuration.gasPayer === undefined ) { throw new InvalidCommandLineArguments( '_checkIfConfigurationFileHasCorrectStructure()', 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 9cb3fadcf..0929fb3ad 100644 --- a/packages/rpc-proxy/src/utils/config-validator/config-validator.ts +++ b/packages/rpc-proxy/src/utils/config-validator/config-validator.ts @@ -119,28 +119,26 @@ function _checkIfConfigurationFileHasCorrectStructure(filePath: string): void { ); } - // Check the delegator - if (configFile.delegator !== undefined) { - // Both delegator private key and url are given + // Check the gasPayer + if (configFile.gasPayer !== undefined) { + // Both gasPayer private key and url are given if ( - configFile.delegator.delegatorPrivateKey !== undefined && - configFile.delegator.delegatorUrl !== undefined + configFile.gasPayer.gasPayerPrivateKey !== undefined && + configFile.gasPayer.gasPayerServiceUrl !== undefined ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', - `Invalid delegator configuration in configuration file: ${absolutePath}. Delegator configuration must contain either a private key or a URL, not both`, + `Invalid gasPayer configuration in configuration file: ${absolutePath}. The gasPayer configuration must contain either a private key or a URL, not both`, { filePath } ); } - // Invalid delegator private key + // Invalid gasPayer private key if ( - configFile.delegator.delegatorPrivateKey !== undefined && - !isValidDelegatorPrivateKey( - configFile.delegator.delegatorPrivateKey - ) + configFile.gasPayer.gasPayerPrivateKey !== undefined && + !isValidDelegatorPrivateKey(configFile.gasPayer.gasPayerPrivateKey) ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', @@ -151,10 +149,10 @@ function _checkIfConfigurationFileHasCorrectStructure(filePath: string): void { ); } - // Invalid delegator url + // Invalid gasPayer url if ( - configFile.delegator.delegatorUrl !== undefined && - !isValidDelegatorUrl(configFile.delegator.delegatorUrl) + configFile.gasPayer.gasPayerServiceUrl !== undefined && + !isValidDelegatorUrl(configFile.gasPayer.gasPayerServiceUrl) ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', @@ -196,14 +194,14 @@ function _checkIfConfigurationFileHasCorrectStructure(filePath: string): void { // NOTE: Here we know all the fields are valid. So we can check the semantics of the fields. - // Delegation cannot be enabled without a delegator + // Delegation cannot be enabled without a gasPayer if ( (configFile.enableDelegation as boolean) && - configFile.delegator === undefined + configFile.gasPayer === undefined ) { throw new InvalidConfigurationFile( '_checkIfConfigurationFileHasCorrectStructure()', - `Invalid configuration file: ${absolutePath}. Delegator configuration must be removed when enableDelegation is false`, + `Invalid configuration file: ${absolutePath}. The gasPayer configuration must be removed when enableDelegation is false`, { filePath } diff --git a/packages/rpc-proxy/src/utils/validators/validators.ts b/packages/rpc-proxy/src/utils/validators/validators.ts index 2dfa90a36..fcb7a5cb7 100644 --- a/packages/rpc-proxy/src/utils/validators/validators.ts +++ b/packages/rpc-proxy/src/utils/validators/validators.ts @@ -87,7 +87,7 @@ function isValidAccountsAsMnemonic(account: { } /** - * Check if the delegator url is valid + * Check if the gasPayer url is valid * @param url - URL to check * @returns True if the url is valid, false otherwise */ @@ -96,7 +96,7 @@ function isValidDelegatorUrl(url: string): boolean { } /** - * Check if the delegator private key is valid + * Check if the gasPayer private key is valid * @param privateKey - Private key to check * @returns True if the private key is valid, false otherwise */ diff --git a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-private-key.json b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json similarity index 95% rename from packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-private-key.json rename to packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json index 885350a0d..906ffa786 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-private-key.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-private-key.json @@ -6,8 +6,8 @@ "count": 10, "initialIndex": 0 }, - "delegator": { + "gasPayer": { "delegatorPrivateKey": "8f9290cc44c5fd2b95fe21d6ad6fe5fa9c177e1cd6f3b4c96a97b13e09eaa158" }, "enableDelegation": false -} \ No newline at end of file +} diff --git a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-url.json b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json similarity index 94% rename from packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-url.json rename to packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json index 7af6e7e30..aaacb8706 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-delegator-url.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/correct-proxy-config-gas-payer-url.json @@ -6,8 +6,8 @@ "count": 10, "initialIndex": 0 }, - "delegator": { + "gasPayer": { "delegatorUrl": "https://testnet.vechain.org" }, "enableDelegation": false -} \ No newline at end of file +} diff --git a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-2.json b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-1.json similarity index 82% rename from packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-2.json rename to packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-1.json index 37020cf52..31f89b348 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-2.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-1.json @@ -6,8 +6,8 @@ "count": 0, "initialIndex": 0 }, - "delegator": { - "delegatorUrl": "INVALID" + "gasPayer": { + "gasPayerPrivateKey": "INVALID" }, "enableDelegation": false -} \ No newline at end of file +} diff --git a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-1.json b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-2.json similarity index 81% rename from packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-1.json rename to packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-2.json index 3b65773b0..7ab8c745e 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-1.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-2.json @@ -6,8 +6,8 @@ "count": 0, "initialIndex": 0 }, - "delegator": { - "delegatorPrivateKey": "INVALID" + "gasPayer": { + "gasPayerServiceUrl": "INVALID" }, "enableDelegation": false -} \ No newline at end of file +} diff --git a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-3.json b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-3.json similarity index 73% rename from packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-3.json rename to packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-3.json index 7145ec069..3b4c181dc 100644 --- a/packages/rpc-proxy/tests/config-files-fixtures/invalid-delegator-proxy-config-3.json +++ b/packages/rpc-proxy/tests/config-files-fixtures/invalid-gas-payer-proxy-config-3.json @@ -6,9 +6,9 @@ "count": 0, "initialIndex": 0 }, - "delegator": { - "delegatorPrivateKey": "INVALID", - "delegatorUrl": "INVALID" + "gasPayer": { + "gasPayerPrivateKey": "INVALID", + "gasPayerServiceUrl": "INVALID" }, "enableDelegation": false -} \ No newline at end of file +} diff --git a/packages/rpc-proxy/tests/fixture.ts b/packages/rpc-proxy/tests/fixture.ts index 1e7529fe7..e8e1d6e68 100644 --- a/packages/rpc-proxy/tests/fixture.ts +++ b/packages/rpc-proxy/tests/fixture.ts @@ -20,9 +20,9 @@ const correctConfigurationFilePathFixture = [ ), path.join( _configFilesDirectory, - 'correct-proxy-config-delegator-private-key.json' + 'correct-proxy-config-gas-payer-private-key.json' ), - path.join(_configFilesDirectory, 'correct-proxy-config-delegator-url.json') + path.join(_configFilesDirectory, 'correct-proxy-config-gas-payer-url.json') ]; /** @@ -84,15 +84,15 @@ const invalidParametersConfigurationFilePathFixture = { 'invalid-delegator': [ path.join( _configFilesDirectory, - 'invalid-delegator-proxy-config-1.json' + 'invalid-gas-payer-proxy-config-1.json' ), path.join( _configFilesDirectory, - 'invalid-delegator-proxy-config-2.json' + 'invalid-gas-payer-proxy-config-2.json' ), path.join( _configFilesDirectory, - 'invalid-delegator-proxy-config-3.json' + 'invalid-gas-payer-proxy-config-3.json' ) ], 'invalid-verbose': [ 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 92e8bbfe8..b7deb479a 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 @@ -151,9 +151,9 @@ describe('Args options tests', () => { }); /** - * Should be able to parse the delegator private key option + * Should be able to parse the gasPayer private key option */ - test('Should be able to parse the delegator private key option', () => { + test('Should be able to parse the gasPayer private key option', () => { [ // Normal syntax [ @@ -183,9 +183,9 @@ describe('Args options tests', () => { }); /** - * Should be able to parse the delegator URL option + * Should be able to parse the gasPayer URL option */ - test('Should be able to parse the delegator URL option', () => { + test('Should be able to parse the gasPayer URL option', () => { [ // Normal syntax ['path', 'program', '--delegatorUrl', '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 86caf8ff2..66c66ae5a 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 @@ -4,11 +4,11 @@ import { getOptionsFromCommandLine, parseAndGetFinalConfig } from '../../../src/utils'; -import { correctConfigurationFilePathFixture } from '../../fixture'; import { InvalidCommandLineArguments, InvalidConfigurationFilePath } from '@vechain/sdk-errors'; +import { correctConfigurationFilePathFixture } from '../../fixture'; /** * Args options tests @@ -641,7 +641,7 @@ describe('Args parser tests', () => { // Short syntax ['path', 'program', '-du', ''], - // Enable delegation without the delegator + // Enable delegation without the gasPayer // Normal syntax ['path', 'program', '--enableDelegation'] 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 ac446ae3c..88734ce35 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 @@ -28,6 +28,7 @@ describe('Configuration file validator', () => { */ test('Should be able to parse valid configuration files', () => { correctConfigurationFilePathFixture.forEach((filePath) => { + console.log(filePath); expect(() => { checkValidConfigurationFile(filePath); }).not.toThrow(); @@ -118,15 +119,16 @@ describe('Configuration file validator', () => { }); /** - * Should not be able to parse a configuration file with invalid delegator + * Should not be able to parse a configuration file with invalid gasPayer */ - test('Should not be able to parse a configuration file with invalid delegator', () => { + test('Should not be able to parse a configuration file with invalid gasPayer', () => { invalidParametersConfigurationFilePathFixture[ 'invalid-delegator' ].forEach((filePath) => { + console.log(filePath); expect(() => { checkValidConfigurationFile(filePath); - }).toThrow(InvalidConfigurationFile); + }).toThrow(); }); });