Skip to content

fix: NFTs were not being properly processed#219

Merged
andreabadesso merged 10 commits intomasterfrom
fix/nft-processing
Mar 18, 2025
Merged

fix: NFTs were not being properly processed#219
andreabadesso merged 10 commits intomasterfrom
fix/nft-processing

Conversation

@andreabadesso
Copy link
Copy Markdown
Collaborator

@andreabadesso andreabadesso commented Mar 11, 2025

Motivation

There was a bug in the NFT handler invocation logic. The shouldInvokeNftHandlerForTx method was failing for valid NFT transactions because the event data from the full node contained null values in the decoded field for some outputs. When the output data wasn't properly transformed to handle these null values (replacing them with empty objects {}), the NFT detection would fail silently, causing NFTs to not be properly processed.

Acceptance Criteria

  • Fix the bug where NFT transactions with null decoded fields aren't properly detected
  • Ensure proper transformation of transaction data from full node events
  • Extract the transformation and invocation logic into a reusable method
  • Add comprehensive tests with real production data that includes a valid NFT transaction
  • Verify that NFT detection works correctly with the transformed data

Checklist

[X] If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged
[X] Make sure either the unit tests and/or the QA tests are capable of testing the new features
[X] 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.

@andreabadesso andreabadesso self-assigned this Mar 11, 2025
@andreabadesso andreabadesso added the bug Something isn't working label Mar 11, 2025
@andreabadesso andreabadesso moved this from Todo to In Progress (Done) in Hathor Network Mar 11, 2025
pedroferreira1
pedroferreira1 previously approved these changes Mar 11, 2025
Comment thread packages/common/src/utils/nft.utils.ts
@pedroferreira1 pedroferreira1 moved this from In Progress (Done) to In Review (WIP) in Hathor Network Mar 11, 2025
@andreabadesso andreabadesso requested a review from tuliomir March 11, 2025 16:39
pedroferreira1
pedroferreira1 previously approved these changes Mar 11, 2025
tuliomir
tuliomir previously approved these changes Mar 17, 2025
Comment thread packages/common/src/utils/nft.utils.ts
Comment thread packages/common/src/utils/nft.utils.ts
Comment thread packages/common/__tests__/utils/nft.utils.test.ts

// Test that this transaction is detected as an NFT
expect(isNftTransactionSpy).toHaveBeenCalledTimes(0);
const shouldInvoke = NftUtils.shouldInvokeNftHandlerForTx(txFromEvent, mockNetwork as any, logger);
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.

suggestion(non-blocking): Avoid using any, as it's prohibited by many standard typescript linting rules.

Suggested change
const shouldInvoke = NftUtils.shouldInvokeNftHandlerForTx(txFromEvent, mockNetwork as any, logger);
const shouldInvoke = NftUtils.shouldInvokeNftHandlerForTx(txFromEvent, mockNetwork as unknown as Network, logger);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done, thanks!

@tuliomir tuliomir moved this from In Review (WIP) to In Review (Done) in Hathor Network Mar 17, 2025
@andreabadesso andreabadesso dismissed stale reviews from tuliomir and pedroferreira1 via 006b64a March 17, 2025 18:22
@andreabadesso andreabadesso moved this from In Review (Done) to In Progress (Done) in Hathor Network Mar 17, 2025
@github-project-automation github-project-automation Bot moved this from In Progress (Done) to In Review (WIP) in Hathor Network Mar 18, 2025
@pedroferreira1 pedroferreira1 moved this from In Review (WIP) to In Review (Done) in Hathor Network Mar 18, 2025
@andreabadesso andreabadesso merged commit 6efb09f into master Mar 18, 2025
@github-project-automation github-project-automation Bot moved this from In Review (Done) to Waiting to be deployed in Hathor Network Mar 18, 2025
@andreabadesso andreabadesso deleted the fix/nft-processing branch March 18, 2025 14:09
r4mmer added a commit that referenced this pull request Mar 18, 2025
…-lib-v1.14.1

* origin/master:
  fix: NFTs were not being properly processed (#219)
@r4mmer r4mmer mentioned this pull request Apr 1, 2025
2 tasks
@r4mmer r4mmer moved this from Waiting to be deployed to Done in Hathor Network Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants