enhancement: add address validation, shortening, and token amount formatting utilities - #80
Open
D2758695161 wants to merge 3 commits into
Open
enhancement: add address validation, shortening, and token amount formatting utilities#80D2758695161 wants to merge 3 commits into
D2758695161 wants to merge 3 commits into
Conversation
added 3 commits
March 29, 2026 14:22
…tisig signer Bug fixes: 1. HRC20.burn() and HRC20.burnFrom() parameters were typed as 'number' but should accept BNish (BN|string|bigint|Arrayish) per the README docs. Added Promise<Transaction> return types. 2. BridgeToken constructor always set hmyMasterWallet signer to MAINNET_MULTISIG_WALLET regardless of network. Fixed to use DEVNET_MULTISIG_WALLET for devnet.
1. README.md: Fix 'lastest' typo -> 'latest' (3 instances) 2. README.md: Fix HRC721/HRC1155 naming -> HRC-721/HRC-1155 (proper standard naming) 3. README.md: Fix outdated explorer.ps.hmny.io -> explorer.harmony.one 4. CONTRIBUTING.md: Fix 'tslint' -> 'ESLint' (project uses ESLint, not deprecated TSLint)
…, and token amount formatting Added three new utility functions to src/utils.ts: - isValidHarmonyAddress(address): validates 'one1...' format addresses - shortenAddress(address, prefixLength?, suffixLength?): shortens addresses for display - parseTokenAmount(amount, decimals?): converts human-readable amounts to wei units - formatTokenAmount(amount, decimals?, displayDecimals?): converts wei units to human-readable amounts These are commonly needed utilities when working with HRC20/HRC721/HRC1155 tokens.
Author
|
Following up on PR #80 — adds address validation utilities and token amount formatting. Clean implementation, ready to merge. Happy to adjust if needed! 🦀 |
Author
|
👋 Hi! Just bumping this PR. All ready for merge - let me know if you need any changes! 🦞 |
Author
Description
Added four commonly-needed utility functions to
src/utils.tsfor working with Harmony blockchain addresses and token amounts.New Utilities
1.
isValidHarmonyAddress(address)Validates if a string is a properly formatted Harmony ONE address (starts with 'one1' and is 42 characters total).
2.
shortenAddress(address, prefixLength?, suffixLength?)Shortens a Harmony address for display in UIs.
3.
parseTokenAmount(amount, decimals?)Converts a human-readable token amount to the smallest unit (wei/gwei).
4.
formatTokenAmount(amount, decimals?, displayDecimals?)Converts from the smallest unit back to a human-readable string.
These utilities solve common developer pain points when building on Harmony:
All functions are exported automatically via
export * from './utils'in the main index.Bounty claim: This PR adds useful enhancements to the Harmony Marketplace SDK as part of the Encode Hackathon Enhancement Bounty (harmony-one/bounties#124).
Payment address for bounty: 0xaae0101ac77a2e4e0ea826eb4d309374f029b0a6