Skip to content

[Beginner]: Add operator== to TokenTransfer #1298

@rwalworth

Description

@rwalworth

🐥 Beginner Friendly

This issue is a great fit for contributors who are ready to explore the Hiero C++ codebase a little more and take on slightly more independent work.

Beginner Issues often involve reading existing C++ code, understanding how different parts of the SDK fit together, and making small, thoughtful updates that follow established patterns.

The goal is to support skill growth while keeping the experience approachable, well-scoped, and enjoyable.


👾 Description of the Issue

The TokenTransfer class is missing an operator== implementation.

Relevant files:

src/sdk/main/include/TokenTransfer.h
src/sdk/main/src/TokenTransfer.cc

Without operator==, callers must compare transfer objects field-by-field. Other SDK value types (e.g. TokenId, AccountId, PendingAirdropId) already implement operator== as a pattern — TokenTransfer should follow suit.


💡 Proposed Solution

Add operator== to TokenTransfer following the same pattern used by PendingAirdropId (a recently added, clean example):

  • Declare a [[nodiscard]] friend bool operator==(const TokenTransfer&, const TokenTransfer&) in the header
  • Implement it in TokenTransfer.cc, comparing all meaningful member fields:
    • mTokenId, mAccountId, mAmount, mExpectedDecimals, mIsApproval
  • Add or extend the unit test file in src/sdk/tests/unit/TokenTransferTest.cc

The change should not affect any existing behavior or public API.


👩‍💻 Implementation Steps

  • Read src/sdk/main/include/PendingAirdropId.h and src/sdk/main/src/PendingAirdropId.cc to understand the pattern
  • Open src/sdk/main/include/TokenTransfer.h and add the friend declaration inside the class body
  • Open src/sdk/main/src/TokenTransfer.cc and implement operator== comparing all five member fields
  • Open src/sdk/tests/unit/TokenTransferTest.cc and add equality tests:
    • Two default-constructed instances are equal
    • Two identically-constructed instances are equal
    • Instances differing in each field are not equal
  • Build the SDK and confirm all tests pass

✅ Acceptance Criteria

  • Scope: Changes are limited to TokenTransfer.h, TokenTransfer.cc, and its unit test
  • Behavior: No other SDK behavior or API changes
  • Tests: Existing and new equality tests pass
  • Review: All code review feedback addressed

📋 Step-by-Step Contribution Guide

  • Comment /assign to request the issue
  • Wait for assignment
  • Fork the repository and create a branch
  • Set up the project using the instructions in README.md
  • Make the requested changes
  • Sign each commit using -s -S
  • Push your branch and open a pull request

Read Workflow Guide for step-by-step workflow guidance. Read README.md for setup instructions.

❗ Pull requests cannot be merged without S and s signed commits. See the Signing Guide.


🤔 Additional Information

Reference implementation to follow:

  • src/sdk/main/include/PendingAirdropId.h
  • src/sdk/main/src/PendingAirdropId.cc

If you have questions while working on this issue, feel free to ask! Hiero-SDK-C++ Discord

Metadata

Metadata

Assignees

Labels

priority: lowNon-urgent tasks, nice-to-have improvements, or minor issuesscope: apiRelated to the public SDK API surfaceskill: beginnerSuitable for contributors who have completed a good first issue and want to build skillsstatus: in progressSomeone is actively working on this issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions