From 6f215f5451a7d613f04044fa20f510c624459305 Mon Sep 17 00:00:00 2001 From: M Date: Wed, 12 Jan 2022 17:38:32 +0200 Subject: [PATCH] Add throwing exception for yat api calls. Remove random address generation on address page. --- .../dashboard/widgets/address_page.dart | 1 - lib/src/screens/yat/yat_sending.dart | 42 +++++++++---------- lib/store/yat/yat_store.dart | 32 ++++++++------ .../settings/settings_view_model.dart | 36 ++++++++-------- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index e9b78ea4f..51bb05a40 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -27,7 +27,6 @@ class AddressPage extends StatelessWidget { @override Widget build(BuildContext context) { - addressListViewModel.generateRandomAddress(); autorun((_) async { if (!walletViewModel.isOutdatedElectrumWallet || !walletViewModel.settingsStore.shouldShowReceiveWarning) { diff --git a/lib/src/screens/yat/yat_sending.dart b/lib/src/screens/yat/yat_sending.dart index 1bd9659ea..1e6de793e 100644 --- a/lib/src/screens/yat/yat_sending.dart +++ b/lib/src/screens/yat/yat_sending.dart @@ -66,28 +66,28 @@ class YatSending extends BasePage { color: Colors.black, child: Stack( children: [ - Center( - child:FutureBuilder( - future: visualisationForEmojiId(sendViewModel.outputs.first.address), - builder: (BuildContext context, AsyncSnapshot snapshot) { - switch (snapshot.connectionState) { - case ConnectionState.done: - if (snapshot.hasError || snapshot.data.isEmpty) { - return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); - } + //Center( + // child:FutureBuilder( + // future: visualisationForEmojiId(sendViewModel.outputs.first.address), + // builder: (BuildContext context, AsyncSnapshot snapshot) { + // switch (snapshot.connectionState) { + // case ConnectionState.done: + // if (snapshot.hasError || snapshot.data.isEmpty) { + // return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); + // } - return Image.network( - snapshot.data, - scale: 0.7, - loadingBuilder: (Object z, Widget child, ImageChunkEvent loading) - => loading != null - ? CupertinoActivityIndicator(animating: true) - : child); - default: - return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); - } - }), - ), + // return Image.network( + // snapshot.data, + // scale: 0.7, + // loadingBuilder: (Object z, Widget child, ImageChunkEvent loading) + // => loading != null + // ? CupertinoActivityIndicator(animating: true) + // : child); + // default: + // return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white); + // } + // }), + // ), Positioned( bottom: 20, child: Container( diff --git a/lib/store/yat/yat_store.dart b/lib/store/yat/yat_store.dart index d6a655595..8cb13c735 100644 --- a/lib/store/yat/yat_store.dart +++ b/lib/store/yat/yat_store.dart @@ -43,6 +43,7 @@ class YatLink { } Future> fetchYatAddress(String emojiId, String ticker) async { + throw Exception(); //final url = YatLink.emojiIdUrl + emojiId + '/payment'; //final response = await get(url); @@ -71,6 +72,7 @@ Future> fetchYatAddress(String emojiId, String ticker) async { } Future fetchYatAccessToken(String refreshToken) async { + throw Exception(); //try { // final url = YatLink.apiUrl + '/auth/token/refresh'; // final bodyJson = json.encode({'refresh_token': refreshToken}); @@ -95,6 +97,7 @@ Future fetchYatAccessToken(String refreshToken) async { } Future fetchYatApiKey(String accessKey) async { + throw Exception(); //try { // final url = YatLink.apiUrl + '/api_keys'; // final bodyJson = json.encode({'name': 'CW'}); @@ -120,6 +123,7 @@ Future fetchYatApiKey(String accessKey) async { } Future updateEmojiIdAddress(String emojiId, String address, String apiKey, WalletType type) async { + throw Exception(); //final url = YatLink.emojiIdUrl + emojiId; //final cur = walletTypeToCryptoCurrency(type); //final curFormatted = cur.toString().toUpperCase(); @@ -152,6 +156,7 @@ Future updateEmojiIdAddress(String emojiId, String address, String apiKey, } Future visualisationForEmojiId(String emojiId) async { + throw Exception(); //final url = YatLink.emojiIdUrl + emojiId + '/json/VisualizerFileLocations'; //final response = await get(url); //final responseJSON = json.decode(response.body) as Map; @@ -167,9 +172,9 @@ abstract class YatStoreBase with Store { YatStoreBase({@required this.appStore, @required this.secureStorage}) { _wallet ??= appStore.wallet; emoji = _wallet?.walletInfo?.yatEmojiId ?? ''; - reaction((_) => appStore.wallet, _onWalletChange); - reaction((_) => emoji, (String _) => _onEmojiChange()); - reaction((_) => refreshToken, (String _) => _onRefreshTokenChange()); + //reaction((_) => appStore.wallet, _onWalletChange); + //reaction((_) => emoji, (String _) => _onEmojiChange()); + //reaction((_) => refreshToken, (String _) => _onRefreshTokenChange()); emojiIncommingSC = StreamController.broadcast(); } @@ -246,18 +251,21 @@ abstract class YatStoreBase with Store { @action Future _onRefreshTokenChange() async { - try { - await secureStorage.write(key: yatRefreshTokenKey(_wallet.walletInfo.name), value: refreshToken); - accessToken = await fetchYatAccessToken(refreshToken); - await secureStorage.write(key: yatAccessTokenKey(_wallet.walletInfo.name), value: accessToken); - apiKey = await fetchYatApiKey(accessToken); - await secureStorage.write(key: yatApiKey(_wallet.walletInfo.name), value: accessToken); - } catch (e) { - print(e.toString()); - } + throw Exception(); + + //try { + // await secureStorage.write(key: yatRefreshTokenKey(_wallet.walletInfo.name), value: refreshToken); + // accessToken = await fetchYatAccessToken(refreshToken); + // await secureStorage.write(key: yatAccessTokenKey(_wallet.walletInfo.name), value: accessToken); + // apiKey = await fetchYatApiKey(accessToken); + // await secureStorage.write(key: yatApiKey(_wallet.walletInfo.name), value: accessToken); + //} catch (e) { + // print(e.toString()); + //} } String defineQueryParameters() { + throw Exception(); //final result = {}; //final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()]; //String tag = tags.first; diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index eca7a7173..bb2f01361 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -69,29 +69,29 @@ abstract class SettingsViewModelBase with Store { _settingsStore.priority[wallet.type] = priorities.first; } - var connectYatUrl = YatLink.baseUrl + YatLink.signInSuffix; - final connectYatUrlParameters = - _yatStore.defineQueryParameters(); + //var connectYatUrl = YatLink.baseUrl + YatLink.signInSuffix; + //final connectYatUrlParameters = + // _yatStore.defineQueryParameters(); - if (connectYatUrlParameters.isNotEmpty) { - connectYatUrl += YatLink.queryParameter + connectYatUrlParameters; - } + //if (connectYatUrlParameters.isNotEmpty) { + // connectYatUrl += YatLink.queryParameter + connectYatUrlParameters; + //} - var manageYatUrl = YatLink.baseUrl + YatLink.managePath; - final manageYatUrlParameters = - _yatStore.defineQueryParameters(); + //var manageYatUrl = YatLink.baseUrl + YatLink.managePath; + //final manageYatUrlParameters = + // _yatStore.defineQueryParameters(); - if (manageYatUrlParameters.isNotEmpty) { - manageYatUrl += YatLink.queryParameter + manageYatUrlParameters; - } + //if (manageYatUrlParameters.isNotEmpty) { + // manageYatUrl += YatLink.queryParameter + manageYatUrlParameters; + //} - var createNewYatUrl = YatLink.startFlowUrl; - final createNewYatUrlParameters = - _yatStore.defineQueryParameters(); + //var createNewYatUrl = YatLink.startFlowUrl; + //final createNewYatUrlParameters = + // _yatStore.defineQueryParameters(); - if (createNewYatUrlParameters.isNotEmpty) { - createNewYatUrl += '?sub1=' + createNewYatUrlParameters; - } + //if (createNewYatUrlParameters.isNotEmpty) { + // createNewYatUrl += '?sub1=' + createNewYatUrlParameters; + //} sections = [