mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
Upstream merge brings 52 commits from safe-global/safe-wallet-monorepo into the luxfi/safe-wallet@dev fork. Conflicts resolved: - yarn.lock: deleted (we are on pnpm) - apps/web/package.json: kept pnpm version + brand build scripts (build:safe / build:lux / build:hanzo) plus upstream's new generate-version.mjs step - apps/mobile/.../Signer/appKit.ts: took upstream's import pattern for shared/projectId, shared/metadata, shared/mmkvStorageAdapter Yarn sweep applied to 42 files (docs, github-actions, workflows, AGENTS, specs, codemods, scripts, READMEs). Net result: zero yarn-* command references anywhere outside node_modules. ❯ pnpm is the law in this fork. No yarn.
4.8 KiB
4.8 KiB
Quickstart: Mobile Positions Tab
Feature: 001-mobile-positions-tab
Date: 2026-01-19
Prerequisites
- Node.js 18+
- Yarn 4 (via corepack)
- Expo CLI
- iOS Simulator or Android Emulator (or physical device)
- A Safe account with DeFi positions for testing
Setup
# Clone and checkout feature branch
git checkout 001-mobile-positions-tab
# Install dependencies
pnpm install
# Start mobile development
pnpm --filter @safe-global/mobile start
Development Workflow
1. Create Shared Utilities First
# Create positions utilities in shared package
mkdir -p packages/utils/src/features/positions/utils
mkdir -p packages/utils/src/features/positions/__tests__
Files to create:
packages/utils/src/features/positions/utils/getReadablePositionType.tspackages/utils/src/features/positions/utils/calculatePositionsFiatTotal.tspackages/utils/src/features/positions/utils/calculateProtocolPercentage.tspackages/utils/src/features/positions/index.ts(exports)
2. Write Tests for Shared Utilities
# Run shared package tests
pnpm --filter @safe-global/utils test --watch
3. Create Mobile Components
# Create positions components
mkdir -p apps/mobile/src/features/Assets/components/Positions
mkdir -p apps/mobile/src/features/Assets/components/Positions/ProtocolSection
mkdir -p apps/mobile/src/features/Assets/components/Positions/PositionItem
mkdir -p apps/mobile/src/features/Assets/components/Positions/PositionsEmpty
mkdir -p apps/mobile/src/features/Assets/components/Positions/PositionsError
4. Run Mobile Tests
# Run mobile tests
pnpm --filter @safe-global/mobile test --watch
5. Test on Device/Simulator
# iOS
pnpm --filter @safe-global/mobile ios
# Android
pnpm --filter @safe-global/mobile android
Testing Positions
Finding a Safe with Positions
For testing, you need a Safe account that has positions in DeFi protocols. Options:
- Use existing test Safe - Check team documentation for test accounts
- Create positions - Deposit into protocols like Aave, Lido on testnet
- Mock data - Use MSW to mock the positions endpoint (recommended for unit tests)
Mock Data for Testing
// Example mock protocol data for tests
const mockProtocol: Protocol = {
protocol: 'aave-v3',
protocol_metadata: {
name: 'Aave V3',
icon: { url: 'https://example.com/aave.png' },
},
fiatTotal: '1500.00',
items: [
{
name: 'Main Pool',
items: [
{
balance: '100000000',
fiatBalance: '1500.00',
fiatConversion: '0.000015',
tokenInfo: {
address: '0x...',
decimals: 6,
logoUri: 'https://example.com/usdc.png',
name: 'USD Coin',
symbol: 'USDC',
type: 'ERC20',
},
fiatBalance24hChange: '0.5',
position_type: 'deposit',
},
],
},
],
}
Verification Checklist
Before marking tasks complete:
- Shared utilities have high test coverage (100% lines, 97% branches)
- Mobile components render correctly in all states (loading, loaded, error, empty)
- Pull-to-refresh works with native indicator
- Protocol sections expand/collapse
- Percentage displays correctly (uses shared
calculateProtocolPercentage+formatPercentage) - Position type labels display correctly
- Feature flag hides tab when disabled
- Web app still works after refactor to use shared utilities
- Type-check passes:
pnpm --filter @safe-global/mobile type-check - Lint passes:
pnpm --filter @safe-global/mobile lint - All tests pass:
pnpm --filter @safe-global/mobile test
Common Issues
"Positions tab not showing"
- Check feature flag is enabled for the chain
- Verify
useHasFeature(FEATURES.POSITIONS)returns true
"Data not loading"
- Check Safe has positions (not all Safes do)
- Verify network connectivity
- Check RTK Query devtools for API errors
"Percentage shows 0%"
- Verify
calculatePositionsFiatTotalreturns non-zero - Check for division by zero protection
Related Files
| Purpose | Path |
|---|---|
| Spec | specs/001-mobile-positions-tab/spec.md |
| Plan | specs/001-mobile-positions-tab/plan.md |
| Research | specs/001-mobile-positions-tab/research.md |
| Data Model | specs/001-mobile-positions-tab/data-model.md |
| Web Reference | apps/web/src/features/positions/ |
| Shared Store Types | packages/store/src/gateway/AUTO_GENERATED/positions.ts |
| Mobile Assets | apps/mobile/src/features/Assets/ |