Skip to content

fix: native token version defaulting to DEPOSIT#1054

Merged
raul-oliveira merged 2 commits intomasterfrom
raul-oliveira/fix/native-token-version-from-storage
Apr 2, 2026
Merged

fix: native token version defaulting to DEPOSIT#1054
raul-oliveira merged 2 commits intomasterfrom
raul-oliveira/fix/native-token-version-from-storage

Conversation

@raul-oliveira
Copy link
Copy Markdown
Contributor

@raul-oliveira raul-oliveira commented Apr 1, 2026

Motivation

When the fullnode's /version endpoint returns native_token without a version field (e.g. { "name": "Hathor", "symbol": "HTR" }), getNativeTokenData() was producing an object with no version property. When this was later passed to memory_store.saveToken(), its default spread ({ version: TokenVersion.DEPOSIT, ...tokenConfig }) kicked in, incorrectly tagging HTR as DEPOSIT (1) instead of NATIVE (0).

Acceptance Criteria

  • getNativeTokenData() always returns version: TokenVersion.NATIVE when the fullnode omits the version field
  • getNativeTokenData() forwards the fullnode-provided version as-is (including unknown values like 99)
  • getNativeTokenData() falls back to DEFAULT_NATIVE_TOKEN_CONFIG when native_token is null or version is not set
  • saveNativeToken() round-trip through MemoryStore persists version: NATIVE, not DEPOSIT
  • Custom tokens still default to TokenVersion.DEPOSIT in saveToken() (no regression)

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

Summary by CodeRabbit

  • Tests

    • Expanded test coverage for native token version handling scenarios, including cases with missing, unknown, or null version values.
  • Bug Fixes

    • Ensured native tokens now explicitly include version information when retrieved from storage, with proper fallback behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 55269af1-9126-4bda-91ea-e142dde30979

📥 Commits

Reviewing files that changed from the base of the PR and between b408dd6 and 72ea6ec.

📒 Files selected for processing (2)
  • __tests__/storage/storage.test.ts
  • src/storage/storage.ts

📝 Walkthrough

Walkthrough

The changes expand native token versioning support by adding explicit version: TokenVersion.NATIVE field handling to the storage layer and its corresponding tests. Implementation ensures consistent version fields across all native token scenarios, with tests validating version handling for missing, explicit, unknown, and null cases.

Changes

Cohort / File(s) Summary
Test Expansions
__tests__/storage/storage.test.ts
Expanded native token config version behavior tests covering scenarios: no API version set, missing version field, explicit version preservation, unknown version forwarding, null handling, and post-save version validation. Added ApiVersion import.
Storage Implementation
src/storage/storage.ts
Updated getNativeTokenData() to explicitly include version: TokenVersion.NATIVE in returned token data. Added TokenVersion import from types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Suggested reviewers

  • pedroferreira1
  • tuliomir

Poem

🐰 A token's version, now held with care,
Native and versioned beyond compare,
Through storage it hops with field so true,
NATIVE it shouts in all that's new! 🎪

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the bug being fixed: native token version incorrectly defaulting to DEPOSIT instead of NATIVE.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch raul-oliveira/fix/native-token-version-from-storage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@raul-oliveira raul-oliveira self-assigned this Apr 1, 2026
@raul-oliveira raul-oliveira moved this from Todo to In Progress (Done) in Hathor Network Apr 1, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.86%. Comparing base (29d2ff2) to head (eab9acc).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1054       +/-   ##
===========================================
+ Coverage   66.53%   87.86%   +21.32%     
===========================================
  Files         114      114               
  Lines        8828     8828               
  Branches     2006     1996       -10     
===========================================
+ Hits         5874     7757     +1883     
+ Misses       2926     1043     -1883     
  Partials       28       28               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@raul-oliveira raul-oliveira requested a review from tuliomir April 2, 2026 04:03
@tuliomir tuliomir moved this from In Progress (Done) to In Review (WIP) in Hathor Network Apr 2, 2026
@raul-oliveira raul-oliveira merged commit dd2fef9 into master Apr 2, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Apr 2, 2026
raul-oliveira added a commit that referenced this pull request Apr 10, 2026
* feat: export all types and utils from public API (#1034)

* Test: Shared tests for `start` (#1032)

* Merge pull request #1046 from HathorNetwork/refact/fee-test-suite

refact: move fee test suite to the right folder

* test: add new fee template integration tests (#1048)

* refact: move fee test suite to the right folder

* review changes

* refact: keep only moved tests, remove new template tests

* test: add new fee template integration tests

* fix: native token version defaulting to deposit (#1054)

* test: Shared tests for internal wallet methods (#1047)

BREAKING CHANGE: HathorWallet.changeServer now returns
Promise<void> instead of void, matching the service
facade signature. Added changeServer to IHathorWallet.

* fix: precalculated wallet address derivation bug (#1056)

* feat: single address policy (#1038)

* feat: single address policy

* chore: improve CI integration test logs (#1049)

---------

Co-authored-by: André Abadesso <andre.abadesso@gmail.com>
Co-authored-by: Tulio Miranda <tulio.mir@gmail.com>
Co-authored-by: André Carneiro <andreluizmrcarneiro@gmail.com>
This was referenced Apr 14, 2026
@raul-oliveira raul-oliveira moved this from Waiting to be deployed to Done in Hathor Network Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants