hiero-ledger / hiero-ledger/hiero-sdk-cpp
[Beginner]: Add `operator==` to `TokenAllowance`
- Dominant language
- C++
- Stars
- 42
- Forks
- 108
- Avg merge
- 11h 45m
- Merged PRs (30d)
- 2
Description
### 🐥 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.
> [!IMPORTANT]
> ### 🐥 About Beginner Issues
>
> Beginner Issues are a great next step for contributors who feel comfortable with the basic project workflow and want to explore the codebase a little more.
>
> These issues often involve:
> - Reading existing C++ code
> - Understanding how different parts of the SDK fit together
> - Making small, thoughtful updates that follow established patterns
>
> You'll usually see Beginner Issues focused on things like:
> - Small, well-scoped improvements to existing tests
> - Narrow updates to `src` functionality (e.g. refining helpers or improving readability)
> - Documentation or comment clarity
> - Enhancements to existing examples
>
> Other types of contributions — such as brand-new features, broader system changes, or deeper technical work — are just as valuable and may use different labels.
### 👾 Description of the Issue
The `TokenAllowance` class is missing an `operator==` implementation.
Relevant files:
```
src/sdk/main/include/TokenAllowance.h
src/sdk/main/src/TokenAllowance.cc
```
Without `operator==`, callers must compare allowance objects field-by-field. Other SDK value types (e.g. `AccountId`, `TokenId`, `PendingAirdropId`) already implement `operator==` as a pattern — `TokenAllowance` should follow suit.
### 💡 Proposed Solution
Add `operator==` to `TokenAllowance` as a `const` member function:
- Declare `[[nodiscard]] bool operator==(const TokenAllowance& rhs) const` in the header
- Implement it in `TokenAllowance.cc`, comparing all meaningful member fields:
- `mTokenId`, `mOwnerAccountId`, `mSpenderAccountId`, `mAmount`
- Add or extend the unit test file in `src/sdk/tests/unit/TokenAllowanceTest.cc`
The change should not affect any existing behavior or public API.
### 👩💻 Implementation Steps
- [ ] Open `src/sdk/main/include/TokenAllowance.h` and add the member `operator==` declaration inside the class body
- [ ] Open `src/sdk/main/src/TokenAllowance.cc` and implement `operator==` comparing all four member fields
- [ ] Open `src/sdk/tests/unit/TokenAllowanceTest.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 `TokenAllowance.h`, `TokenAllowance.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
To help keep contributions consistent and easy to review, we recommend following these steps:
- [ ] 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](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/docs/training/workflow.md) for step-by-step workflow guidance.
Read [README.md](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/README.md) for setup instructions.
❗ Pull requests **cannot be merged** without `S` and `s` signed commits.
See the [Signing Guide](https://github.com/hiero-ledger/hiero-sdk-cpp/blob/main/docs/training/signing.md).
### 🤔 Additional Information
Declare `operator==` as a `const` member function — not a `friend`. The declaration in the header is `[[nodiscard]] bool operator==(const T& rhs) const;` and the definition in the `.cc` file uses `mField` directly (not `lhs.mField`) since `this` is the left-hand side.
If you have questions while working on this issue, feel free to ask! [Hiero-SDK-C++ Discord](https://discord.com/channels/905194001349627914/1337424839761465364)
Contributor guide
Research direction
Start with src/sdk/main/include/TokenAllowance.h and src/sdk/main/src/TokenAllowance.cc, then compare equality implementations in AccountId, TokenId, or PendingAirdropId. Add or extend src/sdk/tests/unit/TokenAllowanceTest.cc with default, identical, and per-field inequality cases. Done means the scoped tests and the existing SDK test suite pass without changes outside the three named files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100