### Setup Commands Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Commands to set up the project, including installing global tools and fetching dependencies for all packages. ```bash # Install global tools make activate_utils # Get dependencies for all packages melos bootstrap ``` -------------------------------- ### Dependency Injection Setup (Flutter) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Illustrates the use of GetIt and Injectable for dependency injection in the Flutter application. Configuration is managed in specific files, with generated configurations. ```dart // Configuration in `lib/di.dart` and generated `lib/di.config.dart` // Feature modules provide their own DI configurations ``` -------------------------------- ### Solana Program Structure Example Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana/README.md Demonstrates the conventional structure for adding new Solana programs to the library, including program and instruction files. ```dart The subdirectory shall be called `${program_name}_program` and it should contain 2 files, `${program_name}_program.dart` and `${program_name}_instructions.dart`. Each of these files will have one or more factory constructors that build messages with one or more instructions for the `_program.dart` file or single instructions for the `_instructions.dart` file. ``` -------------------------------- ### Authorize and Connect Solana Wallet (Dart) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana_mobile_client/README.md This snippet shows how to authorize a Solana wallet using the `LocalAssociationScenario`. It involves creating a session, starting the activity for the wallet adapter, and then calling the `authorize` method with identity details. The resulting `authToken` and `publicKey` are crucial for subsequent wallet interactions. It's important to handle the `result` being potentially null. ```dart import 'package:solana_mobile_client/solana_mobile_client.dart'; String? authToken; Uint8List? publicKey; Future authorizeWallet() async { final session = await LocalAssociationScenario.create(); await session.startActivityForResult(null); final client = await session.start(); final result = await client.authorize( identityUri: Uri.parse('https://yourdapp.com'), iconUri: Uri.parse('favicon.ico'), identityName: 'Your Dapp Name', cluster: 'testnet', // or 'mainnet-beta' ); if (result != null) { authToken = result.authToken; publicKey = result.publicKey; // Save these in your state } await session.close(); } ``` -------------------------------- ### Dart Variable Declaration Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/jsonrpc_client/README.md This snippet demonstrates a simple variable declaration in Dart. It defines a constant string variable named 'like' and assigns it the value 'sample'. This is a basic example of Dart syntax for variable assignment. ```dart const like = 'sample'; ``` -------------------------------- ### Deauthorize (Disconnect) Solana Wallet (Dart) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana_mobile_client/README.md Provides the functionality to deauthorize or disconnect a previously connected Solana wallet. It requires the `authToken` obtained during authorization. The process involves creating a new session, starting the client, and calling the `deauthorize` method. Both `authToken` and `publicKey` are reset after successful deauthorization. ```dart Future deauthorizeWallet() async { if (authToken == null) return; final session = await LocalAssociationScenario.create(); await session.startActivityForResult(null); final client = await session.start(); await client.deauthorize(authToken: authToken!); authToken = null; publicKey = null; await session.close(); } ``` -------------------------------- ### Code Style Guidelines Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Outlines the code style conventions for the project, including linting rules, page width, and import preferences, enforced by tools like mews_pedantic and DCM. ```dart // Uses mews_pedantic linting rules // Page width: 100 characters // Prefer relative imports within packages // DCM (Dart Code Metrics) for additional static analysis ``` -------------------------------- ### Testing Commands Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Commands for running various types of tests, including all packages, specific packages, end-to-end tests, and tests with specific Solana RPC endpoints. ```bash # Run tests for all packages melos test # Run tests for specific package (from package directory) make flutter_test # Run integration tests make flutter_test_e2e # Run tests with specific Solana RPC (required for some tests) make flutter_test SOLANA_RPC_URL=https://api.mainnet-beta.solana.com SOLANA_WEBSOCKET_URL=wss://api.mainnet-beta.solana.com ``` -------------------------------- ### Build Commands Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Commands for building the Flutter application, including code generation, iOS/Android builds, and splash screen generation. Requires specific environment variables for builds. ```bash # Generate code (run from package directory) make flutter_build # Build iOS (requires BUILD_NUMBER and SENTRY_DSN env vars) make build_ios BUILD_NUMBER=123 SENTRY_DSN=your_dsn # Build Android (requires BUILD_NUMBER and SENTRY_DSN env vars) make build_android BUILD_NUMBER=123 SENTRY_DSN=your_dsn # Generate native splash screen make splash ``` -------------------------------- ### Create Solana Client Instance (Dart) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana_mobile_client/README.md Demonstrates how to create a `SolanaClient` instance, which is essential for interacting with the Solana network. It allows switching between mainnet and testnet by configuring RPC and WebSocket URLs. This client should be instantiated once and potentially managed globally or within the application's state. ```dart import 'package:solana/solana.dart'; // Create a SolanaClient instance globally or in your State class late SolanaClient solanaClient; void setupSolanaClient({bool isMainnet = false}) { solanaClient = SolanaClient( rpcUrl: Uri.parse(isMainnet ? 'https://api.mainnet-beta.solana.com' : 'https://api.testnet.solana.com'), websocketUrl: Uri.parse(isMainnet ? 'wss://api.mainnet-beta.solana.com' : 'wss://api.testnet.solana.com'), ); } ``` -------------------------------- ### Database Schema Commands Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Commands for managing the database schema, including dumping the current schema and generating test schemas. ```bash # Dump current schema (from espressocash_app) make dump_schema VERSION=63 # Generate test schemas make flutter_generate_test_schemas ``` -------------------------------- ### Build Flutter Application Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/espressocash_app/README.md Compiles and prepares the Flutter application for deployment. It includes fetching dependencies and building the project. ```shell make flutter_get flutter_build ``` -------------------------------- ### Code Quality Commands Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Commands for maintaining code quality, including code analysis, checking for unused code, and analyzing dependency cycles. ```bash # Analyze code make dart_analyze # Check unused code (from espressocash_app) make flutter_check_unused_code # Check dependency cycles make deps_graph_features ``` -------------------------------- ### Running Solana Test Validator Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana/README.md Instructions to run the Solana test validator using the Solana Tool Suite for testing purposes. ```shell solana-test-validator ``` -------------------------------- ### Local Database (Flutter) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Shows the use of Drift (formerly Moor) for local database management in the Flutter app. Schema versions are tracked, and implementations are located in a specific directory. ```dart // Uses Drift (formerly Moor) for local database // Schema versions tracked in `moor_schemas/` // Database implementation in `lib/data/db/` ``` -------------------------------- ### State Management (Flutter) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Demonstrates the use of flutter_bloc for state management within the Flutter application. Each feature utilizes its own BLoCs/Cubits. ```dart // Uses flutter_bloc for state management // Each feature has its own BLoCs/Cubits ``` -------------------------------- ### Solana Mobile Demo with Flutter Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana_mobile_client/README.md A Flutter widget demonstrating a full integration with the Solana mobile client. It includes state management for wallet connection, cluster selection (testnet/mainnet), and performing actions like authorize, deauthorize, and request airdrop. Dependencies include 'flutter/material.dart', 'solana/solana.dart', and 'solana_mobile_client/solana_mobile_client.dart'. ```dart import 'package:flutter/material.dart'; import 'package:solana/solana.dart'; import 'package:solana_mobile_client/solana_mobile_client.dart'; class SolanaMobileDemo extends StatefulWidget { const SolanaMobileDemo({super.key}); @override State createState() => _SolanaMobileDemoState(); } class _SolanaMobileDemoState extends State authorizeWallet() async { final session = await LocalAssociationScenario.create(); await session.startActivityForResult(null); final client = await session.start(); final result = await client.authorize( identityUri: Uri.parse('https://yourdapp.com'), iconUri: Uri.parse('favicon.ico'), identityName: 'Your Dapp Name', cluster: cluster, ); if (result != null) { setState(() { authToken = result.authToken; publicKey = result.publicKey; }); } await session.close(); } Future deauthorizeWallet() async { if (authToken == null) return; final session = await LocalAssociationScenario.create(); await session.startActivityForResult(null); final client = await session.start(); await client.deauthorize(authToken: authToken!); setState(() { authToken = null; publicKey = null; }); await session.close(); } Future requestAirdrop() async { if (publicKey == null) return; await solanaClient.requestAirdrop( address: Ed25519HDPublicKey(publicKey!), lamports: 1000000000, ); ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('Airdrop requested')), ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Solana Mobile Demo')), body: Padding( padding: const EdgeInsets.all(16), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text('Address: \${publicKey != null ? Ed25519HDPublicKey(publicKey!).toBase58() : "Not connected"}') const SizedBox(height: 16), ElevatedButton( onPressed: authorizeWallet, child: const Text('Authorize Wallet'), ), ElevatedButton( onPressed: authToken != null ? deauthorizeWallet : null, child: const Text('Deauthorize'), ), ElevatedButton( onPressed: publicKey != null ? requestAirdrop : null, child: const Text('Request Airdrop'), ), const SizedBox(height: 16), Row( children: [ ElevatedButton( onPressed: () { setState(() { cluster = 'testnet'; setupSolanaClient(); }); }, child: const Text('Testnet'), ), const SizedBox(width: 8), ElevatedButton( onPressed: () { setState(() { cluster = 'mainnet-beta'; setupSolanaClient(); }); }, child: const Text('Mainnet'), ), ], ), ], ), ), ); } } ``` -------------------------------- ### Define Environmental Variables with Flutter Run Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/jupiter_aggregator/README.md Demonstrates how to define environmental variables when launching a Flutter application using command-line flags. This is useful for configuring API endpoints or other settings dynamically. ```bash flutter run lib/main.dart --dart-define=QUOTE_API_BASE=https://public.jupiterapi.com ``` -------------------------------- ### Run Flutter Tests Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/espressocash_app/README.md Executes unit, golden, and end-to-end tests for the Flutter application. This command ensures the application's quality and functionality. ```shell make flutter_generate_test_schemas flutter_test ``` ```shell make flutter_test_e2e ``` -------------------------------- ### Request Airdrop from Solana (Dart) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/packages/solana_mobile_client/README.md This function demonstrates how to request an airdrop of lamports to a specified Solana public key. It utilizes the previously created `solanaClient` and requires a valid `publicKey`. The amount of lamports to request is passed as an argument. Ensure the `publicKey` is not null before calling this function. ```dart Future requestAirdrop() async { if (publicKey == null) return; await solanaClient.requestAirdrop( address: Ed25519HDPublicKey(publicKey!), lamports: 1000000000, // 1 SOL = 1,000,000,000 lamports ); } ``` -------------------------------- ### Import Rules (Flutter DCM) Source: https://github.com/espresso-cash/espresso-cash-public/blob/master/CLAUDE.md Defines the import rules enforced by Dart Code Metrics (DCM) to maintain modularity and prevent circular dependencies between different parts of the Flutter application. ```dart // Models cannot import from data, services, widgets, screens, ui, or l10n // Data cannot import from services, widgets, screens, or ui // Services cannot import from widgets, screens, ui, or l10n // UI cannot import from features // Utils cannot import from features or ui ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.