Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9c04c7f
Localization Update
Jun 12, 2025
e314200
Wallet Refactor
Jul 18, 2025
ccb89df
merged from main and fixed bugs
Jul 18, 2025
e0239e3
v5 migration
Jul 22, 2025
8e99685
Conflicts Resolved
Jul 24, 2025
970aa16
fixed conflict
Jul 25, 2025
9e2ae18
Merge pull request #241 from citizenwallet/feature/wallet_refactor
kevtechi Jul 25, 2025
adc1230
Merge branch 'release/2.0.19' into feature/v5-migration
ViranRanaraja Jul 25, 2025
6c6aaca
Merge Conflicts
ViranRanaraja Jul 25, 2025
95c9401
fixed bugfix
ViranRanaraja Jul 28, 2025
9356a40
added the scenarios
ViranRanaraja Jul 28, 2025
67b1f0a
account factory update
ViranRanaraja Jul 29, 2025
f3861b2
fixed community issue
ViranRanaraja Jul 30, 2025
3aeb5bc
Community.json update
ViranRanaraja Jul 30, 2025
1d5c01e
Community.json update
ViranRanaraja Jul 30, 2025
101438e
Update on Modal
ViranRanaraja Jul 30, 2025
2533936
update on communities
ViranRanaraja Jul 30, 2025
0d33b99
minor update
ViranRanaraja Jul 31, 2025
348da37
Merge branch 'feature/v5-migration' into feature/new-app-migration
ViranRanaraja Jul 31, 2025
61439ea
button update
ViranRanaraja Jul 31, 2025
343853d
cursor rules
ViranRanaraja Jul 31, 2025
70920e9
print statements
ViranRanaraja Aug 1, 2025
ccb1675
update
ViranRanaraja Aug 1, 2025
4d32dc2
Merge pull request #242 from citizenwallet/feature/v5-migration
kevtechi Aug 7, 2025
515fb15
Repo Update
ViranRanaraja Aug 12, 2025
3313ec2
Repo Update
ViranRanaraja Aug 12, 2025
d1b1f6a
migration fix
ViranRanaraja Aug 13, 2025
080ba73
Json update
ViranRanaraja Aug 14, 2025
6861afd
added removed migration
ViranRanaraja Aug 14, 2025
b4f7fb5
Merge pull request #243 from citizenwallet/feature/v5-migration
kevtechi Aug 14, 2025
a56b49b
pubspec update
ViranRanaraja Aug 15, 2025
544adc5
cursorrules
ViranRanaraja Aug 18, 2025
ebbcda5
Merge branch 'release/2.0.19' into feature/new-app-migration
ViranRanaraja Aug 18, 2025
f594aec
fixed duplicate issue
ViranRanaraja Aug 19, 2025
42bd4e3
Repo Update
ViranRanaraja Aug 21, 2025
a3ada88
bug issue fixed
ViranRanaraja Aug 25, 2025
7ef2090
Merge branch 'main' into release/2.0.20
ViranRanaraja Aug 26, 2025
f384fa8
Merge pull request #245 from citizenwallet/bugfix/duplicate_account_c…
ViranRanaraja Aug 26, 2025
05de2cc
updates to v5 community config
ViranRanaraja Aug 26, 2025
12045f9
pubspec update
ViranRanaraja Aug 26, 2025
7f40057
network bug fixed
ViranRanaraja Aug 28, 2025
f936ecb
fix for search and account username
ViranRanaraja Sep 4, 2025
c6175be
repo update
ViranRanaraja Sep 8, 2025
2d74139
Merge pull request #249 from citizenwallet/bugfix/network-call
ViranRanaraja Sep 10, 2025
9d226cf
pubspec update
ViranRanaraja Sep 10, 2025
2777e62
logic update
ViranRanaraja Sep 11, 2025
966b69a
Merge pull request #250 from citizenwallet/feature/new-app-migration
ViranRanaraja Sep 11, 2025
92327fc
updated config
ViranRanaraja Sep 11, 2025
96a1400
Merge pull request #251 from citizenwallet/bugfix/config_update
ViranRanaraja Sep 11, 2025
92ded9a
pubspec update
ViranRanaraja Sep 12, 2025
3206e48
repo update
ViranRanaraja Sep 12, 2025
620b4a3
repo update
ViranRanaraja Sep 15, 2025
9146e10
fixed issue with api and added network crash protection
ViranRanaraja Sep 16, 2025
21eaba0
Merge branch 'main' into release/2.0.26
ViranRanaraja Sep 16, 2025
2b7d386
Merge pull request #254 from citizenwallet/bugfix/search_bar
ViranRanaraja Sep 16, 2025
b9a39f7
Merge branch 'main' into release/2.0.26
ViranRanaraja Sep 16, 2025
d1299ad
Fixed save profile bu
ViranRanaraja Sep 16, 2025
2eb38a4
repo update
ViranRanaraja Sep 17, 2025
f57f896
pubspec update
ViranRanaraja Sep 18, 2025
1caef65
repo update
ViranRanaraja Sep 22, 2025
cc407c2
repo update
ViranRanaraja Sep 24, 2025
d4f7294
Merge pull request #256 from citizenwallet/bugfix/save_profile
ViranRanaraja Oct 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
277 changes: 277 additions & 0 deletions .cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
# Citizen Wallet Flutter Project - Coding Patterns & Conventions

## Project Overview

This is a Flutter-based mobile wallet application for community tokens, built with a focus on blockchain integration, state management, and cross-platform compatibility.

## Architecture Patterns

### 1. State Management

- **Provider Pattern**: Uses `provider` package for state management
- **State/Logic Separation**: Each feature has separate `state.dart` and `logic.dart` files
- **ChangeNotifier**: All state classes extend `ChangeNotifier` for reactive updates
- **MultiProvider**: Centralized state provisioning in `lib/state/state.dart`

### 2. Directory Structure

```
lib/
├── models/ # Data models and DTOs
├── screens/ # UI screens organized by feature
├── widgets/ # Reusable UI components
├── services/ # Business logic and external integrations
├── state/ # State management (state + logic files)
├── router/ # Navigation and routing
├── theme/ # UI theming and styling
├── utils/ # Utility functions and helpers
├── modals/ # Modal dialogs and sheets
└── l10n/ # Localization files
```

### 3. File Naming Conventions

- **snake_case**: All file names use snake_case
- **Feature-based**: Files organized by feature/domain
- **Platform suffixes**: `.android.dart`, `.apple.dart`, `.web.dart` for platform-specific code
- **State files**: `state.dart` for state classes, `logic.dart` for business logic

## Code Style & Patterns

### 1. Dart/Flutter Conventions

- **Null Safety**: Full null safety implementation
- **Async/Await**: Prefer async/await over Future.then()
- **Const Constructors**: Use const constructors where possible
- **Final Variables**: Use final for immutable variables
- **Type Annotations**: Explicit type annotations for clarity

### 2. State Management Patterns

```dart
// State class pattern
class WalletState with ChangeNotifier {
bool loading = false;
String? error;

void setLoading(bool value) {
loading = value;
notifyListeners();
}
}

// Logic class pattern
class WalletLogic {
final WalletState _state;

Future<void> loadWallet() async {
_state.setLoading(true);
try {
// business logic
} catch (e) {
_state.setError(e.toString());
} finally {
_state.setLoading(false);
}
}
}
```

### 3. Service Layer Patterns

- **Singleton Services**: Services like `ConfigService`, `AccountDBService`
- **Interface-based**: Use interfaces for service contracts
- **Error Handling**: Comprehensive try-catch blocks with proper error propagation
- **Async Operations**: All external operations are async

### 4. UI Patterns

- **Cupertino Design**: Uses Cupertino widgets for iOS-style design
- **Responsive Design**: Platform-aware UI components
- **Modal Sheets**: Heavy use of modal bottom sheets for user interactions
- **Loading States**: Consistent loading indicators and skeleton screens
- **Error Handling**: Toast notifications and error banners

### 5. Navigation Patterns

- **GoRouter**: Uses go_router for navigation
- **Deep Linking**: Comprehensive deep link support
- **Route Guards**: Conditional navigation based on app state
- **Platform-specific**: Different navigation patterns for web/mobile

## Blockchain Integration

### 1. Web3 Integration

- **web3dart**: Primary Web3 library
- **Smart Contracts**: Custom contract interactions
- **Account Abstraction**: ERC-4337 account abstraction support
- **Gas Management**: Custom gas estimation and management

### 2. Wallet Patterns

- **Multi-wallet Support**: Multiple wallet accounts per user
- **Secure Storage**: Encrypted key storage
- **Transaction Management**: Queue-based transaction handling
- **Event Listening**: Real-time blockchain event monitoring

## Database & Storage

### 1. Local Storage

- **SQLite**: Primary local database (sqflite)
- **Shared Preferences**: Simple key-value storage
- **Secure Storage**: Encrypted sensitive data storage
- **File System**: Asset and backup file management

### 2. Data Models

- **JSON Serialization**: All models support JSON serialization
- **Copy Methods**: Immutable data with copyWith methods
- **Validation**: Input validation and sanitization

## Error Handling

### 1. Exception Patterns

- **Custom Exceptions**: Domain-specific exception classes
- **Graceful Degradation**: Fallback mechanisms for failures
- **User Feedback**: Clear error messages to users
- **Logging**: Comprehensive error logging and monitoring

### 2. Error Recovery

- **Retry Logic**: Exponential backoff for network operations
- **Offline Support**: Offline-first architecture
- **State Recovery**: Automatic state recovery mechanisms

## Testing Patterns

### 1. Test Organization

- **Unit Tests**: Service and utility function tests
- **Widget Tests**: UI component testing
- **Integration Tests**: End-to-end workflow testing
- **Mock Services**: Comprehensive mocking for external dependencies

### 2. Test Utilities

- **Mock HTTP**: Network request mocking
- **Test Helpers**: Reusable test utilities
- **Test Data**: Consistent test data fixtures

## Security Patterns

### 1. Cryptography

- **Encryption**: AES encryption for sensitive data
- **Key Management**: Secure key generation and storage
- **Digital Signatures**: Transaction signing and verification
- **Secure Communication**: HTTPS and secure WebSocket connections

