Skip to content

[Beginner]: Add operator== to TokenNftTransfer #1299

@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 TokenNftTransfer class is missing an operator== implementation.

Relevant files:

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

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


💡 Proposed Solution

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

  • Declare a [[nodiscard]] friend bool operator==(const TokenNftTransfer&, const TokenNftTransfer&) in the header
  • Implement it in TokenNftTransfer.cc, comparing all meaningful member fields:
    • mNftId, mSenderAccountId, mReceiverAccountId, mIsApproval
  • Add or extend the unit test file in src/sdk/tests/unit/TokenNftTransferTest.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/TokenNftTransfer.h and add the friend declaration inside the class body
  • Open src/sdk/main/src/TokenNftTransfer.cc and implement operator== comparing all four member fields
  • Open src/sdk/tests/unit/TokenNftTransferTest.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 TokenNftTransfer.h, TokenNftTransfer.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

No one assigned

    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: ready for devThe issue is fully defined and ready for a contributor

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions