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 4, 2024
2 parents 067204c + a007192 commit e6e9339
Show file tree
Hide file tree
Showing 34 changed files with 374 additions and 198 deletions.
31 changes: 31 additions & 0 deletions lib/app/shared/enum/type/blockchain_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,37 @@ extension BlockchainTypeX on BlockchainType {
}
}

bool get supportWert {
switch (this) {
case BlockchainType.tezos:
case BlockchainType.ethereum:
case BlockchainType.polygon:
case BlockchainType.binance:
return true;

case BlockchainType.etherlink:
case BlockchainType.fantom:
return false;
}
}

// commodity, network, commodityId
(String, String, String) get commodityData {
switch (this) {
case BlockchainType.tezos:
return ('XTZ', 'tezos', 'xtz.simple.tezos');
case BlockchainType.ethereum:
return ('ETH', 'ethereum', 'eth.simple.ethereum');
case BlockchainType.polygon:
return ('POL', 'polygon', 'pol.simple.polygon');
case BlockchainType.binance:
return ('BNB', 'bsc', 'bnb.simple.bsc');
case BlockchainType.etherlink:
case BlockchainType.fantom:
return ('', '', '');
}
}

String get chain {
String name = '';
switch (this) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,13 +609,13 @@ extension CredentialSubjectTypeExtension on CredentialSubjectType {
case CredentialSubjectType.tezVoucher:
case CredentialSubjectType.diplomaCard:
case CredentialSubjectType.twitterCard:
return true;
case CredentialSubjectType.tezosAssociatedWallet:
case CredentialSubjectType.ethereumAssociatedWallet:
case CredentialSubjectType.fantomAssociatedWallet:
case CredentialSubjectType.polygonAssociatedWallet:
case CredentialSubjectType.binanceAssociatedWallet:
case CredentialSubjectType.etherlinkAssociatedWallet:
return true;
case CredentialSubjectType.walletCredential:
case CredentialSubjectType.tezosPooAddress:
case CredentialSubjectType.ethereumPooAddress:
Expand Down
14 changes: 13 additions & 1 deletion lib/app/shared/helper_functions/helper_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,19 @@ Map<String, dynamic> createJsonByDecryptingSDValues({
final content = sh256HashToContent[sdValue];
if (content is Map) {
content.forEach((key, value) {
json[key.toString()] = value;
if (value is Map<String, dynamic>) {
if (value.containsKey('_sd')) {
final nestedJson = createJsonByDecryptingSDValues(
selectiveDisclosure: selectiveDisclosure,
encryptedJson: value,
);
json[key.toString()] = nestedJson;
} else {
json[key.toString()] = value;
}
} else {
json[key.toString()] = value;
}
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/app/shared/models/blockchain_network/polygon_network.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class PolygonNetwork extends EthereumNetwork {
type: BlockchainType.polygon,
networkname: 'Testnet',
apiUrl: Urls.moralisBaseUrl,
chainId: 80001,
chain: 'mumbai',
rpcNodeUrl: 'https://rpc-mumbai.maticvigil.com',
title: 'Polygon Testnet (Mumbai)',
chainId: 80002,
chain: 'polygon amoy',
rpcNodeUrl: 'https://rpc-amoy.polygon.technology/',
title: 'Polygon Amoy Testnet',
subTitle: 'This network is used to test protocol upgrades'
' (do not use it unless you are a developer).',
);
Expand Down
3 changes: 1 addition & 2 deletions lib/credentials/cubit/credentials_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,7 @@ class CredentialsCubit extends Cubit<CredentialsState> {
}
}
} else if (credentialSubjectModel
.credentialSubjectType.isBlockchainAccount ||
credentialSubjectModel.credentialSubjectType.supportSingleOnly) {
.credentialSubjectType.supportSingleOnly) {
await deleteById(
id: storedCredential.id,
showMessage: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/dashboard/drawer/src/view/drawer_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DrawerView extends StatelessWidget {
const SizedBox(height: Sizes.spaceSmall),
],
DrawerCategoryItem(
title: l10n.walletSecurity,
title: l10n.walletSecurityAndBackup,
subTitle: l10n.walletSecurityDescription,
onClick: () {
Navigator.of(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Oidc4vcSettingMenuView extends StatelessWidget {
JsonViewerPage.route(
title: 'Wallet metadata for issuers',
data: value,
showButton: false,
),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class ClientTypeWidget extends StatelessWidget {
builder: (context, state) {
return OptionContainer(
title: 'Wallet Client_id Scheme',
subtitle: 'Pre-registered',
body: ListView.builder(
itemCount: ClientType.values.length,
shrinkWrap: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VCFormatWidget extends StatelessWidget {
return BlocBuilder<ProfileCubit, ProfileState>(
builder: (context, state) {
return OptionContainer(
title: 'VC Format"',
title: 'VC Format',
subtitle: 'Select one of the VC formats. Default: ldp_vc.',
body: ListView.builder(
itemCount: VCFormatType.values.length,
Expand All @@ -32,9 +32,9 @@ class VCFormatWidget extends StatelessWidget {
ListTile(
onTap: () {
context.read<ProfileCubit>().updateProfileSetting(
vcFormatType: vcFormatType,
formatsSupported: [vcFormatType],
);
vcFormatType: vcFormatType,
formatsSupported: [vcFormatType],
);
},
shape: RoundedRectangleBorder(
side: BorderSide(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:altme/app/app.dart';
import 'package:altme/dashboard/dashboard.dart';
import 'package:altme/oidc4vc/verify_encoded_data.dart';
import 'package:altme/polygon_id/polygon_id.dart';
import 'package:altme/selective_disclosure/selective_disclosure.dart';
import 'package:did_kit/did_kit.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
Expand Down Expand Up @@ -113,25 +112,25 @@ class CredentialDetailsCubit extends Cubit<CredentialDetailsState> {
final listOfSd = collectSdValues(data);

if (claims != null && listOfSd.isNotEmpty) {
final selectiveDisclosure = SelectiveDisclosure(item);
final decryptedDatas = selectiveDisclosure.contents;

/// check if sd already contain sh256 hash
for (final element in decryptedDatas) {
final sh256Hash = profileCubit.oidc4vc.sh256HashOfContent(element);

if (!listOfSd.contains(sh256Hash)) {
emit(
state.copyWith(
credentialStatus: CredentialStatus.invalidSignature,
status: AppStatus.idle,
statusListIndex: statusListIndex,
statusListUrl: statusListUri,
),
);
return;
}
}
// final selectiveDisclosure = SelectiveDisclosure(item);
// final decryptedDatas = selectiveDisclosure.contents;

// /// check if sd already contain sh256 hash
// for (final element in decryptedDatas) {
// final sh256Hash = profileCubit.oidc4vc.sh256HashOfContent(element);

// if (!listOfSd.contains(sh256Hash)) {
// emit(
// state.copyWith(
// credentialStatus: CredentialStatus.invalidSignature,
// status: AppStatus.idle,
// statusListIndex: statusListIndex,
// statusListUrl: statusListUri,
// ),
// );
// return;
// }
// }

/// check the status
final status = item.data['status'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ class _CredentialsDetailsViewState extends State<CredentialsDetailsView> {
],

/// credential manifest details
if (credentialManifestSupport &&
if (!isDeveloperMode &&
credentialManifestSupport &&
outputDescriptors != null) ...[
CredentialManifestDetails(
outputDescriptor: outputDescriptors.firstOrNull,
Expand Down Expand Up @@ -341,9 +342,10 @@ class _CredentialsDetailsViewState extends State<CredentialsDetailsView> {
// ],

//// wallet attestation data
if (widget.credentialModel.credentialPreview
.credentialSubjectModel
is WalletCredentialModel) ...[
if (!isDeveloperMode &&
widget.credentialModel.credentialPreview
.credentialSubjectModel
is WalletCredentialModel) ...[
WalletCredentialetailsWidget(
credentialModel: widget.credentialModel,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ class DeveloperDetails extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = context.l10n;

// final String issuerDid = credentialModel.credentialPreview.issuer;
// final String subjectDid =
// credentialModel.credentialPreview.credentialSubjectModel.id ?? '';
// final String type = credentialModel.credentialPreview.type.toString();

final titleColor = Theme.of(context).colorScheme.onSurface;
final valueColor = Theme.of(context).colorScheme.onSurface;

Expand Down Expand Up @@ -80,51 +75,6 @@ class DeveloperDetails extends StatelessWidget {
valueColor: valueColor,
showVertically: showVertically,
),
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.issuerDID,
// value: issuerDid,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// if (credentialModel.credentialPreview.credentialSubjectModel
// is! WalletCredentialModel &&
// subjectDid.isNotEmpty)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.subjectDID,
// value: subjectDid,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.type,
// value: type,
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: showVertically,
// ),
// if (statusListUri != null)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.statusList,
// value: statusListUri.toString(),
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: false,
// ),
// if (statusListIndex != null)
// CredentialField(
// padding: const EdgeInsets.only(top: 10),
// title: l10n.statusListIndex,
// value: statusListIndex.toString(),
// titleColor: titleColor,
// valueColor: valueColor,
// showVertically: false,
// ),
if (header != null)
CredentialField(
padding: const EdgeInsets.only(top: 10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class _HomeCredentialsListPageState extends State<HomeCredentialsListPage>
message = messageHandler.getMessage(context, messageHandler);
}

if (state.status == CredentialsStatus.loading) {
return const CredentialListShimmer();
} else if (state.status == CredentialsStatus.error) {
if (state.status == CredentialsStatus.error) {
return ErrorView(message: message, onTap: onRefresh);
} else {
return HomeCredentialCategoryList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ class _HomeCredentialCategoryListState
.toList();

if (!formatsSupported
.contains(element.getFormat) ||
element.getFormat == 'auto') {
.contains(element.getFormat) &&
element.getFormat != 'auto' &&
!formatsSupported.contains('auto')) {
return false;
}
}
Expand Down

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
Expand Up @@ -96,6 +96,57 @@ class CredentialManifestOfferPickView extends StatefulWidget {

class _CredentialManifestOfferPickViewState
extends State<CredentialManifestOfferPickView> {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
final isVcSdJWT = context
.read<CredentialManifestPickCubit>()
.state
.filteredCredentialList
.firstOrNull
?.getFormat ==
VCFormatType.vcSdJWT.vcValue;
if (isVcSdJWT) {
final element = context
.read<CredentialManifestPickCubit>()
.state
.filteredCredentialList;
final containsSingleElement = element.isNotEmpty && element.length == 1;
if (containsSingleElement) {
final PresentationDefinition? presentationDefinition = context
.read<CredentialManifestPickCubit>()
.state
.presentationDefinition;
if (presentationDefinition != null) {
context.read<CredentialManifestPickCubit>().toggle(
index: 0,
inputDescriptor: presentationDefinition
.inputDescriptors[widget.inputDescriptorIndex],
isVcSdJWT: isVcSdJWT,
);

final credentialManifestState =
context.read<CredentialManifestPickCubit>().state;
final firstOne = credentialManifestState
.filteredCredentialList[credentialManifestState.selected.first];

Navigator.of(context).pushReplacement<void, void>(
SelectiveDisclosurePickPage.route(
uri: widget.uri,
issuer: widget.issuer,
credential: widget.credential,
inputDescriptorIndex: widget.inputDescriptorIndex,
credentialsToBePresented: widget.credentialsToBePresented,
presentationDefinition: presentationDefinition,
selectedCredential: firstOne,
),
);
}
}
}
});
}

@override
Widget build(BuildContext context) {
Expand Down
Loading

0 comments on commit e6e9339

Please sign in to comment.