Skip to content

Comments

feat: fee token creation#858

Merged
raul-oliveira merged 12 commits intomasterfrom
raul-oliveira/fee-token-creation
Dec 6, 2025
Merged

feat: fee token creation#858
raul-oliveira merged 12 commits intomasterfrom
raul-oliveira/fee-token-creation

Conversation

@raul-oliveira
Copy link
Contributor

@raul-oliveira raul-oliveira commented May 5, 2025

Motivation

Hathor now supports a new token versioning system, and with it the FEE version. The fee will be charged according to the docs:

Fee cost

Fees will be proportional to the number of outputs with fee-based tokens. For instance, if there are 3 HTR outputs, 2 outputs with deposit-based tokens, and another 5 with fee-based tokens, only the latter 5 will count towards the fee.

For melting operations that don't contain any outputs, we'll count them as 1 output in the fee calculation.

This proposal suggests 0.01 HTR per output.

We accept payments with deposit based tokens in the protocol level. However, in our clients we will not. Accepting only payments with HTR.

Acceptance criteria

This PR should enable preparing a transaction taking into account the fee without affecting the current flow.

Some modifications that will be applied on merge:

  • Adds the versionprop to addCreatedTokenFromTx method.
  • Change the saveToken method in the MemoryStore to set the default token version.
  • Adds the Fee utils, containing the methods to calculate fees depending on the scope.
  • Change the CreateTokenTransaction to accept a token version.
  • Change the zod generalTokenInfoSchema in the wallet schemas to accept a nullable version, since HTR is null or undefined.
  • Updates the ITokenData, and IHistoryTx to have the token_info_version field.
  • Adds the FEE_PER_OUTPUT constant.
  • Update the DEFAULT_NATIVE_TOKEN_CONFIG with the TokenVersion.NATIVE prop.
  • Update the tests to fix any regression caused by the new model.
  • Update the mint, melt, and create token apis in both wallets (wallet.js and wallet.ts)

@raul-oliveira raul-oliveira self-assigned this May 5, 2025
@raul-oliveira raul-oliveira moved this from Todo to In Progress (WIP) in Hathor Network May 5, 2025
@raul-oliveira raul-oliveira requested a review from r4mmer May 14, 2025 16:32
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch 3 times, most recently from 4bb1331 to 3871785 Compare May 19, 2025 17:43
@raul-oliveira raul-oliveira moved this from In Progress (WIP) to In Progress (Done) in Hathor Network May 19, 2025
@raul-oliveira raul-oliveira marked this pull request as ready for review May 19, 2025 18:27
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch 2 times, most recently from 4a8175a to 03f2e6d Compare May 22, 2025 02:56
@raul-oliveira raul-oliveira moved this from In Progress (Done) to In Progress (WIP) in Hathor Network May 28, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from 03f2e6d to 1cb4f76 Compare June 2, 2025 18:14
@raul-oliveira raul-oliveira moved this from In Progress (WIP) to In Progress (Done) in Hathor Network Jun 10, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch 2 times, most recently from b37cde2 to 15f0993 Compare June 17, 2025 15:53
@codecov
Copy link

codecov bot commented Jun 17, 2025

Codecov Report

❌ Patch coverage is 88.99676% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.99%. Comparing base (155f827) to head (a4761be).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/utils/tokens.ts 84.44% 14 Missing ⚠️
src/new/sendTransaction.ts 76.36% 13 Missing ⚠️
src/utils/fee.ts 94.11% 2 Missing ⚠️
src/wallet/wallet.ts 97.89% 2 Missing ⚠️
src/errors.ts 50.00% 1 Missing ⚠️
src/models/create_token_transaction.ts 90.90% 1 Missing ⚠️
src/template/transaction/interpreter.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #858      +/-   ##
==========================================
+ Coverage   84.70%   84.99%   +0.29%     
==========================================
  Files         112      113       +1     
  Lines        8243     8389     +146     
  Branches     1791     1832      +41     
==========================================
+ Hits         6982     7130     +148     
+ Misses       1232     1230       -2     
  Partials       29       29              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@raul-oliveira raul-oliveira changed the title feat: token info version upgrade feat: fee token creation Jun 25, 2025
@raul-oliveira raul-oliveira moved this from In Progress (Done) to Todo in Hathor Network Aug 6, 2025
@raul-oliveira raul-oliveira moved this from Todo to In Progress (WIP) in Hathor Network Oct 13, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch 7 times, most recently from 31e3f45 to 797500a Compare October 22, 2025 03:09
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from 1d71b48 to 55ff9ca Compare December 3, 2025 23:19
@raul-oliveira
Copy link
Contributor Author

017ff79

as we discussed, it will be addressed in another PR.

@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from 55ff9ca to dfddf95 Compare December 3, 2025 23:27
@HathorNetwork HathorNetwork deleted a comment from Leopiarsa Dec 4, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from aa00b05 to b0a4ba0 Compare December 4, 2025 16:14
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from 60733a2 to 467ae8d Compare December 5, 2025 17:02
@raul-oliveira raul-oliveira merged commit 21ba6c1 into master Dec 6, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Dec 6, 2025
r4mmer added a commit that referenced this pull request Dec 11, 2025
…-policy

* origin/master: (31 commits)
  feat: fee token creation (#858)
  fix: checkAddressMine was crashing when called with an empty array (#977)
  feat: the nano amount field should accept 0
  Merge pull request #975 from HathorNetwork/chore/bump-v2.11.0
  feat: add nano execution logs API (#973)
  Refactor: Fullnode facade to Typescript (#972)
  Merge pull request #970 from HathorNetwork/chore/bump-v2.10.0
  fix: added missing tx proposal delete schema (#969)
  feat: add missing api calls for graphviz and nano (#967)
  Merge pull request #965 from HathorNetwork/feat/complete-token-info-object
  chore: bump package to v2.9.1 (#962)
  feat: catch and store async promise error (#960)
  chore: bump wallet lib to v2.9.0 (#958)
  tests: use core v0.67.0 docker image for the integration tests (#956)
  tests: update integration tests blueprints for the new core sdk (#954)
  fix: added a minimal accessData so methods that need storage don't crash (#955)
  feat: fee header (#951)
  feat: added read-only start (#950)
  fix: dont add metadata changed for voided txs (#948)
  test: Wallet Service infrastructure (#909)
  ...
@raul-oliveira raul-oliveira moved this from Waiting to be deployed to Done in Hathor Network Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants