Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1658 bnc - part 1 #1777

Merged
merged 7 commits into from
Jan 30, 2025
Merged

1658 bnc - part 1 #1777

merged 7 commits into from
Jan 30, 2025

Conversation

lucanicoladebiasi
Copy link
Collaborator

@lucanicoladebiasi lucanicoladebiasi commented Jan 30, 2025

Description

This PR removes the expression delegator to mean the gas-payer of delegated transactions in

  • packages/core/src/transaction
  • packages/network/src/signer/signers

The misleading delegator expression is still present in other places of the the SDK, the refactoring to correct terminology is the goal of following PRs.

Fixes # BNC

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • yarn test:examples
  • yarn test:solo
  • yarn test:unit

Test Configuration:

  • Node.js Version: v23.1.0
  • Yarn Version: 1.22.22

Summary by CodeRabbit

  • Documentation

    • Updated terminology from "delegator" to "gas-payer" across documentation and code examples.
    • Clarified fee delegation terminology in transaction and contract documentation.
    • Added comments indicating upcoming deprecation of "delegator" term.
  • Refactor

    • Renamed variables and method names to consistently use "gas-payer" terminology.
    • Updated error handling to reflect new terminology.
  • Tests

    • Updated test cases to use new "gas-payer" naming conventions.
    • Maintained existing test logic and functionality.

Copy link

coderabbitai bot commented Jan 30, 2025

Walkthrough

This pull request introduces a comprehensive terminology update across the VeChain SDK documentation and codebase, replacing the term "delegator" with "gas-payer" to provide clearer and more precise language around transaction fee delegation. The changes span multiple files in documentation and implementation, focusing on renaming variables, updating comments, and ensuring consistent terminology that better reflects the role of the account responsible for paying transaction fees.

Changes

File Change Summary
docs/contracts.md, docs/transactions.md, various example files Renamed delegatorPrivateKeygasPayerPrivateKey, delegatorAddressgasPayerAddress, and updated comments to reflect the new terminology.
packages/errors/src/... Updated error class to use gasPayerUrl instead of delegatorUrl.
packages/network/src/signer/... Renamed methods and variables from delegator to gasPayer, including updates in the VeChainPrivateKeySigner class.

Possibly related issues

Possibly related PRs

Suggested labels

Type: Enhancement, Type: Security

Suggested reviewers

  • claytonneal

Poem

In blockchain's dance of bits and bytes,
Where gas pays for transaction's flights,
"Delegator" fades, "Gas-Payer" gleams bright,
Clarity emerges, terminology takes flight! 🚀💨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6a5f9b1 and 74447ca.

📒 Files selected for processing (3)
  • docs/contracts.md (2 hunks)
  • docs/transactions.md (5 hunks)
  • packages/network/src/signer/signers/vechain-abstract-signer/vechain-abstract-signer.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/network/src/signer/signers/vechain-abstract-signer/vechain-abstract-signer.ts
  • docs/contracts.md
  • docs/transactions.md
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: rpc-proxy / test / test
  • GitHub Check: unit-integration-test / Build & Lint (latest)
  • GitHub Check: unit-integration-test / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test / Build & Lint (18)
  • GitHub Check: unit-integration-test-browser / Build & Lint (latest)
  • GitHub Check: unit-integration-test-browser / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test-browser / Build & Lint (18)
  • GitHub Check: test-apps / Install and test example apps
  • GitHub Check: install-build / Build & Lint
  • GitHub Check: Execute doc examples

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (4)
docs/examples/transactions/fee-delegation.ts (1)

64-64: LGTM: Consistent terminology update in fee delegation example

The variable renames from delegator to gas-payer are consistent and maintain the example's functionality.

Consider adding a comment explaining the role of the gas payer in fee delegation for better documentation:

 const nodeDelegate = HDKey.fromMnemonic(Mnemonic.of());
+// Generate the private key for the account that will pay for transaction fees
 const gasPayerPrivateKey = nodeDelegate.privateKey;

