From 539451541e8a88ccc8cb799eb9530617dcdc5ae4 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Thu, 20 Jun 2024 17:21:26 +0300 Subject: [PATCH 01/34] Fix getting identity full name --- app/lib/services/identity_service.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/services/identity_service.dart b/app/lib/services/identity_service.dart index abd0264e..7c4a4b51 100644 --- a/app/lib/services/identity_service.dart +++ b/app/lib/services/identity_service.dart @@ -2,8 +2,9 @@ String getFullNameOfObject(Map identityName) { String firstName = identityName['first_name'] ?? ''; String middleName = identityName['middle_name'] ?? ''; String lastName = identityName['last_name'] ?? ''; + String fullName = identityName['full_name'] ?? ''; - return '$firstName $middleName $lastName'; + return fullName != '' ? fullName : '$firstName $middleName $lastName'; } String getCorrectState( From 7f623c7e2062803dc234b6d27e01046402977879 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Thu, 20 Jun 2024 17:22:19 +0300 Subject: [PATCH 02/34] Fix identity card colors --- .../screens/identity_verification_screen.dart | 160 +++++++++++++----- 1 file changed, 115 insertions(+), 45 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 5eadabf6..1abd0df4 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -8,7 +8,6 @@ import 'package:shuftipro_sdk/shuftipro_sdk.dart'; import 'package:threebotlogin/events/events.dart'; import 'package:threebotlogin/events/identity_callback_event.dart'; import 'package:threebotlogin/helpers/globals.dart'; -import 'package:threebotlogin/helpers/hex_color.dart'; import 'package:threebotlogin/helpers/kyc_helpers.dart'; import 'package:threebotlogin/main.dart'; import 'package:threebotlogin/services/identity_service.dart'; @@ -359,6 +358,13 @@ class _IdentityVerificationScreenState } }, context: context, + countryListTheme: CountryListThemeData( + backgroundColor: Theme.of(context).colorScheme.secondaryContainer, + textStyle: Theme.of(context).textTheme.bodySmall!.copyWith( + color: Theme.of(context).colorScheme.onSecondaryContainer), + searchTextStyle: Theme.of(context).textTheme.bodySmall!.copyWith( + color: Theme.of(context).colorScheme.onSecondaryContainer), + ), showPhoneCode: false, // optional. Shows phone code before the country name. onSelect: (Country country) async { @@ -1068,8 +1074,8 @@ class _IdentityVerificationScreenState return _pleaseWait(); } - String name = - jsonDecode(snapshot.data['identityName'])['full_name']; + String name = getFullNameOfObject( + jsonDecode(snapshot.data['identityName'])); return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -1079,47 +1085,69 @@ class _IdentityVerificationScreenState ), Container( padding: const EdgeInsets.fromLTRB(15, 10, 15, 10), - child: const Column( + child: Column( children: [ - Row( - children: [ - Text( - 'OpenKYC ID CARD', - style: TextStyle( - fontSize: 18.0, - fontWeight: FontWeight.bold), - textAlign: TextAlign.left, - ), - ], + Text( + 'OpenKYC ID CARD', + style: Theme.of(context) + .textTheme + .titleLarge! + .copyWith( + fontWeight: FontWeight.bold, + color: Theme.of(context) + .colorScheme + .onSecondaryContainer), + textAlign: TextAlign.center, ), - SizedBox(height: 5), + const SizedBox(height: 5), Row(children: [ Text( 'Your own personal KYC ID CARD', - style: TextStyle( - fontSize: 13, color: Colors.grey), + style: Theme.of(context) + .textTheme + .titleMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .onSecondaryContainer), ), ]), ], )), Container( + color: Theme.of(context).colorScheme.secondaryContainer, padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), - color: HexColor('#f2f5f3'), child: Column( children: [ Row( children: [ Text( 'Full name', - style: TextStyle( - fontSize: 13, - color: HexColor('#787878'), - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .primary, + ), ) ], ), Row( - children: [Text(name)], + children: [ + Text( + name, + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), + ) + ], ) ], ), @@ -1132,44 +1160,72 @@ class _IdentityVerificationScreenState children: [ Text( 'Birthday', - style: TextStyle( - fontSize: 13, - color: HexColor('#787878'), - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .primary, + ), ), ], ), Row( children: [ - Text(snapshot.data['identityDOB'] != 'None' - ? snapshot.data['identityDOB'] - : 'Unknown') + Text( + snapshot.data['identityDOB'] != 'None' + ? snapshot.data['identityDOB'] + : 'Unknown', + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), + ) ], ) ], ), ), Container( + color: Theme.of(context).colorScheme.secondaryContainer, padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), - color: HexColor('#f2f5f3'), child: Column( children: [ Row( children: [ Text( 'Country', - style: TextStyle( - fontSize: 13, - color: HexColor('#787878'), - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .primary, + ), ) ], ), Row( children: [ - Text(snapshot.data['identityCountry'] != 'None' - ? snapshot.data['identityCountry'] - : 'Unknown') + Text( + snapshot.data['identityCountry'] != 'None' + ? snapshot.data['identityCountry'] + : 'Unknown', + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), + ) ], ) ], @@ -1183,18 +1239,32 @@ class _IdentityVerificationScreenState children: [ Text( 'Gender', - style: TextStyle( - fontSize: 13, - color: HexColor('#787878'), - ), + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .primary, + ), ) ], ), Row( children: [ - Text(snapshot.data['identityGender'] != 'None' - ? snapshot.data['identityGender'] - : 'Unknown') + Text( + snapshot.data['identityGender'] != 'None' + ? snapshot.data['identityGender'] + : 'Unknown', + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith( + color: Theme.of(context) + .colorScheme + .onSecondaryContainer, + ), + ) ], ) ], From d17990ab9c26c0489d95f51f56741e7b15e2c8ef Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 13:18:46 +0300 Subject: [PATCH 03/34] Update the user table to have new columns for twin_id, phone, and identity --- backend/migrations/8-add-twin-phone-identity-to-users.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 backend/migrations/8-add-twin-phone-identity-to-users.py diff --git a/backend/migrations/8-add-twin-phone-identity-to-users.py b/backend/migrations/8-add-twin-phone-identity-to-users.py new file mode 100644 index 00000000..bf242eda --- /dev/null +++ b/backend/migrations/8-add-twin-phone-identity-to-users.py @@ -0,0 +1,4 @@ +from database import update_table + +update_users_sql = """ ALTER TABLE users ADD COLUMN twin_id integer, ADD COLUMN phone text, ADD COLUMN identity_reference text; """ +update_table(update_users_sql) From 20b6f6579e90c28508cc173842555f06c72010d0 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 15:09:46 +0300 Subject: [PATCH 04/34] Fix migration script --- backend/migrations/8-add-twin-phone-identity-to-users.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/migrations/8-add-twin-phone-identity-to-users.py b/backend/migrations/8-add-twin-phone-identity-to-users.py index bf242eda..9dee6423 100644 --- a/backend/migrations/8-add-twin-phone-identity-to-users.py +++ b/backend/migrations/8-add-twin-phone-identity-to-users.py @@ -1,4 +1,6 @@ from database import update_table -update_users_sql = """ ALTER TABLE users ADD COLUMN twin_id integer, ADD COLUMN phone text, ADD COLUMN identity_reference text; """ +update_users_sql = """ ALTER TABLE users ADD COLUMN twin_id integer; + ALTER TABLE users ADD COLUMN phone text; + ALTER TABLE users ADD COLUMN identity_reference text; """ update_table(update_users_sql) From 47d9740964f13dd324c692bb7a8c3ef15421bc7f Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 16:07:50 +0300 Subject: [PATCH 05/34] Add method to update the user data on the database --- backend/database.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/database.py b/backend/database.py index da2cc84c..718a1db9 100644 --- a/backend/database.py +++ b/backend/database.py @@ -618,12 +618,15 @@ def use_productkey(key): pass -def update_user_email(double_name, email): - update_sql = 'UPDATE users set email =? where double_name =?' +def update_user(double_name, field, value): + if field not in ["twin_id", "email", "phone", "identity_reference"]: + raise Exception(f"This field {field} doesn't exist on the users table") + + update_sql = f'UPDATE users set {field} =? where double_name =?' try: cursor = conn.cursor() - cursor.execute(update_sql, (email, double_name)) + cursor.execute(update_sql, (value, double_name)) conn.commit() except Error as e: From e563978b5fce72c08abed68c08b16c0299be0389 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 16:16:23 +0300 Subject: [PATCH 06/34] Add route for updating the user data --- backend/routes/users.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/routes/users.py b/backend/routes/users.py index d3b123ef..2a0c2962 100644 --- a/backend/routes/users.py +++ b/backend/routes/users.py @@ -197,19 +197,20 @@ def set_phone_verified_handler(doublename): return Response("Ok") -@ api_users.route("/change-email", methods=["POST"]) -def change_email_for_user(): +@ api_users.route("/update", methods=["POST"]) +def update_user(): body = request.get_json() if body is None: - return Response('Body cannot be empty', status=404) + return Response('Body cannot be empty', status=400) username = body.get('username') - email = body.get('email') - if username is None or email is None: - return Response("Username is empty or Email is empty", status=404) + field = body.get('field') + value = body.get('value') + if username is None or field is None or value is None: + return Response("Username, Field, or Value is empty", status=400) - logger.debug("Change email for user %s", username) + logger.debug(f"Change {field} for user {username}") user = db.get_user_by_double_name(username) if user is None: @@ -222,9 +223,9 @@ def change_email_for_user(): logger.debug("Response of verification is of instance Response, Failed to Verify.") return signed_data_verification_response - db.update_user_email(username, email) - return Response("Successfully updated email address", status=200) + db.update_user(username, field, value) + return Response(f"Successfully updated {field}", status=200) except Exception as e: print(e) - return Response("Something went wrong", status=402) \ No newline at end of file + return Response("Something went wrong", status=402) From 4562befd69f7465fac6872629b84b97714f8158f Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 16:20:01 +0300 Subject: [PATCH 07/34] Add method for updating the user data in the app --- app/lib/services/open_kyc_service.dart | 34 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/app/lib/services/open_kyc_service.dart b/app/lib/services/open_kyc_service.dart index 52e0ac6a..7e86ce34 100644 --- a/app/lib/services/open_kyc_service.dart +++ b/app/lib/services/open_kyc_service.dart @@ -200,6 +200,7 @@ Future verifyIdentity(String reference) async { return http.post(url, body: encodedBody, headers: requestHeaders); } +// TODO: Remove this method and user update user data Future updateEmailAddressOfUser() async { String timestamp = DateTime.now().millisecondsSinceEpoch.toString(); Uint8List sk = await getPrivateKey(); @@ -217,10 +218,37 @@ Future updateEmailAddressOfUser() async { 'Jimber-Authorization': signedPayload }; - String encodedBody = - jsonEncode({'username': await getDoubleName(), 'email': email['email']}); + String encodedBody = jsonEncode({ + 'username': await getDoubleName(), + 'field': 'email', + 'value': email['email'] + }); + + Uri url = Uri.parse('$threeBotApiUrl/users/update'); + print('Sending call: ${url.toString()}'); + + return http.post(url, headers: loginRequestHeaders, body: encodedBody); +} + +Future updateUserData(String field, String value) async { + String timestamp = DateTime.now().millisecondsSinceEpoch.toString(); + Uint8List sk = await getPrivateKey(); + + Map payload = { + 'timestamp': timestamp, + 'intention': 'change-$field' + }; + String signedPayload = await signData(jsonEncode(payload), sk); + + Map loginRequestHeaders = { + 'Content-type': 'application/json', + 'Jimber-Authorization': signedPayload + }; + + String encodedBody = jsonEncode( + {'username': await getDoubleName(), 'field': field, 'value': value}); - Uri url = Uri.parse('$threeBotApiUrl/users/change-email'); + Uri url = Uri.parse('$threeBotApiUrl/users/update'); print('Sending call: ${url.toString()}'); return http.post(url, headers: loginRequestHeaders, body: encodedBody); From 4112f847cb006953854a459c3730ca9810bb4dfb Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Tue, 25 Jun 2024 17:01:43 +0300 Subject: [PATCH 08/34] Use the user update method to update email, phone, and identity after they are verified --- app/lib/helpers/kyc_helpers.dart | 3 ++- app/lib/services/shared_preference_service.dart | 10 ++++++++-- app/lib/services/socket_service.dart | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/lib/helpers/kyc_helpers.dart b/app/lib/helpers/kyc_helpers.dart index 2201bc17..1b57404c 100644 --- a/app/lib/helpers/kyc_helpers.dart +++ b/app/lib/helpers/kyc_helpers.dart @@ -69,7 +69,8 @@ Future handleKYCData(Map emailData, jsonDecode(identityData['identityDocumentMeta']), identityData['signedIdentityDocumentMetaIdentifier'], identityData['identityGender'], - identityData['signedIdentityGenderIdentifier']); + identityData['signedIdentityGenderIdentifier'], + identityData['referenceId']); } } diff --git a/app/lib/services/shared_preference_service.dart b/app/lib/services/shared_preference_service.dart index de8893fd..027edeae 100644 --- a/app/lib/services/shared_preference_service.dart +++ b/app/lib/services/shared_preference_service.dart @@ -8,6 +8,7 @@ import 'package:threebotlogin/helpers/globals.dart'; import 'package:threebotlogin/models/wallet_data.dart'; import 'package:threebotlogin/services/3bot_service.dart'; import 'package:threebotlogin/services/crypto_service.dart'; +import 'package:threebotlogin/services/open_kyc_service.dart'; import 'package:threebotlogin/services/pkid_service.dart'; import 'package:pinenacl/api.dart'; import 'package:pinenacl/tweetnacl.dart' show TweetNaClExt; @@ -160,6 +161,7 @@ Future saveEmail(String email, String? signedEmailIdentifier) async { prefs.setString('signedEmailIdentifier', signedEmailIdentifier); client.setPKidDoc( 'email', json.encode({'email': email, 'sei': signedEmailIdentifier})); + updateUserData("email", email); return; } @@ -207,6 +209,7 @@ Future savePhone(String phone, String? signedPhoneIdentifier) async { prefs.setString('signedPhoneIdentifier', signedPhoneIdentifier); client.setPKidDoc( 'phone', json.encode({'phone': phone, 'spi': signedPhoneIdentifier})); + updateUserData("phone", phone); return; } @@ -261,7 +264,8 @@ Future saveIdentity( Map identityDocumentMeta, String signedIdentityDocumentMetaIdentifier, String identityGender, - String signedIdentityGenderIdentifier) async { + String signedIdentityGenderIdentifier, + String referenceId) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.remove('identityName'); prefs.remove('identityCountry'); @@ -301,8 +305,10 @@ Future saveIdentity( 'signedIdentityDocumentMetaIdentifier': signedIdentityDocumentMetaIdentifier, 'identityGender': identityGender, - 'signedIdentityGenderIdentifier': signedIdentityGenderIdentifier + 'signedIdentityGenderIdentifier': signedIdentityGenderIdentifier, + 'referenceId': referenceId })); + updateUserData("identity_reference", referenceId); Globals().identityVerified.value = true; } diff --git a/app/lib/services/socket_service.dart b/app/lib/services/socket_service.dart index 9cf226e0..9e208a7a 100644 --- a/app/lib/services/socket_service.dart +++ b/app/lib/services/socket_service.dart @@ -353,7 +353,8 @@ Future identityVerification(String reference) async { verifiedSignedIdentityDocumentMetaIdentifier['document_meta_data'], signedIdentityDocumentMetaIdentifier, verifiedSignedIdentityGenderIdentifier['gender_data'], - signedIdentityGenderIdentifier); + signedIdentityGenderIdentifier, + reference); return 'Verified'; } From 64e718da9d2ccdc2ede6e8928a0d6055b5ea687f Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 17:19:29 +0300 Subject: [PATCH 09/34] Add tfchain and stellar clients to the app --- app/pubspec.lock | 451 +++++++++++++++++++++++++++++++++++++++++++++-- app/pubspec.yaml | 14 +- 2 files changed, 450 insertions(+), 15 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index cde1bbd2..016a493f 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -1,6 +1,30 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + url: "https://pub.dev" + source: hosted + version: "64.0.0" + adaptive_number: + dependency: transitive + description: + name: adaptive_number + sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + url: "https://pub.dev" + source: hosted + version: "6.2.0" args: dependency: transitive description: @@ -25,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + base_x: + dependency: transitive + description: + name: base_x + sha256: "519abcdafd637d4b6bd7e72fabd8f9264935f804b9b9f6c5d8411c7d52cbf8fd" + url: "https://pub.dev" + source: hosted + version: "2.0.1" bip39: dependency: "direct main" description: @@ -33,6 +65,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.6" + bip39_mnemonic: + dependency: transitive + description: + name: bip39_mnemonic + sha256: "24855a62fb9dd930f697063a274e084b0a574e1cc55ec270ca4756f579ab512c" + url: "https://pub.dev" + source: hosted + version: "3.0.6" boolean_selector: dependency: transitive description: @@ -41,6 +81,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.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: c7913a9737ee4007efedaffc968c049fd0f3d0e49109e778edc10de9426005cb + url: "https://pub.dev" + source: hosted + version: "8.9.2" characters: dependency: transitive description: @@ -57,6 +113,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + url: "https://pub.dev" + source: hosted + version: "4.10.0" collection: dependency: transitive description: @@ -89,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + cryptography: + dependency: transitive + description: + name: cryptography + sha256: d146b76d33d94548cf035233fbc2f4338c1242fa119013bead807d033fc4ae05 + url: "https://pub.dev" + source: hosted + version: "2.7.0" csslib: dependency: transitive description: @@ -105,6 +177,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" + source: hosted + version: "2.3.6" + decimal: + dependency: transitive + description: + name: decimal + sha256: "24a261d5d5c87e86c7651c417a5dbdf8bcd7080dd592533910e8d0505a279f21" + url: "https://pub.dev" + source: hosted + version: "2.3.3" device_info_plus: dependency: "direct main" description: @@ -129,6 +217,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.2" + ed25519_edwards: + dependency: transitive + description: + name: ed25519_edwards + sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd" + url: "https://pub.dev" + source: hosted + version: "0.3.1" + edwards25519: + dependency: transitive + description: + name: edwards25519 + sha256: "48e4678136e362bed9790dfb716ebe8e2f34f026bdb900b058214620672c6273" + url: "https://pub.dev" + source: hosted + version: "1.0.4" encrypt: dependency: transitive description: @@ -137,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.1" + equatable: + dependency: transitive + description: + name: equatable + sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2 + url: "https://pub.dev" + source: hosted + version: "2.0.5" fake_async: dependency: transitive description: @@ -149,10 +261,10 @@ packages: dependency: transitive description: name: ffi - sha256: ed5337a5660c506388a9f012be0288fb38b49020ce2b45fe1f8b8323fe429f99 + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "2.1.0" file: dependency: transitive description: @@ -161,6 +273,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.1.4" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flagsmith: dependency: "direct main" description: @@ -182,6 +302,14 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_curve25519: + dependency: transitive + description: + name: flutter_curve25519 + sha256: d2d196e51de878f5f0289d2d7c5e93dc0c62ccda7ca98c7e47b5a58a6851b861 + url: "https://pub.dev" + source: hosted + version: "0.1.2" flutter_inappwebview: dependency: "direct main" description: @@ -249,6 +377,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" google_fonts: dependency: "direct main" description: @@ -257,6 +393,22 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + hashlib: + dependency: transitive + description: + name: hashlib + sha256: d41795742c10947930630118c6836608deeb9047cd05aee32d2baeb697afd66a + url: "https://pub.dev" + source: hosted + version: "1.19.2" + hashlib_codecs: + dependency: transitive + description: + name: hashlib_codecs + sha256: "8cea9ccafcfeaa7324d2ae52c61c69f7ff71f4237507a018caab31b9e416e3b1" + url: "https://pub.dev" + source: hosted + version: "2.6.0" hex: dependency: transitive description: @@ -277,10 +429,10 @@ packages: dependency: "direct main" description: name: http - sha256: "4c3f04bfb64d3efd508d06b41b825542f08122d30bda4933fb95c069d22a4fa3" + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "1.2.0" http_parser: dependency: transitive description: @@ -290,13 +442,13 @@ packages: source: hosted version: "4.0.2" intl: - dependency: transitive + dependency: "direct overridden" description: name: intl - sha256: "910f85bce16fb5c6f614e117efa303e85a1731bb0081edf3604a2ae6e9a3cc91" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.17.0" + version: "0.19.0" intl_phone_field: dependency: "direct main" description: @@ -321,6 +473,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.6.0" + json_schema2: + dependency: transitive + description: + name: json_schema2 + sha256: "094e60d3605333c0816eeb2e5310b4f71ffaea2c0abc026b27418c1ac41a5db3" + url: "https://pub.dev" + source: hosted + version: "2.0.4+9" lints: dependency: transitive description: @@ -341,10 +501,10 @@ packages: dependency: transitive description: name: logging - sha256: c0bbfe94d46aedf9b8b3e695cf3bd48c8e14b35e3b2c639e0aa7755d589ba946 + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.0" matcher: dependency: transitive description: @@ -361,6 +521,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.0" + merlin: + dependency: transitive + description: + name: merlin + sha256: c6b5d5bc70880aa7639686db66480d0be4b89da843b5cab20550610507da2540 + url: "https://pub.dev" + source: hosted + version: "1.0.3" meta: dependency: transitive description: @@ -369,6 +537,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + moment_dart: + dependency: transitive + description: + name: moment_dart + sha256: "721f008251341578a818140afe402be827bc29951846575598426f4039a0799b" + url: "https://pub.dev" + source: hosted + version: "2.2.1+beta.0" open_filex: dependency: "direct main" description: @@ -377,6 +553,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.3.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" package_info_plus: dependency: "direct main" description: @@ -557,10 +741,42 @@ packages: dependency: transitive description: name: pointycastle - sha256: "7c1e5f0d23c9016c5bbd8b1473d0d3fb3fc851b876046039509e18e0c7485f2c" + sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe" + url: "https://pub.dev" + source: hosted + version: "3.9.1" + polkadart: + dependency: transitive + description: + name: polkadart + sha256: "91ff0cefa9a6a94a55bc241b40f2bde69ad11a3de2b26912941367127c933afe" + url: "https://pub.dev" + source: hosted + version: "0.4.6" + polkadart_cli: + dependency: transitive + description: + name: polkadart_cli + sha256: a0c82811e7ed935208afc7a8e0ef04446574d53f0a1855694ec5ad0792decef1 + url: "https://pub.dev" + source: hosted + version: "0.4.2" + polkadart_keyring: + dependency: transitive + description: + name: polkadart_keyring + sha256: "10cdd75e3319169ca7a4bb49745d85fab3f56bba2eafda35655c4f278a4c5e07" url: "https://pub.dev" source: hosted - version: "3.7.3" + version: "0.4.3" + polkadart_scale_codec: + dependency: transitive + description: + name: polkadart_scale_codec + sha256: fab60c739f6ebcc812796e56378656dca57179cec46e92c23614db6fd9ed0f86 + url: "https://pub.dev" + source: hosted + version: "1.2.0" process: dependency: transitive description: @@ -569,6 +785,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.2.4" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" qr_code_scanner: dependency: "direct main" description: @@ -577,6 +801,46 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.1" + quiver: + dependency: transitive + description: + name: quiver + sha256: ea0b925899e64ecdfbf9c7becb60d5b50e706ade44a85b2363be2a22d88117d2 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + rational: + dependency: transitive + description: + name: rational + sha256: cb808fb6f1a839e6fc5f7d8cb3b0a10e1db48b3be102de73938c627f0b636336 + url: "https://pub.dev" + source: hosted + version: "2.2.3" + recase: + dependency: transitive + description: + name: recase + sha256: e4eb4ec2dcdee52dcf99cb4ceabaffc631d7424ee55e56f280bc039737f89213 + url: "https://pub.dev" + source: hosted + version: "4.1.0" + rest_client: + dependency: transitive + description: + name: rest_client + sha256: "90473416250779b85f8d620e9dc277f38ea67acf84d3c6299e005ce08caedd69" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + ristretto255: + dependency: transitive + description: + name: ristretto255 + sha256: "3824d6786146dfb3b0783f305b714d36fa213c0d08e0ba864267baa0ede51cdd" + url: "https://pub.dev" + source: hosted + version: "1.0.2" rxdart: dependency: transitive description: @@ -585,6 +849,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.27.7" + secp256k1_ecdsa: + dependency: transitive + description: + name: secp256k1_ecdsa + sha256: "87008b4fd164d861b94b0edf2e01ffadd6f06769e1f0382e19bb091daecc0576" + url: "https://pub.dev" + source: hosted + version: "0.4.0" shared_preferences: dependency: "direct main" description: @@ -657,6 +929,15 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.7" + signer: + dependency: transitive + description: + path: "packages/signer" + ref: main + resolved-ref: "85f205055e8b0fecf9242147f44b4456cab5e71d" + url: "https://github.com/codescalers/tfgrid-sdk-dart.git" + source: git + version: "0.1.0" sky_engine: dependency: transitive description: flutter @@ -710,6 +991,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.10.0" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + sr25519: + dependency: transitive + description: + name: sr25519 + sha256: "266f7b2a4dd2d6a41a49924d41e80665f3b8340c157deff172f2b0cf64657a27" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + ss58: + dependency: transitive + description: + name: ss58 + sha256: b24d2713597b83708ef30daea5a565dba8bc9129031b30c025069e168301ae5e + url: "https://pub.dev" + source: hosted + version: "1.1.2" stack_trace: dependency: transitive description: @@ -718,6 +1023,21 @@ packages: url: "https://pub.dev" source: hosted version: "1.11.1" + stellar_client: + dependency: "direct main" + description: + path: "../../../codescalers/tfgrid-sdk-dart/packages/stellar_client" + relative: true + source: path + version: "0.1.0" + stellar_flutter_sdk: + dependency: transitive + description: + name: stellar_flutter_sdk + sha256: "7d505963fe11d0f90b3f798964c485ed9fa64731c38f14c9b2fb76d5d5bd6cd8" + url: "https://pub.dev" + source: hosted + version: "1.8.1" stream_channel: dependency: transitive description: @@ -734,6 +1054,30 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + strobe: + dependency: transitive + description: + name: strobe + sha256: a23adf7d305e45c6f210270aa925d8b404819144e29f7c5257a67281b63e0887 + url: "https://pub.dev" + source: hosted + version: "1.0.4" + substrate_bip39: + dependency: transitive + description: + name: substrate_bip39 + sha256: "29548105e939d1fb213aba96686eb5c5aae472249fa12b8dda58b252d23f492c" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + substrate_metadata: + dependency: transitive + description: + name: substrate_metadata + sha256: "4557950c7dcea17cdf7e1224ac7822ab38dd9658f000be6d58b4a41b0a8126d4" + url: "https://pub.dev" + source: hosted + version: "1.2.0" synchronized: dependency: transitive description: @@ -758,14 +1102,29 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.1" + tfchain_client: + dependency: "direct main" + description: + path: "../../../codescalers/tfgrid-sdk-dart/packages/tfchain_client" + relative: true + source: path + version: "0.1.0" + toml: + dependency: transitive + description: + name: toml + sha256: "69756bc12eccf279b72217a87310d217efc4b3752f722e890f672801f19ac485" + url: "https://pub.dev" + source: hosted + version: "0.13.1" typed_data: dependency: transitive description: name: typed_data - sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.3.2" uni_links: dependency: "direct main" description: @@ -798,6 +1157,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0+1" + unorm_dart: + dependency: transitive + description: + name: unorm_dart + sha256: "5b35bff83fce4d76467641438f9e867dc9bcfdb8c1694854f230579d68cd8f4b" + url: "https://pub.dev" + source: hosted + version: "0.2.0" + uri: + dependency: transitive + description: + name: uri + sha256: "889eea21e953187c6099802b7b4cf5219ba8f3518f604a1033064d45b1b8268a" + url: "https://pub.dev" + source: hosted + version: "1.0.0" url_launcher: dependency: "direct main" description: @@ -862,6 +1237,22 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" + utility: + dependency: transitive + description: + name: utility + sha256: "200d264c3804e87da7ea36aa81bd73fb845d2cb7b2e820f3f357a0a2bd4e37f5" + url: "https://pub.dev" + source: hosted + version: "1.0.3" + uuid: + dependency: transitive + description: + name: uuid + sha256: f33d6bb662f0e4f79dcd7ada2e6170f3b3a2530c28fc41f49a411ddedd576a77 + url: "https://pub.dev" + source: hosted + version: "4.5.0" vector_graphics: dependency: transitive description: @@ -894,6 +1285,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" web: dependency: transitive description: @@ -902,6 +1301,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.3.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" win32: dependency: transitive description: @@ -934,6 +1341,22 @@ packages: url: "https://pub.dev" source: hosted version: "6.3.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" + yaon: + dependency: transitive + description: + name: yaon + sha256: "7ffb8284eb13e448fdabf340209c306336cfeabdca97294c27b5a11237eaa3c4" + url: "https://pub.dev" + source: hosted + version: "1.1.4+10" sdks: - dart: ">=3.2.0-194.0.dev <4.0.0" + dart: ">=3.2.3 <4.0.0" flutter: ">=3.7.0" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 0498b550..7264c1df 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -16,7 +16,16 @@ dependencies: git: url: https://github.com/threefoldtech/threefold_connect_flutter_pkid_client ref: master - + tfchain_client: + git: + url: https://github.com/codescalers/tfgrid-sdk-dart + ref: main + path: packages/tfchain_client + stellar_client: + git: + url: https://github.com/codescalers/tfgrid-sdk-dart + ref: main + path: packages/stellar_client shuftipro_sdk: ^1.2.5 flutter_svg: ^2.0.6 bip39: ^1.0.6 @@ -50,6 +59,9 @@ dev_dependencies: sdk: flutter flutter_lints: ^2.0.0 +dependency_overrides: + intl: 0.19.0 + flutter: uses-material-design: true assets: From 27858cc5c40759b0bb267abdea7ae5a457307bfd Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 17:36:53 +0300 Subject: [PATCH 10/34] Add method for getting the user twin ID --- app/lib/services/tfchain_service.dart | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/lib/services/tfchain_service.dart diff --git a/app/lib/services/tfchain_service.dart b/app/lib/services/tfchain_service.dart new file mode 100644 index 00000000..6bb47061 --- /dev/null +++ b/app/lib/services/tfchain_service.dart @@ -0,0 +1,24 @@ +import 'package:threebotlogin/services/shared_preference_service.dart'; +import 'package:stellar_client/stellar_client.dart' as Stellar; +import 'package:convert/convert.dart'; +import 'package:tfchain_client/tfchain_client.dart' as TFChain; + +Future getTwinId() async { + final phrase = await getPhrase(); + if (phrase != null) { + final wallet = await Stellar.Client.createFromMnemonic( + Stellar.NetworkType.PUBLIC, phrase); + final privateKey = wallet.privateKey; + if (privateKey != null) { + final hexSecret = hex.encode(privateKey.toList().sublist(0, 32)); + // TODO: get the chain url from flagsmith + final tfchainClient = TFChain.Client( + "wss://tfchain.dev.grid.tf/ws", '0x$hexSecret', "sr25519"); + await tfchainClient.connect(); + final twinId = await tfchainClient.twins.getMyTwinId(); + await tfchainClient.disconnect(); + return twinId; + } + } + return null; +} From 8f67692ae2ef95b477a085deced8c5a4942eda44 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 17:37:38 +0300 Subject: [PATCH 11/34] Add mehtods for setting and getting the twinId from the device storage --- app/lib/services/shared_preference_service.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/lib/services/shared_preference_service.dart b/app/lib/services/shared_preference_service.dart index 027edeae..1092c740 100644 --- a/app/lib/services/shared_preference_service.dart +++ b/app/lib/services/shared_preference_service.dart @@ -121,6 +121,19 @@ Future getPhrase() async { return prefs.getString('phrase'); } +Future saveTwinId(int twinId) async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + prefs.remove('twinId'); + + prefs.setInt('twinId', twinId); + updateUserData("twinId", twinId as String); +} + +Future getTwinId() async { + final SharedPreferences prefs = await SharedPreferences.getInstance(); + return prefs.getInt('twinId'); +} + /// /// /// Email methods in Shared Preferences From 37a1430957c8ba6329916c8267d961d2c9bdd20f Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 17:41:46 +0300 Subject: [PATCH 12/34] Load twin details while staring the app --- app/lib/helpers/globals.dart | 1 + app/lib/screens/main_screen.dart | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index fb0daa25..ba2f9142 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -60,6 +60,7 @@ class Globals { int smsSentOn = 0; int smsMinutesCoolDown = 5; + int twinId = 0; ValueNotifier hidePhoneButton = ValueNotifier(false); diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index b699d36d..aaf380f6 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -18,6 +18,7 @@ import 'package:threebotlogin/services/shared_preference_service.dart'; import 'package:threebotlogin/widgets/error_widget.dart'; import 'package:threebotlogin/widgets/home_logo.dart'; import 'package:uni_links/uni_links.dart'; +import 'package:threebotlogin/services/tfchain_service.dart' as TFChain; class MainScreen extends StatefulWidget { const MainScreen({super.key, this.initDone, this.registered}); @@ -185,6 +186,8 @@ class _AppState extends State { print(mounted); Navigator.of(context).popUntil((route) => route.isFirst); + await loadTwinId(); + // await Navigator.push(context, MaterialPageRoute(builder: (context) => UnregisteredScreen())); await Navigator.of(context).pushReplacement(PageRouteBuilder( transitionDuration: Duration(seconds: 1), @@ -294,4 +297,15 @@ class _AppState extends State { initialLink = incomingLink; }); } + + Future loadTwinId() async { + int? twinId = await getTwinId(); + if (twinId != null) { + twinId = await TFChain.getTwinId(); + if (twinId != null) { + await saveTwinId(twinId); + Globals().twinId = twinId; + } + } + } } From 803bd81f3e14c7811c37998aa820b76bdb2edfc0 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 18:36:34 +0300 Subject: [PATCH 13/34] Add chain url to flagsmith --- app/lib/app_config.dart | 1 + app/lib/helpers/flags.dart | 2 ++ app/lib/helpers/globals.dart | 1 + app/lib/services/tfchain_service.dart | 7 ++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/lib/app_config.dart b/app/lib/app_config.dart index 932dfe06..b9a82157 100644 --- a/app/lib/app_config.dart +++ b/app/lib/app_config.dart @@ -215,4 +215,5 @@ void setFallbackConfigs() { Globals().redoIdentityVerification = false; Globals().timeOutSeconds = 10; Globals().phoneVerification = false; + Globals().chainUrl = ''; } diff --git a/app/lib/helpers/flags.dart b/app/lib/helpers/flags.dart index 7793d123..65465994 100644 --- a/app/lib/helpers/flags.dart +++ b/app/lib/helpers/flags.dart @@ -60,6 +60,8 @@ class Flags { await Flags().hasFlagValueByFeatureName('redo-identity-verification'); Globals().phoneVerification = await Flags().hasFlagValueByFeatureName('phone-verification'); + Globals().chainUrl = + (await Flags().getFlagValueByFeatureName('chain-url'))!; } Future hasFlagValueByFeatureName(String name) async { diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index ba2f9142..80d35a84 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -54,6 +54,7 @@ class Globals { String tosUrl = ''; bool maintenance = false; bool phoneVerification = false; + String chainUrl = ''; bool isCacheClearedWallet = false; bool isCacheClearedFarmer = false; diff --git a/app/lib/services/tfchain_service.dart b/app/lib/services/tfchain_service.dart index 6bb47061..cd92ef77 100644 --- a/app/lib/services/tfchain_service.dart +++ b/app/lib/services/tfchain_service.dart @@ -1,9 +1,12 @@ +import 'package:threebotlogin/helpers/globals.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; import 'package:stellar_client/stellar_client.dart' as Stellar; import 'package:convert/convert.dart'; import 'package:tfchain_client/tfchain_client.dart' as TFChain; Future getTwinId() async { + final chainUrl = Globals().chainUrl; + if (chainUrl == '') return null; final phrase = await getPhrase(); if (phrase != null) { final wallet = await Stellar.Client.createFromMnemonic( @@ -11,9 +14,7 @@ Future getTwinId() async { final privateKey = wallet.privateKey; if (privateKey != null) { final hexSecret = hex.encode(privateKey.toList().sublist(0, 32)); - // TODO: get the chain url from flagsmith - final tfchainClient = TFChain.Client( - "wss://tfchain.dev.grid.tf/ws", '0x$hexSecret', "sr25519"); + final tfchainClient = TFChain.Client(chainUrl, '0x$hexSecret', "sr25519"); await tfchainClient.connect(); final twinId = await tfchainClient.twins.getMyTwinId(); await tfchainClient.disconnect(); From f2a501e14912c9a6598945fd04831e9bcf895023 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 18:38:02 +0300 Subject: [PATCH 14/34] Fix casting while saving the twin ID in the device storage --- app/lib/services/shared_preference_service.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/services/shared_preference_service.dart b/app/lib/services/shared_preference_service.dart index 1092c740..44ada36d 100644 --- a/app/lib/services/shared_preference_service.dart +++ b/app/lib/services/shared_preference_service.dart @@ -126,7 +126,7 @@ Future saveTwinId(int twinId) async { prefs.remove('twinId'); prefs.setInt('twinId', twinId); - updateUserData("twinId", twinId as String); + updateUserData("twinId", twinId.toString()); } Future getTwinId() async { From f7fa84c90340bacfe25923b5de7c99fd70bd8d92 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 4 Sep 2024 18:38:30 +0300 Subject: [PATCH 15/34] Fix the condition of loading the twin ID --- app/lib/screens/main_screen.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index aaf380f6..dbf06a9a 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -300,7 +300,7 @@ class _AppState extends State { Future loadTwinId() async { int? twinId = await getTwinId(); - if (twinId != null) { + if (twinId == null || twinId == 0) { twinId = await TFChain.getTwinId(); if (twinId != null) { await saveTwinId(twinId); From ee79c8ea72a6ab05597838043b19a84fbcbd82eb Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Thu, 5 Sep 2024 10:34:27 +0300 Subject: [PATCH 16/34] Add spending limit to the flagsmith flags --- app/lib/app_config.dart | 1 + app/lib/helpers/flags.dart | 2 ++ app/lib/helpers/globals.dart | 1 + 3 files changed, 4 insertions(+) diff --git a/app/lib/app_config.dart b/app/lib/app_config.dart index b9a82157..ddcd9252 100644 --- a/app/lib/app_config.dart +++ b/app/lib/app_config.dart @@ -216,4 +216,5 @@ void setFallbackConfigs() { Globals().timeOutSeconds = 10; Globals().phoneVerification = false; Globals().chainUrl = ''; + Globals().timeOutSeconds = 0; } diff --git a/app/lib/helpers/flags.dart b/app/lib/helpers/flags.dart index 65465994..34aa6b9f 100644 --- a/app/lib/helpers/flags.dart +++ b/app/lib/helpers/flags.dart @@ -62,6 +62,8 @@ class Flags { await Flags().hasFlagValueByFeatureName('phone-verification'); Globals().chainUrl = (await Flags().getFlagValueByFeatureName('chain-url'))!; + Globals().spendingLimit = int.parse( + (await Flags().getFlagValueByFeatureName('spending-limit')).toString()); } Future hasFlagValueByFeatureName(String name) async { diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index 80d35a84..9a5d1a62 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -62,6 +62,7 @@ class Globals { int smsSentOn = 0; int smsMinutesCoolDown = 5; int twinId = 0; + int spendingLimit = 0; ValueNotifier hidePhoneButton = ValueNotifier(false); From 7a3f9fb21e999bfc0e3ba4501c31d38e477bf7d1 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 11:31:25 +0300 Subject: [PATCH 17/34] Add gridproxy client to the app --- app/pubspec.lock | 173 +++++++++++++++++++++++++++++++++++++++++++++-- app/pubspec.yaml | 8 ++- 2 files changed, 173 insertions(+), 8 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 016a493f..1302fd6a 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -5,10 +5,10 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" url: "https://pub.dev" source: hosted - version: "64.0.0" + version: "67.0.0" adaptive_number: dependency: transitive description: @@ -21,10 +21,10 @@ packages: dependency: transitive description: name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" url: "https://pub.dev" source: hosted - version: "6.2.0" + version: "6.4.1" args: dependency: transitive description: @@ -81,6 +81,54 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: transitive + description: + name: build_runner + sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22" + url: "https://pub.dev" + source: hosted + version: "2.4.9" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "30859c90e9ddaccc484f56303931f477b1f1ba2bab74aa32ed5d6ce15870f8cf" + url: "https://pub.dev" + source: hosted + version: "7.2.8" built_collection: dependency: transitive description: @@ -105,6 +153,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" clock: dependency: transitive description: @@ -377,6 +433,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" glob: dependency: transitive description: @@ -393,6 +457,21 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + gridproxy_client: + dependency: "direct main" + description: + path: "../../../codescalers/tfgrid-sdk-dart/packages/gridproxy_client" + relative: true + source: path + version: "1.0.0" hashlib: dependency: transitive description: @@ -433,6 +512,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" http_parser: dependency: transitive description: @@ -457,6 +544,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" js: dependency: transitive description: @@ -530,13 +625,21 @@ packages: source: hosted version: "1.0.3" meta: - dependency: transitive + dependency: "direct overridden" description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.15.0" + mime: + dependency: transitive + description: + name: mime + sha256: "801fd0b26f14a4a58ccb09d5892c3fbdeff209594300a542492cf13fba9d247a" + url: "https://pub.dev" + source: hosted + version: "1.0.6" moment_dart: dependency: transitive description: @@ -777,6 +880,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" process: dependency: transitive description: @@ -793,6 +904,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + url: "https://pub.dev" + source: hosted + version: "1.2.1" qr_code_scanner: dependency: "direct main" description: @@ -825,6 +944,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + reflectable: + dependency: transitive + description: + name: reflectable + sha256: cdc1a278a2e9769abafaf9ba54ce1fd3432b2a38360e14b87ea6344f715340de + url: "https://pub.dev" + source: hosted + version: "4.0.6" rest_client: dependency: transitive description: @@ -921,6 +1048,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" shuftipro_sdk: dependency: "direct main" description: @@ -1046,6 +1189,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -1109,6 +1260,14 @@ packages: relative: true source: path version: "0.1.0" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" toml: dependency: transitive description: diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 7264c1df..b7dcb323 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -26,6 +26,11 @@ dependencies: url: https://github.com/codescalers/tfgrid-sdk-dart ref: main path: packages/stellar_client + gridproxy_client: + git: + url: https://github.com/codescalers/tfgrid-sdk-dart + ref: main + path: packages/gridproxy_client shuftipro_sdk: ^1.2.5 flutter_svg: ^2.0.6 bip39: ^1.0.6 @@ -60,7 +65,8 @@ dev_dependencies: flutter_lints: ^2.0.0 dependency_overrides: - intl: 0.19.0 + intl: ^0.19.0 + meta: ^1.11.0 flutter: uses-material-design: true From 888894e9724493ed88812033738f04a79e523b11 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 11:37:00 +0300 Subject: [PATCH 18/34] Fix loading twin id --- app/lib/screens/main_screen.dart | 4 ++-- app/lib/services/tfchain_service.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index dbf06a9a..5e91b632 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -301,11 +301,11 @@ class _AppState extends State { Future loadTwinId() async { int? twinId = await getTwinId(); if (twinId == null || twinId == 0) { - twinId = await TFChain.getTwinId(); + twinId = await TFChain.getMyTwinId(); if (twinId != null) { await saveTwinId(twinId); - Globals().twinId = twinId; } } + Globals().twinId = twinId ?? 0; } } diff --git a/app/lib/services/tfchain_service.dart b/app/lib/services/tfchain_service.dart index cd92ef77..fd4a347d 100644 --- a/app/lib/services/tfchain_service.dart +++ b/app/lib/services/tfchain_service.dart @@ -4,7 +4,7 @@ import 'package:stellar_client/stellar_client.dart' as Stellar; import 'package:convert/convert.dart'; import 'package:tfchain_client/tfchain_client.dart' as TFChain; -Future getTwinId() async { +Future getMyTwinId() async { final chainUrl = Globals().chainUrl; if (chainUrl == '') return null; final phrase = await getPhrase(); From 155f50bfc29e1802b5c11cf3306be402fe740806 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 11:38:06 +0300 Subject: [PATCH 19/34] Add method to get the user consumption on tfchain --- app/lib/services/gridproxy_service.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/lib/services/gridproxy_service.dart diff --git a/app/lib/services/gridproxy_service.dart b/app/lib/services/gridproxy_service.dart new file mode 100644 index 00000000..80be62f4 --- /dev/null +++ b/app/lib/services/gridproxy_service.dart @@ -0,0 +1,10 @@ +import 'package:gridproxy_client/gridproxy_client.dart'; +import 'package:threebotlogin/services/shared_preference_service.dart'; + +Future getMySpending() async { + final twinId = await getTwinId(); + if (twinId == null) return 0.0; + final gridProxyClient = GridProxyClient("https://gridproxy.dev.grid.tf"); + final spending = await gridProxyClient.twins.getConsumption(twinID: twinId); + return spending.overall_consumption; +} From 43d691c62d34c58cfec5d66d289fc9361f55fa32 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 12:23:30 +0300 Subject: [PATCH 20/34] Add catch block with error snackbar for loading the twin --- app/lib/screens/main_screen.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index 5e91b632..988b4240 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -186,7 +186,16 @@ class _AppState extends State { print(mounted); Navigator.of(context).popUntil((route) => route.isFirst); - await loadTwinId(); + try { + await loadTwinId(); + } catch (e) { + const loadingTwinFailure = SnackBar( + content: Text('Failed to load twin information'), + duration: Duration(seconds: 1), + ); + ScaffoldMessenger.of(context).showSnackBar(loadingTwinFailure); + print('Failed to load twin information due to $e'); + } // await Navigator.push(context, MaterialPageRoute(builder: (context) => UnregisteredScreen())); await Navigator.of(context).pushReplacement(PageRouteBuilder( From c2fd97eb75019baad77bf259b90bc4f6430d89fb Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 12:24:33 +0300 Subject: [PATCH 21/34] Show the phone and identity verification based on the user spending --- .../screens/identity_verification_screen.dart | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 1abd0df4..0d1c881b 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -10,6 +10,7 @@ import 'package:threebotlogin/events/identity_callback_event.dart'; import 'package:threebotlogin/helpers/globals.dart'; import 'package:threebotlogin/helpers/kyc_helpers.dart'; import 'package:threebotlogin/main.dart'; +import 'package:threebotlogin/services/gridproxy_service.dart'; import 'package:threebotlogin/services/identity_service.dart'; import 'package:threebotlogin/services/open_kyc_service.dart'; import 'package:threebotlogin/services/pkid_service.dart'; @@ -128,6 +129,7 @@ class _IdentityVerificationScreenState 'text': 'My name is John Doe and I authorize this transaction of \$100/-', }, }; + double spending = 0.0; setEmailVerified() { if (mounted) { @@ -254,7 +256,9 @@ class _IdentityVerificationScreenState Icons.email), // Step two: verify phone - Globals().phoneVerification == true + (Globals().phoneVerification == true || + (Globals().spendingLimit > 0 && + spending > Globals().spendingLimit)) ? _fillCard( getCorrectState(2, emailVerified, phoneVerified, identityVerified), @@ -264,7 +268,9 @@ class _IdentityVerificationScreenState : Container(), // Step three: verify identity - Globals().isOpenKYCEnabled + (Globals().isOpenKYCEnabled || + (Globals().spendingLimit > 0 && + spending > Globals().spendingLimit)) ? _fillCard( getCorrectState(3, emailVerified, phoneVerified, identityVerified), @@ -1610,4 +1616,19 @@ class _IdentityVerificationScreenState phoneSendDialog(context); } + + Future getSpending() async { + try { + final mySpending = await getMySpending(); + setState(() { + spending = mySpending; + }); + } catch (e) { + const loadingSpendingFailure = SnackBar( + content: Text('Failed to load user spending'), + duration: Duration(seconds: 1), + ); + ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure); + } + } } From f6d11e4b3ab29edd23b15bff070a0a8cea60fb90 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 12:32:50 +0300 Subject: [PATCH 22/34] Add grid proxy url to flagsmith --- app/lib/app_config.dart | 1 + app/lib/helpers/flags.dart | 2 ++ app/lib/helpers/globals.dart | 1 + app/lib/services/gridproxy_service.dart | 5 ++++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/lib/app_config.dart b/app/lib/app_config.dart index ddcd9252..96ab8868 100644 --- a/app/lib/app_config.dart +++ b/app/lib/app_config.dart @@ -216,5 +216,6 @@ void setFallbackConfigs() { Globals().timeOutSeconds = 10; Globals().phoneVerification = false; Globals().chainUrl = ''; + Globals().gridproxyUrl = ''; Globals().timeOutSeconds = 0; } diff --git a/app/lib/helpers/flags.dart b/app/lib/helpers/flags.dart index 34aa6b9f..5bdfdbf6 100644 --- a/app/lib/helpers/flags.dart +++ b/app/lib/helpers/flags.dart @@ -62,6 +62,8 @@ class Flags { await Flags().hasFlagValueByFeatureName('phone-verification'); Globals().chainUrl = (await Flags().getFlagValueByFeatureName('chain-url'))!; + Globals().gridproxyUrl = + (await Flags().getFlagValueByFeatureName('gridproxy-url'))!; Globals().spendingLimit = int.parse( (await Flags().getFlagValueByFeatureName('spending-limit')).toString()); } diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index 9a5d1a62..82e9aa53 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -55,6 +55,7 @@ class Globals { bool maintenance = false; bool phoneVerification = false; String chainUrl = ''; + String gridproxyUrl = ''; bool isCacheClearedWallet = false; bool isCacheClearedFarmer = false; diff --git a/app/lib/services/gridproxy_service.dart b/app/lib/services/gridproxy_service.dart index 80be62f4..4da6fe1b 100644 --- a/app/lib/services/gridproxy_service.dart +++ b/app/lib/services/gridproxy_service.dart @@ -1,10 +1,13 @@ import 'package:gridproxy_client/gridproxy_client.dart'; +import 'package:threebotlogin/helpers/globals.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; Future getMySpending() async { + final gridproxyUrl = Globals().gridproxyUrl; + if (gridproxyUrl == '') return 0.0; final twinId = await getTwinId(); if (twinId == null) return 0.0; - final gridProxyClient = GridProxyClient("https://gridproxy.dev.grid.tf"); + final gridProxyClient = GridProxyClient(gridproxyUrl); final spending = await gridProxyClient.twins.getConsumption(twinID: twinId); return spending.overall_consumption; } From 5f0644a3978f4e37b6edc85f6911e884ca14fb65 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Sun, 8 Sep 2024 18:54:38 +0300 Subject: [PATCH 23/34] Format the snack bar --- .../screens/identity_verification_screen.dart | 26 +++++++++++++------ app/lib/screens/main_screen.dart | 15 ++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 0d1c881b..d544b05b 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -217,6 +217,11 @@ class _IdentityVerificationScreenState } }); }); + getSpending().then((mySpending) => { + setState(() { + spending = mySpending; + }) + }); } @override @@ -1617,18 +1622,23 @@ class _IdentityVerificationScreenState phoneSendDialog(context); } - Future getSpending() async { + Future getSpending() async { try { - final mySpending = await getMySpending(); - setState(() { - spending = mySpending; - }); + return await getMySpending(); } catch (e) { - const loadingSpendingFailure = SnackBar( - content: Text('Failed to load user spending'), - duration: Duration(seconds: 1), + final loadingSpendingFailure = SnackBar( + content: Text( + 'Failed to load user spending', + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(color: Theme.of(context).colorScheme.errorContainer), + ), + duration: Duration(seconds: 2), ); + ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure); + return 0.0; } } } diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index 988b4240..75bc7daa 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -186,13 +186,22 @@ class _AppState extends State { print(mounted); Navigator.of(context).popUntil((route) => route.isFirst); + updateMessage = 'Fetching user data'; + setState(() {}); try { await loadTwinId(); } catch (e) { - const loadingTwinFailure = SnackBar( - content: Text('Failed to load twin information'), - duration: Duration(seconds: 1), + final loadingTwinFailure = SnackBar( + content: Text( + 'Failed to load twin information', + style: Theme.of(context) + .textTheme + .bodyMedium! + .copyWith(color: Theme.of(context).colorScheme.errorContainer), + ), + duration: Duration(seconds: 2), ); + ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).showSnackBar(loadingTwinFailure); print('Failed to load twin information due to $e'); } From 9236bf5b0e9183cce9eeeafbb8fc00214340f3a4 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 08:50:24 +0300 Subject: [PATCH 24/34] Use compute to not block the main thread and the ui --- app/lib/services/tfchain_service.dart | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/app/lib/services/tfchain_service.dart b/app/lib/services/tfchain_service.dart index fd4a347d..6d238eaf 100644 --- a/app/lib/services/tfchain_service.dart +++ b/app/lib/services/tfchain_service.dart @@ -1,3 +1,5 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; import 'package:threebotlogin/helpers/globals.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; import 'package:stellar_client/stellar_client.dart' as Stellar; @@ -9,17 +11,23 @@ Future getMyTwinId() async { if (chainUrl == '') return null; final phrase = await getPhrase(); if (phrase != null) { - final wallet = await Stellar.Client.createFromMnemonic( - Stellar.NetworkType.PUBLIC, phrase); - final privateKey = wallet.privateKey; - if (privateKey != null) { - final hexSecret = hex.encode(privateKey.toList().sublist(0, 32)); - final tfchainClient = TFChain.Client(chainUrl, '0x$hexSecret', "sr25519"); - await tfchainClient.connect(); - final twinId = await tfchainClient.twins.getMyTwinId(); - await tfchainClient.disconnect(); - return twinId; - } + final token = RootIsolateToken.instance; + return await compute((dynamic token) async { + BackgroundIsolateBinaryMessenger.ensureInitialized(token); + final wallet = await Stellar.Client.createFromMnemonic( + Stellar.NetworkType.PUBLIC, phrase); + final privateKey = wallet.privateKey; + if (privateKey != null) { + final hexSecret = hex.encode(privateKey.toList().sublist(0, 32)); + final tfchainClient = + TFChain.Client(chainUrl, '0x$hexSecret', "sr25519"); + await tfchainClient.connect(); + final twinId = await tfchainClient.twins.getMyTwinId(); + await tfchainClient.disconnect(); + return twinId; + } + return null; + }, token); } return null; } From 9f7ebbe8b8733cde360fc1ad527c89750885fcff Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 08:51:37 +0300 Subject: [PATCH 25/34] Increase the snackbar duration --- app/lib/screens/identity_verification_screen.dart | 3 ++- app/lib/screens/main_screen.dart | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index d544b05b..e0db055a 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -1634,10 +1634,11 @@ class _IdentityVerificationScreenState .bodyMedium! .copyWith(color: Theme.of(context).colorScheme.errorContainer), ), - duration: Duration(seconds: 2), + duration: const Duration(seconds: 3), ); ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure); + print('Failed to load user spending due to $e'); return 0.0; } } diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index 75bc7daa..84a3994b 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -199,7 +199,7 @@ class _AppState extends State { .bodyMedium! .copyWith(color: Theme.of(context).colorScheme.errorContainer), ), - duration: Duration(seconds: 2), + duration: const Duration(seconds: 3), ); ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).showSnackBar(loadingTwinFailure); From 52ec1096f6f11e46f6a5c90782c63c9d45cacad7 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 14:47:10 +0300 Subject: [PATCH 26/34] Only update the UI if the spending limit > 0 --- .gitignore | 8 +++++++- app/lib/screens/identity_verification_screen.dart | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 76f5983b..8b7172f8 100644 --- a/.gitignore +++ b/.gitignore @@ -347,4 +347,10 @@ backend/services/__pycache__/productkeys.cpython-39.pyc backend/services/__pycache__/socket.cpython-39.pyc *.pyc -.vscode \ No newline at end of file +.vscode + +# reflected files +app/lib/main.reflectable.dart + +# pubSpec override +app/pubspec_overrides.yaml diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index e0db055a..b318afc8 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -218,9 +218,12 @@ class _IdentityVerificationScreenState }); }); getSpending().then((mySpending) => { - setState(() { - spending = mySpending; - }) + if (Globals().spendingLimit > 0) + { + setState(() { + spending = mySpending; + }) + } }); } From 5a2c3e80e5283503f5b870e8044137bcf293719c Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 14:48:03 +0300 Subject: [PATCH 27/34] Add build runner package and upgrade the packages --- app/pubspec.lock | 312 +++++++++++++++++++++++------------------------ app/pubspec.yaml | 1 + 2 files changed, 153 insertions(+), 160 deletions(-) diff --git a/app/pubspec.lock b/app/pubspec.lock index 1302fd6a..d902b162 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -29,18 +29,18 @@ packages: dependency: transitive description: name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a" url: "https://pub.dev" source: hosted - version: "2.4.2" + version: "2.5.0" asn1lib: dependency: transitive description: name: asn1lib - sha256: ab96a1cb3beeccf8145c52e449233fe68364c9641623acd3adad66f8184f1039 + sha256: "58082b3f0dca697204dbab0ef9ff208bfaea7767ea771076af9a343488428dda" url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.5.3" async: dependency: transitive description: @@ -114,7 +114,7 @@ packages: source: hosted version: "2.4.2" build_runner: - dependency: transitive + dependency: "direct main" description: name: build_runner sha256: "3ac61a79bfb6f6cc11f693591063a7f19a7af628dc52f141743edac5c16e8c22" @@ -125,10 +125,10 @@ packages: dependency: transitive description: name: build_runner_core - sha256: "30859c90e9ddaccc484f56303931f477b1f1ba2bab74aa32ed5d6ce15870f8cf" + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" url: "https://pub.dev" source: hosted - version: "7.2.8" + version: "7.3.0" built_collection: dependency: transitive description: @@ -197,10 +197,10 @@ packages: dependency: "direct main" description: name: country_picker - sha256: aa975b41c8052298d227ff7ff58d6eddcad0196127445f72af7456224c9ef104 + sha256: "327f5e15a76352089a6b5057abb761ee5202e7516c9440d8d6a7524139f9b14e" url: "https://pub.dev" source: hosted - version: "2.0.20" + version: "2.0.26" crypto: dependency: transitive description: @@ -221,18 +221,18 @@ packages: dependency: transitive description: name: csslib - sha256: "831883fb353c8bdc1d71979e5b342c7d88acfbc643113c14ae51e2442ea0f20f" + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" url: "https://pub.dev" source: hosted - version: "0.17.3" + version: "1.0.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6 url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.8" dart_style: dependency: transitive description: @@ -253,26 +253,34 @@ packages: dependency: "direct main" description: name: device_info_plus - sha256: "2c35b6d1682b028e42d07b3aee4b98fa62996c10bc12cb651ec856a80d6a761b" + sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110" url: "https://pub.dev" source: hosted - version: "9.0.2" + version: "9.1.2" device_info_plus_platform_interface: dependency: transitive description: name: device_info_plus_platform_interface - sha256: d3b01d5868b50ae571cd1dc6e502fc94d956b665756180f7b16ead09e836fd64 + sha256: "282d3cf731045a2feb66abfe61bbc40870ae50a3ed10a4d3d217556c35c8c2ba" url: "https://pub.dev" source: hosted - version: "7.0.0" + version: "7.0.1" dio: dependency: "direct main" description: name: dio - sha256: "347d56c26d63519552ef9a569f2a593dda99a81fdbdff13c584b7197cfe05059" + sha256: "5598aa796bbf4699afd5c67c0f5f6e2ed542afc956884b9cd58c306966efc260" + url: "https://pub.dev" + source: hosted + version: "5.7.0" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "36c5b2d79eb17cdae41e974b7a8284fec631651d2a6f39a8a2ff22327e90aeac" url: "https://pub.dev" source: hosted - version: "5.1.2" + version: "1.0.1" ed25519_edwards: dependency: transitive description: @@ -293,10 +301,10 @@ packages: dependency: transitive description: name: encrypt - sha256: "4fd4e4fdc21b9d7d4141823e1e6515cd94e7b8d84749504c232999fba25d9bbb" + sha256: "62d9aa4670cc2a8798bab89b39fc71b6dfbacf615de6cf5001fb39f7e4a996a2" url: "https://pub.dev" source: hosted - version: "5.0.1" + version: "5.0.3" equatable: dependency: transitive description: @@ -325,10 +333,10 @@ packages: dependency: transitive description: name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" url: "https://pub.dev" source: hosted - version: "6.1.4" + version: "7.0.0" fixnum: dependency: transitive description: @@ -370,10 +378,10 @@ packages: dependency: "direct main" description: name: flutter_inappwebview - sha256: "1c1bfdde3d06c7177b65af20dbe66219f278abebf6e7d90b54440e21c0aac631" + sha256: d198297060d116b94048301ee6749cd2e7d03c1f2689783f52d210a6b7aba350 url: "https://pub.dev" source: hosted - version: "5.6.0+2" + version: "5.8.0" flutter_json_viewer: dependency: "direct main" description: @@ -386,16 +394,16 @@ packages: 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_pkid: dependency: "direct main" description: path: "." ref: master - resolved-ref: "6be967a41bb54333d40a88f2f34f63b601056941" + resolved-ref: "57827618dd0dda003b86ecb1d6c4ddb015fdad5f" url: "https://github.com/threefoldtech/threefold_connect_flutter_pkid_client" source: git version: "0.0.1" @@ -403,18 +411,18 @@ packages: dependency: transitive description: name: flutter_plugin_android_lifecycle - sha256: "60fc7b78455b94e6de2333d2f95196d32cf5c22f4b0b0520a628804cb463503b" + sha256: "8cf40eebf5dec866a6d1956ad7b4f7016e6c0cc69847ab946833b7d43743809f" url: "https://pub.dev" source: hosted - version: "2.0.7" + version: "2.0.19" flutter_svg: dependency: "direct main" description: name: flutter_svg - sha256: "6ff8c902c8056af9736de2689f63f81c42e2d642b9f4c79dbf8790ae48b63012" + sha256: "7b4ca6cf3304575fe9c8ec64813c8d02ee41d2afe60bcfe0678bcb5375d596a2" url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.0.10+1" flutter_test: dependency: "direct dev" description: flutter @@ -429,10 +437,10 @@ packages: dependency: transitive description: name: freezed_annotation - sha256: aeac15850ef1b38ee368d4c53ba9a847e900bb2c53a4db3f6881cbb3cb684338 + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.4.4" frontend_server_client: dependency: transitive description: @@ -453,10 +461,10 @@ packages: dependency: "direct main" description: name: google_fonts - sha256: db5efba8106bd784a92c96cfd81716f4e06baab54e37de858488e9a00a764cad + sha256: e20ff62b158b96f392bfc8afe29dee1503c94fbea2cbe8186fd59b756b8ae982 url: "https://pub.dev" source: hosted - version: "5.0.0" + version: "5.1.0" graphs: dependency: transitive description: @@ -476,10 +484,10 @@ packages: dependency: transitive description: name: hashlib - sha256: d41795742c10947930630118c6836608deeb9047cd05aee32d2baeb697afd66a + sha256: "7431346983b7c18fa3d6107891b7f00da4fffc378eed8454a0c9e17961164ffd" url: "https://pub.dev" source: hosted - version: "1.19.2" + version: "1.20.2" hashlib_codecs: dependency: transitive description: @@ -500,10 +508,10 @@ packages: dependency: transitive description: name: html - sha256: "58e3491f7bf0b6a4ea5110c0c688877460d1a6366731155c4a4580e7ded773e8" + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" url: "https://pub.dev" source: hosted - version: "0.15.3" + version: "0.15.4" http: dependency: "direct main" description: @@ -540,10 +548,10 @@ packages: dependency: "direct main" description: name: intl_phone_field - sha256: "0d2b35d148ed28a454d50797e6c2fb297f0a295feab84641b02d3dd32294b3f3" + sha256: "73819d3dfcb68d2c85663606f6842597c3ddf6688ac777f051b17814fe767bbf" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.2.0" io: dependency: transitive description: @@ -564,10 +572,10 @@ packages: dependency: transitive description: name: json_annotation - sha256: cb314f00b2488de7bc575207e54402cd2f92363f333a7933fd1b0631af226baa + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" url: "https://pub.dev" source: hosted - version: "4.6.0" + version: "4.9.0" json_schema2: dependency: transitive description: @@ -580,10 +588,10 @@ packages: dependency: transitive description: name: lints - sha256: "5e4a9cd06d447758280a8ac2405101e0e2094d2a1dbdd3756aec3fe7775ba593" + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "2.1.1" local_auth: dependency: "direct main" description: @@ -652,10 +660,10 @@ packages: dependency: "direct main" description: name: open_filex - sha256: "854aefd72dfd74219dc8c8d1767c34ec1eae64b8399a5be317bddb1ec2108915" + sha256: ba425ea49affd0a98a234aa9344b9ea5d4c4f7625a1377961eae9fe194c3d523 url: "https://pub.dev" source: hosted - version: "4.3.2" + version: "4.5.0" package_config: dependency: transitive description: @@ -668,10 +676,10 @@ packages: dependency: "direct main" description: name: package_info_plus - sha256: ceb027f6bc6a60674a233b4a90a7658af1aebdea833da0b5b53c1e9821a78c7b + sha256: "7e76fad405b3e4016cd39d08f455a4eb5199723cf594cd1b8916d47140d93017" url: "https://pub.dev" source: hosted - version: "4.0.2" + version: "4.2.0" package_info_plus_platform_interface: dependency: transitive description: @@ -700,58 +708,50 @@ packages: dependency: "direct main" description: name: path_provider - sha256: "050e8e85e4b7fecdf2bb3682c1c64c4887a183720c802d323de8a5fd76d372dd" + sha256: fec0d61223fba3154d87759e3cc27fe2c8dc498f6386c6d6fc80d1afdd1bf378 url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.1.4" path_provider_android: dependency: transitive description: name: path_provider_android - sha256: "4d5542667150f5b779ba411dd5dc0b674a85d1355e45bda2877e0e82f4ad08d8" + sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d url: "https://pub.dev" source: hosted - version: "2.0.20" - path_provider_ios: + version: "2.2.4" + path_provider_foundation: dependency: transitive description: - name: path_provider_ios - sha256: "03d639406f5343478352433f00d3c4394d52dac8df3d847869c5e2333e0bbce8" + name: path_provider_foundation + sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f" url: "https://pub.dev" source: hosted - version: "2.0.11" + version: "2.3.2" path_provider_linux: dependency: transitive description: name: path_provider_linux - sha256: ab0987bf95bc591da42dffb38c77398fc43309f0b9b894dcc5d6f40c4b26c379 - url: "https://pub.dev" - source: hosted - version: "2.1.7" - path_provider_macos: - dependency: transitive - description: - name: path_provider_macos - sha256: "2a97e7fbb7ae9dcd0dfc1220a78e9ec3e71da691912e617e8715ff2a13086ae8" + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.2.1" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface - sha256: "27dc7a224fcd07444cb5e0e60423ccacea3e13cf00fc5282ac2c918132da931d" + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.1.2" path_provider_windows: dependency: transitive description: name: path_provider_windows - sha256: d3f80b32e83ec208ac95253e0cd4d298e104fbc63cb29c5c69edaed43b0c69d6 + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 url: "https://pub.dev" source: hosted - version: "2.1.6" + version: "2.3.0" pbkdf2ns: dependency: "direct main" description: @@ -764,42 +764,42 @@ packages: 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: f1044cf68ae3a56b31854b7b3e022d5a50dd78b5a28bba5287bcf1d9e3e62537 + sha256: "59c6322171c29df93a22d150ad95f3aa19ed86542eaec409ab2691b8f35f9a47" url: "https://pub.dev" source: hosted - version: "10.2.2" + version: "10.3.6" permission_handler_apple: dependency: transitive description: name: permission_handler_apple - sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85 + sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5" url: "https://pub.dev" source: hosted - version: "9.0.8" + 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" petitparser: dependency: transitive description: @@ -828,18 +828,18 @@ packages: dependency: transitive description: name: platform - sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76" + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.5" 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" pointycastle: dependency: transitive description: @@ -888,14 +888,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" - process: - dependency: transitive - description: - name: process - sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09" - url: "https://pub.dev" - source: hosted - version: "4.2.4" pub_semver: dependency: transitive description: @@ -908,10 +900,10 @@ packages: dependency: transitive description: name: pubspec_parse - sha256: "75f6614d6dde2dc68948dffbaa4fe5dae32cd700eb9fb763fe11dfb45a3c4d0a" + sha256: c799b721d79eb6ee6fa56f00c04b472dcd44a30d258fac2174a6ec57302678f8 url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.3.0" qr_code_scanner: dependency: "direct main" description: @@ -988,66 +980,58 @@ packages: dependency: "direct main" description: name: shared_preferences - sha256: "76917b7d4b9526b2ba416808a7eb9fb2863c1a09cf63ec85f1453da240fa818a" + sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180 url: "https://pub.dev" source: hosted - version: "2.0.15" + version: "2.2.3" shared_preferences_android: dependency: transitive description: name: shared_preferences_android - sha256: "853801ce6ba7429ec4e923e37317f32a57c903de50b8c33ffcfbdb7e6f0dd39c" + sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2" url: "https://pub.dev" source: hosted - version: "2.0.12" - shared_preferences_ios: + version: "2.2.2" + shared_preferences_foundation: dependency: transitive description: - name: shared_preferences_ios - sha256: "585a14cefec7da8c9c2fb8cd283a3bb726b4155c0952afe6a0caaa7b2272de34" + name: shared_preferences_foundation + sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.3.5" shared_preferences_linux: dependency: transitive description: name: shared_preferences_linux - sha256: "28aefc1261746e7bad3d09799496054beb84e8c4ffcdfed7734e17b4ada459a5" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - shared_preferences_macos: - dependency: transitive - description: - name: shared_preferences_macos - sha256: fbb94bf296576f49be37a1496d5951796211a8db0aa22cc0d68c46440dad808c + sha256: "2ba0510d3017f91655b7543e9ee46d48619de2a2af38e5c790423f7007c7ccc1" url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.4.0" shared_preferences_platform_interface: dependency: transitive description: name: shared_preferences_platform_interface - sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3 + sha256: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.4.1" shared_preferences_web: dependency: transitive description: name: shared_preferences_web - sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958 + sha256: "7b15ffb9387ea3e237bb7a66b8a23d2147663d391cafc5c8f37b2e7b4bde5d21" url: "https://pub.dev" source: hosted - version: "2.0.4" + version: "2.2.2" shared_preferences_windows: dependency: transitive description: name: shared_preferences_windows - sha256: "97f7ab9a7da96d9cf19581f5de520ceb529548498bd6b5e0ccd02d68a0d15eba" + sha256: "398084b47b7f92110683cac45c6dc4aae853db47e470e5ddcd52cab7f7196ab2" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.4.0" shelf: dependency: transitive description: @@ -1068,16 +1052,16 @@ packages: dependency: "direct main" description: name: shuftipro_sdk - sha256: "869b9d67191c671f1ea5b229a994173520381cc0524994496c61523592a45a0a" + sha256: fd47550bbbfe50c99ef490fdb609b5a8d5e3e770d3fb8196c984a7f68d00772e url: "https://pub.dev" source: hosted - version: "1.3.7" + version: "1.3.9" signer: dependency: transitive description: path: "packages/signer" ref: main - resolved-ref: "85f205055e8b0fecf9242147f44b4456cab5e71d" + resolved-ref: "27c3fda2b6fe8c67785cbe5ff08373878a2a8470" url: "https://github.com/codescalers/tfgrid-sdk-dart.git" source: git version: "0.1.0" @@ -1114,18 +1098,18 @@ packages: dependency: transitive description: name: sodium - sha256: "575916e4d579b7885174f2ba4ab6d7d30617d2248f346d220c9f1786c83d5ef6" + sha256: ad436bdd889ec5b0a86e1a0b49a1c714b94c87c08c759defab10717239f39879 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.3.0+2" sodium_libs: dependency: "direct main" description: name: sodium_libs - sha256: c7ef44664ec57bb89da9173cf3a672045e92a8297b05a3ab34e07da96eff8238 + sha256: a3399776deac73767bff9dd3da041b9553dce2da432912a6134b8441995df285 url: "https://pub.dev" source: hosted - version: "2.1.0+1" + version: "2.2.0+11" source_span: dependency: transitive description: @@ -1233,10 +1217,10 @@ packages: dependency: transitive description: name: synchronized - sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" url: "https://pub.dev" source: hosted - version: "3.1.0" + version: "3.1.0+1" term_glyph: dependency: transitive description: @@ -1308,14 +1292,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.1.0" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" universal_platform: dependency: transitive description: name: universal_platform - sha256: d315be0f6641898b280ffa34e2ddb14f3d12b1a37882557869646e0cc363d0cc + sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec" url: "https://pub.dev" source: hosted - version: "1.0.0+1" + version: "1.1.0" unorm_dart: dependency: transitive description: @@ -1336,66 +1328,66 @@ packages: dependency: "direct main" description: name: url_launcher - sha256: "4f0d5f9bf7efba3da5a7ff03bd33cc898c84bac978c068e1c94483828e709592" + sha256: "21b704ce5fa560ea9f3b525b43601c678728ba46725bab9b01187b4831377ed3" url: "https://pub.dev" source: hosted - version: "6.1.5" + version: "6.3.0" url_launcher_android: dependency: transitive description: name: url_launcher_android - sha256: "1ccd353c1bff66b49863527c02759f4d06b92744bd9777c96a00ca6a9e8e1d2f" + sha256: "17cd5e205ea615e2c6ea7a77323a11712dffa0720a8a90540db57a01347f9ad9" url: "https://pub.dev" source: hosted - version: "6.0.17" + version: "6.3.2" url_launcher_ios: dependency: transitive description: name: url_launcher_ios - sha256: "6ba7dddee26c9fae27c9203c424631109d73c8fa26cfa7bc3e35e751cb87f62e" + sha256: "75bb6fe3f60070407704282a2d295630cab232991eb52542b18347a8a941df03" url: "https://pub.dev" source: hosted - version: "6.0.17" + version: "6.2.4" url_launcher_linux: dependency: transitive description: name: url_launcher_linux - sha256: "360fa359ab06bcb4f7c5cd3123a2a9a4d3364d4575d27c4b33468bd4497dd094" + sha256: ab360eb661f8879369acac07b6bb3ff09d9471155357da8443fd5d3cf7363811 url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.1.1" url_launcher_macos: dependency: transitive description: name: url_launcher_macos - sha256: a9b3ea9043eabfaadfa3fb89de67a11210d85569086d22b3854484beab8b3978 + sha256: "9a1a42d5d2d95400c795b2914c36fdcb525870c752569438e4ebb09a2b5d90de" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.2.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface - sha256: "80b860b31a11ebbcbe51b8fe887efc204f3af91522f3b51bcda4622d276d2120" + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" url: "https://pub.dev" source: hosted - version: "2.1.0" + version: "2.3.2" url_launcher_web: dependency: transitive description: name: url_launcher_web - sha256: "88de707cba8e0c1c678ed79274298c4737f7f24addd12e786fbf0597de085850" + sha256: fff0932192afeedf63cdd50ecbb1bc825d31aed259f02bb8dba0f3b729a5e88b url: "https://pub.dev" source: hosted - version: "2.0.6" + version: "2.2.3" url_launcher_windows: dependency: transitive description: name: url_launcher_windows - sha256: e3c3b16d3104260c10eea3b0e34272aaa57921f83148b0619f74c2eced9b7ef1 + sha256: "49c10f879746271804767cb45551ec5592cdab00ee105c06dddde1a98f73b185" url: "https://pub.dev" source: hosted - version: "3.0.1" + version: "3.1.2" utility: dependency: transitive description: @@ -1416,26 +1408,26 @@ packages: dependency: transitive description: name: vector_graphics - sha256: b96f10cbdfcbd03a65758633a43e7d04574438f059b1043104b5d61b23d38a4f + sha256: "32c3c684e02f9bc0afb0ae0aa653337a2fe022e8ab064bcd7ffda27a74e288e3" url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "1.1.11+1" vector_graphics_codec: dependency: transitive description: name: vector_graphics_codec - sha256: "57a8e6e24662a3bdfe3b3d61257db91768700c0b8f844e235877b56480f31c69" + sha256: c86987475f162fadff579e7320c7ddda04cd2fdeffbe1129227a85d9ac9e03da url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "1.1.11+1" vector_graphics_compiler: dependency: transitive description: name: vector_graphics_compiler - sha256: "7430f5d834d0db4560d7b19863362cd892f1e52b43838553a3c5cdfc9ab28e5b" + sha256: "12faff3f73b1741a36ca7e31b292ddeb629af819ca9efe9953b70bd63fc8cd81" url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "1.1.11+1" vector_math: dependency: transitive description: @@ -1472,26 +1464,26 @@ packages: dependency: transitive description: name: win32 - sha256: "5a751eddf9db89b3e5f9d50c20ab8612296e4e8db69009788d6c8b060a84191c" + sha256: "464f5674532865248444b4c3daca12bd9bf2d7c47f759ce2617986e7229494a8" url: "https://pub.dev" source: hosted - version: "4.1.4" + version: "5.2.0" win32_registry: dependency: transitive description: name: win32_registry - sha256: "1c52f994bdccb77103a6231ad4ea331a244dbcef5d1f37d8462f713143b0bfae" + sha256: "41fd8a189940d8696b1b810efb9abcf60827b6cbfab90b0c43e8439e3a39d85a" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.1.2" xdg_directories: dependency: transitive description: name: xdg_directories - sha256: bd512f03919aac5f1313eb8249f223bacf4927031bf60b02601f81f687689e86 + sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d url: "https://pub.dev" source: hosted - version: "0.2.0+3" + version: "1.0.4" xml: dependency: transitive description: @@ -1518,4 +1510,4 @@ packages: version: "1.1.4+10" sdks: dart: ">=3.2.3 <4.0.0" - flutter: ">=3.7.0" + flutter: ">=3.16.0" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index b7dcb323..94e28f69 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -58,6 +58,7 @@ dependencies: country_picker: ^2.0.20 pinenacl: ^0.5.1 pinput: 3.0.1 + build_runner: ^2.4.9 dev_dependencies: flutter_test: From 64ac3a99688afdb98e01dd6118bc77242b8016a8 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 14:48:27 +0300 Subject: [PATCH 28/34] Fix opening file helper --- app/lib/helpers/download_helper.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/lib/helpers/download_helper.dart b/app/lib/helpers/download_helper.dart index 5b624f5e..defa856a 100644 --- a/app/lib/helpers/download_helper.dart +++ b/app/lib/helpers/download_helper.dart @@ -5,7 +5,9 @@ import 'package:path_provider/path_provider.dart'; // https://www.youtube.com/watch?v=6tfBflFUO7s Future openFile(File? file) async { - OpenFilex.open(file?.path); + if (file != null && file.path != null) { + OpenFilex.open(file.path); + } } Future downloadFile(String url, String name) async { From 4ca7b2e1540bca19837afe972358744f9bb72043 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 14:49:16 +0300 Subject: [PATCH 29/34] Add the reflectable initializer in gridproxy service --- app/lib/services/gridproxy_service.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/lib/services/gridproxy_service.dart b/app/lib/services/gridproxy_service.dart index 4da6fe1b..3a6fa309 100644 --- a/app/lib/services/gridproxy_service.dart +++ b/app/lib/services/gridproxy_service.dart @@ -1,8 +1,10 @@ import 'package:gridproxy_client/gridproxy_client.dart'; import 'package:threebotlogin/helpers/globals.dart'; +import 'package:threebotlogin/main.reflectable.dart'; import 'package:threebotlogin/services/shared_preference_service.dart'; Future getMySpending() async { + initializeReflectable(); final gridproxyUrl = Globals().gridproxyUrl; if (gridproxyUrl == '') return 0.0; final twinId = await getTwinId(); From 8f2a9f5d649229bc2eb6c21f6f1754b92f2c53e1 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 15:18:40 +0300 Subject: [PATCH 30/34] Fix app config initialized globals --- app/lib/app_config.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/app_config.dart b/app/lib/app_config.dart index 96ab8868..bfee8a1c 100644 --- a/app/lib/app_config.dart +++ b/app/lib/app_config.dart @@ -217,5 +217,5 @@ void setFallbackConfigs() { Globals().phoneVerification = false; Globals().chainUrl = ''; Globals().gridproxyUrl = ''; - Globals().timeOutSeconds = 0; + Globals().spendingLimit = 0; } From 743d56b1e88b8aac6e488b44e907b1be06800a87 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 16:23:16 +0300 Subject: [PATCH 31/34] Make the ui more smoother while getting the user spendings --- .../screens/identity_verification_screen.dart | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index b318afc8..50dccff3 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -217,14 +217,7 @@ class _IdentityVerificationScreenState } }); }); - getSpending().then((mySpending) => { - if (Globals().spendingLimit > 0) - { - setState(() { - spending = mySpending; - }) - } - }); + getSpending(); } @override @@ -1625,9 +1618,13 @@ class _IdentityVerificationScreenState phoneSendDialog(context); } - Future getSpending() async { + Future getSpending() async { + if (Globals().spendingLimit <= 0) return; try { - return await getMySpending(); + setState(() { + isLoading = true; + }); + spending = await getMySpending(); } catch (e) { final loadingSpendingFailure = SnackBar( content: Text( @@ -1642,7 +1639,11 @@ class _IdentityVerificationScreenState ScaffoldMessenger.of(context).clearSnackBars(); ScaffoldMessenger.of(context).showSnackBar(loadingSpendingFailure); print('Failed to load user spending due to $e'); - return 0.0; + spending = 0.0; + } finally { + setState(() { + isLoading = false; + }); } } } From be5ec4c0da61c439bbf6a66179a54157a3234130 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Mon, 9 Sep 2024 16:40:16 +0300 Subject: [PATCH 32/34] Remove unnecessairly global variable --- app/lib/helpers/globals.dart | 1 - app/lib/screens/main_screen.dart | 1 - 2 files changed, 2 deletions(-) diff --git a/app/lib/helpers/globals.dart b/app/lib/helpers/globals.dart index 82e9aa53..9a614add 100644 --- a/app/lib/helpers/globals.dart +++ b/app/lib/helpers/globals.dart @@ -62,7 +62,6 @@ class Globals { int smsSentOn = 0; int smsMinutesCoolDown = 5; - int twinId = 0; int spendingLimit = 0; ValueNotifier hidePhoneButton = ValueNotifier(false); diff --git a/app/lib/screens/main_screen.dart b/app/lib/screens/main_screen.dart index 84a3994b..40a37051 100644 --- a/app/lib/screens/main_screen.dart +++ b/app/lib/screens/main_screen.dart @@ -324,6 +324,5 @@ class _AppState extends State { await saveTwinId(twinId); } } - Globals().twinId = twinId ?? 0; } } From dc99ee371f5ccde40e3295aae3292fb313f228bc Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 11 Sep 2024 17:27:42 +0300 Subject: [PATCH 33/34] Fix check on string from null to isNotEmpty --- app/lib/helpers/download_helper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/helpers/download_helper.dart b/app/lib/helpers/download_helper.dart index defa856a..443cb77a 100644 --- a/app/lib/helpers/download_helper.dart +++ b/app/lib/helpers/download_helper.dart @@ -5,7 +5,7 @@ import 'package:path_provider/path_provider.dart'; // https://www.youtube.com/watch?v=6tfBflFUO7s Future openFile(File? file) async { - if (file != null && file.path != null) { + if (file != null && file.path.isNotEmpty) { OpenFilex.open(file.path); } } From 427d5b87b77000a1534c0b04d0b68ccd0d7478b7 Mon Sep 17 00:00:00 2001 From: ahmedhanafy725 Date: Wed, 11 Sep 2024 17:28:35 +0300 Subject: [PATCH 34/34] Use symmetric instead of LTRB --- app/lib/screens/identity_verification_screen.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/lib/screens/identity_verification_screen.dart b/app/lib/screens/identity_verification_screen.dart index 50dccff3..d5bb9dce 100644 --- a/app/lib/screens/identity_verification_screen.dart +++ b/app/lib/screens/identity_verification_screen.dart @@ -1091,7 +1091,8 @@ class _IdentityVerificationScreenState height: 10, ), Container( - padding: const EdgeInsets.fromLTRB(15, 10, 15, 10), + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 10), child: Column( children: [ Text( @@ -1123,7 +1124,8 @@ class _IdentityVerificationScreenState )), Container( color: Theme.of(context).colorScheme.secondaryContainer, - padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 20), child: Column( children: [ Row( @@ -1160,7 +1162,8 @@ class _IdentityVerificationScreenState ), ), Container( - padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 20), child: Column( children: [ Row( @@ -1200,7 +1203,8 @@ class _IdentityVerificationScreenState ), Container( color: Theme.of(context).colorScheme.secondaryContainer, - padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 20), child: Column( children: [ Row( @@ -1239,7 +1243,8 @@ class _IdentityVerificationScreenState ), ), Container( - padding: const EdgeInsets.fromLTRB(15, 20, 15, 20), + padding: const EdgeInsets.symmetric( + horizontal: 15, vertical: 20), child: Column( children: [ Row(