Skip to content

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
Copy Markdown
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
Copy Markdown

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
@github-project-automation github-project-automation bot moved this from In Progress (WIP) to In Review (WIP) in Hathor Network Nov 6, 2025
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from ab8cdcf to a9d458a Compare November 11, 2025 17:07
@raul-oliveira raul-oliveira requested a review from r4mmer November 12, 2025 02:36
@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch from 578d9ba to c23972a Compare November 27, 2025 14:29
src/types.ts Outdated
uid: string;
name: string;
symbol: string;
version: TokenVersion;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe the version should be optional for backwards compatibility.
In the event of connecting with an old fullnode/service that does not take token version into account, having it required could break something, what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How do you see the treatment of the data? For example, if we don't have the token version it could led us to a wrong calculation, and utxo selection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done in 04575c9

src/types.ts Outdated
interface IDataTokenCreationTx {
name: string;
symbol: string;
tokenVersion: TokenVersion;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should have a comment here that tokenVersion cannot be named version because it would clash with the tx version field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 37abb71

Copy link
Copy Markdown
Member

@pedroferreira1 pedroferreira1 left a comment

Choose a reason for hiding this comment

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

I believe it's also missing changes on the src/wallet/sendTransactionWalletService.ts file, similar to the src/new/sendTransaction.js.

@raul-oliveira raul-oliveira force-pushed the raul-oliveira/fee-token-creation branch 2 times, most recently from 017ff79 to 1d71b48 Compare December 3, 2025 23:13
@raul-oliveira
Copy link
Copy Markdown
Contributor Author

017ff79

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

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