Skip to content

Commit

Permalink
Merge pull request #311 from 0xPolygonID/feature/update_dart_3
Browse files Browse the repository at this point in the history
Feature/update dart 3
  • Loading branch information
Plumillon authored May 22, 2023
2 parents c0b00ed + 1dae933 commit 680f05b
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 135 deletions.
4 changes: 0 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ analyzer:
prefer_final_fields: ignore
unused_element: ignore
unused_local_variable: ignore
null_argument_to_non_null_type: ignore
unnecessary_import: ignore
unused_import: ignore
unused_field: ignore
camel_case_types: ignore
no_leading_underscores_for_local_identifiers: ignore
unnecessary_new: ignore
unnecessary_null_comparison: ignore
override_on_non_overriding_member: ignore
prefer_typing_uninitialized_variables: ignore
prefer_interpolation_to_compose_strings: ignore
avoid_print: ignore
prefer_double_quotes: ignore
depend_on_referenced_packages: ignore
annotate_overrides: ignore
Expand Down
4 changes: 0 additions & 4 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,14 @@ analyzer:
prefer_final_fields: ignore
unused_element: ignore
unused_local_variable: ignore
null_argument_to_non_null_type: ignore
unnecessary_import: ignore
unused_import: ignore
unused_field: ignore
camel_case_types: ignore
no_leading_underscores_for_local_identifiers: ignore
unnecessary_new: ignore
unnecessary_null_comparison: ignore
override_on_non_overriding_member: ignore
prefer_typing_uninitialized_variables: ignore
prefer_interpolation_to_compose_strings: ignore
avoid_print: ignore
prefer_double_quotes: ignore
annotate_overrides: ignore
depend_on_referenced_packages: ignore
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
6 changes: 0 additions & 6 deletions example/lib/src/presentation/ui/auth/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
String? did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey, blockchain: 'polygon', network: 'mumbai');

if (did == null) {
emit(const AuthState.error(
"an identity is needed before trying to authenticate"));
return;
}

