getTrade method

Future<TradeInfo?> getTrade(
  1. String tradeId
)

Retrieves a specific trade by its trade ID.

Sends a GetTradeRequest with the provided tradeId and fetches details about the trade. If the client is not connected, a DaemonNotConnectedException is thrown.

Example:

final trade = await tradesService.getTrade('1234');
print('Trade ID: ${trade?.tradeId}');

Returns:

  • A Future containing the TradeInfo for the specified trade.
  • null if an error occurs.

Implementation

Future<TradeInfo?> getTrade(String tradeId) async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    final getTradeReply = await havenoChannel.tradesClient!
        .getTrade(GetTradeRequest(tradeId: tradeId));
    return getTradeReply.trade;
  } on GrpcError catch (e) {
    handleGrpcError(e);
    return null;
  }
}