Skip to content

feat: show network fee for send tx, create token and create nano dialogs#144

Merged
pedroferreira1 merged 2 commits intomasterfrom
feat/snap-network-fee
Mar 9, 2026
Merged

feat: show network fee for send tx, create token and create nano dialogs#144
pedroferreira1 merged 2 commits intomasterfrom
feat/snap-network-fee

Conversation

@pedroferreira1
Copy link
Copy Markdown
Member

@pedroferreira1 pedroferreira1 commented Mar 9, 2026

Motivation

With the addition of Fee based tokens, we now have network fee for sending transactions in the network. We must show the fee for the user approval.

Acceptance Criteria

  • Show network fee for send tx, create token and create nano dialogs
image image image image image image image image

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged
  • Make sure either the unit tests and/or the QA tests are capable of testing the new features
  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

Summary by CodeRabbit

  • New Features
    • Network fees are now displayed in transaction confirmation dialogs.
    • Token creation dialog now shows fee model, network fee, and deposit amount details.
    • Amount values formatted more consistently across transaction and token UIs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 9, 2026

📝 Walkthrough

Walkthrough

A new NetworkFee component and formatHtrAmount helper are added and exported. The snap manifest shasum is updated. The NetworkFee UI is integrated into createNano, createToken (refactored to show fee model, network fee, deposit), and sendTransaction dialogs; a small helper getFeeModelLabel is added in createToken.

Changes

Cohort / File(s) Summary
Manifest Update
packages/snap/snap.manifest.json
Updated source.shasum from GSxSmcmiD0HXf+qm3n/2QBYBgd+lt/2sxRwJxNoNVlc= to zuKLrJeNvUp9ImMD6+3cJ8ShO6sN9CSWjwFrwwitSFc=.
Network Fee Component
packages/snap/src/components/NetworkFee.tsx, packages/snap/src/components/index.ts
Added NetworkFee React component and formatHtrAmount helper; re-exported both from components index.
Dialog Integrations
packages/snap/src/dialogs/createNano.tsx, packages/snap/src/dialogs/sendTransaction.tsx
Imported and rendered <NetworkFee networkFee={...} /> in createNano and sendTransaction dialogs (showDivider used in sendTransaction).
Fee Display Enhancements
packages/snap/src/dialogs/createToken.tsx
Refactored createTokenPage to a block body, added getFeeModelLabel helper, precomputed values, and inserted Cards for Fee model, Network fee, and Deposit amount using formatHtrAmount.
Dependency Bump
packages/snap/package.json
Bumped @hathor/wallet-lib from 2.14.0 to 2.16.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • andreabadesso
  • raul-oliveira

Poem

🐰 I hopped in code to show the fee,
Small numbers glowing for all to see.
Cards and dividers, tidy and neat,
Network whispers make UX sweet.
Hoppy builds — a tiny treat! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main change: adding network fee display to three specific dialogs (send tx, create token, create nano).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/snap-network-fee

Comment @coderabbitai help to get the list of available commands and usage tips.

@pedroferreira1 pedroferreira1 moved this from Todo to In Progress (WIP) in Hathor Network Mar 9, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/snap/src/components/NetworkFee.tsx`:
- Around line 11-16: The helper formatHtrAmount currently treats 0n as missing
and returns '-', which hides legitimate zero fees; update formatHtrAmount so
only undefined (or null if applicable) returns '-' and 0n is formatted via
numberUtils.prettyValue and appended with
libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol (e.g., "0 SYMBOL"); locate
formatHtrAmount and adjust the conditional (remove the amount === 0n check) so
zero values render as "0 <symbol>" using the existing numberUtils.prettyValue
and symbol constant.

In `@packages/snap/src/dialogs/sendTransaction.tsx`:
- Line 125: The other dialogs are reading the wrong property for fees; in the
CreateToken dialog (component CreateToken, around where NetworkFee is rendered)
replace uses of data.networkFee with data.fee so the NetworkFee component
receives the backend-provided fee, and in the CreateNano dialog (component
CreateNano, where NetworkFee is rendered near the submit/summary) do the same
replacement of data.networkFee -> data.fee to prevent the fallback "-" from
showing; update any related prop names or typings if needed to match the fee
field.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2235400-2dbb-4f55-96b9-d473ec3dc11e

📥 Commits

Reviewing files that changed from the base of the PR and between a124fa5 and 1329b0c.

📒 Files selected for processing (6)
  • packages/snap/snap.manifest.json
  • packages/snap/src/components/NetworkFee.tsx
  • packages/snap/src/components/index.ts
  • packages/snap/src/dialogs/createNano.tsx
  • packages/snap/src/dialogs/createToken.tsx
  • packages/snap/src/dialogs/sendTransaction.tsx

Comment on lines +11 to +16
export const formatHtrAmount = (amount?: bigint): string => {
if (amount === undefined || amount === 0n) {
return '-';
}
return `${numberUtils.prettyValue(amount)} ${libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol}`;
}
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Mar 9, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Render zero fees as 0, not -.

0n is still a real amount. Treating it as missing data makes zero-fee or zero-deposit confirmations ambiguous in every dialog that reuses this helper.

🛠 Proposed fix
 export const formatHtrAmount = (amount?: bigint): string => {
-  if (amount === undefined || amount === 0n) {
+  if (amount === undefined) {
     return '-';
   }
   return `${numberUtils.prettyValue(amount)} ${libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol}`;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const formatHtrAmount = (amount?: bigint): string => {
if (amount === undefined || amount === 0n) {
return '-';
}
return `${numberUtils.prettyValue(amount)} ${libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol}`;
}
export const formatHtrAmount = (amount?: bigint): string => {
if (amount === undefined) {
return '-';
}
return `${numberUtils.prettyValue(amount)} ${libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol}`;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/snap/src/components/NetworkFee.tsx` around lines 11 - 16, The helper
formatHtrAmount currently treats 0n as missing and returns '-', which hides
legitimate zero fees; update formatHtrAmount so only undefined (or null if
applicable) returns '-' and 0n is formatted via numberUtils.prettyValue and
appended with libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol (e.g., "0
SYMBOL"); locate formatHtrAmount and adjust the conditional (remove the amount
=== 0n check) so zero values render as "0 <symbol>" using the existing
numberUtils.prettyValue and symbol constant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pedroferreira1 I was about to make the same comment as the rabbit: shouldn't we hide the "Network fee" entirely when it is zero? Or maybe show explicitly zero instead of -?

