-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/Wallet-162: Show daos #223
Changes from all commits
75980f1
c3b3ba9
6a7a96f
c744573
b1d6313
55b4460
c5a03d4
bfc66d9
a10bfaf
e1e8df9
223d875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
import 'package:dio/dio.dart'; | ||
import 'package:hypha_wallet/core/error_handler/model/hypha_error.dart'; | ||
import 'package:hypha_wallet/core/logging/log_helper.dart'; | ||
import 'package:hypha_wallet/core/network/api/services/remote_config_service.dart'; | ||
import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; | ||
import 'package:hypha_wallet/core/network/models/user_profile_data.dart'; | ||
import 'package:hypha_wallet/core/network/networking_manager.dart'; | ||
import 'package:hypha_wallet/ui/architecture/result/result.dart'; | ||
|
||
class DaoService { | ||
final NetworkingManager networkingManager; | ||
final RemoteConfigService remoteConfigService; | ||
final NetworkingManager _networkingManager; | ||
final RemoteConfigService _remoteConfigService; | ||
|
||
DaoService({required this.networkingManager, required this.remoteConfigService}); | ||
const DaoService(this._networkingManager, this._remoteConfigService); | ||
|
||
Future<List<DaoData>> getDaos({ | ||
/// Get dao's for this account | ||
Future<Result<List<DaoData>, HyphaError>> getDaos({ | ||
required UserProfileData user, | ||
}) async { | ||
final String accountName = user.accountName; | ||
final String query = | ||
'{"query":"query profileDhos(\$username: String!, \$first: Int, \$offset: Int) { getMember(details_member_n: \$username) { docId __typename createdDate details_member_n memberofAggregate { count } memberof(first: \$first, offset: \$offset) { ... on Dao { docId details_daoName_n settings { settings_daoTitle_s settings_isHypha_i settings_logo_s settings_daoUrl_s } } } applicantof { ... on Dao { details_daoName_n settings { settings_daoTitle_s settings_daoUrl_s } } } } }","variables":{"username":"$accountName"}}'; | ||
|
||
final url = remoteConfigService.graphQLEndpoint(network: user.network); | ||
final url = _remoteConfigService.graphQLEndpoint(network: user.network); | ||
try { | ||
final res = await networkingManager.post(url, data: query); | ||
final res = await _networkingManager.post(url, data: query); | ||
final Map<String, dynamic> response = res.data; | ||
final List<dynamic> memberOfList = response['data']['getMember']['memberof']; | ||
final List<DaoData> daos = memberOfList.map((member) { | ||
return DaoData.fromJson(member); | ||
}).toList(); | ||
return daos; | ||
return Result.value(daos); | ||
} catch (error) { | ||
print('Error accessing graphQL'); | ||
print(error); | ||
if (error is DioException) { | ||
final dioError = error; | ||
print('message: ${dioError.message}'); | ||
print('status code: ${dioError.response?.statusCode}'); | ||
print('message: ${dioError.response?.statusMessage}'); | ||
print('dioError: $dioError'); | ||
LogHelper.d('message: ${dioError.message}'); | ||
LogHelper.d('status code: ${dioError.response?.statusCode}'); | ||
LogHelper.d('message: ${dioError.response?.statusMessage}'); | ||
LogHelper.d('dioError: $dioError'); | ||
} | ||
rethrow; | ||
|
||
|
||
LogHelper.e('Error accessing graphQL'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls use log helper and not print There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code you replaced this with doesn't do the same thing - in this case I needed to know specifically what the error responses look like.. We should probably keep it this way, although, OK, I can add it back when debugging. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If your need to know is for debug purposes then we should not release with debug code. |
||
LogHelper.e(error.toString()); | ||
return Result.error(HyphaError.fromError(error)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,10 +163,10 @@ class RemoteConfigService { | |
'accountCreatorEndpoint': 'http://34.236.29.152:9108', | ||
'profileServiceEndpoint': 'http://34.236.29.152:9109', | ||
'profileService': json.encode({ | ||
'telos': pppConfig.getProfileSeriviceConfig(Network.telos), | ||
'telosTestnet': pppConfig.getProfileSeriviceConfig(Network.telosTestnet), | ||
'eos': pppConfig.getProfileSeriviceConfig(Network.eos), | ||
'eosTestnet': pppConfig.getProfileSeriviceConfig(Network.eosTestnet), | ||
'telos': pppConfig.getProfileServiceConfig(Network.telos), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo rename |
||
'telosTestnet': pppConfig.getProfileServiceConfig(Network.telosTestnet), | ||
'eos': pppConfig.getProfileServiceConfig(Network.eos), | ||
'eosTestnet': pppConfig.getProfileServiceConfig(Network.eosTestnet), | ||
}), | ||
'signUpEnabled': false, | ||
'walletEnabled': false, | ||
|
@@ -184,7 +184,7 @@ class RemoteConfigService { | |
} | ||
|
||
extension MapExtensions on Map<String, dynamic> { | ||
Map<String, dynamic> getProfileSeriviceConfig(Network network) { | ||
Map<String, dynamic> getProfileServiceConfig(Network network) { | ||
final networkMap = { | ||
Network.telos: 'prod', | ||
Network.telosTestnet: 'test', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hypha_wallet/core/network/models/dao_data_model.dart'; | ||
import 'package:hypha_wallet/design/hypha_card.dart'; | ||
import 'package:hypha_wallet/design/themes/extensions/theme_extension_provider.dart'; | ||
|
||
class DaoWidget extends StatelessWidget { | ||
final DaoData dao; | ||
|
||
const DaoWidget({ | ||
super.key, | ||
required this.dao, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Padding( | ||
padding: const EdgeInsets.symmetric(horizontal: 22), | ||
child: HyphaCard( | ||
child: InkWell( | ||
borderRadius: BorderRadius.circular(16), | ||
onTap: () {}, | ||
child: Padding( | ||
padding: const EdgeInsets.only(left: 22, right: 22, top: 12, bottom: 22), | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.start, | ||
crossAxisAlignment: CrossAxisAlignment.start, | ||
children: [ | ||
ListTile( | ||
dense: true, | ||
// leading: FutureBuilder<String>( | ||
// future: fetchSVGFromIPFS('QmV3KmaoqCCXuCDvHzYWS9Jg3RfjrDTQSXK1e7453qfSRS'), | ||
// builder: (context, snapshot) { | ||
// if (snapshot.connectionState == ConnectionState.waiting) { | ||
// return CircularProgressIndicator(); | ||
// } else if (snapshot.hasError) { | ||
// return Text('Error: ${snapshot.error}'); | ||
// } else { | ||
// return SvgPicture.string(snapshot.data!); | ||
// } | ||
// }, | ||
// ), | ||
visualDensity: VisualDensity.compact, | ||
title: Text(dao.settingsDaoTitle, style: context.hyphaTextTheme.smallTitles), | ||
), | ||
// const SizedBox(height: 14), | ||
// const HyphaDivider(), | ||
// const SizedBox(height: 20), | ||
], | ||
), | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
// Future<String> fetchSVGFromIPFS(String ipfsHash) async { | ||
// final ipfsURL = 'https://ipfs.io/ipfs/$ipfsHash:svg'; | ||
// final response = await http.get(Uri.parse(ipfsURL)); | ||
// | ||
// if (response.statusCode == 200) { | ||
// return response.body; | ||
// } else { | ||
// throw Exception('Failed to fetch SVG from IPFS. Status code: ${response.statusCode}'); | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls return Result from all services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am creating a ticket for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#224