Skip to content

Conversation

@MonaaEid
Copy link

Description:
This PR refactors the following example scripts to improve readability, modularity, and developer experience:

  • token_delete.py

  • token_dissociate.py

  • token_freeze.py

  • token_unfreeze.py

  • token_mint_fungible.py

  • token_mint_non_fungible.py

  • topic_create.py

Related issue(s):

Fixes #370

Checklist

  • Extracted reusable logic into helper functions (e.g., setup_client(), generate_supply_key(), create_new_token()).
  • Ensure that scripts still produce the same output as before.
  • Documented (Code comments)
  • Tested

@MonaaEid MonaaEid changed the title Chore/refactor token examples Chore: refactor token examples Sep 13, 2025
@MonaaEid MonaaEid changed the title Chore: refactor token examples chore: refactor token examples Sep 13, 2025
Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi, this is going great! You've mostly achieved all that was requested, would you like to add a little more detail to the key steps make it easier to understand and perhaps add some checks if useful?

@MonaaEid
Copy link
Author

@exploreriii I have done the requirements, if there is anything I should change please let me know

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Thank you for all this
Could I ask you in the final functions to add a step by step?

e.g.
def token_associate...
"""

  1. Create an account that will associate tokens
  2. Create the tokens to associate to the account
  3. Associate the tokens to the account
  4. Verify the tokens are both associated to the account

It is not necessary but will help to improve the clarity for users

Also maybe some additional checks could be useful but not necessary, mentioned above

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi. The output is looking great, thorough and easy to follow.
However, some of the code can be tidied up further see some ideas below

"""
Create two new tokens (one NFT and one fungible) for demonstration purposes.
- This example shows how to associate and dissociate both types of tokens (NFT and fungible)
Copy link
Contributor

Choose a reason for hiding this comment

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

keep this briefer please so its easier to read

E.g
This example shows how to dissociate NFT and fungible tokens from an account that already has them associated.

We demonstrate an end-to-end example that first creates the tokens, the account, associates them and finally, dissociates.

@exploreriii
Copy link
Contributor

Hi @MonaaEid just checking in on this

@MonaaEid
Copy link
Author

Hi @exploreriii I will finish this asap

@exploreriii
Copy link
Contributor

Looking great, let me know when its ready to review. Thank you

@MonaaEid
Copy link
Author

MonaaEid commented Oct 1, 2025

Good morning @exploreriii , could you please review the updates

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Hi @MonaaEid . This is generally looking really great. I've taken a first pass through these recent changes - I need to look at it in more detail tomorrow or soon.
Meanwhile I've added a couple of ideas if you think they are worth pushing forward

@exploreriii
Copy link
Contributor

please let me know when this is ready to review again

@MonaaEid
Copy link
Author

MonaaEid commented Oct 8, 2025

Hello@exploreriii , I will.
I haven't started on this updates yet but soon I will finish this.

@exploreriii
Copy link
Contributor

No problem, thanks for the update. Don't want to leave you hanging in case you were expecting a review.

@exploreriii
Copy link
Contributor

Hi @MonaaEid we have had a lot of PR's relating to examples but I have tried to keep the ones you are working on untouched. I think I created an issue on topic_create which conflits with yours, sorry.
please confirm when you are planning to finish this, else I would like to release these issues.

@MonaaEid
Copy link
Author

@exploreriii could you please review?

@MonaaEid MonaaEid marked this pull request as ready for review October 24, 2025 16:34
@exploreriii
Copy link
Contributor

Yes, thank you! If any other issue interest you in the meantime, please feel free to take it on while I finish reviewing this

@exploreriii exploreriii self-requested a review October 25, 2025 23:19
"""Generate a new supply key for the token."""
print("\nSTEP 1: Generating a new supply key...")
supply_key = PrivateKey.generate("ed25519")
supply_key = PrivateKey.generate_ed25519()
Copy link
Contributor

Choose a reason for hiding this comment

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

could be nice if we'd have generate() and then in there an env var either setting it to ED25519 or ECDSA

Copy link
Author

Choose a reason for hiding this comment

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

Is this ok?

 supply_key = PrivateKey.generate(os.getenv('HSDK_KEY_TYPE', 'ed25519'))

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, just maybe just KEY_TYPE. but else perfect:)

Copy link
Contributor

Choose a reason for hiding this comment

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