Not a blocking comment, as this was probably discussed in a design somewhere before, but it feels weird to me as it is now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As we discussed, this is the UI defined for the screen on figma. I actually liked it, to be honest

<Divider />
{renderOutputs(params.outputs, data.tokenDetails)}
{renderChangeAddress(params.changeAddress)}
<NetworkFee networkFee={data.fee} showDivider />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Dialog consumers:"
rg -n -C2 '\bdata\.(fee|networkFee|depositAmount)\b' packages/snap/src/dialogs

echo
echo "Potential producers / assignments:"
rg -n -C3 '\b(networkFee|fee|depositAmount)\s*:' packages -g '!**/dist/**' -g '!**/node_modules/**'

Repository: HathorNetwork/hathor-rpc-lib

Length of output: 21306


🏁 Script executed:

# Find type definitions for different prompt types
rg -n 'CreateTokenConfirmationPrompt|SendNanoContractTxConfirmationPrompt|SendTransactionConfirmationPrompt' packages/hathor-rpc-handler/src/types --type ts

# Look for where networkFee and depositAmount are assigned
rg -n -B3 -A3 'networkFee\s*=' packages/hathor-rpc-handler/src -g '!**/*test.ts'

# Check if there's a field mapping or transform in the handler files
rg -n 'depositAmount|networkFee' packages/hathor-rpc-handler/src/rpcMethods -g '!**/*test.ts'

Repository: HathorNetwork/hathor-rpc-lib

Length of output: 1303


🏁 Script executed:

# Read the type definitions to see what fields they have
sed -n '223,250p' packages/hathor-rpc-handler/src/types/prompt.ts
sed -n '228,250p' packages/hathor-rpc-handler/src/types/prompt.ts  
sed -n '312,330p' packages/hathor-rpc-handler/src/types/prompt.ts

Repository: HathorNetwork/hathor-rpc-lib

Length of output: 2146


🏁 Script executed:

# Find CreateTokenParams and NanoContractParams definitions
rg -n 'type CreateTokenParams|interface CreateTokenParams' packages/hathor-rpc-handler/src/types -A15

rg -n 'type NanoContractParams|interface NanoContractParams' packages/hathor-rpc-handler/src/types -A15

Repository: HathorNetwork/hathor-rpc-lib

Length of output: 2608


This dialog is correct; the bugs are in the other dialogs.