### 2. Authentication

- **Biometric Auth**: Touch ID/Face ID integration
- **OAuth**: Google Sign-In integration
- **Session Management**: Secure session handling

## Performance Patterns

### 1. Optimization

- **Lazy Loading**: On-demand resource loading
- **Caching**: Multi-level caching strategies
- **Image Optimization**: Efficient image handling and caching
- **Memory Management**: Proper disposal of resources

### 2. Background Processing

- **Event Listeners**: Efficient event handling
- **Background Tasks**: Non-blocking background operations
- **State Synchronization**: Efficient state updates

## Internationalization

### 1. Localization

- **ARB Files**: Flutter's localization format
- **Multi-language**: English, French, Dutch support
- **RTL Support**: Right-to-left language support
- **Currency Formatting**: Localized currency display

## Platform-Specific Code

### 1. Platform Detection

- **kIsWeb**: Web platform detection
- **Platform-specific Files**: Separate implementations for different platforms
- **Conditional Compilation**: Platform-specific code blocks

### 2. Native Integrations

- **iOS**: Apple-specific features (Face ID, iCloud)
- **Android**: Android-specific features (Google Sign-In)
- **Web**: Web-specific optimizations and features

## Dependencies & Packages

### 1. Core Dependencies

- **Flutter**: Latest stable version
- **Provider**: State management
- **GoRouter**: Navigation
- **web3dart**: Blockchain integration
- **sqflite**: Local database

### 2. UI Dependencies

- **flutter_svg**: SVG support
- **lottie**: Animation support
- **cached_network_image**: Image caching
- **modal_bottom_sheet**: Modal dialogs

### 3. Blockchain Dependencies

- **smartcontracts**: Custom smart contract library
- **contractforge**: Contract interaction utilities
- **reown_walletkit**: Wallet functionality

## Development Workflow

### 1. Code Organization

- **Feature-based**: Organize code by business features
- **Separation of Concerns**: Clear separation between UI, business logic, and data
- **Dependency Injection**: Service locator pattern for dependencies

### 2. Code Quality

- **Linting**: Flutter lints for code quality
- **Analysis**: Static analysis with custom rules
- **Documentation**: Comprehensive code documentation
- **Type Safety**: Strong typing throughout the codebase

## Best Practices

### 1. General

- **Immutability**: Prefer immutable data structures
- **Composition**: Use composition over inheritance
- **Single Responsibility**: Each class has a single responsibility
- **Dependency Inversion**: Depend on abstractions, not concretions

### 2. Flutter-specific

- **Stateless Widgets**: Prefer stateless widgets when possible
- **Const Constructors**: Use const constructors for performance
- **Keys**: Use keys for widget identification
- **Dispose**: Properly dispose of controllers and listeners

### 3. State Management

- **Minimal State**: Keep state as minimal as possible
- **Predictable Updates**: State updates should be predictable
- **Performance**: Avoid unnecessary rebuilds
- **Testing**: Make state easily testable

This project follows a well-structured, maintainable architecture with clear separation of concerns, comprehensive error handling, and strong typing throughout the codebase.
1 change: 1 addition & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ENCRYPTED_STORAGE_GROUP_ID='x'
ORIGIN_HEADER='https://app.citizenwallet.xyz'
MAIN_APP_SCHEME='citizenwallet://app.citizenwallet.xyz'
APP_LINK_SUFFIX='.citizenwallet.xyz'
DASHBOARD_API=''
WALLET_CONFIG_URL='https://config.internal.citizenwallet.xyz'
SENTRY_URL='x'
WC_PROJECT_ID='x'
Expand Down
12 changes: 6 additions & 6 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "be698c48a6750c8cb8e61c740ca9991bb947aba2"
revision: "a402d9a4376add5bc2d6b1e33e53edaae58c07f8"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: be698c48a6750c8cb8e61c740ca9991bb947aba2
base_revision: be698c48a6750c8cb8e61c740ca9991bb947aba2
- platform: ios
create_revision: be698c48a6750c8cb8e61c740ca9991bb947aba2
base_revision: be698c48a6750c8cb8e61c740ca9991bb947aba2
create_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
base_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
- platform: android
create_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8
base_revision: a402d9a4376add5bc2d6b1e33e53edaae58c07f8

# User provided section

Expand Down
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {

android {
// compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 35
compileSdkVersion 36
// ndkVersion flutter.ndkVersion
ndkVersion = "27.0.12077973"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package xyz.citizenwallet.citizenwallet

import io.flutter.embedding.android.FlutterActivity

class MainActivity : FlutterActivity()
2 changes: 1 addition & 1 deletion assets/config/v4/communities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2139,4 +2139,4 @@
"config_location": "https://config.internal.citizenwallet.xyz/v4/wallet.kingfishersmedia.io.json",
"version": 4
}
]
]
2 changes: 1 addition & 1 deletion assets/config/v4/communities.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2139,4 +2139,4 @@
"config_location": "https://config.internal.citizenwallet.xyz/v4/wallet.kingfishersmedia.io.json",
"version": 4
}
]
]
Loading