would be great if we could implement this across the board

exploreriii
exploreriii previously approved these changes Oct 27, 2025
Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

@MonaaEid thank you SO MUCH for this!
I see you added queries to verify, plus improved the existing scripts quite a bit

Please rebase then let's follow up with Nadine to see any final changes

@exploreriii
Copy link
Contributor

I'm just noting the solo checks didn't run. Hopefully they re-trigger on rebasing

@exploreriii
Copy link
Contributor

Need you to rebase, your changelog and examples/topic_create.py have conflicts.
This suggests your main is not up to date.

try
git checkout main
git fetch upstream
git pull upstream main
git checkout your-branch
git rebase main -S

then read merge_conflicts.md!

@exploreriii
Copy link
Contributor

I'm not familiar on the key generation issues, but did see other sdks start to recommend to not use ed25519

Copy link
Contributor

@exploreriii exploreriii left a comment

Choose a reason for hiding this comment

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

Sorry @MonaaEid you have two commits (near the start) that are not marked as verified, see the commits tab please.
You can pick at these commits and edit to sign them
else you can try to soft revert and re-sign

@nadineloepfe
Copy link
Contributor

@MonaaEid : Hi there, are you still working on this issue? If so, do you require help with the signing of commits? Thanks

@MonaaEid
Copy link
Author

MonaaEid commented Nov 6, 2025

@nadineloepfe, I am working on it right now. and I need to know what to do. could you please help?

@exploreriii
Copy link
Contributor

exploreriii commented Nov 6, 2025

This will involve picking at those specific commits and then rebasing, which is quite difficult, also because you have a lot of merges from main
git rebase -S -i HEAD~40

you'll see
pick a1b2c3d First commit message
pick d4e5f6g Second commit message

find the commit hash of your unsigned commits
d1dc519
6de8df4

Change each pick to edit for the commits you want to sign:
This is VIM so you need to first press to edit : i
:q to exit
this will prompt a rebase, so then you do:
git commit --amend -S -s
git rebase --continue
this will be hard because you'll now have to resolve many conflicts (which is why the other method may be easier at first)
git push --force-with-lease

You can alos soft revert your 40 commits, then re commit (in fewer commits) and sign appropriately: git reset soft--HEAD ~40, git commit -s -S -M "....."

You'll also need to rebase.
git checkout main
git fetch upstream
git pull upstream main
git checkout chore/refactor-token-examples
git rebase main -S
git push --force [ONCE YOU ARE HAPPY WITH EVERYTHING]

useful:
git rebase --abort
git reset --hard upstream/chore/refactor-token-examples <- carefully, only if you need to reset back to what you have here

Get in touch via discord.md and i can help you if you want

@exploreriii
Copy link
Contributor

Hi @MonaaEid would you like me to do the final steps for you?

@MonaaEid
Copy link
Author

MonaaEid commented Nov 7, 2025

Hi @MonaaEid would you like me to do the final steps for you?

It would be nice. thank you.
I have some issues I will solve before making a new PR

@MonaaEid MonaaEid force-pushed the chore/refactor-token-examples branch from 8685cd0 to c53f383 Compare November 7, 2025 18:17
@exploreriii
Copy link
Contributor

Hi @MonaaEid I'll be releasing a new python sdk release soon -
if this PR is not done in time that's no problem, but note you will need to change your changelog entry and put it under a new unreleased section.
Thank you
As you already have conflicts, its easier to start fresh and copy in your changes - else persist and you'll learn many skills!

@MonaaEid MonaaEid force-pushed the chore/refactor-token-examples branch 5 times, most recently from 2473279 to 7ebfad1 Compare November 8, 2025 14:53
@MonaaEid MonaaEid closed this Nov 8, 2025
@MonaaEid MonaaEid force-pushed the chore/refactor-token-examples branch from 7ebfad1 to 478cd57 Compare November 8, 2025 14:54
@MonaaEid MonaaEid reopened this Nov 8, 2025
@MonaaEid MonaaEid force-pushed the chore/refactor-token-examples branch from b0b0fea to 3015f47 Compare November 8, 2025 22:50
@MonaaEid MonaaEid closed this Nov 8, 2025
@MonaaEid MonaaEid force-pushed the chore/refactor-token-examples branch from 3015f47 to 89b1391 Compare November 8, 2025 23:26
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