Skip to content

Commit

Permalink
Merge branch 'main' into ALTME
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkbee1 committed Dec 11, 2024
2 parents e6e9339 + 1a11f43 commit 60f4489
Show file tree
Hide file tree
Showing 79 changed files with 1,582 additions and 1,075 deletions.
2 changes: 1 addition & 1 deletion lib/app/shared/constants/image_strings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ImageStrings {

static const String imagePath = 'assets/image';
static const String ebsiLogo = '$imagePath/ebsi_logo.png';
static const String diipLogo = '$imagePath/diipLogo.png';
//static const String diipLogo = '$imagePath/diipLogo.png';

static const String cardMissing = '$imagePath/card_missing.png';
static const String employmentCertificateFront =
Expand Down
2 changes: 2 additions & 0 deletions lib/app/shared/enum/status/app_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ enum AppStatus {
updateEnterpriseAccount,
replaceEnterpriseAccount,
restoreWallet,
successAdd,
successUpdate,
}
9 changes: 9 additions & 0 deletions lib/app/shared/extension/iterable_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ extension IterableExtension<E> on Iterable<E> {
}
return result;
}

int? indexWhereOrNull(bool Function(E) test) {
int index = 0;
for (final element in this) {
if (test(element)) return index;
index++;
}
return null;
}
}
103 changes: 103 additions & 0 deletions lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2315,3 +2315,106 @@ String generateP256KeyForDPop() {

return publicKeyForDPop;
}

Map<String, dynamic> getCredentialDataFromJson({
required String data,
required String format,
required JWTDecode jwtDecode,
required String credentialType,
}) {
late Map<String, dynamic> credential;

final jsonContent = jwtDecode.parseJwt(data);
if (format == VCFormatType.vcSdJWT.vcValue) {
final sdAlg = jsonContent['_sd_alg'] ?? 'sha-256';

if (sdAlg != 'sha-256') {
throw ResponseMessage(
data: {
'error': 'invalid_request',
'error_description': 'Only sha-256 is supported.',
},
);
}

credential = jsonContent;
} else {
credential = jsonContent['vc'] as Map<String, dynamic>;
}

if (format == VCFormatType.vcSdJWT.vcValue) {
/// type
if (!credential.containsKey('type')) {
credential['type'] = [credentialType];
}

///credentialSubject
if (!credential.containsKey('credentialSubject')) {
credential['credentialSubject'] = {'type': credentialType};
}
}

/// id -> jti
if (!credential.containsKey('id')) {
if (jsonContent.containsKey('jti')) {
credential['id'] = jsonContent['jti'];
} else {
credential['id'] = 'urn:uuid:${const Uuid().v4()}';
}
}

/// issuer -> iss
if (!credential.containsKey('issuer')) {
if (jsonContent.containsKey('iss')) {
credential['issuer'] = jsonContent['iss'];
} else {
throw ResponseMessage(
data: {
'error': 'unsupported_format',
'error_description': 'Issuer is missing',
},
);
}
}

/// issuanceDate -> iat
if (!credential.containsKey('issuanceDate')) {
if (jsonContent.containsKey('iat')) {
credential['issuanceDate'] = jsonContent['iat'].toString();
} else if (jsonContent.containsKey('issuanceDate')) {
credential['issuanceDate'] = jsonContent['issuanceDate'].toString();
}
}

/// expirationDate -> exp
if (!credential.containsKey('expirationDate')) {
if (jsonContent.containsKey('exp')) {
credential['expirationDate'] = jsonContent['exp'].toString();
} else if (jsonContent.containsKey('expirationDate')) {
credential['expirationDate'] = jsonContent['expirationDate'].toString();
}
}

/// cred,tailSubject.id -> sub
// if (newCredential['id'] == null) {
// newCredential['id'] = 'urn:uuid:${const Uuid().v4()}';
// }

// if (newCredential['credentialPreview']['id'] == null) {
// newCredential['credentialPreview']['id'] =
// 'urn:uuid:${const Uuid().v4()}';
// }

credential['jwt'] = data;

return credential;
}

