Skip to content

[lightapi] feat: Keep NEM transfer message semantics in lightapi by exposing the original message type#2382

Merged
cryptoBeliever merged 4 commits into
devfrom
lightapi/fix-normalize-transfer-message-isplain-to-boolean
Jul 8, 2026
Merged

[lightapi] feat: Keep NEM transfer message semantics in lightapi by exposing the original message type#2382
cryptoBeliever merged 4 commits into
devfrom
lightapi/fix-normalize-transfer-message-isplain-to-boolean

Conversation

@cryptoBeliever

@cryptoBeliever cryptoBeliever commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep NEM transfer message semantics in lightapi by exposing the original message type in Message objects instead of a derived boolean.
  • Rename the transfer message field from is_plain to type in lightapi mapping (1 = plain, 2 = encrypted).
  • Update lightapi tests to validate message type mapping for plain and encrypted transfer messages.
  • Use MessageType.PLAIN instead of forwarding the raw NEM message type integer (1 / 2).

Motivation

A boolean is_plain loses message-type information and makes downstream handling brittle if new NEM message types appear in the future. Keeping the raw type in lightapi preserves protocol semantics and centralizes interpretation in Explorer/UI logic while maintaining a clear migration path for already persisted data.

Issue: #2352

@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.01%. Comparing base (84e4aea) to head (5425b82).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #2382      +/-   ##
==========================================
+ Coverage   95.38%   97.01%   +1.62%     
==========================================
  Files         631      276     -355     
  Lines       49344    21314   -28030     
  Branches     1362      206    -1156     
==========================================
- Hits        47068    20678   -26390     
+ Misses       2226      630    -1596     
+ Partials       50        6      -44     
Flag Coverage Δ
lightapi-python 98.69% <100.00%> (ø)
wallet-mobile-symbol ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ightapi/python/symbollightapi/model/Transaction.py 99.31% <100.00%> (ø)

... and 355 files with indirect coverage changes

🚀 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.

Comment thread lightapi/python/tests/model/test_Transaction.py

@AnthonyLaw AnthonyLaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍🏼

@Wayonb Wayonb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix looks fine 👍🏾
Is there a reason not to fix this on the Explorer side?
I think api is correct and should just return the information from the node. 🤔

@cryptoBeliever

cryptoBeliever commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

The fix looks fine 👍🏾 Is there a reason not to fix this on the Explorer side? I think api is correct and should just return the information from the node. 🤔

@Wayonb, there’s a fix on the Explorer side as well -> #2383

The variable in lightapi is called is_plain, so I changed it here to return a boolean as the name suggests. The alternative would be to rename it to message_type and handle the interpretation accordingly on the Explorer side. I chose to keep the original name. Ultimately, there are only two possible values in NEM anyway.

If you’d prefer lightapi to return a numeric type, I can change it (and rename the property). But if the current approach is fine, I’d leave it as it is.

@Wayonb

Wayonb commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The fix looks fine 👍🏾 Is there a reason not to fix this on the Explorer side? I think api is correct and should just return the information from the node. 🤔

@Wayonb, there’s a fix on the Explorer side as well -> #2383

The variable in lightapi is called is_plain, so I changed it here to return a boolean as the name suggests. The alternative would be to rename it to message_type and handle the interpretation accordingly on the Explorer side. I chose to keep the original name. Ultimately, there are only two possible values in NEM anyway.

If you’d prefer lightapi to return a numeric type, I can change it (and rename the property). But if the current approach is fine, I’d leave it as it is.

Yea, ideally it should return the type but I see your point its already broken. The issue is that if we ever add a new message type, this will not work, and we will need to update all downstream products.
I think the rename to message_type is a better fix. Thanks.

@cryptoBeliever cryptoBeliever force-pushed the lightapi/fix-normalize-transfer-message-isplain-to-boolean branch from ecb4755 to b080e48 Compare July 8, 2026 16:12
@cryptoBeliever cryptoBeliever requested a review from Wayonb July 8, 2026 17:48
@cryptoBeliever

Copy link
Copy Markdown
Contributor Author

@Wayonb updated 👍

@cryptoBeliever cryptoBeliever changed the title [lightapi] feat: map transfer message type to boolean is_plain [lightapi] feat: Keep NEM transfer message semantics in lightapi by exposing the original message type Jul 8, 2026

@Wayonb Wayonb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏾

Map NEM message type to a strict boolean when building transfer
Message objects. Use MessageType.PLAIN instead of persisting the raw
type integer (1/2).
Map NEM message type to a strict boolean when building transfer
Message objects. Use MessageType.PLAIN instead of persisting the raw
type integer (1/2).
Map NEM message type to a strict boolean when building transfer
Message objects. Use MessageType.PLAIN instead of persisting the raw
type integer (1/2).
…aw NEM message type

Map transfer message metadata to `Message(payload, type)` instead of a derived boolean flag, so lightapi exposes the original node message type for forward compatibility with future message variants. Update TransactionHandler and connector/model tests accordingly.
@cryptoBeliever cryptoBeliever force-pushed the lightapi/fix-normalize-transfer-message-isplain-to-boolean branch from 813f1fb to 5425b82 Compare July 8, 2026 20:25
@cryptoBeliever cryptoBeliever merged commit 51481fb into dev Jul 8, 2026
25 checks passed
@cryptoBeliever cryptoBeliever deleted the lightapi/fix-normalize-transfer-message-isplain-to-boolean branch July 8, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants