Skip to content

feat: adopt Amount type across types, services, and pages (#65, #66, #67, #68) - #74

Merged
Gaubee merged 8 commits into
mainfrom
feat/amount-types
Dec 22, 2025
Merged

Gaubee merged 8 commits into
mainfrom
feat/amount-types

Conversation

@Gaubee

@Gaubee Gaubee commented Dec 22, 2025

Copy link
Copy Markdown
Contributor

Summary

Full project-wide adoption of the Amount type for type-safe monetary operations.

Changes

Type Definitions Updated:

  • AssetInfo.amount: string → Amount
  • TransactionRecord.amount/fee: string → Amount
  • StakingTransaction, StakingOverviewItem amounts: string → Amount
  • Chain adapter types (Balance, Fee, Transaction, GasPrice): bigint → Amount

Services Updated:

  • Bioforest chain adapter services (asset, chain, transaction)
  • Transaction service (mock, web)
  • Staking service mock

Hooks Updated:

  • use-assets.ts - Mock data uses Amount.fromRaw()
  • use-send.ts - Uses Amount for fee handling
  • use-transaction-history.ts - Converts API data to Amount

Pages/Components Updated:

  • send/index.tsx - Uses Amount for balance and fees
  • history/detail.tsx - Uses Amount.toNumber() for display
  • Staking forms (mint-form, burn-form) - Converts input to Amount
  • Staking components (pool-card, record-list) - Uses Amount.toNumber()
  • Token detail page - Uses Amount for mock transactions

Tests Updated:

  • All test files updated to use Amount factory methods
  • Removed references to deprecated formatAssetAmount

Breaking Changes

  • All code consuming AssetInfo.amount must now use Amount methods
  • TransactionRecord.amount and fee are now Amount objects
  • Chain adapter Balance no longer has raw, formatted, decimals - use amount.toRawString(), amount.toFormatted(), amount.decimals

Related Issues

Closes #65 (AmountInput V2 component)
Part of Epic #63

Testing

  • TypeScript compilation passes
  • Unit tests pass
  • E2E tests pass

- Update AssetInfo.amount to use Amount
- Update TransactionRecord to use Amount for amount and fee
- Update StakingTransaction, StakingOverviewItem to use Amount
- Update chain-adapter types (Balance, Fee, Transaction, GasPrice) to use Amount
- Update bioforest services to use Amount factory methods
- Update hooks (use-assets, use-send, use-transaction-history) to use Amount
- Update pages (send, history, staking forms, token detail) to use Amount
- Update transaction service (mock, web) to use Amount
- Add Amount.fromFormatted() for user input conversion
- Add Amount.toNumber() and toFormatted() for display

Production code is now fully migrated to Amount type.
Test files will be updated in a follow-up commit.

Part of Epic #63
- Update transaction-item, transaction-list tests to use Amount
- Update use-send, use-transaction-history tests to use Amount
- Update bioforest-adapter tests to use Amount
- Update asset and staking tests for Amount compatibility
- Remove references to deprecated formatAssetAmount

All tests now use Amount factory methods for mock data.
- Fix staking/index.test.tsx to use Amount factory methods
- Fix history/detail.test.tsx and index.test.tsx mock data
- Fix use-transaction-history.ts to not double-convert Amount objects
- Fix use-send.test.ts feeAmount assertion to use Amount.toFormatted()

All 122 test files pass (1425 tests)
- Create new chapter: 03-架构篇/08-Amount类型系统/
  - Complete API reference for Amount class
  - Usage examples and best practices
  - Migration guide from string/bigint
  - Serialization and Zod schema support

- Update 05-组件篇/02-通用组件/AmountDisplay.md
  - Add Amount type integration section
  - Update props to support Amount objects

- Update 04-服务篇/02-链服务/ITransactionService.md
  - Change amount/fee types from bigint to Amount
  - Add link to Amount type documentation

- Update 03-架构篇/index.md
  - Add Amount type system chapter link
- Add e2e/send-transaction.spec.ts:
  - Amount input validation tests
  - Balance validation (insufficient funds)
  - Confirm flow tests
  - Screenshot tests for send page states

- Add e2e/transaction-history.spec.ts:
  - Transaction list amount display tests
  - Transaction detail tests
  - Filter functionality tests
  - Empty state tests

These tests verify that Amount type is correctly displayed
in user-facing UI (formatted values, not raw wei/satoshi).
- Make confirm flow tests more robust
- Add logging for debugging in CI
- Update screenshots baselines
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.

创建 AmountInput V2 组件

1 participant