toto-wallet-system
v1.0.2
Published
Stellar-based wallet management system for Toto platform
Maintainers
Readme
Toto Wallet System
A standalone, reusable Stellar wallet management system for the Toto platform. This non-custodial wallet module provides secure client-side wallet creation, management, fiat on-ramping via MoonPay, and donation capabilities.
Project Status
🎉 COMPLETE 🎉
All features have been implemented, and all tests are passing successfully. The project includes comprehensive test coverage with 46 passing tests across 9 test suites covering all components, hooks, context providers, and utility functions.
Features
- ✅ Non-custodial Stellar wallet creation and management
- ✅ XLM balance checking
- ✅ Direct XLM donations with memo support
- ✅ MoonPay integration for fiat on-ramping
- ✅ Transaction history tracking
- ✅ React hooks for easy integration
Installation
# With npm
npm install @toto/wallet-system
# With yarn
yarn add @toto/wallet-systemPublishing
For project maintainers, to publish a new version:
- Use the release scripts to bump the version and update the changelog:
# For a patch release (bugfixes)
npm run release:patch
# For a minor release (new features, backward compatible)
npm run release:minor
# For a major release (breaking changes)
npm run release:majorFollow the prompts and instructions after running the release script
Create a new release on GitHub to trigger the automatic publishing workflow
Quick Start
import { WalletProvider, CreateWalletButton, useAccountBalance } from '@toto/wallet-system';
// Wrap your app with the provider
function App() {
return (
<WalletProvider
moonPayApiKey="your_moonpay_public_api_key"
stellarNetwork="testnet" // or 'public' for production
>
<WalletPage />
</WalletProvider>
);
}
// Use the wallet system in your components
function WalletPage() {
const { publicKey, createWallet } = useStellarWallet();
const { balance, isLoading, refetch } = useAccountBalance();
return (
<div>
<h1>Toto Wallet</h1>
{!publicKey ? (
<CreateWalletButton onWalletCreated={(pk, mnemonic) => {
console.log("Save this mnemonic securely:", mnemonic);
}}>
Create New Wallet
</CreateWalletButton>
) : (
<div>
<p>Public Key: {publicKey}</p>
<p>Balance: {isLoading ? "Loading..." : `${balance?.xlm || 0} XLM`}</p>
<button onClick={refetch}>Refresh Balance</button>
</div>
)}
</div>
);
}Documentation
See the integration guide for detailed instructions on how to use each component and hook.
Core Components
WalletProvider- Context provider for wallet functionalityCreateWalletButton- Component for creating a new walletDonationModal- Modal for submitting XLM donationsMoonPayLoader- Component for loading the MoonPay widget
Hooks
useStellarWallet- Access the wallet contextuseAccountBalance- Check account balanceuseSubmitDonation- Submit donationsuseTransactionHistory- Get transaction history
Example Apps
See the examples directory for complete usage examples.
Development
Prerequisites
- Node.js 16+
- npm or yarn
Setup
- Clone the repository
- Install dependencies:
npm installBuild
npm run buildWatch for changes during development
npm run devTesting
npm testRoadmap
See the roadmap progress for detailed implementation status.
License
This project is licensed under the UNLICENSED license - see the LICENSE file for details.
Contributing
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/my-new-feature - Submit a pull request
Test Coverage
The project includes comprehensive test coverage for hooks and components:
Hooks
useAccountBalance: Tests for checking account existence, balance retrieval, and manual refresh functionalityuseSubmitDonation: Tests for donation submission, error handling, and transaction confirmationuseTransactionHistory: Tests for automatic and manual transaction fetching, custom public key handling, and error states
Components
CreateWalletButton: Tests for rendering, custom styling, wallet creation, loading states, and error handlingDonationModal: Tests for form validation, submission handling, loading states, and error displayMoonPayLoader: Tests for URL construction, error states, development mode functionality, and transaction simulation
Running Tests
npm testTo run specific tests:
npm test -- ComponentName.test.tsxTest Environment
Tests use Jest with React Testing Library and @testing-library/react-hooks for testing custom hooks.
