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?

Updated token creation and association logic to handle both NFT and fungible tokens. Added verification for token dissociation.

Signed-off-by: MontyPokemon <[email protected]>
…mentation

Updated freeze key generation method and enhanced freeze_token docstring for clarity.

Signed-off-by: MontyPokemon <[email protected]>
Updated the supply key generation and added detailed comments for clarity.

Signed-off-by: MontyPokemon <[email protected]>
Updated the supply key generation method and enhanced the documentation for the token minting function.

Signed-off-by: MontyPokemon <[email protected]>
Updated the freeze key generation method and enhanced the token unfreeze function documentation.

Signed-off-by: MontyPokemon <[email protected]>
@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

Signed-off-by: MontyPokemon <[email protected]>
Updated freeze_token function to include operator key and improved error handling for token transfer verification.

Signed-off-by: MontyPokemon <[email protected]>
Refactor status code handling for account freeze.

Signed-off-by: MontyPokemon <[email protected]>
Added token supply verification after minting.

Signed-off-by: MontyPokemon <[email protected]>
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.

Removed optional verification step after token dissociation.

Signed-off-by: MontyPokemon <[email protected]>
Removed unfreeze function and added verification for token freeze.

Signed-off-by: MontyPokemon <[email protected]>
Updated changelog with new features, changes, fixes, and breaking changes for version 0.1.6 and earlier.

Signed-off-by: MontyPokemon <[email protected]>
@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

Signed-off-by: MontyPokemon <[email protected]>
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

Signed-off-by: MontyPokemon <[email protected]>
# Conflicts:
#	examples/token_mint_fungible.py
Signed-off-by: MontyPokemon <[email protected]>
# Conflicts:
#	CHANGELOG.md
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

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