Skip to content

Commit

Permalink
Merge pull request #305 from 0xPolygonID/feature/PID-339_android_release
Browse files Browse the repository at this point in the history
Feature/pid 339 android release
  • Loading branch information
rauljareno authored May 19, 2023
2 parents d4a80bf + 123500f commit 1ae6c49
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 196 deletions.
200 changes: 60 additions & 140 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apply from: 'sdk.properties'

group 'io.github.0xpolygonid.polygonid_flutter_sdk'
version '2.2.0'
version sdkVersion

buildscript {
ext.kotlin_version = '1.8.0'
Expand Down Expand Up @@ -89,142 +91,60 @@ dependencies {
}

// Maven
//publishing {
// publications {
// release(MavenPublication) {
// pom {
// name = 'PolygonID Flutter SDK'
// description = 'PolygonID Flutter SDK.'
// url = 'https://polygon.technology/polygon-id'
// licenses {
// license {
// name = 'GNU AFFERO GENERAL PUBLIC LICENSE, Version 3.0'
// url = 'https://www.gnu.org/licenses/agpl-3.0.txt'
// }
// }
// developers {
// developer {
// name = 'Flavien Norindr'
// email = 'fnorindr@polygon.technology'
// }
// }
// scm {
// connection = 'scm:git@github.com:iden3/polygonid-flutter-sdk.git'
// developerConnection = 'scm:git@github.com:iden3/polygonid-flutter-sdk.git'
// url = 'https://github.com/iden3/polygonid-flutter-sdk/tree/main'
// }
// }
// }
// }
//}

//uploadArchives {
// repositories {
// mavenDeployer {
// beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
//
// repository(url: "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") {
// authentication(userName: ossrhUsername, password: ossrhPassword)
// }
//
// snapshotRepository(url: "https://s01.oss.sonatype.org/content/repositories/snapshots/") {
// authentication(userName: ossrhUsername, password: ossrhPassword)
// }
//
// pom.project {
// name 'PolygonID Flutter SDK'
// packaging 'aar'
// description 'The PolygonID Flutter SDK.'
// url 'https://polygon.technology/polygon-id'
//
// scm {
// connection 'scm:git@github.com:0xPolygonID/polygonid-flutter-sdk.git'
// developerConnection 'scm:git@github.com:0xPolygonID/polygonid-flutter-sdk.git'
// url 'https://github.com:0xPolygonID/polygonid-flutter-sdk.git'
// }
//
// licenses {
// license {
// name 'The Apache License, Version 2.0'
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// }
// license {
// name 'MIT License'
// url 'https://mit-license.org/'
// }
// }
//
// developers {
// developer {
// id 'flavien'
// name 'Flavien Norindr'
// email 'fnorindr@polygon.technology'
// organization 'Polygon'
// organizationUrl 'https://polygon.technology'
// }
// }
// }
// }
// }
//}

//task addToPom {
// dependsOn 'generatePomFileForReleasePublication'
// mustRunAfter 'generatePomFileForReleasePublication'
//
// doLast {
// def pomTask = tasks.getByName('generatePomFileForReleasePublication')
// def pom = pomTask.pom
// println "=========================================================================================================================================================================================================================================================================================================================================="
// println pomTask.destination
// println pomTask.actions
// println pom.name
// println pom.packaging
// println pom.licenses
// println "=========================================================================================================================================================================================================================================================================================================================================="
//
// pom.name.value('PolygonID Flutter SDK')
// pom.description.value('The SDK for PolygonID in Flutter.')
// pom.url.value('https://polygon.technology/polygon-id')
//
// pom.licenses {
// license {
// name = 'GNU AFFERO GENERAL PUBLIC LICENSE, Version 3.0'
// url = 'https://www.gnu.org/licenses/agpl-3.0.txt'
// }
// }
//
// pom.developers {
// developer {
// name = 'Flavien Norindr'
// email = 'fnorindr@polygon.technology'
// }
// }
//
// pom.scm {
// connection = 'scm:git@github.com:iden3/polygonid-flutter-sdk.git'
// developerConnection = 'scm:git@github.com:iden3/polygonid-flutter-sdk.git'
// url = 'https://github.com/iden3/polygonid-flutter-sdk/tree/main'
// }
//
// println "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
// tasks
// println "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
// }
//}

//tasks.named('generatePomFileForReleasePublication') {
// finalizedBy 'addToPom'
//}

//task listTasks {
// dependsOn 'tasks'
//}
//
//tasks.named('publish') {
// finalizedBy 'listTasks'
//}

//tasks.named('publish') {
// finalizedBy 'uploadArchives'
//}
publishing {
publications {
sdkDebug(MavenPublication) {
groupId = 'io.github.0xpolygonid.polygonid_flutter_sdk'
artifactId = 'polygonid_flutter_sdk_debug'
version = version

pom {
name = 'PolygonID Flutter SDK'
description = 'The Flutter SDK for PolygonID.'
url = 'https://polygon.technology/polygon-id'

licenses {
license {
name = 'Apache License 2.0'
url = 'http://www.apache.org/licenses/'
}
license {
name = 'MIT License'
url = 'https://mit-license.org/'
}
}

developers {
developer {
name = 'Flavien Norindr'
email = 'id@polygon.technology'
organization = 'Polygon'
organizationUrl = 'https://polygon.technology'
}
developer {
name = 'Emanuel Muroni'
email = 'id@polygon.technology'
organization = 'Polygon'
organizationUrl = 'https://polygon.technology'
}
developer {
name = 'Raùl Jareño'
email = 'id@polygon.technology'
organization = 'Polygon'
organizationUrl = 'https://polygon.technology'
}
}

scm {
connection = 'scm:git@github.com:0xPolygonID/polygonid-flutter-sdk.git'
developerConnection = 'scm:git@github.com:0xPolygonID/polygonid-flutter-sdk.git'
url = 'https://github.com/0xPolygonID/polygonid-flutter-sdk'
}
}

afterEvaluate {
from components.debug
}
}
}
}
3 changes: 3 additions & 0 deletions android/sdk.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ext {
sdkVersion = '2.2.5'
}
38 changes: 38 additions & 0 deletions lib/common/utils/number_extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extension ListRound on List {
List deepDoubleToInt() {
return map((value) {
if (value is Map<String, dynamic>) {
return value.deepDoubleToInt();
}

if (value is List) {
return value.deepDoubleToInt();
}

return value is double && !value.hasDecimals() ? value.floor() : value;
}).toList();
}
}

extension MapRound on Map<String, dynamic> {
Map<String, dynamic> deepDoubleToInt() {
return map((key, value) {
if (value is Map<String, dynamic>) {
return MapEntry(key, value.deepDoubleToInt());
}

if (value is List) {
return MapEntry(key, value.deepDoubleToInt());
}

return MapEntry(
key, value is double && !value.hasDecimals() ? value.floor() : value);
});
}
}

extension DoubleRound on double {
bool hasDecimals() {
return this % 1 != 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@

import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:polygonid_flutter_sdk/common/domain/domain_logger.dart';
import 'package:polygonid_flutter_sdk/common/utils/number_extension.dart';

class ProofScopeQueryRequest {
final List<String>? allowedIssuers;
Expand All @@ -109,6 +111,7 @@ class ProofScopeQueryRequest {
final int? challenge;
final bool? skipClaimRevocationCheck;
final Map<String, dynamic>? credentialSubject;

//final ProofScopeRulesQuerySchemaRequest? schema;

ProofScopeQueryRequest({
Expand All @@ -126,6 +129,8 @@ class ProofScopeQueryRequest {
/// @param [Map<String, dynamic>] json
/// @returns [ProofScopeRulesQueryRequest]
factory ProofScopeQueryRequest.fromJson(Map<String, dynamic>? json) {
logger().i("ProofScopeRulesQueryRequest.fromJson $json");

if (json != null) {
//ProofScopeRulesQuerySchemaRequest? schema =
// ProofScopeRulesQuerySchemaRequest.fromJson(json['schema']);
Expand All @@ -134,7 +139,11 @@ class ProofScopeQueryRequest {
context: json['context'],
type: json['type'],
challenge: json['challenge'],
credentialSubject: json['credentialSubject'],

/// FIXME: flooring doubles without decimals to ints, this is because of protobuf
/// only use number_value for google.protobuf.Value and turn int to float
credentialSubject: (json['credentialSubject'] as Map<String, dynamic>?)
?.deepDoubleToInt(),
skipClaimRevocationCheck: json['skipClaimRevocationCheck'],
);
//schema: schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ import '../../../../common/domain/domain_constants.dart';

class AddInteractionParam {
final String? genesisDid;
final BigInt? profileNonce;
final String? privateKey;
final InteractionBaseEntity interaction;

AddInteractionParam({
this.genesisDid,
this.profileNonce,
this.privateKey,
required this.interaction,
});
Expand All @@ -38,18 +36,11 @@ class AddInteractionUseCase
@override
Future<InteractionBaseEntity> execute(
{required AddInteractionParam param}) async {
// we check if profile is valid and identity is existing
if (param.genesisDid != null &&
param.profileNonce != null &&
param.privateKey != null) {
await _checkProfileValidityUseCase
.execute(
param:
CheckProfileValidityParam(profileNonce: param.profileNonce!))
.then((_) => _getIdentityUseCase.execute(
param: GetIdentityParam(
genesisDid: param.genesisDid!,
privateKey: param.privateKey)));
// we check if identity is existing
if (param.genesisDid != null && param.privateKey != null) {
await _getIdentityUseCase.execute(
param: GetIdentityParam(
genesisDid: param.genesisDid!, privateKey: param.privateKey));
}
return _interactionRepository
.addInteraction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import 'package:polygonid_flutter_sdk/identity/domain/use_cases/profile/check_pr

class RemoveInteractionsParam {
final String? genesisDid;
final BigInt? profileNonce;
final String? privateKey;
final List<String> ids;

RemoveInteractionsParam({
this.genesisDid,
this.profileNonce,
this.privateKey,
required this.ids,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class UpdateInteractionUseCase
return _addInteractionUseCase.execute(
param: AddInteractionParam(
genesisDid: param.genesisDid,
profileNonce: param.profileNonce,
privateKey: param.privateKey,
interaction: updatedInteraction));
} else {
Expand Down
Loading

0 comments on commit 1ae6c49

Please sign in to comment.