sendTransaction.tsx correctly reads data.fee matching the actual type definition. The issues are in packages/snap/src/dialogs/createToken.tsx (lines 44-45) and packages/snap/src/dialogs/createNano.tsx (line 190), which incorrectly read data.networkFee when the backend provides fee. Both dialogs will display - (fallback value) instead of the actual fee.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/snap/src/dialogs/sendTransaction.tsx` at line 125, The other dialogs
are reading the wrong property for fees; in the CreateToken dialog (component
CreateToken, around where NetworkFee is rendered) replace uses of
data.networkFee with data.fee so the NetworkFee component receives the
backend-provided fee, and in the CreateNano dialog (component CreateNano, where
NetworkFee is rendered near the submit/summary) do the same replacement of
data.networkFee -> data.fee to prevent the fallback "-" from showing; update any
related prop names or typings if needed to match the fee field.

@pedroferreira1 pedroferreira1 force-pushed the feat/snap-network-fee branch from 1329b0c to a0399a7 Compare March 9, 2026 20:53
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/snap/src/dialogs/createToken.tsx (1)

62-65: Confirm intentional formatting difference for "Amount" vs fee fields.

The "Network fee" and "Deposit amount" cards use formatHtrAmount() which appends the HTR symbol, while the "Amount" card uses numberUtils.prettyValue(amount) without a symbol. This is likely intentional since "Amount" refers to the quantity of the new token being created (not HTR), but verify this matches the desired UX for clarity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/snap/src/dialogs/createToken.tsx` around lines 62 - 65, Verify
whether the "Amount" card should display a unit/symbol like the HTR fields:
inspect the Card usages for networkFee/depositAmount (which call
formatHtrAmount) and the "Amount" field (which uses
numberUtils.prettyValue(amount)); if the intent is to show the new token
quantity without HTR, make the UX explicit by either appending the token symbol
to the description (e.g., prettyValue(amount) + " TOKEN_SYMBOL") or changing the
title to "Amount (tokens)"; otherwise document the intentional difference and
keep numberUtils.prettyValue(amount) as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/snap/src/dialogs/createToken.tsx`:
- Around line 62-65: Verify whether the "Amount" card should display a
unit/symbol like the HTR fields: inspect the Card usages for
networkFee/depositAmount (which call formatHtrAmount) and the "Amount" field
(which uses numberUtils.prettyValue(amount)); if the intent is to show the new
token quantity without HTR, make the UX explicit by either appending the token
symbol to the description (e.g., prettyValue(amount) + " TOKEN_SYMBOL") or
changing the title to "Amount (tokens)"; otherwise document the intentional
difference and keep numberUtils.prettyValue(amount) as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9f3f669f-2f92-424b-89e6-5e352a2722a7

📥 Commits

Reviewing files that changed from the base of the PR and between 1329b0c and a0399a7.

📒 Files selected for processing (6)
  • packages/snap/snap.manifest.json
  • packages/snap/src/components/NetworkFee.tsx
  • packages/snap/src/components/index.ts
  • packages/snap/src/dialogs/createNano.tsx
  • packages/snap/src/dialogs/createToken.tsx
  • packages/snap/src/dialogs/sendTransaction.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/snap/src/dialogs/sendTransaction.tsx
  • packages/snap/src/components/NetworkFee.tsx
  • packages/snap/snap.manifest.json
  • packages/snap/src/dialogs/createNano.tsx

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/snap/src/dialogs/createToken.tsx`:
- Around line 28-35: The helper getFeeModelLabel currently treats any unknown
version as 'Deposit Token'; update it so only undefined maps to 'Deposit Token'
and any other unknown string is surfaced explicitly (e.g., return 'Unsupported
Token Version' or throw an error) instead of falling through. Locate
getFeeModelLabel and change the switch/logic to: case 'fee' -> 'Fee Token'; case
'deposit' or undefined -> 'Deposit Token'; default -> return a clear
unsupported-version marker (or throw) so unexpected params.version values are
not silently mapped.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bbd51416-247b-48be-9b0c-d4380ab167a7

📥 Commits

Reviewing files that changed from the base of the PR and between a0399a7 and 652b060.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • packages/snap/package.json
  • packages/snap/snap.manifest.json
  • packages/snap/src/dialogs/createNano.tsx
  • packages/snap/src/dialogs/createToken.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/snap/src/dialogs/createNano.tsx
  • packages/snap/snap.manifest.json

Comment thread packages/snap/src/dialogs/createToken.tsx
@pedroferreira1 pedroferreira1 requested review from tuliomir and removed request for andreabadesso March 9, 2026 21:44
Comment on lines +11 to +16
export const formatHtrAmount = (amount?: bigint): string => {
if (amount === undefined || amount === 0n) {
return '-';
}
return `${numberUtils.prettyValue(amount)} ${libConstants.DEFAULT_NATIVE_TOKEN_CONFIG.symbol}`;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pedroferreira1 I was about to make the same comment as the rabbit: shouldn't we hide the "Network fee" entirely when it is zero? Or maybe show explicitly zero instead of -?

Not a blocking comment, as this was probably discussed in a design somewhere before, but it feels weird to me as it is now.

@github-project-automation github-project-automation bot moved this from In Progress (WIP) to In Review (WIP) in Hathor Network Mar 9, 2026
@pedroferreira1 pedroferreira1 merged commit 405c2e9 into master Mar 9, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from In Review (WIP) to Waiting to be deployed in Hathor Network Mar 9, 2026
@pedroferreira1 pedroferreira1 deleted the feat/snap-network-fee branch March 9, 2026 22:40
@pedroferreira1 pedroferreira1 moved this from Waiting to be deployed to Done in Hathor Network Mar 10, 2026
@pedroferreira1 pedroferreira1 moved this from Done to Waiting to be deployed in Hathor Network Mar 10, 2026
@pedroferreira1 pedroferreira1 moved this from Waiting to be deployed to Done in Hathor Network Mar 10, 2026
@pedroferreira1 pedroferreira1 moved this from Done to Waiting to be deployed in Hathor Network Mar 10, 2026
@pedroferreira1 pedroferreira1 moved this from Waiting to be deployed to Done in Hathor Network Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants