Skip to content

Commit

Permalink
Merge pull request #1800 from ardriveapp/PE-6470-better-handling-on-t…
Browse files Browse the repository at this point in the history
…he-get-pending-tx-fees-method-for-null-error-null-check-operator-used-on-a-null-value

PE-6470: better handling on the get pending tx fees method for null error null check operator used on a null value
  • Loading branch information
thiagocarvalhodev authored Jul 22, 2024
2 parents e377482 + 493c094 commit 8c01cff
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/services/arweave/arweave_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:convert';

import 'package:ardrive/core/crypto/crypto.dart';
import 'package:ardrive/entities/entities.dart';
import 'package:ardrive/services/arweave/arweave_service_exception.dart';
import 'package:ardrive/services/arweave/error/gateway_error.dart';
import 'package:ardrive/services/arweave/get_segmented_transaction_from_drive_strategy.dart';
import 'package:ardrive/services/services.dart';
Expand Down Expand Up @@ -117,8 +118,18 @@ class ArweaveService {

/// Returns the pending transaction fees of the specified address that is not reflected by `getWalletBalance()`.
Future<BigInt> getPendingTxFees(String address) async {
final query = await graphQLRetry.execute(PendingTxFeesQuery(
variables: PendingTxFeesArguments(walletAddress: address)));
final query = await graphQLRetry.execute(
PendingTxFeesQuery(
variables: PendingTxFeesArguments(
walletAddress: address,
),
),
);

if (query.data == null) {
throw ArweaveServiceException(
'Error fetching pending transaction fees. The query `PendingTxFeesQuery` returned null');
}

return query.data!.transactions.edges
.map((edge) => edge.node)
Expand Down
10 changes: 10 additions & 0 deletions lib/services/arweave/arweave_service_exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ArweaveServiceException implements Exception {
final String message;

ArweaveServiceException(this.message);

@override
String toString() {
return 'ArweaveServiceException: $message';
}
}

0 comments on commit 8c01cff

Please sign in to comment.