-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from k5924/HP-65
HP-65: Started Implementing Binance API
- Loading branch information
Showing
21 changed files
with
450 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'dart:convert'; | ||
import 'package:crypto/crypto.dart'; | ||
import 'package:monerate/src/providers/export.dart'; | ||
|
||
class BinanceExchangeProvider { | ||
final String url = "api.binance.com"; | ||
|
||
String _hmacSha256(String query, String secret) { | ||
final key = utf8.encode(secret); | ||
final msg = utf8.encode(query); | ||
final hmac = Hmac(sha256, key); | ||
final signature = hmac.convert(msg).toString(); | ||
|
||
return signature; | ||
} | ||
|
||
Future getBalances(String secret, String apiKey) async { | ||
final String timestamp = | ||
"timestamp=${DateTime.now().millisecondsSinceEpoch}"; | ||
final String query = '' + '&' + timestamp; | ||
final String signature = _hmacSha256(query, secret); | ||
final ExternalAPIProvider externalAPIProvider = ExternalAPIProvider( | ||
url: url, | ||
endPoint: '/api/v3/account', | ||
parameters: { | ||
'?': query, | ||
'&signature': signature, | ||
}, | ||
headers: { | ||
'X-MBX-APIKEY': apiKey, | ||
}, | ||
); | ||
final cryptoBalances = await externalAPIProvider.getData(); | ||
if (cryptoBalances.runtimeType == int) { | ||
return "error"; | ||
} else { | ||
return cryptoBalances; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
70 changes: 70 additions & 0 deletions
70
lib/src/screens/complete_profile/end_user/end_user_tab.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:monerate/src/screens/complete_profile/end_user/export.dart'; | ||
|
||
class EndUserTab extends StatefulWidget { | ||
const EndUserTab({Key? key}) : super(key: key); | ||
|
||
@override | ||
_EndUserTabState createState() => _EndUserTabState(); | ||
} | ||
|
||
class _EndUserTabState extends State<EndUserTab> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(25), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
"End-user", | ||
style: Theme.of(context).textTheme.headline3, | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
Image.asset( | ||
'assets/images/End-user complete profile.png', | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
Text( | ||
"I want to manage my finances", | ||
style: Theme.of(context).textTheme.headline5, | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
Navigator.pushNamed( | ||
context, | ||
CompleteEndUserProfile.kID, | ||
); | ||
}, | ||
style: ElevatedButton.styleFrom( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: 40, | ||
vertical: 10, | ||
), | ||
), | ||
child: const Text( | ||
"Complete Profile", | ||
style: TextStyle( | ||
fontSize: 24, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'complete_end_user_profile.dart'; | ||
export 'end_user_tab.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export 'complete_end_user_profile.dart'; | ||
export 'complete_financial_advisor_profile.dart'; | ||
export 'complete_profile_screen.dart'; | ||
export 'complete_support_manager_profile.dart'; | ||
export 'end_user/export.dart'; | ||
export 'financial_advisor/export.dart'; | ||
export 'support_manager/export.dart'; |
File renamed without changes.
2 changes: 2 additions & 0 deletions
2
lib/src/screens/complete_profile/financial_advisor/export.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'complete_financial_advisor_profile.dart'; | ||
export 'financial_advisor_tab.dart'; |
70 changes: 70 additions & 0 deletions
70
lib/src/screens/complete_profile/financial_advisor/financial_advisor_tab.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
import 'package:monerate/src/screens/complete_profile/financial_advisor/export.dart'; | ||
|
||
class FinancialAdvisorTab extends StatefulWidget { | ||
const FinancialAdvisorTab({Key? key}) : super(key: key); | ||
|
||
@override | ||
_FinancialAdvisorTabState createState() => _FinancialAdvisorTabState(); | ||
} | ||
|
||
class _FinancialAdvisorTabState extends State<FinancialAdvisorTab> { | ||
@override | ||
Widget build(BuildContext context) { | ||
return Center( | ||
child: SingleChildScrollView( | ||
child: Padding( | ||
padding: const EdgeInsets.all(25), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
Text( | ||
"Financial Advisor", | ||
style: Theme.of(context).textTheme.headline3, | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
Image.asset( | ||
'assets/images/Financial Advisor complete profile.png', | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
Text( | ||
"I want to give individuals financial advice", | ||
style: Theme.of(context).textTheme.headline5, | ||
textAlign: TextAlign.center, | ||
), | ||
const SizedBox( | ||
height: 25, | ||
), | ||
ElevatedButton( | ||
onPressed: () { | ||
Navigator.pushNamed( | ||
context, | ||
CompleteFinancialAdvisorProfile.kID, | ||
); | ||
}, | ||
style: ElevatedButton.styleFrom( | ||
padding: const EdgeInsets.symmetric( | ||
horizontal: 40, | ||
vertical: 10, | ||
), | ||
), | ||
child: const Text( | ||
"Complete Profile", | ||
style: TextStyle( | ||
fontSize: 24, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'complete_support_manager_profile.dart'; | ||
export 'support_manager_tab.dart'; | ||
|
Oops, something went wrong.