Also applies to: 68-68, 74-74

packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts (1)

167-167: Update remaining parameter documentation.

While the implementation has been updated, some JSDoc parameter descriptions still reference the old terminology (delegatorUrl, delegatorPrivateKey).

Consider updating the parameter documentation in the JSDoc comments to use the new terminology consistently.

Also applies to: 174-174, 182-187, 206-210, 217-222, 226-228

docs/contracts.md (1)

206-215: Enhance the deprecation notice for better clarity

While the deprecation notice is good, it could be more informative for users.

Consider expanding the deprecation notice:

-        // The term `delegator` will be deprecated soon and renamed `gasPayer`.
+        // DEPRECATED: The term `delegator` is being replaced with `gasPayer` to better reflect its role in fee payment.
+        // The `delegator` field will be removed in a future version. Please use `gasPayer` instead.
docs/transactions.md (1)

Line range hint 467-596: Consider adding a terminology transition guide

While the documentation updates are thorough, users might benefit from additional context about the terminology change.

Consider adding a note at the beginning of the fee delegation section:

> Note: Recent versions of the SDK use the term "gas-payer" instead of "delegator" to better reflect the role's responsibility in transaction fee payment. This change affects only the terminology; the underlying functionality remains the same.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 631274e and 6a5f9b1.

