Skip to content

Commit

Permalink
🐛 Fix ArchethicJsonRPCException is not catched
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Apr 11, 2024
1 parent 769f4d6 commit eb19dac
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changelog
=========
=========

#### Version 3.3.12
* Fix `ArchethicJsonRPCException` is not catched

#### Version 3.3.11
* Upgrade dependencies

Expand Down
1 change: 1 addition & 0 deletions lib/src/services/api_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class ApiService with JsonRPCUtil {
'sendTx: (${transaction.address}) $e',
logsActivation: logsActivation,
);
rethrow;
}

return completer.future;
Expand Down
9 changes: 9 additions & 0 deletions lib/src/utils/confirmations/archethic_transaction_sender.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ class ArchethicTransactionSender
await onError(
const TransactionError.connectivity(),
);
} on ArchethicJsonRPCException catch (e) {
close();
await onError(
TransactionError.rpcError(
code: e.code,
message: e.message,
data: e.data,
),
);
} on Exception {
close();
await onError(
Expand Down
6 changes: 6 additions & 0 deletions lib/src/utils/confirmations/transaction_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class TransactionError with _$TransactionError implements Exception {
const factory TransactionError.unknownAccount({
required String accountName,
}) = _TransactionUnknownAccount;
const factory TransactionError.rpcError({
required int code,
required String message,
Object? data,
}) = _TransactionRPCError;
const factory TransactionError.other({
String? reason,
}) = _TransactionOtherError;
Expand All @@ -37,6 +42,7 @@ class TransactionError with _$TransactionError implements Exception {
serviceAlreadyExists: (_) => 'service already exists in the keychain',
userRejected: (_) => 'user rejected',
unknownAccount: (_) => 'unknown account',
rpcError: (_) => 'JSON RPC error',
other: (other) => other.reason ?? 'other reason',
);
}
Expand Down
299 changes: 299 additions & 0 deletions lib/src/utils/confirmations/transaction_event.freezed.dart

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ packages:
dependency: transitive
description:
name: args
sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.4.2"
version: "2.5.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -245,10 +245,10 @@ packages:
dependency: "direct dev"
description:
name: freezed
sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5"
sha256: a434911f643466d78462625df76fd9eb13e57348ff43fe1f77bbe909522c67a1
url: "https://pub.dev"
source: hosted
version: "2.4.7"
version: "2.5.2"
freezed_annotation:
dependency: "direct main"
description:
Expand Down Expand Up @@ -437,10 +437,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.14.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -501,10 +501,10 @@ packages:
dependency: "direct main"
description:
name: phoenix_socket
sha256: "21c0ed733db29a74d54f676aaab4800d8b7278bc0e4e95a7a7c5d7773464a2bf"
sha256: "95898872f898a4f53c81b552a0ddd4ebb35881c0616f1242150f1b4f0536e6c7"
url: "https://pub.dev"
source: hosted
version: "0.7.1"
version: "0.7.2"
pinenacl:
dependency: "direct main"
description:
Expand All @@ -517,10 +517,10 @@ packages:
dependency: "direct main"
description:
name: pointycastle
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333"
url: "https://pub.dev"
source: hosted
version: "3.7.4"
version: "3.8.0"
pool:
dependency: transitive
description:
Expand Down Expand Up @@ -693,26 +693,26 @@ packages:
dependency: "direct dev"
description:
name: test
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
sha256: d87214d19fb311997d8128ec501a980f77cb240ac4e7e219accf452813ff473c
url: "https://pub.dev"
source: hosted
version: "1.25.2"
version: "1.25.3"
test_api:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "2419f20b0c8677b2d67c8ac4d1ac7372d862dc6c460cdbb052b40155408cd794"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.1"
test_core:
dependency: transitive
description:
name: test_core
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
sha256: "2236f70be1e5ab405c675e88c36935a87dad9e05a506b57dd5c0f617f5aebcb2"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
timing:
dependency: transitive
description:
Expand All @@ -733,10 +733,10 @@ packages:
dependency: transitive
description:
name: uuid
sha256: cd210a09f7c18cbe5a02511718e0334de6559871052c90a90c0cca46a4aa81c8
sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8"
url: "https://pub.dev"
source: hosted
version: "4.3.3"
version: "4.4.0"
vm_service:
dependency: transitive
description:
Expand Down Expand Up @@ -765,10 +765,10 @@ packages:
dependency: transitive
description:
name: web_socket_channel
sha256: "1d8e795e2a8b3730c41b8a98a2dff2e0fb57ae6f0764a1c46ec5915387d257b2"
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
url: "https://pub.dev"
source: hosted
version: "2.4.4"
version: "2.4.5"
webkit_inspection_protocol:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: archethic_lib_dart
description: Archethic dart library for Flutter for Node and Browser. This library aims to provide a easy way to create Archethic transaction and to send them over the network
homepage: https://github.com/archethic-foundation/libdart

version: 3.3.11
version: 3.3.12

environment:
sdk: ">=3.3.0 <4.0.0"
Expand Down

0 comments on commit eb19dac

Please sign in to comment.