How dapplink-labs/wallet-chain-account works
Main Components
• Client / Upper-Layer Service: This represents any external service or client consuming the gRPC interface (for example, via grpcui or a custom client).
• RPC Server: The entry point of the application (main.go) that sets up and exposes the gRPC service. Note the RPC service definitions and generated protobuf code under the “rpc” folder (account and common subdirectories).
• Chain Gateway / Dispatcher: The “chaindispatcher” package (dispatcher.go) acts as an adapter to forward requests to the appropriate chain module. This layer makes the routing decision across different blockchain implementations.
• Chain Modules: The “chain” directory is segmented into subdirectories for each blockchain (aptos, ethereum, cosmos, sui, solana, etc.). Each module encapsulates chain-specific logic, transaction handling, and integration with underlying blockchain networks.
• Common Utilities & Helpers: Refer to the “common” folder (global constants, helpers, retry strategies, and utility packages) which support the core business logic, error handling, and common operations across modules.
• Configuration & Deployment: The “config” package (config.go) and external files (config.yml, Dockerfile, charts directory) handle runtime configuration and provide deployment artifacts such as Docker and Helm charts.
Relationships & Interactions
• The Client initiates requests (RPC calls) to the RPC Server.
• The RPC Server processes incoming gRPC requests and then leverages the Chain Gateway/Dispatcher to decide which specific blockchain chain module should handle the request.
• The chain modules implement the business logic for interacting with each respective blockchain. They use utility functions from the “common” packages as needed.
• Responses (e.g., account data, transaction details) are sent back through this chain: from the chain module → back through the dispatcher → to the RPC Server → then returned to the Client.
• Deployment artifacts (Dockerfile, Helm charts) ensure the system is containerized and can be orchestrated (for cloud/Kubernetes setups).
Incorporate Architectural Patterns and Technologies
• Modularity/Separation of Concerns: Clearly separated directories for each blockchain imply a modular design where changes for one blockchain do not affect the others.
• Adapter/Dispatcher Pattern: The “chaindispatcher” layer is crucial as it decouples the gRPC interface from the specific implementation details of each blockchain.
• RPC and gRPC Communication: The service exposes a clear gRPC API defined and generated in the “rpc” directory.
• Testing and Continuous Integration: The presence of “.github/workflows” and numerous *_test.go files indicates thorough test coverage and CI/CD practice.
• Containerization and Deployment: Dockerfile and Helm charts (in the “charts” directory) indicate that the service is designed to run in containerized environments.