mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-08 20:09:24 +00:00
Add throwing exception for yat api calls. Remove random address generation on address page.
This commit is contained in:
parent
5e172f982f
commit
6f215f5451
4 changed files with 59 additions and 52 deletions
|
@ -27,7 +27,6 @@ class AddressPage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
addressListViewModel.generateRandomAddress();
|
|
||||||
autorun((_) async {
|
autorun((_) async {
|
||||||
if (!walletViewModel.isOutdatedElectrumWallet
|
if (!walletViewModel.isOutdatedElectrumWallet
|
||||||
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {
|
|| !walletViewModel.settingsStore.shouldShowReceiveWarning) {
|
||||||
|
|
|
@ -66,28 +66,28 @@ class YatSending extends BasePage {
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
//Center(
|
||||||
child:FutureBuilder<String>(
|
// child:FutureBuilder<String>(
|
||||||
future: visualisationForEmojiId(sendViewModel.outputs.first.address),
|
// future: visualisationForEmojiId(sendViewModel.outputs.first.address),
|
||||||
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
// builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||||
switch (snapshot.connectionState) {
|
// switch (snapshot.connectionState) {
|
||||||
case ConnectionState.done:
|
// case ConnectionState.done:
|
||||||
if (snapshot.hasError || snapshot.data.isEmpty) {
|
// if (snapshot.hasError || snapshot.data.isEmpty) {
|
||||||
return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white);
|
// return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return Image.network(
|
// return Image.network(
|
||||||
snapshot.data,
|
// snapshot.data,
|
||||||
scale: 0.7,
|
// scale: 0.7,
|
||||||
loadingBuilder: (Object z, Widget child, ImageChunkEvent loading)
|
// loadingBuilder: (Object z, Widget child, ImageChunkEvent loading)
|
||||||
=> loading != null
|
// => loading != null
|
||||||
? CupertinoActivityIndicator(animating: true)
|
// ? CupertinoActivityIndicator(animating: true)
|
||||||
: child);
|
// : child);
|
||||||
default:
|
// default:
|
||||||
return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white);
|
// return Image.asset('assets/images/yat_logo.png', width: screenWidth, color: Colors.white);
|
||||||
}
|
// }
|
||||||
}),
|
// }),
|
||||||
),
|
// ),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 20,
|
bottom: 20,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
|
@ -43,6 +43,7 @@ class YatLink {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
|
Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
|
||||||
|
throw Exception();
|
||||||
//final url = YatLink.emojiIdUrl + emojiId + '/payment';
|
//final url = YatLink.emojiIdUrl + emojiId + '/payment';
|
||||||
//final response = await get(url);
|
//final response = await get(url);
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ Future<List<String>> fetchYatAddress(String emojiId, String ticker) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> fetchYatAccessToken(String refreshToken) async {
|
Future<String> fetchYatAccessToken(String refreshToken) async {
|
||||||
|
throw Exception();
|
||||||
//try {
|
//try {
|
||||||
// final url = YatLink.apiUrl + '/auth/token/refresh';
|
// final url = YatLink.apiUrl + '/auth/token/refresh';
|
||||||
// final bodyJson = json.encode({'refresh_token': refreshToken});
|
// final bodyJson = json.encode({'refresh_token': refreshToken});
|
||||||
|
@ -95,6 +97,7 @@ Future<String> fetchYatAccessToken(String refreshToken) async {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> fetchYatApiKey(String accessKey) async {
|
Future<String> fetchYatApiKey(String accessKey) async {
|
||||||
|
throw Exception();
|
||||||
//try {
|
//try {
|
||||||
// final url = YatLink.apiUrl + '/api_keys';
|
// final url = YatLink.apiUrl + '/api_keys';
|
||||||
// final bodyJson = json.encode({'name': 'CW'});
|
// 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 {
|
Future<void> updateEmojiIdAddress(String emojiId, String address, String apiKey, WalletType type) async {
|
||||||
|
throw Exception();
|
||||||
//final url = YatLink.emojiIdUrl + emojiId;
|
//final url = YatLink.emojiIdUrl + emojiId;
|
||||||
//final cur = walletTypeToCryptoCurrency(type);
|
//final cur = walletTypeToCryptoCurrency(type);
|
||||||
//final curFormatted = cur.toString().toUpperCase();
|
//final curFormatted = cur.toString().toUpperCase();
|
||||||
|
@ -152,6 +156,7 @@ Future<void> updateEmojiIdAddress(String emojiId, String address, String apiKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> visualisationForEmojiId(String emojiId) async {
|
Future<String> visualisationForEmojiId(String emojiId) async {
|
||||||
|
throw Exception();
|
||||||
//final url = YatLink.emojiIdUrl + emojiId + '/json/VisualizerFileLocations';
|
//final url = YatLink.emojiIdUrl + emojiId + '/json/VisualizerFileLocations';
|
||||||
//final response = await get(url);
|
//final response = await get(url);
|
||||||
//final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
//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}) {
|
YatStoreBase({@required this.appStore, @required this.secureStorage}) {
|
||||||
_wallet ??= appStore.wallet;
|
_wallet ??= appStore.wallet;
|
||||||
emoji = _wallet?.walletInfo?.yatEmojiId ?? '';
|
emoji = _wallet?.walletInfo?.yatEmojiId ?? '';
|
||||||
reaction((_) => appStore.wallet, _onWalletChange);
|
//reaction((_) => appStore.wallet, _onWalletChange);
|
||||||
reaction((_) => emoji, (String _) => _onEmojiChange());
|
//reaction((_) => emoji, (String _) => _onEmojiChange());
|
||||||
reaction((_) => refreshToken, (String _) => _onRefreshTokenChange());
|
//reaction((_) => refreshToken, (String _) => _onRefreshTokenChange());
|
||||||
emojiIncommingSC = StreamController<String>.broadcast();
|
emojiIncommingSC = StreamController<String>.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,18 +251,21 @@ abstract class YatStoreBase with Store {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
Future<void> _onRefreshTokenChange() async {
|
Future<void> _onRefreshTokenChange() async {
|
||||||
try {
|
throw Exception();
|
||||||
await secureStorage.write(key: yatRefreshTokenKey(_wallet.walletInfo.name), value: refreshToken);
|
|
||||||
accessToken = await fetchYatAccessToken(refreshToken);
|
//try {
|
||||||
await secureStorage.write(key: yatAccessTokenKey(_wallet.walletInfo.name), value: accessToken);
|
// await secureStorage.write(key: yatRefreshTokenKey(_wallet.walletInfo.name), value: refreshToken);
|
||||||
apiKey = await fetchYatApiKey(accessToken);
|
// accessToken = await fetchYatAccessToken(refreshToken);
|
||||||
await secureStorage.write(key: yatApiKey(_wallet.walletInfo.name), value: accessToken);
|
// await secureStorage.write(key: yatAccessTokenKey(_wallet.walletInfo.name), value: accessToken);
|
||||||
} catch (e) {
|
// apiKey = await fetchYatApiKey(accessToken);
|
||||||
print(e.toString());
|
// await secureStorage.write(key: yatApiKey(_wallet.walletInfo.name), value: accessToken);
|
||||||
}
|
//} catch (e) {
|
||||||
|
// print(e.toString());
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
String defineQueryParameters() {
|
String defineQueryParameters() {
|
||||||
|
throw Exception();
|
||||||
//final result = <String, String>{};
|
//final result = <String, String>{};
|
||||||
//final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()];
|
//final tags = YatLink.tags[_wallet.currency.toString().toUpperCase()];
|
||||||
//String tag = tags.first;
|
//String tag = tags.first;
|
||||||
|
|
|
@ -69,29 +69,29 @@ abstract class SettingsViewModelBase with Store {
|
||||||
_settingsStore.priority[wallet.type] = priorities.first;
|
_settingsStore.priority[wallet.type] = priorities.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
var connectYatUrl = YatLink.baseUrl + YatLink.signInSuffix;
|
//var connectYatUrl = YatLink.baseUrl + YatLink.signInSuffix;
|
||||||
final connectYatUrlParameters =
|
//final connectYatUrlParameters =
|
||||||
_yatStore.defineQueryParameters();
|
// _yatStore.defineQueryParameters();
|
||||||
|
|
||||||
if (connectYatUrlParameters.isNotEmpty) {
|
//if (connectYatUrlParameters.isNotEmpty) {
|
||||||
connectYatUrl += YatLink.queryParameter + connectYatUrlParameters;
|
// connectYatUrl += YatLink.queryParameter + connectYatUrlParameters;
|
||||||
}
|
//}
|
||||||
|
|
||||||
var manageYatUrl = YatLink.baseUrl + YatLink.managePath;
|
//var manageYatUrl = YatLink.baseUrl + YatLink.managePath;
|
||||||
final manageYatUrlParameters =
|
//final manageYatUrlParameters =
|
||||||
_yatStore.defineQueryParameters();
|
// _yatStore.defineQueryParameters();
|
||||||
|
|
||||||
if (manageYatUrlParameters.isNotEmpty) {
|
//if (manageYatUrlParameters.isNotEmpty) {
|
||||||
manageYatUrl += YatLink.queryParameter + manageYatUrlParameters;
|
// manageYatUrl += YatLink.queryParameter + manageYatUrlParameters;
|
||||||
}
|
//}
|
||||||
|
|
||||||
var createNewYatUrl = YatLink.startFlowUrl;
|
//var createNewYatUrl = YatLink.startFlowUrl;
|
||||||
final createNewYatUrlParameters =
|
//final createNewYatUrlParameters =
|
||||||
_yatStore.defineQueryParameters();
|
// _yatStore.defineQueryParameters();
|
||||||
|
|
||||||
if (createNewYatUrlParameters.isNotEmpty) {
|
//if (createNewYatUrlParameters.isNotEmpty) {
|
||||||
createNewYatUrl += '?sub1=' + createNewYatUrlParameters;
|
// createNewYatUrl += '?sub1=' + createNewYatUrlParameters;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
sections = [
|
sections = [
|
||||||
|
|
Loading…
Reference in a new issue