getDispute method

Future<Dispute?> getDispute(
  1. String tradeId
)

Implementation

Future<Dispute?> getDispute(String tradeId) async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {

    GetDisputeReply? getDisputeReply = await havenoChannel.disputesClient?.getDispute(GetDisputeRequest(tradeId: tradeId));

    Dispute newDispute = getDisputeReply!.dispute;

    _disputeToTradeIdMap[newDispute.id] = tradeId;
    _tradeIdToDisputeMap[newDispute.tradeId] = newDispute;

    // Update the _disputes list or map if necessary
    final int existingIndex = _disputes.indexWhere((d) => d.id == newDispute.id);

    if (existingIndex != -1) {
      _disputes[existingIndex] = newDispute;
    } else {
      _disputes.add(newDispute);
    }
    return newDispute;
  } on GrpcError catch (e) {
    handleGrpcError(e);
    return null;
  }
}