Add throwing exception for yat api calls. Remove random address generation on address page.

This commit is contained in:
M 2022-01-12 17:38:32 +02:00
parent 5e172f982f
commit 6f215f5451
4 changed files with 59 additions and 52 deletions

View file

@ -27,7 +27,6 @@ class AddressPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
addressListViewModel.generateRandomAddress();
autorun((_) async {
if (!walletViewModel.isOutdatedElectrumWallet
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {

View file

@ -66,28 +66,28 @@ class YatSending extends BasePage {
color: Colors.black,
child: Stack(
children: [
Center(
child:FutureBuilder<String>(
future: visualisationForEmojiId(sendViewModel.outputs.first.address),
builder: (BuildContext context, AsyncSnapshot<String> 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<String>(
// future: visualisationForEmojiId(sendViewModel.outputs.first.address),
// builder: (BuildContext context, AsyncSnapshot<String> 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(

View file

@ -43,6 +43,7 @@ class YatLink {
}
Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
throw Exception();
//final url = YatLink.emojiIdUrl + emojiId + '/payment';
//final response = await get(url);
@ -71,6 +72,7 @@ Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
}
Future<String> 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<String> fetchYatAccessToken(String refreshToken) async {
}
Future<String> fetchYatApiKey(String accessKey) async {
throw Exception();
//try {
// final url = YatLink.apiUrl + '/api_keys';
// final bodyJson = json.encode({'name': 'CW'});
@ -120,6 +123,7 @@ Future<String> fetchYatApiKey(String accessKey) async {
}
Future<void> 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<void> updateEmojiIdAddress(String emojiId, String address, String apiKey,
}
Future<String> 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<String, dynamic>;
@ -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<String>.broadcast();
}
@ -246,18 +251,21 @@ abstract class YatStoreBase with Store {
@action
Future<void> _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 = <String, String>{};
//final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()];
//String tag = tags.first;

View file

@ -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 = [