Skip to content

Commit

Permalink
Add chain url to flagsmith
Browse files Browse the repository at this point in the history
  • Loading branch information
AhmedHanafy725 committed Sep 4, 2024
1 parent 37a1430 commit 803bd81
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/lib/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,5 @@ void setFallbackConfigs() {
Globals().redoIdentityVerification = false;
Globals().timeOutSeconds = 10;
Globals().phoneVerification = false;
Globals().chainUrl = '';
}
2 changes: 2 additions & 0 deletions app/lib/helpers/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> hasFlagValueByFeatureName(String name) async {
Expand Down
1 change: 1 addition & 0 deletions app/lib/helpers/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Globals {
String tosUrl = '';
bool maintenance = false;
bool phoneVerification = false;
String chainUrl = '';

bool isCacheClearedWallet = false;
bool isCacheClearedFarmer = false;
Expand Down
7 changes: 4 additions & 3 deletions app/lib/services/tfchain_service.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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<int?> getTwinId() async {
final chainUrl = Globals().chainUrl;
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));
// 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();
Expand Down

0 comments on commit 803bd81

Please sign in to comment.