Skip to content

Commit

Permalink
feat(app): Update the invalid pin error handling scenario
Browse files Browse the repository at this point in the history
Signed-off-by: Talwinder kaur <[email protected]>
  • Loading branch information
Talwinder kaur committed Jul 25, 2023
1 parent 1f6dc9f commit b6a5a91
Show file tree
Hide file tree
Showing 7 changed files with 286 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,6 @@ class MainActivity : FlutterActivity() {
}
}

"fetchDID" -> {
try {
val didID = call.argument<String>("didID")
} catch (e: Exception) {
result.error("Exception", "Error while setting fetched DID", e)
}
}

"serializeDisplayData" -> {
try {
val credentialDisplay = serializeDisplayData(call)
Expand Down Expand Up @@ -164,6 +156,15 @@ class MainActivity : FlutterActivity() {
}
}

"parseWalletError" -> {
try {
val parsedWalletError = parseWalletSDKError(call)
result.success(parsedWalletError)
} catch (e: Exception) {
result.error("Exception", "Error while parsing wallet sdk error", e)
}
}

"getIssuerID" -> {
try {
val issuerID = getIssuerID(call)
Expand Down Expand Up @@ -400,7 +401,19 @@ class MainActivity : FlutterActivity() {
}


private fun parseWalletSDKError(call: MethodCall): MutableMap<String, Any> {
val localizedErrorMessage = call.argument<String>("localizedErrorMessage") ?: throw java.lang.Exception("localizedErrorMessage is missed")

val parsedError = Walleterror.parse(localizedErrorMessage)

val parsedErrResp: MutableMap<String, Any> = mutableMapOf()
parsedErrResp["category"] = parsedError.category
parsedErrResp["details"] = parsedError.details
parsedErrResp["code"] = parsedError.code
parsedErrResp["traceID"] = parsedError.traceID

return parsedErrResp
}
/**
* ResolveDisplay resolves display information for issued credentials based on an issuer's metadata, which is fetched
using the issuer's (base) URI. The CredentialDisplays returns DisplayData object correspond to the VCs passed in and are in the
Expand Down
25 changes: 24 additions & 1 deletion demo/app/ios/Runner/flutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin {
let otp = fetchArgsKeyValue(call, key: "otp")
requestCredential(otp: otp!, result: result)

case "parseWalletSDKError":
parseWalletSDKError(arguments: arguments!, result: result)

case "requestCredentialWithAuth":
let redirectURIWithParams = fetchArgsKeyValue(call, key: "redirectURIWithParams")
requestCredentialWithAuth(redirectURIWithParams: redirectURIWithParams!, result: result)
Expand Down Expand Up @@ -528,12 +531,32 @@ public class SwiftWalletSDKPlugin: NSObject, FlutterPlugin {
vcCredentials: convertToVerifiableCredentialsArray(credentials: vcCredentials))
result(displayDataResp)
} catch let error as NSError {
let parsedError = WalleterrorParse(error.localizedDescription)
return result(FlutterError.init(code: "Exception",
message: "error while resolving credential",
details: error.localizedDescription))
details: parsedError))

}
}

public func parseWalletSDKError(arguments: Dictionary<String, Any>, result: @escaping FlutterResult){
guard let localizedErrorMessage = arguments["localizedErrorMessage"] as? String else{
return result(FlutterError.init(code: "NATIVE_ERR",
message: "error while parsing Wallet-SDK error",
details: "localizedErrorMessage is missing"))
}
let parsedError = WalleterrorParse(localizedErrorMessage)!

var parsedErrorResult :[String:Any] = [
"category": parsedError.category,
"details": parsedError.details,
"code": parsedError.code,
"traceID": parsedError.traceID
]
result(parsedErrorResult)
}


public func resolveCredentialDisplay(arguments: Dictionary<String, Any>, result: @escaping FlutterResult){


Expand Down
5 changes: 2 additions & 3 deletions demo/app/lib/views/credential_shared.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:app/widgets/success_card.dart';
import 'package:flutter/material.dart';
import 'package:app/models/credential_data.dart';
import 'package:app/widgets/credential_card.dart';
Expand Down Expand Up @@ -57,12 +56,12 @@ class CredentialSharedState extends State<CredentialShared> {
Image.asset('lib/assets/images/success.png')
],
),
title: Text('Success',textAlign: TextAlign.left, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
title: const Text('Success',textAlign: TextAlign.left, style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold)),
subtitle: Text("Credentials have been shared with ${widget.verifierName}", style: const TextStyle(fontSize: 14, fontWeight: FontWeight.normal)),
),
Expanded(
child: ListView.builder(
padding: EdgeInsets.only(left: 24, right:24, top: 24, bottom: 8),
padding: const EdgeInsets.only(left: 24, right:24, top: 24, bottom: 8),
itemCount: widget.credentialData.length,
itemBuilder: (BuildContext context, int index) {
return CredentialCard(credentialData: widget.credentialData[index], isDashboardWidget: true, isDetailArrowRequired: false,);
Expand Down
2 changes: 1 addition & 1 deletion demo/app/lib/views/custom_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import 'package:flutter/material.dart';

import '../widgets/common_title_appbar.dart';
import 'package:app/widgets/common_title_appbar.dart';

class CustomError extends StatefulWidget {
final String requestErrorTitleMsg;
Expand Down
Loading

0 comments on commit b6a5a91

Please sign in to comment.