TDD: Infrastructure — Security, State, Testing, Deployment
- All wallets are **devnet-only, ephemeral, generated in-browser** via faucet
TDD: Infrastructure — Security, State, Testing, Deployment
1. Security Considerations
Wallet Key Handling
- All wallets are devnet-only, ephemeral, generated in-browser via faucet
- No private keys stored in
.envor persisted to disk - Wallet objects (seed, privateKey, address) live only in React Context state
- Page refresh = wallets lost (by design for devnet demo)
Input Validation
validateAddress(address)— regex check for XRPL r-address formatvalidateAmount(amount)— positive finite numbervalidateTicker(ticker)— 1-10 uppercase alphanumericvalidateAssetScale(scale)— integer 0-15validateTransferFee(fee)— integer 0-50000validateMetadataSize(size)— ≤1024 bytes
XSS Prevention
- React's built-in JSX escaping handles output encoding
- No
dangerouslySetInnerHTMLused anywhere - All user inputs are typed (number fields, controlled inputs)
2. Error Handling
Error Classes
XRPLConnectionError— network connectivity failuresTransactionError— XRPL transaction result codes (tec*, tem*, tef*)ValidationError— input validation failures with optional field name
XRPL Error Code Mapping
Human-readable messages for common codes:
tecUNFUNDED→ "Account does not have enough XRP..."tecNO_AUTH→ "Holder is not authorized..."tecFROZEN→ "This token is currently frozen/locked..."tefPAST_SEQ→ "Transaction sequence is in the past..."temDISABLED→ "This feature is not enabled..."
Transaction Status Pattern
Every transaction goes through: idle → submitting → success | error
useTransaction()hook manages this lifecycleTransactionStatuscomponent renders appropriate feedbackexecute(fn, message)wraps any async tx function
3. State Management Architecture
XRPLProvider (connection + client)
└── WalletProvider (issuer, protocol, shareholders)
└── TokenProvider (mptIssuanceId, metadata, holders)
└── App pages
- Contexts are nested in dependency order
- Each context exports both Provider component and accessor hook
- Hooks throw if used outside their provider
4. Environment Configuration
.env.local
NEXT_PUBLIC_XRPL_WSS=wss://s.devnet.rippletest.net:51233
NEXT_PUBLIC_XRPL_FAUCET=https://faucet.devnet.rippletest.net/accounts
NEXT_PUBLIC_NETWORK=devnet
- All values are public (NEXT_PUBLIC_ prefix) — no secrets
- Constants in
src/lib/constants.tsfor code access
5. Testing Strategy
Manual Test Script (src/test/manual-test-flow.ts)
End-to-end flow on devnet:
- Connect to devnet
- Fund 3 wallets (issuer, protocol, shareholder)
- Create MPT issuance with all flags
- Authorize + send MPTs to protocol
- Create escrow → finish escrow
- Verify shareholder holds tokens
- Test lock/unlock
- Test clawback
- Test cashflow distribution
What to Test
- Flag dependency cascading (UI logic)
- Metadata size validation (≤1024 bytes)
- Transaction error handling (simulate failures)
- Wallet generation flow
- Multi-step transaction sequences (correct ordering)
6. Performance Considerations
- Singleton client — one WebSocket connection, reused across all operations
- Sequential distributions — avoid sequence number conflicts in batch payments
- Paginated queries —
getMPTHoldersuses marker-based pagination - No polling — holders/state refreshed on-demand (button click)
7. Deployment
- Vercel-ready — standard Next.js App Router project
- No server-side secrets needed
next.config.jshandles webpack fallbacks for xrpl.js Node.js dependencies- All XRPL operations run client-side (browser)
8. Devnet Considerations
- Devnet resets periodically — all accounts and tokens are wiped
- Faucet rate limits: ~10 requests/minute per IP
- All XLS-33 and XLS-85 amendments active on devnet
- Network latency: expect 3-5 second transaction confirmation times
- Custom IOU used instead of RLUSD (not available on devnet)
9. File Inventory
Context Providers (src/context/)
XRPLContext.tsx— client connection lifecycleWalletContext.tsx— wallet generation + storageTokenContext.tsx— current token stateAppProviders.tsx— nested provider wrapper
Hooks (src/hooks/)
useXRPL.ts— access XRPL client + statususeWallet.ts— access wallet state + generatorsuseToken.ts— access token state + settersuseTransaction.ts— transaction submission state machine
Utils (src/utils/)
errors.ts— error classes + XRPL error code mappingvalidation.ts— input validation helpersformat.ts— display formatting (XRP, addresses, timestamps)
Related Documents
Design Document: BharatSeva AI
BharatSeva AI is a multi-agent orchestration system built on AWS using Amazon Bedrock Agents with Claude 3.5 Sonnet as the foundation model. The system deploys 10 AI agents (1 Master Orchestrator + 9 Specialist Agents) to assist India's informal sector workers in navigating government schemes across three domains: PM Vishwakarma (artisan credit), PMFBY (crop insurance), and BOCW (construction worker welfare).
OpenClaw Enterprise Transformation Plan
Transform OpenClaw from a single-user personal AI assistant into a **dual-mode platform** that is simultaneously:
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Daniel Sandner, for article on https://sandner.art/
Qwen3-TTS — Model Reference
Models: `Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice` and `Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice`