diff --git a/assets/image/wallet-certificate-android.png b/assets/image/wallet-certificate-android.png index d84aec3c7..06e675c52 100644 Binary files a/assets/image/wallet-certificate-android.png and b/assets/image/wallet-certificate-android.png differ diff --git a/assets/image/wallet-certificate-ios.png b/assets/image/wallet-certificate-ios.png index 6d2247a11..06d217e80 100644 Binary files a/assets/image/wallet-certificate-ios.png and b/assets/image/wallet-certificate-ios.png differ diff --git a/lib/app/shared/constants/secure_storage_keys.dart b/lib/app/shared/constants/secure_storage_keys.dart index 48c471af4..ac545ddb5 100644 --- a/lib/app/shared/constants/secure_storage_keys.dart +++ b/lib/app/shared/constants/secure_storage_keys.dart @@ -62,7 +62,7 @@ class SecureStorageKeys { static const String polygonIdNetwork = 'profile/polygonIdNetwork'; static const String didKeyType = 'profile/didKeyType'; - static const String blockchainNetworkKey = 'profile/blockchainNetwork'; + static const String blockChainNetworksIndexing = 'blockChainNetworksIndexing'; static const String credentialKey = 'credential'; static const String ssiMnemonic = 'ssi/mnemonic'; diff --git a/lib/app/shared/enum/status/app_status.dart b/lib/app/shared/enum/status/app_status.dart index 8aefb89c5..f45e362df 100644 --- a/lib/app/shared/enum/status/app_status.dart +++ b/lib/app/shared/enum/status/app_status.dart @@ -8,5 +8,5 @@ enum AppStatus { success, idle, goBack, - gotTokenReward, + //gotTokenReward, } diff --git a/lib/app/shared/models/blockchain_network/tezos_network.dart b/lib/app/shared/models/blockchain_network/tezos_network.dart index b8a8c9063..67d946f9e 100644 --- a/lib/app/shared/models/blockchain_network/tezos_network.dart +++ b/lib/app/shared/models/blockchain_network/tezos_network.dart @@ -11,15 +11,15 @@ class TezosNetwork extends BlockchainNetwork { required super.rpcNodeUrl, required String super.title, required String super.subTitle, + required super.type, super.apiKey, - }) : super( - type: BlockchainType.tezos, - ); + }); factory TezosNetwork.fromJson(Map json) => _$TezosNetworkFromJson(json); factory TezosNetwork.mainNet() => const TezosNetwork( + type: BlockchainType.tezos, networkname: 'Mainnet', apiUrl: Urls.tzktMainnetUrl, rpcNodeUrl: Urls.mainnetRPC, @@ -30,6 +30,7 @@ class TezosNetwork extends BlockchainNetwork { ); factory TezosNetwork.ghostnet() => const TezosNetwork( + type: BlockchainType.tezos, networkname: 'Ghostnet', apiUrl: Urls.tzktGhostnetUrl, rpcNodeUrl: Urls.ghostnetRPC, diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 44f9d4e73..a72b3fbd3 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -78,11 +78,6 @@ class App extends StatelessWidget { ); }, ), - BlocProvider( - create: (context) => ManageNetworkCubit( - secureStorageProvider: secure_storage.getSecureStorage, - ), - ), BlocProvider( create: (context) => DIDCubit( secureStorageProvider: secure_storage.getSecureStorage, @@ -130,6 +125,12 @@ class App extends StatelessWidget { walletConnectCubit: context.read(), ), ), + BlocProvider( + create: (context) => ManageNetworkCubit( + secureStorageProvider: secure_storage.getSecureStorage, + walletCubit: context.read(), + ), + ), BlocProvider( create: (context) => PolygonIdCubit( client: DioClient('', Dio()), diff --git a/lib/credentials/cubit/credentials_cubit.dart b/lib/credentials/cubit/credentials_cubit.dart index 0c55b5182..47228fd81 100644 --- a/lib/credentials/cubit/credentials_cubit.dart +++ b/lib/credentials/cubit/credentials_cubit.dart @@ -439,15 +439,46 @@ class CredentialsCubit extends Cubit { /// update or create AssociatedAddres credential with new name if (filteredCredentialList.isNotEmpty) { - final credential = await createAssociatedWalletCredential( + //find old id of the credential + final oldCredential = oldCredentialList.where((CredentialModel element) { + final credentialSubjectModel = + element.credentialPreview.credentialSubjectModel; + + String? walletAddress; + + if (credentialSubjectModel is EthereumAssociatedAddressModel) { + walletAddress = credentialSubjectModel.associatedAddress; + } else if (credentialSubjectModel is TezosAssociatedAddressModel) { + walletAddress = credentialSubjectModel.associatedAddress; + } else if (credentialSubjectModel is FantomAssociatedAddressModel) { + walletAddress = credentialSubjectModel.associatedAddress; + } else if (credentialSubjectModel is BinanceAssociatedAddressModel) { + walletAddress = credentialSubjectModel.associatedAddress; + } else if (credentialSubjectModel is PolygonAssociatedAddressModel) { + walletAddress = credentialSubjectModel.associatedAddress; + } else { + return false; + } + + if (walletAddress != null && + walletAddress == cryptoAccountData.walletAddress) { + return true; + } + + return false; + }).first; + + // final credential = state.credentials.where((element) => element.); + final credential = await createOrUpdateAssociatedWalletCredential( blockchainType: blockchainType, cryptoAccountData: cryptoAccountData, + oldId: oldCredential.id, ); if (credential != null) { await updateCredential(credential: credential); } } else { - final credential = await createAssociatedWalletCredential( + final credential = await createOrUpdateAssociatedWalletCredential( blockchainType: blockchainType, cryptoAccountData: cryptoAccountData, ); @@ -457,9 +488,10 @@ class CredentialsCubit extends Cubit { } } - Future createAssociatedWalletCredential({ + Future createOrUpdateAssociatedWalletCredential({ required BlockchainType blockchainType, required CryptoAccountData cryptoAccountData, + String? oldId, }) async { return generateAssociatedWalletCredential( cryptoAccountData: cryptoAccountData, @@ -467,6 +499,7 @@ class CredentialsCubit extends Cubit { didKitProvider: didKitProvider, blockchainType: blockchainType, keyGenerator: keyGenerator, + oldId: oldId, ); } diff --git a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/manage_accounts_page.dart b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/manage_accounts_page.dart index ad948016e..6ec7e9690 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/manage_accounts_page.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_accounts/view/manage_accounts_page.dart @@ -32,6 +32,7 @@ class _ManageAccountsPageState extends State { final l10n = context.l10n; final List cryptoAccount = context.read().state.cryptoAccount.data; + final accountNameList = cryptoAccount.map((e) => e.name).toList(); final cryptoAccountData = cryptoAccount[index]; diff --git a/lib/dashboard/drawer/blockchain_settings/manage_network/cubit/manage_network_cubit.dart b/lib/dashboard/drawer/blockchain_settings/manage_network/cubit/manage_network_cubit.dart index 626a2895e..1f74aa5a6 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_network/cubit/manage_network_cubit.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_network/cubit/manage_network_cubit.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:altme/app/app.dart'; +import 'package:altme/wallet/cubit/wallet_cubit.dart'; import 'package:bloc/bloc.dart'; import 'package:equatable/equatable.dart'; import 'package:json_annotation/json_annotation.dart'; @@ -11,28 +12,42 @@ part 'manage_network_cubit.g.dart'; part 'manage_network_state.dart'; class ManageNetworkCubit extends Cubit { - ManageNetworkCubit({required this.secureStorageProvider}) - : super(ManageNetworkState(network: TezosNetwork.mainNet())) { - _load(); + ManageNetworkCubit({ + required this.secureStorageProvider, + required this.walletCubit, + }) : super(ManageNetworkState(network: TezosNetwork.mainNet())) { + loadNetwork(); } final SecureStorageProvider secureStorageProvider; + final WalletCubit walletCubit; - Future _load() async { - final blockchainNetworkJson = - await secureStorageProvider.get(SecureStorageKeys.blockchainNetworkKey); + Future loadNetwork() async { + final blockchainType = walletCubit.state.currentAccount?.blockchainType; - late final BlockchainNetwork blockchainNetwork; + if (blockchainType == null) return; + + late BlockchainNetwork blockchainNetwork; + + final blockchainNetworkJson = await secureStorageProvider + .get(SecureStorageKeys.blockChainNetworksIndexing); if (blockchainNetworkJson != null) { - final mJson = json.decode(blockchainNetworkJson) as Map; - if (mJson['chain'] != null) { - blockchainNetwork = EthereumNetwork.fromJson(mJson); + final jsonData = + json.decode(blockchainNetworkJson) as Map; + + final key = blockchainType.name; + + if (jsonData.containsKey(key)) { + final index = jsonData[key] as int; + blockchainNetwork = blockchainType.networks[index]; } else { - blockchainNetwork = BlockchainNetwork.fromJson(mJson); + // take index 0 of the current account + blockchainNetwork = blockchainType.networks[0]; } } else { - blockchainNetwork = TezosNetwork.mainNet(); + // take index 0 of the current account + blockchainNetwork = blockchainType.networks[0]; } emit(state.copyWith(network: blockchainNetwork)); @@ -40,18 +55,34 @@ class ManageNetworkCubit extends Cubit { Future setNetwork(BlockchainNetwork network) async { if (network == state.network) return; - Map networkJson; - if (network is EthereumNetwork) { - networkJson = network.toJson(); - } else if (network is TezosNetwork) { - networkJson = network.toJson(); + + final blockchainNetworkJson = await secureStorageProvider + .get(SecureStorageKeys.blockChainNetworksIndexing); + + late Map jsonData; + + if (blockchainNetworkJson != null) { + jsonData = json.decode(blockchainNetworkJson) as Map; } else { - networkJson = network.toJson(); + jsonData = {}; } + + final blockchainType = network.type; + final supportedNetworks = blockchainType.networks; + final key = blockchainType.name; + + final index = supportedNetworks.indexOf(network); + + /// map with index is saved + /// {'tezos': 1 , 'ethereum': 1} + + jsonData[key] = index; + await secureStorageProvider.set( - SecureStorageKeys.blockchainNetworkKey, - jsonEncode(networkJson), + SecureStorageKeys.blockChainNetworksIndexing, + jsonEncode(jsonData), ); + emit(state.copyWith(network: network)); } } diff --git a/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart b/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart index 35f22f130..9f326e49e 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_network/view/manage_network_page.dart @@ -28,7 +28,7 @@ class ManageNetworkPage extends StatelessWidget { builder: (context, state) { final blockchainType = context.read().state.currentAccount!.blockchainType; - final allNetworks = blockchainType.networks; + final currentNetworkList = blockchainType.networks; return BackgroundCard( child: Column( @@ -41,27 +41,30 @@ class ManageNetworkPage extends StatelessWidget { ), ), const SizedBox(height: 15), - ...List.generate(allNetworks.length, (index) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - NetworkSelector( - network: allNetworks[index], - groupValue: state.network, - ), - Padding( - padding: const EdgeInsets.symmetric( - horizontal: Sizes.spaceSmall, - vertical: Sizes.spaceXSmall, + ...List.generate( + currentNetworkList.length, + (index) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + NetworkSelector( + network: currentNetworkList[index], + groupValue: state.network, ), - child: Divider( - height: 0.2, - color: Theme.of(context).colorScheme.borderColor, + Padding( + padding: const EdgeInsets.symmetric( + horizontal: Sizes.spaceSmall, + vertical: Sizes.spaceXSmall, + ), + child: Divider( + height: 0.2, + color: Theme.of(context).colorScheme.borderColor, + ), ), - ), - ], - ); - }), + ], + ); + }, + ), ], ), ); diff --git a/lib/dashboard/drawer/blockchain_settings/manage_network/widgets/network_selector.dart b/lib/dashboard/drawer/blockchain_settings/manage_network/widgets/network_selector.dart index 4416928c8..2a37052e3 100644 --- a/lib/dashboard/drawer/blockchain_settings/manage_network/widgets/network_selector.dart +++ b/lib/dashboard/drawer/blockchain_settings/manage_network/widgets/network_selector.dart @@ -16,8 +16,7 @@ class NetworkSelector extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocConsumer( - listener: (context, state) {}, + return BlocBuilder( builder: (context, state) { return RadioListTile( value: network, diff --git a/lib/dashboard/home/home/cubit/home_cubit.dart b/lib/dashboard/home/home/cubit/home_cubit.dart index 5a141df00..5a90cc36e 100644 --- a/lib/dashboard/home/home/cubit/home_cubit.dart +++ b/lib/dashboard/home/home/cubit/home_cubit.dart @@ -267,157 +267,157 @@ class HomeCubit extends Cubit { await LaunchUrl.launch(link ?? state.link!); } - Future periodicCheckRewardOnTezosBlockchain() async { - Timer.periodic(const Duration(minutes: 1), (timer) async { - List walletAddresses = []; - final String? savedCryptoAccount = - await secureStorageProvider.get(SecureStorageKeys.cryptoAccount); - - if (savedCryptoAccount != null && savedCryptoAccount.isNotEmpty) { - //load all the content of walletAddress - final cryptoAccountJson = - jsonDecode(savedCryptoAccount) as Map; - final CryptoAccount cryptoAccount = - CryptoAccount.fromJson(cryptoAccountJson); - - walletAddresses = - cryptoAccount.data.map((e) => e.walletAddress).toList(); - } - if (walletAddresses.isEmpty) return; - try { - final tezosWalletAddresses = - walletAddresses.where((e) => e.startsWith('tz')).toList(); - if (tezosWalletAddresses.isEmpty) return; - await checkRewards(tezosWalletAddresses); - } catch (e, s) { - getLogger('HomeCubit') - .e('error in checking for reward , error: $e, stack: $s'); - } - }); - } - - Future checkRewards(List walletAddresses) async { - for (int i = 0; i < walletAddresses.length; i++) { - await checkUNOReward(walletAddresses[i]); - await checkXTZReward(walletAddresses[i]); - } - } - - Future checkUNOReward(String walletAddress) async { - getLogger('HomeCubit').i('check for UNO reward'); - final response = await client.get( - '${Urls.tzktMainnetUrl}/v1/tokens/transfers', - queryParameters: { - 'from': 'tz1YtKsJMx5FqhULTDzNxs9r9QYHBGsmz58o', // tezotopia - 'to': walletAddress, - 'token.contract.eq': 'KT1ErKVqEhG9jxXgUG2KGLW3bNM7zXHX8SDF', // UNO - 'sort.desc': 'timestamp', - }, - ) as List; - - if (response.isEmpty) { - return; - } - - final operations = response - .map( - (dynamic e) => OperationModel.fromFa2Json(e as Map), - ) - .toList(); - - final String? lastNotifiedRewardId = await secureStorageProvider.get( - SecureStorageKeys.lastNotifiedUNORewardId + walletAddress, - ); - - final lastOperation = operations.first; //operations sorted by time in api - if (lastOperation.id.toString() == lastNotifiedRewardId) { - return; - } else { - // save the operation id to storage - await secureStorageProvider.set( - SecureStorageKeys.lastNotifiedUNORewardId + walletAddress, - lastOperation.id.toString(), - ); - - emit( - state.copyWith( - status: AppStatus.gotTokenReward, - tokenReward: TokenReward( - amount: lastOperation.calcAmount( - decimal: 9, //UNO - value: lastOperation.amount.toString(), - ), - txId: lastOperation.hash, - counter: lastOperation.counter, - account: walletAddress, - origin: - 'Tezotopia Membership Card', // TODO(all): dynamic text later - symbol: 'UNO', - name: 'Unobtanium', - ), - ), - ); - } - } - - Future checkXTZReward(String walletAddress) async { - getLogger('HomeCubit').i('check for XTZ reward'); - - final result = await client.get( - '${Urls.tzktMainnetUrl}/v1/operations/transactions', - queryParameters: { - 'sender': 'tz1YtKsJMx5FqhULTDzNxs9r9QYHBGsmz58o', // tezotopia - 'target': walletAddress, - 'amount.gt': 0, - }, - ) as List; - - if (result.isEmpty) { - return; - } - - final operations = result - .map( - (dynamic e) => OperationModel.fromJson(e as Map), - ) - .toList(); - //sort for last transaction at first - operations.sort( - (a, b) => b.dateTime.compareTo(a.dateTime), - ); - - final String? lastNotifiedRewardId = await secureStorageProvider.get( - SecureStorageKeys.lastNotifiedXTZRewardId + walletAddress, - ); - - final lastOperation = operations.first; //operations sorted by time in api - if (lastOperation.id.toString() == lastNotifiedRewardId) { - return; - } else { - // save the operation id to storage - await secureStorageProvider.set( - SecureStorageKeys.lastNotifiedXTZRewardId + walletAddress, - lastOperation.id.toString(), - ); - - emit( - state.copyWith( - status: AppStatus.gotTokenReward, - tokenReward: TokenReward( - amount: lastOperation.calcAmount( - decimal: 6, //XTZ - value: lastOperation.amount.toString(), - ), - account: walletAddress, - txId: lastOperation.hash, - counter: lastOperation.counter, - origin: - 'Tezotopia Membership Card', // TODO(all): dynamic text later - symbol: 'XTZ', - name: 'Tezos', - ), - ), - ); - } - } + // Future periodicCheckRewardOnTezosBlockchain() async { + // Timer.periodic(const Duration(minutes: 1), (timer) async { + // List walletAddresses = []; + // final String? savedCryptoAccount = + // await secureStorageProvider.get(SecureStorageKeys.cryptoAccount); + + // if (savedCryptoAccount != null && savedCryptoAccount.isNotEmpty) { + // //load all the content of walletAddress + // final cryptoAccountJson = + // jsonDecode(savedCryptoAccount) as Map; + // final CryptoAccount cryptoAccount = + // CryptoAccount.fromJson(cryptoAccountJson); + + // walletAddresses = + // cryptoAccount.data.map((e) => e.walletAddress).toList(); + // } + // if (walletAddresses.isEmpty) return; + // try { + // final tezosWalletAddresses = + // walletAddresses.where((e) => e.startsWith('tz')).toList(); + // if (tezosWalletAddresses.isEmpty) return; + // await checkRewards(tezosWalletAddresses); + // } catch (e, s) { + // getLogger('HomeCubit') + // .e('error in checking for reward , error: $e, stack: $s'); + // } + // }); + // } + + // Future checkRewards(List walletAddresses) async { + // for (int i = 0; i < walletAddresses.length; i++) { + // await checkUNOReward(walletAddresses[i]); + // await checkXTZReward(walletAddresses[i]); + // } + // } + + // Future checkUNOReward(String walletAddress) async { + // getLogger('HomeCubit').i('check for UNO reward'); + // final response = await client.get( + // '${Urls.tzktMainnetUrl}/v1/tokens/transfers', + // queryParameters: { + // 'from': 'tz1YtKsJMx5FqhULTDzNxs9r9QYHBGsmz58o', // tezotopia + // 'to': walletAddress, + // 'token.contract.eq': 'KT1ErKVqEhG9jxXgUG2KGLW3bNM7zXHX8SDF', // UNO + // 'sort.desc': 'timestamp', + // }, + // ) as List; + + // if (response.isEmpty) { + // return; + // } + + // final operations = response + // .map( + // (dynamic e) => OperationModel.fromFa2Json(e as Map), + // ) + // .toList(); + + // final String? lastNotifiedRewardId = await secureStorageProvider.get( + // SecureStorageKeys.lastNotifiedUNORewardId + walletAddress, + // ); + + // final lastOperation = operations.first; //operations sorted by time in api + // if (lastOperation.id.toString() == lastNotifiedRewardId) { + // return; + // } else { + // // save the operation id to storage + // await secureStorageProvider.set( + // SecureStorageKeys.lastNotifiedUNORewardId + walletAddress, + // lastOperation.id.toString(), + // ); + + // emit( + // state.copyWith( + // status: AppStatus.gotTokenReward, + // tokenReward: TokenReward( + // amount: lastOperation.calcAmount( + // decimal: 9, //UNO + // value: lastOperation.amount.toString(), + // ), + // txId: lastOperation.hash, + // counter: lastOperation.counter, + // account: walletAddress, + // origin: + // 'Tezotopia Membership Card', // TODO(all): dynamic text later + // symbol: 'UNO', + // name: 'Unobtanium', + // ), + // ), + // ); + // } + // } + + // Future checkXTZReward(String walletAddress) async { + // getLogger('HomeCubit').i('check for XTZ reward'); + + // final result = await client.get( + // '${Urls.tzktMainnetUrl}/v1/operations/transactions', + // queryParameters: { + // 'sender': 'tz1YtKsJMx5FqhULTDzNxs9r9QYHBGsmz58o', // tezotopia + // 'target': walletAddress, + // 'amount.gt': 0, + // }, + // ) as List; + + // if (result.isEmpty) { + // return; + // } + + // final operations = result + // .map( + // (dynamic e) => OperationModel.fromJson(e as Map), + // ) + // .toList(); + // //sort for last transaction at first + // operations.sort( + // (a, b) => b.dateTime.compareTo(a.dateTime), + // ); + + // final String? lastNotifiedRewardId = await secureStorageProvider.get( + // SecureStorageKeys.lastNotifiedXTZRewardId + walletAddress, + // ); + + // final lastOperation = operations.first; //operations sorted by time in api + // if (lastOperation.id.toString() == lastNotifiedRewardId) { + // return; + // } else { + // // save the operation id to storage + // await secureStorageProvider.set( + // SecureStorageKeys.lastNotifiedXTZRewardId + walletAddress, + // lastOperation.id.toString(), + // ); + + // emit( + // state.copyWith( + // status: AppStatus.gotTokenReward, + // tokenReward: TokenReward( + // amount: lastOperation.calcAmount( + // decimal: 6, //XTZ + // value: lastOperation.amount.toString(), + // ), + // account: walletAddress, + // txId: lastOperation.hash, + // counter: lastOperation.counter, + // origin: + // 'Tezotopia Membership Card', // TODO(all): dynamic text later + // symbol: 'XTZ', + // name: 'Tezos', + // ), + // ), + // ); + // } + // } } diff --git a/lib/dashboard/home/home/view/home_page.dart b/lib/dashboard/home/home/view/home_page.dart index 5925a0691..d3ff910ef 100644 --- a/lib/dashboard/home/home/view/home_page.dart +++ b/lib/dashboard/home/home/view/home_page.dart @@ -25,13 +25,13 @@ class HomePage extends StatelessWidget { if (homeState.status == AppStatus.success) {} - if (homeState.status == AppStatus.gotTokenReward && - homeState.tokenReward != null) { - TokenRewardDialog.show( - context: context, - tokenReward: homeState.tokenReward!, - ); - } + // if (homeState.status == AppStatus.gotTokenReward && + // homeState.tokenReward != null) { + // TokenRewardDialog.show( + // context: context, + // tokenReward: homeState.tokenReward!, + // ); + // } }, child: Parameters.walletHandlesCrypto ? const TabControllerPage() diff --git a/lib/dashboard/profile/cubit/profile_cubit.dart b/lib/dashboard/profile/cubit/profile_cubit.dart index a4086f68c..c6370a262 100644 --- a/lib/dashboard/profile/cubit/profile_cubit.dart +++ b/lib/dashboard/profile/cubit/profile_cubit.dart @@ -79,13 +79,6 @@ class ProfileCubit extends Cubit { (await secureStorageProvider.get(SecureStorageKeys.didKeyType)) ?? DidKeyType.ebsiv3.toString(); - final tezosNetworkJson = await secureStorageProvider - .get(SecureStorageKeys.blockchainNetworkKey); - final tezosNetwork = tezosNetworkJson != null - ? TezosNetwork.fromJson( - json.decode(tezosNetworkJson) as Map, - ) - : TezosNetwork.mainNet(); final isEnterprise = (await secureStorageProvider .get(SecureStorageKeys.isEnterpriseUser)) == 'true'; @@ -168,7 +161,6 @@ class ProfileCubit extends Cubit { email: email, polygonIdNetwork: polygonIdNetwork, didKeyType: didKeyType, - tezosNetwork: tezosNetwork, companyName: companyName, companyWebsite: companyWebsite, jobTitle: jobTitle, diff --git a/lib/dashboard/profile/models/profile.dart b/lib/dashboard/profile/models/profile.dart index 51ccc95ef..ff2488187 100644 --- a/lib/dashboard/profile/models/profile.dart +++ b/lib/dashboard/profile/models/profile.dart @@ -13,7 +13,6 @@ class ProfileModel extends Equatable { required this.location, required this.email, required this.polygonIdNetwork, - required this.tezosNetwork, required this.didKeyType, required this.isEnterprise, required this.isBiometricEnabled, @@ -52,7 +51,6 @@ class ProfileModel extends Equatable { userConsentForIssuerAccess: true, userConsentForVerifierAccess: true, userPINCodeForAuthentication: true, - tezosNetwork: TezosNetwork.mainNet(), didKeyType: DidKeyType.ebsiv3.toString(), enableSecurity: false, isDeveloperMode: false, @@ -74,7 +72,6 @@ class ProfileModel extends Equatable { final String companyWebsite; final String jobTitle; final String polygonIdNetwork; - final TezosNetwork tezosNetwork; final String didKeyType; final bool isEnterprise; final bool isBiometricEnabled; @@ -100,7 +97,6 @@ class ProfileModel extends Equatable { location, email, polygonIdNetwork, - tezosNetwork, didKeyType, companyName, companyWebsite, @@ -160,7 +156,6 @@ class ProfileModel extends Equatable { companyWebsite: companyWebsite ?? this.companyWebsite, jobTitle: jobTitle ?? this.jobTitle, polygonIdNetwork: polygonIdNetwork ?? this.polygonIdNetwork, - tezosNetwork: tezosNetwork ?? this.tezosNetwork, didKeyType: didKeyType ?? this.didKeyType, isEnterprise: isEnterprise ?? this.isEnterprise, isBiometricEnabled: isBiometricEnabled ?? this.isBiometricEnabled, diff --git a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart index 00e704037..f3c6320d0 100644 --- a/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart +++ b/lib/dashboard/qr_code/qr_code_scan/cubit/qr_code_scan_cubit.dart @@ -496,12 +496,12 @@ class QRCodeScanCubit extends Cubit { final keys = []; state.uri?.queryParameters.forEach((key, value) => keys.add(key)); - if (keys.contains('claims')) { - /// claims is old standard - throw ResponseMessage( - message: ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, - ); - } + // if (keys.contains('claims')) { + // /// claims is old standard + // throw ResponseMessage( + // message: ResponseString.RESPONSE_STRING_thisRequestIsNotSupported, + // ); + // } if (!keys.contains('response_type')) { throw ResponseMessage( @@ -608,7 +608,7 @@ class QRCodeScanCubit extends Cubit { /// contain id_token but may or may not contain vp_token if (hasIDToken(responseType)) { final scope = state.uri!.queryParameters['scope']; - if (scope == null || scope != 'openid') { + if (scope == null || !scope.contains('openid')) { throw ResponseMessage( data: { 'error': 'invalid_request', @@ -949,10 +949,9 @@ class QRCodeScanCubit extends Cubit { } final isSecurityEnabled = profileCubit.state.model.enableSecurity; + final enableJWKThumbprint = profileCubit.state.model.enableJWKThumbprint; - if (!isSecurityEnabled) { - emit(state.acceptHost()); - } else { + if (isSecurityEnabled && enableJWKThumbprint) { final Map payload = decodePayload(jwtDecode: jwtDecode, token: encodedData as String); @@ -986,6 +985,8 @@ class QRCodeScanCubit extends Cubit { ), ); } + } else { + emit(state.acceptHost()); } } @@ -1011,6 +1012,8 @@ class QRCodeScanCubit extends Cubit { secureStorage: secureStorageProvider, ); + final enableJWKThumbprint = profileCubit.state.model.enableJWKThumbprint; + final Response response = await oidc4vc.siopv2Flow( clientId: clientId, privateKey: privateKey, @@ -1019,7 +1022,7 @@ class QRCodeScanCubit extends Cubit { redirectUri: redirectUri, nonce: nonce, stateValue: stateValue, - useJWKThumbPrint: profileCubit.state.model.enableJWKThumbprint, + useJWKThumbPrint: enableJWKThumbprint, ); String? url; diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index 58d1b5282..1388f0497 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -703,7 +703,6 @@ "trooperzPassWhyGetThisCard": "This Membership card will give you 25% cash backs on ALL Tezotopia Game transactions when you buy a Drops on the marketplace or mint an NFT on starbase.", "trooperzPassExpirationDate": "This card will remain active and reusable for 1 YEAR.", "trooperzPassHowToGetIt": "You need to present a Nationality Proof and an Age Range Proof. Claim them by following Altme’s KYC check.", - "wallet_credential": "Wallet Credential", "walletSecurity": "Wallet Security", "walletSecurityDescription": "Protect your wallet with Pin Code and Biometrics Authentication", "blockchainSettings": "Blockchain Settings", diff --git a/lib/l10n/arb/app_fr.arb b/lib/l10n/arb/app_fr.arb index a51e8ce91..a381dec4b 100644 --- a/lib/l10n/arb/app_fr.arb +++ b/lib/l10n/arb/app_fr.arb @@ -686,7 +686,6 @@ "trooperzPassWhyGetThisCard": "Cette carte de membre vous donnera 25 % de remise en argent sur TOUTES les transactions du jeu Tezotopia lorsque vous achetez un Drops sur le marché ou frappez un NFT sur starbase.", "trooperzPassExpirationDate": "Cette carte restera active et réutilisable pendant 1 AN.", "trooperzPassHowToGetIt": "Vous devez présenter une preuve de nationalité et une preuve de tranche d'âge. Réclamez-les en suivant la vérification KYC d'Altme.", - "wallet_credential": "Identifiant de portefeuille", "walletSecurity": "Sécurité du portefeuille", "walletSecurityDescription": "Protégez votre portefeuille avec le code PIN et l'authentification biométrique", "blockchainSettings": "Paramètres de la chaîne de blocs", diff --git a/lib/l10n/untranslated.json b/lib/l10n/untranslated.json index fb7287fe7..4f54b83e2 100644 --- a/lib/l10n/untranslated.json +++ b/lib/l10n/untranslated.json @@ -639,7 +639,6 @@ "trooperzPassWhyGetThisCard", "trooperzPassExpirationDate", "trooperzPassHowToGetIt", - "wallet_credential", "walletSecurity", "walletSecurityDescription", "blockchainSettings", @@ -1552,7 +1551,6 @@ "trooperzPassWhyGetThisCard", "trooperzPassExpirationDate", "trooperzPassHowToGetIt", - "wallet_credential", "walletSecurity", "walletSecurityDescription", "blockchainSettings", @@ -2681,7 +2679,6 @@ "trooperzPassWhyGetThisCard", "trooperzPassExpirationDate", "trooperzPassHowToGetIt", - "wallet_credential", "walletSecurity", "walletSecurityDescription", "blockchainSettings", diff --git a/lib/splash/bloclisteners/blocklisteners.dart b/lib/splash/bloclisteners/blocklisteners.dart index 89fbc656a..c7343e657 100644 --- a/lib/splash/bloclisteners/blocklisteners.dart +++ b/lib/splash/bloclisteners/blocklisteners.dart @@ -120,24 +120,8 @@ final walletBlocAccountChangeListener = BlocListener( } }, listener: (context, state) async { - final BlockchainType? blockchainType = state.currentAccount?.blockchainType; - if (blockchainType == null) return; - BlockchainNetwork network; - if (blockchainType == BlockchainType.tezos) { - network = TezosNetwork.mainNet(); - } else if (blockchainType == BlockchainType.ethereum) { - network = EthereumNetwork.mainNet(); - } else if (blockchainType == BlockchainType.polygon) { - network = PolygonNetwork.mainNet(); - } else if (blockchainType == BlockchainType.fantom) { - network = FantomNetwork.mainNet(); - } else if (blockchainType == BlockchainType.binance) { - network = BinanceNetwork.mainNet(); - } else { - network = TezosNetwork.mainNet(); - } try { - await context.read().setNetwork(network); + await context.read().loadNetwork(); unawaited(context.read().fetchFromZero()); unawaited(context.read().fetchFromZero()); } catch (e, s) { diff --git a/lib/splash/cubit/splash_cubit.dart b/lib/splash/cubit/splash_cubit.dart index 37fef26a2..ac50991e2 100644 --- a/lib/splash/cubit/splash_cubit.dart +++ b/lib/splash/cubit/splash_cubit.dart @@ -51,11 +51,11 @@ class SplashCubit extends Cubit { if (hasWallet) { await homeCubit.emitHasWallet(); emit(state.copyWith(status: SplashStatus.routeToPassCode)); - if (Parameters.walletHandlesCrypto) { - unawaited( - homeCubit.periodicCheckRewardOnTezosBlockchain(), - ); - } + // if (Parameters.walletHandlesCrypto) { + // unawaited( + // homeCubit.periodicCheckRewardOnTezosBlockchain(), + // ); + // } } else { homeCubit.emitHasNoWallet(); emit(state.copyWith(status: SplashStatus.routeToOnboarding)); diff --git a/lib/wallet/cubit/wallet_cubit.dart b/lib/wallet/cubit/wallet_cubit.dart index 1bbfd38a4..8c1b4694f 100644 --- a/lib/wallet/cubit/wallet_cubit.dart +++ b/lib/wallet/cubit/wallet_cubit.dart @@ -350,7 +350,7 @@ class WalletCubit extends Cubit { /// If we are not using crypto in the wallet we are not generating /// AssociatedAddress credentials. final credential = Parameters.walletHandlesCrypto - ? await credentialsCubit.createAssociatedWalletCredential( + ? await credentialsCubit.createOrUpdateAssociatedWalletCredential( blockchainType: blockchainType, cryptoAccountData: cryptoAccountData, ) diff --git a/pubspec.lock b/pubspec.lock index d7842a94b..2b9705ed4 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -222,10 +222,10 @@ packages: dependency: transitive description: name: build_daemon - sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65" + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" url: "https://pub.dev" source: hosted - version: "4.0.0" + version: "4.0.1" build_resolvers: dependency: transitive description: @@ -856,10 +856,10 @@ packages: dependency: "direct main" description: name: flutter_chat_ui - sha256: d2b7d99fae88d17fdab13f4be3e6ae15c4ceaa5d3e199b61c254a67222d42611 + sha256: "6a4712026429d3b28547bd3d147ded44f8dd53dacc1ff14113693d7b7dd14382" url: "https://pub.dev" source: hosted - version: "1.6.9" + version: "1.6.10" flutter_dotenv: dependency: "direct main" description: @@ -1908,10 +1908,10 @@ packages: dependency: transitive description: name: provider - sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f + sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096" url: "https://pub.dev" source: hosted - version: "6.0.5" + version: "6.1.1" pub_semver: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4a58e4558..e28fdf028 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: altme description: AltMe Flutter App -version: 1.24.3+316 +version: 1.24.6+319 environment: sdk: ">=3.1.0 <4.0.0"