bool isContract(String reciever) {
// check if it smart contract or not
// smart contarct address start with KT1
if (reciever.startsWith('tz')) return false;
if (reciever.startsWith('KT1')) return true;
return false;
}
4 changes: 2 additions & 2 deletions lib/app/shared/widget/wallet_logo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class WalletLogo extends StatelessWidget {
switch (profileModel.profileType) {
case ProfileType.custom:
case ProfileType.defaultOne:
case ProfileType.diipv3:
image = flavorCubit.state == FlavorMode.development
? ImageStrings.appLogoDev
: flavorCubit.state == FlavorMode.staging
Expand All @@ -45,8 +46,7 @@ class WalletLogo extends StatelessWidget {
: generalOptions.companyLogo;

//case ProfileType.diipv2point1:
case ProfileType.diipv3:
image = ImageStrings.diipLogo;
//image = ImageStrings.diipLogo;
}

return Column(
Expand Down
1 change: 1 addition & 0 deletions lib/app/view/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class App extends StatelessWidget {
create: (context) => ManageNetworkCubit(
secureStorageProvider: secureStorageProvider,
walletCubit: context.read<WalletCubit>(),
profileCubit: context.read<ProfileCubit>(),
),
),
BlocProvider<PolygonIdCubit>(
Expand Down
2 changes: 2 additions & 0 deletions lib/chat_room/cubit/chat_room_cubit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/connection_bridge/beacon/cubit/beacon_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class BeaconCubit extends Cubit<BeaconState> {
debounce?.cancel();
}

debounce = Timer(const Duration(seconds: 1), () {
debounce = Timer(const Duration(seconds: 2), () {
switch (beaconRequest.type) {
case RequestType.permission:
emit(
Expand Down
10 changes: 9 additions & 1 deletion lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
Future<void> addWalletCredential({
required BlockchainType? blockchainType,
required QRCodeScanCubit qrCodeScanCubit,
required Uri uri,
}) async {
final log = getLogger('addRequiredCredentials');

Expand Down Expand Up @@ -195,6 +196,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
credential: walletCredential,
showMessage: false,
blockchainType: blockchainType,
uri: uri,
);
}
}
Expand Down Expand Up @@ -291,6 +293,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {

Future<void> insertCredential({
required CredentialModel credential,
required Uri uri,
required BlockchainType? blockchainType,
bool showMessage = true,
bool showStatus = true,
Expand Down Expand Up @@ -356,7 +359,11 @@ class CredentialsCubit extends Cubit<CredentialsState> {
await activityLogManager.saveLog(
LogData(
type: LogType.addVC,
vcInfo: VCInfo(id: credential.id, name: credential.getName),
vcInfo: VCInfo(
id: credential.id,
name: credential.getName,
domain: uri.host,
),
),
);

Expand Down Expand Up @@ -584,6 +591,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
credential: credential,
blockchainType: cryptoAccountData.blockchainType,
showMessage: false,
uri: Uri.parse(Parameters.walletIssuer),
);
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/kyc_verification/kyc_verification.dart';
import 'package:altme/l10n/l10n.dart';
import 'package:confetti/confetti.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -155,7 +154,6 @@ class SuccessWidget extends StatelessWidget {
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.normal,
color: Theme.of(context).colorScheme.onTertiary,
),
),
),
Expand Down Expand Up @@ -237,34 +235,30 @@ class FailureWidget extends StatelessWidget {
);
},
),
const SizedBox(
height: Sizes.spaceNormal,
),
MyElevatedButton(
text: l10n.kyc,
verticalSpacing: 16,
borderRadius: Sizes.largeRadius,
onPressed: () async {
await securityCheck(
context: context,
title: l10n.typeYourPINCodeToAuthenticate,
localAuthApi: LocalAuthApi(),
onSuccess: () {
context
.read<KycVerificationCubit>()
.startKycVerifcation(vcType: KycVcType.verifiableId);
},
);
await Navigator.pushAndRemoveUntil<void>(
context,
DashboardPage.route(),
(Route<dynamic> route) => route.isFirst,
);
},
),
const SizedBox(
height: Sizes.spaceNormal,
),
const SizedBox(height: Sizes.spaceNormal),
// MyElevatedButton(
// text: l10n.kyc,
// verticalSpacing: 16,
// borderRadius: Sizes.largeRadius,
// onPressed: () async {
// await securityCheck(
// context: context,
// title: l10n.typeYourPINCodeToAuthenticate,
// localAuthApi: LocalAuthApi(),
// onSuccess: () {
// context
// .read<KycVerificationCubit>()
// .startKycVerifcation(vcType: KycVcType.verifiableId);
// },
// );
// await Navigator.pushAndRemoveUntil<void>(
// context,
// DashboardPage.route(),
// (Route<dynamic> route) => route.isFirst,
// );
// },
// ),
// const SizedBox(height: Sizes.spaceNormal),
MyElevatedButton(
text: l10n.decline,
verticalSpacing: 16,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions lib/dashboard/connection/operation/view/operation_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class _OperationViewState extends State<OperationView> {
late String reciever;
late String? symbol;

bool isSmartContract = false;

final BeaconRequest? beaconRequest =
context.read<BeaconCubit>().state.beaconRequest;

Expand All @@ -134,6 +136,8 @@ class _OperationViewState extends State<OperationView> {
sender = tezosOperationDetails!.first.source!;
reciever = tezosOperationDetails.first.destination!;
}

if (isContract(reciever)) isSmartContract = true;
} else if (transaction != null) {
symbol = state.cryptoAccountData?.blockchainType.symbol;
sender = transaction.from!.toString();
Expand Down Expand Up @@ -247,7 +251,7 @@ class _OperationViewState extends State<OperationView> {
MyElevatedButton(
verticalSpacing: 15,
borderRadius: Sizes.normalRadius,
text: l10n.send,
text: isSmartContract ? l10n.confirm : l10n.send,
onPressed: state.status != AppStatus.idle
? null
: () {
Expand All @@ -259,7 +263,7 @@ class _OperationViewState extends State<OperationView> {
const SizedBox(height: 8),
MyOutlinedButton(
borderRadius: Sizes.normalRadius,
text: l10n.cancel,
text: isSmartContract ? l10n.reject : l10n.cancel,
onPressed: () {
context.read<OperationCubit>().rejectOperation(
connectionBridgeType: widget.connectionBridgeType,
Expand Down
2 changes: 2 additions & 0 deletions lib/dashboard/connection/rights/cubit/rights_cubit.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 60f4489

Please sign in to comment.