Wallet, token and DeFi patterns, built from hyuskui components. Each is a GPUI view you copy into your project.
Wallet connection, addresses, token amounts, swaps, transaction status, signing requests and DeFi positions: the pieces an onchain app's interface is made of. There is no hyuskui crate to depend on. A pattern is a single Rust file that composes components such as Dialog, Form and Data Table, so you own every line.
UI only
These are presentational, controlled views. They never hold a key, sign, or call an RPC node. The host app connects the wallet, reads balances and quotes, and sends transactions; the pattern shows what it is given and calls your handlers when the user clicks Connect, Approve, Swap or Sign. Every demo runs on sample data with obviously fake addresses such as 0x0000…11cE. Tokens use generic symbols such as ETH and USDC with their real decimals; there are no real addresses, chains or protocols.
Amounts and addresses
Mistakes here cost money, so the patterns share one small module, Onchain, with no floating point in it:
- Amounts are
u128counts of base units.parse_unitsrejects more decimals than the token has instead of rounding, and display formatting rounds down so a balance never looks larger than it is. Max fills the exact balance.u128is smaller than Solidity'suint256; values that don't fit are errors, never wrapped. - Addresses are EIP-55 checksummed. A mixed-case address with a wrong checksum is rejected as a likely typo.
0x1234…abcdis for display only: copy, compare and send the full address. - Rates, slippage, price impact, vault shares and health factors are integer math in basis points.
Patterns
Full pages built from these patterns, a swap page, a portfolio dashboard and a staking page, are on the Crypto blocks tab.
Installation
Add the components
Each pattern lists the components it uses. Most build on Onchain, Button and Card:
$ cargo hyuskui add onchain button cardAdd the crates
Onchain hashes addresses with Keccak-256. The CLI copies files only, so add the crate yourself:
$ cargo add sha3@0.10Copy a pattern
Open a pattern, copy its code into your project, for example
src/crypto/swap_card.rs, and render the view like any other. Replace the sample data with what your wallet and RPC layer report, and callcx.notify()when it changes.// src/main.rs mod crypto { pub mod swap_card; }