-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(app): Update the invalid pin error handling scenario #511
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #511 +/- ##
==========================================
+ Coverage 89.47% 89.48% +0.01%
==========================================
Files 93 93
Lines 3639 3643 +4
==========================================
+ Hits 3256 3260 +4
Misses 251 251
Partials 132 132
☔ View full report in Codecov by Sentry. |
demo/app/lib/views/otp.dart
Outdated
errorMessage = err.details!; | ||
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details); | ||
if(resp.category == "INVALID_GRANT"){ | ||
errorMessage = "Try re-entering the pin or scan the new QR code"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errorMessage = "Try re-entering the pin or scan the new QR code"; | |
errorMessage = "Try re-entering the PIN or scan a new QR code"; |
guard let localizedErrorMessage = arguments["localizedErrorMessage"] as? String else{ | ||
return result(FlutterError.init(code: "NATIVE_ERR", | ||
message: "error while parsing wallet sdk error", | ||
details: "parameter localizedErrorMessage is missed")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean localizedErrorMessage is missing
?
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message: "error while parsing wallet sdk error", | |
message: "error while parsing Wallet-SDK error", |
let parsedError = WalleterrorParse(localizedErrorMessage) | ||
|
||
var parsedErrorResult :[String:Any] = [ | ||
"category": parsedError!.category, | ||
"details": parsedError!.details, | ||
"code": parsedError!.code, | ||
"traceID": parsedError!.traceID | ||
] | ||
result(parsedErrorResult) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the force unwrap once on line 548 instead of on every line from 551-554? Like this:
let parsedError = WalleterrorParse(localizedErrorMessage)!
demo/app/lib/views/otp.dart
Outdated
if (err is PlatformException && | ||
err.message != null && | ||
err.message!.isNotEmpty) { | ||
errorMessage = err.details!; | ||
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details); | ||
if(resp.category == "INVALID_GRANT"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(resp.category == "INVALID_GRANT"){ | |
if (resp.category == "INVALID_GRANT"){ |
demo/app/lib/views/otp.dart
Outdated
if (err is PlatformException && | ||
err.message != null && | ||
err.message!.isNotEmpty) { | ||
errorMessage = err.details!; | ||
var resp = await WalletSDKPlugin.parseWalletSDKError(localizedErrorMessage: err.details); | ||
if(resp.category == "INVALID_GRANT"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's one more error category you can add a check for: INVALID_TOKEN
. In the case of INVALID_TOKEN
, however, re-entering the PIN won't help, so in that case the error message should just tell the user to scan a new QR code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall - I suggested some recommended UI text changes and another error code we can check for to improve the user experience, however I don't see any major issues.
b6a5a91
to
8205b92
Compare
demo/app/android/app/src/main/kotlin/walletsdk/flutter/app/MainActivity.kt
Outdated
Show resolved
Hide resolved
@@ -65,6 +66,12 @@ class WalletSDK extends WalletPlatform { | |||
} | |||
} | |||
|
|||
Future<WalletSDKError> parseWalletSDKError({required String localizedErrorMessage}) async { | |||
var parsedWalletError = await methodChannel.invokeMethod( | |||
'parseWalletSDKError', <String, dynamic>{'localizedErrorMessage': localizedErrorMessage}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this map be made more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean map of string , string ? Instead of dynamic
Other than that walletsdkerror is the object type we are rendering the object which we get from sdk.
I believe, It cant be more specific than that. I will change that if thats what u mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better: see if it can just be a simple string instead of a map
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final Map<String, dynamic> data = <String, dynamic>{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This map looks more generic than it needs to be
return data; | ||
} | ||
|
||
factory WalletSDKError.fromJson(Map<String, dynamic> json) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
a3897f6
to
bb01d0c
Compare
The commit says "iOS", but I see android code there too. Does this also add support for the Android app, or is that going to be a separate PR? |
Signed-off-by: Talwinder kaur <[email protected]>
Kudos, SonarCloud Quality Gate passed! |
Try re-entering the pin or scan the new QR code."
Things to fix: