Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions app/lib/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class AppConfigProduction extends AppConfigImpl {

@override
String openKycApiUrl() {
return "https://openkyc.threefold.me";
return 'https://openkyc.threefold.me';
}

@override
Expand Down Expand Up @@ -118,7 +118,7 @@ class AppConfigProduction extends AppConfigImpl {
class AppConfigStaging extends AppConfigImpl {
@override
String baseUrl() {
return "login.staging.threefold.me";
return 'login.staging.threefold.me';
}

@override
Expand All @@ -128,17 +128,17 @@ class AppConfigStaging extends AppConfigImpl {

@override
String threeBotApiUrl() {
return "https://login.staging.threefold.me/api";
return 'https://login.staging.threefold.me/api';
}

@override
String threeBotFrontEndUrl() {
return "https://login.staging.threefold.me/";
return 'https://login.staging.threefold.me/';
}

@override
String threeBotSocketUrl() {
return "wss://login.staging.threefold.me";
return 'wss://login.staging.threefold.me';
}

@override
Expand All @@ -163,27 +163,27 @@ class AppConfigStaging extends AppConfigImpl {
class AppConfigTesting extends AppConfigImpl {
@override
String baseUrl() {
return "login.testing.threefold.me";
return 'login.testing.threefold.me';
}

@override
String openKycApiUrl() {
return "https://openkyc.testing.threefold.me";
return 'https://openkyc.testing.threefold.me';
}

@override
String threeBotApiUrl() {
return "https://login.testing.threefold.me/api";
return 'https://login.testing.threefold.me/api';
}

@override
String threeBotFrontEndUrl() {
return "https://login.testing.threefold.me/";
return 'https://login.testing.threefold.me/';
}

@override
String threeBotSocketUrl() {
return "wss://login.testing.threefold.me";
return 'wss://login.testing.threefold.me';
}

@override
Expand Down
2 changes: 1 addition & 1 deletion app/lib/apps/chatbot/chatbot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class Chatbot implements App {
void back() {
Events().emit(GoHomeEvent());
}
}
}
19 changes: 12 additions & 7 deletions app/lib/apps/chatbot/chatbot_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class ChatbotWidget extends StatefulWidget {
_ChatbotState createState() => _ChatbotState(email: email);
}

class _ChatbotState extends State<ChatbotWidget> with AutomaticKeepAliveClientMixin {
class _ChatbotState extends State<ChatbotWidget>
with AutomaticKeepAliveClientMixin {
InAppWebViewController? webView;

ChatbotConfig config = ChatbotConfig();
Expand All @@ -23,18 +24,23 @@ class _ChatbotState extends State<ChatbotWidget> with AutomaticKeepAliveClientMi
_ChatbotState({required this.email}) {
iaWebview = InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse('${config.url()}$email&cache_buster=${DateTime.now().millisecondsSinceEpoch}')),
url: Uri.parse(
'${config.url()}$email&cache_buster=${DateTime.now().millisecondsSinceEpoch}')),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(useShouldOverrideUrlLoading: true),
android: AndroidInAppWebViewOptions(supportMultipleWindows: true, useHybridComposition: true)),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true, useHybridComposition: true)),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onCreateWindow: (InAppWebViewController controller, CreateWindowAction req) {
inAppBrowser.openUrlRequest(urlRequest: req.request, options: InAppBrowserClassOptions());
onCreateWindow:
(InAppWebViewController controller, CreateWindowAction req) {
inAppBrowser.openUrlRequest(
urlRequest: req.request, options: InAppBrowserClassOptions());
return Future.value(true);
},
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
onConsoleMessage:
(InAppWebViewController controller, ConsoleMessage consoleMessage) {
print('CB console: ${consoleMessage.message}');
},
onLoadStart: (InAppWebViewController controller, _) {
Expand Down Expand Up @@ -69,7 +75,6 @@ class _ChatbotState extends State<ChatbotWidget> with AutomaticKeepAliveClientMi
);
}


@override
void dispose() {
super.dispose();
Expand Down
38 changes: 25 additions & 13 deletions app/lib/apps/farmers/farmers_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class FarmersWidget extends StatefulWidget {
_FarmersState createState() => _FarmersState();
}

class _FarmersState extends State<FarmersWidget> with AutomaticKeepAliveClientMixin {
class _FarmersState extends State<FarmersWidget>
with AutomaticKeepAliveClientMixin {
late InAppWebViewController webView;

double progress = 0;

// Still use wallet configs to have the same derived key
var walletConfig = WalletConfig();


late InAppWebView iaWebView;

_back(FarmersBackEvent event) async {
Expand All @@ -54,15 +54,19 @@ class _FarmersState extends State<FarmersWidget> with AutomaticKeepAliveClientMi
'$farmersUri?cache_buster=${DateTime.now().millisecondsSinceEpoch}')),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
cacheEnabled: Globals().isCacheClearedFarmer, clearCache: !Globals().isCacheClearedFarmer),
cacheEnabled: Globals().isCacheClearedFarmer,
clearCache: !Globals().isCacheClearedFarmer),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true, thirdPartyCookiesEnabled: true, useHybridComposition: true),
supportMultipleWindows: true,
thirdPartyCookiesEnabled: true,
useHybridComposition: true),
ios: IOSInAppWebViewOptions()),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
addHandler();
},
onCreateWindow: (InAppWebViewController controller, CreateWindowAction req) {
onCreateWindow:
(InAppWebViewController controller, CreateWindowAction req) {
return Future.value(true);
},
onLoadStop: (InAppWebViewController controller, Uri? url) async {
Expand All @@ -76,7 +80,8 @@ class _FarmersState extends State<FarmersWidget> with AutomaticKeepAliveClientMi
this.progress = progress / 100;
});
},
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
onConsoleMessage:
(InAppWebViewController controller, ConsoleMessage consoleMessage) {
print('Wallet console: ${consoleMessage.message}');
},
);
Expand Down Expand Up @@ -106,29 +111,36 @@ class _FarmersState extends State<FarmersWidget> with AutomaticKeepAliveClientMi
await SystemChannels.textInput.invokeMethod('TextInput.hide');

// QRCode scanner is black if we don't sleep here.
bool slept = await Future.delayed(const Duration(milliseconds: 400), () => true);
bool slept =
await Future.delayed(const Duration(milliseconds: 400), () => true);

String? result;
if (slept) {
result = await Navigator.push(context, MaterialPageRoute(builder: (context) => const ScanScreen()));
result = await Navigator.push(
context, MaterialPageRoute(builder: (context) => const ScanScreen()));
}

return result;
}

addHandler() {
webView.addJavaScriptHandler(handlerName: 'ADD_IMPORT_WALLET', callback: saveImportedWallet);
webView.addJavaScriptHandler(handlerName: 'ADD_APP_WALLET', callback: saveAppWallet);
webView.addJavaScriptHandler(
handlerName: 'ADD_IMPORT_WALLET', callback: saveImportedWallet);
webView.addJavaScriptHandler(
handlerName: 'ADD_APP_WALLET', callback: saveAppWallet);
webView.addJavaScriptHandler(handlerName: 'SCAN_QR', callback: scanQrCode);
webView.addJavaScriptHandler(handlerName: 'VUE_INITIALIZED', callback: vueInitialized);
webView.addJavaScriptHandler(handlerName: 'SAVE_WALLETS', callback: saveWalletCallback);
webView.addJavaScriptHandler(
handlerName: 'VUE_INITIALIZED', callback: vueInitialized);
webView.addJavaScriptHandler(
handlerName: 'SAVE_WALLETS', callback: saveWalletCallback);
}

saveWalletCallback(List<dynamic> params) async {
try {
List<WalletData> walletData = [];
for (var data in params[0]) {
walletData.add(WalletData(data['name'], data['chain'], data['address']));
walletData
.add(WalletData(data['name'], data['chain'], data['address']));
}

await saveWallets(walletData);
Expand Down
4 changes: 2 additions & 2 deletions app/lib/apps/news/news_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class _NewsState extends State<NewsWidget> with AutomaticKeepAliveClientMixin {
}

_NewsState() {
this.initialEndsWith = new DateTime.now().millisecondsSinceEpoch.toString();
initialEndsWith = DateTime.now().millisecondsSinceEpoch.toString();
iaWebView = InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse(
'https://news.threefold.me?cache_buster=' + initialEndsWith)),
'https://news.threefold.me?cache_buster=$initialEndsWith')),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(),
android: AndroidInAppWebViewOptions(
Expand Down
2 changes: 1 addition & 1 deletion app/lib/apps/wallet/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ class Wallet implements App {

@override
void back() {
Events().emit(GoHomeEvent());
Events().emit(GoHomeEvent());
}
}
53 changes: 32 additions & 21 deletions app/lib/apps/wallet/wallet_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class WalletWidget extends StatefulWidget {
_WalletState createState() => _WalletState();
}

class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixin {
class _WalletState extends State<WalletWidget>
with AutomaticKeepAliveClientMixin {
late InAppWebViewController webView;
late InAppWebView iaWebView;

Expand All @@ -45,25 +46,29 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
}

_WalletState() {
String walletUri =
Globals().useNewWallet == true ? Globals().newWalletUrl : 'https://${config.appId()}/init';
String walletUri = Globals().useNewWallet == true
? Globals().newWalletUrl
: 'https://${config.appId()}/init';

iaWebView = InAppWebView(
initialUrlRequest: URLRequest(
url: Uri.parse(
'$walletUri?cache_buster=${DateTime.now().millisecondsSinceEpoch}')),
initialOptions: InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
cacheEnabled: Globals().isCacheClearedWallet,
clearCache: !Globals().isCacheClearedWallet
),
android: AndroidInAppWebViewOptions(supportMultipleWindows: true, thirdPartyCookiesEnabled: true, useHybridComposition: true),
cacheEnabled: Globals().isCacheClearedWallet,
clearCache: !Globals().isCacheClearedWallet),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true,
thirdPartyCookiesEnabled: true,
useHybridComposition: true),
ios: IOSInAppWebViewOptions()),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
addHandler();
},
onCreateWindow: (InAppWebViewController controller, CreateWindowAction req) {
onCreateWindow:
(InAppWebViewController controller, CreateWindowAction req) {
return Future.value(true);
},
onLoadStop: (InAppWebViewController controller, Uri? url) async {
Expand All @@ -77,7 +82,8 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
this.progress = progress / 100;
});
},
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {
onConsoleMessage:
(InAppWebViewController controller, ConsoleMessage consoleMessage) {
print('Wallet console: ${consoleMessage.message}');
},
);
Expand All @@ -102,7 +108,6 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
var importedWallets = await getImportedWallets();
var appWallets = await getAppWallets();


var jsStartApp = Globals().useNewWallet == true
? "window.init('$doubleName', '$seed')"
: "window.vueInstance.startWallet('$doubleName', '$seed', '$importedWallets', '$appWallets');";
Expand All @@ -124,21 +129,28 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
scanQrCode(List<dynamic> params) async {
await SystemChannels.textInput.invokeMethod('TextInput.hide');
// QRCode scanner is black if we don't sleep here.
bool slept = await Future.delayed(const Duration(milliseconds: 400), () => true);
bool slept =
await Future.delayed(const Duration(milliseconds: 400), () => true);
late Barcode result;
if (slept) {
result = await Navigator.push(context, MaterialPageRoute(builder: (context) => const ScanScreen()));
result = await Navigator.push(
context, MaterialPageRoute(builder: (context) => const ScanScreen()));
}
return result.code;
}

addHandler() {
webView.addJavaScriptHandler(handlerName: 'ADD_IMPORT_WALLET', callback: saveImportedWallet);
webView.addJavaScriptHandler(handlerName: 'ADD_APP_WALLET', callback: saveAppWallet);
webView.addJavaScriptHandler(
handlerName: 'ADD_IMPORT_WALLET', callback: saveImportedWallet);
webView.addJavaScriptHandler(
handlerName: 'ADD_APP_WALLET', callback: saveAppWallet);
webView.addJavaScriptHandler(handlerName: 'SCAN_QR', callback: scanQrCode);
webView.addJavaScriptHandler(handlerName: 'VUE_INITIALIZED', callback: vueInitialized);
webView.addJavaScriptHandler(handlerName: 'SAVE_WALLETS', callback: saveWalletCallback);
webView.addJavaScriptHandler(handlerName: 'SIGNING', callback: signCallback);
webView.addJavaScriptHandler(
handlerName: 'VUE_INITIALIZED', callback: vueInitialized);
webView.addJavaScriptHandler(
handlerName: 'SAVE_WALLETS', callback: saveWalletCallback);
webView.addJavaScriptHandler(
handlerName: 'SIGNING', callback: signCallback);
}

signCallback(List<dynamic> params) async {
Expand All @@ -148,9 +160,7 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
Uint8List sk = await getPrivateKey();
String signedData = await signData(data, sk);
return signedData;
}

catch(e) {
} catch (e) {
print(e);
return '';
}
Expand All @@ -160,7 +170,8 @@ class _WalletState extends State<WalletWidget> with AutomaticKeepAliveClientMixi
try {
List<WalletData> walletData = [];
for (var data in params[0]) {
walletData.add(WalletData(data['name'], data['chain'], data['address']));
walletData
.add(WalletData(data['name'], data['chain'], data['address']));
}

await saveWallets(walletData);
Expand Down
1 change: 0 additions & 1 deletion app/lib/events/go_settings_event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class GoSettingsEvent {
GoSettingsEvent();
}

3 changes: 1 addition & 2 deletions app/lib/events/go_sign_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ import 'package:threebotlogin/models/sign.dart';

class NewSignEvent {
Sign? signData;
NewSignEvent({ this.signData});
NewSignEvent({this.signData});
}

3 changes: 1 addition & 2 deletions app/lib/helpers/flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class Flags {
(await Flags().getFlagValueByFeatureName('terms-conditions-url'))!;
Globals().spendingLimit = int.parse(
(await Flags().getFlagValueByFeatureName('spending-limit')).toString());
Globals().newsUrl =
(await Flags().getFlagValueByFeatureName('news-url'))!;
Globals().newsUrl = (await Flags().getFlagValueByFeatureName('news-url'))!;
}

Future<bool> hasFlagValueByFeatureName(String name) async {
Expand Down
Loading