This README provides a comprehensive overview of the Stellar Service module, detailing its components, functionality, and internal flow. The module is designed to interact with the Stellar blockchain, specifically focusing on contract management and transaction handling.
The Stellar Service module is responsible for managing interactions with the Stellar blockchain. It includes functionalities for verifying networks, generating methods from contract IDs, running invocations, preparing transactions, and handling contract deployments. The module is composed of several key components, including services, adapters, mappers, interfaces, and domain definitions.
The StellarService
class is the main service that provides various methods to interact with the Stellar blockchain. It includes methods for verifying networks, generating methods from contract IDs, running invocations, preparing transactions, and deploying contracts.
The StellarAdapter
class is responsible for low-level interactions with the Stellar blockchain. It handles network changes, contract existence checks, transaction preparation, and execution. The adapter abstracts the complexity of interacting with the Stellar SDK and provides a simplified interface for the service layer.
Mappers are responsible for converting data between different formats. The StellarMapper
class, for example, converts Stellar-specific data structures into application-specific formats and vice versa.
Interfaces define the contracts for the services and adapters. They ensure that the implementations adhere to the expected methods and properties. Key interfaces include IStellarService
, IStellarAdapter
, and IStellarMapper
.
The domain layer includes enums, constants, and type definitions that are used throughout the module. This layer defines the core concepts and values that the module operates on.
- Change Network: The
changeNetwork
method inStellarAdapter
allows switching between different Stellar networks (e.g., FUTURENET, TESTNET, MAINNET). - Validate Ephemeral Network: Ensures that the selected network is valid and, if necessary, configures the network for ephemeral environments.
- Verify Network: The
verifyNetwork
method inStellarService
checks if the selected network matches the current network and updates it if necessary. - Generate Methods from Contract ID: The
generateMethodsFromContractId
method retrieves contract specifications and decodes them to generate method definitions. - Deploy WASM File: The
deployWasmFile
method handles the deployment of WebAssembly (WASM) files to the Stellar blockchain.
- Run Invocation: The
runInvocation
method prepares and executes a transaction based on the provided invocation parameters. - Prepare Transaction: The
prepareTransaction
method inStellarAdapter
constructs a transaction object with the necessary operations and signs it if required. - Send Transaction: The
sendTransaction
method sends the prepared transaction to the Stellar network and handles the response.
This file contains the StellarService
class, which provides high-level methods for interacting with the Stellar blockchain. Key methods include:
verifyNetwork
generateMethodsFromContractId
runInvocation
deployWasmFile
prepareUploadWASM
runUploadWASM
getPreparedTransactionXDR
pollTransactionStatus
generateScArgsToFromContractId
getStellarAssetContractFunctions
decodeContractSpecBuffer
extractFunctionInfo
getContractSpecEntries
getScValFromSmartContract
This file contains the StellarAdapter
class, which handles low-level interactions with the Stellar blockchain. Key methods include:
changeNetwork
getInstanceValue
prepareTransaction
sendTransaction
uploadWasm
deployContract
executeTransactionWithRetry
verifyNetwork
getScSpecEntryFromXDR
createContractSpec
contractExists
getWasmCode
getContractEvents
getKeypair
getTransaction
submitSignedTransaction
prepareUploadWASM
signTransaction
streamTransactionsByMemoId
buildAndSendTransaction
createTransaction
getOperationDetails
validateEphemeralNetwork
setNetwork
updateUserBalance
getAccountOrFund
fundAccount
createDeployContractOperation
extractContractAddress
fetchFromServer
checkContractNetwork
findNetworkWithContract