diff --git a/example/pubspec.lock b/example/pubspec.lock index 09b0ebd..ea92f43 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,26 +5,34 @@ packages: dependency: "direct main" description: name: algorand_dart - sha256: "6ccf13584cffddda40735b667661f3e8328e0955bb4b5895e2c3307e6b1262c4" + sha256: "6152e42df97381a609a7cfff55539ccbd2b248b50f5cdf44d911f2f384e81285" url: "https://pub.dev" source: hosted - version: "2.0.0-dev.4" - algorand_kmd: + version: "2.0.0-dev.14" + algorand_json: dependency: transitive description: - name: algorand_kmd - sha256: "9fb8daba25064ecd18b2668bf8551ad2feb3e97d5055e7bbaca677676c02ee1c" + name: algorand_json + sha256: "0c6339e0fdb65ed1089c2ecf5260920361c00f68f4338034d0ae418e37d8adfd" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "0.0.2" + algorand_msgpack: + dependency: transitive + description: + name: algorand_msgpack + sha256: f504ae345c902623ba76f56b8e6619349cdae8e7b0e28fffde6eb6c507804145 + url: "https://pub.dev" + source: hosted + version: "1.0.1" async: dependency: transitive description: name: async - sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" url: "https://pub.dev" source: hosted - version: "2.10.0" + version: "2.11.0" base32: dependency: transitive description: @@ -37,18 +45,18 @@ packages: dependency: "direct main" description: name: bloc - sha256: bd4f8027bfa60d96c8046dec5ce74c463b2c918dce1b0d36593575995344534a + sha256: f53a110e3b48dcd78136c10daa5d51512443cea5e1348c9d80a320095fa2db9e url: "https://pub.dev" source: hosted - version: "8.1.0" + version: "8.1.3" bloc_concurrency: dependency: "direct main" description: name: bloc_concurrency - sha256: "0af76bfdbdcf21d897c743bb376fbe0d356e2b9e76dc787397077391074d985d" + sha256: "5857eb6653b4dd5e30e1ffab91037957fd64a9b9c5e53d26714ef25a46c04679" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.2.4" boolean_selector: dependency: transitive description: @@ -61,34 +69,18 @@ packages: dependency: transitive description: name: buffer - sha256: "850b666e7d27c5cf42f39c43d3a9d37b7b35519b9715d9f85b418d76201518c6" + sha256: "94f60815065a8f0fd4f05be51faf86cf86519327e039d5c2aac72e1d1cc1dad4" url: "https://pub.dev" source: hosted - version: "1.1.1" - built_collection: - dependency: transitive - description: - name: built_collection - sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" - url: "https://pub.dev" - source: hosted - version: "5.1.1" - built_value: - dependency: transitive - description: - name: built_value - sha256: "59e08b0079bb75f7e27392498e26339387c1089c6bd58525a14eb8508637277b" - url: "https://pub.dev" - source: hosted - version: "8.4.2" + version: "1.2.2" characters: dependency: transitive description: name: characters - sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" clock: dependency: transitive description: @@ -101,10 +93,10 @@ packages: dependency: "direct main" description: name: collection - sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.0" + version: "1.18.0" convert: dependency: "direct main" description: @@ -117,18 +109,18 @@ packages: dependency: transitive description: name: crypto - sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.3" cryptography: dependency: transitive description: name: cryptography - sha256: e0e37f79665cd5c86e8897f9abe1accfe813c0cc5299dab22256e22fddc1fef8 + sha256: d146b76d33d94548cf035233fbc2f4338c1242fa119013bead807d033fc4ae05 url: "https://pub.dev" source: hosted - version: "2.0.5" + version: "2.7.0" dio: dependency: transitive description: @@ -153,14 +145,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21" + url: "https://pub.dev" + source: hosted + version: "2.1.2" fixnum: dependency: transitive description: name: fixnum - sha256: "04be3e934c52e082558cc9ee21f42f5c1cd7a1262f4c63cd0357c08d5bba81ec" + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" url: "https://pub.dev" source: hosted - version: "1.0.1" + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -170,26 +170,26 @@ packages: dependency: "direct main" description: name: flutter_bloc - sha256: "890c51c8007f0182360e523518a0c732efb89876cb4669307af7efada5b55557" + sha256: "87325da1ac757fcc4813e6b34ed5dd61169973871fdf181d6c2109dd6935ece1" url: "https://pub.dev" source: hosted - version: "8.1.1" + version: "8.1.4" flutter_lints: dependency: "direct dev" description: name: flutter_lints - sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.0.3" flutter_reactive_ble: dependency: transitive description: name: flutter_reactive_ble - sha256: "9eea5244d1958608f22e96dcb2ee459f7f37434b28e43c0a829276b6dc7d1aaa" + sha256: "247e2efa76de203d1ba11335c13754b5b9d0504b5423e5b0c93a600f016b24e0" url: "https://pub.dev" source: hosted - version: "5.0.3" + version: "5.3.1" flutter_test: dependency: "direct dev" description: flutter @@ -199,10 +199,10 @@ packages: dependency: transitive description: name: functional_data - sha256: "950f886463a7531a3b77904e0eb89e8e06dda78c4e3f5a84686445a2290cce18" + sha256: aefdec4365452283b2a7cf420a3169654d51d3e9553069a22d76680d7a9d7c3d url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.1.1" http_parser: dependency: transitive description: @@ -215,18 +215,50 @@ packages: dependency: transitive description: name: js - sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.7" json_annotation: dependency: transitive description: name: json_annotation - sha256: "3520fa844009431b5d4491a5a778603520cdc399ab3406332dcc50f93547258c" + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + jsontool: + dependency: transitive + description: + name: jsontool + sha256: "7741060cd6615ae82b07d70ebeca6fa6402b1c5cc1e801054911918300a780ac" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" url: "https://pub.dev" source: hosted - version: "4.7.0" + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" ledger_algorand: dependency: "direct main" description: @@ -239,10 +271,10 @@ packages: dependency: "direct main" description: name: ledger_flutter - sha256: "6a2b31131a776865734630af08f2848524f7d73f29d46760ec288817250073c7" + sha256: f1680060ed6ff78f275837e0024ccaf667715a59ba7aa29fa7354bc7752e71c8 url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.0.1" ledger_usb: dependency: transitive description: @@ -255,42 +287,34 @@ packages: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" matcher: dependency: transitive description: name: matcher - sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.13" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" - url: "https://pub.dev" - source: hosted - version: "1.8.0" - msgpack_dart: - dependency: transitive - description: - name: msgpack_dart - sha256: "46b0e5a3fcdbb1944ed04847fe7b1d7694343270977f598ac27f2c0abf896b12" + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.11.0" nested: dependency: transitive description: @@ -303,58 +327,58 @@ packages: dependency: transitive description: name: path - sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.2" + version: "1.9.0" permission_handler: dependency: "direct main" description: name: permission_handler - sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8" + sha256: bc56bfe9d3f44c3c612d8d393bd9b174eb796d706759f9b495ac254e4294baa5 url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "10.4.5" permission_handler_android: dependency: transitive description: name: permission_handler_android - sha256: "8028362b40c4a45298f1cbfccd227c8dd6caf0e27088a69f2ba2ab15464159e2" + sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47" url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: "9c370ef6a18b1c4b2f7f35944d644a56aa23576f23abee654cf73968de93f163" + sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5" url: "https://pub.dev" source: hosted - version: "9.0.7" + version: "9.1.4" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84" + sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4" url: "https://pub.dev" source: hosted - version: "3.9.0" + version: "3.12.0" permission_handler_windows: dependency: transitive description: name: permission_handler_windows - sha256: f67cab14b4328574938ecea2db3475dad7af7ead6afab6338772c5f88963e38b + sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098 url: "https://pub.dev" source: hosted - version: "0.1.2" + version: "0.1.3" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - sha256: "6a2128648c854906c53fa8e33986fc0247a1116122f9534dd20e3ab9e16a32bc" + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" url: "https://pub.dev" source: hosted - version: "2.1.4" + version: "2.1.8" protobuf: dependency: transitive description: @@ -367,26 +391,34 @@ packages: dependency: transitive description: name: provider - sha256: e1e7413d70444ea3096815a60fe5da1b11bda8a9dc4769252cc82c53536f8bcc + sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c url: "https://pub.dev" source: hosted - version: "6.0.4" + version: "6.1.2" reactive_ble_mobile: dependency: transitive description: name: reactive_ble_mobile - sha256: "616a5ad9bc96fe051414a41b133e13f75ef35e6d8db77c84f0527a43afbf614e" + sha256: "9ec2b4c9c725e439950838d551579750060258fbccd5536d0543b4d07d225798" url: "https://pub.dev" source: hosted - version: "5.0.3" + version: "5.3.1" reactive_ble_platform_interface: dependency: transitive description: name: reactive_ble_platform_interface - sha256: f9a446150076f1601c397b6bbf554eda2c37b066bb7397a226e72f04c13dbd9b + sha256: "632c92401a2d69c9b94bd48f8fd47488a7013f3d1f9b291884350291a4a81813" url: "https://pub.dev" source: hosted - version: "5.0.3" + version: "5.3.1" + retrofit: + dependency: transitive + description: + name: retrofit + sha256: "9254ec985d5e26a839a9070ae25b98f0781c9c420e4241c5fb8b8965aa1fc7f2" + url: "https://pub.dev" + source: hosted + version: "3.3.1" sky_engine: dependency: transitive description: flutter @@ -396,34 +428,34 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" stack_trace: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" stream_transform: dependency: transitive description: name: stream_transform - sha256: f1d172e22a5432c042b5adfa9aff621372e4292231d9d73ad00f486ad01c2395 + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.0" string_scanner: dependency: transitive description: @@ -444,18 +476,18 @@ packages: dependency: transitive description: name: test_api - sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.4.16" + version: "0.6.1" typed_data: dependency: transitive description: name: typed_data - sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.2" vector_math: dependency: transitive description: @@ -464,6 +496,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" sdks: - dart: ">=2.18.2 <3.0.0" + dart: ">=3.3.0-279.1.beta <4.0.0" flutter: ">=2.8.0" diff --git a/lib/src/ledger/ledger_gatt_reader.dart b/lib/src/ledger/ledger_gatt_reader.dart index 488a27b..6013638 100644 --- a/lib/src/ledger/ledger_gatt_reader.dart +++ b/lib/src/ledger/ledger_gatt_reader.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'dart:typed_data'; -import 'package:ledger_flutter/src/exceptions/ledger_exception.dart'; import 'package:ledger_flutter/src/utils/buffer.dart'; class LedgerGattReader { @@ -16,8 +15,6 @@ class LedgerGattReader { /// the protocol being used static const versionCla = 0x00; - static const errorDataSize = 2; - var currentSequence = 0; var remainingBytes = 0; var payload = []; @@ -26,8 +23,8 @@ class LedgerGattReader { void read( Stream> stream, { - void Function(Uint8List event)? onData, - Function? onError, + required void Function(Uint8List event) onData, + required void Function(Object exception) onError, }) { subscription?.cancel(); subscription = stream.listen( @@ -57,11 +54,10 @@ class LedgerGattReader { payload.addAll(reader.read(reader.remainingLength)); if (remainingBytes == 0) { - _handleData( - Uint8List.fromList(payload), - onData: onData, - onError: onError, - ); + final data = Uint8List.fromList(payload); + reset(); + + onData(data); } else if (remainingBytes > 0) { // wait for next message currentSequence += 1; @@ -70,28 +66,11 @@ class LedgerGattReader { } }, onError: (ex) { - onError?.call(ex); + onError.call(ex); }, ); } - void _handleData( - Uint8List data, { - void Function(Uint8List event)? onData, - Function? onError, - }) { - reset(); - - if (data.length > errorDataSize) { - onData?.call(data); - } else if (data.length == errorDataSize) { - final errorCode = ByteData.sublistView(data).getInt16(0); - onError?.call(LedgerException(errorCode: errorCode)); - } else { - onError?.call(LedgerException()); - } - } - /// Reset the reader void reset() { currentSequence = 0; diff --git a/pubspec.yaml b/pubspec.yaml index 9638599..5324c0c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,8 +6,8 @@ repository: https://github.com/RootSoft/ledger-flutter issue_tracker: https://github.com/RootSoft/ledger-flutter/issues environment: - sdk: '>=2.17.6 <3.0.0' - flutter: ">=1.17.0" + sdk: ">=3.0.0 <4.0.0" + flutter: ">=3.10.0" dependencies: flutter: @@ -19,6 +19,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 flutter: