Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export get_nftoken_id and parse_nftoken_id, better error handling #646

Merged
merged 10 commits into from
Oct 5, 2023

Conversation

mvadari
Copy link
Collaborator

@mvadari mvadari commented Sep 21, 2023

High Level Overview of Change

This PR:

  • Exports get_nftoken_id and parse_nftoken_id at the xrpl.utils level
  • Adds better error handling to get_nftoken_id if a metadata for an unrelated transaction is accidentally passed in

Context of Change

Noticed while working on #417

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Did you update CHANGELOG.md?

  • Yes

Test Plan

Added a test.

@@ -97,6 +97,9 @@ def has_nftoken_page(node: Node) -> bool:

affected_nodes = [node for node in meta["AffectedNodes"] if has_nftoken_page(node)]

if len(affected_nodes) == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it typical to throw a exception and not just return None. This would be a normal occurance in cases where there is a tec code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it'd be more difficult to identify a bug if it returns None instead of erroring.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with Mayukha's approach of throwing an error because it indicates invalid user input; this justifies throwing an error. We should probably make it consistent with JS to throw an error too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, it's also valid to have a failed transaction and not throw an error. So now I'm leaning more towards not throwing an error and keeping things consistent 😄

@ckniffen ckniffen merged commit 61ff43a into master Oct 5, 2023
17 checks passed
@ckniffen ckniffen deleted the fix-get-nftokenid branch October 5, 2023 00:40
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.

None yet

3 participants