try {
await _polygonIdSdk.iden3comm.authenticate(
message: iden3message,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BackupIdentityBloc
network: env.network,
);

if (genesisDid == null || genesisDid.isEmpty) {
if (genesisDid.isEmpty) {
emit(const BackupIdentityState.error(
"without an identity is impossible to do the backup"));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ class ClaimDetailBloc extends Bloc<ClaimDetailEvent, ClaimDetailState> {
return;
}

String? did = await _polygonIdSdk.identity.getDidIdentifier(
final String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey, blockchain: 'polygon', network: 'mumbai');

if (did != null) {
await _polygonIdSdk.credential.removeClaims(
claimIds: [event.claimId], genesisDid: did, privateKey: privateKey);
emit(const ClaimDetailState.claimDeleted());
} else {
emit(const ClaimDetailState.error(CustomStrings.claimRemovingError));
}
await _polygonIdSdk.credential.removeClaims(
claimIds: [event.claimId],
genesisDid: did,
privateKey: privateKey,
);

emit(const ClaimDetailState.claimDeleted());
} catch (_) {
emit(const ClaimDetailState.error(CustomStrings.claimRemovingError));
}
Expand Down
20 changes: 10 additions & 10 deletions example/lib/src/presentation/ui/claims/claims_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ class ClaimsBloc extends Bloc<ClaimsEvent, ClaimsState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null || did.isEmpty) {
if (did.isEmpty) {
emit(const ClaimsState.error(
"without an identity is impossible to remove credential"));
return;
Expand Down Expand Up @@ -143,13 +143,13 @@ class ClaimsBloc extends Bloc<ClaimsEvent, ClaimsState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null || did.isEmpty) {
if (did.isEmpty) {
emit(const ClaimsState.error(
"without an identity is impossible to remove credential"));
return;
Expand Down Expand Up @@ -188,13 +188,13 @@ class ClaimsBloc extends Bloc<ClaimsEvent, ClaimsState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null || did.isEmpty) {
if (did.isEmpty) {
emit(const ClaimsState.error(
"without an identity is impossible to remove credential"));
return;
Expand Down Expand Up @@ -229,13 +229,13 @@ class ClaimsBloc extends Bloc<ClaimsEvent, ClaimsState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null || did.isEmpty) {
if (did.isEmpty) {
emit(const ClaimsState.error(
"without an identity is impossible to remove claims"));
return;
Expand Down Expand Up @@ -354,13 +354,13 @@ class ClaimsBloc extends Bloc<ClaimsEvent, ClaimsState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null || did.isEmpty) {
if (did.isEmpty) {
emit(const ClaimsState.error(
"without an identity is impossible to remove all claims"));
return;
Expand Down
8 changes: 1 addition & 7 deletions example/lib/src/presentation/ui/home/home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,12 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {

EnvEntity env = await _polygonIdSdk.getEnv();

String? did = await _polygonIdSdk.identity.getDidIdentifier(
String did = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (did == null) {
emit(const HomeState.error(
message: "cannot delete identity without identifier"));
return;
}

try {
await _polygonIdSdk.identity
.removeIdentity(genesisDid: did, privateKey: privateKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,9 @@ class _CameraViewState extends State<CameraView> {
///
void _openDropDown() {
_dropdownKey.currentContext?.visitChildElements((element) {
if (element.widget != null && element.widget is Semantics) {
if (element.widget is Semantics) {
element.visitChildElements((element) {
if (element.widget != null && element.widget is Actions) {
if (element.widget is Actions) {
element.visitChildElements((element) {
Actions.invoke(element, const ActivateIntent());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class RestoreIdentityBloc

EnvEntity env = await _polygonIdSdk.getEnv();

String? genesisDid = await _polygonIdSdk.identity.getDidIdentifier(
String genesisDid = await _polygonIdSdk.identity.getDidIdentifier(
privateKey: privateKey,
blockchain: env.blockchain,
network: env.network,
);

if (genesisDid == null || genesisDid.isEmpty) {
if (genesisDid.isEmpty) {
emit(const RestoreIdentityState.error(
"without an identity is impossible to restore the backup"));
return;
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2.2.2+23050202


environment:
sdk: ">=2.17.0 <3.0.0"
sdk: ">=2.17.0 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
Expand Down Expand Up @@ -47,15 +47,15 @@ dependencies:
google_mlkit_barcode_scanning: ^0.5.0
camera: ^0.10.3+2
image_picker: ^0.8.7
envied: ^0.3.0
envied: ^0.3.0+3

dev_dependencies:
integration_test:
sdk: flutter
flutter_test:
sdk: flutter
mockito: ^5.3.2
envied_generator: ^0.3.0
envied_generator: ^0.3.0+3
build_runner: ^2.3.3
json_serializable: ^6.6.1
freezed: ^2.3.2
Expand Down
42 changes: 16 additions & 26 deletions lib/common/domain/tuples.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ class Pair<M, N> {

@override
bool operator ==(Object other) {
return (other == null && this == null ||
other != null &&
other is Pair &&
first == other.first &&
second == other.second);
return other is Pair && first == other.first && second == other.second;
}

@override
Expand All @@ -30,12 +26,10 @@ class Triple<M, N, O> {

@override
bool operator ==(Object other) {
return (other == null && this == null ||
other != null &&
other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third);
return other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third;
}

@override
Expand All @@ -55,13 +49,11 @@ class Quadruple<M, N, O, P> {

@override
bool operator ==(Object other) {
return (other == null && this == null ||
other != null &&
other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third &&
fourth == other.fourth);
return other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third &&
fourth == other.fourth;
}

@override
Expand All @@ -84,14 +76,12 @@ class Quintuple<M, N, O, P, Q> {

@override
bool operator ==(Object other) {
return (other == null && this == null ||
other != null &&
other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third &&
fourth == other.fourth &&
fifth == other.fifth);
return other is Quintuple &&
first == other.first &&
second == other.second &&
third == other.third &&
fourth == other.fourth &&
fifth == other.fifth;
}

@override
Expand Down
8 changes: 0 additions & 8 deletions lib/common/utils/hex_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ class HexUtils {
}

static Uint8List hexToBuffer(String source) {
// Source
print(source.length.toString() +
': "' +
source +
'" (' +
source.runes.length.toString() +
')');

// String (Dart uses UTF-16) to bytes
List<int> list = [];
for (var rune in source.runes) {
Expand Down
11 changes: 5 additions & 6 deletions lib/common/utils/uint8_list_utils.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:ffi';
import 'dart:io';
import 'dart:typed_data';

import 'package:ffi/ffi.dart';
Expand Down Expand Up @@ -57,7 +56,7 @@ class Uint8ArrayUtils {
r = r >> 8;
}
if (r != BigInt.zero) {
throw new ArgumentError("Number does not fit in this length");
throw ArgumentError("Number does not fit in this length");
}
return buff;
}
Expand All @@ -74,7 +73,7 @@ class Uint8ArrayUtils {
r = r >> 8;
}
if (r == BigInt.zero) {
throw new ArgumentError("Number does not fit in this length");
throw ArgumentError("Number does not fit in this length");
}
return buff;
}
Expand All @@ -86,7 +85,7 @@ class Uint8ArrayUtils {
for (int i = end - 1; i >= start; i--) {
result = result * 256 + bytes[i];
}
return new BigInt.from(result);
return BigInt.from(result);
}
int mid = start + ((end - start) >> 1);
var result = read(start, mid) +
Expand All @@ -101,8 +100,8 @@ class Uint8ArrayUtils {
static Uint8List bigIntToBytes(BigInt number) {
// Not handling negative numbers. Decide how you want to do that.
int bytes = (number.bitLength + 7) >> 3;
var b256 = new BigInt.from(256);
var result = new Uint8List(bytes);
var b256 = BigInt.from(256);
var result = Uint8List(bytes);
for (int i = 0; i < bytes; i++) {
result[i] = number.remainder(b256).toInt();
number = number >> 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class GetIden3commClaimsUseCase
)))
.then(
(claims) async {
if (claims == null || claims.isEmpty) {
if (claims.isEmpty) {
return null;
}
if (request.scope.query.skipClaimRevocationCheck == null ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class GetProofQueryContextUseCase
@override
Future<Map<String, dynamic>> execute(
{required ProofScopeRequest param}) async {
String? schemaUrl = param.query.context!;
String schemaUrl = param.query.context!;

if (schemaUrl != null && schemaUrl.isNotEmpty) {
if (schemaUrl.isNotEmpty) {
return _iden3commCredentialRepository
.fetchSchema(url: schemaUrl)
.catchError((error) => <String, dynamic>{});
Expand Down
Loading

0 comments on commit 680f05b

Please sign in to comment.