📒 Files selected for processing (13)
  • docs/contracts.md (2 hunks)
  • docs/examples/contracts/contract-delegation-ERC20.ts (4 hunks)
  • docs/examples/transactions/fee-delegation.ts (2 hunks)
  • docs/examples/transactions/full-flow-delegator-private-key.ts (3 hunks)
  • docs/examples/transactions/full-flow-delegator-url.ts (3 hunks)
  • docs/templates/contracts.md (1 hunks)
  • docs/transactions.md (5 hunks)
  • packages/core/tests/transaction/Transaction.unit.test.ts (16 hunks)
  • packages/errors/src/available-errors/transaction/transaction.ts (1 hunks)
  • packages/errors/tests/available-errors/transaction.unit.test.ts (2 hunks)
  • packages/network/src/signer/signers/vechain-abstract-signer/vechain-abstract-signer.ts (1 hunks)
  • packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts (4 hunks)
  • packages/network/src/thor-client/transactions/helpers/delegation-handler.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • docs/templates/contracts.md
  • packages/network/src/signer/signers/vechain-abstract-signer/vechain-abstract-signer.ts
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: rpc-proxy / test / test
  • GitHub Check: unit-integration-test / Build & Lint (latest)
  • GitHub Check: unit-integration-test-browser / Build & Lint (latest)
  • GitHub Check: unit-integration-test-browser / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test / Build & Lint (lts/*)
  • GitHub Check: unit-integration-test-browser / Build & Lint (18)
  • GitHub Check: unit-integration-test / Build & Lint (18)
  • GitHub Check: test-apps / Install and test example apps
  • GitHub Check: install-build / Build & Lint
  • GitHub Check: Execute doc examples
🔇 Additional comments (13)
docs/examples/transactions/full-flow-delegator-url.ts (1)

38-39: LGTM: Clear variable renaming

The account variable rename is clear and consistent with the new terminology.

docs/examples/transactions/full-flow-delegator-private-key.ts (2)

32-33: LGTM: Clear account type definition and renaming

The account type definition and renaming are clear and consistent with the new terminology.


123-123: LGTM: Updated assertion using new terminology

The test assertion correctly uses the new gasPayer property.

packages/errors/tests/available-errors/transaction.unit.test.ts (1)

69-69: LGTM! Consistent terminology update in test data.

The renaming from delegatorUrl to gasPayerUrl in the test parameters aligns with the broader terminology update across the SDK.

Also applies to: 87-88

packages/network/src/thor-client/transactions/helpers/delegation-handler.ts (1)

51-51: LGTM! Error property renamed for consistency.

The error object property has been updated from delegatorUrl to gasPayerUrl to maintain consistency with the new terminology.

Consider tracking remaining "delegation" terms for future updates:

✅ Verification successful

Terminology update scope extends beyond this PR

The current property rename from delegatorUrl to gasPayerUrl is correct and consistent with the immediate context. The term "delegation" is used extensively across multiple packages, including core functionality, tests, and documentation. This suggests that a complete terminology update should be handled as a separate, coordinated effort.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find remaining instances of "delegation" in file/class names
rg -l "delegation" --type ts

Length of output: 2408

packages/network/src/signer/signers/vechain-private-key-signer/vechain-private-key-signer.ts (1)

97-103: LGTM! Variable renaming is consistent.

The variable renaming from delegator to gasPayer maintains consistency with the new terminology.

Also applies to: 111-111

docs/examples/contracts/contract-delegation-ERC20.ts (2)

26-27: LGTM! Clear variable renaming with deprecation notice.

The changes are well-documented:

  1. Variable renamed from delegatorAccount to gasPayerAccount
  2. Helpful deprecation notice added to inform users about the upcoming terminology change

Also applies to: 39-42


73-73: LGTM! Consistent variable naming in test assertions.

The test assertions maintain consistency with the new terminology.

packages/core/tests/transaction/Transaction.unit.test.ts (3)

20-26: LGTM! Consistent renaming of delegator-related constants

The renaming from DelegatorPrivateKeyFix to GasPayerPrivateKeyFix and DelegatorFix to GasPayerFix aligns with the PR's objective to update terminology.


236-236: LGTM! Consistent usage of new gas-payer terminology in test cases

The test cases have been updated to use the new GasPayerFix references while maintaining the same test logic and coverage.

Also applies to: 279-279, 307-307, 424-424, 474-474


Line range hint 674-715: LGTM! Correct preservation of "delegated" transaction terminology

The test method names correctly maintain the use of "delegated" when referring to transaction types while updating role-specific terms to "gas-payer".

docs/transactions.md (2)

467-468: LGTM! Clear and consistent terminology updates in documentation

The documentation has been updated to use the new gas-payer terminology consistently, with clear variable names and comments.

Also applies to: 488-490


575-576: LGTM! Consistent terminology in URL-based delegation example

The URL-based delegation example maintains consistency with the new gas-payer terminology.

Also applies to: 594-596

Copy link

github-actions bot commented Jan 30, 2025

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 99%
98.98% (4378/4423) 97.01% (1398/1441) 98.9% (906/916)
Title Tests Skipped Failures Errors Time
core 838 0 💤 0 ❌ 0 🔥 2m 29s ⏱️
network 731 0 💤 0 ❌ 0 🔥 4m 59s ⏱️
errors 40 0 💤 0 ❌ 0 🔥 17.396s ⏱️
logging 3 0 💤 0 ❌ 0 🔥 19.374s ⏱️
hardhat-plugin 19 0 💤 0 ❌ 0 🔥 1m 2s ⏱️
aws-kms-adapter 23 0 💤 0 ❌ 0 🔥 1m 38s ⏱️
ethers-adapter 5 0 💤 0 ❌ 0 🔥 1m 19s ⏱️
rpc-proxy 37 0 💤 0 ❌ 0 🔥 1m 8s ⏱️

Copy link
Member

@claytonneal claytonneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one!

@lucanicoladebiasi lucanicoladebiasi merged commit 3eecea9 into main Jan 30, 2025
16 of 17 checks passed
@lucanicoladebiasi lucanicoladebiasi deleted the 1658-bnc branch January 30, 2025 19:51
lucanicoladebiasi added a commit that referenced this pull request Jan 30, 2025
* fix: fix BNC...

* fix: fix BNC...

* fix: fix BNC...

* fix: fix BNC...

* fix: fix BNC...

* fix: fix BNC...

(cherry picked from commit 3eecea9)
@coderabbitai coderabbitai bot mentioned this pull request Jan 31, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BNC
2 participants